https://sourceware.org/bugzilla/show_bug.cgi?id=34988

--- Comment #3 from Sourceware Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jan Beulich <[email protected]>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=dda69931f2cb113f109015a1f3eeb6219ebd3e20

commit dda69931f2cb113f109015a1f3eeb6219ebd3e20
Author: Harshit Kumar <[email protected]>
Date:   Mon Nov 23 13:44:56 2026 +0100

    x86: relocate IFUNC references from non-alloc sections as STT_FUNC

    A local STT_GNU_IFUNC symbol gets its hash entry from the relocation
    scan, which skips non-SEC_ALLOC sections (PR ld/26080).  When only such
    a section refers to it, elf_i386_relocate_section and
    elf_x86_64_relocate_section find no entry and abort.  "gcc -g -O2"
    produces this: once call () below loses its unused argument, only the
    call-site DWARF still refers to f, and ld 2.47 aborts:

      static int impl(void){return 1;}
      static int (*resolve(void))(void){return impl;}
      static int f(void) __attribute__((ifunc("resolve")));
      __attribute__((noinline))
      static int call(int (*p)(void), int x){ return x; }
      int g(int x){ return call(f, x); }

    A non-alloc section is not loaded and ld.so never processes it, so
    relocate a reference from any non-alloc section, debugging and note
    sections included, as against STT_FUNC: it gets the address of the
    resolver.  This replaces the separate SHT_NOTE (PR ld/22929) and
    SEC_DEBUGGING (PR ld/18808) cases for a global symbol, which left a
    debugging section's field unrelocated (0, or the bare addend, in
    .debug_info) and rejected or aborted on other non-alloc sections.

    bfd/
            PR ld/34988
            * elf32-i386.c (elf_i386_relocate_section): Relocate a reference
            from a non-alloc section to an STT_GNU_IFUNC symbol, local without
a
            hash entry or defined, as against STT_FUNC.
            * elf64-x86-64.c (elf_x86_64_relocate_section): Likewise.
    ld/
            PR ld/34988
            * testsuite/ld-i386/ifunc-debug-nonalloc.d: New test.
            * testsuite/ld-i386/ifunc-debug-nonalloc.s: New file.
            * testsuite/ld-i386/ifunc-global-debug-nonalloc.d: New test.
            * testsuite/ld-i386/ifunc-global-debug-nonalloc.s: New file.
            * testsuite/ld-i386/ifunc-global-plain-nonalloc.d: New test.
            * testsuite/ld-i386/ifunc-global-plain-nonalloc.s: New file.
            * testsuite/ld-i386/ifunc-note-nonalloc.d: New test.
            * testsuite/ld-i386/ifunc-note-nonalloc.s: New file.
            * testsuite/ld-i386/ifunc-plain-nonalloc.d: New test.
            * testsuite/ld-i386/ifunc-plain-nonalloc.s: New file.
            * testsuite/ld-i386/i386.exp: Run them.
            * testsuite/ld-x86-64/ifunc-debug-nonalloc.d: New test.
            * testsuite/ld-x86-64/ifunc-debug-nonalloc.s: New file.
            * testsuite/ld-x86-64/ifunc-global-debug-nonalloc.d: New test.
            * testsuite/ld-x86-64/ifunc-global-debug-nonalloc.s: New file.
            * testsuite/ld-x86-64/ifunc-global-plain-nonalloc.d: New test.
            * testsuite/ld-x86-64/ifunc-global-plain-nonalloc.s: New file.
            * testsuite/ld-x86-64/ifunc-note-nonalloc.d: New test.
            * testsuite/ld-x86-64/ifunc-note-nonalloc.s: New file.
            * testsuite/ld-x86-64/ifunc-plain-nonalloc.d: New test.
            * testsuite/ld-x86-64/ifunc-plain-nonalloc.s: New file.
            * testsuite/ld-x86-64/x86-64.exp: Run them.

    Signed-off-by: Harshit Kumar <[email protected]>

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Reply via email to