linux_dsm_epyc7002/arch/mips
Nathan Chancellor 2ff906994b MIPS: VDSO: Use $(LD) instead of $(CC) to link VDSO
Currently, the VDSO is being linked through $(CC). This does not match
how the rest of the kernel links objects, which is through the $(LD)
variable.

When clang is built in a default configuration, it first attempts to use
the target triple's default linker then the system's default linker,
unless told otherwise through -fuse-ld=... We do not use -fuse-ld=
because it can be brittle and we have support for invoking $(LD)
directly. See commit fe00e50b2d ("ARM: 8858/1: vdso: use $(LD)
instead of $(CC) to link VDSO") and commit 691efbedc6 ("arm64: vdso:
use $(LD) instead of $(CC) to link VDSO") for examples of doing this in
the VDSO.

Do the same thing here. Replace the custom linking logic with $(cmd_ld)
and ldflags-y so that $(LD) is respected. We need to explicitly add two
flags to the linker that were implicitly passed by the compiler:
-G 0 (which comes from ccflags-vdso) and --eh-frame-hdr.

Before this patch (generated by adding '-v' to VDSO_LDFLAGS):

<gcc_prefix>/libexec/gcc/mips64-linux/9.3.0/collect2 \
-plugin <gcc_prefix>/libexec/gcc/mips64-linux/9.3.0/liblto_plugin.so \
-plugin-opt=<gcc_prefix>/libexec/gcc/mips64-linux/9.3.0/lto-wrapper \
-plugin-opt=-fresolution=/tmp/ccGEi5Ka.res \
--eh-frame-hdr \
-G 0 \
-EB \
-mips64r2 \
-shared \
-melf64btsmip \
-o arch/mips/vdso/vdso.so.dbg.raw \
-L<gcc_prefix>/lib/gcc/mips64-linux/9.3.0/64 \
-L<gcc_prefix>/lib/gcc/mips64-linux/9.3.0 \
-L<gcc_prefix>/lib/gcc/mips64-linux/9.3.0/../../../../mips64-linux/lib \
-Bsymbolic \
--no-undefined \
-soname=linux-vdso.so.1 \
-EB \
--hash-style=sysv \
--build-id \
-T arch/mips/vdso/vdso.lds \
arch/mips/vdso/elf.o \
arch/mips/vdso/vgettimeofday.o \
arch/mips/vdso/sigreturn.o

After this patch:

<gcc_prefix>/bin/mips64-linux-ld \
-m elf64btsmip \
-Bsymbolic \
--no-undefined \
-soname=linux-vdso.so.1 \
-EB \
-nostdlib \
-shared \
-G 0 \
--eh-frame-hdr \
--hash-style=sysv \
--build-id \
-T  arch/mips/vdso/vdso.lds \
arch/mips/vdso/elf.o \
arch/mips/vdso/vgettimeofday.o
arch/mips/vdso/sigreturn.o \
-o arch/mips/vdso/vdso.so.dbg.raw

Note that we leave behind -mips64r2. Turns out that ld ignores it (see
get_emulation in ld/ldmain.c). This is true of current trunk and 2.23,
which is the minimum supported version for the kernel:

https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=ld/ldmain.c;hb=aa4209e7b679afd74a3860ce25659e71cc4847d5#l593
https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=ld/ldmain.c;hb=a55e30b51bc6227d8d41f707654d0a5620978dcf#l641

Before this patch, LD=ld.lld did nothing:

$ llvm-readelf -p.comment arch/mips/vdso/vdso.so.dbg | sed 's/(.*//'
String dump of section '.comment':
[     0] ClangBuiltLinux clang version 11.0.0

After this patch, it does:

$ llvm-readelf -p.comment arch/mips/vdso/vdso.so.dbg | sed 's/(.*//'
String dump of section '.comment':
[     0] Linker: LLD 11.0.0
[    62] ClangBuiltLinux clang version 11.0.0

Link: https://github.com/ClangBuiltLinux/linux/issues/785
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
2020-05-12 10:02:00 +02:00
..
alchemy MIPS: Use fallthrough for arch/mips 2020-05-07 11:55:47 +02:00
ar7 MIPS: Use fallthrough for arch/mips 2020-05-07 11:55:47 +02:00
ath25 MIPS: Replace setup_irq() by request_irq() 2020-03-05 16:47:35 +01:00
ath79 MIPS: Use fallthrough for arch/mips 2020-05-07 11:55:47 +02:00
bcm47xx MIPS: BCM47XX: Add support for Netgear R6200 V1 2019-07-25 22:10:05 -07:00
bcm63xx MIPS: Use fallthrough for arch/mips 2020-05-07 11:55:47 +02:00
bmips MIPS: BMIPS: Replace <linux/clk-provider.h> by <linux/of_clk.h> 2020-02-19 10:36:02 -08:00
boot MIPS: Truncate link address into 32bit for 32bit kernel 2020-05-07 10:31:01 +02:00
cavium-octeon MIPS: Use fallthrough for arch/mips 2020-05-07 11:55:47 +02:00
cobalt MIPS: Replace setup_irq() by request_irq() 2020-03-05 16:47:35 +01:00
configs MIPS: Remove NEC MARKEINS/EMMA 2020-05-09 18:05:57 +02:00
crypto crypto: {arm,arm64,mips}/poly1305 - remove redundant non-reduction from emit 2020-01-16 15:18:12 +08:00
dec MIPS: asm: Rename some macros to avoid build errors 2020-05-07 13:20:05 +02:00
fw MIPS: CFE: Remove dead code in cfe_getfwinfo() 2020-05-07 10:29:42 +02:00
generic MIPS: generic: Replace <linux/clk-provider.h> by <linux/of_clk.h> 2020-02-19 10:36:07 -08:00
include MIPS: Remove NEC MARKEINS/EMMA 2020-05-09 18:05:57 +02:00
jazz MIPS: Replace setup_irq() by request_irq() 2020-03-05 16:47:35 +01:00
jz4740 MIPS: ingenic: Replace <linux/clk-provider.h> by <linux/of_clk.h> 2020-05-07 11:59:55 +02:00
kernel MIPS: Replace zero-length array with flexible-array 2020-05-08 12:01:02 +02:00
kvm MIPS: Use fallthrough for arch/mips 2020-05-07 11:55:47 +02:00
lantiq remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
lib MIPS: do not compile generic functions for CONFIG_CAVIUM_OCTEON_SOC 2020-03-25 16:07:13 +01:00
loongson2ef mips: loongsoon2ef: remove private clk api 2020-04-16 17:34:23 +02:00
loongson32 MIPS: Replace setup_irq() by request_irq() 2020-03-05 16:47:35 +01:00
loongson64 MIPS: Loongson: Add DMA support for LS7A 2020-05-08 12:00:07 +02:00
math-emu MIPS: Use fallthrough for arch/mips 2020-05-07 11:55:47 +02:00
mm MIPS: unexport __flush_icache_user_range 2020-05-11 17:59:47 +02:00
mti-malta MIPS: Replace setup_irq() by request_irq() 2020-03-05 16:47:35 +01:00
net MIPS: BPF: Use sizeof_field() instead of FIELD_SIZEOF() 2020-01-10 11:33:35 -08:00
netlogic MIPS: Netlogic: remove unneeded semicolon in fmn_message_handler() 2020-04-19 16:05:19 +02:00
oprofile MIPS: Use fallthrough for arch/mips 2020-05-07 11:55:47 +02:00
paravirt mips: unify prom_putchar() declarations 2018-07-17 09:40:17 -07:00
pci MIPS: Remove NEC MARKEINS/EMMA 2020-05-09 18:05:57 +02:00
pic32 MIPS: pic32mzda: Drop pointless static qualifier 2020-02-28 12:44:39 +01:00
pistachio MIPS: Pistachio: Replace <linux/clk-provider.h> by <linux/of_clk.h> 2020-02-19 10:36:21 -08:00
pnx833x A batch of MIPS fixes: 2019-06-08 13:09:31 -07:00
power mips: check for dsp presence only once before save/restore 2019-10-07 10:58:53 -07:00
ralink MIPS: ralink: mt7621: Fix soc_device introduction 2020-03-28 17:26:36 +01:00
rb532 remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
sgi-ip22 MIPS: Replace setup_irq() by request_irq() 2020-03-05 16:47:35 +01:00
sgi-ip27 mfd: ioc3: Add driver for SGI IOC3 chip 2020-01-09 15:30:59 -08:00
sgi-ip30 MIPS: SGI-IP30: Check for valid pointer before using it 2020-01-22 10:15:45 -08:00
sgi-ip32 MIPS: Replace setup_irq() by request_irq() 2020-03-05 16:47:35 +01:00
sibyte treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
sni MIPS: pass non-NULL dev_id on shared request_irq() 2020-03-16 16:04:49 +01:00
tools MIPS: tools: Move "returns" after "loongson3-llsc-check" 2020-05-04 10:18:41 +02:00
txx9 MIPS: TXx9: Fix Kconfig warnings 2020-04-14 12:52:28 +02:00
vdso MIPS: VDSO: Use $(LD) instead of $(CC) to link VDSO 2020-05-12 10:02:00 +02:00
vr41xx MIPS: Replace setup_irq() by request_irq() 2020-03-05 16:47:35 +01:00
Kbuild treewide: Add SPDX license identifier - Kbuild 2019-05-30 11:32:33 -07:00
Kbuild.platforms MIPS: Remove NEC MARKEINS/EMMA 2020-05-09 18:05:57 +02:00
Kconfig MIPS: VDSO: Move disabling the VDSO logic to Kconfig 2020-05-12 10:01:45 +02:00
Kconfig.debug MIPS: cmdline: Remove redundant Kconfig defaults 2019-10-09 15:53:16 -07:00
Makefile MIPS: Unconditionally specify '-EB' or '-EL' 2020-05-12 10:01:53 +02:00
Makefile.postlink MIPS: fix indentation of the 'RELOCS' message 2020-01-20 15:37:30 -08:00