[lld] r304584 - Revert "Merge IAT and ILT."
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 2 11:49:38 PDT 2017
Author: rnk
Date: Fri Jun 2 13:49:38 2017
New Revision: 304584
URL: http://llvm.org/viewvc/llvm-project?rev=304584&view=rev
Log:
Revert "Merge IAT and ILT."
This reverts r303374. It breaks Chrome's IAT patching code:
http://crbug.com/729077
Modified:
lld/trunk/COFF/DLL.cpp
lld/trunk/COFF/DLL.h
lld/trunk/test/COFF/armnt-imports.test
lld/trunk/test/COFF/hello32.test
lld/trunk/test/COFF/imports.test
Modified: lld/trunk/COFF/DLL.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/DLL.cpp?rev=304584&r1=304583&r2=304584&view=diff
==============================================================================
--- lld/trunk/COFF/DLL.cpp (original)
+++ lld/trunk/COFF/DLL.cpp Fri Jun 2 13:49:38 2017
@@ -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::getC
// 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);
}
Modified: lld/trunk/COFF/DLL.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/DLL.h?rev=304584&r1=304583&r2=304584&view=diff
==============================================================================
--- lld/trunk/COFF/DLL.h (original)
+++ lld/trunk/COFF/DLL.h Fri Jun 2 13:49:38 2017
@@ -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;
Modified: lld/trunk/test/COFF/armnt-imports.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/armnt-imports.test?rev=304584&r1=304583&r2=304584&view=diff
==============================================================================
--- lld/trunk/test/COFF/armnt-imports.test (original)
+++ lld/trunk/test/COFF/armnt-imports.test Fri Jun 2 13:49:38 2017
@@ -6,7 +6,7 @@
# CHECK: Import {
# CHECK: Name: library.dll
# CHECK: ImportLookupTableRVA: 0x2028
-# CHECK: ImportAddressTableRVA: 0x2028
+# CHECK: ImportAddressTableRVA: 0x2030
# CHECK: Symbol: function (0)
# CHECK: }
Modified: lld/trunk/test/COFF/hello32.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/hello32.test?rev=304584&r1=304583&r2=304584&view=diff
==============================================================================
--- lld/trunk/test/COFF/hello32.test (original)
+++ lld/trunk/test/COFF/hello32.test Fri Jun 2 13:49:38 2017
@@ -78,7 +78,7 @@ HEADER-NEXT: LoadConfigTableRVA: 0x0
HEADER-NEXT: LoadConfigTableSize: 0x0
HEADER-NEXT: BoundImportRVA: 0x0
HEADER-NEXT: BoundImportSize: 0x0
-HEADER-NEXT: IATRVA: 0x3028
+HEADER-NEXT: IATRVA: 0x3034
HEADER-NEXT: IATSize: 0xC
HEADER-NEXT: DelayImportDescriptorRVA: 0x0
HEADER-NEXT: DelayImportDescriptorSize: 0x0
@@ -114,7 +114,7 @@ IMPORTS: AddressSize: 32bit
IMPORTS: Import {
IMPORTS: Name: std32.dll
IMPORTS: ImportLookupTableRVA: 0x3028
-IMPORTS: ImportAddressTableRVA: 0x3028
+IMPORTS: ImportAddressTableRVA: 0x3034
IMPORTS: Symbol: ExitProcess (0)
IMPORTS: Symbol: MessageBoxA (1)
IMPORTS: }
Modified: lld/trunk/test/COFF/imports.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/imports.test?rev=304584&r1=304583&r2=304584&view=diff
==============================================================================
--- lld/trunk/test/COFF/imports.test (original)
+++ lld/trunk/test/COFF/imports.test Fri Jun 2 13:49:38 2017
@@ -21,14 +21,14 @@ TEXT-NEXT: callq 60
TEXT-NEXT: movl $0, %ecx
TEXT-NEXT: callq 18
TEXT-NEXT: callq 29
-TEXT: jmpq *4066(%rip)
-TEXT: jmpq *4058(%rip)
-TEXT: jmpq *4050(%rip)
+TEXT: jmpq *4098(%rip)
+TEXT: jmpq *4090(%rip)
+TEXT: jmpq *4082(%rip)
IMPORT: Import {
IMPORT-NEXT: Name: std64.dll
IMPORT-NEXT: ImportLookupTableRVA: 0x3028
-IMPORT-NEXT: ImportAddressTableRVA: 0x3028
+IMPORT-NEXT: ImportAddressTableRVA: 0x3048
IMPORT-NEXT: Symbol: ExitProcess (0)
IMPORT-NEXT: Symbol: (50)
IMPORT-NEXT: Symbol: MessageBoxA (1)
More information about the llvm-commits
mailing list