[PATCH 1/7] bfd: add _bfd_elf_ifunc_nonalloc_reloc

Harshit Kumar harshit7kr@gmail.com
Fri Nov 13 12:46:48 GMT 2026


> Question is: Why don't you replace those existing incarnations of the
> rule enforcement then?

I left them alone to keep the series a fix rather than a refactor (the
cover letter says so).  I'm happy to convert them, though: v2 will make
the global-symbol code in x86, AArch64, RISC-V and SPARC use the helper
too, and (per the 0/7 thread) have it treat debugging sections like
SHT_NOTE, unless Alan objects.

> Pointer-to-const for the function argument?

Yes, will do.

Thanks,
Harshit

P.S: This should have been sent here.

On Fri, 13 Nov 2026 at 16:51, Jan Beulich <jbeulich@suse.com> wrote:
>
> On 11.11.2026 12:03, Harshit Kumar wrote:
> > The relocation scan skips non-SEC_ALLOC sections (PR ld/26080), so an
> > STT_GNU_IFUNC reference there has no PLT entry.  For a global symbol,
> > x86, AArch64, RISC-V and SPARC handle such a reference the same way:
> > STT_FUNC in a SHT_NOTE section (PR ld/22929), unapplied in a debugging
> > section (PR ld/18808), an error elsewhere.  Put that rule in one
> > function, so the local-symbol fixes that follow can share it.  No
> > functional change.
>
> Question is: Why don't you replace those existing incarnations of the
> rule enforcement then? That may not meaningfully shrink code size (as
> you still need a switch() over the function result), but it would
> centralize things.
>
> > --- a/bfd/elflink.c
> > +++ b/bfd/elflink.c
> > @@ -4390,6 +4390,26 @@ _bfd_elf_link_check_relocs (bfd *abfd, struct bfd_link_info *info)
> >    return true;
> >  }
> >
> > +/* Return how relocate_section should handle a relocation in
> > +   INPUT_SECTION, which is not SEC_ALLOC, against an STT_GNU_IFUNC
> > +   symbol.  The relocation scan skips such a section (PR ld/26080), so
> > +   the reference has no PLT entry or dynamic relocation.  Treat the
> > +   symbol as STT_FUNC in a SHT_NOTE section (PR ld/22929), leave the
> > +   relocation unapplied in a debugging section, which ld.so never
> > +   processes (PR ld/18808), and reject it in any other section.  This is
> > +   what x86, AArch64, RISC-V and SPARC do for a global STT_GNU_IFUNC
> > +   symbol there.  */
> > +
> > +enum elf_ifunc_nonalloc_action
> > +_bfd_elf_ifunc_nonalloc_reloc (asection *input_section)
>
> Pointer-to-const for the function argument?
>
> Jan


More information about the Binutils mailing list