binutils Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
binutils/microblaze

MicroBlaze assembler uses md_number_to_chars for apply_fix

MicroBlaze assembler simplifies relocation fixup handling using a standard utility function.

The MicroBlaze assembler’s relocation handling has been refactored to use the md_number_to_chars function, replacing manual bitwise operations for writing data and instruction relocations. This change unifies the implementation with other backends and simplifies code for handling byte order and immediate field placement, aiming for code clarity without functional changes.

In Details

In gas/config/tc-microblaze.c, the manual construction of relocation fixups using bitwise OR operations (|=) and direct byte assignments has been replaced by calls to md_number_to_chars. For data relocations, this simplifies the code to a single call. For instruction relocations, where immediate fields have specific offsets within the instruction word, md_number_to_chars is used in conjunction with an INST_IMM_OFFSET macro to correctly handle both byte ordering and the immediate field's position, similar to how Mips handles it.

For Context
md_apply_fix
A function in an assembler's backend responsible for applying relocation information to an object file, adjusting values based on symbol addresses and relocation types.
md_number_to_chars
A utility function, common in assembler backends, that converts an integer value into a sequence of bytes according to the target's endianness and desired word size.
relocation
A process performed by the linker or assembler to adjust memory addresses in code or data. It resolves references to symbols that are not yet known at compile or assembly time.
endianness
The order in which a machine's memory stores the bytes of a multi-byte word. Big-endian stores the most significant byte first, while little-endian stores the least significant byte first.
Filed Under: microblazeassemblerrelocationcode-refactor