[ELF] - Applied clang format. NFC.

llvm-svn: 284705
This commit is contained in:
George Rimar 2016-10-20 08:36:42 +00:00
parent 8010b631d5
commit a4c7e74d4b
15 changed files with 69 additions and 83 deletions

View File

@ -235,8 +235,8 @@ static void checkOptions(opt::InputArgList &Args) {
}
}
static StringRef
getString(opt::InputArgList &Args, unsigned Key, StringRef Default = "") {
static StringRef getString(opt::InputArgList &Args, unsigned Key,
StringRef Default = "") {
if (auto *Arg = Args.getLastArg(Key))
return Arg->getValue();
return Default;
@ -265,8 +265,8 @@ static bool hasZOption(opt::InputArgList &Args, StringRef Key) {
return false;
}
static uint64_t
getZOptionValue(opt::InputArgList &Args, StringRef Key, uint64_t Default) {
static uint64_t getZOptionValue(opt::InputArgList &Args, StringRef Key,
uint64_t Default) {
for (auto *Arg : Args.filtered(OPT_z)) {
StringRef Value = Arg->getValue();
size_t Pos = Value.find("=");

View File

@ -718,7 +718,7 @@ static Symbol *createBitcodeSymbol(DenseSet<StringRef> &KeptComdats,
if (!Keep)
return Symtab<ELFT>::X->addUndefined(NameRef, Binding, Visibility, Type,
CanOmitFromDynSym, F);
}
}
if (Flags & BasicSymbolRef::SF_Undefined)
return Symtab<ELFT>::X->addUndefined(NameRef, Binding, Visibility, Type,

View File

@ -162,7 +162,8 @@ public:
return *SymbolBodies[SymbolIndex];
}
template <typename RelT> SymbolBody &getRelocTargetSym(const RelT &Rel) const {
template <typename RelT>
SymbolBody &getRelocTargetSym(const RelT &Rel) const {
uint32_t SymIndex = Rel.getSymbol(Config->Mips64EL);
return getSymbolBody(SymIndex);
}
@ -260,8 +261,7 @@ class BitcodeFile : public InputFile {
public:
explicit BitcodeFile(MemoryBufferRef M);
static bool classof(const InputFile *F) { return F->kind() == BitcodeKind; }
template <class ELFT>
void parse(llvm::DenseSet<StringRef> &ComdatGroups);
template <class ELFT> void parse(llvm::DenseSet<StringRef> &ComdatGroups);
ArrayRef<Symbol *> getSymbols() { return Symbols; }
std::unique_ptr<llvm::lto::InputFile> Obj;

View File

@ -173,9 +173,8 @@ InputSectionBase<ELFT>::getOffset(const DefinedRegular<ELFT> &Sym) const {
return getOffset(Sym.Value);
}
template<class ELFT>
InputSectionBase<ELFT>*
InputSectionBase<ELFT>::getLinkOrderDep() const {
template <class ELFT>
InputSectionBase<ELFT> *InputSectionBase<ELFT>::getLinkOrderDep() const {
const Elf_Shdr *Hdr = getSectionHdr();
if ((Hdr->sh_flags & SHF_LINK_ORDER) && Hdr->sh_link != 0)
return getFile()->getSections()[Hdr->sh_link];
@ -199,8 +198,7 @@ InputSectionBase<ELFT> *InputSection<ELFT>::getRelocatedSection() {
return Sections[this->Header->sh_info];
}
template <class ELFT>
void InputSection<ELFT>::addThunk(const Thunk<ELFT> *T) {
template <class ELFT> void InputSection<ELFT>::addThunk(const Thunk<ELFT> *T) {
Thunks.push_back(T);
}
@ -452,7 +450,7 @@ void InputSectionBase<ELFT>::relocate(uint8_t *Buf, uint8_t *BufEnd) {
// Patch a nop (0x60000000) to a ld.
if (BufLoc + 8 <= BufEnd && read32be(BufLoc + 4) == 0x60000000)
write32be(BufLoc + 4, 0xe8410028); // ld %r2, 40(%r1)
// fallthrough
// fallthrough
default:
Target->relocateOne(BufLoc, Type, SymVA);
break;
@ -540,8 +538,7 @@ static unsigned getReloc(IntTy Begin, IntTy Size, const ArrayRef<RelTy> &Rels,
// .eh_frame is a sequence of CIE or FDE records.
// This function splits an input section into records and returns them.
template <class ELFT>
void EhInputSection<ELFT>::split() {
template <class ELFT> void EhInputSection<ELFT>::split() {
// Early exit if already split.
if (!this->Pieces.empty())
return;
@ -705,7 +702,7 @@ typename ELFT::uint MergeInputSection<ELFT>::getOffset(uintX_t Offset) const {
// Create a map from input offsets to output offsets for all section pieces.
// It is called after finalize().
template <class ELFT> void MergeInputSection<ELFT>::finalizePieces() {
template <class ELFT> void MergeInputSection<ELFT>::finalizePieces() {
OffsetMap.reserve(this->Pieces.size());
for (SectionPiece &Piece : this->Pieces) {
if (!Piece.Live)

View File

@ -65,7 +65,7 @@ static std::unique_ptr<lto::LTO> createLTO() {
if (Config->SaveTemps)
checkError(Conf.addSaveTemps(std::string(Config->OutputFile) + ".",
/*UseInputModulePath*/ true));
/*UseInputModulePath*/ true));
lto::ThinBackend Backend;
if (Config->ThinLtoJobs != -1u)

View File

@ -240,7 +240,7 @@ LinkerScript<ELFT>::createInputSectionList(OutputSectionCommand &OutCmd) {
}
// After we created final list we should now set OutSec pointer to null,
// instead of -1. Otherwise we may get a crash when writing relocs, in
// instead of -1. Otherwise we may get a crash when writing relocs, in
// case section is discarded by linker script
for (InputSectionBase<ELFT> *S : Ret)
S->OutSec = nullptr;

View File

@ -44,8 +44,7 @@ using namespace lld::elf;
namespace {
// A resolved relocation. The Sec and Offset fields are set if the relocation
// was resolved to an offset within a section.
template <class ELFT>
struct ResolvedReloc {
template <class ELFT> struct ResolvedReloc {
InputSectionBase<ELFT> *Sec;
typename ELFT::uint Offset;
};

View File

@ -93,8 +93,7 @@ GotSection<ELFT>::GotSection()
this->Header.sh_addralign = Target->GotEntrySize;
}
template <class ELFT>
void GotSection<ELFT>::addEntry(SymbolBody &Sym) {
template <class ELFT> void GotSection<ELFT>::addEntry(SymbolBody &Sym) {
Sym.GotIndex = Entries.size();
Entries.push_back(&Sym);
}
@ -294,7 +293,7 @@ template <class ELFT> void GotSection<ELFT>::writeMipsGot(uint8_t *Buf) {
auto AddEntry = [&](const MipsGotEntry &SA) {
uint8_t *Entry = Buf;
Buf += sizeof(uintX_t);
const SymbolBody* Body = SA.first;
const SymbolBody *Body = SA.first;
uintX_t VA = Body->template getVA<ELFT>(SA.second);
writeUint<ELFT>(Entry, VA);
};
@ -1396,8 +1395,7 @@ template <class ELFT> void SymbolTableSection<ELFT>::finalize() {
S.Symbol->DynsymIndex = ++I;
}
template <class ELFT>
void SymbolTableSection<ELFT>::addSymbol(SymbolBody *B) {
template <class ELFT> void SymbolTableSection<ELFT>::addSymbol(SymbolBody *B) {
Symbols.push_back({B, StrTabSec.addString(B->getName(), false)});
}

View File

@ -187,7 +187,7 @@ private:
// GOT entries should have one-to-one mapping with dynamic symbols table.
// But we use the same container's types for both kind of GOT entries
// to handle them uniformly.
typedef std::pair<const SymbolBody*, uintX_t> MipsGotEntry;
typedef std::pair<const SymbolBody *, uintX_t> MipsGotEntry;
typedef std::vector<MipsGotEntry> MipsGotEntries;
llvm::DenseMap<MipsGotEntry, size_t> MipsGotMap;
MipsGotEntries MipsLocal;
@ -288,9 +288,7 @@ public:
typename Base::Kind getKind() const override { return Base::SymTable; }
static bool classof(const Base *B) { return B->getKind() == Base::SymTable; }
ArrayRef<SymbolTableEntry> getSymbols() const {
return Symbols;
}
ArrayRef<SymbolTableEntry> getSymbols() const { return Symbols; }
unsigned NumLocals = 0;
StringTableSection<ELFT> &StrTabSec;

View File

@ -271,7 +271,7 @@ static int32_t findMipsPairedAddend(const uint8_t *Buf, const uint8_t *BufLoc,
readSignedLo16<E>(Buf + RI->r_offset);
}
warn("can't find matching " + getRelName(Type) + " relocation for " +
getRelName(Rel->getType(Config->Mips64EL)));
getRelName(Rel->getType(Config->Mips64EL)));
return 0;
}
@ -444,8 +444,8 @@ static RelExpr adjustExpr(const elf::ObjectFile<ELFT> &File, SymbolBody &Body,
// the refered symbol can be preemepted to refer to the executable.
if (Config->Shared || (Config->Pic && !isRelExpr(Expr))) {
StringRef Name = getSymbolName(File, Body);
error("can't create dynamic relocation " + getRelName(Type) +
" against " + (Name.empty() ? "readonly segment" : "symbol " + Name));
error("can't create dynamic relocation " + getRelName(Type) + " against " +
(Name.empty() ? "readonly segment" : "symbol " + Name));
return Expr;
}
if (Body.getVisibility() != STV_DEFAULT) {
@ -578,7 +578,8 @@ static void scanRelocs(InputSectionBase<ELFT> &C, ArrayRef<RelTy> Rels) {
SymbolBody &Body = File.getRelocTargetSym(RI);
uint32_t Type = RI.getType(Config->Mips64EL);
// We only report undefined symbols if they are referenced somewhere in the code.
// We only report undefined symbols if they are referenced somewhere in the
// code.
if (!Body.isLocal() && Body.isUndefined() && !Body.symbol()->isWeak())
reportUndefined(Body);

View File

@ -246,8 +246,7 @@ SymbolTable<ELFT>::insert(StringRef &Name, uint8_t Type, uint8_t Visibility,
S->IsUsedInRegularObj = true;
if (!WasInserted && S->body()->Type != SymbolBody::UnknownType &&
((Type == STT_TLS) != S->body()->isTls()))
error("TLS attribute mismatch for symbol: " +
conflictMsg(S->body(), File));
error("TLS attribute mismatch for symbol: " + conflictMsg(S->body(), File));
return {S, WasInserted};
}

View File

@ -439,8 +439,7 @@ struct Symbol {
llvm::AlignedCharArrayUnion<
DefinedCommon, DefinedRegular<llvm::object::ELF64LE>,
DefinedSynthetic<llvm::object::ELF64LE>, Undefined,
SharedSymbol<llvm::object::ELF64LE>, LazyArchive, LazyObject>
Body;
SharedSymbol<llvm::object::ELF64LE>, LazyArchive, LazyObject> Body;
SymbolBody *body() { return reinterpret_cast<SymbolBody *>(Body.buffer); }
const SymbolBody *body() const { return const_cast<Symbol *>(this)->body(); }

View File

@ -185,8 +185,7 @@ public:
void writePltHeader(uint8_t *Buf) const override;
void writePlt(uint8_t *Buf, uint64_t GotEntryAddr, uint64_t PltEntryAddr,
int32_t Index, unsigned RelOff) const override;
RelExpr getThunkExpr(RelExpr Expr, uint32_t RelocType,
const InputFile &File,
RelExpr getThunkExpr(RelExpr Expr, uint32_t RelocType, const InputFile &File,
const SymbolBody &S) const override;
void relocateOne(uint8_t *Loc, uint32_t Type, uint64_t Val) const override;
};
@ -203,8 +202,7 @@ public:
void writePltHeader(uint8_t *Buf) const override;
void writePlt(uint8_t *Buf, uint64_t GotEntryAddr, uint64_t PltEntryAddr,
int32_t Index, unsigned RelOff) const override;
RelExpr getThunkExpr(RelExpr Expr, uint32_t RelocType,
const InputFile &File,
RelExpr getThunkExpr(RelExpr Expr, uint32_t RelocType, const InputFile &File,
const SymbolBody &S) const override;
void relocateOne(uint8_t *Loc, uint32_t Type, uint64_t Val) const override;
bool usesOnlyLowPageBits(uint32_t Type) const override;
@ -266,9 +264,7 @@ bool TargetInfo::isTlsInitialExecRel(uint32_t Type) const { return false; }
bool TargetInfo::isTlsLocalDynamicRel(uint32_t Type) const { return false; }
bool TargetInfo::isTlsGlobalDynamicRel(uint32_t Type) const {
return false;
}
bool TargetInfo::isTlsGlobalDynamicRel(uint32_t Type) const { return false; }
RelExpr TargetInfo::adjustRelaxExpr(uint32_t Type, const uint8_t *Data,
RelExpr Expr) const {
@ -1046,26 +1042,33 @@ void PPC64TargetInfo::writePlt(uint8_t *Buf, uint64_t GotEntryAddr,
// be a pointer to the function descriptor in the .opd section. Using
// this scheme is simpler, but requires an extra indirection per PLT dispatch.
write32be(Buf, 0xf8410028); // std %r2, 40(%r1)
write32be(Buf + 4, 0x3d620000 | applyPPCHa(Off)); // addis %r11, %r2, X@ha
write32be(Buf + 8, 0xe98b0000 | applyPPCLo(Off)); // ld %r12, X@l(%r11)
write32be(Buf + 12, 0xe96c0000); // ld %r11,0(%r12)
write32be(Buf + 16, 0x7d6903a6); // mtctr %r11
write32be(Buf + 20, 0xe84c0008); // ld %r2,8(%r12)
write32be(Buf + 24, 0xe96c0010); // ld %r11,16(%r12)
write32be(Buf + 28, 0x4e800420); // bctr
write32be(Buf, 0xf8410028); // std %r2, 40(%r1)
write32be(Buf + 4, 0x3d620000 | applyPPCHa(Off)); // addis %r11, %r2, X@ha
write32be(Buf + 8, 0xe98b0000 | applyPPCLo(Off)); // ld %r12, X@l(%r11)
write32be(Buf + 12, 0xe96c0000); // ld %r11,0(%r12)
write32be(Buf + 16, 0x7d6903a6); // mtctr %r11
write32be(Buf + 20, 0xe84c0008); // ld %r2,8(%r12)
write32be(Buf + 24, 0xe96c0010); // ld %r11,16(%r12)
write32be(Buf + 28, 0x4e800420); // bctr
}
static std::pair<uint32_t, uint64_t> toAddr16Rel(uint32_t Type, uint64_t Val) {
uint64_t V = Val - PPC64TocOffset;
switch (Type) {
case R_PPC64_TOC16: return {R_PPC64_ADDR16, V};
case R_PPC64_TOC16_DS: return {R_PPC64_ADDR16_DS, V};
case R_PPC64_TOC16_HA: return {R_PPC64_ADDR16_HA, V};
case R_PPC64_TOC16_HI: return {R_PPC64_ADDR16_HI, V};
case R_PPC64_TOC16_LO: return {R_PPC64_ADDR16_LO, V};
case R_PPC64_TOC16_LO_DS: return {R_PPC64_ADDR16_LO_DS, V};
default: return {Type, Val};
case R_PPC64_TOC16:
return {R_PPC64_ADDR16, V};
case R_PPC64_TOC16_DS:
return {R_PPC64_ADDR16_DS, V};
case R_PPC64_TOC16_HA:
return {R_PPC64_ADDR16_HA, V};
case R_PPC64_TOC16_HI:
return {R_PPC64_ADDR16_HI, V};
case R_PPC64_TOC16_LO:
return {R_PPC64_ADDR16_LO, V};
case R_PPC64_TOC16_LO_DS:
return {R_PPC64_ADDR16_LO_DS, V};
default:
return {Type, Val};
}
}
@ -1694,7 +1697,7 @@ void ARMTargetInfo::relocateOne(uint8_t *Loc, uint32_t Type,
// BLX (always unconditional) instruction to an ARM Target, select an
// unconditional BL.
write32le(Loc, 0xeb000000 | (read32le(Loc) & 0x00ffffff));
// fall through as BL encoding is shared with B
// fall through as BL encoding is shared with B
case R_ARM_JUMP24:
case R_ARM_PC24:
case R_ARM_PLT32:
@ -1728,7 +1731,7 @@ void ARMTargetInfo::relocateOne(uint8_t *Loc, uint32_t Type,
}
// Bit 12 is 0 for BLX, 1 for BL
write16le(Loc + 2, (read16le(Loc + 2) & ~0x1000) | (Val & 1) << 12);
// Fall through as rest of encoding is the same as B.W
// Fall through as rest of encoding is the same as B.W
case R_ARM_THM_JUMP24:
// Encoding B T4, BL T1, BLX T2: Val = S:I1:I2:imm10:imm11:0
// FIXME: Use of I1 and I2 require v6T2ops
@ -1990,29 +1993,25 @@ static void applyMipsPcReloc(uint8_t *Loc, uint32_t Type, uint64_t V) {
write32<E>(Loc, (Instr & ~Mask) | ((V >> SHIFT) & Mask));
}
template <endianness E>
static void writeMipsHi16(uint8_t *Loc, uint64_t V) {
template <endianness E> static void writeMipsHi16(uint8_t *Loc, uint64_t V) {
uint32_t Instr = read32<E>(Loc);
uint16_t Res = ((V + 0x8000) >> 16) & 0xffff;
write32<E>(Loc, (Instr & 0xffff0000) | Res);
}
template <endianness E>
static void writeMipsHigher(uint8_t *Loc, uint64_t V) {
template <endianness E> static void writeMipsHigher(uint8_t *Loc, uint64_t V) {
uint32_t Instr = read32<E>(Loc);
uint16_t Res = ((V + 0x80008000) >> 32) & 0xffff;
write32<E>(Loc, (Instr & 0xffff0000) | Res);
}
template <endianness E>
static void writeMipsHighest(uint8_t *Loc, uint64_t V) {
template <endianness E> static void writeMipsHighest(uint8_t *Loc, uint64_t V) {
uint32_t Instr = read32<E>(Loc);
uint16_t Res = ((V + 0x800080008000) >> 48) & 0xffff;
write32<E>(Loc, (Instr & 0xffff0000) | Res);
}
template <endianness E>
static void writeMipsLo16(uint8_t *Loc, uint64_t V) {
template <endianness E> static void writeMipsLo16(uint8_t *Loc, uint64_t V) {
uint32_t Instr = read32<E>(Loc);
write32<E>(Loc, (Instr & 0xffff0000) | (V & 0xffff));
}
@ -2045,9 +2044,9 @@ void MipsTargetInfo<ELFT>::writePlt(uint8_t *Buf, uint64_t GotEntryAddr,
uint64_t PltEntryAddr, int32_t Index,
unsigned RelOff) const {
const endianness E = ELFT::TargetEndianness;
write32<E>(Buf, 0x3c0f0000); // lui $15, %hi(.got.plt entry)
write32<E>(Buf + 4, 0x8df90000); // l[wd] $25, %lo(.got.plt entry)($15)
// jr $25
write32<E>(Buf, 0x3c0f0000); // lui $15, %hi(.got.plt entry)
write32<E>(Buf + 4, 0x8df90000); // l[wd] $25, %lo(.got.plt entry)($15)
// jr $25
write32<E>(Buf + 8, isMipsR6<ELFT>() ? 0x03200009 : 0x03200008);
write32<E>(Buf + 12, 0x25f80000); // addiu $24, $15, %lo(.got.plt entry)
writeMipsHi16<E>(Buf, GotEntryAddr);

View File

@ -51,9 +51,8 @@ private:
void copyLocalSymbols();
void addReservedSymbols();
void createSections();
void forEachRelSec(
std::function<void(InputSectionBase<ELFT> &, const typename ELFT::Shdr &)>
Fn);
void forEachRelSec(std::function<void(InputSectionBase<ELFT> &,
const typename ELFT::Shdr &)> Fn);
void sortSections();
void finalizeSections();
void addPredefinedSections();
@ -529,14 +528,13 @@ template <class ELFT> static bool isDiscarded(InputSectionBase<ELFT> *S) {
}
// Program header entry
template<class ELFT>
template <class ELFT>
PhdrEntry<ELFT>::PhdrEntry(unsigned Type, unsigned Flags) {
H.p_type = Type;
H.p_flags = Flags;
}
template<class ELFT>
void PhdrEntry<ELFT>::add(OutputSectionBase<ELFT> *Sec) {
template <class ELFT> void PhdrEntry<ELFT>::add(OutputSectionBase<ELFT> *Sec) {
Last = Sec;
if (!First)
First = Sec;
@ -1012,8 +1010,7 @@ static typename ELFT::uint computeFlags(typename ELFT::uint F) {
// Decide which program headers to create and which sections to include in each
// one.
template <class ELFT>
std::vector<PhdrEntry<ELFT>> Writer<ELFT>::createPhdrs() {
template <class ELFT> std::vector<PhdrEntry<ELFT>> Writer<ELFT>::createPhdrs() {
std::vector<Phdr> Ret;
auto AddHdr = [&](unsigned Type, unsigned Flags) -> Phdr * {
Ret.emplace_back(Type, Flags);

View File

@ -28,8 +28,7 @@ template <class ELFT> bool isRelroSection(OutputSectionBase<ELFT> *Sec);
// This describes a program header entry.
// Each contains type, access flags and range of output sections that will be
// placed in it.
template<class ELFT>
struct PhdrEntry {
template <class ELFT> struct PhdrEntry {
PhdrEntry(unsigned Type, unsigned Flags);
void add(OutputSectionBase<ELFT> *Sec);