[PATCH 0/7] bfd: local IFUNC symbols referenced only from non-alloc sections

Harshit Kumar harshit7kr@gmail.com
Sat Nov 14 04:50:20 GMT 2026


Hi Alan,

> Yes, that should happen for all non-alloc sections.  You shouldn't
> need to distinguish SHT_NOTE or SEC_DEBUGGING from other non-alloc in
> the way relocations are handled, with a very few exceptions where
> SEC_DEBUGGING silences an error.

Thanks, that makes it simpler.  v2 relocates an IFUNC reference from
any non-alloc section as against STT_FUNC, for local and global
symbols, on x86, AArch64, RISC-V and SPARC, as LoongArch and s390
already do.  The helper in 1/7 goes away.

> I see many wrong tests of
> SEC_DEBUGGING in elf_x86_64_relocate_section.

I take it you mean the (SEC_ALLOC | SEC_DEBUGGING) == 0 checks in the
GOT, PLT and TLS cases, which reject a non-alloc section unless it is
a debugging one.  They came with 471130b39c, and a series I am still
working on, for GOT and TLS relocations in sections the scan skips,
builds on them.  I'd prefer to fix them in a separate patch with the
x86 maintainers, unless you want it in this series.

Thanks,
Harshit


On Sat, 14 Nov 2026 at 03:22, Alan Modra <amodra@gmail.com> wrote:
>
> On Fri, Nov 13, 2026 at 01:39:33PM +0100, Jan Beulich wrote:
> > On 13.11.2026 13:36, Harshit Kumar wrote:
> > >> I have some doubt that x86 and the others that have followed x86 are
> > >> correct regarding not applying relocs in debug sections.  Debug
> > >> sections certainly should not generate dynamic relocations, but why
> > >> would you not apply the reloc to the debug section?
> > >
> > > I could not find a reason either.  PR ld/18808 was an abort () on such a
> > > relocation; the first fix (97dc35c88d) used "break", and the same day
> > > 0eace2105d changed it to "continue", without saying why skipping is
> > > the right outcome.  The series only copied that.
> > >
> > > It also gives wrong debug info.  With a global IFUNC "ifn" at 0x10001,
> > > "ld -e _start -Ttext=0x10000" leaves ".quad ifn" in .debug_info as 0
> > > on x86-64, while the same reference in a non-alloc note gets 0x10001.
> > > On i386 ".long ifn+4" stays 4.  arm, ppc32, ppc64, alpha, arc, csky,
> > > hppa, s390 and LoongArch already apply the reloc there, with the
> > > resolver address.
> > >
> > > So I'd apply it the way the SHT_NOTE case does, as against an STT_FUNC
> > > symbol.  If you and Jan agree, v2 would do that for debugging
> > > sections, for global and local symbols alike, on x86, AArch64, RISC-V
> > > and SPARC.
>
> Yes, that should happen for all non-alloc sections.  You shouldn't
> need to distinguish SHT_NOTE or SEC_DEBUGGING from other non-alloc in
> the way relocations are handled, with a very few exceptions where
> SEC_DEBUGGING silences an error.  I see many wrong tests of
> SEC_DEBUGGING in elf_x86_64_relocate_section.
>
> > Sgtm, fwiw.
> >
> > Jan
>
> --
> Alan Modra


More information about the Binutils mailing list