[lld] r246407 - Delete SyntheticUndefined.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 30 18:46:20 PDT 2015
Author: rafael
Date: Sun Aug 30 20:46:20 2015
New Revision: 246407
URL: http://llvm.org/viewvc/llvm-project?rev=246407&view=rev
Log:
Delete SyntheticUndefined.
Now that resolved is templated anyway, we can use the regular Undefined.
Modified:
lld/trunk/ELF/SymbolTable.cpp
lld/trunk/ELF/SymbolTable.h
lld/trunk/ELF/Symbols.h
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=246407&r1=246406&r2=246407&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Sun Aug 30 20:46:20 2015
@@ -27,25 +27,29 @@ void SymbolTable::addFile(std::unique_pt
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;
}
}
Modified: lld/trunk/ELF/SymbolTable.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.h?rev=246407&r1=246406&r2=246407&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.h (original)
+++ lld/trunk/ELF/SymbolTable.h Sun Aug 30 20:46:20 2015
@@ -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;
Modified: lld/trunk/ELF/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.h?rev=246407&r1=246406&r2=246407&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.h (original)
+++ lld/trunk/ELF/Symbols.h Sun Aug 30 20:46:20 2015
@@ -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
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=246407&r1=246406&r2=246407&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Sun Aug 30 20:46:20 2015
@@ -302,8 +302,6 @@ template <class ELFT> void SymbolTableSe
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;
More information about the llvm-commits
mailing list