mirror of
https://github.com/intel/llvm.git
synced 2026-01-24 17:01:00 +08:00
[ELF][RISCV] Support PLT, GOT, copy and relative relocations
* Handle initial relocation types: R_RISCV_CALL_PLT and R_RISCV_GOT_HI20.
* Produce dynamic relocation types: R_RISCV_COPY, R_RISCV_RELATIVE, R_RISCV_JUMP_SLOT.
* Define SymbolRel as R_RISCV_{32,64}
* Generate PLT header: it is used by lazy binding PLT in glibc.
* R_RISCV_CALL is changed from R_PC to R_PC_PLT. If the target symbol is preemptable, this will suppress an unnecessary "canonical PLT".
This behavior is different from ld.bfd but it is agreed the current lld behavior is favored.
I have received positive responses from the binutils maintainer that the ABI/binutils implementation can be improved, see:
https://github.com/riscv/riscv-elf-psabi-doc/issues/98
https://sourceware.org/bugzilla/show_bug.cgi?id=24685
Many -no-pie/-pie/-shared programs linked against musl or glibc should work with this patch.
Reviewed By: jrtc27
Differential Revision: https://reviews.llvm.org/D63076
llvm-svn: 364812
This commit is contained in:
@@ -587,7 +587,7 @@ static Relocation *getRISCVPCRelHi20(const Symbol *Sym, uint64_t Addend) {
|
||||
});
|
||||
|
||||
for (auto It = Range.first; It != Range.second; ++It)
|
||||
if (It->Expr == R_PC)
|
||||
if (It->Type == R_RISCV_PCREL_HI20 || It->Type == R_RISCV_GOT_HI20)
|
||||
return &*It;
|
||||
|
||||
error("R_RISCV_PCREL_LO12 relocation points to " + IS->getObjMsg(D->Value) +
|
||||
|
||||
Reference in New Issue
Block a user