mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-14 11:39:35 +00:00
ELF2: Treat IsMips64EL as a global configuration.
If one file is MIPS64EL, all files are MIPS64EL, and vice versa. We do not have to look up MIPS-ness for each file. Currently we do not support 64-bit MIPS, so the config value is always false. llvm-svn: 250566
This commit is contained in:
parent
a9da9b48ef
commit
6455852a28
@ -50,6 +50,7 @@ struct Configuration {
|
||||
bool DiscardNone;
|
||||
bool EnableNewDtags;
|
||||
bool ExportDynamic;
|
||||
bool Mips64EL = false;
|
||||
bool NoInhibitExec;
|
||||
bool NoUndefined;
|
||||
bool Shared;
|
||||
|
@ -48,10 +48,9 @@ void InputSection<ELFT>::relocate(
|
||||
iterator_range<const Elf_Rel_Impl<ELFT, isRela> *> Rels,
|
||||
const ObjectFile<ELFT> &File, uintX_t BaseAddr) {
|
||||
typedef Elf_Rel_Impl<ELFT, isRela> RelType;
|
||||
bool IsMips64EL = File.getObj().isMips64EL();
|
||||
for (const RelType &RI : Rels) {
|
||||
uint32_t SymIndex = RI.getSymbol(IsMips64EL);
|
||||
uint32_t Type = RI.getType(IsMips64EL);
|
||||
uint32_t SymIndex = RI.getSymbol(Config->Mips64EL);
|
||||
uint32_t Type = RI.getType(Config->Mips64EL);
|
||||
|
||||
// Handle relocations for local symbols -- they never get
|
||||
// resolved so we don't allocate a SymbolBody.
|
||||
|
@ -103,20 +103,19 @@ RelocationSection<ELFT>::RelocationSection(bool IsRela)
|
||||
|
||||
template <class ELFT> void RelocationSection<ELFT>::writeTo(uint8_t *Buf) {
|
||||
const unsigned EntrySize = IsRela ? sizeof(Elf_Rela) : sizeof(Elf_Rel);
|
||||
bool IsMips64EL = Relocs[0].C.getFile()->getObj().isMips64EL();
|
||||
for (const DynamicReloc<ELFT> &Rel : Relocs) {
|
||||
auto *P = reinterpret_cast<Elf_Rel *>(Buf);
|
||||
Buf += EntrySize;
|
||||
|
||||
const InputSection<ELFT> &C = Rel.C;
|
||||
const Elf_Rel &RI = Rel.RI;
|
||||
uint32_t SymIndex = RI.getSymbol(IsMips64EL);
|
||||
uint32_t SymIndex = RI.getSymbol(Config->Mips64EL);
|
||||
const ObjectFile<ELFT> &File = *C.getFile();
|
||||
SymbolBody *Body = File.getSymbolBody(SymIndex);
|
||||
if (Body)
|
||||
Body = Body->repl();
|
||||
|
||||
uint32_t Type = RI.getType(IsMips64EL);
|
||||
uint32_t Type = RI.getType(Config->Mips64EL);
|
||||
|
||||
bool NeedsGot = Body && Target->relocNeedsGot(Type, *Body);
|
||||
bool CanBePreempted = canBePreempted(Body, NeedsGot);
|
||||
@ -128,21 +127,21 @@ template <class ELFT> void RelocationSection<ELFT>::writeTo(uint8_t *Buf) {
|
||||
else
|
||||
Addend += getLocalRelTarget(File, RI);
|
||||
}
|
||||
P->setSymbolAndType(0, Target->getRelativeReloc(), IsMips64EL);
|
||||
P->setSymbolAndType(0, Target->getRelativeReloc(), Config->Mips64EL);
|
||||
}
|
||||
|
||||
if (NeedsGot) {
|
||||
P->r_offset = Out<ELFT>::Got->getEntryAddr(*Body);
|
||||
if (CanBePreempted)
|
||||
P->setSymbolAndType(Body->getDynamicSymbolTableIndex(),
|
||||
Target->getGotReloc(), IsMips64EL);
|
||||
Target->getGotReloc(), Config->Mips64EL);
|
||||
} else {
|
||||
if (IsRela)
|
||||
Addend += static_cast<const Elf_Rela &>(RI).r_addend;
|
||||
P->r_offset = RI.r_offset + C.OutSec->getVA() + C.OutSecOff;
|
||||
if (CanBePreempted)
|
||||
P->setSymbolAndType(Body->getDynamicSymbolTableIndex(), Type,
|
||||
IsMips64EL);
|
||||
Config->Mips64EL);
|
||||
}
|
||||
|
||||
if (IsRela)
|
||||
|
@ -172,11 +172,10 @@ void Writer<ELFT>::scanRelocs(
|
||||
iterator_range<const Elf_Rel_Impl<ELFT, isRela> *> Rels) {
|
||||
typedef Elf_Rel_Impl<ELFT, isRela> RelType;
|
||||
const ObjectFile<ELFT> &File = *C.getFile();
|
||||
bool IsMips64EL = File.getObj().isMips64EL();
|
||||
for (const RelType &RI : Rels) {
|
||||
uint32_t SymIndex = RI.getSymbol(IsMips64EL);
|
||||
uint32_t SymIndex = RI.getSymbol(Config->Mips64EL);
|
||||
SymbolBody *Body = File.getSymbolBody(SymIndex);
|
||||
uint32_t Type = RI.getType(IsMips64EL);
|
||||
uint32_t Type = RI.getType(Config->Mips64EL);
|
||||
|
||||
// Set "used" bit for --as-needed.
|
||||
if (Body && Body->isUndefined() && !Body->isWeak())
|
||||
|
Loading…
Reference in New Issue
Block a user