[ Upstream commit fcae44fd36d052e956e69a64642fc03820968d78 ] Recently, ld.lld moved from '--undefined-version' to '--no-undefined-version' as the default, which breaks the compat vDSO build: ld.lld: error: version script assignment of 'LINUX_4.15' to symbol '__vdso_gettimeofday' failed: symbol not defined ld.lld: error: version script assignment of 'LINUX_4.15' to symbol '__vdso_clock_gettime' failed: symbol not defined ld.lld: error: version script assignment of 'LINUX_4.15' to symbol '__vdso_clock_getres' failed: symbol not defined These symbols are not present in the compat vDSO or the regular vDSO for 32-bit but they are unconditionally included in the version section of the linker script, which is prohibited with '--no-undefined-version'. Fix this issue by only including the symbols that are actually exported in the version section of the linker script. Link: https://github.com/ClangBuiltLinux/linux/issues/1756 Signed-off-by: Nathan Chancellor <nathan@kernel.org> Tested-by: Conor Dooley <conor.dooley@microchip.com> Link: https://lore.kernel.org/r/20221108171324.3377226-1-nathan@kernel.org/ Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
73 lines
2.3 KiB
Makefile
73 lines
2.3 KiB
Makefile
# Copied from arch/tile/kernel/vdso/Makefile
|
|
|
|
# Symbols present in the vdso
|
|
vdso-syms = rt_sigreturn
|
|
vdso-syms += gettimeofday
|
|
vdso-syms += clock_gettime
|
|
vdso-syms += clock_getres
|
|
vdso-syms += getcpu
|
|
vdso-syms += flush_icache
|
|
|
|
# Files to link into the vdso
|
|
obj-vdso = $(patsubst %, %.o, $(vdso-syms))
|
|
|
|
# Build rules
|
|
targets := $(obj-vdso) vdso.so vdso.so.dbg vdso.lds vdso-dummy.o
|
|
obj-vdso := $(addprefix $(obj)/, $(obj-vdso))
|
|
|
|
obj-y += vdso.o vdso-syms.o
|
|
CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
|
|
ifneq ($(filter vgettimeofday, $(vdso-syms)),)
|
|
CPPFLAGS_vdso.lds += -DHAS_VGETTIMEOFDAY
|
|
endif
|
|
|
|
# Disable gcov profiling for VDSO code
|
|
GCOV_PROFILE := n
|
|
|
|
# Force dependency
|
|
$(obj)/vdso.o: $(obj)/vdso.so
|
|
|
|
# link rule for the .so file, .lds has to be first
|
|
SYSCFLAGS_vdso.so.dbg = $(c_flags)
|
|
$(obj)/vdso.so.dbg: $(src)/vdso.lds $(obj-vdso) FORCE
|
|
$(call if_changed,vdsold)
|
|
|
|
# We also create a special relocatable object that should mirror the symbol
|
|
# table and layout of the linked DSO. With ld --just-symbols we can then
|
|
# refer to these symbols in the kernel code rather than hand-coded addresses.
|
|
|
|
SYSCFLAGS_vdso.so.dbg = -shared -s -Wl,-soname=linux-vdso.so.1 \
|
|
$(call cc-ldoption, -Wl$(comma)--hash-style=both)
|
|
$(obj)/vdso-dummy.o: $(src)/vdso.lds $(obj)/rt_sigreturn.o FORCE
|
|
$(call if_changed,vdsold)
|
|
|
|
LDFLAGS_vdso-syms.o := -r --just-symbols
|
|
$(obj)/vdso-syms.o: $(obj)/vdso-dummy.o FORCE
|
|
$(call if_changed,ld)
|
|
|
|
# strip rule for the .so file
|
|
$(obj)/%.so: OBJCOPYFLAGS := -S
|
|
$(obj)/%.so: $(obj)/%.so.dbg FORCE
|
|
$(call if_changed,objcopy)
|
|
|
|
# actual build commands
|
|
# The DSO images are built using a special linker script
|
|
# Add -lgcc so rv32 gets static muldi3 and lshrdi3 definitions.
|
|
# Make sure only to export the intended __vdso_xxx symbol offsets.
|
|
quiet_cmd_vdsold = VDSOLD $@
|
|
cmd_vdsold = $(CC) $(KBUILD_CFLAGS) $(call cc-option, -no-pie) -nostdlib -nostartfiles $(SYSCFLAGS_$(@F)) \
|
|
-Wl,-T,$(filter-out FORCE,$^) -o $@.tmp && \
|
|
$(CROSS_COMPILE)objcopy \
|
|
$(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@ && \
|
|
rm $@.tmp
|
|
|
|
# install commands for the unstripped file
|
|
quiet_cmd_vdso_install = INSTALL $@
|
|
cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
|
|
|
|
vdso.so: $(obj)/vdso.so.dbg
|
|
@mkdir -p $(MODLIB)/vdso
|
|
$(call cmd,vdso_install)
|
|
|
|
vdso_install: vdso.so
|