[lld] r241318 - COFF: Fix ordinal-only delay-imported symbols.

Rui Ueyama ruiu at google.com
Thu Jul 2 21:32:49 PDT 2015


Author: ruiu
Date: Thu Jul  2 23:32:49 2015
New Revision: 241318

URL: http://llvm.org/viewvc/llvm-project?rev=241318&view=rev
Log:
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.

Modified:
    lld/trunk/COFF/DLL.cpp
    lld/trunk/test/COFF/delayimports.test

Modified: lld/trunk/COFF/DLL.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/DLL.cpp?rev=241318&r1=241317&r2=241318&view=diff
==============================================================================
--- lld/trunk/COFF/DLL.cpp (original)
+++ lld/trunk/COFF/DLL.cpp Thu Jul  2 23:32:49 2015
@@ -354,10 +354,14 @@ void DelayLoadContents::create(Defined *
       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));

Modified: lld/trunk/test/COFF/delayimports.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/delayimports.test?rev=241318&r1=241317&r2=241318&view=diff
==============================================================================
--- lld/trunk/test/COFF/delayimports.test (original)
+++ lld/trunk/test/COFF/delayimports.test Thu Jul  2 23:32:49 2015
@@ -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: }





More information about the llvm-commits mailing list