libbpf: Skip DWARF sections in linker sanity check
authorAlyssa Ross <hi@alyssa.is>
Tue, 19 Dec 2023 11:03:24 +0000 (12:03 +0100)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 21 Dec 2023 09:05:15 +0000 (10:05 +0100)
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>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Closes: https://lore.kernel.org/bpf/ZXcFRJVKbKxtEL5t@nz.home/
Link: https://lore.kernel.org/bpf/20231219110324.8989-1-hi@alyssa.is
tools/lib/bpf/linker.c

index 52a2901e8bd0ec75467040593aee552c8f9524d0..16bca56002ab3570833d315475811221800152df 100644 (file)
@@ -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,