binutils Newspaper
OCTOBER 6, 2026
microblaze — Proposed

microblaze: add BFD_RELOC_8 and BFD_RELOC_16 cases

Adds support for 8-bit and 16-bit relocations in MicroBlaze's `md_apply_fix` function.

This patch introduces support for BFD_RELOC_8 and BFD_RELOC_16 relocations within the MicroBlaze assembler’s md_apply_fix function. Previously, these relocation types were not handled, causing byte or halfword data that was only known at fixup time to be assembled as zero. This would then be resolved to BFD_RELOC_NONE, preventing the linker from correcting the value. The patch implements these cases using md_number_to_chars, which writes in the target’s byte order, thus fixing issues in the gas/all/simple-forward test and removing an xfail for gas/all/forward. The test suite results show an improvement in passing counts for both microblaze-elf and microblazeel-elf.

In Details

This patch, the first in a series for MicroBlaze md_apply_fix and md_assemble cleanup, adds handling for 8-bit and 16-bit relocations. The md_apply_fix function in gas/config/tc-microblaze.c previously lacked explicit cases for BFD_RELOC_8 and BFD_RELOC_16, causing them to fall through and result in zero-value fixups. This change adds these cases, utilizing md_number_to_chars for writing the values in target byte order. This resolves the gas/all/simple-forward test and allows the gas/all/forward test to be removed from the xfail list. The test results show a reduction in une…

For Context
md_apply_fix
A BFD function responsible for applying relocation fixups to data or code during the assembly process for a specific target architecture.
BFD_RELOC_8
A relocation type indicating an 8-bit value needs to be adjusted.
BFD_RELOC_16
A relocation type indicating a 16-bit value needs to be adjusted.
md_number_to_chars
A generic BFD utility function that converts a number into a sequence of bytes respecting the target's endianness.
Fixup
A placeholder in assembled code that needs to be resolved by the linker to a final address or value. In this context, if a fixup is not properly handled, it can lead to incorrect code.
Filed Under: microblazegasrelocationfixup