[lld] r267979 - Do not produce broken debug info.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 28 20:21:09 PDT 2016
Author: ruiu
Date: Thu Apr 28 22:21:08 2016
New Revision: 267979
URL: http://llvm.org/viewvc/llvm-project?rev=267979&view=rev
Log:
Do not produce broken debug info.
r267917 produces corrupted debug info because it didn't apply
relocations to right offsets.
Modified:
lld/trunk/ELF/InputSection.cpp
lld/trunk/test/ELF/relocation-non-alloc.s
Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=267979&r1=267978&r2=267979&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Thu Apr 28 22:21:08 2016
@@ -238,18 +238,22 @@ template <class RelTy>
void InputSection<ELFT>::relocateNonAlloc(uint8_t *Buf, ArrayRef<RelTy> Rels) {
const unsigned Bits = sizeof(uintX_t) * 8;
for (const RelTy &Rel : Rels) {
- uint8_t *BufLoc = Buf + Rel.r_offset;
- uintX_t AddrLoc = this->OutSec->getVA() + Rel.r_offset;
uint32_t Type = Rel.getType(Config->Mips64EL);
- SymbolBody &Sym = this->File->getRelocTargetSym(Rel);
+ uintX_t Addend = getAddend<ELFT>(Rel);
+ if (!RelTy::IsRela)
+ Addend += Target->getImplicitAddend(Buf + Rel.r_offset, Type);
+ SymbolBody &Sym = this->File->getRelocTargetSym(Rel);
if (Target->getRelExpr(Type, Sym) != R_ABS) {
error(this->getSectionName() + " has non-ABS reloc");
return;
}
+ uintX_t Offset = this->getOffset(Rel.r_offset);
+ uint8_t *BufLoc = Buf + Offset;
+ uintX_t AddrLoc = this->OutSec->getVA() + Offset;
uint64_t SymVA = SignExtend64<Bits>(getSymVA<ELFT>(
- Type, getAddend<ELFT>(Rel), AddrLoc, Sym, BufLoc, *this->File, R_ABS));
+ Type, Addend, AddrLoc, Sym, BufLoc, *this->File, R_ABS));
Target->relocateOne(BufLoc, Type, SymVA);
}
}
Modified: lld/trunk/test/ELF/relocation-non-alloc.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/relocation-non-alloc.s?rev=267979&r1=267978&r2=267979&view=diff
==============================================================================
--- lld/trunk/test/ELF/relocation-non-alloc.s (original)
+++ lld/trunk/test/ELF/relocation-non-alloc.s Thu Apr 28 22:21:08 2016
@@ -27,13 +27,14 @@
// CHECK-NEXT: ]
// CHECK-NEXT: Address: 0x0
// CHECK-NEXT: Offset:
-// CHECK-NEXT: Size: 16
+// CHECK-NEXT: Size: 32
// CHECK-NEXT: Link: 0
// CHECK-NEXT: Info: 0
// CHECK-NEXT: AddressAlignment: 1
// CHECK-NEXT: EntrySize: 0
// CHECK-NEXT: SectionData (
// CHECK-NEXT: 0000: 00100000 00000000 00100000 00000000
+// CHECK-NEXT: 0010: 00100000 00000000 00100000 00000000
// CHECK-NEXT: )
// CHECK: Relocations [
@@ -49,6 +50,10 @@ bar:
.quad bar
.quad zed
+ .section foo
+ .quad bar
+ .quad zed
+
.section foo
.quad bar
.quad zed
More information about the llvm-commits
mailing list