[PATCH 0/2] sparc: Fix IFUNC startup and ldd-trace regressions

Andreas K. Huettel dilfridge@gentoo.org
Wed Jul 15 12:00:58 GMT 2026


> Patch 1 fixes BZ#34396: on a static (non-PIE) binary __libc_setup_tls
> issuse _dl_allocate_tls_init which copies the TLS init image with the
> IFUNC __mempcpy, which now runs before the static IFUNC (IRELATIVE)
> relocations are applied, so the call jumps through an unrelocated PLT
> slot and dies with SIGILL.  It redirects the mem* routines reached on
> that path to their non-IFUNC ultra1 implementations.
[...]
> With an working toolchain, running the sparc testsuite with patch 1 applied
> exposed two further regressions:
> 
>   FAIL: elf/tst-ifunc-fault-bindnow
>   FAIL: elf/tst-ifunc-fault-lazy
> 
> Patch 2 fixes those by proper handling R_SPARC_JMP_IREL.  I also checked
> other ABIs for similar issues and powerpc64 (ELFv1) uses a similar second
> reloc (R_PPC64_JMP_IREL).  The patch fixes it as well.

Tested on sparc64 (catbus) and improves the situation a lot - down to 12 failures
from >200. Feel free to add 

Tested-by: Andreas K. Hüttel <dilfridge@gentoo.org>

In detail, the remaining failures are:

FAIL: elf/tst-pldd (*)
FAIL: elf/tst-thp-1
FAIL: elf/tst-thp-1-no-s-code
FAIL: elf/tst-thp-1-no-s-code-pde
FAIL: elf/tst-thp-1-no-s-code-static
FAIL: elf/tst-thp-1-pde
FAIL: elf/tst-thp-1-static
FAIL: elf/tst-thp-align
FAIL: math/test-float64x-float128-mul (*)
FAIL: posix/tst-chmod
FAIL: socket/tst-socket-timestamp (*)
FAIL: stdlib/tst-setcontext2 (*)
                === Summary of results ===
     12 FAIL
   6727 PASS
     70 UNSUPPORTED
     17 XFAIL
      2 XPASS

This machine was offline for a while; my last baseline is 2.41. 
All tests marked (*) above already failed back then. About the remaining 
regressions, all except one seem to be internally an identical problem:

elf/tst-thp-1.out:
===================================
../sysdeps/unix/sysv/linux/tst-thp-align-check.h:59: numeric comparison failure (widths 64 and 32)
   left: 6291456 (0x600000); from: from % thp_size
  right: 0 (0x0); from: 0
error: 1 test failures

elf/tst-thp-1-no-s-code.out:
===================================
../sysdeps/unix/sysv/linux/tst-thp-align-check.h:59: numeric comparison failure (widths 64 and 32)
   left: 4194304 (0x400000); from: from % thp_size
  right: 0 (0x0); from: 0
../sysdeps/unix/sysv/linux/tst-thp-align-check.h:59: numeric comparison failure (widths 64 and 32)
   left: 4194304 (0x400000); from: from % thp_size
  right: 0 (0x0); from: 0
error: 2 test failures

elf/tst-thp-1-no-s-code-pde.out:
===================================
../sysdeps/unix/sysv/linux/tst-thp-align-check.h:59: numeric comparison failure (widths 64 and 32)
   left: 2097152 (0x200000); from: from % thp_size
  right: 0 (0x0); from: 0
../sysdeps/unix/sysv/linux/tst-thp-align-check.h:59: numeric comparison failure (widths 64 and 32)
   left: 2097152 (0x200000); from: from % thp_size
  right: 0 (0x0); from: 0
error: 2 test failures

elf/tst-thp-1-no-s-code-static.out:
===================================
../sysdeps/unix/sysv/linux/tst-thp-align-check.h:59: numeric comparison failure (widths 64 and 32)
   left: 2097152 (0x200000); from: from % thp_size
  right: 0 (0x0); from: 0
../sysdeps/unix/sysv/linux/tst-thp-align-check.h:59: numeric comparison failure (widths 64 and 32)
   left: 2097152 (0x200000); from: from % thp_size
  right: 0 (0x0); from: 0
error: 2 test failures

elf/tst-thp-align.out:
===================================
../sysdeps/unix/sysv/linux/tst-thp-align-check.h:59: numeric comparison failure (widths 64 and 32)
   left: 4194304 (0x400000); from: from % thp_size
  right: 0 (0x0); from: 0
error: 1 test failures

posix/tst-chmod.out:
===================================
chmod(".../file",0600) did not set ctime correctly







> 
> The existing tests do not catch it there because they only take the
> resolver's *address*, which powerpc64 emits as R_PPC64_IRELATIVE; the
> JMP_IREL slot is emitted only when the IFUNC is actually *called*. All
> other ABIs use a single IRELATIVE type and are unaffected.
> 
> Adhemerval Zanella (2):
>   sparc: Fix static IFUNC startup crash by redirecting __mempcpy (BZ
>     #34396)
>   elf: Defer arch PLT IFUNC relocations in the two-phase relocation
>     split
> 
>  elf/do-rel.h                                  |  8 ++++++-
>  sysdeps/powerpc/powerpc64/dl-machine.h        |  1 +
>  .../multiarch => }/dl-symbol-redir-ifunc.h    | 13 +++++++++-
>  sysdeps/sparc/sparc32/dl-machine.h            |  1 +
>  sysdeps/sparc/sparc64/dl-machine.h            |  1 +
>  .../sparc64/multiarch/dl-symbol-redir-ifunc.h | 24 -------------------
>  6 files changed, 22 insertions(+), 26 deletions(-)
>  rename sysdeps/sparc/{sparc32/sparcv9/multiarch => }/dl-symbol-redir-ifunc.h (70%)
>  delete mode 100644 sysdeps/sparc/sparc64/multiarch/dl-symbol-redir-ifunc.h
> 
> 


-- 
PD Dr. Andreas K. Hüttel
dilfridge@gentoo.org
Gentoo Linux developer 
(council, comrel, toolchain, base-system, perl, libreoffice)
https://wiki.gentoo.org/wiki/User:Dilfridge
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 870 bytes
Desc: This is a digitally signed message part.
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20260715/60cb6b08/attachment.sig>


More information about the Libc-alpha mailing list