Skip to content

Commit

Permalink
BACKPORT: arm64: vdso: use $(LD) instead of $(CC) to link VDSO
Browse files Browse the repository at this point in the history
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 <yamada.masahiro@socionext.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
[panchajanya1999: cherry-pick and adapt to subsequent vdso32 changes from pixel]
[linked from: aosp-mirror/kernel_common@691efbe#diff-0aef76c20f8f6b0455c2de52956f5edb]
Signed-off-by: Panchajanya Sarkar <panchajanya@azure-dev.live>
Signed-off-by: Panchajanya1999 <panchajanya@azure-dev.live>

Change-Id: I4f4c67303c882987ba19bac1d98b21517dea770c
Signed-off-by: Panchajanya1999 <panchajanya@azure-dev.live>
Signed-off-by: Kyvangka1610 <kyvangka2002@gmail.com>
  • Loading branch information
masahir0y authored and Kyvangka1610 committed Jan 5, 2021
1 parent e3f3c3b commit 4bc368c
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions arch/arm64/kernel/vdso/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 $@
Expand Down

0 comments on commit 4bc368c

Please sign in to comment.