COFF: Rename getReplacement -> repl.

The previous name was too long to my taste.

llvm-svn: 241215
This commit is contained in:
Rui Ueyama 2015-07-02 00:21:11 +00:00
parent 18f8d2c5c0
commit 0744e87fad
5 changed files with 15 additions and 19 deletions

View File

@ -58,8 +58,7 @@ void SectionChunk::writeTo(uint8_t *Buf) {
// Apply relocations.
for (const coff_relocation &Rel : Relocs) {
uint8_t *Off = Buf + FileOff + Rel.VirtualAddress;
SymbolBody *Body =
File->getSymbolBody(Rel.SymbolTableIndex)->getReplacement();
SymbolBody *Body = File->getSymbolBody(Rel.SymbolTableIndex)->repl();
uint64_t S = cast<Defined>(Body)->getRVA();
uint64_t P = RVA + Rel.VirtualAddress;
switch (Rel.Type) {
@ -98,8 +97,7 @@ void SectionChunk::getBaserels(std::vector<uint32_t> *Res, Defined *ImageBase) {
// address never changes even if image is relocated.
if (Rel.Type != IMAGE_REL_AMD64_ADDR64)
continue;
SymbolBody *Body =
File->getSymbolBody(Rel.SymbolTableIndex)->getReplacement();
SymbolBody *Body = File->getSymbolBody(Rel.SymbolTableIndex)->repl();
if (Body == ImageBase)
continue;
Res->push_back(RVA + Rel.VirtualAddress);
@ -171,9 +169,8 @@ bool SectionChunk::equals(const SectionChunk *X) const {
return false;
if (R1.VirtualAddress != R2.VirtualAddress)
return false;
SymbolBody *B1 = File->getSymbolBody(R1.SymbolTableIndex)->getReplacement();
SymbolBody *B2 =
X->File->getSymbolBody(R2.SymbolTableIndex)->getReplacement();
SymbolBody *B1 = File->getSymbolBody(R1.SymbolTableIndex)->repl();
SymbolBody *B2 = X->File->getSymbolBody(R2.SymbolTableIndex)->repl();
if (B1 == B2)
return true;
auto *D1 = dyn_cast<DefinedRegular>(B1);

View File

@ -420,7 +420,7 @@ public:
void writeTo(uint8_t *Buf) override {
for (Export &E : Config->Exports) {
auto *D = cast<Defined>(E.Sym->getReplacement());
auto *D = cast<Defined>(E.Sym->repl());
write32le(Buf + FileOff + E.Ordinal * 4, D->getRVA());
}
}

View File

@ -122,7 +122,7 @@ bool SymbolTable::reportRemainingUndefines() {
StringRef Name = Undef->getName();
// The weak alias may have been resovled, so check for that.
if (SymbolBody *Alias = Undef->WeakAlias) {
if (auto *D = dyn_cast<Defined>(Alias->getReplacement())) {
if (auto *D = dyn_cast<Defined>(Alias->repl())) {
Sym->Body = D;
continue;
}
@ -248,7 +248,7 @@ Symbol *SymbolTable::findSymbol(StringRef Name) {
void SymbolTable::mangleMaybe(Undefined *U) {
if (U->WeakAlias)
return;
if (!isa<Undefined>(U->getReplacement()))
if (!isa<Undefined>(U->repl()))
return;
// In Microsoft ABI, a non-member function name is mangled this way.
@ -284,7 +284,7 @@ std::error_code SymbolTable::rename(StringRef From, StringRef To) {
SymbolBody *Body = new (Alloc) Undefined(To);
if (auto EC = addSymbol(Body))
return EC;
SymbolBody *Repl = Body->getReplacement();
SymbolBody *Repl = Body->repl();
if (isa<Undefined>(Repl))
return std::error_code();
Sym->Body = Repl;
@ -380,19 +380,18 @@ ErrorOr<ObjectFile *> SymbolTable::createLTOObject(LTOCodeGenerator *CG) {
// All symbols referenced by non-bitcode objects must be preserved.
for (ObjectFile *File : ObjectFiles)
for (SymbolBody *Body : File->getSymbols())
if (auto *S = dyn_cast<DefinedBitcode>(Body->getReplacement()))
if (auto *S = dyn_cast<DefinedBitcode>(Body->repl()))
CG->addMustPreserveSymbol(S->getName());
// Likewise for bitcode symbols which we initially resolved to non-bitcode.
for (BitcodeFile *File : BitcodeFiles)
for (SymbolBody *Body : File->getSymbols())
if (isa<DefinedBitcode>(Body) &&
!isa<DefinedBitcode>(Body->getReplacement()))
if (isa<DefinedBitcode>(Body) && !isa<DefinedBitcode>(Body->repl()))
CG->addMustPreserveSymbol(Body->getName());
// Likewise for other symbols that must be preserved.
for (Undefined *U : Config->GCRoot)
if (isa<DefinedBitcode>(U->getReplacement()))
if (isa<DefinedBitcode>(U->repl()))
CG->addMustPreserveSymbol(U->getName());
CG->setModule(BitcodeFiles[0]->releaseModule());

View File

@ -80,7 +80,7 @@ public:
// has chosen the object among other objects having the same name,
// you can access P->Backref->Body to get the resolver's result.
void setBackref(Symbol *P) { Backref = P; }
SymbolBody *getReplacement() { return Backref ? Backref->Body : this; }
SymbolBody *repl() { return Backref ? Backref->Body : this; }
// Decides which symbol should "win" in the symbol table, this or
// the Other. Returns 1 if this wins, -1 if the Other wins, or 0 if

View File

@ -118,7 +118,7 @@ void Writer::markLive() {
SmallVector<SectionChunk *, 256> Worklist;
for (Undefined *U : Config->GCRoot) {
auto *D = cast<DefinedRegular>(U->getReplacement());
auto *D = cast<DefinedRegular>(U->repl());
if (D->isLive())
continue;
D->markLive();
@ -137,7 +137,7 @@ void Writer::markLive() {
// Mark all symbols listed in the relocation table for this section.
for (SymbolBody *S : SC->symbols())
if (auto *D = dyn_cast<DefinedRegular>(S->getReplacement()))
if (auto *D = dyn_cast<DefinedRegular>(S->repl()))
if (!D->isLive()) {
D->markLive();
Worklist.push_back(D->getChunk());
@ -349,7 +349,7 @@ void Writer::writeHeader() {
PE->SizeOfImage = SizeOfImage;
PE->SizeOfHeaders = SizeOfHeaders;
if (!Config->NoEntry) {
Defined *Entry = cast<Defined>(Config->Entry->getReplacement());
Defined *Entry = cast<Defined>(Config->Entry->repl());
PE->AddressOfEntryPoint = Entry->getRVA();
}
PE->SizeOfStackReserve = Config->StackReserve;