[lld] r365035 - [ELF][RISCV] Allow R_RISCV_ADD in relocateNonAlloc()
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 3 05:48:05 PDT 2019
Author: maskray
Date: Wed Jul 3 05:48:04 2019
New Revision: 365035
URL: http://llvm.org/viewvc/llvm-project?rev=365035&view=rev
Log:
[ELF][RISCV] Allow R_RISCV_ADD in relocateNonAlloc()
gcc may generate .debug_info/.debug_aranges/.debug_line/etc that are
relocated by R_RISCV_ADD*/R_RISCV_SUB* pairs.
Allow R_RISCV_ADD in non-SHF_ALLOC section to fix link errors like:
ld.lld: error: print.c:(.debug_frame+0x60): has non-ABS relocation R_RISCV_ADD64 against symbol '.L0 '
Differential Revision: https://reviews.llvm.org/D63259
Modified:
lld/trunk/ELF/InputSection.cpp
lld/trunk/test/ELF/riscv-reloc-add.s
Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=365035&r1=365034&r2=365035&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Wed Jul 3 05:48:04 2019
@@ -838,7 +838,7 @@ void InputSection::relocateNonAlloc(uint
if (Expr == R_NONE)
continue;
- if (Expr != R_ABS && Expr != R_DTPREL) {
+ if (Expr != R_ABS && Expr != R_DTPREL && Expr != R_RISCV_ADD) {
std::string Msg = getLocation<ELFT>(Offset) +
": has non-ABS relocation " + toString(Type) +
" against symbol '" + toString(Sym) + "'";
Modified: lld/trunk/test/ELF/riscv-reloc-add.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/riscv-reloc-add.s?rev=365035&r1=365034&r2=365035&view=diff
==============================================================================
--- lld/trunk/test/ELF/riscv-reloc-add.s (original)
+++ lld/trunk/test/ELF/riscv-reloc-add.s Wed Jul 3 05:48:04 2019
@@ -24,3 +24,9 @@ _start:
.word .L1 - .L0
.half .L1 - .L0
.byte .L1 - .L0
+
+## Debug section may use R_RISCV_ADD64/R_RISCV_SUB64 pairs to measure lengths
+## of code ranges (e.g. DW_AT_high_pc). Check we allow R_RISCV_ADD*/R_RISCV_SUB*
+## in such non-SHF_ALLOC sections in -pie/-shared mode.
+.section .debug_info
+.quad .L1 - .L0
More information about the llvm-commits
mailing list