PE (portable executable) header flags (Delphi)
Go Up to Delphi Compiler Directives (List) Index
Type |
Flag |
Syntax |
{$SetPEFlags <integer expression>} {$SetPEOptFlags <integer expression>} |
Scope |
Local |
Microsoft relies on PE (portable executable) header flags to allow an application to indicate compatiblity with OS services or request advanced OS services. These directives provide powerful options for tuning your applications on high-end NT systems.
These directives allow you to set flag bits in the PE file header's Characteristics field and PE file optional header's DLLCharacteristics field, respectively. Most of the Characteristics flags, set using $SetPEFlags, are specifically for object files and libraries. DLLCharacteristics, set using $SetPEOptFlags, are flags that describe when to call a DLL's entry point.
The <integer expression> in these directives can include Delphi constant identifiers, such as the IMAGE_FILE_xxxx constants defined in Windows.pas. Multiple constants should be OR'd together.
The following table lists some of the header flags you can set, using SetPEFlags or SetPEOptFlags.
Name | Description |
---|---|
IMAGE_FILE_RELOCS_STRIPPED |
Relocation information is stripped from file. |
IMAGE_FILE_EXECUTABLE_IMAGE |
File is executable (i.e. no unresolved external references). |
IMAGE_FILE_LINE_NUMS_STRIPPED |
Line numbers are stripped from file. |
IMAGE_FILE_LOCAL_SYMS_STRIPPED |
Local symbols are stripped from file. |
IMAGE_FILE_AGGRESIVE_WS_TRIM |
Agressively trim working set. |
IMAGE_FILE_LARGE_ADDRESS_AWARE |
Application can handle addresses larger than 2 GB. |
IMAGE_FILE_BYTES_REVERSED_LO |
Bytes of machine word are reversed. |
IMAGE_FILE_32BIT_MACHINE |
32 bit word machine. |
IMAGE_FILE_DEBUG_STRIPPED |
Debugging info is stripped from file in .DBG file. |
IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP |
If Image is on removable media, copy and run from the swap file. |
IMAGE_FILE_NET_RUN_FROM_SWAP |
If Image is on Net, copy and run from the swap file. |
IMAGE_FILE_SYSTEM |
System File. |
IMAGE_FILE_DLL |
The file is a DLL. |
IMAGE_FILE_UP_SYSTEM_ONLY |
File should only be run on a UP machine. |
IMAGE_FILE_BYTES_REVERSED_HI |
Bytes of machine word are reversed. |
IMAGE_FILE_MACHINE_UNKNOWN |
Unknown machine. |
IMAGE_FILE_MACHINE_I386 |
Intel 386. |
IMAGE_FILE_MACHINE_R3000 |
MIPS Little-Endian, 0x160 big-endian. |
IMAGE_FILE_MACHINE_R4000 |
MIPS Little-Endian. |
IMAGE_FILE_MACHINE_R10000 |
MIPS Little-Endian. |
IMAGE_FILE_MACHINE_ALPHA |
Alpha_AXP. |
IMAGE_FILE_MACHINE_POWERPC |
IBM PowerPC Little-Endian. |
You can include these directives in the source code multiple times. The flag values specified by multiple directives are strictly cumulative: if the first occurrence of the directive sets $03 and the second occurrence sets $10, the value written to the executable file at link time will be $13 (plus whatever bits the linker normally sets in the PE flag fields).
These directives only affect the output file if included in source code prior to linking. This means you should place these directives in a .dpr or .dpk file, not in a regular unit. Like the exe description directive, placing these directives in unit source code is not an error. However, these directives in unit source will not affect the output file (exe or dll) unless the unit source is recompiled at the time the output file is linked.
Five options related to the PE header are available on the Project > Options > Delphi Compiler > Linking page in the IDE.