[PECOFF] Set the correct PE header field value.

The charcateristics field should not have IMAGE_FILE_32BIT_MACHINE bit but have
IMAGE_FILE_LARGE_ADDRESS_AWARE bit for PE32+.

llvm-svn: 200518
This commit is contained in:
Rui Ueyama 2014-01-31 05:43:12 +00:00
parent 2cbf38e36f
commit 14876abb3d
2 changed files with 6 additions and 5 deletions

View File

@ -331,9 +331,10 @@ PEHeaderChunk<PEHeader>::PEHeaderChunk(const PECOFFLinkingContext &ctx)
_coffHeader.TimeDateStamp = time(nullptr);
// Attributes of the executable.
uint16_t characteristics = llvm::COFF::IMAGE_FILE_32BIT_MACHINE |
llvm::COFF::IMAGE_FILE_EXECUTABLE_IMAGE;
if (ctx.getLargeAddressAware())
uint16_t characteristics = llvm::COFF::IMAGE_FILE_EXECUTABLE_IMAGE;
if (!ctx.is64Bit())
characteristics |= llvm::COFF::IMAGE_FILE_32BIT_MACHINE;
if (ctx.getLargeAddressAware() || ctx.is64Bit())
characteristics |= llvm::COFF::IMAGE_FILE_LARGE_ADDRESS_AWARE;
if (ctx.getSwapRunFromCD())
characteristics |= llvm::COFF::IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP;

View File

@ -14,9 +14,9 @@ CHECK-NEXT: TimeDateStamp:
CHECK-NEXT: PointerToSymbolTable: 0x0
CHECK-NEXT: SymbolCount: 0
CHECK-NEXT: OptionalHeaderSize: 240
CHECK-NEXT: Characteristics [ (0x102)
CHECK-NEXT: IMAGE_FILE_32BIT_MACHINE (0x100)
CHECK-NEXT: Characteristics [ (0x22)
CHECK-NEXT: IMAGE_FILE_EXECUTABLE_IMAGE (0x2)
CHECK-NEXT: IMAGE_FILE_LARGE_ADDRESS_AWARE (0x20)
CHECK-NEXT: ]
CHECK-NEXT: }
CHECK-NEXT: ImageOptionalHeader {