[lld] r250566 - ELF2: Treat IsMips64EL as a global configuration.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 16 15:51:43 PDT 2015
Author: ruiu
Date: Fri Oct 16 17:51:43 2015
New Revision: 250566
URL: http://llvm.org/viewvc/llvm-project?rev=250566&view=rev
Log:
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.
Modified:
lld/trunk/ELF/Config.h
lld/trunk/ELF/InputSection.cpp
lld/trunk/ELF/OutputSections.cpp
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Config.h?rev=250566&r1=250565&r2=250566&view=diff
==============================================================================
--- lld/trunk/ELF/Config.h (original)
+++ lld/trunk/ELF/Config.h Fri Oct 16 17:51:43 2015
@@ -50,6 +50,7 @@ struct Configuration {
bool DiscardNone;
bool EnableNewDtags;
bool ExportDynamic;
+ bool Mips64EL = false;
bool NoInhibitExec;
bool NoUndefined;
bool Shared;
Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=250566&r1=250565&r2=250566&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Fri Oct 16 17:51:43 2015
@@ -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.
Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=250566&r1=250565&r2=250566&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Fri Oct 16 17:51:43 2015
@@ -103,20 +103,19 @@ RelocationSection<ELFT>::RelocationSecti
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 RelocationSec
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)
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=250566&r1=250565&r2=250566&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Fri Oct 16 17:51:43 2015
@@ -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())
More information about the llvm-commits
mailing list