COFF: Fix ordinal-only delay-imported symbols.

DLLs can export symbols only by ordinal, and DLLs are also able to be
delay-loaded. The combination of the two is valid. I didn't expect
that combination. This patch implements that feature.

With this patch, LLD is now able to link a working executable of Chrome
for 64-bit debug build. The browser seemed to be working fine. Chrome is
good for testing because of its variety and size. It contains various
open-source libraries written by various people. The largest file in
Chrome is chrome.dll whose size is 496MB. LLD can link it in 24 seconds.
MSVC linker takes 48 seconds. So it is exactly 2x faster. (I measured
that with debug info and ICF being turned off.)

With this achievement, I think I can say that the new COFF linker is
now mostly feature complete for x86-64 Windows. I believe there are
still many lingering bugs, though.

llvm-svn: 241318
This commit is contained in:
Rui Ueyama 2015-07-03 04:32:49 +00:00
parent cb30079f41
commit d8111f2c2e
2 changed files with 9 additions and 5 deletions

View File

@ -354,10 +354,14 @@ void DelayLoadContents::create(Defined *H) {
auto A = make_unique<DelayAddressChunk>(T.get());
Addresses.push_back(std::move(A));
Thunks.push_back(std::move(T));
auto C =
make_unique<HintNameChunk>(S->getExternalName(), S->getOrdinal());
Names.push_back(make_unique<LookupChunk>(C.get()));
HintNames.push_back(std::move(C));
StringRef ExtName = S->getExternalName();
if (ExtName.empty()) {
Names.push_back(make_unique<OrdinalOnlyChunk>(S->getOrdinal()));
} else {
auto C = make_unique<HintNameChunk>(ExtName, 0);
Names.push_back(make_unique<LookupChunk>(C.get()));
HintNames.push_back(std::move(C));
}
}
// Terminate with null values.
Addresses.push_back(make_unique<NullChunk>(8));

View File

@ -21,7 +21,7 @@ IMPORT-NEXT: Symbol: (50)
IMPORT-NEXT: Address: 0x1400020BD
IMPORT-NEXT: }
IMPORT-NEXT: Import {
IMPORT-NEXT: Symbol: MessageBoxA (1)
IMPORT-NEXT: Symbol: MessageBoxA (0)
IMPORT-NEXT: Address: 0x140002114
IMPORT-NEXT: }
IMPORT-NEXT: }