binutils Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
binutils/ld

ld/pdb: Fix uninitialized memory read in section handling

Linker now safely handles malformed object files with debug sections by zero-initializing the section array.

The linker’s PDB handling for debug sections now correctly initializes the sectlist array using xcalloc. Previously, if an object file contained malformed debug information, the linker could read uninitialized memory when processing relocations against symbols not associated with a valid section. This fix prevents such reads and ensures robustness when linking files with malformed PDB debug sections.

In Details

This commit addresses a potential uninitialized memory read in ld/pdb.c within the handle_debugs_section function. The sectlist array, which maps symbol table entries to sections, was allocated with xmalloc and not guaranteed to be zero-initialized. This could lead to crashes or incorrect behavior if a relocation referred to a symbol whose n_scnum did not map to a valid section, causing relocate_section to access uninitialized memory. The fix replaces xmalloc with xcalloc, which zero-initializes the allocated memory, and ensures that relocations against NULL sections are ski…

For Context
ld
The GNU linker, responsible for combining object files and libraries into an executable or another object file.
PDB
Program Database, a file format commonly used by Microsoft development tools to store information about libraries and executables, including debugging symbols.
section
A part of an object file or executable that contains related data, such as code, initialized data, or uninitialized data.
relocation
A modification that needs to be made to an object code instruction or data before it can be executed. Relocations are necessary to resolve addresses that are not known until link time.
symbol table
A data structure within an object file that lists the symbols (e.g., function names, variable names) defined or referenced by the file, along with information about them.
xcalloc
A memory allocation function that allocates memory and initializes it to zero. It is similar to calloc but may provide additional error checking or features.
Filed Under: linkerdebugsecurityrobustness