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 <[email protected]>
Suggested-by: Andrii Nakryiko <[email protected]>
Signed-off-by: Alyssa Ross <[email protected]>
Signed-off-by: Andrii Nakryiko <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Acked-by: Daniel Borkmann <[email protected]>
Closes: https://lore.kernel.org/bpf/[email protected]/
Link: https://lore.kernel.org/bpf/[email protected]
  • Loading branch information
alyssais authored and borkmann committed Dec 21, 2023
1 parent 9299924 commit 812d8bf
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 812d8bf

Please sign in to comment.