Skip to content

Commit

Permalink
libbpf: Skip DWARF sections in linker sanity check
Browse files Browse the repository at this point in the history
clang can generate (with -g -Wa,--compress-debug-sections) 4-byte
aligned DWARF sections that declare themselves to be 8-byte aligned in
the section header.  Since DWARF sections are dropped during linking
anyway, just skip running the sanity checks on them.

Reported-by: Sergei Trofimovich <slyich@gmail.com>
Suggested-by: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Signed-off-by: Alyssa Ross <hi@alyssa.is>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20231219110324.8989-1-hi@alyssa.is

Closes: https://lore.kernel.org/bpf/ZXcFRJVKbKxtEL5t@nz.home/
  • Loading branch information
alyssais authored and anakryiko committed Dec 20, 2023
1 parent 9299924 commit a4897b8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tools/lib/bpf/linker.c
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,9 @@ static int linker_sanity_check_elf(struct src_obj *obj)
return -EINVAL;
}

if (is_dwarf_sec_name(sec->sec_name))
continue;

if (sec->shdr->sh_addralign && !is_pow_of_2(sec->shdr->sh_addralign)) {
pr_warn("ELF section #%zu alignment %llu is non pow-of-2 alignment in %s\n",
sec->sec_idx, (long long unsigned)sec->shdr->sh_addralign,
Expand Down

0 comments on commit a4897b8

Please sign in to comment.