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

Adhemerval Zanella <[email protected]>
Newsgroups gmane.comp.lib.glibc.alpha
Message-ID <[email protected]>
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.

These problems escaped my own testing because the binutils I was using
has an ld that segfaults on glibc's gnu-indirect-function configure probe
(a NULL-name strcmp on a local STT_GNU_IFUNC, since binutils commit
fd82d5ddf57a). configure therefore recorded
libc_cv_ld_gnu_indirect_function=no and built glibc without multi-arch,
so no IFUNC was exercised at all.

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.

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

-- 
2.43.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.