MicroBlaze: Handle BFD_RELOC_8 and BFD_RELOC_16 relocations
MicroBlaze assembler now correctly handles 8-bit and 16-bit relocations, fixing incorrect zeroing of data.
The MicroBlaze assembler’s md_apply_fix function previously lacked specific cases for BFD_RELOC_8 and BFD_RELOC_16 relocations. This caused byte or halfword data, whose values were only known at fixup time, to be assembled as zero, with no relocation information surviving for the linker. This commit adds these cases, ensuring values are written correctly and fixing issues in the gas testsuite.
In Details
The md_apply_fix function in tc-microblaze.c handles MicroBlaze relocations. Previously, it only had explicit cases for BFD_RELOC_32 and BFD_RELOC_64, and MicroBlaze-specific relocations. BFD_RELOC_8 and BFD_RELOC_16 would fall through to a default handler that wrote nothing, leading to zeroed data when these relocations were present. This change ensures these smaller relocations are handled similarly to other architectures like aarch64, mips, and sparc by using md_number_to_chars to write the value, preventing data loss and fixing testsuite failures.
- BFD_RELOC_8
- A relocation type in the Binary File Descriptor (BFD) library representing an 8-bit data field that needs to be resolved at link time.
- BFD_RELOC_16
- A relocation type in the Binary File Descriptor (BFD) library representing a 16-bit data field that needs to be resolved at link time.
- fixup time
- The stage in the assembly or compilation process where symbolic addresses or values are replaced with their final, resolved numerical values. This typically happens before or during linking.
- md_apply_fix
- A function within the BFD library's machine-dependent code for a specific architecture (here, MicroBlaze) that applies relocation information to the output object file.
- md_number_to_chars
- A BFD library function that converts a numerical value into a sequence of bytes in the target's endianness, used for writing data into object files.
- BFD_RELOC_NONE
- A relocation type indicating that no further relocation processing is needed for a particular symbol or address.
- gas
- The GNU Assembler, part of the GNU Binutils project. It translates assembly language code into machine code.