[lld] r213216 - [PECOFF] Set DLL bit in PE header if DLL.
Rui Ueyama
ruiu at google.com
Wed Jul 16 17:22:27 PDT 2014
Author: ruiu
Date: Wed Jul 16 19:22:26 2014
New Revision: 213216
URL: http://llvm.org/viewvc/llvm-project?rev=213216&view=rev
Log:
[PECOFF] Set DLL bit in PE header if DLL.
Windows loader can load a DLL without this bit but it wouldn't
call the initializer function in the DLL if the bit is absent.
Added:
lld/trunk/test/pecoff/dll.test
Modified:
lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
Modified: lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp?rev=213216&r1=213215&r2=213216&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp Wed Jul 16 19:22:26 2014
@@ -332,6 +332,8 @@ PEHeaderChunk<PEHeader>::PEHeaderChunk(c
uint16_t characteristics = llvm::COFF::IMAGE_FILE_EXECUTABLE_IMAGE;
if (!ctx.is64Bit())
characteristics |= llvm::COFF::IMAGE_FILE_32BIT_MACHINE;
+ if (ctx.isDll())
+ characteristics |= llvm::COFF::IMAGE_FILE_DLL;
if (ctx.getLargeAddressAware() || ctx.is64Bit())
characteristics |= llvm::COFF::IMAGE_FILE_LARGE_ADDRESS_AWARE;
if (ctx.getSwapRunFromCD())
Added: lld/trunk/test/pecoff/dll.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/dll.test?rev=213216&view=auto
==============================================================================
--- lld/trunk/test/pecoff/dll.test (added)
+++ lld/trunk/test/pecoff/dll.test Wed Jul 16 19:22:26 2014
@@ -0,0 +1,7 @@
+# RUN: yaml2obj %p/Inputs/nop.obj.yaml > %t.obj
+#
+# RUN: lld -flavor link /out:%t.exe /subsystem:console \
+# RUN: /entry:start /dll -- %t.obj
+# RUN: llvm-readobj -file-headers %t.exe | FileCheck %s
+
+CHECK: IMAGE_FILE_DLL (0x2000)
More information about the llvm-commits
mailing list