binutils Newspaper
OCTOBER 6, 2026
microblaze — Ready to Land — Sentiment 7 / 10

microblaze: Neutralize relocations against discarded sections

Patch corrects GNU ld for MicroBlaze by neutralizing relocations against symbols in discarded sections, fixing garbage in debug sections.

This patch addresses a bug in the MicroBlaze ELF linker where relocations against symbols in discarded sections were not properly handled. This led to garbage data appearing in debug sections instead of expected zeros. The fix neutralizes these problematic relocations, aligning with behavior in other BFD backends and correcting existing test failures.

In the Thread 2 participants
  1. Sam Price <thesamprice@gmail.com> proposer

    Submits a patch to fix MicroBlaze ELF linker behavior, ensuring relocations against discarded sections are neutralized to prevent incorrect data in debug sections.

    “microblaze_elf_relocate_section does not handle relocations against symbols defined in sections discarded by linkonce or comdat handling. bfd/elf32-microblaze.c contains no RELOC_AGAINST_DISCARDED_SECTION at all, where 60 other bfd/elf*.c files use it. The relocation survives and resolves against a dead symbol, so debug sections end up holding garbage where zero is expected:”
  2. Neal Frager <neal.frager@amd.com> other

    Acknowledges the issue and the proposed fix, providing context that this is related to AMD's systems.

    “Hello Sam, > microblaze_elf_relocate_section does not handle relocations against > symbols defined in sections discarded by linkonce or comdat handling. > bfd/elf32-microblaze.c contains no RELOC_AGAINST_DISCARDED_SECTION at > all, where 60 other bfd/elf*.c files use it. The relocation survives and > resolves against a dead symbol, so debug sections end up holding garbage > where zero is expect…”

Technical Tradeoffs

  • Neutralizing relocations prevents incorrect data but might mask underlying issues if the discarded sections were intended to be present.
  • Adopting standard BFD practices ensures consistency across targets.

In Details

A bugfix patch for the MicroBlaze ELF linker addresses incorrect handling of relocations. Specifically, microblaze_elf_relocate_section fails to neutralize relocations targeting symbols within sections that have been discarded by linkonce or comdat mechanisms. This results in debug sections containing erroneous data (garbage) where zeros are expected. The proposed solution introduces the RELOC_AGAINST_DISCARDED_SECTION handling, mirroring common practice in other BFD ELF backends, and resolves several failing tests.

For Context
MicroBlaze
A soft processor core from Xilinx, commonly used in FPGAs.
ELF
Executable and Linkable Format, the standard file format for object files, executables, and shared libraries on Unix-like systems.
relocation
A process performed by the linker to adjust symbolic references in object files to their final memory addresses in the executable or shared library.
discarded sections
Sections within an object file that are intentionally removed or ignored during the linking process, often due to linkonce or comdat grouping.
linkonce
A linker flag or mechanism that ensures a section or symbol is included only once in the final output, even if defined in multiple input files.
comdat
COMDAT (COMDAT sections) is a mechanism in object files that allows multiple identical sections from different input files to be merged into a single section in the output file, or discarded entirely if not needed.
BFD
Binary File Descriptor library, a GNU library that provides a common interface for manipulating various object file formats.
Filed Under: ldmicroblazebugfixrelocationdebug