Skip to content

Commit 3effc06

Browse files
jpbruckerAlexei Starovoitov
authored andcommitted
selftests/bpf: Fix alignment of .BTF_ids
Fix a build failure on arm64, due to missing alignment information for the .BTF_ids section: resolve_btfids.test.o: in function `test_resolve_btfids': tools/testing/selftests/bpf/prog_tests/resolve_btfids.c:140:(.text+0x29c): relocation truncated to fit: R_AARCH64_LDST32_ABS_LO12_NC against `.BTF_ids' ld: tools/testing/selftests/bpf/prog_tests/resolve_btfids.c:140: warning: one possible cause of this error is that the symbol is being referenced in the indicated code as if it had a larger alignment than was declared where it was defined In vmlinux, the .BTF_ids section is aligned to 4 bytes by vmlinux.lds.h. In test_progs however, .BTF_ids doesn't have alignment constraints. The arm64 linker expects the btf_id_set.cnt symbol, a u32, to be naturally aligned but finds it misaligned and cannot apply the relocation. Enforce alignment of .BTF_ids to 4 bytes. Fixes: cd04b04 ("selftests/bpf: Add set test to resolve_btfids") Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Jiri Olsa <jolsa@redhat.com> Link: https://lore.kernel.org/bpf/20200930093559.2120126-1-jean-philippe@linaro.org
1 parent f4d385e commit 3effc06

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tools/testing/selftests/bpf/prog_tests/resolve_btfids.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ struct symbol test_symbols[] = {
2828
{ "func", BTF_KIND_FUNC, -1 },
2929
};
3030

31+
/* Align the .BTF_ids section to 4 bytes */
32+
asm (
33+
".pushsection " BTF_IDS_SECTION " ,\"a\"; \n"
34+
".balign 4, 0; \n"
35+
".popsection; \n");
36+
3137
BTF_ID_LIST(test_list_local)
3238
BTF_ID_UNUSED
3339
BTF_ID(typedef, S)

0 commit comments

Comments
 (0)