From fc68781822bd6f71d3148ec95fbf1e3e305dc8e8 Mon Sep 17 00:00:00 2001 From: Lorenz Bauer Date: Fri, 3 Nov 2023 13:51:17 +0000 Subject: [PATCH] program: fix LINUX_HAS_SYSCALL_WRAPPER use with bpf_tracing.h bpf_tracing.h defines LINUX_HAS_SYSCALL_WRAPPER as a boolean: extern _Bool LINUX_HAS_SYSCALL_WRAPPER __kconfig; Our kconfig fixup code currently expects a uint32 and therefore bails out with the following error: resolve .kconfig: variable LINUX_HAS_SYSCALL_WRAPPER must be a 32 bits integer, got Int:"_Bool" Fix this by changing the code to expect a one byte integer instead. A cursory search on Sourcegraph shows no open source users of uint32. This makes sense since the variable is meant to be consumed via the macros from bpf_tracing.h. Signed-off-by: Lorenz Bauer --- collection.go | 8 ++++---- testdata/kconfig-eb.elf | Bin 2032 -> 2056 bytes testdata/kconfig-el.elf | Bin 2032 -> 2056 bytes testdata/kconfig.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/collection.go b/collection.go index ac7108e62..54f7adc59 100644 --- a/collection.go +++ b/collection.go @@ -626,17 +626,17 @@ func resolveKconfig(m *MapSpec) error { internal.NativeEndian.PutUint32(data[vsi.Offset:], kv.Kernel()) case "LINUX_HAS_SYSCALL_WRAPPER": - if integer, ok := v.Type.(*btf.Int); !ok || integer.Size != 4 { - return fmt.Errorf("variable %s must be a 32 bits integer, got %s", n, v.Type) + if integer, ok := v.Type.(*btf.Int); !ok || integer.Size != 1 { + return fmt.Errorf("variable %s must be a 8 bit integer, got %v", n, v.Type) } - var value uint32 = 1 + var value uint8 = 1 if err := haveSyscallWrapper(); errors.Is(err, ErrNotSupported) { value = 0 } else if err != nil { return fmt.Errorf("unable to derive a value for LINUX_HAS_SYSCALL_WRAPPER: %w", err) } - internal.NativeEndian.PutUint32(data[vsi.Offset:], value) + data[vsi.Offset] = value default: // Catch CONFIG_*. configs[n] = configInfo{ diff --git a/testdata/kconfig-eb.elf b/testdata/kconfig-eb.elf index 776c8485f2707e667ca9d2ee4e8bc1da268a9180..c1f1494f2724c6118f72f386fec5fa27c389cbb7 100644 GIT binary patch delta 234 zcmeys-ytwTkBOCIqJaZr;lx5E&MyoM3?Te&;+#1yj6enuFtRW(Z~*DUd|)mEH;`fi z;=BA18YIdEB7gv>lz|7#0_p?O&nD+EUSy4T%FoZ4yn#h}ayXM9Bg5o$rW#%gpsX|y zCowRXFirl*A~TtXd9&gJpa?S*11W|#K+KBZGqP-cz?{#>m^?XvbwA^V$pUQcjK3z& nU^8dDF!=(TJ!8XU0d_kk7KX_I?DmWalP3T<%p8+1uqyxnAATzn delta 195 zcmeAW_`p9wkBQ~OL<5J30Rj^nggKuuFff4di-~jQnD7A^K)?jW*ZCoAkQf(;00I^u z<_5DM><5!;7%xr^X40PAz*Nm>F!>MDZN&>fd1fdEDZK;4tVsMXn}0CpGctNl&S2fo zIAgK~TRY>E$s5?r8Fx&6!Di2xFY~qvmv#T>PeVF`$T>${% CF)G~v diff --git a/testdata/kconfig-el.elf b/testdata/kconfig-el.elf index 8cd4ebd29609d21cc986855559f7d55da598d6f3..f8eb619225c329332f51d82c84c0baba84c20017 100644 GIT binary patch delta 222 zcmeys-ytwTgNcK6qLv$D;lx6D&MyoM3?Te&;><;MjEq1Q2Ll7kVIU0zeB3~S35f4P zXnr8Yzy%_JfCY$oz$^v^kiKV=Ga0Y2#yjQb=S<$fB0V{rNsy6YaynBbqs8QhOxKkj zK-Dq>X%K#c#AgMvSr|9pV$Ne^OrGq?x}R~wWKOnr#$S^svY9hpn0%7Wp0QyvC%gUR e`K%n11K2HC6F}BaHe?l^ynr3(A?C@a*wp}-bSr@X delta 186 zcmeAW_`p9wgXsgyL@l?80Rj^n1UR2CFff4di-|KA>G3fESs;8JLh}PD1}+c*1S~+z z4Q4^u4<=VKUYQ)sq&>NTse;j9@=vDgN*AE=%s?81?;!D6f$T2~n?EtE$t&5+8Fx&6$Y#%&F