Portable Executable and Common Object File Format Specification
Portable Executable and Common Object File Format Specification
Microsoft, MS, MS-DOS, and CodeView are registered trademarks, and Windows, Windows NT, Win32, Win32s, and
Visual C++ are trademarks of Microsoft Corporation in the USA and other countries.
Alpha AXP is a trademark of Digital Equipment Corporation. Intel is a registered trademark, and Intel386 is a trademark of
Intel Corporation. MIPS is a registered trademark of MIPS Computer Systems, Inc. Unicode is a trademark of Unicode,
Incorporated. UNIX is a registered trademark of UNIX Systems Laboratories. Other product and company names
mentioned herein may be the trademarks of their respective owners.
2. Overview
Figures 1 and 2 illustrate the Microsoft PE executable format and the Microsoft COFF object-
module format.
Figure 1. Typical 32-Bit Portable .EXE File Layout
PE32+ images allow for a 64-bit address space while limiting the image size to 4 Gigabytes.
Other PE32+ modifications are addressed in their respective sections.
The Optional Header itself has three major parts:
Offset Size Header part Description
(PE32/PE32+) (PE32/PE32+)
DLL Characteristics
The following values are defined for the DLLCharacteristics field of the Optional Header.
Constant Value Description
0x0001 Reserved
0x0002 Reserved
0x0004 Reserved
0x0008 Reserved
IMAGE_DLLCHARACTERISTICS_NO_BIND 0x0800 Do not bind image
IMAGE_DLLCHARACTERISTICS_WDM_DRIVER 0x2000 Driver is a WDM Driver
IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_ 0x8000 Image is Terminal Server aware
AWARE
3.4.3. Optional Header Data Directories (Image Only)
Each data directory gives the address and size of a table or string used by Windows NT. These
are all loaded into memory so that they can be used by the system at run time. A data directory
is an eight-byte field that has the following declaration:
typedef struct _IMAGE_DATA_DIRECTORY {
DWORD RVA;
DWORD Size;
} IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
The first field, RVA, is the relative virtual address of the table. The RVA is the address of the
table, when loaded, relative to the base address of the image. The second field gives the size in
bytes. The data directories, which form the last part of the Optional Header, are listed below.
Note that the number of directories is not fixed. The NumberOfRvaAndSizes field in the optional
header should be checked before looking for a specific directory.
Do not assume that the RVAs given in this table point to the beginning of a section or that the
sections containing specific tables have specific names.
Offset Size Field Description
(PE/PE32+)
If the symbol referred to (by the SymbolTableIndex field) has storage class
IMAGE_SYM_CLASS_SECTION, the symbol’s address is the beginning of the section. The
section is usually in the same file, except when the object file is part of an archive (library). In
that case, the section may be found in any other object file in the archive that has the same
archive-member name as the current object file. (The relationship with the archive-member
name is used in the linking of import tables, i.e. the .idata section.)
Intel 386™
The following relocation type indicators are defined for Intel386 and compatible processors:
Constant Value Description
IMAGE_REL_I386_ABSOLUTE 0x0000 This relocation is ignored.
IMAGE_REL_I386_DIR16 0x0001 Not supported.
IMAGE_REL_I386_REL16 0x0002 Not supported.
IMAGE_REL_I386_DIR32 0x0006 The target’s 32-bit virtual address.
IMAGE_REL_I386_DIR32NB 0x0007 The target’s 32-bit relative virtual address.
IMAGE_REL_I386_SEG12 0x0009 Not supported.
IMAGE_REL_I386_SECTION 0x000A The 16-bit-section index of the section containing the
target. This is used to support debugging information.
IMAGE_REL_I386_SECREL 0x000B The 32-bit offset of the target from the beginning of its
section. This is used to support debugging information
as well as static thread local storage.
IMAGE_REL_I386_REL32 0x0014 The 32-bit relative displacement to the target. This
supports the x86 relative branch and call instructions.
MIPS Processors
The following relocation type indicators are defined for MIPS processors:
Constant Value Description
IMAGE_REL_MIPS_ABSOLUTE 0x0000 This relocation is ignored.
IMAGE_REL_MIPS_REFHALF 0x0001 The high 16 bits of the target’s 32-bit virtual
address.
IMAGE_REL_MIPS_REFWORD 0x0002 The target’s 32-bit virtual address.
IMAGE_REL_MIPS_JMPADDR 0x0003 The low 26 bits of the target’s virtual address.
This supports the MIPS J and JAL instructions.
IMAGE_REL_MIPS_REFHI 0x0004 The high 16 bits of the target’s 32-bit virtual
address. Used for the first instruction in a two-
instruction sequence that loads a full address.
This relocation must be immediately followed by
a PAIR relocations whose SymbolTableIndex
contains a signed 16-bit displacement which is
added to the upper 16 bits taken from the
location being relocated.
IMAGE_REL_MIPS_REFLO 0x0005 The low 16 bits of the target’s virtual address.
IMAGE_REL_MIPS_GPREL 0x0006 16-bit signed displacement of the target relative
to the Global Pointer (GP) register.
IMAGE_REL_MIPS_LITERAL 0x0007 Same as IMAGE_REL_MIPS_GPREL.
IMAGE_REL_MIPS_SECTION 0x000A The 16-bit section index of the section
containing the target. This is used to support
debugging information.
IMAGE_REL_MIPS_SECREL 0x000B The 32-bit offset of the target from the beginning
of its section. This is used to support debugging
information as well as static thread local storage.
IMAGE_REL_MIPS_SECRELLO 0x000C The low 16 bits of the 32-bit offset of the target
from the beginning of its section.
IMAGE_REL_MIPS_SECRELHI 0x000D The high 16 bits of the 32-bit offset of the target
from the beginning of its section. A PAIR
relocation must immediately follow this on. The
SymbolTableIndex of the PAIR relocation
contains a signed 16-bit displacement, which is
added to the upper 16 bits taken from the
location being relocated.
IMAGE_REL_MIPS_JMPADDR16 0x0010 The low 26 bits of the target’s virtual address.
This supports the MIPS16 JAL instruction.
IMAGE_REL_MIPS_REFWORDNB 0x0022 The target’s 32-bit relative virtual address.
IMAGE_REL_MIPS_PAIR 0x0025 This relocation is only valid when it immediately
follows a REFHI or SECRELHI relocation. Its
SymbolTableIndex contains a displacement and
not an index into the symbol table.
Alpha Processors
The following relocation Type indicators are defined for Alpha processors:
Constant Value Description
IMAGE_REL_ALPHA_ABSOLUTE 0x0000 This relocation is ignored.
IMAGE_REL_ALPHA_REFLONG 0x0001 The target’s 32-bit virtual address. This fixup is
illegal in a PE32+ image unless the image has
been sandboxed by clearing the
IMAGE_FILE_LARGE_ADDRESS_AWARE bit in
the File Header.
IMAGE_REL_ALPHA_REFQUAD 0x0002 The target’s 64-bit virtual address.
IMAGE_REL_ALPHA_GPREL32 0x0003 32-bit signed displacement of the target relative
to the Global Pointer (GP) register.
IMAGE_REL_ALPHA_LITERAL 0x0004 16-bit signed displacement of the target relative
to the Global Pointer (GP) register.
IMAGE_REL_ALPHA_LITUSE 0x0005 Reserved for future use.
IMAGE_REL_ALPHA_GPDISP 0x0006 Reserved for future use.
IMAGE_REL_ALPHA_BRADDR 0x0007 The 21-bit relative displacement to the target.
This supports the Alpha relative branch
instructions.
IMAGE_REL_ALPHA_HINT 0x0008 14-bit hints to the processor for the target of an
Alpha jump instruction.
IMAGE_REL_ALPHA_INLINE_REFL 0x0009 The target’s 32-bit virtual address split into high
ONG and low 16-bit parts. Either an ABSOLUTE or
MATCH relocation must immediately follow this
relocation. The high 16 bits of the target address
are stored in the location identified by the
INLINE_REFLONG relocation. The low 16 bits
are stored four bytes later if the following
relocation is of type ABSOLUTE or at a signed
displacement given in the SymbolTableIndex if
the following relocation is of type MATCH.
IMAGE_REL_ALPHA_REFHI 0x000A The high 16 bits of the target’s 32-bit virtual
address. Used for the first instruction in a two-
instruction sequence that loads a full address.
This relocation must be immediately followed by a
PAIR relocations whose SymbolTableIndex
contains a signed 16-bit displacement which is
added to the upper 16 bits taken from the location
being relocated.
IMAGE_REL_ALPHA_REFLO 0x000B The low 16 bits of the target’s virtual address.
IMAGE_REL_ALPHA_PAIR 0x000C This relocation is only valid when it immediately
follows a REFHI , REFQ3, REFQ2, or SECRELHI
relocation. Its SymbolTableIndex contains a
displacement and not an index into the symbol
table.
IMAGE_REL_ALPHA_MATCH 0x000D This relocation is only valid when it immediately
follows INLINE_REFLONG relocation. Its
SymbolTableIndex contains the displacement in
bytes of the location for the matching low address
and not an index into the symbol table.
IMAGE_REL_ALPHA_SECTION 0x000E The 16-bit section index of the section containing
the target. This is used to support debugging
information.
IMAGE_REL_ALPHA_SECREL 0x000F The 32-bit offset of the target from the beginning
of its section. This is used to support debugging
information as well as static thread local storage.
IMAGE_REL_ALPHA_REFLONGNB 0x0010 The target’s 32-bit relative virtual address.
IMAGE_REL_ALPHA_SECRELLO 0x0011 The low 16 bits of the 32-bit offset of the target
from the beginning of its section.
IMAGE_REL_ALPHA_SECRELHI 0x0012 The high 16 bits of the 32-bit offset of the target
from the beginning of its section. A PAIR
relocation must immediately follow this on. The
SymbolTableIndex of the PAIR relocation
contains a signed 16-bit displacement which is
added to the upper 16 bits taken from the location
being relocated.
IMAGE_REL_ALPHA_REFQ3 0x0013 The low 16 bits of the high 32 bits of the target’s
64-bit virtual address. This relocation must be
immediately followed by a PAIR relocations
whose SymbolTableIndex contains a signed 32-
bit displacement which is added to the 16 bits
taken from the location being relocated. The 16
bits in the relocated location are shifted left by 32
before this addition.
IMAGE_REL_ALPHA_REFQ2 0x0014 The high 16 bits of the low 32 bits of the target’s
64-bit virtual address. This relocation must be
immediately followed by a PAIR relocations
whose SymbolTableIndex contains a signed 16-
bit displacement which is added to the upper 16
bits taken from the location being relocated.
IMAGE_REL_ALPHA_REFQ1 0x0015 The low 16 bits of the target’s 64-bit virtual
address.
IMAGE_REL_ALPHA_GPRELLO 0x0016 The low 16 bits of the 32-bit signed displacement
of the target relative to the Global Pointer (GP)
register.
IMAGE_REL_ALPHA_GPRELHI 0x0017 The high 16 bits of the 32-bit signed displacement
of the target relative to the Global Pointer (GP)
register.
ARM Processors
The following relocation Type indicators are defined for ARM processors:
Constant Value Description
IMAGE_REL_ARM_ABSOLUTE 0x0000 This relocation is ignored.
IMAGE_REL_ARM_ADDR32 0x0001 The target’s 32-bit virtual address.
IMAGE_REL_ARM_ADDR32NB 0x0002 The target’s 32-bit relative virtual address.
IMAGE_REL_ARM_BRANCH24 0x0003 The 24-bit relative displacement to the target.
IMAGE_REL_ARM_BRANCH11 0x0004 Reference to a subroutine call, consisting of
two 16-bit instructions with 11-bit offsets.
IMAGE_REL_ARM_SECTION 0x000E The 16-bit section index of the section
containing the target. This is used to support
debugging information.
IMAGE_REL_ARM_SECREL 0x000F The 32-bit offset of the target from the
beginning of its section. This is used to support
debugging information as well as static thread
local storage.
A line-number record, then, can either set the Linenumber field to 0 and point to a function
definition in the Symbol Table, or else it can work as a standard line-number entry by giving a
positive integer (line number) and the corresponding address in the object code.
A group of line-number entries always begins with the first format: the index of a function
symbol. If this is the first line-number record in the section, then it is also the COMDAT symbol
name for the function if the section’s COMDAT flag is set. (See Section 5.5.6, “COMDAT
Sections.”) The function’s auxiliary record in the Symbol Table has a Pointer to Linenumbers
field that points to this same line-number record.
A record identifying a function is followed by any number of line-number entries that give actual
line-number information (Linenumber greater than zero). These entries are one-based, relative to
the beginning of the function, and represent every source line in the function except for the first
one.
For example, the first line-number record for the following example would specify the
ReverseSign function (Symbol Table Index of ReverseSign, Linenumber set to 0). Then records
with Linenumber values of 1, 2, and 3 would follow, corresponding to source lines as shown:
// some code precedes ReverseSign function
int ReverseSign(int i)
1: {
2: return -1 * i;
3: }
Zero or more auxiliary symbol-table records immediately follow each standard symbol-table
record. However, typically not more than one auxiliary symbol-table record follows a standard
symbol-table record (except for .file records with long file names). Each auxiliary record is the
same size as a standard symbol-table record (18 bytes), but rather than define a new symbol, the
auxiliary record gives additional information on the last symbol defined. The choice of which of
several formats to use depends on the Storage Class field. Currently defined formats for
auxiliary symbol table records are shown in “Auxiliary Symbol Records.”
Tools that read COFF symbol tables must ignore auxiliary symbol records whose interpretation is
unknown. This allows the symbol table format to be extended to add new auxiliary records,
without breaking existing tools.
5.4.1. Symbol Name Representation
The Name field in a symbol table consists of eight bytes that contain the name itself, if not too
long, or else give an offset into the String Table. To determine whether the name itself or an
offset is given, test the first four bytes for equality to zero.
Offset Size Field Description
0 8 Short Name An array of eight bytes. This array is
padded with nulls on the right if the name is
less than eight bytes long.
0 4 Zeroes Set to all zeros if the name is longer than
eight bytes.
4 4 Offset Offset into the String Table.
The most significant byte specifies whether the symbol is a pointer to, function returning, or array
of the base type specified in the least significant byte. Microsoft tools use this field only to
indicate whether or not the symbol is a function, so that the only two resulting values are 0x0 and
0x20 for the Type field. However, other tools can use this field to communicate more
information.
It is very important to specify the function attribute correctly. This information is required for
incremental linking to work correctly. For some architectures the information may be required for
other purposes.
Constant Value Description
IMAGE_SYM_DTYPE_NULL 0 No derived type; the symbol is a simple scalar
variable.
IMAGE_SYM_DTYPE_POINTER 1 Pointer to base type.
IMAGE_SYM_DTYPE_FUNCTION 2 Function returning base type.
IMAGE_SYM_DTYPE_ARRAY 3 Array of base type.
A value of
IMAGE_WEAK_EXTERN_SEARCH_LIBRARY
indicates that a library search for sym1 should be
performed.
A value of
IMAGE_WEAK_EXTERN_SEARCH_ALIAS
indicates that sym1 is an alias for sym2.
8 10 Unused.
Note that the Characteristics field is not defined in WINNT.H; instead, the Total Size field is
used.
Notice that certificates always start on an octaword boundary. If a certificate is not an even
number of octawords long, it is zero padded to the next octaword boundary. However, the length
of the certificate does not include this padding and so any certificate navigation software must
be sure to round up to the next octaword to locate another certificate.
The tables referenced in this data structure are organized and sorted just as their counterparts
are for traditional imports. See Section 6.4. The idata Section for details.
5.8.2. Attributes
As yet, there are no attribute flags defined. This field is currently set to zero by the linker in the
image. This field can be used to extend the record by indicating the presence of new fields or for
indicating behaviors to the delay and/or unload helper functions.
5.8.3. Name
The name of the DLL to be delay loaded resides in the read-only data section of the image and is
referenced via the szName field.
5.8.7. Delay Bound Import Address Table (BIAT) and Time Stamp
The delay BIAT is an optional table of IMAGE_THUNK_DATA items that is used along with the
timestamp field by a post process binding phase.
6. Special Sections
Typical COFF sections contain code or data that linkers and Win32 loaders process without
special knowledge of the sections’ contents. The contents are relevant only to the application
being linked or executed.
However, some COFF sections have special meanings when found in object files and/or image
files. Tools and loaders recognize these sections because they have special flags set in the
section header, or because they are pointed to from special locations in the image optional
header, or because the section name is “magic”: that is, the name indicates a special function of
the section. (Even where the section name is not magic, the name is dictated by convention, so
we will refer to a name.)
The reserved sections and their attributes are described in the table below, followed by detailed
descriptions for a subset of them.
Section Content Characteristics
Name
.arch Alpha architecture IMAGE_SCN_MEM_READ |
information IMAGE_SCN_CNT_INITIALIZED_DATA |
IMAGE_SCN_ALIGN_8BYTES |
IMAGE_SCN_MEM_DISCARDABLE
.bss Uninitialized data IMAGE_SCN_CNT_UNINITIALIZED_DATA |
IMAGE_SCN_MEM_READ |
IMAGE_SCN_MEM_WRITE
.data Initialized data IMAGE_SCN_CNT_INITIALIZED_DATA |
IMAGE_SCN_MEM_READ |
IMAGE_SCN_MEM_WRITE
.edata Export tables IMAGE_SCN_CNT_INITIALIZED_DATA |
IMAGE_SCN_MEM_READ
.idata Import tables IMAGE_SCN_CNT_INITIALIZED_DATA |
IMAGE_SCN_MEM_READ |
IMAGE_SCN_MEM_WRITE
.pdata Exception IMAGE_SCN_CNT_INITIALIZED_DATA |
information IMAGE_SCN_MEM_READ
.rdata Read-only IMAGE_SCN_CNT_INITIALIZED_DATA |
initialized data IMAGE_SCN_MEM_READ
.reloc Image relocations IMAGE_SCN_CNT_INITIALIZED_DATA |
IMAGE_SCN_MEM_READ |
IMAGE_SCN_MEM_DISCARDABLE
.rsrc Resource IMAGE_SCN_CNT_INITIALIZED_DATA |
directory IMAGE_SCN_MEM_READ |
IMAGE_SCN_MEM_WRITE
.text Executable code IMAGE_SCN_CNT_CODE |
IMAGE_SCN_MEM_EXECUTE |
IIMAGE_SCN_MEM_READ
.tls Thread-local IMAGE_SCN_CNT_INITIALIZED_DATA |
storage IMAGE_SCN_MEM_READ |
IMAGE_SCN_MEM_WRITE
.xdata Exception IMAGE_SCN_CNT_INITIALIZED_DATA |
information IMAGE_SCN_MEM_READ
Some of the sections listed here are marked “(object only)” or “(image only)” to indicate that their
special semantics are relevant only for object files or image files, respectively. A section that
says “(image only)” may still appear in an object file as a way of getting into the image file, but
the section has no special meaning to the linker, only to the image file loader.
6.1. The .debug Section
The .debug section is used in object files to contain compiler-generated debug information, and
in image files to contain the total debug information generated. This section describes the
packaging of debug information in object and image files. The actual format of CodeView debug
information is not described here. See the document CV4 Symbolic Debug Information
Specification.
The next section describes the format of the debug directory, which can be anywhere in the
image. Subsequent sections describe the “groups” in object files that contain debug information.
The default for the linker is that debug information is not mapped into the address space of the
image. A .debug section exists only when debug information is mapped in the address space.
If Debug Type is set to IMAGE_DEBUG_TYPE_FPO, the debug raw data is an array in which
each member describes the stack frame of a function. Not every function in the image file need
have FPO information defined for it, even though debug type is FPO. Those functions that do
not have FPO information are assumed to have normal stack frames. The format for FPO
information is defined as follows:
#define FRAME_FPO 0
#define FRAME_TRAP 1
#define FRAME_TSS 2
When another image file imports a symbol by name, the Name Pointer Table is searched for a
matching string. If one is found, the associated ordinal is then determined by looking at the
corresponding member in the Ordinal Table (that is, the member of the Ordinal Table with the
same index as the string pointer found in the Name Pointer Table). The resulting ordinal is an
index into the Export Address Table, which gives the actual location of the desired symbol.
Every export symbol can be accessed by an ordinal.
Direct use of an ordinal is therefore more efficient, because it avoids the need to search the
Name Pointer Table for a matching string. However, use of an export name is more mnemonic
and does not require the user to know the table index for the symbol.
A Forwarder RVA exports a definition from some other image, making it appear as if it were
being exported by the current image. Thus the symbol is simultaneously imported and exported.
For example, in KERNEL32.DLL in Windows NT, the export named “HeapAlloc” is forwarded to
the string “NTDLL.RtlAllocateHeap”. This allows applications to use the Windows NT-specific
module “NTDLL.DLL” without actually containing import references to it. The application’s import
table references only “KERNEL32.DLL.” Therefore, the application is not specific to Windows NT
and can run on any Win32 system.
Null
Null
Null
Hint-Name Table
For the ARM, PowerPC, SH3 and SH4 WindowsCE platforms, this function table entry format is
used:
Offset Size Field Description
0 4 Begin Address Virtual address of the corresponding
function.
4 8 bits Prolog Length Number of instructions in the function’s
prolog.
4 22 bits Function Length Number of instructions in the function.
4 1 bit 32-bit Flag Set if the function is comprised of 32-bit
instructions, cleared for a 16-bit function.
4 1 bit Exception Flag Set if an exception handler exists for the
function.
The Block Size field is then followed by any number of Type/Offset entries. Each entry is a word
(2 bytes) and has the following structure:
Offset Size Field Description
0 4 bits Type Stored in high 4 bits of word. Value
indicating which type of fixup is to be
applied. These fixups are described in
“Fixup Types.”
0 12 bits Offset Stored in remaining 12 bits of word. Offset
from starting address specified in the Page
RVA field for the block. This offset specifies
where the fixup is to be applied.
To apply a fixup, a delta is calculated as the difference between the preferred base address, and
the base where the image is actually loaded. If the image is loaded at its preferred base, the
delta would be zero, and thus the fixups would not have to be applied.
To support this programming construct, the PE/COFF .tls section specifies the following
information: initialization data, callback routines for per-thread initialization and termination, and
the TLS index explained in the following discussion.
Note Statically declared TLS data objects can be used only in statically loaded image files.
This fact makes it unreliable to use static TLS data in a DLL unless you know that the DLL,
or anything statically linked with it, will never be loaded dynamically with the LoadLibrary
API function.
Executable code accesses a static TLS data object through the following steps:
1. At link time, the linker sets the Address of Index field of the TLS Directory. This field points
to a location where the program will expect to receive the TLS index.
The Microsoft run-time library facilitates this process by defining a memory image of the TLS
Directory and giving it the special name “__tls_used” (Intel x86 platforms) or “_tls_used” (other
platforms). The linker looks for this memory image and uses the data there to create the TLS
Directory. Other compilers that support TLS and work with the Microsoft linker must use this
same technique.
2. When a thread is created, the loader communicates the address of the thread’s TLS array
by placing the address of the Thread Environment Block (TEB) in the FS register. A pointer to
the TLS array is at the offset of 0x2C from the beginning of TEB. This behavior is Intel x86
specific.
3. The loader assigns the value of the TLS index to the place indicated by the Address of
Index field.
4. The executable code retrieves the TLS index and also the location of the TLS array.
5. The code uses the TLS index and the TLS array location (multiplying the index by four and
using it as an offset to the array) to get the address of the TLS data area for the given program
and module. Each thread has its own TLS data area, but this is transparent to the program,
which doesn’t need to know how data is allocated for individual threads.
6. An individual TLS data object is accessed as some fixed offset into the TLS data area.
The TLS array is an array of addresses that the system maintains for each thread. Each address
in this array gives the location of TLS data for a given module (.EXE or DLL) within the program.
The TLS index indicates which member of the array to use. (The index is a number, meaningful
only to the system that identifies the module).
When this data is encoded, a dump of the PE/COFF Resource Directory results in the following
output:
Offset Data
0000: 00000000 00000000 00000000 00030000 (3 entries in this directory)
0010: 00000001 80000028 (TypeId #1, Subdirectory at offset 0x28)
0018: 00000002 80000050 (TypeId #2, Subdirectory at offset 0x50)
0020: 00000009 80000080 (TypeId #9, Subdirectory at offset 0x80)
0028: 00000000 00000000 00000000 00030000 (3 entries in this directory)
0038: 00000001 800000A0 (NameId #1, Subdirectory at offset 0xA0)
0040: 00000002 00000108 (NameId #2, data desc at offset 0x108)
0048: 00000003 00000118 (NameId #3, data desc at offset 0x118)
0050: 00000000 00000000 00000000 00040000 (4 entries in this directory)
0060: 00000001 00000128 (NameId #1, data desc at offset 0x128)
0068: 00000002 00000138 (NameId #2, data desc at offset 0x138)
0070: 00000003 00000148 (NameId #3, data desc at offset 0x148)
0078: 00000004 00000158 (NameId #4, data desc at offset 0x158)
0080: 00000000 00000000 00000000 00020000 (2 entries in this directory)
0090: 00000001 00000168 (NameId #1, data desc at offset 0x168)
0098: 00000009 800000C0 (NameId #9, Subdirectory at offset 0xC0)
00A0: 00000000 00000000 00000000 00020000 (2 entries in this directory)
00B0: 00000000 000000E8 (Language ID 0, data desc at offset 0xE8
00B8: 00000001 000000F8 (Language ID 1, data desc at offset 0xF8
00C0: 00000000 00000000 00000000 00030000 (3 entries in this directory)
00D0: 00000001 00000178 (Language ID 0, data desc at offset 0x178
00D8: 00000001 00000188 (Language ID 1, data desc at offset 0x188
00E0: 00000001 00000198 (Language ID 2, data desc at offset 0x198
00E8: 000001A8 (At offset 0x1A8, for TypeId #1, NameId #1,
Language id #0
00000004 (4 bytes of data)
00000000 (codepage)
00000000 (reserved)
00F8: 000001AC (At offset 0x1AC, for TypeId #1, NameId #1,
Language id #1
00000004 (4 bytes of data)
00000000 (codepage)
00000000 (reserved)
0108: 000001B0 (At offset 0x1B0, for TypeId #1, NameId #2,
00000004 (4 bytes of data)
00000000 (codepage)
00000000 (reserved)
0118: 000001B4 (At offset 0x1B4, for TypeId #1, NameId #3,
00000004 (4 bytes of data)
00000000 (codepage)
00000000 (reserved)
0128: 000001B8 (At offset 0x1B8, for TypeId #2, NameId #1,
00000004 (4 bytes of data)
00000000 (codepage)
00000000 (reserved)
0138: 000001BC (At offset 0x1BC, for TypeId #2, NameId #2,
00000004 (4 bytes of data)
00000000 (codepage)
00000000 (reserved)
0148: 000001C0 (At offset 0x1C0, for TypeId #2, NameId #3,
00000004 (4 bytes of data)
00000000 (codepage)
00000000 (reserved)
0158: 000001C4 (At offset 0x1C4, for TypeId #2, NameId #4,
00000004 (4 bytes of data)
00000000 (codepage)
00000000 (reserved)
0168: 000001C8 (At offset 0x1C8, for TypeId #9, NameId #1,
00000004 (4 bytes of data)
00000000 (codepage)
00000000 (reserved)
0178: 000001CC (At offset 0x1CC, for TypeId #9, NameId #9,
Language id #0
00000004 (4 bytes of data)
00000000 (codepage)
00000000 (reserved)
0188: 000001D0 (At offset 0x1D0, for TypeId #9, NameId #9,
Language id #1
00000004 (4 bytes of data)
00000000 (codepage)
00000000 (reserved)
0198: 000001D4 (At offset 0x1D4, for TypeId #9, NameId #9,
Language id #2
00000004 (4 bytes of data)
00000000 (codepage)
00000000 (reserved)
01A8: 00010001
01AC: 10010001
01B0: 00010002
01B4: 00010003
01B8: 00020001
01BC: 00020002
01C0: 00020003
01C4: 00020004
01C8: 00090001
01CC: 00090009
01D0: 10090009
01D4: 20090009
Header
st
1 Linker Member
Header
2nd Linker Member
Header
Longnames Member
Header
Contents of OBJ File 1
(COFF format)
Header
Contents of OBJ File 2
(COFF format)
.
Header
Contents of OBJ File N
(COFF format)
The Name field has one of the formats shown in the following table. As mentioned above, each
of these strings is left justified and padded with trailing spaces within a field of 16 bytes:
Contents of Name Field Description
Name/ The field gives the name of the archive member directly.
/ The archive member is one of the two linker members. Both of
the linker members have this name.
// The archive member is the longname member, which consists of
a series of null-terminated ASCII strings. The longnames
member is the third archive member, and must always be
present even if the contents are empty.
The name of the archive member is located at offset n within the
longnames member. The number n is the decimal representation
of the offset. For example: “\26” indicates that the name of the
archive member is located 26 bytes beyond the beginning of
longnames member contents.
The elements in the Offsets array must be arranged in ascending order. This fact implies that the
symbols listed in the String Table must be arranged according to the order of archive members.
For example, all the symbols in the first object-file member would have to be listed before the
symbols in the second object file.
This is sufficient information to accurately reconstruct the entire contents of the member
at the time of its use.
This structure is followed by two null-terminated strings describing the imported symbol’s name,
and the DLL from which it came.
These values are used to determine which section contributions must be generated by the tool
using the library if it must access that data.
foo()
{
}
The commands used to compile HELLO.C (with debug information) and generate this example
were the following (the -Gy option to the compiler is used, which causes each procedure to be
generated as a separate COMDAT section):
cl -c -Zi -Gy hello2.c
link -dump -all hello2.obj >hello2.dmp
Here is the resulting file HELLO2.DMP: (The reader is encouraged to experiment with various
other examples, in order to clarify the concepts described in this specification.)
Dump of file hello2.obj
SECTION HEADER #1
.drectve name
0 physical address
0 virtual address
26 size of raw data
12C file pointer to raw data
0 file pointer to relocation table
0 file pointer to line numbers
0 number of relocations
0 number of line numbers
100A00 flags
Info
Remove
1 byte align
RAW DATA #1
00000000 2D 64 65 66 61 75 6C 74 | 6C 69 62 3A 4C 49 42 43 -default|lib:LIBC
00000010 20 2D 64 65 66 61 75 6C | 74 6C 69 62 3A 4F 4C 44 -defaul|tlib:OLD
00000020 4E 41 4D 45 53 20 NAMES
Linker Directives
-----------------
-defaultlib:LIBC
-defaultlib:OLDNAMES
SECTION HEADER #2
.debug$S name
0 physical address
0 virtual address
5C size of raw data
152 file pointer to raw data
0 file pointer to relocation table
0 file pointer to line numbers
0 number of relocations
0 number of line numbers
42100048 flags
No Pad
Initialized Data
Discardable
1 byte align
Read Only
RAW DATA #2
00000000 02 00 00 00 11 00 09 00 | 00 00 00 00 0A 68 65 6C ........|.....hel
00000010 6C 6F 32 2E 6F 62 6A 43 | 00 01 00 05 00 00 00 3C lo2.objC|.......<
00000020 4D 69 63 72 6F 73 6F 66 | 74 20 28 52 29 20 33 32 Microsof|t (R) 32
00000030 2D 62 69 74 20 43 2F 43 | 2B 2B 20 4F 70 74 69 6D -bit C/C|++ Optim
00000040 69 7A 69 6E 67 20 43 6F | 6D 70 69 6C 65 72 20 56 izing Co|mpiler V
00000050 65 72 73 69 6F 6E 20 31 | 31 2E 30 30 ersion 1|1.00
SECTION HEADER #3
.text name
0 physical address
0 virtual address
A size of raw data
1AE file pointer to raw data
1B8 file pointer to relocation table
1C2 file pointer to line numbers
1 number of relocations
3 number of line numbers
60501020 flags
Code
Communal; sym= _main
16 byte align
Execute Read
RAW DATA #3
00000000 55 8B EC E8 00 00 00 00 | 5D C3 U‹ìè....|].
RELOCATIONS #3
Symbol Symbol
Offset Type Applied To Index Name
-------- ---------------- ----------------- -------- ------
00000004 REL32 00000000 13 _foo
LINENUMBERS #3
SECTION HEADER #4
.debug$S name
0 physical address
0 virtual address
30 size of raw data
1D4 file pointer to raw data
204 file pointer to relocation table
0 file pointer to line numbers
2 number of relocations
0 number of line numbers
42101048 flags
No Pad
Initialized Data
Communal (no symbol)
Discardable
1 byte align
Read Only
RAW DATA #4
00000000 2A 00 0B 10 00 00 00 00 | 00 00 00 00 00 00 00 00 *.......|........
00000010 0A 00 00 00 03 00 00 00 | 08 00 00 00 01 10 00 00 ........|........
00000020 00 00 00 00 00 00 01 04 | 6D 61 69 6E 02 00 06 00 ........|main....
RELOCATIONS #4
Symbol Symbol
Offset Type Applied To Index Name
-------- ---------------- ----------------- -------- ------
00000020 SECREL 00000000 8 _main
00000024 SECTION 0000 8 _main
SECTION HEADER #5
.text name
0 physical address
0 virtual address
5 size of raw data
218 file pointer to raw data
0 file pointer to relocation table
21D file pointer to line numbers
0 number of relocations
2 number of line numbers
60501020 flags
Code
Communal; sym= _foo
16 byte align
Execute Read
RAW DATA #5
00000000 55 8B EC 5D C3 U‹ì].
LINENUMBERS #5
SECTION HEADER #6
.debug$S name
0 physical address
0 virtual address
2F size of raw data
229 file pointer to raw data
258 file pointer to relocation table
0 file pointer to line numbers
2 number of relocations
0 number of line numbers
42101048 flags
No Pad
Initialized Data
Communal (no symbol)
Discardable
1 byte align
Read Only
RAW DATA #6
00000000 29 00 0B 10 00 00 00 00 | 00 00 00 00 00 00 00 00 ).......|........
00000010 05 00 00 00 03 00 00 00 | 03 00 00 00 01 10 00 00 ........|........
00000020 00 00 00 00 00 00 01 03 | 66 6F 6F 02 00 06 00 ........|foo....
RELOCATIONS #6
Symbol Symbol
Offset Type Applied To Index Name
-------- ---------------- ----------------- -------- ------
00000020 SECREL 00000000 13 _foo
00000024 SECTION 0000 13 _foo
SECTION HEADER #7
.debug$T name
0 physical address
0 virtual address
34 size of raw data
26C file pointer to raw data
0 file pointer to relocation table
0 file pointer to line numbers
0 number of relocations
0 number of line numbers
42100048 flags
No Pad
Initialized Data
Discardable
1 byte align
Read Only
RAW DATA #7
00000000 02 00 00 00 2E 00 16 00 | 33 E1 36 34 01 00 00 00 ........|3á64....
00000010 22 65 3A 5C 62 62 74 5C | 74 6F 6F 6C 73 5C 76 63 "e:\bbt\|tools\vc
00000020 35 30 5C 62 69 6E 5C 78 | 38 36 5C 76 63 35 30 2E 50\bin\x|86\vc50.
00000030 70 64 62 F1 pdb.
Summary
BB .debug$S
34 .debug$T
26 .drectve
F .text