ld/PE: Use standard relocation type checks
Simplifies PE linker code by using a generic `in_reloc_p` function and removing architecture-specific relocation type recording.
This commit refactors the PE linker’s handling of relocation types. It introduces or enhances a generic in_reloc_p function to determine if a relocation is ‘in-place’ (i.e., modifies the code/data directly). By filling in the necessary relocation type checks in per-architecture implementations, the linker can drop its custom recording of section, section-relative, and absolute relocation types. This leads to cleaner and more maintainable code.
In Details
This patch aims to consolidate relocation type handling in the PE loader. Previously, multiple architecture-specific COFF backends had custom logic for recording relocation types. The introduction and refinement of in_reloc_p allows for a more standardized approach. By ensuring that per-arch implementations correctly identify section, section-relative, image-base relative, and ABS/NONE relocation types within the in_reloc_p framework, the linker's generic PE relocation handling code (ld/pe-dll.c) can be simplified by removing its custom recording mechanisms.
- ld
- The GNU linker, responsible for combining object files and libraries into an executable or shared library.
- PE
- Portable Executable, a file format for executables, object code, DLLs, and system components used in 32-bit and 64-bit versions of Windows.
- Relocation
- Information in an object file that tells the linker how to modify code or data addresses when combining object files into an executable or shared library.
- Relocation type
- A specific kind of relocation, indicating how an address in the code or data should be adjusted (e.g., absolute, relative to program counter, relative to image base).