diff options
author | Alan Maguire <alan.maguire@oracle.com> | 2024-06-24 21:29:03 +0200 |
---|---|---|
committer | Andrii Nakryiko <andrii@kernel.org> | 2024-06-27 01:38:59 +0200 |
commit | 0f31c2c61f6923747628c65a0fe36b2d4d7e21b0 (patch) | |
tree | 12f2bebc7c7747f1b0c4a3f4e956c808bf1a22bd /tools/lib/subcmd/pager.c | |
parent | selftests/bpf: Don't close(-1) in serial_test_fexit_stress() (diff) | |
download | linux-0f31c2c61f6923747628c65a0fe36b2d4d7e21b0.tar.xz linux-0f31c2c61f6923747628c65a0fe36b2d4d7e21b0.zip |
libbpf: Fix clang compilation error in btf_relocate.c
When building with clang for ARCH=i386, the following errors are
observed:
CC kernel/bpf/btf_relocate.o
./tools/lib/bpf/btf_relocate.c:206:23: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
206 | info[id].needs_size = true;
| ^ ~
./tools/lib/bpf/btf_relocate.c:256:25: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
256 | base_info.needs_size = true;
| ^ ~
2 errors generated.
The problem is we use 1-bit, 31-bit bitfields in a signed int.
Changing to
bool needs_size: 1;
unsigned int size:31;
...resolves the error and pahole reports that 4 bytes are used
for the underlying representation:
$ pahole btf_name_info tools/lib/bpf/btf_relocate.o
struct btf_name_info {
const char * name; /* 0 8 */
unsigned int needs_size:1; /* 8: 0 4 */
unsigned int size:31; /* 8: 1 4 */
__u32 id; /* 12 4 */
/* size: 16, cachelines: 1, members: 4 */
/* last cacheline: 16 bytes */
};
Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20240624192903.854261-1-alan.maguire@oracle.com
Diffstat (limited to 'tools/lib/subcmd/pager.c')
0 files changed, 0 insertions, 0 deletions