]> git.baikalelectronics.ru Git - kernel.git/commitdiff
arch: fix broken BuildID for arm64 and riscv
authorMasahiro Yamada <masahiroy@kernel.org>
Mon, 26 Dec 2022 18:45:37 +0000 (03:45 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 25 Feb 2023 10:25:42 +0000 (11:25 +0100)
commit fe15ce495a511c71ffb78121ce0b6d8ca33dc5fd upstream.

Dennis Gilmore reports that the BuildID is missing in the arm64 vmlinux
since commit 47547576d4c3 ("arm64: remove special treatment for the
link order of head.o").

The issue is that the type of .notes section, which contains the BuildID,
changed from NOTES to PROGBITS.

Ard Biesheuvel figured out that whichever object gets linked first gets
to decide the type of a section. The PROGBITS type is the result of the
compiler emitting .note.GNU-stack as PROGBITS rather than NOTE.

While Ard provided a fix for arm64, I want to fix this globally because
the same issue is happening on riscv since commit 72506fddc7f8 ("riscv:
remove special treatment for the link order of head.o"). This problem
will happen in general for other architectures if they start to drop
unneeded entries from scripts/head-object-list.txt.

Discard .note.GNU-stack in include/asm-generic/vmlinux.lds.h.

Link: https://lore.kernel.org/lkml/CAABkxwuQoz1CTbyb57n0ZX65eSYiTonFCU8-LCQc=74D=xE=rA@mail.gmail.com/
Fixes: 47547576d4c3 ("arm64: remove special treatment for the link order of head.o")
Fixes: 72506fddc7f8 ("riscv: remove special treatment for the link order of head.o")
Reported-by: Dennis Gilmore <dennis@ausil.us>
Suggested-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: Tom Saeger <tom.saeger@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/asm-generic/vmlinux.lds.h

index 3dc5824141cd229a55962dc55c9e0613a1b9aa9f..7ad6f51b3d914e081876bf230c940a68a9a70fee 100644 (file)
 #define PRINTK_INDEX
 #endif
 
+/*
+ * Discard .note.GNU-stack, which is emitted as PROGBITS by the compiler.
+ * Otherwise, the type of .notes section would become PROGBITS instead of NOTES.
+ */
 #define NOTES                                                          \
+       /DISCARD/ : { *(.note.GNU-stack) }                              \
        .notes : AT(ADDR(.notes) - LOAD_OFFSET) {                       \
                __start_notes = .;                                      \
                KEEP(*(.note.*))                                        \