[lld] r249360 - Fix R_X86_64_RELATIVE for local symbols that refer to other sections.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 5 15:49:17 PDT 2015
Author: rafael
Date: Mon Oct 5 17:49:16 2015
New Revision: 249360
URL: http://llvm.org/viewvc/llvm-project?rev=249360&view=rev
Log:
Fix R_X86_64_RELATIVE for local symbols that refer to other sections.
We were mixing up the relocated and target sections.
Modified:
lld/trunk/ELF/OutputSections.cpp
lld/trunk/test/elf2/relative-dynamic-reloc.s
Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=249360&r1=249359&r2=249360&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Mon Oct 5 17:49:16 2015
@@ -103,7 +103,10 @@ template <class ELFT> void RelocationSec
const Elf_Rel &RI = Rel.RI;
OutputSection<ELFT> *Out = C.getOutputSection();
uint32_t SymIndex = RI.getSymbol(IsMips64EL);
- const SymbolBody *Body = C.getFile()->getSymbolBody(SymIndex);
+ const ObjectFile<ELFT> &File = *C.getFile();
+ const SymbolBody *Body = File.getSymbolBody(SymIndex);
+ const ELFFile<ELFT> &Obj = File.getObj();
+
uint32_t Type = RI.getType(IsMips64EL);
if (Body && Target->relocNeedsGot(Type, *Body)) {
P->r_offset = GotSec.getEntryAddr(*Body);
@@ -124,7 +127,8 @@ template <class ELFT> void RelocationSec
if (Body)
Addent += getSymVA(cast<ELFSymbolBody<ELFT>>(*Body), BssSec);
else
- Addent += C.getOutputSectionOff() + Out->getVA();
+ Addent += getLocalSymVA(
+ Obj.getRelocationSymbol(&RI, File.getSymbolTable()), File);
}
}
if (IsRela)
Modified: lld/trunk/test/elf2/relative-dynamic-reloc.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/relative-dynamic-reloc.s?rev=249360&r1=249359&r2=249360&view=diff
==============================================================================
--- lld/trunk/test/elf2/relative-dynamic-reloc.s (original)
+++ lld/trunk/test/elf2/relative-dynamic-reloc.s Mon Oct 5 17:49:16 2015
@@ -11,6 +11,7 @@
// CHECK-NEXT: 0x[[BAR_ADDR:.*]] R_X86_64_RELATIVE - 0x[[BAR_ADDR]]
// CHECK-NEXT: 0x2010 R_X86_64_RELATIVE - 0x2009
// CHECK-NEXT: 0x{{.*}} R_X86_64_RELATIVE - 0x[[ZED_ADDR:.*]]
+// CHECK-NEXT: 0x{{.*}} R_X86_64_RELATIVE - 0x[[FOO_ADDR]]
// CHECK-NEXT: }
// CHECK-NEXT: ]
@@ -47,3 +48,6 @@ bar:
.hidden zed
.comm zed,1
.quad zed
+
+ .section abc,"a"
+ .quad foo
More information about the llvm-commits
mailing list