Re: [PATCH] alpha: enable gnu-indirect-function support for alpha-linux

Matt Turner <[email protected]>
Newsgroups gmane.comp.gcc.patches
Message-ID <CAEdQ38HiiG=gwmN39BCnxqHuHow=UaDywHzUw2_q7UOcn=xVqA@mail.gmail.com>
On Sun, Aug 9, 2026 at 6:31 PM Jeffrey Law <[email protected]> wrote:
> On 8/9/2026 1:58 PM, Matt Turner wrote:
> > Add alpha*-* to the list of targets that default to
> > --enable-gnu-indirect-function on glibc-based Linux systems.  This
> > sets HAVE_GNU_INDIRECT_FUNCTION=1, making targetm.has_ifunc_p() return
> > true and enabling __attribute__((ifunc)) support.
> >
> > No Alpha backend changes are needed — the generic ifunc machinery in
> > varasm.cc handles emission, and alpha/elf.h already provides the
> > required ASM_OUTPUT_TYPE_DIRECTIVE and ASM_OUTPUT_DEF macros.
> >
> > Requires binutils support for R_ALPHA_IRELATIVE and glibc dynamic
> > linker support for the new relocation.
> >
> > The binutils patch series adding STT_GNU_IFUNC and R_ALPHA_IRELATIVE
> > support has been sent to the binutils list:
> >
> >    https://sourceware.org/pipermail/binutils/2026-August/150713.html
> >
> > glibc dynamic linker support for R_ALPHA_IRELATIVE will follow.
> >
> > Tested by cross-compiling gcc.dg/attr-ifunc-{1..5}.c and
> > g++.dg/ext/attr-ifunc-{1..5}.C targeting alpha-linux-gnu.  GCC
> > correctly emits .type foo, @gnu_indirect_function and the resulting
> > binaries contain STT_GNU_IFUNC symbols.  Runtime tests require the
> > pending glibc dynamic linker patch.
> But doesn't this mean that the compiler is reliant upon an unreleased
> version of binutils?  Which implies we probably need to do an assembler
> feature test?

You're right that there's a dependency, but it isn't one an assembler
test would find.

%gnu_indirect_function is handled by generic ELF code in gas
(obj-elf.c), not by anything target specific, so it has been accepted
on alpha for as long as it has been accepted anywhere.  With a stock
binutils 2.47:

    $ alpha-unknown-linux-gnu-as -o conftest.o conftest.s
    $ alpha-unknown-linux-gnu-readelf -sW conftest.o | grep foo
         5: 0000000000000000     4 IFUNC   GLOBAL DEFAULT    1 foo

So an assembler feature test passes and tells us nothing.

The actual missing piece is in the linker, and it fails silently:

    $ alpha-unknown-linux-gnu-ld -o conftest conftest.o
    alpha-unknown-linux-gnu-ld: warning: cannot find entry symbol _start
    $ alpha-unknown-linux-gnu-readelf --relocs --wide conftest
    There are no relocations in this file.

The link succeeds, there is no diagnostic, and the IRELATIVE
relocation is simply dropped -- so the call goes straight to the
resolver rather than to the address the resolver returns.

v2 therefore drops the config.gcc hunk and instead follows the
riscv*-*-linux* precedent already in configure.ac: assemble, link, and
check that readelf reports R_ALPHA_IRELATIVE.  I generalized that
existing check so both targets share one code path.  Alpha needs its
own test source because alpha gas reserves .set for setting assembler
modes, so the alias has to be spelled with '=' -- which is what the
target's ASM_OUTPUT_DEF emits anyway.

With that, --enable-gnu-indirect-function defaults to off with a stock
binutils and enables itself once the alpha IFUNC support lands, so
there is no dependency on unreleased tools.  Runtime use still needs
the glibc side, as before.

I've sent v2 in reply to the original.
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.