Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 64ea9b4b authored by Masahiro Yamada's avatar Masahiro Yamada Committed by Alistair Delva
Browse files

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: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>

Change-Id: I8a14d6dd51d46b6942e68720e24217d1564b7869
[nd: conflicts due to ANDROID patches for LTO and SCS]
(cherry picked from commit 691efbedc60d2a7364a90e38882fc762f06f52c4)
Bug: 153418016
Bug: 157279372
Signed-off-by: default avatarNick Desaulniers <ndesaulniers@google.com>
parent 40fc2b48
Loading
Loading
Loading
Loading
+3 −10
Original line number Diff line number Diff line
@@ -12,9 +12,8 @@ obj-vdso := gettimeofday.o note.o sigreturn.o
targets := $(obj-vdso) vdso.so vdso.so.dbg
obj-vdso := $(addprefix $(obj)/, $(obj-vdso))

ccflags-y := -shared -fno-common -fno-builtin
ccflags-y += -nostdlib -Wl,-soname=linux-vdso.so.1 \
		$(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
ldflags-y := -shared -nostdlib -soname=linux-vdso.so.1 \
		$(call ld-option, --hash-style=sysv) -n -T
ccflags-y += $(DISABLE_LTO)

CFLAGS_REMOVE_vgettimeofday.o += $(CC_FLAGS_SCS)
@@ -22,10 +21,6 @@ CFLAGS_REMOVE_vgettimeofday.o += $(CC_FLAGS_SCS)
# Disable gcov profiling for VDSO code
GCOV_PROFILE := n

# Workaround for bare-metal (ELF) toolchains that neglect to pass -shared
# down to collect2, resulting in silent corruption of the vDSO image.
ccflags-y += -Wl,-shared

obj-y += vdso.o
extra-y += vdso.lds
CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
@@ -35,7 +30,7 @@ $(obj)/vdso.o : $(obj)/vdso.so

# Link rule for the .so file, .lds has to be first
$(obj)/vdso.so.dbg: $(src)/vdso.lds $(obj-vdso)
	$(call if_changed,vdsold)
	$(call if_changed,ld)

# Strip rule for the .so file
$(obj)/%.so: OBJCOPYFLAGS := -S
@@ -57,8 +52,6 @@ $(obj-vdso): %.o: %.S FORCE
	$(call if_changed_dep,vdsoas)

# Actual build commands
quiet_cmd_vdsold = VDSOL   $@
      cmd_vdsold = $(CC) $(c_flags) -Wl,-n -Wl,-T $^ -o $@
quiet_cmd_vdsoas = VDSOA   $@
      cmd_vdsoas = $(CC) $(a_flags) -c -o $@ $<