[PATCH 5.15 5.10 5.4 1/1] arm64: fix Build ID if CONFIG_MODVERSIONS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Backport of: 0d362be5b142 ("Makefile: link with -z noexecstack --no-warn-rwx-segments")
breaks arm64 Build ID when CONFIG_MODVERSIONS=y.

CONFIG_MODVERSIONS adds extra tooling to calculate symbol versions.
This kernel's KBUILD tooling uses both
relocatable (-r) and (-z noexecstack) to link head.o
which results in ld adding a .note.GNU-stack section.
Final linking of vmlinux should add a .NOTES segment containing the
Build ID, but does NOT if head.o has a .note.GNU-stack section.

Selectively remove -z noexecstack from head.o's KBUILD_LDFLAGS to
prevent .note.GNU-stack from being added to head.o.  Final link of
vmlinux then properly adds .NOTES segment containing Build ID that can
be read using tools like 'readelf -n'.

Cc: <stable@xxxxxxxxxxxxxxx> # 5.15, 5.10, 5.4
Signed-off-by: Tom Saeger <tom.saeger@xxxxxxxxxx>
---
 arch/arm64/kernel/Makefile | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
index 749e31475e41..8bdee0f655e2 100644
--- a/arch/arm64/kernel/Makefile
+++ b/arch/arm64/kernel/Makefile
@@ -85,3 +85,8 @@ extra-y					+= $(head-y) vmlinux.lds
 ifeq ($(CONFIG_DEBUG_EFI),y)
 AFLAGS_head.o += -DVMLINUX_PATH="\"$(realpath $(objtree)/vmlinux)\""
 endif
+
+ifeq ($(CONFIG_MODVERSIONS),y)
+# filter-out -z noexecstack for head.S
+$(obj)/head.o: KBUILD_LDFLAGS := $(shell echo "$(KBUILD_LDFLAGS)" | sed -e 's/-z\s\+noexecstack//')
+endif
-- 
2.38.1




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux