microblaze: Fix relocations against discarded sections
Corrects microblaze relocations against discarded sections, preventing garbage in debug info.
This commit fixes an issue in the microblaze ELF relocator where relocations against symbols in discarded sections were not handled correctly. This led to relocations surviving and resolving against dead symbols, resulting in garbage data in debug sections where zeros were expected. The fix ensures that these relocations are properly neutralized, and new test cases demonstrate the correction.
In Details
The microblaze_elf_relocate_section function in bfd/elf32-microblaze.c processes relocations. This commit addresses a bug where it failed to handle RELOC_AGAINST_DISCARDED_SECTION relocations, unlike many other BFD backends. The fix involves adding checks for sym_hashes (which can be NULL if an object has no global symbols) and ensuring the relocation resolution logic correctly neutralizes these relocations when their defining section is discarded. The current structure of the function allows this fix without significant restructuring.
- microblaze
- A 32-bit RISC soft processor core developed by Xilinx, often used in embedded systems. Binutils provides support for targeting this architecture.
- ELF
- Executable and Linkable Format. A standard file format for object files, executables, and shared libraries on many Unix-like systems.
- Relocation
- A process performed by the linker to adjust symbolic references in object files, typically to account for the final memory addresses of code and data.
- Discarded sections
- Sections within an object file that are marked for removal during the linking process, often due to linkonce or comdat attributes, or if they contain only unreferenced debug information.
- Debug sections
- Sections in an object file that contain debugging information, such as symbol names, line numbers, and type information, used by debuggers.