RISC-V: Correctly exclude .rela.plt from DT_RELASZ
Fixes RISC-V dynamic linking information to prevent duplicate processing of relocation sections.
This change corrects how the RISC-V dynamic linker calculates the size of relocation entries. Previously, it incorrectly included the .rela.plt section in DT_RELASZ, causing tools like llvm-bolt to process the same relocation information twice. By defining elf_backend_dtrel_excludes_plt, the calculation now excludes .rela.plt, aligning with other targets and resolving the issue.
In Details
The RISC-V ELF backend in binutils did not define elf_backend_dtrel_excludes_plt, unlike other targets such as x86-64 and AArch64. This resulted in DT_RELASZ encompassing both .rela.dyn and .rela.plt. When .rela.dyn is empty, this leads to aliasing where DT_RELA equals DT_JMPREL and DT_RELASZ equals DT_PLTRELSZ. While glibc tolerates this, tools like llvm-bolt are confused by the duplicated information. Defining the macro ensures DT_RELASZ correctly excludes .rela.plt, resolving the aliasing when .rela.dyn is empty.
- RISC-V
- An open-standard Instruction Set Architecture (ISA) based on RISC principles.
- ELF
- Executable and Linkable Format, a common standard file format for object files, executables, and shared libraries on Unix-like systems.
- DT_RELASZ
- A dynamic tag in an ELF file that specifies the size of the relocation entry array.
- .rela.dyn
- A section in an ELF file containing relocation entries used for dynamically linked executables and shared libraries.
- .rela.plt
- A section in an ELF file containing relocation entries for the Procedure Linkage Table (PLT), used for lazy binding of function calls.
- llvm-bolt
- A profile-guided binary optimization tool from the LLVM project.