Bug 31408 - ld arm: fdpic link segfaults on R_ARM_GOTOFFFUNCDESC referencing a hidden symbol
Summary: ld arm: fdpic link segfaults on R_ARM_GOTOFFFUNCDESC referencing a hidden symbol
Status: NEW
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-02-24 06:53 UTC by Fangrui Song
Modified: 2024-02-24 06:53 UTC (History)
1 user (show)

See Also:
Host:
Target: arm*-*-uclinuxfdpiceabi
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fangrui Song 2024-02-24 06:53:39 UTC
% cat a.c
__attribute__((visibility("hidden"))) void fun_hidden();
void *fun_hidden_addr() { return fun_hidden; }
% ./bin/ld-new -m armelf_linux_fdpiceabi a.o
[1]    3819239 segmentation fault  ./bin/ld-new a.o
% ./bin/ld-new -m armelf_linux_fdpiceabi -shared a.o
./bin/ld-new: BFD (GNU Binutils) 2.42.50.20240224 internal error, aborting at ../../../bfd/elf32-arm.c:16466 in allocate_dynrelocs_for_symbol

./bin/ld-new: Please report this bug.


If fun_hidden is defined, -shared will suceed while -no-pie still segfaults.

(gdb) bt
#0  allocate_dynrelocs_for_symbol (h=0x5555557d5430, inf=0x5555557acf80 <link_info>) at ../../../bfd/elf32-arm.c:16474
#1  0x00005555556e6892 in bfd_link_hash_traverse (htab=htab@entry=0x5555557d4950, func=func@entry=0x5555556f8ba0 <allocate_dynrelocs_for_symbol>, info=info@entry=0x5555557acf80 <link_info>) at ../../../bfd/linker.c:674
#2  0x000055555570dc8b in elf_link_hash_traverse (info=0x5555557acf80 <link_info>, f=0x5555556f8ba0 <allocate_dynrelocs_for_symbol>, table=0x5555557d4950) at ../../../bfd/elf-bfd.h:787
#3  elf32_arm_size_dynamic_sections (output_bfd=0x5555557d2830, info=0x5555557acf80 <link_info>) at ../../../bfd/elf32-arm.c:16986
#4  0x0000555555738ba9 in bfd_elf_size_dynamic_sections (output_bfd=<optimized out>, soname=<optimized out>, rpath=rpath@entry=0x0, filter_shlib=0x0, audit=audit@entry=0x0, depaudit=0x0, auxiliary_filters=0x0, info=0x5555557acf80 <link_info>,
    sinterpptr=0x7fffffffd388) at ../../../bfd/elflink.c:7488
#5  0x00005555556d803b in ldelf_before_allocation (audit=<optimized out>, depaudit=<optimized out>, default_interpreter_name=0x0) at ../../../ld/ldelf.c:1839
#6  0x00005555556bfb9b in lang_process () at ../../../ld/ldlang.c:8423
#7  0x00005555556c4680 in main (argc=<optimized out>, argv=<optimized out>) at ../../../ld/ldmain.c:504



16468│       /* We only allocate one function descriptor with its associated
16469│          relocation.  */
16470│       if (eh->fdpic_cnts.funcdesc_offset == -1)
16471│         {
16472│           asection *s = htab->root.sgot; ///////// s is null
16473│
16474│           eh->fdpic_cnts.funcdesc_offset = s->size;
16475│           s->size += 8;


PR31407 is a similar bug failing on another line in allocate_dynrelocs_for_symbol