aboutsummaryrefslogtreecommitdiffstats
path: root/COFF/Symbols.h
diff options
context:
space:
mode:
Diffstat (limited to 'COFF/Symbols.h')
-rw-r--r--COFF/Symbols.h52
1 files changed, 36 insertions, 16 deletions
diff --git a/COFF/Symbols.h b/COFF/Symbols.h
index 86cd4f585e50..fd79bd5065b1 100644
--- a/COFF/Symbols.h
+++ b/COFF/Symbols.h
@@ -21,6 +21,14 @@
#include <vector>
namespace lld {
+
+std::string toString(coff::Symbol &b);
+
+// There are two different ways to convert an Archive::Symbol to a string:
+// One for Microsoft name mangling and one for Itanium name mangling.
+// Call the functions toCOFFString and toELFString, not just toString.
+std::string toCOFFString(const coff::Archive::Symbol &b);
+
namespace coff {
using llvm::object::Archive;
@@ -51,7 +59,8 @@ public:
DefinedSyntheticKind,
UndefinedKind,
- LazyKind,
+ LazyArchiveKind,
+ LazyObjectKind,
LastDefinedCOFFKind = DefinedCommonKind,
LastDefinedKind = DefinedSyntheticKind,
@@ -71,6 +80,10 @@ public:
// after calling markLive.
bool isLive() const;
+ bool isLazy() const {
+ return symbolKind == LazyArchiveKind || symbolKind == LazyObjectKind;
+ }
+
protected:
friend SymbolTable;
explicit Symbol(Kind k, StringRef n = "")
@@ -248,24 +261,29 @@ private:
// This class represents a symbol defined in an archive file. It is
// created from an archive file header, and it knows how to load an
// object file from an archive to replace itself with a defined
-// symbol. If the resolver finds both Undefined and Lazy for
-// the same name, it will ask the Lazy to load a file.
-class Lazy : public Symbol {
+// symbol. If the resolver finds both Undefined and LazyArchive for
+// the same name, it will ask the LazyArchive to load a file.
+class LazyArchive : public Symbol {
public:
- Lazy(ArchiveFile *f, const Archive::Symbol s)
- : Symbol(LazyKind, s.getName()), file(f), sym(s) {}
+ LazyArchive(ArchiveFile *f, const Archive::Symbol s)
+ : Symbol(LazyArchiveKind, s.getName()), file(f), sym(s) {}
- static bool classof(const Symbol *s) { return s->kind() == LazyKind; }
-
- ArchiveFile *file;
+ static bool classof(const Symbol *s) { return s->kind() == LazyArchiveKind; }
-private:
- friend SymbolTable;
+ MemoryBufferRef getMemberBuffer();
-private:
+ ArchiveFile *file;
const Archive::Symbol sym;
};
+class LazyObject : public Symbol {
+public:
+ LazyObject(LazyObjFile *f, StringRef n)
+ : Symbol(LazyObjectKind, n), file(f) {}
+ static bool classof(const Symbol *s) { return s->kind() == LazyObjectKind; }
+ LazyObjFile *file;
+};
+
// Undefined symbols.
class Undefined : public Symbol {
public:
@@ -371,7 +389,8 @@ inline uint64_t Defined::getRVA() {
return cast<DefinedCommon>(this)->getRVA();
case DefinedRegularKind:
return cast<DefinedRegular>(this)->getRVA();
- case LazyKind:
+ case LazyArchiveKind:
+ case LazyObjectKind:
case UndefinedKind:
llvm_unreachable("Cannot get the address for an undefined symbol.");
}
@@ -394,7 +413,8 @@ inline Chunk *Defined::getChunk() {
return cast<DefinedLocalImport>(this)->getChunk();
case DefinedCommonKind:
return cast<DefinedCommon>(this)->getChunk();
- case LazyKind:
+ case LazyArchiveKind:
+ case LazyObjectKind:
case UndefinedKind:
llvm_unreachable("Cannot get the chunk of an undefined symbol.");
}
@@ -409,11 +429,12 @@ union SymbolUnion {
alignas(DefinedCommon) char b[sizeof(DefinedCommon)];
alignas(DefinedAbsolute) char c[sizeof(DefinedAbsolute)];
alignas(DefinedSynthetic) char d[sizeof(DefinedSynthetic)];
- alignas(Lazy) char e[sizeof(Lazy)];
+ alignas(LazyArchive) char e[sizeof(LazyArchive)];
alignas(Undefined) char f[sizeof(Undefined)];
alignas(DefinedImportData) char g[sizeof(DefinedImportData)];
alignas(DefinedImportThunk) char h[sizeof(DefinedImportThunk)];
alignas(DefinedLocalImport) char i[sizeof(DefinedLocalImport)];
+ alignas(LazyObject) char j[sizeof(LazyObject)];
};
template <typename T, typename... ArgT>
@@ -429,7 +450,6 @@ void replaceSymbol(Symbol *s, ArgT &&... arg) {
}
} // namespace coff
-std::string toString(coff::Symbol &b);
} // namespace lld
#endif