forked from OSchip/llvm-project
Include existing addend when computing R_X86_64_RELATIVE.
llvm-svn: 249353
This commit is contained in:
parent
0dbf123f7b
commit
3c83e2bbfb
|
@ -110,17 +110,23 @@ template <class ELFT> void RelocationSection<ELFT>::writeTo(uint8_t *Buf) {
|
|||
Target->getGotReloc(), IsMips64EL);
|
||||
} else {
|
||||
P->r_offset = RI.r_offset + C.getOutputSectionOff() + Out->getVA();
|
||||
uintX_t Addent = 0;
|
||||
if (IsRela)
|
||||
Addent = static_cast<const Elf_Rela &>(RI).r_addend;
|
||||
|
||||
if (Body && Body->isShared()) {
|
||||
P->setSymbolAndType(Body->getDynamicSymbolTableIndex(), Type,
|
||||
IsMips64EL);
|
||||
if (IsRela)
|
||||
static_cast<Elf_Rela *>(P)->r_addend =
|
||||
static_cast<const Elf_Rela &>(RI).r_addend;
|
||||
} else {
|
||||
P->setSymbolAndType(0, Target->getRelativeReloc(), IsMips64EL);
|
||||
if (IsRela)
|
||||
static_cast<Elf_Rela *>(P)->r_addend = P->r_offset;
|
||||
if (IsRela) {
|
||||
Addent += C.getOutputSectionOff() + Out->getVA();
|
||||
if (Body)
|
||||
Addent += cast<DefinedRegular<ELFT>>(Body)->Sym.st_value;
|
||||
}
|
||||
}
|
||||
if (IsRela)
|
||||
static_cast<Elf_Rela *>(P)->r_addend = Addent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -189,6 +189,7 @@ template <class ELFT>
|
|||
class RelocationSection final : public OutputSectionBase<ELFT::Is64Bits> {
|
||||
typedef typename llvm::object::ELFFile<ELFT>::Elf_Rel Elf_Rel;
|
||||
typedef typename llvm::object::ELFFile<ELFT>::Elf_Rela Elf_Rela;
|
||||
typedef typename llvm::object::ELFFile<ELFT>::uintX_t uintX_t;
|
||||
|
||||
public:
|
||||
RelocationSection(SymbolTableSection<ELFT> &DynSymSec,
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
// CHECK-NEXT: Section ({{.*}}) .rela.dyn {
|
||||
// CHECK-NEXT: 0x[[FOO_ADDR:.*]] R_X86_64_RELATIVE - 0x[[FOO_ADDR]]
|
||||
// CHECK-NEXT: 0x[[BAR_ADDR:.*]] R_X86_64_RELATIVE - 0x[[BAR_ADDR]]
|
||||
// CHECK-NEXT: 0x2010 R_X86_64_RELATIVE - 0x2009
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: ]
|
||||
|
||||
|
@ -38,3 +39,4 @@ foo:
|
|||
.global bar
|
||||
bar:
|
||||
.quad bar
|
||||
.quad bar + 1
|
||||
|
|
Loading…
Reference in New Issue