binutils Newspaper
OCTOBER 6, 2026
binutils — Proposed

binutils: remove assumptions about dynobj

A patch series cleans up assumptions in various backends that dynamic sections must exist if dynobj is non-NULL.

This patch series addresses an issue where several BFD backends incorrectly assume that the existence of dynobj implies that dynamic sections have been created. This assumption can fail if dynobj is set without create_dynamic_sections being called, such as when dynobj is assigned a stub BFD early in the linking process. The changes adjust assertions and checks in multiple backends to correctly test for dynamic_sections_created or the existence of specific dynamic section symbols.

In the Thread 1 participant
  1. Alan Modra <amodra@gmail.com> proposer

    Submits a patch series to fix incorrect assumptions about dynamic objects in BFD backends.

    “A number of backends assume that if dynobj is non-NULL then some dynamic sections must have been created. That isn't the case if dynobj is set without a create_dynamic_sections call, for instance, if dynobj were set to the stub bfd as ppc64 does early in linking. This patch fixes those assumptions, and tidies some code a little.”

In Details

Several BFD backends contain logic that assumes bfd_link_info.dynobj being non-NULL implies dynamic_sections_created is true. This commit corrects this by ensuring that specific dynamic section checks (like sgot, sdyn) and assertions only occur after verifying dynamic_sections_created. This is particularly relevant for cases like ppc64 where dynobj might be set to a stub BFD before dynamic sections are properly initialized.

For Context
dynobj
Likely refers to a pointer to a BFD (Binary File Descriptor) structure that represents a dynamic object or section within the linker's internal representation.
dynamic sections
Special sections in an ELF file (e.g., .dynamic, .dynsym, .dynstr) that contain information necessary for dynamic linking at runtime.
create_dynamic_sections
A function call within the linker that initializes and allocates structures for dynamic sections.
stub bfd
A placeholder or incomplete Binary File Descriptor structure used early in the linking process before the full details of an object file are known.
BFD
Binary File Descriptor. A library used by GNU toolchain components (like ld and gas) to provide a common interface for reading and writing various executable file formats.
backend
In the context of BFD or linker scripts, a specific implementation or set of rules tailored for a particular architecture or file format.
sgot
Likely refers to the 'Static GOT' or 'Small GOT' section, relevant for position-independent code.
Filed Under: binutilslinkerelfbackendpatch