[PATCH 0/4] alpha: add IFUNC support

Matt Turner <[email protected]>
Newsgroups gmane.comp.gnu.binutils
Message-ID <[email protected]>
This series adds STT_GNU_IFUNC and R_ALPHA_IRELATIVE support to the
Alpha BFD backend, the necessary groundwork for enabling glibc's
multi-arch optimized string routines on Alpha.

Patch 1 adds the core IFUNC machinery: a new R_ALPHA_IRELATIVE
relocation (type 42), the HOWTO entry and BFD_RELOC_IRELATIVE mapping,
and the changes to want_plt, adjust_dynamic_symbol,
finish_dynamic_symbol, and relocate_section needed to route IFUNC
symbols through PLT entries and emit IRELATIVE relocations in place of
JMP_SLOT and RELATIVE ones. Alpha is removed from the exclusion list in
ld-ifunc/ifunc.exp; some tests fail at this point and are fixed by later
patches.

Patch 2 fixes two independent failures. A static link that referenced an
IFUNC hit a BFD assertion because no .rela.iplt section had been
created; patch 2 creates the section on demand, sizes it from GOT
entries, and emits the relocations into it so that the C library's
startup code can apply them. A hidden IFUNC in a shared library (as
glibc uses for __GI_ aliases) caused a heap corruption because
finish_dynamic_symbol emitted an unaccounted IRELATIVE into .rela.got;
the fix is to gate that path on needs_plt as well as the dynamic flag.

Patch 3 prevents the Alpha relaxation pass from turning a call to an
IFUNC into a direct branch. An IFUNC has no address until its resolver
runs, so the call must keep going through the GOT entry that IRELATIVE
fills in at startup; relaxing it away also silently dropped the
IRELATIVE. After this patch all standard ld-ifunc tests pass.

Patch 4 handles IFUNC symbols with local binding, which have no hash
table entry. Every IFUNC-related predicate that consulted only the hash
entry silently treated such a symbol as an ordinary one, producing wrong
relocations or no relocation at all. This is also what caused glibc's
configure probe for linker IFUNC support to fail, since it declares its
test symbol without .globl. New ld-alpha tests cover a data reference to
a local IFUNC and a call to one, in both static and shared links.

A small GCC patch is also needed to teach the Alpha back end to emit
STT_GNU_IFUNC on ifunc-attributed function definitions; that will be
sent separately to the GCC list. glibc multi-arch support for Alpha (the
motivation for the whole effort) will follow once both toolchain pieces
are in place.

Tested with a native Alpha build; check-ld shows no unexpected failures.

Matt Turner (4):
  alpha: add IFUNC (STT_GNU_IFUNC) and R_ALPHA_IRELATIVE support
  alpha: support IFUNC in static links
  alpha: do not relax references to IFUNC symbols
  alpha: handle IFUNC symbols with local binding

 bfd/elf64-alpha.c                             | 299 +++++++++++++++++-
 include/elf/alpha.h                           |   2 +
 .../ld-alpha/ifunc-local-call-shared.d        |   8 +
 ld/testsuite/ld-alpha/ifunc-local-call.d      |   8 +
 ld/testsuite/ld-alpha/ifunc-local-call.s      |  23 ++
 ld/testsuite/ld-alpha/ifunc-local.d           |   8 +
 ld/testsuite/ld-alpha/ifunc-local.s           |  18 ++
 ld/testsuite/ld-ifunc/ifunc.exp               |   1 -
 8 files changed, 349 insertions(+), 18 deletions(-)
 create mode 100644 ld/testsuite/ld-alpha/ifunc-local-call-shared.d
 create mode 100644 ld/testsuite/ld-alpha/ifunc-local-call.d
 create mode 100644 ld/testsuite/ld-alpha/ifunc-local-call.s
 create mode 100644 ld/testsuite/ld-alpha/ifunc-local.d
 create mode 100644 ld/testsuite/ld-alpha/ifunc-local.s

-- 
2.54.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.