aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlistair Strachan <astrachan@google.com>2018-08-03 13:39:31 -0400
committerThomas Gleixner <tglx@linutronix.de>2018-08-05 16:33:50 -0400
commit379d98ddf41344273d9718556f761420f4dc80b3 (patch)
treeeebf30181fb7687a8f13d3be359616d908195046
parent1ffaddd029c867d134a1dde39f540dcc8c52e274 (diff)
x86: vdso: Use $LD instead of $CC to link
The vdso{32,64}.so can fail to link with CC=clang when clang tries to find a suitable GCC toolchain to link these libraries with. /usr/bin/ld: arch/x86/entry/vdso/vclock_gettime.o: access beyond end of merged section (782) This happens because the host environment leaked into the cross compiler environment due to the way clang searches for suitable GCC toolchains. Clang is a retargetable compiler, and each invocation of it must provide --target=<something> --gcc-toolchain=<something> to allow it to find the correct binutils for cross compilation. These flags had been added to KBUILD_CFLAGS, but the vdso code uses CC and not KBUILD_CFLAGS (for various reasons) which breaks clang's ability to find the correct linker when cross compiling. Most of the time this goes unnoticed because the host linker is new enough to work anyway, or is incompatible and skipped, but this cannot be reliably assumed. This change alters the vdso makefile to just use LD directly, which bypasses clang and thus the searching problem. The makefile will just use ${CROSS_COMPILE}ld instead, which is always what we want. This matches the method used to link vmlinux. This drops references to DISABLE_LTO; this option doesn't seem to be set anywhere, and not knowing what its possible values are, it's not clear how to convert it from CC to LD flag. Signed-off-by: Alistair Strachan <astrachan@google.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Andy Lutomirski <luto@kernel.org> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: kernel-team@android.com Cc: joel@joelfernandes.org Cc: Andi Kleen <andi.kleen@intel.com> Link: https://lkml.kernel.org/r/20180803173931.117515-1-astrachan@google.com
-rw-r--r--arch/x86/entry/vdso/Makefile22
1 files changed, 9 insertions, 13 deletions
diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
index 261802b1cc50..42c6c1bea4f4 100644
--- a/arch/x86/entry/vdso/Makefile
+++ b/arch/x86/entry/vdso/Makefile
@@ -46,10 +46,8 @@ targets += $(vdso_img_sodbg) $(vdso_img-y:%=vdso%.so)
46 46
47CPPFLAGS_vdso.lds += -P -C 47CPPFLAGS_vdso.lds += -P -C
48 48
49VDSO_LDFLAGS_vdso.lds = -m64 -Wl,-soname=linux-vdso.so.1 \ 49VDSO_LDFLAGS_vdso.lds = -m elf_x86_64 -soname linux-vdso.so.1 --no-undefined \
50 -Wl,--no-undefined \ 50 -z max-page-size=4096 -z common-page-size=4096
51 -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096 \
52 $(DISABLE_LTO)
53 51
54$(obj)/vdso64.so.dbg: $(obj)/vdso.lds $(vobjs) FORCE 52$(obj)/vdso64.so.dbg: $(obj)/vdso.lds $(vobjs) FORCE
55 $(call if_changed,vdso) 53 $(call if_changed,vdso)
@@ -95,10 +93,8 @@ CFLAGS_REMOVE_vvar.o = -pg
95# 93#
96 94
97CPPFLAGS_vdsox32.lds = $(CPPFLAGS_vdso.lds) 95CPPFLAGS_vdsox32.lds = $(CPPFLAGS_vdso.lds)
98VDSO_LDFLAGS_vdsox32.lds = -Wl,-m,elf32_x86_64 \ 96VDSO_LDFLAGS_vdsox32.lds = -m elf32_x86_64 -soname linux-vdso.so.1 \
99 -Wl,-soname=linux-vdso.so.1 \ 97 -z max-page-size=4096 -z common-page-size=4096
100 -Wl,-z,max-page-size=4096 \
101 -Wl,-z,common-page-size=4096
102 98
103# x32-rebranded versions 99# x32-rebranded versions
104vobjx32s-y := $(vobjs-y:.o=-x32.o) 100vobjx32s-y := $(vobjs-y:.o=-x32.o)
@@ -123,7 +119,7 @@ $(obj)/vdsox32.so.dbg: $(obj)/vdsox32.lds $(vobjx32s) FORCE
123 $(call if_changed,vdso) 119 $(call if_changed,vdso)
124 120
125CPPFLAGS_vdso32.lds = $(CPPFLAGS_vdso.lds) 121CPPFLAGS_vdso32.lds = $(CPPFLAGS_vdso.lds)
126VDSO_LDFLAGS_vdso32.lds = -m32 -Wl,-m,elf_i386 -Wl,-soname=linux-gate.so.1 122VDSO_LDFLAGS_vdso32.lds = -m elf_i386 -soname linux-gate.so.1
127 123
128targets += vdso32/vdso32.lds 124targets += vdso32/vdso32.lds
129targets += vdso32/note.o vdso32/system_call.o vdso32/sigreturn.o 125targets += vdso32/note.o vdso32/system_call.o vdso32/sigreturn.o
@@ -157,13 +153,13 @@ $(obj)/vdso32.so.dbg: FORCE \
157# The DSO images are built using a special linker script. 153# The DSO images are built using a special linker script.
158# 154#
159quiet_cmd_vdso = VDSO $@ 155quiet_cmd_vdso = VDSO $@
160 cmd_vdso = $(CC) -nostdlib -o $@ \ 156 cmd_vdso = $(LD) -nostdlib -o $@ \
161 $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \ 157 $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \
162 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \ 158 -T $(filter %.lds,$^) $(filter %.o,$^) && \
163 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@' 159 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
164 160
165VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=both) \ 161VDSO_LDFLAGS = -shared $(call ld-option, --hash-style=both) \
166 $(call cc-ldoption, -Wl$(comma)--build-id) -Wl,-Bsymbolic $(LTO_CFLAGS) 162 $(call ld-option, --build-id) -Bsymbolic
167GCOV_PROFILE := n 163GCOV_PROFILE := n
168 164
169# 165#