Skip to content

v2.1-20260917

@BKPepe BKPepe tagged this 17 Sep 00:43
A bl sym@plt call emitted by the VM assembler produces an
R_PPC_PLTREL24 relocation with addend 0, which forces the linker to
use BSS-PLT for the entire link. GCC 12 and newer emit inline-PLT
relocations (R_PPC_PLTSEQ, R_PPC_PLTCALL, R_PPC_PLT16_*) that have no
BSS-PLT equivalent, so linking libluajit.so fails outright:

  ld: bss-plt forced due to lj_vm.o
  ld: crtstuff.c:(.text+0x46): R_PPC_PLT16_HA relocation unsupported
      for bss-plt

Route these calls through a private GOT stored in GG_State, the way
the MIPS port already does. No PLT relocation is emitted, the linker
selects secure-PLT and the link succeeds.

Originally submitted upstream as LuaJIT/LuaJIT#486, against 2.0 and
addressing LuaJIT/LuaJIT#481, and closed without being merged. OpenWrt
has carried it for the upstream luajit package as 060-ppc-musl.patch
since 2019, extended with the soft-float helpers the 2.1 branch needs
in the GOT. Adapted here for luajit2 and verified on OpenWrt.

Tested on Turris 1.x (e500v2, 32-bit big-endian, musl, soft-float)
with BUILDMODE=dynamic. No R_PPC_PLTREL24 relocations remain, and the
resulting binary runs correctly, including all libm calls routed
through the new GOT. The previously produced dynamic binary crashed
during startup.

Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
Co-authored-by: Clint Bland <bland.cr@gmail.com>
Assets 2
Loading