[PATCH v6 07/11] LoongArch: vDSO: Enable the vdsocheck tool
From: Thomas Weißschuh
Date: Mon Nov 23 2026 - 08:51:43 EST
The vdsocheck tool validates the object files and final .so library.
It can detect if the compiler created relocations which are incompatible
with the vDSO which need to be worked around.
Wire it up for the architecture.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@xxxxxxxxxxxxx>
---
arch/loongarch/Kconfig | 1 +
arch/loongarch/vdso/Makefile | 4 ++--
lib/vdso/check/vdsocheck.rs | 26 ++++++++++++++++++++++++++
3 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig
index b5ed4881d3c0..ad4cafeddbb8 100644
--- a/arch/loongarch/Kconfig
+++ b/arch/loongarch/Kconfig
@@ -211,6 +211,7 @@ config LOONGARCH
select TRACE_IRQFLAGS_SUPPORT
select USE_PERCPU_NUMA_NODE_ID
select USER_STACKTRACE_SUPPORT
+ select VDSO_CHECK
select VDSO_DATASTORE
select VDSO_GETRANDOM
select ZONE_DMA32 if 64BIT
diff --git a/arch/loongarch/vdso/Makefile b/arch/loongarch/vdso/Makefile
index 0b84892d084b..ad54383b1908 100644
--- a/arch/loongarch/vdso/Makefile
+++ b/arch/loongarch/vdso/Makefile
@@ -51,7 +51,7 @@ ldflags-y := -Bsymbolic --no-undefined -soname=linux-vdso.so.1 \
#
quiet_cmd_vdsold_and_vdso_check = LD $@
- cmd_vdsold_and_vdso_check = $(cmd_ld); $(cmd_vdso_check)
+ cmd_vdsold_and_vdso_check = $(cmd_ld_vdso); $(cmd_vdso_check)
quiet_cmd_vdsoas_o_S = AS $@
cmd_vdsoas_o_S = $(CC) $(a_flags) -c -o $@ $<
@@ -80,7 +80,7 @@ $(obj-vdso): KBUILD_AFLAGS := $(aflags-vdso) $(native-abi)
$(obj)/vdso.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) $(native-abi)
-$(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) FORCE
+$(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) $(vdsocheck) FORCE
$(call if_changed,vdsold_and_vdso_check)
$(obj)/vdso.so: OBJCOPYFLAGS := -S
diff --git a/lib/vdso/check/vdsocheck.rs b/lib/vdso/check/vdsocheck.rs
index 37455d326110..7952ad6ba72b 100644
--- a/lib/vdso/check/vdsocheck.rs
+++ b/lib/vdso/check/vdsocheck.rs
@@ -122,6 +122,32 @@ fn allowed_relocations_for_machine(machine: u16) -> Option<AllowedRelocations<'s
..Default::default()
}
.into(),
+ bindings::EM_LOONGARCH => AllowedRelocations {
+ in_object_file: &[
+ 47, /* R_LARCH_ADD8 */
+ 48, /* R_LARCH_ADD16 */
+ 49, /* R_LARCH_ADD24 */
+ 50, /* R_LARCH_ADD32 */
+ 51, /* R_LARCH_ADD64 */
+ 52, /* R_LARCH_SUB8 */
+ 53, /* R_LARCH_SUB16 */
+ 54, /* R_LARCH_SUB24 */
+ 55, /* R_LARCH_SUB32 */
+ 56, /* R_LARCH_SUB64 */
+ 64, /* R_LARCH_B16 */
+ 65, /* R_LARCH_B21 */
+ 66, /* R_LARCH_B26 */
+ 71, /* R_LARCH_PCALA_HI20 */
+ 72, /* R_LARCH_PCALA_LO12 */
+ 73, /* R_LARCH_PCALA64_LO20 */
+ 74, /* R_LARCH_PCALA64_HI12 */
+ 99, /* R_LARCH_32_PCREL */
+ 128, /* R_LARCH_PCADD_HI20 */
+ 128, /* R_LARCH_PCADD_LO12 */
+ ],
+ ..Default::default()
+ }
+ .into(),
_ => None,
}
}
--
2.56.1