[PATCH 1/7] bfd: add _bfd_elf_ifunc_nonalloc_reloc

Jan Beulich jbeulich@suse.com
Fri Nov 13 11:21:51 GMT 2026


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