Delete SyntheticUndefined.

Now that resolved is templated anyway, we can use the regular Undefined.

llvm-svn: 246407
This commit is contained in:
Rafael Espindola 2015-08-31 01:46:20 +00:00
parent 7b5563aa5c
commit f7d45f0869
4 changed files with 18 additions and 23 deletions

View File

@ -27,25 +27,29 @@ void SymbolTable::addFile(std::unique_ptr<InputFile> File) {
addObject(P);
}
template <class ELFT> void SymbolTable::init() {
resolve<ELFT>(new (Alloc)
Undefined<ELFT>("_start", Undefined<ELFT>::Synthetic));
}
void SymbolTable::addObject(ObjectFileBase *File) {
if (!ObjectFiles.empty()) {
ObjectFileBase &Old = *ObjectFiles[0];
if (!Old.isCompatibleWith(*File))
error(Twine(Old.getName() + " is incompatible with " + File->getName()));
} else {
auto *Start = new (Alloc) SyntheticUndefined("_start");
switch (File->kind()) {
case InputFile::Object32LEKind:
resolve<ELF32LE>(Start);
init<ELF32LE>();
break;
case InputFile::Object32BEKind:
resolve<ELF32BE>(Start);
init<ELF32BE>();
break;
case InputFile::Object64LEKind:
resolve<ELF64LE>(Start);
init<ELF64LE>();
break;
case InputFile::Object64BEKind:
resolve<ELF64BE>(Start);
init<ELF64BE>();
break;
}
}

View File

@ -51,6 +51,7 @@ public:
private:
void addObject(ObjectFileBase *File);
template <class ELFT> void init();
template <class ELFT> void resolve(SymbolBody *Body);
llvm::DenseMap<StringRef, Symbol *> Symtab;

View File

@ -42,16 +42,13 @@ public:
DefinedAbsoluteKind = 1,
DefinedCommonKind = 2,
DefinedLast = 2,
UndefinedKind = 3,
UndefinedSyntheticKind = 4
UndefinedKind = 3
};
Kind kind() const { return static_cast<Kind>(SymbolKind); }
bool isWeak() const { return IsWeak; }
bool isUndefined() const {
return SymbolKind == UndefinedKind || SymbolKind == UndefinedSyntheticKind;
}
bool isUndefined() const { return SymbolKind == UndefinedKind; }
bool isDefined() const { return !isUndefined(); }
bool isStrongUndefined() const { return !IsWeak && isUndefined(); }
bool isCommon() const { return SymbolKind == DefinedCommonKind; }
@ -166,22 +163,14 @@ public:
const SectionChunk<ELFT> &Section;
};
// Undefined symbols.
class SyntheticUndefined : public SymbolBody {
public:
explicit SyntheticUndefined(StringRef N)
: SymbolBody(UndefinedKind, N, false) {}
static bool classof(const SymbolBody *S) {
return S->kind() == UndefinedSyntheticKind;
}
};
// Undefined symbol.
template <class ELFT> class Undefined : public ELFSymbolBody<ELFT> {
typedef ELFSymbolBody<ELFT> Base;
typedef typename Base::Elf_Sym Elf_Sym;
public:
static Elf_Sym Synthetic;
explicit Undefined(StringRef N, const Elf_Sym &Sym)
: ELFSymbolBody<ELFT>(Base::UndefinedKind, N, Sym) {}
@ -190,6 +179,9 @@ public:
}
};
template <class ELFT>
typename Undefined<ELFT>::Elf_Sym Undefined<ELFT>::Synthetic;
} // namespace elf2
} // namespace lld

View File

@ -302,8 +302,6 @@ template <class ELFT> void SymbolTableSection<ELFT>::writeTo(uint8_t *Buf) {
const Elf_Sym *InputSym = nullptr;
switch (Body->kind()) {
case SymbolBody::UndefinedSyntheticKind:
llvm_unreachable("Should be defined by now");
case SymbolBody::DefinedRegularKind: {
auto *Def = cast<DefinedRegular<ELFT>>(Body);
InputSym = &Def->Sym;