Skip to content

Commit bd71558

Browse files
sulixrichardweinberger
authored andcommitted
arch: um: Mark the stack non-executable to fix a binutils warning
Since binutils 2.39, ld will print a warning if any stack section is executable, which is the default for stack sections on files without a .note.GNU-stack section. This was fixed for x86 in commit ffcf9c5 ("x86: link vdso and boot with -z noexecstack --no-warn-rwx-segments"), but remained broken for UML, resulting in several warnings: /usr/bin/ld: warning: arch/x86/um/vdso/vdso.o: missing .note.GNU-stack section implies executable stack /usr/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker /usr/bin/ld: warning: .tmp_vmlinux.kallsyms1 has a LOAD segment with RWX permissions /usr/bin/ld: warning: .tmp_vmlinux.kallsyms1.o: missing .note.GNU-stack section implies executable stack /usr/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker /usr/bin/ld: warning: .tmp_vmlinux.kallsyms2 has a LOAD segment with RWX permissions /usr/bin/ld: warning: .tmp_vmlinux.kallsyms2.o: missing .note.GNU-stack section implies executable stack /usr/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker /usr/bin/ld: warning: vmlinux has a LOAD segment with RWX permissions Link both the VDSO and vmlinux with -z noexecstack, fixing the warnings about .note.GNU-stack sections. In addition, pass --no-warn-rwx-segments to dodge the remaining warnings about LOAD segments with RWX permissions in the kallsyms objects. (Note that this flag is apparently not available on lld, so hide it behind a test for BFD, which is what the x86 patch does.) Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ffcf9c5700e49c0aee42dcba9a12ba21338e8136 Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=ba951afb99912da01a6e8434126b8fac7aa75107 Signed-off-by: David Gow <[email protected]> Reviewed-by: Lukas Straub <[email protected]> Tested-by: Lukas Straub <[email protected]> Acked-by: Randy Dunlap <[email protected]> # build-tested Signed-off-by: Richard Weinberger <[email protected]>
1 parent 2975e4a commit bd71558

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

arch/um/Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,18 @@ export LDS_ELF_FORMAT := $(ELF_FORMAT)
132132
# The wrappers will select whether using "malloc" or the kernel allocator.
133133
LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc
134134

135+
# Avoid binutils 2.39+ warnings by marking the stack non-executable and
136+
# ignorning warnings for the kallsyms sections.
137+
LDFLAGS_EXECSTACK = -z noexecstack
138+
ifeq ($(CONFIG_LD_IS_BFD),y)
139+
LDFLAGS_EXECSTACK += $(call ld-option,--no-warn-rwx-segments)
140+
endif
141+
135142
LD_FLAGS_CMDLINE = $(foreach opt,$(KBUILD_LDFLAGS),-Wl,$(opt))
136143

137144
# Used by link-vmlinux.sh which has special support for um link
138145
export CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE)
146+
export LDFLAGS_vmlinux := $(LDFLAGS_EXECSTACK)
139147

140148
# When cleaning we don't include .config, so we don't include
141149
# TT or skas makefiles and don't clean skas_ptregs.h.

arch/x86/um/vdso/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ quiet_cmd_vdso = VDSO $@
6565
-Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
6666
sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
6767

68-
VDSO_LDFLAGS = -fPIC -shared -Wl,--hash-style=sysv
68+
VDSO_LDFLAGS = -fPIC -shared -Wl,--hash-style=sysv -z noexecstack
6969
GCOV_PROFILE := n
7070

7171
#

0 commit comments

Comments
 (0)