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

            Bug ID: 33451
           Summary: A SEGV in elf_x86_allocate_dynrelocs at
                    elfxx-x86.c:329
           Product: binutils
           Version: 2.45
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: binutils
          Assignee: unassigned at sourceware dot org
          Reporter: yfzhang23 at stu dot pku.edu.cn
  Target Milestone: ---

Created attachment 16347
  --> https://sourceware.org/bugzilla/attachment.cgi?id=16347&action=edit
POC

## Description

- Version: Binutils 2.45
- Environment: Ubuntu 20.04.6 LTS, Clang 12.0.0

## Steps to reproduce

export CC="clang"
export CFLAGS="-g -fsanitize=address"
./configure
make -j
./ld/ld-new --gc-sections --no-print-gc-sections -w $POC

## Sanitizer output

==139058==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000078 (pc
0x00000067112d bp 0x7ffcd07fcc50 sp 0x7ffcd07fbf40 T0)
==139058==The signal is caused by a READ memory access.
==139058==Hint: address points to the zero page.
    #0 0x67112d in elf_x86_allocate_dynrelocs
/benchmark/bin/binutils-2.45/bfd/elfxx-x86.c:329:8
    #1 0x5e320e in bfd_link_hash_traverse
/benchmark/bin/binutils-2.45/bfd/linker.c:692:7
    #2 0x66e8d4 in elf_link_hash_traverse
/benchmark/bin/binutils-2.45/bfd/./elf-bfd.h:809:3
    #3 0x66aa30 in _bfd_x86_elf_late_size_sections
/benchmark/bin/binutils-2.45/bfd/elfxx-x86.c:2401:3
    #4 0x744215 in bfd_elf_size_dynamic_sections
/benchmark/bin/binutils-2.45/bfd/elflink.c:7725:11
    #5 0x59afe4 in ldelf_before_allocation
/benchmark/bin/binutils-2.45/ld/ldelf.c:1840:10
    #6 0x57acc0 in gldelf_x86_64_before_allocation
/benchmark/bin/binutils-2.45/ld/eelf_x86_64.c:172:3
    #7 0x57111b in elf_x86_64_before_allocation
/benchmark/bin/binutils-2.45/ld/eelf_x86_64.c:115:3
    #8 0x554af7 in ldemul_before_allocation
/benchmark/bin/binutils-2.45/ld/ldemul.c:104:3
    #9 0x50cdcc in lang_process /benchmark/bin/binutils-2.45/ld/ldlang.c:8627:3
    #10 0x53ca89 in main /benchmark/bin/binutils-2.45/ld/./ldmain.c:882:3
    #11 0x7f25f0ced082 in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x24082)
    #12 0x41d6ad in _start (/benchmark/bin/binutils-2.45/ld/ld-new+0x41d6ad)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV
/benchmark/bin/binutils-2.45/bfd/elfxx-x86.c:329:8 in
elf_x86_allocate_dynrelocs
==139058==ABORTING

## Credit

Reported by Yifan Zhang, [PLL](https://pl.cs.pku.edu.cn/en/)

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

Reply via email to