diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-06-03 15:21:18 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-06-03 15:21:18 +0000 |
commit | b9a1baec33e911ca24f51abf882d454e62047ea6 (patch) | |
tree | d426cb84117bdb3ec63a7bef741444456d30e414 /COFF | |
parent | 80350c116f86dbb87e055a630b1b2be0c66b244b (diff) |
Notes
Diffstat (limited to 'COFF')
-rw-r--r-- | COFF/DLL.cpp | 15 | ||||
-rw-r--r-- | COFF/DLL.h | 1 | ||||
-rw-r--r-- | COFF/Driver.cpp | 3 | ||||
-rw-r--r-- | COFF/PDB.cpp | 3 |
4 files changed, 13 insertions, 9 deletions
diff --git a/COFF/DLL.cpp b/COFF/DLL.cpp index 3ac14e4ea2b0b..d76410b67471c 100644 --- a/COFF/DLL.cpp +++ b/COFF/DLL.cpp @@ -100,17 +100,13 @@ public: void writeTo(uint8_t *Buf) const override { auto *E = (coff_import_directory_table_entry *)(Buf + OutputSectionOff); + E->ImportLookupTableRVA = LookupTab->getRVA(); E->NameRVA = DLLName->getRVA(); - - // The import descriptor table contains two pointers to - // the tables describing dllimported symbols. But the - // Windows loader actually uses only one. So we create - // only one table and set both fields to its address. - E->ImportLookupTableRVA = AddressTab->getRVA(); E->ImportAddressTableRVA = AddressTab->getRVA(); } Chunk *DLLName; + Chunk *LookupTab; Chunk *AddressTab; }; @@ -392,6 +388,7 @@ std::vector<Chunk *> IdataContents::getChunks() { // Add each type in the correct order. std::vector<Chunk *> V; V.insert(V.end(), Dirs.begin(), Dirs.end()); + V.insert(V.end(), Lookups.begin(), Lookups.end()); V.insert(V.end(), Addresses.begin(), Addresses.end()); V.insert(V.end(), Hints.begin(), Hints.end()); V.insert(V.end(), DLLNames.begin(), DLLNames.end()); @@ -407,18 +404,21 @@ void IdataContents::create() { // we need to create HintName chunks to store the names. // If they don't (if they are import-by-ordinals), we store only // ordinal values to the table. - size_t Base = Addresses.size(); + size_t Base = Lookups.size(); for (DefinedImportData *S : Syms) { uint16_t Ord = S->getOrdinal(); if (S->getExternalName().empty()) { + Lookups.push_back(make<OrdinalOnlyChunk>(Ord)); Addresses.push_back(make<OrdinalOnlyChunk>(Ord)); continue; } auto *C = make<HintNameChunk>(S->getExternalName(), Ord); + Lookups.push_back(make<LookupChunk>(C)); Addresses.push_back(make<LookupChunk>(C)); Hints.push_back(C); } // Terminate with null values. + Lookups.push_back(make<NullChunk>(ptrSize())); Addresses.push_back(make<NullChunk>(ptrSize())); for (int I = 0, E = Syms.size(); I < E; ++I) @@ -427,6 +427,7 @@ void IdataContents::create() { // Create the import table header. DLLNames.push_back(make<StringChunk>(Syms[0]->getDLLName())); auto *Dir = make<ImportDirectoryChunk>(DLLNames.back()); + Dir->LookupTab = Lookups[Base]; Dir->AddressTab = Addresses[Base]; Dirs.push_back(Dir); } diff --git a/COFF/DLL.h b/COFF/DLL.h index 939771b3290c8..ad312789edf16 100644 --- a/COFF/DLL.h +++ b/COFF/DLL.h @@ -36,6 +36,7 @@ private: std::vector<DefinedImportData *> Imports; std::vector<Chunk *> Dirs; + std::vector<Chunk *> Lookups; std::vector<Chunk *> Addresses; std::vector<Chunk *> Hints; std::vector<Chunk *> DLLNames; diff --git a/COFF/Driver.cpp b/COFF/Driver.cpp index d871f942737db..96c328b305189 100644 --- a/COFF/Driver.cpp +++ b/COFF/Driver.cpp @@ -434,7 +434,8 @@ std::vector<COFFShortExport> createCOFFShortExportFromConfig() { std::vector<COFFShortExport> Exports; for (Export &E1 : Config->Exports) { COFFShortExport E2; - E2.Name = E1.Name; + // Use SymbolName, which will have any stdcall or fastcall qualifiers. + E2.Name = E1.SymbolName; E2.ExtName = E1.ExtName; E2.Ordinal = E1.Ordinal; E2.Noname = E1.Noname; diff --git a/COFF/PDB.cpp b/COFF/PDB.cpp index a3b3ab7bbab00..eb8c3820412d8 100644 --- a/COFF/PDB.cpp +++ b/COFF/PDB.cpp @@ -157,7 +157,8 @@ static void dumpDebugS(ScopedPrinter &W, ObjectFile *File) { fatal(EC, "StreamReader.readArray<CVSymbolArray> failed"); TypeDatabase TDB(0); - CVSymbolDumper SymbolDumper(W, TDB, nullptr, false); + CVSymbolDumper SymbolDumper(W, TDB, CodeViewContainer::ObjectFile, nullptr, + false); if (auto EC = SymbolDumper.dump(Symbols)) fatal(EC, "CVSymbolDumper::dump failed"); } |