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

            Bug ID: 34454
           Summary: ld: SEGV (BFD_ASSERT) in _bfd_elf_strtab_delref
                    (bfd/elf-strtab.c:200) via malformed versioned symbol
                    with `--version-exports-section symbol --shared`
           Product: binutils
           Version: 2.47
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: 2722900221 at qq dot com
  Target Milestone: ---

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

Summary

Linking a malformed ELF with `--version-exports-section symbol --shared`
triggers a `BFD_ASSERT` failure in `_bfd_elf_strtab_delref`
(`bfd/elf-strtab.c:200`) that manifests as a SEGV. The call chain is
`_bfd_elf_link_symbol_references_local` → `_bfd_elf_link_hide_sym_by_version` →
`_bfd_x86_elf_hide_symbol` → `_bfd_elf_link_hash_hide_symbol` →
`_bfd_elf_strtab_delref`. A malformed versioned symbol causes a delref on an
inconsistent string-table entry.

Affected Version

- binutils 2.47 (release tarball, version date `20260726`)
- Originally triaged on dev snapshot `2.47.50.20260722` (commit `640a79623`)

Reproduction

Build (ASAN):
CC=gcc CFLAGS='-g -O1 -fsanitize=address -fno-omit-frame-pointer -fno-common' \
LDFLAGS='-fsanitize=address' \
./configure --disable-gdb --disable-gdbserver --disable-sim --disable-cet \
            --disable-werror --disable-nls --enable-targets=x86_64-linux-gnu
MAKEINFO=true
make -j

Run:
export
ASAN_OPTIONS="abort_on_error=0:symbolize=1:detect_leaks=0:allocator_may_return_null=1:halt_on_error=1"
ld --version-exports-section symbol --shared -o /dev/null bug_13.o


Error Log

==65166==ERROR: AddressSanitizer: SEGV on unknown address (pc 0x5e132ccdf5b5 bp
0x7fff883dc960 sp 0x7fff883dc940 T0)
The signal is caused by a READ memory access.
    #0 _bfd_elf_strtab_delref            
/home/user/build/binutils-2.47/bfd/elf-strtab.c:200
    #1 _bfd_elf_link_hash_hide_symbol    
/home/user/build/binutils-2.47/bfd/elflink.c:8344
    #2 _bfd_x86_elf_hide_symbol          
/home/user/build/binutils-2.47/bfd/elfxx-x86.c:3659
    #3 _bfd_elf_link_hide_sym_by_version 
/home/user/build/binutils-2.47/bfd/elflink.c:2644
    #4 _bfd_x86_elf_link_symbol_references_local
/home/user/build/binutils-2.47/bfd/elfxx-x86.c:3695
SUMMARY: AddressSanitizer: SEGV
/home/user/build/binutils-2.47/bfd/elf-strtab.c:200 in _bfd_elf_strtab_delref

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

Reply via email to