Extract input object compatibility checks into a new function
Introduces ``compatible_format`` function to centralize input object compatibility checks in elflink.c.
This change introduces a new function, compatible_format, in elflink.c to consolidate various checks that determine if an input object file is compatible with the linker’s output. This function is then used in several places, including _bfd_elf_link_create_dynstrtab and _bfd_elf_link_iterate_on_relocs, to ensure consistency and reduce code duplication.
In Details
Extracts compatibility checks between input object files and the linker's output into a new function compatible_format within elflink.c. This function consolidates checks related to ELF flavour, hash table compatibility, and section output type. It's used to replace scattered checks in _bfd_elf_link_create_dynstrtab, _bfd_elf_link_iterate_on_relocs, bfd_elf_gc_sections, and elf_gc_sweep, improving code maintainability.
- elflink.c
- A source file within the Binutils project that contains code for linking ELF (Executable and Linkable Format) object files.
- input object file
- An object file being processed by the linker as part of the overall executable or library construction.
- ELF flavour
- Refers to the specific characteristics or variant of the ELF format used by a particular architecture or system.
- hash table
- A data structure used by the linker to efficiently store and retrieve symbol information.
- GC sections
- Garbage Collection sections. Sections in an object file that the linker can discard if they are not referenced, helping to reduce the final executable size.