Rename replaceBody -> replaceSymbol.

llvm-svn: 317383
This commit is contained in:
Rui Ueyama 2017-11-03 22:48:47 +00:00
parent d21a53f246
commit f483da0038
9 changed files with 37 additions and 36 deletions

View File

@ -88,7 +88,7 @@ BitcodeCompiler::BitcodeCompiler() : LTOObj(createLTO()) {}
BitcodeCompiler::~BitcodeCompiler() = default;
static void undefine(Symbol *S) { replaceBody<Undefined>(S, S->getName()); }
static void undefine(Symbol *S) { replaceSymbol<Undefined>(S, S->getName()); }
void BitcodeCompiler::add(BitcodeFile &F) {
lto::InputFile &Obj = *F.Obj;

View File

@ -126,7 +126,7 @@ void SymbolTable::reportRemainingUndefines() {
Symbol *Imp = find(Name.substr(strlen("__imp_")));
if (Imp && isa<Defined>(Imp)) {
auto *D = cast<Defined>(Imp);
replaceBody<DefinedLocalImport>(Sym, Name, D);
replaceSymbol<DefinedLocalImport>(Sym, Name, D);
LocalImportChunks.push_back(cast<DefinedLocalImport>(Sym)->getChunk());
continue;
}
@ -135,7 +135,7 @@ void SymbolTable::reportRemainingUndefines() {
// Remaining undefined symbols are not fatal if /force is specified.
// They are replaced with dummy defined symbols.
if (Config->Force)
replaceBody<DefinedAbsolute>(Sym, Name, 0);
replaceSymbol<DefinedAbsolute>(Sym, Name, 0);
Undefs.insert(Sym);
}
@ -170,7 +170,7 @@ Symbol *SymbolTable::addUndefined(StringRef Name, InputFile *F,
if (!F || !isa<BitcodeFile>(F))
S->IsUsedInRegularObj = true;
if (WasInserted || (isa<Lazy>(S) && IsWeakAlias)) {
replaceBody<Undefined>(S, Name);
replaceSymbol<Undefined>(S, Name);
return S;
}
if (auto *L = dyn_cast<Lazy>(S)) {
@ -188,7 +188,7 @@ void SymbolTable::addLazy(ArchiveFile *F, const Archive::Symbol Sym) {
bool WasInserted;
std::tie(S, WasInserted) = insert(Name);
if (WasInserted) {
replaceBody<Lazy>(S, F, Sym);
replaceSymbol<Lazy>(S, F, Sym);
return;
}
auto *U = dyn_cast<Undefined>(S);
@ -210,7 +210,7 @@ Symbol *SymbolTable::addAbsolute(StringRef N, COFFSymbolRef Sym) {
std::tie(S, WasInserted) = insert(N);
S->IsUsedInRegularObj = true;
if (WasInserted || isa<Undefined>(S) || isa<Lazy>(S))
replaceBody<DefinedAbsolute>(S, N, Sym);
replaceSymbol<DefinedAbsolute>(S, N, Sym);
else if (!isa<DefinedCOFF>(S))
reportDuplicate(S, nullptr);
return S;
@ -222,7 +222,7 @@ Symbol *SymbolTable::addAbsolute(StringRef N, uint64_t VA) {
std::tie(S, WasInserted) = insert(N);
S->IsUsedInRegularObj = true;
if (WasInserted || isa<Undefined>(S) || isa<Lazy>(S))
replaceBody<DefinedAbsolute>(S, N, VA);
replaceSymbol<DefinedAbsolute>(S, N, VA);
else if (!isa<DefinedCOFF>(S))
reportDuplicate(S, nullptr);
return S;
@ -234,7 +234,7 @@ Symbol *SymbolTable::addSynthetic(StringRef N, Chunk *C) {
std::tie(S, WasInserted) = insert(N);
S->IsUsedInRegularObj = true;
if (WasInserted || isa<Undefined>(S) || isa<Lazy>(S))
replaceBody<DefinedSynthetic>(S, N, C);
replaceSymbol<DefinedSynthetic>(S, N, C);
else if (!isa<DefinedCOFF>(S))
reportDuplicate(S, nullptr);
return S;
@ -252,7 +252,8 @@ Symbol *SymbolTable::addRegular(InputFile *F, StringRef N, bool IsCOMDAT,
if (SP == SP_CONFLICT) {
reportDuplicate(S, F);
} else if (SP == SP_NEW) {
replaceBody<DefinedRegular>(S, F, N, IsCOMDAT, /*IsExternal*/ true, Sym, C);
replaceSymbol<DefinedRegular>(S, F, N, IsCOMDAT, /*IsExternal*/ true, Sym,
C);
} else if (SP == SP_EXISTING && IsCOMDAT && C) {
C->markDiscarded();
// Discard associative chunks that we've parsed so far. No need to recurse
@ -271,10 +272,10 @@ Symbol *SymbolTable::addCommon(InputFile *F, StringRef N, uint64_t Size,
if (!isa<BitcodeFile>(F))
S->IsUsedInRegularObj = true;
if (WasInserted || !isa<DefinedCOFF>(S))
replaceBody<DefinedCommon>(S, F, N, Size, Sym, C);
replaceSymbol<DefinedCommon>(S, F, N, Size, Sym, C);
else if (auto *DC = dyn_cast<DefinedCommon>(S))
if (Size > DC->getSize())
replaceBody<DefinedCommon>(S, F, N, Size, Sym, C);
replaceSymbol<DefinedCommon>(S, F, N, Size, Sym, C);
return S;
}
@ -284,7 +285,7 @@ DefinedImportData *SymbolTable::addImportData(StringRef N, ImportFile *F) {
std::tie(S, WasInserted) = insert(N);
S->IsUsedInRegularObj = true;
if (WasInserted || isa<Undefined>(S) || isa<Lazy>(S)) {
replaceBody<DefinedImportData>(S, N, F);
replaceSymbol<DefinedImportData>(S, N, F);
return cast<DefinedImportData>(S);
}
@ -300,7 +301,7 @@ DefinedImportThunk *SymbolTable::addImportThunk(StringRef Name,
std::tie(S, WasInserted) = insert(Name);
S->IsUsedInRegularObj = true;
if (WasInserted || isa<Undefined>(S) || isa<Lazy>(S)) {
replaceBody<DefinedImportThunk>(S, Name, ID, Machine);
replaceSymbol<DefinedImportThunk>(S, Name, ID, Machine);
return cast<DefinedImportThunk>(S);
}

View File

@ -412,7 +412,7 @@ union SymbolUnion {
};
template <typename T, typename... ArgT>
void replaceBody(Symbol *S, ArgT &&... Arg) {
void replaceSymbol(Symbol *S, ArgT &&... Arg) {
static_assert(sizeof(T) <= sizeof(SymbolUnion), "Symbol too small");
static_assert(alignof(T) <= alignof(SymbolUnion),
"SymbolUnion not aligned enough");

View File

@ -806,7 +806,7 @@ void Writer::fixSafeSEHSymbols() {
// section relative relocations.
Symbol *T = Symtab->find("___safe_se_handler_table");
Symbol *C = Symtab->find("___safe_se_handler_count");
replaceBody<DefinedSynthetic>(T, T->getName(), SEHTable);
replaceSymbol<DefinedSynthetic>(T, T->getName(), SEHTable);
cast<DefinedAbsolute>(C)->setVA(SEHTable->getSize() / 4);
}

View File

@ -119,8 +119,8 @@ BitcodeCompiler::BitcodeCompiler() : LTOObj(createLTO()) {
BitcodeCompiler::~BitcodeCompiler() = default;
static void undefine(Symbol *S) {
replaceBody<Undefined>(S, nullptr, S->getName(), /*IsLocal=*/false,
STV_DEFAULT, S->Type);
replaceSymbol<Undefined>(S, nullptr, S->getName(), /*IsLocal=*/false,
STV_DEFAULT, S->Type);
}
void BitcodeCompiler::add(BitcodeFile &F) {

View File

@ -149,8 +149,8 @@ void LinkerScript::addSymbol(SymbolAssignment *Cmd) {
// write expressions like this: `alignment = 16; . = ALIGN(., alignment)`.
uint64_t SymValue = Value.Sec ? 0 : Value.getValue();
replaceBody<DefinedRegular>(Sym, nullptr, Cmd->Name, /*IsLocal=*/false,
Visibility, STT_NOTYPE, SymValue, 0, Sec);
replaceSymbol<DefinedRegular>(Sym, nullptr, Cmd->Name, /*IsLocal=*/false,
Visibility, STT_NOTYPE, SymValue, 0, Sec);
Cmd->Sym = cast<DefinedRegular>(Sym);
}

View File

@ -315,7 +315,7 @@ Symbol *SymbolTable::addUndefined(StringRef Name, bool IsLocal, uint8_t Binding,
// in the same DSO.
if (WasInserted || (isa<SharedSymbol>(S) && Visibility != STV_DEFAULT)) {
S->Binding = Binding;
replaceBody<Undefined>(S, File, Name, IsLocal, StOther, Type);
replaceSymbol<Undefined>(S, File, Name, IsLocal, StOther, Type);
return S;
}
if (Binding != STB_WEAK) {
@ -404,7 +404,7 @@ Symbol *SymbolTable::addCommon(StringRef N, uint64_t Size, uint32_t Alignment,
int Cmp = compareDefined(S, WasInserted, Binding, N);
if (Cmp > 0) {
S->Binding = Binding;
replaceBody<DefinedCommon>(S, File, N, Size, Alignment, StOther, Type);
replaceSymbol<DefinedCommon>(S, File, N, Size, Alignment, StOther, Type);
} else if (Cmp == 0) {
auto *C = dyn_cast<DefinedCommon>(S);
if (!C) {
@ -419,7 +419,7 @@ Symbol *SymbolTable::addCommon(StringRef N, uint64_t Size, uint32_t Alignment,
Alignment = C->Alignment = std::max(C->Alignment, Alignment);
if (Size > C->Size)
replaceBody<DefinedCommon>(S, File, N, Size, Alignment, StOther, Type);
replaceSymbol<DefinedCommon>(S, File, N, Size, Alignment, StOther, Type);
}
return S;
}
@ -480,8 +480,8 @@ Symbol *SymbolTable::addRegular(StringRef Name, uint8_t StOther, uint8_t Type,
int Cmp = compareDefinedNonCommon(S, WasInserted, Binding, Section == nullptr,
Value, Name);
if (Cmp > 0)
replaceBody<DefinedRegular>(S, File, Name, /*IsLocal=*/false, StOther, Type,
Value, Size, Section);
replaceSymbol<DefinedRegular>(S, File, Name, /*IsLocal=*/false, StOther,
Type, Value, Size, Section);
else if (Cmp == 0)
reportDuplicate<ELFT>(S, dyn_cast_or_null<InputSectionBase>(Section),
Value);
@ -507,8 +507,8 @@ void SymbolTable::addShared(StringRef Name, SharedFile<ELFT> *File,
// in the same DSO.
if (WasInserted || ((S->isUndefined() || S->isLazy()) &&
S->getVisibility() == STV_DEFAULT)) {
replaceBody<SharedSymbol>(S, File, Name, Sym.st_other, Sym.getType(),
Sym.st_value, Sym.st_size, Alignment, Verdef);
replaceSymbol<SharedSymbol>(S, File, Name, Sym.st_other, Sym.getType(),
Sym.st_value, Sym.st_size, Alignment, Verdef);
if (!S->isWeak())
File->IsUsed = true;
}
@ -524,8 +524,8 @@ Symbol *SymbolTable::addBitcode(StringRef Name, uint8_t Binding,
int Cmp = compareDefinedNonCommon(S, WasInserted, Binding,
/*IsAbs*/ false, /*Value*/ 0, Name);
if (Cmp > 0)
replaceBody<DefinedRegular>(S, F, Name, /*IsLocal=*/false, StOther, Type, 0,
0, nullptr);
replaceSymbol<DefinedRegular>(S, F, Name, /*IsLocal=*/false, StOther, Type,
0, 0, nullptr);
else if (Cmp == 0)
reportDuplicate(S, F);
return S;
@ -559,7 +559,7 @@ Symbol *SymbolTable::addLazyArchive(StringRef Name, ArchiveFile *F,
bool WasInserted;
std::tie(S, WasInserted) = insert(Name);
if (WasInserted) {
replaceBody<LazyArchive>(S, F, Sym, Symbol::UnknownType);
replaceSymbol<LazyArchive>(S, F, Sym, Symbol::UnknownType);
return S;
}
if (!S->isUndefined())
@ -568,7 +568,7 @@ Symbol *SymbolTable::addLazyArchive(StringRef Name, ArchiveFile *F,
// An undefined weak will not fetch archive members. See comment on Lazy in
// Symbols.h for the details.
if (S->isWeak()) {
replaceBody<LazyArchive>(S, F, Sym, S->Type);
replaceSymbol<LazyArchive>(S, F, Sym, S->Type);
return S;
}
std::pair<MemoryBufferRef, uint64_t> MBInfo = F->getMember(&Sym);
@ -583,7 +583,7 @@ void SymbolTable::addLazyObject(StringRef Name, LazyObjFile &Obj) {
bool WasInserted;
std::tie(S, WasInserted) = insert(Name);
if (WasInserted) {
replaceBody<LazyObject>(S, &Obj, Name, Symbol::UnknownType);
replaceSymbol<LazyObject>(S, &Obj, Name, Symbol::UnknownType);
return;
}
if (!S->isUndefined())
@ -591,7 +591,7 @@ void SymbolTable::addLazyObject(StringRef Name, LazyObjFile &Obj) {
// See comment for addLazyArchive above.
if (S->isWeak())
replaceBody<LazyObject>(S, &Obj, Name, S->Type);
replaceSymbol<LazyObject>(S, &Obj, Name, S->Type);
else if (InputFile *F = Obj.fetch())
addFile<ELFT>(F);
}

View File

@ -388,7 +388,7 @@ union SymbolUnion {
void printTraceSymbol(Symbol *Sym);
template <typename T, typename... ArgT>
void replaceBody(Symbol *S, InputFile *File, ArgT &&... Arg) {
void replaceSymbol(Symbol *S, InputFile *File, ArgT &&... Arg) {
static_assert(sizeof(T) <= sizeof(SymbolUnion), "SymbolUnion too small");
static_assert(alignof(T) <= alignof(SymbolUnion),
"SymbolUnion not aligned enough");

View File

@ -80,9 +80,9 @@ template <class ELFT> void elf::createCommonSections() {
// Replace all DefinedCommon symbols with DefinedRegular symbols so that we
// don't have to care about DefinedCommon symbols beyond this point.
replaceBody<DefinedRegular>(S, Sym->getFile(), Sym->getName(),
static_cast<bool>(Sym->isLocal()), Sym->StOther,
Sym->Type, 0, Sym->getSize(), Section);
replaceSymbol<DefinedRegular>(
S, Sym->getFile(), Sym->getName(), static_cast<bool>(Sym->isLocal()),
Sym->StOther, Sym->Type, 0, Sym->getSize(), Section);
}
}