binutils Newspaper
OCTOBER 6, 2026
bfd — Proposed

bfd: xtensa: keep property tables without linker script KEEP

Improve garbage collection for Xtensa property tables to avoid bloating images with dead code.

Alexey Lapshin proposes changes to how Xtensa property tables are handled during garbage collection in Binutils’ BFD library. Previously, linker scripts used KEEP() to retain these unreferenced tables, which inadvertently kept dead code and other unreferenced sections. This patch modifies the garbage collection process to mark property tables correctly, eliminating the need for KEEP() and preventing image bloat.

In the Thread 1 participant
  1. Alexey Lapshin proposer

    Submits a patch to correctly mark Xtensa property tables during garbage collection, removing the need for linker script `KEEP()` and preventing image bloat.

    “Mark property tables from the gc_mark_extra_sections hook, once the sections they describe have been marked, using the existing xtensa_get_property_section lookup. Set gc_mark directly rather than calling _bfd_elf_gc_mark, so a property section that belongs to a COMDAT group does not drag in the rest of the group. Linker scripts no longer need KEEP() for .xt.prop/.xt.lit”

In Details

This patch addresses an issue with garbage collection (GC) in the Xtensa BFD backend for Binutils. Unreferenced .xt.prop and .xt.lit sections, which store Xtensa-specific properties, were being retained by linker scripts using KEEP(). This practice led to the inclusion of dead code and other unused sections when these property sections were part of COMDAT groups. The solution involves using the gc_mark_extra_sections hook to identify and mark these property sections after their associated code has been marked, thus allowing them to be garbage collected if not otherwise referenced. Thi…

For Context
bfd
Binary File Descriptor library. A library provided by GNU binutils that provides a generic interface to a wide variety of object file formats.
Xtensa
A configurable processor architecture used in many embedded systems. Binutils provides support for generating code for Xtensa processors.
property tables
In the context of Xtensa, these are sections (e.g., .xt.prop, .xt.lit) that store metadata or configuration information related to the code.
garbage collection
A memory management technique where the runtime environment automatically reclaims memory that is no longer in use by the program. In the context of linkers, it refers to discarding unused code and data sections.
COMDAT
COMDAT (COmmon DATa) sections are groups of sections that are treated as a single unit by the linker. If any part of a COMDAT group is referenced, the entire group is retained.
KEEP()
A linker script directive that prevents a section or symbol from being discarded by the garbage collector.
Filed Under: binutilsbfdxtensagarbage collectionlinker