diff options
Diffstat (limited to 'lld/COFF/SymbolTable.h')
| -rw-r--r-- | lld/COFF/SymbolTable.h | 48 |
1 files changed, 33 insertions, 15 deletions
diff --git a/lld/COFF/SymbolTable.h b/lld/COFF/SymbolTable.h index 1d11fa76db3..a7f27afa336 100644 --- a/lld/COFF/SymbolTable.h +++ b/lld/COFF/SymbolTable.h @@ -22,6 +22,7 @@ #endif #include <future> +#include <list> namespace llvm { struct LTOCodeGenerator; @@ -31,6 +32,7 @@ namespace lld { namespace coff { class Chunk; +class CommonChunk; class Defined; class DefinedAbsolute; class DefinedRelative; @@ -48,7 +50,9 @@ struct Symbol; // conflicts. For example, obviously, a defined symbol is better than // an undefined symbol. Or, if there's a conflict between a lazy and a // undefined, it'll read an archive member to read a real definition -// to replace the lazy symbol. The logic is implemented in resolve(). +// to replace the lazy symbol. The logic is implemented in the +// add*() functions, which are called by input files as they are parsed. +// There is one add* function per symbol type. class SymbolTable { public: void addFile(InputFile *File); @@ -57,9 +61,10 @@ public: void run(); bool queueEmpty(); - // Print an error message on undefined symbols. If Resolve is true, try to - // resolve any undefined symbols and update the symbol table accordingly. - void reportRemainingUndefines(bool Resolve); + // Try to resolve any undefined symbols and update the symbol table + // accordingly, then print an error message for any remaining undefined + // symbols. + void reportRemainingUndefines(); // Returns a list of chunks of selected symbols. std::vector<Chunk *> getChunks(); @@ -72,7 +77,7 @@ public: // mangled symbol. This function tries to find a mangled name // for U from the symbol table, and if found, set the symbol as // a weak alias for U. - void mangleMaybe(Undefined *U); + void mangleMaybe(SymbolBody *B); StringRef findMangle(StringRef Name); // Print a layout map to OS. @@ -91,36 +96,49 @@ public: std::vector<ObjectFile *> ObjectFiles; // Creates an Undefined symbol for a given name. - Undefined *addUndefined(StringRef Name); - DefinedRelative *addRelative(StringRef Name, uint64_t VA); - DefinedAbsolute *addAbsolute(StringRef Name, uint64_t VA); + SymbolBody *addUndefined(StringRef Name); + + Symbol *addRelative(StringRef N, uint64_t VA); + Symbol *addAbsolute(StringRef N, uint64_t VA); + + Symbol *addUndefined(StringRef Name, InputFile *F, bool IsWeakAlias); + void addLazy(ArchiveFile *F, const Archive::Symbol Sym); + Symbol *addAbsolute(StringRef N, COFFSymbolRef S); + Symbol *addRegular(ObjectFile *F, COFFSymbolRef S, SectionChunk *C); + Symbol *addBitcode(BitcodeFile *F, StringRef N, bool IsReplaceable); + Symbol *addCommon(ObjectFile *F, COFFSymbolRef S, CommonChunk *C); + Symbol *addImportData(StringRef N, ImportFile *F); + Symbol *addImportThunk(StringRef Name, DefinedImportData *S, + uint16_t Machine); + + void reportDuplicate(Symbol *Existing, InputFile *NewFile); // A list of chunks which to be added to .rdata. std::vector<Chunk *> LocalImportChunks; private: - void readArchives(); + void readArchive(); void readObjects(); - void addSymbol(SymbolBody *New); - void addLazy(Lazy *New, std::vector<Symbol *> *Accum); - Symbol *insert(SymbolBody *New); + std::pair<Symbol *, bool> insert(StringRef Name); StringRef findByPrefix(StringRef Prefix); - void addMemberFile(Lazy *Body); + void addMemberFile(ArchiveFile *F, const Archive::Symbol Sym); void addCombinedLTOObject(ObjectFile *Obj); std::vector<ObjectFile *> createLTOObjects(llvm::LTOCodeGenerator *CG); llvm::DenseMap<StringRef, Symbol *> Symtab; std::vector<InputFile *> Files; - std::vector<std::future<ArchiveFile *>> ArchiveQueue; - std::vector<std::future<InputFile *>> ObjectQueue; + std::list<ArchiveFile *> ArchiveQueue; + std::vector<InputFile *> ObjectQueue; std::vector<BitcodeFile *> BitcodeFiles; std::vector<SmallString<0>> Objs; }; +extern SymbolTable *Symtab; + } // namespace coff } // namespace lld |

