From 4bc368c62639807e0a5809353503288a321107e7 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 11 Apr 2019 18:30:15 +0900 Subject: [PATCH] BACKPORT: arm64: vdso: use $(LD) instead of $(CC) to link VDSO We use $(LD) to link vmlinux, modules, decompressors, etc. VDSO is the only exceptional case where $(CC) is used as the linker driver, but I do not know why we need to do so. VDSO uses a special linker script, and does not link standard libraries at all. I changed the Makefile to use $(LD) rather than $(CC). I tested this, and VDSO worked for me. Users will be able to use their favorite linker (e.g. lld instead of of bfd) by passing LD= from the command line. My plan is to rewrite all VDSO Makefiles to use $(LD), then delete cc-ldoption. Signed-off-by: Masahiro Yamada Signed-off-by: Will Deacon [panchajanya1999: cherry-pick and adapt to subsequent vdso32 changes from pixel] [linked from: https://github.com/aosp-mirror/kernel_common/commit/691efbedc60d2a7364a90e38882fc762f06f52c4#diff-0aef76c20f8f6b0455c2de52956f5edb] Signed-off-by: Panchajanya Sarkar Signed-off-by: Panchajanya1999 Change-Id: I4f4c67303c882987ba19bac1d98b21517dea770c Signed-off-by: Panchajanya1999 Signed-off-by: Kyvangka1610 --- arch/arm64/kernel/vdso/Makefile | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/arch/arm64/kernel/vdso/Makefile b/arch/arm64/kernel/vdso/Makefile index 1b6c3a6740b5..e6f9c5bf679d 100644 --- a/arch/arm64/kernel/vdso/Makefile +++ b/arch/arm64/kernel/vdso/Makefile @@ -15,11 +15,9 @@ obj-vdso-s := $(addprefix $(obj)/, $(obj-vdso-s)) obj-vdso-c := $(addprefix $(obj)/, $(obj-vdso-c)) obj-vdso := $(obj-vdso-c) $(obj-vdso-s) -ccflags-y := -shared -fno-common -fno-builtin -fno-stack-protector -ccflags-y += -DDISABLE_BRANCH_PROFILING -ffixed-x18 -ccflags-y += -nostdlib -Wl,-soname=linux-vdso.so.1 \ - $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) -ccflags-y += $(DISABLE_LTO) +ccflags-y := -fno-stack-protector -DDISABLE_BRANCH_PROFILING -ffixed-x18 +ldflags-y := -shared -nostdlib -soname=linux-vdso.so.1 \ + $(call ld-option, --hash-style=sysv) -n -T # Force -O2 to avoid libgcc dependencies CFLAGS_REMOVE_vgettimeofday.o = -pg -Os @@ -43,7 +41,7 @@ $(obj)/vdso.o : $(obj)/vdso.so # Link rule for the .so file, .lds has to be first $(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) FORCE - $(call if_changed,vdsold) + $(call if_changed,ld) # Strip rule for the .so file $(obj)/%.so: OBJCOPYFLAGS := -S @@ -66,8 +64,6 @@ $(obj-vdso-c): %.o: %.c FORCE $(call if_changed_dep,vdsocc) # Actual build commands -quiet_cmd_vdsold = VDSOL $@ - cmd_vdsold = $(CC) $(c_flags) -Wl,-n -Wl,-T $(real-prereqs) -o $@ quiet_cmd_vdsocc = VDSOC $@ cmd_vdsocc = ${CC} $(c_flags) -c -o $@ $< quiet_cmd_vdsoas = VDSOA $@