[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.

llvm-svn: 213216
This commit is contained in:
Rui Ueyama 2014-07-17 00:22:26 +00:00
parent 033890cd0a
commit 286691ad5e
2 changed files with 9 additions and 0 deletions

View File

@ -332,6 +332,8 @@ PEHeaderChunk<PEHeader>::PEHeaderChunk(const PECOFFLinkingContext &ctx)
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())

7
lld/test/pecoff/dll.test Normal file
View File

@ -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)