mirror of
https://github.com/intel/llvm.git
synced 2026-01-22 23:49:22 +08:00
Fix R_X86_64_RELATIVE for local symbols that refer to other sections.
We were mixing up the relocated and target sections. llvm-svn: 249360
This commit is contained in:
@@ -103,7 +103,10 @@ template <class ELFT> void RelocationSection<ELFT>::writeTo(uint8_t *Buf) {
|
||||
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 RelocationSection<ELFT>::writeTo(uint8_t *Buf) {
|
||||
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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user