Bug 31407 - ld arm: fdpic link may have null pointer dereference in allocate_dynrelocs_for_symbol
Summary: ld arm: fdpic link may have null pointer dereference in allocate_dynrelocs_fo...
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 04:07 UTC by Fangrui Song
Modified: 2024-02-24 04:08 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 04:07:08 UTC
Noticed while investigating the behavior of .rofixup

% cat a.s
.globl foo
foo:
  bx lr

.data
.long foo

% ./bin/as-new --fdpic a.s -o a.o && ./bin/ld-new -m armelf_linux_fdpiceabi a.o -o a
./bin/ld-new: warning: a.o: missing .note.GNU-stack section implies executable stack
./bin/ld-new: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
[1]    3777145 segmentation fault  ./bin/ld-new -m armelf_linux_fdpiceabi a.o -o a


(gdb) bt
#0  0x00005555556f9220 in allocate_dynrelocs_for_symbol (h=0x5555557d5348, inf=0x5555557acf80 <link_info>) at ../../../bfd/elf32-arm.c:16704
#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=0x7fffffffd3
68) 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