riscv: Ignore attributes in empty input file
Fixes RISC-V linker to ignore attributes in empty or .note.gnu.build-id sections, passing multiple tests.
This commit modifies the RISC-V ELF linker to ignore attributes when merging data from empty input files or sections like .note.gnu.build-id. Previously, these sections could cause linker test failures related to diagnostics, garbage collection, and symbol definitions. The change ensures these sections do not interfere with attribute merging, resolving multiple failing tests.
In Details
In _bfd_riscv_elf_merge_private_bfd_data, modifies attribute merging logic to ignore empty input BFDs and sections that lack SEC_LOAD and SEC_HAS_CONTENTS flags (specifically targeting .note.gnu.build-id and other empty sections). This resolves multiple linker test failures on RISC-V related to diagnostics, garbage collection, and symbol handling when such sections are present.
- RISC-V
- An open-source instruction set architecture (ISA) that is gaining traction in various computing domains.
- ELF
- Executable and Linkable Format. A common standard file format for executables, object code, shared libraries, and core dumps, used on many Unix-like systems.
- attributes
- In the context of ELF files and linkers, attributes can refer to metadata associated with sections or symbols, influencing linking behavior or providing information.
- .note.gnu.build-id
- An ELF note section containing a unique identifier for the build of an executable or library, used for debugging and crash report correlation.
- SEC_LOAD
- A flag for an ELF section indicating that it should be loaded into memory when the program is executed.
- SEC_HAS_CONTENTS
- A flag for an ELF section indicating that it contains actual data or code, as opposed to being a placeholder or metadata section.