binutils Newspaper
NOVEMBER 30, 2026
ld — Proposed

ld: fix retargeted-output stub-file and hash-table accesses

Addresses crashes in AIX, AVR, and M68HC11 linker emulations when output formats are retargeted using linker scripts.

This series of patches fixes crashes in several linker emulations (AIX, AVR, M68HC11, VxWorks) that occur when a linker script uses OUTPUT_FORMAT to retarget the output to a different format, such as a generic ELF. These retargetings can lead to scenarios where required stub files are not created or link hash tables are of a generic type, causing subsequent accesses to be out-of-bounds reads or NULL pointer dereferences. The patches add checks to ensure stub files exist or that hash tables are of the expected type before access, preventing crashes.

In the Thread 1 participant
  1. Harshit Kumar proposer

    Proposes a series of patches to fix crashes in AIX, AVR, M68HC11, and VxWorks linker emulations related to retargeted output formats, addressing issues with stub files and hash table accesses.

    “A linker script can retarget the output BFD with OUTPUT_FORMAT. The AVR, m68hc1x and VxWorks emulation hooks run after that and assume the output backend created a stub file or an ELF link hash table. The generic elf32-gen/elf64-gen backends do neither, so the hooks either dereference a NULL stub_file or read past a generic hash table.”

In Details

This cover letter introduces a series of patches addressing a common issue in linker emulations: the incorrect assumption that specific structures (stub files, ELF hash tables) exist after the output format has been retargeted by a linker script. For example, generic ELF backends might not create stub files that are expected by AVR or M68HC11 emulations, or they might use a generic hash table where an elf_link_hash_table is expected by VxWorks emulation. The patches add defensive checks for these conditions, preventing crashes and ensuring predictable behavior.

For Context
OUTPUT_FORMAT
A linker script command used to specify the output file format.
stub file
A placeholder file used by the linker for specific linking operations, especially in certain emulations or when dealing with dynamic linking.
link hash table
A data structure used by the linker to store and quickly access symbol information.
AVR
A family of microcontrollers manufactured by Atmel.
M68HC11
A microcontroller from Motorola's M68HC11 family.
AIX
Advanced Interactive eXecutive, a Unix operating system developed by IBM.
VxWorks
A real-time operating system (RTOS) commonly used in embedded systems.
Filed Under: linkeraixavrm68hc11vxworks