Move _bfd_riscv_elf_merge_private_bfd_data()
The RISC-V BFD backend refactors internal data merging by moving a function and making a parameter explicit to reduce redundant code.
The internal _bfd_riscv_elf_merge_private_bfd_data() function in the RISC-V BFD backend has been moved from elfnn-riscv.c to elfxx-riscv.c. This change, which removes duplicate code for different architectural sizes (32-bit vs. 64-bit), now passes the ARCH_SIZE as an explicit function parameter. This refactoring simplifies the codebase by centralizing common logic, reducing maintenance overhead and the potential for inconsistencies.
In Details
The BFD (Binary File Descriptor) library, for RISC-V ELF objects, manages architecture-specific data during linking. This commit refactors the _bfd_riscv_elf_merge_private_bfd_data() function, which is responsible for merging private BFD data associated with RISC-V ELF files. Previously, separate implementations existed for 32-bit and 64-bit architectures in elfnn-riscv.c and elfxx-riscv.c respectively. The change centralizes this logic in elfxx-riscv.c and passes the ARCH_SIZE (which determines the size of the architecture, e.g., 32-bit or 64-bit) as an explicit parameter, eliminat…
For Context
When you compile and link programs for a specific computer architecture like RISC-V, the Binutils toolchain (specifically the BFD library) needs to handle details unique to that architecture. This commit refactors how BFD manages certain internal data (_bfd_riscv_elf_merge_private_bfd_data()) related to RISC-V object files. Think of it like streamlining a factory process: instead of having two separate assembly lines for slightly different versions of the same product, they've combined the core process and now just feed in a configuration parameter to handle the small differences. This makes the tools that build your software easier to maintain and less prone to errors.