forked from OSchip/llvm-project
parent
9385aaa848
commit
67c60727ce
|
|
@ -37,7 +37,7 @@ struct FileFlags {
|
|||
StringRef Filename;
|
||||
uint32_t Flags;
|
||||
};
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static StringRef getAbiName(uint32_t Flags) {
|
||||
switch (Flags) {
|
||||
|
|
@ -337,8 +337,8 @@ uint8_t elf::getMipsFpAbiFlag(uint8_t OldFlag, uint8_t NewFlag,
|
|||
return NewFlag;
|
||||
if (compareMipsFpAbi(OldFlag, NewFlag) < 0)
|
||||
error("target floating point ABI '" + getMipsFpAbiName(OldFlag) +
|
||||
"' is incompatible with '" + getMipsFpAbiName(NewFlag) + "': " +
|
||||
FileName);
|
||||
"' is incompatible with '" + getMipsFpAbiName(NewFlag) +
|
||||
"': " + FileName);
|
||||
return OldFlag;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ struct EhSectionPiece;
|
|||
|
||||
template <class ELFT> size_t readEhRecordSize(InputSectionBase *S, size_t Off);
|
||||
template <class ELFT> uint8_t getFdeEncoding(EhSectionPiece *P);
|
||||
}
|
||||
}
|
||||
} // namespace elf
|
||||
} // namespace lld
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace lld {
|
|||
namespace elf {
|
||||
void unlinkAsync(StringRef Path);
|
||||
std::error_code tryCreateFile(StringRef Path);
|
||||
}
|
||||
}
|
||||
} // namespace elf
|
||||
} // namespace lld
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@
|
|||
#define LLD_ELF_GDB_INDEX_H
|
||||
|
||||
#include "InputFiles.h"
|
||||
#include "llvm/Object/ELF.h"
|
||||
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
|
||||
#include "llvm/Object/ELF.h"
|
||||
|
||||
namespace lld {
|
||||
namespace elf {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,6 @@ namespace lld {
|
|||
namespace elf {
|
||||
template <class ELFT> void doIcf();
|
||||
}
|
||||
}
|
||||
} // namespace lld
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@
|
|||
#define LLD_ELF_INPUT_FILES_H
|
||||
|
||||
#include "Config.h"
|
||||
#include "InputSection.h"
|
||||
#include "Error.h"
|
||||
#include "InputSection.h"
|
||||
#include "Symbols.h"
|
||||
|
||||
#include "lld/Core/LLVM.h"
|
||||
|
|
@ -34,7 +34,7 @@ struct DILineInfo;
|
|||
namespace lto {
|
||||
class InputFile;
|
||||
}
|
||||
}
|
||||
} // namespace llvm
|
||||
|
||||
namespace lld {
|
||||
namespace elf {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace llvm {
|
|||
namespace lto {
|
||||
class LTO;
|
||||
}
|
||||
}
|
||||
} // namespace llvm
|
||||
|
||||
namespace lld {
|
||||
namespace elf {
|
||||
|
|
@ -51,7 +51,7 @@ private:
|
|||
std::vector<SmallString<0>> Buff;
|
||||
std::vector<std::unique_ptr<MemoryBuffer>> Files;
|
||||
};
|
||||
}
|
||||
}
|
||||
} // namespace elf
|
||||
} // namespace lld
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -462,7 +462,7 @@ void LinkerScript::fabricateDefaultCommands() {
|
|||
// The Sections with -T<section> have been sorted in order of ascending
|
||||
// address. We must lower StartAddr if the lowest -T<section address> as
|
||||
// calls to setDot() must be monotonically increasing.
|
||||
for (auto& KV : Config->SectionStartMap)
|
||||
for (auto &KV : Config->SectionStartMap)
|
||||
StartAddr = std::min(StartAddr, KV.second);
|
||||
|
||||
Commands.push_back(make<SymbolAssignment>(
|
||||
|
|
@ -752,7 +752,7 @@ void LinkerScript::adjustSectionsAfterSorting() {
|
|||
Cmd->MemRegion = findMemoryRegion(Cmd);
|
||||
// Handle align (e.g. ".foo : ALIGN(16) { ... }").
|
||||
if (Cmd->AlignExpr)
|
||||
Cmd->Sec->updateAlignment(Cmd->AlignExpr().getValue());
|
||||
Cmd->Sec->updateAlignment(Cmd->AlignExpr().getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ namespace elf {
|
|||
struct OutputSectionCommand;
|
||||
template <class ELFT>
|
||||
void writeMapFile(llvm::ArrayRef<OutputSectionCommand *> Script);
|
||||
}
|
||||
}
|
||||
} // namespace elf
|
||||
} // namespace lld
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ inline void freeArena() {
|
|||
Alloc->reset();
|
||||
BAlloc.Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace elf
|
||||
} // namespace lld
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -222,16 +222,16 @@ void OutputSectionFactory::addInputSec(InputSectionBase *IS,
|
|||
|
||||
if (Sec) {
|
||||
if (getIncompatibleFlags(Sec->Flags) != getIncompatibleFlags(IS->Flags))
|
||||
error("incompatible section flags for " + Sec->Name +
|
||||
"\n>>> " + toString(IS) + ": 0x" + utohexstr(IS->Flags) +
|
||||
error("incompatible section flags for " + Sec->Name + "\n>>> " +
|
||||
toString(IS) + ": 0x" + utohexstr(IS->Flags) +
|
||||
"\n>>> output section " + Sec->Name + ": 0x" +
|
||||
utohexstr(Sec->Flags));
|
||||
if (Sec->Type != IS->Type) {
|
||||
if (canMergeToProgbits(Sec->Type) && canMergeToProgbits(IS->Type))
|
||||
Sec->Type = SHT_PROGBITS;
|
||||
else
|
||||
error("section type mismatch for " + IS->Name +
|
||||
"\n>>> " + toString(IS) + ": " +
|
||||
error("section type mismatch for " + IS->Name + "\n>>> " +
|
||||
toString(IS) + ": " +
|
||||
getELFSectionTypeName(Config->EMachine, IS->Type) +
|
||||
"\n>>> output section " + Sec->Name + ": " +
|
||||
getELFSectionTypeName(Config->EMachine, Sec->Type));
|
||||
|
|
|
|||
|
|
@ -111,8 +111,8 @@ struct SectionKey {
|
|||
uint64_t Flags;
|
||||
uint32_t Alignment;
|
||||
};
|
||||
}
|
||||
}
|
||||
} // namespace elf
|
||||
} // namespace lld
|
||||
namespace llvm {
|
||||
template <> struct DenseMapInfo<lld::elf::SectionKey> {
|
||||
static lld::elf::SectionKey getEmptyKey();
|
||||
|
|
@ -121,7 +121,7 @@ template <> struct DenseMapInfo<lld::elf::SectionKey> {
|
|||
static bool isEqual(const lld::elf::SectionKey &LHS,
|
||||
const lld::elf::SectionKey &RHS);
|
||||
};
|
||||
}
|
||||
} // namespace llvm
|
||||
namespace lld {
|
||||
namespace elf {
|
||||
|
||||
|
|
@ -150,5 +150,4 @@ extern std::vector<OutputSectionCommand *> OutputSectionCommands;
|
|||
} // namespace elf
|
||||
} // namespace lld
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -276,7 +276,7 @@ handleTlsRelocation(uint32_t Type, SymbolBody &Body, InputSectionBase &C,
|
|||
} else {
|
||||
C.Relocations.push_back(
|
||||
{Target->adjustRelaxExpr(Type, nullptr, R_RELAX_TLS_GD_TO_LE), Type,
|
||||
Offset, Addend, &Body});
|
||||
Offset, Addend, &Body});
|
||||
}
|
||||
return Target->TlsGdRelaxSkip;
|
||||
}
|
||||
|
|
@ -1028,7 +1028,7 @@ ThunkSection *ThunkCreator::getISThunkSec(InputSection *IS, OutputSection *OS) {
|
|||
OutputSectionCommand *C = Script->getCmd(TOS);
|
||||
std::vector<InputSection *> *Range = nullptr;
|
||||
for (BaseCommand *BC : C->Commands)
|
||||
if (auto *ISD = dyn_cast<InputSectionDescription> (BC)) {
|
||||
if (auto *ISD = dyn_cast<InputSectionDescription>(BC)) {
|
||||
InputSection *first = ISD->Sections.front();
|
||||
InputSection *last = ISD->Sections.back();
|
||||
if (IS->OutSecOff >= first->OutSecOff &&
|
||||
|
|
@ -1050,7 +1050,6 @@ ThunkSection *ThunkCreator::addThunkSection(OutputSection *OS,
|
|||
return TS;
|
||||
}
|
||||
|
||||
|
||||
std::pair<Thunk *, bool> ThunkCreator::getThunk(SymbolBody &Body,
|
||||
uint32_t Type) {
|
||||
auto Res = ThunkedSymbols.insert({&Body, std::vector<Thunk *>()});
|
||||
|
|
@ -1107,32 +1106,32 @@ bool ThunkCreator::createThunks(
|
|||
// We separate the creation of ThunkSections from the insertion of the
|
||||
// ThunkSections back into the OutputSection as ThunkSections are not always
|
||||
// inserted into the same OutputSection as the caller.
|
||||
forEachExecInputSection(
|
||||
OutputSections, [&](OutputSectionCommand *Cmd,
|
||||
std::vector<InputSection *> *ISR, InputSection *IS) {
|
||||
for (Relocation &Rel : IS->Relocations) {
|
||||
SymbolBody &Body = *Rel.Sym;
|
||||
if (Thunks.find(&Body) != Thunks.end() ||
|
||||
!Target->needsThunk(Rel.Expr, Rel.Type, IS->File, Body))
|
||||
continue;
|
||||
Thunk *T;
|
||||
bool IsNew;
|
||||
std::tie(T, IsNew) = getThunk(Body, Rel.Type);
|
||||
if (IsNew) {
|
||||
// Find or create a ThunkSection for the new Thunk
|
||||
ThunkSection *TS;
|
||||
if (auto *TIS = T->getTargetInputSection())
|
||||
TS = getISThunkSec(TIS, Cmd->Sec);
|
||||
else
|
||||
TS = getOSThunkSec(Cmd, ISR);
|
||||
TS->addThunk(T);
|
||||
Thunks[T->ThunkSym] = T;
|
||||
}
|
||||
// Redirect relocation to Thunk, we never go via the PLT to a Thunk
|
||||
Rel.Sym = T->ThunkSym;
|
||||
Rel.Expr = fromPlt(Rel.Expr);
|
||||
}
|
||||
});
|
||||
forEachExecInputSection(OutputSections, [&](OutputSectionCommand *Cmd,
|
||||
std::vector<InputSection *> *ISR,
|
||||
InputSection *IS) {
|
||||
for (Relocation &Rel : IS->Relocations) {
|
||||
SymbolBody &Body = *Rel.Sym;
|
||||
if (Thunks.find(&Body) != Thunks.end() ||
|
||||
!Target->needsThunk(Rel.Expr, Rel.Type, IS->File, Body))
|
||||
continue;
|
||||
Thunk *T;
|
||||
bool IsNew;
|
||||
std::tie(T, IsNew) = getThunk(Body, Rel.Type);
|
||||
if (IsNew) {
|
||||
// Find or create a ThunkSection for the new Thunk
|
||||
ThunkSection *TS;
|
||||
if (auto *TIS = T->getTargetInputSection())
|
||||
TS = getISThunkSec(TIS, Cmd->Sec);
|
||||
else
|
||||
TS = getOSThunkSec(Cmd, ISR);
|
||||
TS->addThunk(T);
|
||||
Thunks[T->ThunkSym] = T;
|
||||
}
|
||||
// Redirect relocation to Thunk, we never go via the PLT to a Thunk
|
||||
Rel.Sym = T->ThunkSym;
|
||||
Rel.Expr = fromPlt(Rel.Expr);
|
||||
}
|
||||
});
|
||||
// Merge all created synthetic ThunkSections back into OutputSection
|
||||
mergeThunks();
|
||||
++Pass;
|
||||
|
|
|
|||
|
|
@ -103,7 +103,8 @@ struct RelExprMaskBuilder<Head, Tail...> {
|
|||
// RelExpr's as a constant bit mask and test for membership with a
|
||||
// couple cheap bitwise operations.
|
||||
template <RelExpr... Exprs> bool isRelExprOneOf(RelExpr Expr) {
|
||||
assert(0 <= Expr && (int)Expr < 64 && "RelExpr is too large for 64-bit mask!");
|
||||
assert(0 <= Expr && (int)Expr < 64 &&
|
||||
"RelExpr is too large for 64-bit mask!");
|
||||
return (uint64_t(1) << Expr) & RelExprMaskBuilder<Exprs...>::build();
|
||||
}
|
||||
|
||||
|
|
@ -178,7 +179,7 @@ template <class ELFT>
|
|||
static inline int64_t getAddend(const typename ELFT::Rela &Rel) {
|
||||
return Rel.r_addend;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace elf
|
||||
} // namespace lld
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ llvm::Optional<std::string> demangle(StringRef Name);
|
|||
inline ArrayRef<uint8_t> toArrayRef(StringRef S) {
|
||||
return {(const uint8_t *)S.data(), S.size()};
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace elf
|
||||
} // namespace lld
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -172,8 +172,8 @@ template <class ELFT> void SymbolTable<ELFT>::addSymbolWrap(StringRef Name) {
|
|||
}
|
||||
|
||||
// Creates alias for symbol. Used to implement --defsym=ALIAS=SYM.
|
||||
template <class ELFT> void SymbolTable<ELFT>::addSymbolAlias(StringRef Alias,
|
||||
StringRef Name) {
|
||||
template <class ELFT>
|
||||
void SymbolTable<ELFT>::addSymbolAlias(StringRef Alias, StringRef Name) {
|
||||
SymbolBody *B = find(Name);
|
||||
if (!B) {
|
||||
error("-defsym: undefined symbol: " + Name);
|
||||
|
|
@ -393,9 +393,8 @@ static void warnOrError(const Twine &Msg) {
|
|||
}
|
||||
|
||||
static void reportDuplicate(SymbolBody *Sym, InputFile *NewFile) {
|
||||
warnOrError("duplicate symbol: " + toString(*Sym) +
|
||||
"\n>>> defined in " + toString(Sym->File) +
|
||||
"\n>>> defined in " + toString(NewFile));
|
||||
warnOrError("duplicate symbol: " + toString(*Sym) + "\n>>> defined in " +
|
||||
toString(Sym->File) + "\n>>> defined in " + toString(NewFile));
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
|
|
@ -673,7 +672,8 @@ template <class ELFT> void SymbolTable<ELFT>::handleAnonymousVersion() {
|
|||
// Set symbol versions to symbols. This function handles patterns
|
||||
// containing no wildcard characters.
|
||||
template <class ELFT>
|
||||
void SymbolTable<ELFT>::assignExactVersion(SymbolVersion Ver, uint16_t VersionId,
|
||||
void SymbolTable<ELFT>::assignExactVersion(SymbolVersion Ver,
|
||||
uint16_t VersionId,
|
||||
StringRef VersionName) {
|
||||
if (Ver.HasWildcard)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -817,9 +817,7 @@ unsigned MipsGotSection::getLocalEntriesNum() const {
|
|||
LocalEntries32.size();
|
||||
}
|
||||
|
||||
void MipsGotSection::finalizeContents() {
|
||||
updateAllocSize();
|
||||
}
|
||||
void MipsGotSection::finalizeContents() { updateAllocSize(); }
|
||||
|
||||
void MipsGotSection::updateAllocSize() {
|
||||
PageEntriesNum = 0;
|
||||
|
|
@ -843,9 +841,7 @@ bool MipsGotSection::empty() const {
|
|||
return Config->Relocatable;
|
||||
}
|
||||
|
||||
uint64_t MipsGotSection::getGp() const {
|
||||
return ElfSym::MipsGp->getVA(0);
|
||||
}
|
||||
uint64_t MipsGotSection::getGp() const { return ElfSym::MipsGp->getVA(0); }
|
||||
|
||||
static uint64_t readUint(uint8_t *Buf) {
|
||||
if (Config->Is64)
|
||||
|
|
@ -1614,7 +1610,7 @@ HashTableSection<ELFT>::HashTableSection()
|
|||
template <class ELFT> void HashTableSection<ELFT>::finalizeContents() {
|
||||
getParent()->Link = InX::DynSymTab->getParent()->SectionIndex;
|
||||
|
||||
unsigned NumEntries = 2; // nbucket and nchain.
|
||||
unsigned NumEntries = 2; // nbucket and nchain.
|
||||
NumEntries += InX::DynSymTab->getNumSymbols(); // The chain entries.
|
||||
|
||||
// Create as many buckets as there are symbols.
|
||||
|
|
@ -1933,9 +1929,7 @@ void GdbIndexSection::writeTo(uint8_t *Buf) {
|
|||
StringPool.write(Buf);
|
||||
}
|
||||
|
||||
bool GdbIndexSection::empty() const {
|
||||
return !Out::DebugInfo;
|
||||
}
|
||||
bool GdbIndexSection::empty() const { return !Out::DebugInfo; }
|
||||
|
||||
template <class ELFT>
|
||||
EhFrameHeader<ELFT>::EhFrameHeader()
|
||||
|
|
@ -2218,9 +2212,7 @@ void MergeSyntheticSection::finalizeContents() {
|
|||
finalizeNoTailMerge();
|
||||
}
|
||||
|
||||
size_t MergeSyntheticSection::getSize() const {
|
||||
return Builder.getSize();
|
||||
}
|
||||
size_t MergeSyntheticSection::getSize() const { return Builder.getSize(); }
|
||||
|
||||
// This function decompresses compressed sections and scans over the input
|
||||
// sections to create mergeable synthetic sections. It removes
|
||||
|
|
|
|||
|
|
@ -157,6 +157,6 @@ static void checkAlignment(uint8_t *Loc, uint64_t V, uint32_t Type) {
|
|||
lld::toString(Type));
|
||||
}
|
||||
} // namespace elf
|
||||
}
|
||||
} // namespace lld
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ inline void parallelForEachN(size_t Begin, size_t End,
|
|||
else
|
||||
for_each_n(llvm::parallel::seq, Begin, End, Fn);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace elf
|
||||
} // namespace lld
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -72,9 +72,7 @@ public:
|
|||
|
||||
class ThumbV7ABSLongThunk final : public Thunk {
|
||||
public:
|
||||
ThumbV7ABSLongThunk(const SymbolBody &Dest) : Thunk(Dest) {
|
||||
alignment = 2;
|
||||
}
|
||||
ThumbV7ABSLongThunk(const SymbolBody &Dest) : Thunk(Dest) { alignment = 2; }
|
||||
|
||||
uint32_t size() const override { return 10; }
|
||||
void writeTo(uint8_t *Buf, ThunkSection &IS) const override;
|
||||
|
|
@ -84,9 +82,7 @@ public:
|
|||
|
||||
class ThumbV7PILongThunk final : public Thunk {
|
||||
public:
|
||||
ThumbV7PILongThunk(const SymbolBody &Dest) : Thunk(Dest) {
|
||||
alignment = 2;
|
||||
}
|
||||
ThumbV7PILongThunk(const SymbolBody &Dest) : Thunk(Dest) { alignment = 2; }
|
||||
|
||||
uint32_t size() const override { return 12; }
|
||||
void writeTo(uint8_t *Buf, ThunkSection &IS) const override;
|
||||
|
|
@ -218,10 +214,10 @@ bool ThumbV7PILongThunk::isCompatibleWith(uint32_t RelocType) const {
|
|||
// Write MIPS LA25 thunk code to call PIC function from the non-PIC one.
|
||||
void MipsThunk::writeTo(uint8_t *Buf, ThunkSection &) const {
|
||||
uint64_t S = Destination.getVA();
|
||||
write32(Buf, 0x3c190000, Config->Endianness); // lui $25, %hi(func)
|
||||
write32(Buf, 0x3c190000, Config->Endianness); // lui $25, %hi(func)
|
||||
write32(Buf + 4, 0x08000000 | (S >> 2), Config->Endianness); // j func
|
||||
write32(Buf + 8, 0x27390000, Config->Endianness); // addiu $25, $25, %lo(func)
|
||||
write32(Buf + 12, 0x00000000, Config->Endianness); // nop
|
||||
write32(Buf + 8, 0x27390000, Config->Endianness); // addiu $25, $25, %lo(func)
|
||||
write32(Buf + 12, 0x00000000, Config->Endianness); // nop
|
||||
Target->relocateOne(Buf, R_MIPS_HI16, S);
|
||||
Target->relocateOne(Buf + 8, R_MIPS_LO16, S);
|
||||
}
|
||||
|
|
@ -262,9 +258,7 @@ static Thunk *addThunkArm(uint32_t Reloc, SymbolBody &S) {
|
|||
fatal("unrecognized relocation type");
|
||||
}
|
||||
|
||||
static Thunk *addThunkMips(SymbolBody &S) {
|
||||
return make<MipsThunk>(S);
|
||||
}
|
||||
static Thunk *addThunkMips(SymbolBody &S) { return make<MipsThunk>(S); }
|
||||
|
||||
Thunk *addThunk(uint32_t RelocType, SymbolBody &S) {
|
||||
if (Config->EMachine == EM_ARM)
|
||||
|
|
|
|||
|
|
@ -257,7 +257,6 @@ template <class ELFT> void Writer<ELFT>::run() {
|
|||
if (ErrorCount)
|
||||
return;
|
||||
|
||||
|
||||
// Handle -Map option.
|
||||
writeMapFile<ELFT>(OutputSectionCommands);
|
||||
if (ErrorCount)
|
||||
|
|
@ -1392,7 +1391,8 @@ OutputSectionCommand *Writer<ELFT>::findSectionCommand(StringRef Name) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
template <class ELFT> OutputSection *Writer<ELFT>::findSectionInScript(StringRef Name) {
|
||||
template <class ELFT>
|
||||
OutputSection *Writer<ELFT>::findSectionInScript(StringRef Name) {
|
||||
if (OutputSectionCommand *Cmd = findSectionCommand(Name))
|
||||
return Cmd->Sec;
|
||||
return nullptr;
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ uint8_t getMipsFpAbiFlag(uint8_t OldFlag, uint8_t NewFlag,
|
|||
llvm::StringRef FileName);
|
||||
|
||||
bool isMipsN32Abi(const InputFile *F);
|
||||
}
|
||||
}
|
||||
} // namespace elf
|
||||
} // namespace lld
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue