]>
Commit | Line | Data |
---|---|---|
45d80ddf SL |
1 | From a1da6d1e5f14f5e40065d031a53ced0395d1b4b0 Mon Sep 17 00:00:00 2001 |
2 | From: Alistair Strachan <astrachan@google.com> | |
3 | Date: Fri, 3 Aug 2018 10:39:31 -0700 | |
4 | Subject: x86: vdso: Use $LD instead of $CC to link | |
5 | ||
6 | The vdso{32,64}.so can fail to link with CC=clang when clang tries to find | |
7 | a suitable GCC toolchain to link these libraries with. | |
8 | ||
9 | /usr/bin/ld: arch/x86/entry/vdso/vclock_gettime.o: | |
10 | access beyond end of merged section (782) | |
11 | ||
12 | This happens because the host environment leaked into the cross compiler | |
13 | environment due to the way clang searches for suitable GCC toolchains. | |
14 | ||
15 | Clang is a retargetable compiler, and each invocation of it must provide | |
16 | --target=<something> --gcc-toolchain=<something> to allow it to find the | |
17 | correct binutils for cross compilation. These flags had been added to | |
18 | KBUILD_CFLAGS, but the vdso code uses CC and not KBUILD_CFLAGS (for various | |
19 | reasons) which breaks clang's ability to find the correct linker when cross | |
20 | compiling. | |
21 | ||
22 | Most of the time this goes unnoticed because the host linker is new enough | |
23 | to work anyway, or is incompatible and skipped, but this cannot be reliably | |
24 | assumed. | |
25 | ||
26 | This change alters the vdso makefile to just use LD directly, which | |
27 | bypasses clang and thus the searching problem. The makefile will just use | |
28 | ${CROSS_COMPILE}ld instead, which is always what we want. This matches the | |
29 | method used to link vmlinux. | |
30 | ||
31 | This drops references to DISABLE_LTO; this option doesn't seem to be set | |
32 | anywhere, and not knowing what its possible values are, it's not clear how | |
33 | to convert it from CC to LD flag. | |
34 | ||
35 | Signed-off-by: Alistair Strachan <astrachan@google.com> | |
36 | Signed-off-by: Thomas Gleixner <tglx@linutronix.de> | |
37 | Acked-by: Andy Lutomirski <luto@kernel.org> | |
38 | Cc: "H. Peter Anvin" <hpa@zytor.com> | |
39 | Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
40 | Cc: kernel-team@android.com | |
41 | Cc: joel@joelfernandes.org | |
42 | Cc: Andi Kleen <andi.kleen@intel.com> | |
43 | Link: https://lkml.kernel.org/r/20180803173931.117515-1-astrachan@google.com | |
44 | Signed-off-by: Nathan Chancellor <natechancellor@gmail.com> | |
45 | Signed-off-by: Sasha Levin <sashal@kernel.org> | |
46 | --- | |
47 | arch/x86/entry/vdso/Makefile | 22 +++++++++------------- | |
48 | 1 file changed, 9 insertions(+), 13 deletions(-) | |
49 | ||
50 | diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile | |
51 | index d5409660f5de..2ae92c6b1de6 100644 | |
52 | --- a/arch/x86/entry/vdso/Makefile | |
53 | +++ b/arch/x86/entry/vdso/Makefile | |
54 | @@ -47,10 +47,8 @@ targets += $(vdso_img_sodbg) | |
55 | ||
56 | export CPPFLAGS_vdso.lds += -P -C | |
57 | ||
58 | -VDSO_LDFLAGS_vdso.lds = -m64 -Wl,-soname=linux-vdso.so.1 \ | |
59 | - -Wl,--no-undefined \ | |
60 | - -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096 \ | |
61 | - $(DISABLE_LTO) | |
62 | +VDSO_LDFLAGS_vdso.lds = -m elf_x86_64 -soname linux-vdso.so.1 --no-undefined \ | |
63 | + -z max-page-size=4096 -z common-page-size=4096 | |
64 | ||
65 | $(obj)/vdso64.so.dbg: $(src)/vdso.lds $(vobjs) FORCE | |
66 | $(call if_changed,vdso) | |
67 | @@ -96,10 +94,8 @@ CFLAGS_REMOVE_vvar.o = -pg | |
68 | # | |
69 | ||
70 | CPPFLAGS_vdsox32.lds = $(CPPFLAGS_vdso.lds) | |
71 | -VDSO_LDFLAGS_vdsox32.lds = -Wl,-m,elf32_x86_64 \ | |
72 | - -Wl,-soname=linux-vdso.so.1 \ | |
73 | - -Wl,-z,max-page-size=4096 \ | |
74 | - -Wl,-z,common-page-size=4096 | |
75 | +VDSO_LDFLAGS_vdsox32.lds = -m elf32_x86_64 -soname linux-vdso.so.1 \ | |
76 | + -z max-page-size=4096 -z common-page-size=4096 | |
77 | ||
78 | # 64-bit objects to re-brand as x32 | |
79 | vobjs64-for-x32 := $(filter-out $(vobjs-nox32),$(vobjs-y)) | |
80 | @@ -127,7 +123,7 @@ $(obj)/vdsox32.so.dbg: $(src)/vdsox32.lds $(vobjx32s) FORCE | |
81 | $(call if_changed,vdso) | |
82 | ||
83 | CPPFLAGS_vdso32.lds = $(CPPFLAGS_vdso.lds) | |
84 | -VDSO_LDFLAGS_vdso32.lds = -m32 -Wl,-m,elf_i386 -Wl,-soname=linux-gate.so.1 | |
85 | +VDSO_LDFLAGS_vdso32.lds = -m elf_i386 -soname linux-gate.so.1 | |
86 | ||
87 | # This makes sure the $(obj) subdirectory exists even though vdso32/ | |
88 | # is not a kbuild sub-make subdirectory. | |
89 | @@ -165,13 +161,13 @@ $(obj)/vdso32.so.dbg: FORCE \ | |
90 | # The DSO images are built using a special linker script. | |
91 | # | |
92 | quiet_cmd_vdso = VDSO $@ | |
93 | - cmd_vdso = $(CC) -nostdlib -o $@ \ | |
94 | + cmd_vdso = $(LD) -nostdlib -o $@ \ | |
95 | $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \ | |
96 | - -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \ | |
97 | + -T $(filter %.lds,$^) $(filter %.o,$^) && \ | |
98 | sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@' | |
99 | ||
100 | -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=both) \ | |
101 | - $(call cc-ldoption, -Wl$(comma)--build-id) -Wl,-Bsymbolic $(LTO_CFLAGS) | |
102 | +VDSO_LDFLAGS = -shared $(call ld-option, --hash-style=both) \ | |
103 | + $(call ld-option, --build-id) -Bsymbolic | |
104 | GCOV_PROFILE := n | |
105 | ||
106 | # | |
107 | -- | |
108 | 2.19.1 | |
109 |