From: Alyssa Ross Date: Tue, 19 Dec 2023 11:03:24 +0000 (+0100) Subject: libbpf: Skip DWARF sections in linker sanity check X-Git-Tag: v6.8-rc1~131^2~75^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=812d8bf87678f77055b575d20636fdbbbf15edaf;p=thirdparty%2Fkernel%2Flinux.git libbpf: Skip DWARF sections in linker sanity check 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 Suggested-by: Andrii Nakryiko Signed-off-by: Alyssa Ross Signed-off-by: Andrii Nakryiko Signed-off-by: Daniel Borkmann Acked-by: Daniel Borkmann Closes: https://lore.kernel.org/bpf/ZXcFRJVKbKxtEL5t@nz.home/ Link: https://lore.kernel.org/bpf/20231219110324.8989-1-hi@alyssa.is --- diff --git a/tools/lib/bpf/linker.c b/tools/lib/bpf/linker.c index 52a2901e8bd0e..16bca56002ab3 100644 --- a/tools/lib/bpf/linker.c +++ b/tools/lib/bpf/linker.c @@ -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,