@@ -26,7 +26,7 @@ struct vdso_data {
#define VDSO_SYMBOL(base, name) \
({ \
extern const char __vdso_##name[]; \
- (void __user *)((unsigned long)(base) + __vdso_##name); \
+ (void __user *)((unsigned long)(base) + __vdso_##name - PAGE_OFFSET); \
})
asmlinkage long sys_riscv_flush_icache(uintptr_t, uintptr_t, uintptr_t);
@@ -68,7 +68,7 @@ quiet_cmd_vdsold = VDSOLD $@
# Extracts symbol offsets from the VDSO, converting them into an assembly file
# that contains the same symbols at the same offsets.
quiet_cmd_so2s = SO2S $@
- cmd_so2s = $(NM) -D $< | $(srctree)/$(src)/so2s.sh > $@
+ cmd_so2s = $(NM) -D $< | $(srctree)/$(src)/so2s.sh $(CONFIG_PAGE_OFFSET) > $@
# install commands for the unstripped file
quiet_cmd_vdso_install = INSTALL $@
@@ -2,5 +2,5 @@
# SPDX-License-Identifier: GPL-2.0+
# Copyright 2020 Palmer Dabbelt <palmerdabbelt@google.com>
-sed 's!\([0-9a-f]*\) T \([a-z0-9_]*\)\(@@LINUX_4.15\)*!.global \2\n.set \2,0x\1!' \
+sed 's!\([0-9a-f]*\) T \([a-z0-9_]*\)\(@@LINUX_4.15\)*!.global \2\n.set \2,'${1}'+0x\1!' \
| grep '^\.'
The current implementation of the `__rt_sigaction` reference computed an absolute offset relative to the mapped base of the VDSO. While this can be handled in the medlow model, the medany model cannot handle this as it is meant to be position independent. The current implementation relied on the BFD linker relaxing the pc-relative relocation into an absolute relocation as it was a near-zero address allowing it to be referenced relative to `zero`. The constant offsets relative to the image base should be just that - constants. However, this takes a slightly more tricky approach of rebasing the address against the text base (`PAGE_OFFSET`) and then accounting for the image base at runtime to allow us to compute the VDSO relative address for the stub function. This allows the symbolic resolution to remain within the range of the pc-relative relocation, allowing the kernel to build with LLVM/lld. Thanks to Palmer Dabbelt for his assistance with this! Signed-off-by: Saleem Abdulrasool <abdulras@google.com> --- arch/riscv/include/asm/vdso.h | 2 +- arch/riscv/kernel/vdso/Makefile | 2 +- arch/riscv/kernel/vdso/so2s.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)