[PATCH 0/4] alpha: add IFUNC support

Magnus Lindholm linmag7@gmail.com
Mon Aug 10 20:39:15 GMT 2026


On Sun, Aug 9, 2026 at 9:23 PM Matt Turner <mattst88@gmail.com> wrote:
>
> 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.
>

Hi Matt,

I tested the current series, including the v2 revisions posted in this
thread, natively on an AlphaServer ES40 (EV68), configured as
alphaev68-unknown-linux-gnu.

For the full ld testsuite I got:

                     baseline    patched

expected passes 1857 1863
unexpected failures 20 15
unexpected successes 1 1
expected failures 34 35
untested 3 3
unsupported 167 167

Four existing IFUNC tests that fail on the baseline pass with the
current series:

Checking ifunc binaries
ifunc-using shared library does not contain R_ALPHA_IRELATIVE relocation
Local ifunc-using executable does not contain R_ALPHA_IRELATIVE relocation
Static ifunc-using executable does not contain R_ALPHA_IRELATIVE relocation

The two new Alpha IFUNC tests in the current series also pass. All
remaining unexpected failures are identical to the baseline, so I see
no regressions from this series.

One of the five fewer FAILs in the summary above is unrelated to the
series: I changed

#xfail: alpha--

to

#xfail: alpha*--

locally, since alpha-- does not match the
alphaev68-unknown-linux-gnu triplet on my system. This correctly changes
ld-ifunc/ifunc-26 from FAIL to XFAIL.

The full gas and binutils tests also showed no new failures compared
with the unpatched baseline.

Tested-by: Magnus Lindholm linmag7@gmail.com

Thanks,
Magnus


More information about the Binutils mailing list