forked from OSchip/llvm-project
Move the last remaining hard coded relocations to Target.
Unfortunately the i386 and x86_64 relocation have the same numerical value and it is a probably a bit much to add got support for another architecture just to test this. llvm-svn: 248326
This commit is contained in:
parent
9147de0ddf
commit
7f07442bb6
|
@ -77,8 +77,8 @@ template <class ELFT> void RelocationSection<ELFT>::writeTo(uint8_t *Buf) {
|
|||
uint32_t Type = RI.getType(IsMips64EL);
|
||||
if (Target->relocNeedsGot(Type)) {
|
||||
P->r_offset = GotSec.getEntryAddr(*Body);
|
||||
P->setSymbolAndType(Body->getDynamicSymbolTableIndex(), R_X86_64_GLOB_DAT,
|
||||
IsMips64EL);
|
||||
P->setSymbolAndType(Body->getDynamicSymbolTableIndex(),
|
||||
Target->getGotReloc(), IsMips64EL);
|
||||
} else {
|
||||
P->r_offset = RI.r_offset + C.getOutputSectionOff() + Out->getVA();
|
||||
P->setSymbolAndType(Body->getDynamicSymbolTableIndex(), Type, IsMips64EL);
|
||||
|
|
|
@ -26,7 +26,10 @@ std::unique_ptr<TargetInfo> Target;
|
|||
|
||||
TargetInfo::~TargetInfo() {}
|
||||
|
||||
X86TargetInfo::X86TargetInfo() { PCRelReloc = R_386_PC32; }
|
||||
X86TargetInfo::X86TargetInfo() {
|
||||
PCRelReloc = R_386_PC32;
|
||||
GotReloc = R_386_GLOB_DAT;
|
||||
}
|
||||
|
||||
void X86TargetInfo::writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,
|
||||
uint64_t PltEntryAddr) const {
|
||||
|
@ -83,7 +86,10 @@ void X86TargetInfo::relocateOne(uint8_t *Buf, const void *RelP, uint32_t Type,
|
|||
}
|
||||
}
|
||||
|
||||
X86_64TargetInfo::X86_64TargetInfo() { PCRelReloc = R_X86_64_PC32; }
|
||||
X86_64TargetInfo::X86_64TargetInfo() {
|
||||
PCRelReloc = R_X86_64_PC32;
|
||||
GotReloc = R_X86_64_GLOB_DAT;
|
||||
}
|
||||
|
||||
void X86_64TargetInfo::writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,
|
||||
uint64_t PltEntryAddr) const {
|
||||
|
@ -156,6 +162,7 @@ void X86_64TargetInfo::relocateOne(uint8_t *Buf, const void *RelP,
|
|||
|
||||
PPC64TargetInfo::PPC64TargetInfo() {
|
||||
// PCRelReloc = FIXME
|
||||
// GotReloc = FIXME
|
||||
}
|
||||
void PPC64TargetInfo::writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,
|
||||
uint64_t PltEntryAddr) const {}
|
||||
|
@ -183,6 +190,7 @@ void PPC64TargetInfo::relocateOne(uint8_t *Buf, const void *RelP, uint32_t Type,
|
|||
|
||||
PPCTargetInfo::PPCTargetInfo() {
|
||||
// PCRelReloc = FIXME
|
||||
// GotReloc = FIXME
|
||||
}
|
||||
void PPCTargetInfo::writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,
|
||||
uint64_t PltEntryAddr) const {}
|
||||
|
@ -193,6 +201,7 @@ void PPCTargetInfo::relocateOne(uint8_t *Buf, const void *RelP, uint32_t Type,
|
|||
|
||||
ARMTargetInfo::ARMTargetInfo() {
|
||||
// PCRelReloc = FIXME
|
||||
// GotReloc = FIXME
|
||||
}
|
||||
void ARMTargetInfo::writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,
|
||||
uint64_t PltEntryAddr) const {}
|
||||
|
|
|
@ -19,6 +19,7 @@ class SymbolBody;
|
|||
class TargetInfo {
|
||||
public:
|
||||
unsigned getPCRelReloc() const { return PCRelReloc; }
|
||||
unsigned getGotReloc() const { return GotReloc; }
|
||||
virtual void writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,
|
||||
uint64_t PltEntryAddr) const = 0;
|
||||
virtual bool relocNeedsGot(uint32_t Type) const = 0;
|
||||
|
@ -30,6 +31,7 @@ public:
|
|||
|
||||
protected:
|
||||
unsigned PCRelReloc;
|
||||
unsigned GotReloc;
|
||||
};
|
||||
|
||||
class X86TargetInfo final : public TargetInfo {
|
||||
|
|
Loading…
Reference in New Issue