OS2 OMF and LX Object Formats Revision 8 199406
OS2 OMF and LX Object Formats Revision 8 199406
Revision 8
Contents
Introduction . 2
Contents ii
Copyright IBM Corp. 1991, 1993
Contents iii
Copyright IBM Corp. 1991, 1993
Figures
l. Standard object module record format 3
2. THEADR record type definition 7
3. LHEADR record type definition 8
4. COMENT record type definition 9
5. IMPDEF record type definition 12
6. IMPDEF record type definition 13
7. INCDEF record type definition 15
8. LNKDIR record type definition 16
9. BIT FLAGS byte definition 16
10. LIBMOD record type definition 17
11. EXESTR record type definition 18
12. INCERR record type definition 19
13. NOPAD record type definition 20
14. WEAK EXTERN record type definition 21
15. LAZY EXTERN record type definition 23
16. IDMDLL Identifier Manipulator DLL subrecord format definition 24
17. MODEND module enq record . . . . . . . 27
18. EXTDEF external names definition record 29
19. PUBDEF Public Names Definition Record 30
20. LINNUM line number record . . . 32
21. LNAMES list of names record . . . 33
22. SEGDEF segment definition record 34
23. GRPDEF group definition record 37
24. FIXUPP Fixup Record . . . . . . 38
25. LEDATA logical enumerated data record 42
26. LIDATA Logical Iterated Data Record 43
27. COMDEF Communal Names Definition Record 45
28. BAKPAT Backpatch record . . . . . . . . . . . . 47
29. LEXTDEF Local External Names Definition Record 48
30. LPUBDEF Local Public Names Definition Record 49
31. LCOMDEF Local Communal Names Definition Record 50
32. COMDAT initialized communal data record 51
33. COMDAT initialized communal data record 54
34. ALIAS Alias Definition Record . . . 55
35. NB KPAT Named Backpatch Record 56
36. Dos 2.0 Section (Discarded) . . . . . 57
37. Linear Executable Module Header (Resident) 57
38. Loader Section (Resident) 58
39. Loader Section (Resident) 58
40. Non-Resident Section .. 59
41. Not used by the Loader . 59
42. 32-bit Linear EXE Header 60
43. Object Table . . . . . . . 67
44. Object Page Table Entry 69
45. Resource Table . . . . . . 70
46. Resident or Non-resident Name Table Entry 71
47. Entry Table . . . . . . . . . . . . . 72
48. Module Format Directive Table . 76
49. Verify Record Table ...... . 77
50. Per-Page Checksum 78
51. Fixup Page Table 78
Figures iv
Copyright IBM Corp. 1991, 1993
Figures V
Copyright IBM Corp. 1991, 1993
1
Copyright IBM Corp. 1991, 199 3
Introduction
This document is intended to describe the interface that is used by language translators and generators as
their intermediate output to the linker for the 32-bit OS/2 operating system. The linker will generate the
executable module that is used by the loader to invoke the .EXE and .DLL programs at execution time.
Introduction 2
Copyright IBM Corp. 1991, 1993
Record Format:
The Record Type field is a 1-byte field containing the hexadecimal number that identifies the type of object
record. The format is determined by the least significant bit of the Record Type field. Note that this does
not govern Use32/Usel6 segment attributes; it simply specifies the size of certain numeric fields within the
record. An odd Record Type indicates that 32-bit values are present. An even Record Type indicates that
those fields contain 16-bit values. The fields affected are described with each record.
An entire record occupies Record Length + 3 bytes. The record length does not include the count for the
record type and record length fields. Unless otherwise noted within the record definition, the record length
should not exceed 1024 bytes.
The Chk Sum field is a 1-byte field that contains the negative sum (modulo 256) of all other bytes in the
record. The byte sum over the entire record, ignoring overflow, is zero.
NOTES:
The contents of each record are determined by the record type, but certain subfields appear frequently; the
format of such fields is described next.
Names
Name strings are encoded as an 8-bit unsigned count followed by a string of "count" characters. The char-
acter set is usually some ASCII subset. A null name is specified by a single byte of 0 (indicating a string of
length zero).
Indexed References
Certain items are ordered by occurrence, and referenced by index (starting index is 1). Index fields can
contain 0, indicating not-present, or values from 1 through 7FFF. The index is encoded as 1 or 2 bytes.
If the index number is in the range 0-7H, the high-order bit (bit 7) is 0 and the low-order bits contain the
index number, so the field is only 1 byte long. If the index number is in the range 80-7FFFH, the field is 2
bytes long. The high-order bit of the first byte in the field is set to 1, and the high-order byte of the index
number which must be in the range (0-7FH) fits in the remaining 7 bits. The low-order byte of the index
number is specified in the second byte of the field. A 16-bit value is obtained as follows:
Type indices
The type index is treated as an index field when a record is parsed (occupies one or two bytes, occurs in
PUBDEF, COMDEF, EXTDEF records). They are encoded as described under indexed references.
NOTE: At present, no type checking is done by the linker. If any link-time semantics are defined, that
information will be recorded somewhere within this document.
Ordered Collections
Certain records and record groups are ordered; the ordering is obtained from the order of the record types
within the file together with the ordering of repeated fields within these records. Such ordered collections are
referenced by index, counting from 1 (index 0 indicates unknown or decline-to-state).
For example, there may be many LNAMES records within a module and each of those records may contain
many names. The names are indexed starting at 1 for the first name in the first LNAMES record encount-
ered while reading the file, 2 for the second name in the first record, etc., and the highest index for the last
name in the last LNAMES record encountered.
Words and double words (16 and 32 bit quantities) are stored in Intel byte order (lowest address is least
significant).
Certain records, notably SEGDEF, PUB DEF, LINNUM, LEDATA, LIDATA, FIXUPP and MODEND,
contain size, offset, and displacement values which may be 32 bit quantities for Use32 segments. The
encoding is as follows.
• When the least significant bit of the record type byte is set (ie record type is an odd number), the
numeric fields are 4 bytes.
• When the least significant bit of the record type byte is clear, the fields occupy 2 bytes (16 bit Object
Module Format). The values are zero-extended when applied to Use32 segments.
Order of records
The record order is chosen so that bind/link passes through an object module are minimized. This differs
from the previous less specific ordering in that all symbolic information (in particular, all export and public
symbols) must occur at the start of the object module. This order is recommended but not mandatory.
Identifier record(s):
Must be the first record.
• THEADR or LHEADR
In LINK, Pass 2 begins again at the start of the object module, so LIDATA records, etc., are proc-
essed in Pass 2 no matter where they are placed in the object module.
Records ignored by link pass one and processed by link pass two:
May come before or after link pass two:
• LIDA TA or LEDATA records followed by applicable FIXUPP records.
• FIXUPPs containing THREADs only.
BAKPAT and NBAKPA T fixupps.
• LINNUM and LINSYM providing line number to program code or data association.
Terminator
Description:
The THEADR record contains the name of the object module. This name identifies an object module
within an object library or in messages produced by the linker.
The String Length byte gives the number of characters in the name string; the name string itself is ASCII.
This name is usually that of the source program (if supplied by the language translator), or may be specified
directly by the programmer (e.g. TITLE pseudo-op).
This record must occur as the first object record. More than one header record is allowed (as a result of an
object bind, or if source arose from multiple files as a result of include processing).
NOTES:
The name string is always present; a null name is allowed but not recommended (not much information for
a debugger that way).
It is recommended that the module be generated with the full path and filename containing the source code.
The THEADR record must be the first record of the object module.
More than one header record is allowed (as a result of source from multiple files during the include process).
Description:
This record is very similar to the THEADR record. It is used to indicate the name of a module within a
library file (which has a different organization internally than an object module).
Record format:
NOTES:
Description:
The COMENT record contains a character string that may represent a plain text comment, a symbol mean-
ingful to a program such as LINK or LIB, or some binary coded information that alters the linking process.
The comment records are actually a group of items, classified by "comment class".
1 byte 2 byte
88 Record
Length
Comment Type
where
NP is set if the comment is to be preserved by object bind utilities
NL is set if the comment is not for display by object bind utilities
The comment class is an 8-bit numeric which conveys information by its value (accompanied by a null byte
string), or indicates the information to be found in the accompanying byte string. The byte string's length is
determined from the record length, not by an initial count byte.
01 Optional
Subclass 01 indicates the start of link pass 2 records; this may be followed by anything at all, which will
be ignored by the linker (determined from the RecLength). When this comment appears, the linker can
rest assured that only LEDATA, LIDATA, FIXUPP, LINNUM and the terminal MODEND records
will occur after this. All other record types, plus THREAD fix.ups, occur before.
WARNING: It is assumed that this comment will not be present in a module whose MODEND record
contains a program starting address.
A3 LIBMOD indicator
Library module comment record. Ignored by LINK386.
A4 EXESTR indicator
Executable Module Identification String
A commentary string specifying a string to be placed in the executable module, but which is not loaded
with the load module.
A6
INCERR
Incremental compilation error. See INCERR section for a complete description.
A7
NOPAD \
'
No segment padding. Ignored by LINK386.
AS WKEXT
Weak Extern record. See WKEXT section for a complete description.
A9 LZEXT
Lazy Extern record. Ignored by LINK386.
AA PHARLAP
PharLap Format record. Ignored by LINK386.
AF IDMDLL indicator
Identifier Manipulator Dynamic Link Library. See IDMDLL section for a complete description
B2H-Bm
Unused
COH-Fm
Reserved for user-defined comment classes.
Notes:
A COMENT record can appear almost anywhere in an object module. Only two restrictions apply:
• A COMENT record cannot be placed between a FIXUPP record and the LEDATA or LIDATA record
to which it refers.
• A COMENT record can not be the first or last record in an object module. (The first record must
always be a THEADR record and the last must always be a MODEND).
88H IMPDEF Import Definition Record (comment class AO, subtype 01)
Description:
Record format:
where:
01 identifies the subtype as an IMPDEF
OrdFlag is a byte; if zero the import is identified by name. If nonzero, it is identified by ordinal.
Determines the form of the Entryldent field.
InternalName in < count, char> string format and is the name used within this module for the
import symbol. This name will occur again in an EXTDEF record.
ModuleName in < count, char> string format and is the name of the module which supplies an
export symbol matching this import.
Entryldent is an ordinal or the name used by the exporting module for the symbol, depending upon
the OrdFlag.
If this field is an ordinal (OrdFlag nonzero), it is a 16-bit word. If this is a name, and the
first byte of the name is zero, then the exported name is the same as the import name (in
the IntemalName field). Otherwise, it is the imported name in <count, char> string
format (as exported by ModuleName ).
Notes:
IMPDEF records are created by the utility IMPLIB, which builds an "import library" from a module defi-
nition file or dynamic-link library.
88H EXPDEF Export Definition Record (comment class AO, subtype 02)
Description:
Record format:
<conditional>
where:
02 identifies the subtype as an EXPDEF
ExpFlag is a bit-significant 8-bit field.
OrdBit Set if the item is exported by ordinal; in this case the ExportOrdinal field is present.
ResName Set if the exported name is to be kept resident by the system loader; this is an opti-
mization for frequently used items imported by name.
NoData Set if the entry point does not use initialized data (either instanced or global).
ParmCount Number of parameter words. The ParmCount field is set to zero for all but
callgates to 16-bit segments.
Exported Name in <count, char> string format. Name to be used when the entry point is imported by
name.
Internal Name in <count, char> string format. If the name length is zero, the internal name is the same as
the Exported Name. Otherwise, it is the name by which the entry point known within this
module. This name will appear as a PUBDEF or LPUBDEF name.
ExportOrdinal present if the OrdBit is set; it is a 16-bit numeric whose value is the ordinal used (must be
non-zero).
Notes:
EXPDEFs are produced by the compiler when the keyword _export is used in a source file. LINK386 limits
the ExportOrdinal value to 16384(16K) or lower.
88H INCDEF Incremental Compilation Record (comment class AO, subtype 03)
Description:
This record is used for incremental compilation. Every FIXUPP and LINNUM record folliwing an
INCDEF record will adjust all external index values and line number values by the appropriate delta. The
deltas are cumulative if there is more than one INCDEF per module.
Record format:
1 2 2 <variable> (bytes)
Padding (zeros) is added by Quick C to allow for expansion of the object module during incremental compi-
lation and linking.
Notes:
Negative deltas are allowed.
Description:
This record is used by the compiler to pass directives and flags to the linker.
Record format:
1 1 1 1 (bytes)
8 1 1 1 1 1 1 1 1 (bits)
The low-order bit, if set, indicates that LINK386 should output the new EXE format; this flag is ignored for
all but linking of Pseudocode applications. (Pseudocode requires a segmented executable) .
The second low-order bit indicates that LINK386 should not output the $PUBLICS subsection of the
CodeView info.
The third low-order bit indicates that MPC (Microsoft Make Pseudocode Utility) should be run.
Pseudooode Version
One byte indicating the Pseudocode interpreter version number.
CodeView Version
One byte indicating the CodeView version number.
Notes:
The presence of this record in an object module will indicate the presence of global symbols records. The
linker will not emit a Publics section for those modules with this comment record and a $SYMBOLS
section.
Description:
The LIBMOD comment record is used only by the LIB utility, not by LINK. It gives the name of an object
module within a library, allowing LIB to preserve the library file name in the THEADR record and still
identify the module names that make up the library. Since the module names is the basename of the .OBJ
file that was built into the library, it may be completely'different from the final library name.
Record format:
1 <variable> (bytes)
A3 Module Name
The record contains only the ASCII string of the module name, in < coutn, char> format. The module
name has no path and no extension, just the base of the module name.
Notes:
LIB adds a LIBMOD record when a .OBJ file is added to a library and strips the LIBMOD record when a
.OBJ file is removed from a library, so typically this record only exists in .LIB files.
There will be one LIB MOD record in the library file for each object module that was combined to build the
library.
The EXESTR comment record implements the ANSI and XENIX/UNIX features in C:
• #pragma comment(exestr, <char-sequence>)
• #ident string
Record format:
1 <variable> (bytes)
A4 arbitrary text
The linker will copy the text in the Harbitrary text" field byte for byte to the end of the executable file. The
text will not be included in the program load image.
Notes:
If CodeView information is present, the text will not be at the end of the file, but somewhere before so as
not to interfere with the Code View signature.
Description:
This comment record will cause the linker to terminate with the fatal error saying something to the effect of
"inavlid object -- error encountered during incremental compilation".
The purpose of this is for the case when an incremental compilation fails and the user tries to manually link.
the object module cannot be deleted, in order to preserve the base for the next incremental compilation.
Record format:
1 (bytes)
A6 No fields
Description:
This comment record identifies a set of segments which are to be excluded from the padding imposed with
the /PADDATA or /PADCODE options.
Record format:
1 1 or 2 (bytes)
A7 SEGDEF Index
The SEGDEF Index is the standard OMF index type od 1 or 2 bytes. It may be repeated.
Notes:
Description:
This record marks a set of external names as "weak", and for every weak extern associates another external
name to use as the default resolution.
Record format:
1 1 or 2 1 or 2 (bytes)
The Weak EXTDEF Index field is the 1 or 2 byte index to the EXTDEF of the extern which is weak.
The Default Resolution EXTDEF Index is the 1 or 2 byte index to the EXTDEF of the extern that will be
used to resolve the extern if no "stronger" link is found to resolve it.
Notes:
There are two ways to cancel the "weakness" of a weak extern; both result in the extern becoming a "strong"
extern (the same as an EXTDEF). They are:
• if a PUBDEF for the weak extern is linked in,
• if an EXTDEF for the weak extern is found in another module (including libraries).
If the weak extern becomes strong, then it must be resolved with a matching PUB DEF, just like a regular
EXTDEF. If a weak exten has not become strong by the end of the linking process, then the default resol-
ution is used.
If two weak externs for the same symbol in different modules have differing default resolutions, LINK386
will emit a warning.
Weak externs do not query libraries for resolution; if an extern is still weak when libraries are searched, it
stays weak and gets the default resolution. However, if a library module is linked in for other reasons (say, to
resolve strong externs) and there are EXTDEFs for symbols that were weak, the symbols become strong.
For example, suppose there is a weak extern for 'Too" with a default resolution name of "bar". If there is a
PUBDEF for 'Too" in some library module which would not otherwise be linked in, then the library module
is not linked in, and any references to 'Too" are resolved to "bar". However, if the library module is linked in
for other reasons, for example to resolve references to a strong extern named "bletch", then ''foo" will be
resolved by the PUBDEF from the library, not to the default resolution "bar".
WKEXTs are best understood by explaining why they were added in the first place. The minimum BASIC
runtime library in the past consisted of a large amount of code which was always linked in, even for the
smallest program. Most of this code was never called directly by the user, but it was called indirectly from
other routines in other libraries, so it had to be linked in to resolve the external references.
For instance, the floating point library was linked in even if the user's program did not use floating point,
because the PRINT library routine contained calls to the floating point library for support to print floating
point numbers.
The solution was to make the function calls between the libraries into weak externals, with the default resol-
ution set to a small stub routine. If the user never used a language construct or feature that needed the
additional library support, then no strong extern would be generated by the compiler and the default resol-
ution (to the stub routine) would be used. However, if the user accessed the library's routines or used con-
structs that required the library's support, a strong extern would be generated by the compiler to cancel the
effect of the weak extern, and the library module would be linked in. This required that the compiler know a
lot about which libraries are needed for which constructs, but the resulting executable was much smaller.
Description:
This record marks a set of external names as '1azy", and for every lazy extern associates another external
name to use as the default resolution.
Record format:
1 1 or 2 1 or 2 (bytes)
The Lazy EXTDEF Index field is the 1 or 2 byte index to the EXTDEF of the extern which is weak.
The Default Resolution EXTDEF Index is the l or 2 byte index to the EXTDEF of the extern that will be
used to resolve the extern if no "stronger" link is found to resolve it.
Notes:
There are two ways to cancel the 'laziness" of a lazy extern; both result in the extern becoming a "strong"
extern (the same as an EXTDEF). They are:
• if a PUBDEF for the weak extern is linked in,
• if an EXTDEF for the weak extern is found in another module (including libraries).
If a lazy extern becomes strong, then it must be resolved with a matching PUB DEF, just like a regular
EXTDEF. If a lazy extern has not become strong by the end of the linking process, then the default resol-
ution is used.
If two weak externs for the same symbol in different modules have differing default resolutions, LINK will
emit a warning.
Unlike waek externs, lazy externs do not query libraries for resolution; if an extern is still lazy when libraries
are searched, it stays lazy and gets the default resolution.
Description:
This record provides the name and initialization pannameters of a DLL that will demangle the compiler
generated mangled names. The linker will use this DLL when displaying error messages.
Record format:
The Name Length byte gives the number of characters in the DLL Name; the DLL Name itself is ASCII.
The DLL Name is the name of the Identifier Manipulator Dynamic Link Library provided by the language.
This D LL is used to demangle an internal identifier when that identifier will be displayed in an error
message.
The Panns Length byte gives the number of characters in the Demangle lnit Parameters; the Demangle lnit
Parameters itself is ASCII.
The Demangle Init Parameters provides information (to the DLL) on how internal identifiers are mangled.
The linker will not scan forward for an IDMDLL record when an identifier will be displayed. This record
should occur near the beginning of the file.
IDMDLL class COMENT records are processed during pass 1 of the linker.
Notes:
Because object oriented compilers allow for two functions to have the same name but clifferent parameters,
the compiler uniquely identifies each function by changing the name of the function. This is known as
mangling. An example of this would be:
The user will usually not be aware that the compiler changed the name, so it is neccessary for the linker to
demangle the compiler generated name when printing out linker error messages.
The dynamic link library (DLL) provided by an object oriented language compiler must contain two 16-bit
functions which employ the pascal calling convention:
INITDEMANGLEID Receive initialization parameters specified in the IDMDLL COMENT record.
DEMANGLEID Demangles first parameter (identifier, "_add_i_ii") to appropriate prototype (i.e. "int
add(int, int)") and returns result in second parameter.
The INITDEMANGLEID and DEMANGLEID entry points may be called more than once.
All functions must return true (non-zero) if the call is successful and false (zero) if the call fails. In this
manner the linker can ignore whatever is returned in the second parameter of the DEMANGLEID fuction if
the function returns false. When calling DEMANGLEID, the linker will pass in the address of a buffer for
the second parameter, and the size of the buffer for the third parameter.
All string parameters must be length-prefixed ASCII strings except for pszPrototype, parameter 2 for
DEMANGLEID (because the length might not fit in a byte). Function prototypes for these routines look
like:
unsigned short pascal far INITDEMANGLEID(char far* psinitParms);
Description:
The OMF extension designed by PharLap is called "Easy OMF-386" and changes to the affected record
types are described in this section.
Most modifications involve only a substitution of 32-bit (4-byte) fields for what were formerly 16-bit (2-byte)
fields. In the two cases where the changes involve more than just a field size (in the SEGDEF and FIXUPP
records), the information is mentioned in this section but complete details are given in the sections describing
the specific records.
Record format:
AA 11 80386 11
Notes:
The AA comment record should come immediately after the sole THEADR record. Presence of the
comment record indicates that the following other record types have fields that are expanded from 16-bit to
32-bit values:
SEGDEF offset field and offset field length
PUBDEF offset field
LEDATA offset field
LIDATA offset field (note that repeat count field is still 16 bits)
FIXUPP target displacement in explicit FIXUP subrecord
BLKDEF return address offset field
LINNUM offset field
MODEND target displacement field
FIXUPP records have the added Loe values of 5 and 6. See the FIXUPP section of this document for
details.
SEGDEF records have added alignment values (for 4-byte alignment and 4K byte alignment) and an added
optional byte at the end which contains the Usel6/Use32 bit flag and access attributes (read/write/execute)
for the segment. See the SEGDEF section of this document for details.
Description:
The MODEND record denotes the end of the object module. It also indicates whether the object module
contains a main routine in a program, and it can, optionally, contain a reference to a programs entry point.
Record format:
1 byte 2 bytes
BA Record
or BB Length
where:
Module Type
MATTR
Main Strt I ::: I , I , I , I , I x I
2 bits 1 1 1 1 1 1
where:
MATIR is a 2-bit field
Main is set if the module is a main module
Strt is set if the module contains a start address; if this bit is set, the field starting with
the EndDat byte is present and specifies the start address.
SegBit Reserved. Only 0 is supported by OS/2.
x This bit should be set (as described for OMF86). However, as is the case for the
OMF86 linkers, the value will be ignored.
Start Address
The Start Address subfield is present only if the Strt bit in the Module Type byte is set. Its format is iden-
tical to the FixDat, Frame Datum, Target Datum, and Target displacement in a FIXUP subrecord of a
FIXUPP record. The displacement (if present) is a 4 byte field if the record type is 8BH and is a 2-byte field
if the record type is 8AH. This value provides the initial contents of CS:(E)IP.
The start address must be given in th MODEND record of the root module if overlays are used.
Notes:
A MODEND record can appear only as the last record in an object module.
It is assumed that the link pass separator comment record (COMENT A2, subtype 01) will not be present in
a module whose MODEND record contains a program starting address.
Description:
The EXTDEF record contains a list of symbolic external references -- that is, references to symbols defined
in other object modules. The linker resolves external references by matching the symbols declared in
EXTDEF records with symbols declared in PUBDEF records.
Record format:
1 byte 2 bytes
BC Record
Length
<-------- repeated
\
--------->
Figure 18. EXTDEF external names definition record
This record provides a list of unresolved references, identified by name and with optional associated type
information. The external names are ordered by occurrence jointly with the COMDEF and LEXTDEF
records and referenced by an index in other records (FIXUPPs); the name may not be null. Indices start
from one.
String Length is a 1-byte field containing the length of the name field that follows it. The length of the name
is restricted to 255 bytes.
The Type Index is encoded as an index field and contains debug information. No type checking is per-
formed by the linker.
Notes:
Any EXTDEF records in an object module must appear before the FIXUPP records that reference them.
Resolution of an external reference is by name match (case sensitive) and symbol type match. The search
first looks for a matching name, in the sequence:
1. Searches PUBDEF and COMDEF for resolution.
2. If linking a segmented executable, searches imported names (IMPDEF).
3. If this is not a DLL, then searches for an export (EXPDEF) with the same name -- a self-
imported alias.
4. Searches for the symbol name among undefined symbols. If the reference is to a weak extern, then
the default resolution is used. If the reference is to a strong extern, then it's an undefined external
and a link error is generated.
All external references must be resolved at link time (using the above search order). Even though the linker
produces an executable file for and unsuccessful link session, an error bit is set in the header which prevents
the loader from running the executable.
Description:
The PUBDEF record contains a list of public names. It makes items defined in this object module available
to satisfy external references in other modules with which it is bound or linked.
The symbols are also available for export if so indicated in an EXPDEF comment record.
Record format:
1 byte 2 bytes
98 Record
or Length
91
The base group and segment are indices specifying previously defined SEGDEF and GRPDEF records. The
group index may be zero, meaning that no group is associated with this PUBDEF record.
The Base Frame field is present only if the Base Segment is zero, but the content of the Base Frame is
always ignored by the linker.
The Base Frame is normally used for absolute addressing when the Group and Segment Index are both zero.
Absolute addressing is not fully supported in the linker.
The public name string is in <count, char> form and cannot be null. The maximum length of a public
name is 255 bytes.
The public offset is a 2 or 4 byte numeric field containing the offset of the location referred to by the public
name. This offset is assumed to lie within the segment, group or frame specified in the public base field.
The Type Index field is encoded in index format; it contains either debug type information or zero. This
field is ignored by the OS/2 2.0 linker.
NOTES:
All defined functions and initialized global variables generate PUBDEF records.
Any PUBDEF records in an object module must appear after the GRPDEF and SEGDEF records to which
they refer.
The IBM C Compiler will generate PUBDEF records for all defined functions and initialized global vari-
ables. Globals for scalars that are initialized to zero produce COMDEF records.
Record type 90H uses 16-bit encoding of the Public Offset, but it is zero-extended to 32 bits if applied to
Use32 segments.
Description:
The LINNUM record relates line number within language source statements to addresses in the object code.
Record format:
1 byte 2 bytes
94 Record
or Length
95
1 or 2 1 or 2 <variable> 1 byte
Associates a source line number with translated code or data. The LINNUM record is only generated when
the debug option is selected and is therefore specific to the debug information. Refer to the specific debug
documentation for more information.
Description:
The LNAMES record is a list of names that can be referenced by subsequent SEGDEF and GRPDEF
records in the object module.
The names are ordered by occurrence and referenced by index from subsequent records. More than one
LNAMES record may appear. The names themselves are used as segment, class and group names.
1 byte 2 bytes
96 Record
Length
Each name appears in count/char format, and a null name is valid. The character set is ASCII.
NOTES:
The linker imposes a limit of 255 logical names per object module.
Any LNAMES records in an object module must appear before the records that refer to them. Because it
does not refer to any other type of object record, an LNAMES record usually appears near the start of an
object module.
Description:
The SEGDEF record describes a logical segment in an object module. It defines the segment's name, length
and alignment, as well as the way the segment can be combined with other logical segments at bind, link and
load time.
Object records that follow the SEGDEF record can refer to it to identify a particular segment. The
SEGDEF records are ordered by occurrence and are referenced by segment indexes (origin 1) in subsequent
records.
Record format:
1 byte 2 bytes
98 Record
or Length
gg
Segment Attributes
<-3 bits-> <-3 bits-> <-1 bit -> <-1 bit -> 2 bytes 1 byte
A c B p Frame Offset
Number
<cond> <cond>
C combination, a 3-bit field, which determines the way the program segment is mapped into a logical
segment. Values are:
0 private, do not combine with any other program segment
1 reserved
2 public, combine by appending at an offset which meets the alignment requirement
3 reserved
4 same as C = 2 (public)
5 stack, combine as for C = 2.
6 common, combine by overlay using maximum size
7 same as C = 2 (public)
B big, used as the high order bit of the segment length field. If this bit is set the segment length value
must be zero and the segment's size is 2e32 or 4Gbytes long.
P Holds the descriptor table B/D bit value (this is the descriptor table D bit for code segments and the B
bit for data segments).
If zero, then segment is no larger than 64K (if data) and 16-bit addressing and operands are the default
(if code). This is a Use16 segment.
If not zero, then the segment is no larger than 64k (if data) and 32-bit addressing and operands are the
default (if code). This is~ Use32 segment.
Note that this is the only method for defining Use32 segments.
Segment Length
The Segment Length is a 2 or 4 byte numeric quantity and specifies the number of bytes in this program
segment.
NOTE For record type 98H, the length can be from 0 to 64K; if a segment is exactly 64KB in size, segemtn
length should be 0 and the B field in the ACPB byte should be 1. For record type 99H, the length can be
from 0 to 4G; If segment is exactly 4Gbytes in size, segment length should be set to zero and the B field in
the ACBP byte should be set to 1.
The three name indices refer to names that appeared in previous LNAMES record(s). The linker ignores the
overlay name index. The full name of a segment consists of the segment and class names. Segments in
different object modules are normally combined according to the A and C values if their full names are iden-
tical. These indices must be nonzero, although the name itself may be null.
The segment name index identifies the segment with a name. the name need not be unique -- other seg-
ments of the same name will be concatenated onto the first segment with that name. The name may have
been assigned by the programmer, or it may have been generated by the compiler.
The class name index identifies the segment with a class name (such as CODE, DATA or STACK). The
linker places segments with the same class name into a contiguous area of memory in the run-time memory
map.
Notes:
The linker imposes a limit of 255 SEGDEF records per object module.
Description:
The GRPDEF record causes the program segments defined by SEGDEF records to be collected together
(grouped). For OS/2 2.0, the segments are combined into a logical segment which is to be addressed
through a single selector for flat memory.
Record format:
This record causes the program segments identified by SEGDEF records to be collected together (grouped)
within a logical segment which is to be addressed through a single selector.
Group Name
The group name is specified as an index into a previously defined LNAMES name and must be nonzero.
Groups from different object modules are coalesced if their names are identical.
Group Components
The group's components are segments, specified as indices into previously defined SEGDEF records.
The first byte of each group component is a type field for the remainder of the component. The linker
requires a type value of FFH and always assumes that the component contains a segment index value.
The component fields are usually repeated so that all segments constituting a group can be included in one
GRPDEF record.
Notes:
The linker imposes a limit of 31 GRPDEF records in a single object module and limits the total number of
group definitions across all object modules to 31.
An example of a group for the IBM C Compiler is DGROUP32 which groups DATA32, CONST32 and
BSS32.
The linker does special handling of the pseudo-group FLAT. All address references to this group are made
as offsets from the virtual zero address, which is the start of the memory image of the executable.
Description:
The FIXUPP record contains information that allows the linker to resolve (fix up) and eventually relocate
references between object modules. FIXUPP records describe the LOCATION of each address value to be
fixed up, the TAR GET address to which the fixup refers and the FRAME relative to which the address
computation is performed.
Record format:
Record type 9DH is new for LINK386; it has a Target Displacement field of 32 bits rather than 16 bits, and
the LOC field of the LOCAT word has been extended to $ bits (using the previously unused higher-order 'S'
bit) to allow new LOC values of 9, 11 and 13.
Each subrecord in a FIXUPP object record either defines a thread for subsequent use, or refers to a data
location in the nearest previous LEDATA or LIDATA record. The high order bit of the subrecord deter-
mines the subrecord type: if the high order bit is 0, the subrecord is a THREAD subrecord; if the high
order bit is 1, the subrecord is a FIXUP subrecord. Subrecords of different types may be mixed within one
object record.
Information that determines how to resolve a reference can be specified explicitly in a FIXUP subrecord, or
can be specified within a FIXUP subrecord by a reference to a previous THREAD subrecord. A THREAD
subrecord describes only the method to be used by the linker to refer to a particular target or frame.
Because the same THREAD can be referenced in several subsequent FIXUP subrecords, a FIXUPP object
record that uses THREADs may be smaller than one in which THREADs are not used.
THREAD subrecords can be referenced in the same object record in which they appear and also in subse-
quent FIXUPP object records.
THREAD
There are 4 frame threads and 4 target threads; not all need be defined and they can be redefined by later
THREAD subrecords in the same or later FIXUPP object records. The frame threads are used to specify
the Frame Datum field in a later FIXUP subrecord: the target threads are used to specify the Target Datum
field in a later FIXUP subrecord.
A THREAD subrecord defines a thread, and does not require that a previous LEDATA or LIDATA record
occur.
where:
0 The high order bit is zero to indicate that this is a THREAD subrecord.
D is 0 for a target thread, 1 for a frame thread
METHOD is a 3-bit field.
For target threads, only the lower two bits of the field are used; the high-order bit of the method
is derived from the P bit in the FixDat field of the FIXUP subrecords that refer to this thread.
The full list of methods is given here for completeness. This field determines the kind of index
required to specify the Target Datum.
TO specified by a SEGDEF index
Tl specified by a GRPDEF index
T2 specified by a EXTDEF index
T3 specified by an explicit frame number (not supported by the linker)
T4 specified by a SEGDEF index only; the displacement in the FIXUP subrecord is assumed to
be 0.
T5 specified by a GRPDEF index only; the displacement in the FIXUP subrecord is assumed
to be 0.
T6 specified by a EXTDEF index only; the displacement in the FIXUP subrecord is assumed
to be 0.
The index type specified by the target thread method is encoded in the index field.
For frame threads, the method field determines the Frame Datum field of subsequent FIXUP
subrecords that refer to this thread. Values for the method field are:
FO the FRAME is specified by a SEGDEF index
Ft the FRAME is specified by a GRPDEF index
F2 the FRAME is specified by a EXTDEF index. The linker determines the FRAME from
the external name's corresponding PUBDEF record in another object module, which speci-
fies either a logical segment or a group.
F3 invalid (The FRAME is identified by an explicit frame number; this is not supported by the
linker)
F4 the FRAME is determined by the segment index of the previous LEDATA or LIDATA
record (ie the segment in which the location is defined).
F5 the FRAME is determined by the TARGET's segment, group or external index
F6 invalid
The index field is present for frame methods FO, Fl, and F2 only.
THRED is a 2-bit field and determines the thread number (0 through 3, for the 4 threads of each kind).
Index is a conditional field that contains an index value that refers to a previous SEGDEF, GRPDEF
or EXTDEF record. The field is only present if the thread method is 0, 1 or 2. If method 3
were supported by the linker, the Index field would contain an explicit frame number.
FIXUP
A FIXUP subrecord gives the how/what/why/where/who information required to convert a reference when
program segments are combined or placed within logical segments. It applies to the nearest previous
LEDATA or LIDATA record, which must be defined before the FIXUP. This FIXUP subrecord is as
follows:
where the LOCAT field has an unusual format. Contrary to the usual byte order in Intel data structures, the
most significant bits of the LOCAT field are found in the low-order, rather than the high-order byte.
where:
1 the high bit of the low-order byte is set to indicate a FIX UP subrecord.
M is the mode, M = 1 for segment-relative and M = 0 for self-relative fixups
LOC is a 4-bit field which determines what type of location is to be fixed up:
0 Low-order byte (8-bit displacement or low byte of 16-bit offset)
1 16-bit Offset
2 16-bit Base - logical segment base (selector)
3 32-bit Long pointer (16-bit base : 16-bit offset)
4 Hi-order byte (high byte of 16-bit offset) No linker support for this type.
5 16-bit loader-resolved offset, treated as LOC = 1 by the linker
CONFLICT PharLap OMF uses LOC = 5 to indicate a 32-bit offset, where Microsoft and IBM
use LOC=9.
6 not defined, reserved
CONFLICT PharLap OMF uses LOC= 6 to indicate a 48-bit pointer (16-bit base : 32-bit offset)
where Microsoft and IBM use LOC = 11.
7 not defined, reserved
9 32-bit offset
11 48-bit pointer (16-bit base: 32-bit offset)
13 32-bit loader-resolved offset, treated as LOC = 9 by the linker
Data Record Offset The Data record offset indicates the position of the location to be fixed up in the
LEDATA or LIDATA record immediatly preceding the FIXUPP record. This offset indicates either a
byte in the data field of an LEDATA record or a data byte in the content field of an iterated data block
in an LIDATA record.
I I F ~RAM~ I TI p ITAR~T
1 3 1 1 2 (bits)
Notes:
FIXUPP records are used to fix references in the immediately preceding LEDATA, LIDATA or COMDAT
record.
The FRAME is the translator's way of telling the linker the contents of the segment register used for the
reference; the TARGET is the item being referenced whose address was not completely resolved by the
translator. In protect mode, the only legal segment register value are selectors; every segment and group of
segments is mapped through some selector and addressed by offset within the underlying memory defined by
that selector.
Description:
This record provides contiguous binary data -- executable code or program data -- which is part of a
program segment. The data is eventually copied into the program's executable binary image by the linker.
The data bytes may be subject to relocation or fix-up as determined by the presence of a subsequent
FIXUPP record but otherwise requires no expansion when mapped to memory at run time.
Record Format:
1 byte 2 bytes
A0 Record
or Length
Al
Record type AlH is new for LINK386; it has an Enumerated Data Offset field of 32 bits rather than 16 bits.
Segment Index
The Seglndex must be nonzero and is the index of a previously defined SEGDEF record. This is the
segment into which the data in this LEDATA record is to be placed.
The enumerated data offset is a 2 or 4 byte field (depending on the record type) which determines the offset
at which the first data byte is to be placed relative to the start of the SEGDEF segment. Successive data
bytes occupy successively higher locations.
Data Bytes
The maximum number of data bytes is 1024, so that a FIXUPP location field, which is 10 bits, can refer-
ence any of these data bytes. The number of data bytes is computed as the RecLength minus 5 minus the
size of the Seglndex field ( 1 or 2 bytes).
NOTES:
Record type AlH has offset stored as a 32-bit numeric. Record type AO encodes the offset value as a 16-bit
numeric (zero extended if applied to a Use32 segment).
If the LEDATA requires fix.up, a FIXUPP record must immediately follow the LEDATA record.
Description:
Like the LEDATA record, the LIDATA record contains binary data -- executable code or program data.
The data in an LIDATA record, however, is specified as a repeating pattern (iterated), rather than by explicit
enumeration.
The data in an LIDATA record may be modified by the linker if the LIDATA record is immediately fol-
lowed by a FIXUPP record.
Record format:
1 byte 2 bytes
AZ Record
or Length
A3
Record type A3H is new for LINK386; it has Iterated Data Offset and Repeat Count fields of 32 bits rather
than 16 bits.
The segment index and data offset (2 or 4 bytes) are the same as for an LEDATA record. The index must
be nonzero.
Data Block
Repeat Count
The Repeat Count is a 16-bit or 32-bit value which determines the number of repeats of the content field.
The Repeat Count is 32 bits only if the record type is A3.
CONFLICT:The PharLap OMF uses a 16-bit repeat count even in 32-bit records.
Block Count
The Block Count is a 16-bit word whose value determines the interpretation of the content portion, as
follows:
0 indicates that the content field that follows is a one byte "count" value followed by "count" data
bytes. The data bytes will be mapped to memory, repeated Repeat Count times.
! = 0 indicates the content field that follows is comprised of one or more Data Blocks. The Block
Count value specifies the number of Data Blocks (recursive definition).
Notes:
A subsequent FIXUPP record may occur; the fixup is applied before the iterated data block is expanded. It
is a translator error for a fixup to reference any of the count fields.
The size of such a variable the the maximum size defined in any module naming the variable as communal
or public. The placement of communal variables is determined by the data type using established con-
ventions (see data type and communal length below).
Record format:
1 byte 2 bytes
B0 Record
Length
Communal name
The name is in <count, char> string format (and name may be null). Near and Far communals from
different object files are matched at bind or link time if their names agree; the variable's size is the maximum
of the sizes specified (subject to some constraints, as documented below).
Type Index
Encodes symbol information; it is parsed as an index field (one or 2 bytes), and not inspected by the linker.
The data type field indicates the contents of the Communal Length field. All Data type values for Near data
indicate that the Communal Length field has only one numeric value: the amount of memory to be allocated
for the communal variable. All Data Type values for Far data indicate that the Communal Length field has
two numeric values: the first is the number of elements and the second is the element size.
The communal length is a single numeric or a pair of numeric fields (as specified by the Data Type),
encoded as follows:
1 byte value 0 through 128 (80 hex)
3 byte byte 81 hex, followed by a 16-bit word whose value is used (range 0 to 64K-l)
4 byte byte 84 hex, followed by a 3 byte value (range 0 to 16M-1)
5 byte byte 88 hex, followed by a 4 byte value (range -2G-1 to 2G-l, signed)
Groups of name, type index, segment type and communal length fields can be repeated so that more than
one communal variable can be declared in the same COMDEF record.
Notes:
If a public or exported symbol with the same name is found in another module with which this is bound or
linked, the linker gives a multiple defined symbol error message,
The records are ordered by occurrence, together with the items named in EXTDEF records (for reference in
FIX UPS).
The IBM C Compiler generates COMDEF's for all uninitialized global data and for global scalars initialized
to zero.
Record format:
1 2 1 or 2 1 2 or 4 2 or 4 1 (bytes)
82 or Record Seg Loe Offset Value Chk
83 Length Index Type Sum
Seglndex
Segment index to which all "backpatch" fixupps are to be applied. Note that, in contrast to
FIXUPs, these records need not follow the data record to be fixed up. Hence, the segment to
which the backpat'ch apllies must be specified explicitly.
LocTyp
Type of location to be patched; the only valid values are:
0 8-bit lobyte
1 16-bit offset
9 32-bit offset, record type B3 only
Offset and value
These fields are 32-bits for record type B3, 16-bit for B2.
The Offset specifies the loaction to be patched (as an offset into the segdef whose index is
Seglndex).
The associated Value is added to the location being patched (unsigned addition, ignoring over-
flow). The Value field is fixed length (16-bit or 32-bit, depending on the record type) to make
object module processing easier.
Notes:
BAKPAT records can occur anywhere in the object module following the SEGDEF record to which they
refer. They do not have to immediately follow the appropriate LEDATA record as FIXUPP record do.
These records are buffered by the linker in Pass 2 until the end of the module, after applying all other
FIXUPPs. The linker then processes the records as fixups.
Description:
This record is identical in form to the EXTDEF record described earlier. However, the symbols named in
this record are not visible outside the module in which they are defined.
Record format:
Notes:
These records are associated with LPUBDEF and LCOMDEF records, ordered with the EXTDEF records
by occurence, so that they may be referenced by external index for ftxups.
The name string, when stored in LINK's internal data structures, is encoded with spaces and digits at the
beginning of the name.
Description:
This record is identical in form to the PUBDEF record described earlier. However, the symbols named in
this record are not visible outside the module in which. they are defined.
Record format:
Description:
This record is identical in form to the COMDEF record described earlier. However, the symbols named in
this record are not visible outside the module in which they are defined.
Record format:
Description:
The purpose of the COMDAT record is to combine logical blocks of code and data which may be dupli-
cated across a number of compiled modules.
Record format:
1 2
C2 or Record
C3 Length
Flags Attr. Align Enum Data Type Public Public DAT Chk.
Offset Index Base Name Sum
<repeat>
Figure 32. COMDAT initialized communal data record
Flags
O/H - Continuation bit. If clear, then this COMDAT record establishes a new instance of the COMDAT
variable, otherwise the data is a continuation of the previous CO MDAT of the symbol.
02H - Iterated data bit. If clear, the Oat field contains enumerated data, otherwise the Oat field contains
iterated data, as in an LIDATA record.
Attr
This field contains two 4-bit fields: the selection criteria to be used, the allocation type and the ordinal
specifying the type of allocation to be performed. Values are:
20H - Same size - pick any, but instances must have the same length or linker will generate an error.
30H - Exact Match - pick any, but checksums of instances must match of linker will generate an error.
Fixups are ignored.
OOH - Explicit - allocate in the segment specified in the ensuing public base field.
OIH - Far Code - allocate as CODE16. The linker will create segments to contain all COMDAT's of this
type.
02H - Far DATA - allocate as DATA16. The linker will create segments to contain all COMDAT's of this
type.
03H - CODE32 - allocate as CODE32. The linker will create segments to contain all CO MD A T's of this
type.
04H - DATA32 - allocate as DAT A32. The linker will create segments to contain all COMDAT's of this
type.
Align
These codes are based on the ones used by the SEGDEF record:
I - byte aligned.
4 - 4K page aligned.
6 - not defined.
7 - not defined.
This field specifies an offset relative to the beginning location of the symbol specified in the public name field
and defines the relative location of the first byte of the DAT field. Successive data bytes in the DAT field
occupy higher locations of memory. This works very much like the offset field in an LEDATA record, but
instead of an offset relative to a segment, this is relative to the beginning of the COMDAT symbol.
Type Index
The type index field is encoded in index format; it contains either debug type information or an old-style
TYPDEF index. If this index is zero, there is no associated type data. Old-style TYPDEF indices are
ignored by the linker. Present linkers do no type checking.
Public Base
This field is conditional and is identical to the public base stored in the public base field in the PUBDEF
record. This field is only present if the allocation type field specifies explicit allocation.
Public Name
Oat
The Dat field provides up to 1024 consecutive bytes of data. If there are fixups, they must be emitted in a
FIXUPP record that follows the COMDAT record. The data can be either enumerated or iterated,
depending on the flags field.
Notes:
While creating addressing frames, the linker will add the COMDAT data to the appropriate logical segments,
adjusting their sizes. At that time the offset at which the data will go inside the logical segment will be
calculated. Next, the linker \\'ill create physical segments from adjusted logical segments reporting any 64K
boundary overflows. '
If the allocation type is not explicit, COMDAT code and data is accumulated by the linker and broken up
into segments, so that the total may exceed 64K.
In pass two, only the selected occurrence of COMDAT data will be stored in the VM, fixed up and later
written into the .EXE file.
Description:
This record will be used to output numbers for functions specified via COMDATs.
Record format:
1 2 1 <variable> 2 2or4 1
Flags
OlH Continuation bit. If clear, then this COMDAT record establishes a new instance of the
COMDAT variable, otherwise the data is a continuation of the previous COMDAT of the
symbol.
04H Local COMDAT
The Symbol Name Base is a length-preceded name of the base of the LINSYM record.
The Line Number Offset field is the offset relative to tha base specified by the symbol name base. The size of
this field depends on the record type.
Notes:
Record type C5H identical to C4H except that the Line Number Offset field is 4 bytes instead of 2.
Thie record is used to output line numbers for functions specified via COMDATs. Often, the residing
segment as well as the relative offsets of such function is unknown at compile time, in that the linker is the
final arbitrator of such information. For such cases the compiler will generate this record to specify the line
number/offset pairs relative to a symbolic name.
Thie record will also be used to discard duplicate linnum information. If the linker encounters two LINSYM
records with matching symbolic names, the linker will keep the first set of linnums and discard all subse-
quent LINSYM records of that name.
Description:
This record has been introduced to support link-time aliasing, or a method by which compilers or assembles
may direct the linker to substitute all references to one symbol for another.
Record format:
The Alias Name field is a regular length-preceded name of the alias symbol.
The Substitute Name field is a regular length-preceded name of the substitute symbol.
Notes:
The record will consist of two symbolic names: the alias symbol and the substitute symbol. The alias symbol
behaves very much like a PUBDEF in that it must be unique. If a PUBDEF of an alias symbol is encount-
ered or another ALIAS record with a different substitute symbol is encountered, a redefinition error should
be emitted by the linker.
When attempting to satisfy an external reference, if an ALIAS record whose alias symbol matches is found,
the linker will halt the search for alias symbol definitions and will attempt to satisfy the reference with the
substitute symbol.
All ALIAS records must appear before the link pass 2 record.
Description:
The Named Backpatch record is like a BAKPAT record, except that it refers to a COMDAT, by name,
rather than an LIDATA or LEDATA record.
Record format:
1 2 1 <var> 2 or 4 2 or 4 1 (bytes)
LocType
Public Name
These fields are 16-bits for record type C8, 32-bits for C9.
The Offset specifies the location to be patched, as an offset into the COMDAT.
The associated Value is added to the location being patched (unsigned addition, ignoring over-
flow). The Value field is fixed length (16-bit or 32-bit, depending on the record type) to make
object module processing easier.
Revision codes:
revision 1 - Library termination.
revision 2 - Sector Align and Exepack support.
revision 3 - Address Based linking.
revision 4 - OS/2 2.0 PM Debugger (IBM) support.
00h <
DOS 2 Compatible
EXE Header
lCh
unused
xxh <
Executable
Info
Module
Info
Linear Executable
Loader Section Module Header
Info (Resident)
Table Offset
Info
<
<
Object Table
Resource Table
Resident Name
Table
Loader Section
Entry Table (Resident)
Module Format
Directives Table
(Optional)
Resident
Directives Data
(Optional)
(Verify Record)
Per-Page
Checksum
<
<
Fixup Page Table
Fixup Record
Table
Fixup Section
Import Module (Optionally Resident)
Name Table
Import Procedure
Name Table
<
<
Pre load Pages
Demand Load
Pages
Iterated Pages
Non-Resident (Non-Resident)
Name Table
Non-Resident
Directives Data
(Optional)
(To be Defined)
<
LX Header
Note: The OBJECT ITER PAGES OFF must either be 0 or set to the same value as DATA
PAGES OFFSET in OS/2 2.0. le., iterated pages are required to be in the same section of the
file as regular pages.
Note: Table offsets in the Linear EXE Header may be set to zero to indicate that the table does
not exist in the EXE file and it's size is zero.
The signature word is used by the loader to identify the EXE file as a valid 32-bit Linear
Executable Module Format. "L" is low order byte. "X" is high order byte.
B-ORD = DB Byte Ordering.
This byte specifies the byte ordering for the linear EXE format. The values are:
OOH - Little Endian Byte Ordering.
01 H - Big Endian Byte Ordering.
W-ORD = DB Word Ordering.
This byte specifies the Word ordering for the linear EXE format. The values are:
OOH - Little Endian Word Ordering.
01 H - Big Endian Word Ordering.
Format Level = DD Linear EXE Format Level.
The Linear EXE Format Level is set to 0 for the initial version of the 32-bit linear EXE
format. Each incompatible change to the linear EXE format must increment this value.
This allows the system to recognized future EXE file versions so that an appropriate
error message may be displayed if an attempt is made to load them.
CPU Type = DW Module CPU Type.
This field specifies the type of CPU required by this module to run. The values are:
OlH - 80286 or upwardly compatible CPU is required to execute this module.
02H - 80386 or upwardly compatible CPU is required to execute this module.
03H - 80486 or upwardly compatible CPU is required to execute this module.
OS Type = DW Module OS Type.
This field specifies the type of Operating system required to run this module. The cur-
rently defined values are:
OOH - Unknown (any "new-format OS) 11
The Entry Address is the starting address for program modules and the library initializa-
tion and Library termination address for library modules.
ESP OBJECT# = DD The Object number to which the ESP is relative.
This specifies the object to which the starting ESP is relative. This must be a nonzero
value for a program module to be correctly loaded. This field is ignored for a library
module.
ESP = DD Starting stack address of module.
The ESP defines the starting stack pointer address for program modules. A zero value in
this field indicates that the stack pointer is to be initialized to the highest address/offset in
the object. This field is ignored for a library module.
PAGE SIZE = DD The size of one page for this system.
This field specifies the page size used by the linear EXE format and the system. For the
initial version of this linear EXE format the page size is 4Kbytes. (The 4K page size is
specified by a value of 4096 in this field.)
PAGE OFFSET SHIFT = DD The shift left bits for page offsets.
This field gives the number of bit positions to shift left when interpreting the Object
Page Table entries' page offset field. This determines the alignment of the page informa-
tion in the file. For example, a value of 4 in this field would align all pages in the Data
Pages and Iterated Pages sections on 16 byte (paragraph) boundaries. A Page Offset
Shift of 9 would align all pages on a 512 byte (disk sector) basis. All other offsets are
byte aligned.
A page might not start at the next available alignment boundary. Extra padding is
acceptable between pages as long as each page starts on an alignment boundary. For
example, several alignment boundarys may be skipped in order to start a frequently
accessed page on a sector boundary.
FIXUP SECTION SIZE = DD Total size of the fixup information in bytes.
This includes the following 4 tables:
- Fixup Page Table
- Fixup Record Table
- Import Module name Table
- Import Procedure Name Table
FIXUP SECTION CHECKSUM = DD Checksum for fixup information.
This is a cryptographic checksum covering all of the fixup information. The checksum
for the fixup information is kept separate because the fixup data is not always loaded
into main memory with the 1oader section'. If the checksum feature is not implemented,
then the linker will set these fields to zero.
LOADER SECTION SIZE = DD Size of memory resident tables.
This is the total size in bytes of the tables required to be memory resident for the
module, while the module is in use. This total size includes all tables from the Object
Table down to and including the Per-Page Checksum Table.
LOADER SECTION CHECKSUM = DD Checksum for loader section.
This is a cryptographic checksum covering all of the loader section information. If the
checksum feature is not implemented, then the linker will set these fields to zero.
OBJECT TABLE OFF = DD Object Table offset.
NON-RES NAME TBL LEN = DD Number of bytes in the Non-resident name table.
Note: Earlier versions of this doc stated that this offset was from the linear EXE header -
this is incorrect.
DEBUG INFO LEN = DD Debug Information length.
The length of the debug information in bytes.
# INSTANCE PRELOAD = DD Instance pages in preload section.
The number of instance data pages found in the preload section.
# INSTANCE DEMAND = DD Instance pages in demand section.
The number of instance data pages found in the demand section.
HEAPSIZE = DD Heap size added to the Auto DS Object.
The heap size is the number of bytes added to the Auto Data Segment by the loader.
This field is supported for 16-bit compatibility only and is not used by 32-bit modules.
STACKSIZE = DD Stack size.
The stack size is the number of bytes specified by:
1. size of a segment with combine type stack
2. STACKSIZE in the .DEF file
3. /STACK link option
The stacksize may be zero.
Note: Stack sizes with byte 2 equal to 02 or 04 (e.g. 00020000h, 1104111 lh,
0f02ffilh) should be avoided for programs that will run on OS/2 2.0.
EAX = EBX = 0.
ECX = EDX = 0.
ESI = EDI = 0.
EBP = 0.
BAX= EBX = 0.
ECX = EDX = 0.
ESI =EDI= 0.
EBP = 0.
Object Table
The number of entries in the Object Table is given by the # Objects in Module field in the linear
EXE header. Entries in the Object Table are numbered starting from one.
The object table entries are ordered by logical page in the object table. In other words
the object table entries are sorted based on the object page table index value.
#PAGE TABLE ENTRIES = DD #of object page table entries for this object.
Any logical pages at the end of an object that do not have an entry in the object page
table associated with them are handled as zero filled or invalid pages by the loader.
When the last logical pages of an object are not specified with an object page table entry,
they are treated as either zero filled pages or invalid pages based on the last entry in the
object page table for that object. If the last entry was neither a zero filled or invalid
page, then the additional pages are treated as zero filled pages.
RESERVED = DD Reserved for future use. Must be set to zero.
63 32 31 16 15 0
PAGE DATA OFFSET = DD Offset to the page data in the EXE file.
This field, when bit shifted left by the PAGE OFFSET SHIFT from the module header,
specifies the offset from the beginning of the Preload Page section of the physical page
data in the EXE file that corresponds to this logical page entry. The page data may
reside in the Preload Pages, Demand Load Pages or the Iterated Data Pages sections.
A page might not start at the next available alignment boundary. Extra padding is
acceptable between pages as long as each page starts on an alignment boundary. For
example, several alignment boundarys may be skipped in order to start a frequently
accessed page on a sector boundary.
If the FLAGS field specifies that this is a Zero-Filled page then the PAGE DATA
OFFSET field will contain a 0.
If the logical page is specified as an iterated data page, as indicated by the FLAGS field,
then this field specifies the offset into the Iterated Data Pages section.
The logical page number (Object Page Table index), is used to index the Fixup Page
Table to find any fixups associated with the logical page.
Resource Table
The resource table is an array of resource table entries. Each resource table entry contains a type
ID and name ID. These entries are used to locate resource objects contained in the Object table.
The number of entries in the resource table is defined by the Resource Table Count located in
the linear EXE header. More than one resource may be contained within a single object.
Resource table entries are in a sorted order, (ascending, by Resource Name ID within the
Resource Type ID). This allows the DosGetResource API function to use a binary search when
looking up a resource in a 32-bit module instead of the linear search being used in the current
16-bit module.
OFFSET = DD The offset within the specified object where the resource begins.
The resident name table is kept resident in system memory while the module is loaded. It is
intended to contain the exported entry point names that are frequently dynamicaly linked to by
name. Non-resident names are not kept in memory and are read from the EXE file when a
dynamic link reference is made. Exported entry point names that are infrequently dynamicaly
linked to by name or are commonly referenced by ordinal number should be placed in the non-
resident name table. The trade off made for references by name is performance vs memory
usage.
Import references \by name require these tables to be searched to obtain the entry point ordinal
number. Import references by ordinal number provide the fastest lookup since the search of
these tables is not required.
Installable File Systems, Physical Device Drivers, and Virtual Device Drivers are closed after the
file is loaded. Any refeference to the non-resident name table after this time will fail.
The strings are CASE SENSITIVE and are NOT NULL TERMINATED.
The high bit in the LEN field (bit 7) is defined as an Overload bit. This bit signifies that
additional information is contained in the linear EXE module and will be used in the
future for parameter type checking.
ASCII STRING = DB ASCII String.
This is a variable length string with it's length defined in bytes by the LEN field. The
string is case case sensitive and is not null terminated.
ORDINAL # = DW Ordinal number.
The ordinal number in an ordered index into the entry table for this entry point.
Entry Table
The entry table contains object and offset information that is used to resolve fixup references to
the entry points within this module. Not all entry points in the entry table will be exported,
some entry points will only be used within the module. An ordinal number is used to index into
the entry table. The entry table entries are numbered starting from one.
The list of entries are compressed into 'bundles', where possible. The entries within each bundle
are all the same size. A bundle starts with a count field which indicates the number of entries in
the bundle. The count is followed by a type field which identifies the bundle format. This pro-
vides both a means for saving space as well as a mechanism for extending the bundle types.
The type field allows the definition of 256 bundle types. The following bundle types will initially
be defined:
Unused Entry.
16-bit Entry.
286 Call Gate Entry.
32-bit Entry.
Forwarder Entry.
The bundled entry table has the following format:
A zero value for the number of entries identifies the end of the entry table. There is no
further bundle information when the number of entries is zero. In other words the entry
table is terminated by a single zero byte.
TYPE = DB Bundle type.
This defines the bundle type which determines the contents of the BUNDLE INFO.
00h I
CNT TYPE
The 286 Call Gate Entry Point type is needed by the loader only if ring 2 segments
are to be supported. 286 Call Gate entries contain 2 extra bytes which are used by
the loader to store an LDT callgate selector value.
OBJECT = DW Object number.
This is the object number for the entries in this bundle.
FLAGS = DB Entry flags.
These are the flags for this entry point. They have the following definition.
0 lh = Exported entry flag.
F8h = Parameter word count mask.
OFFSET = DW Offset in object.
This is the offset in the object for the entry point defmed at this ordinal number.
CALLGATE = DW Callgate selector.
The callgate selector is a reserved field used by the loader to store a call gate selector
value for references to ring 2 entry points. When a ring 3 reference to a ring 2 entry
point is made, the callgate selector with a zero offset is place in the relocation fixup
address. The segment number and offset in segment is placed in the LDT callgate.
A Forwarder entry (type = 4) is an entry point whose value is an imported reference. When a
load time fixup occurs whose target is a forwarder, the loader obtains the address imported by the
forwarder and uses that imported address to resolve the fump.
A forwarder may refer to an entry point in another module which is itself a forwarder, so there
can be a chain of forwarders. The loader will traverse the chain until it finds a non-forwarded
entry point which terminates the chain , and use this to resolve the original fixup. Circular
chains are detected by the loader and result in a load time error. A maximum of 1024 forwarders
is allowed in a chain; more than this results in a load time error.
Forwarders are useful for merging and recombining API calls into different sets of libraries, while
maintaining compatibility with applications. For example, if one wanted to combine
MONCALLS, MOUCALLS, and VIOCALLS into a single libraries, one could provide entry
points for the three libraries that are forwarders pointing to the common implementation.
tion gathered on the module. When there are no module format directives for a linear EXE
module, the fields in the linear EXE header referencing the module format directives table are
zero.
Each Module Format Directive Table entry has the following format:
00h # OF ENTRY
Per-Page Checksum
The Per-Page Checksum table provides space for a cryptographic checksum for each physical
page in the EXE file.
The checksum table is arranged such that the first entry in the table corresponds to the first
logical page of code/data in the EXE file (usually a preload page) and the last entry corresponds
to the last logical page in the EXE file (usually a iterated data page).
This table is parallel to the Object Page Table, except that there is one additional entry in this
table to indicate the end of the Fixup Record Table.
OFFSET FOR PAGE# = DD Offset for fixup record for this page.
This field specifies the offset, from the beginning of the fixup record table, to the first
fixup record for this page.
OFF TO END OF FIXUP REC = DD Offset to the end of the fixup records.
This field specifies the offset following the last fixup record in the fixup record table.
This is the last entry in the fixup page table.
The fixup records are kept in order by logical page in the fixup record table. This allows
the end of each page's fixup records is defined by the offset for the next logical page's
fixup records. This last entry provides support of this mechanism for the last page in the
fixup page table.
SRCOFFl @ SRCOFFn @
Note that for fixups that cross page boundaries, a separate fixup record is specified for
each page. An offset is still used for the 2nd page but it now becomes a negative offset
since the fixup originated on the preceding page. (For example, if only the last one byte
of a 32-bit address is on the page to be fixed up, then the offset would have a value of
-3.)
TARGET DATA = Target data for fixup.
The format of the TARGET DATA is dependent upon target flags.
SRCOFFl - SRCOFFn = DW[] Source offset list.
This list is present if the Source List Flag is set in the Target Flags field. The number of
entries in the source offset list is defined in the SR CO FF /CNT field. The source offsets
are relative to the beginning of the page where the fixups are to be made.
SRCOFFl @ .. l SRCOFFn @
MOD ORD# = D[BiW] Ordinal index into the Import Module Name Table.
This value is an ordered index in to the Import Module Name Table for the module
containing the procedure entry point. It is a Byte value when the '16-bit Object
Number/Module Ordinal' Flag bit in the target flags field is clear and a Word value
when the bit is set. The loader creates a table of pointers with each pointer in the
table corresponds to the modules named in the Import Module Name Table. This
value is used by the loader to index into this table created by the loader to locate the
referenced module.
IMPORT ORD = D[BIWID] Imported ordinal number.
This is the imported procedure's ordinal number. It is a Byte value when the '8-bit
Ordinal' bit in the target flags field is set. Otherwise it is a Word value when the
'32-bit Target Offset Flag' bit in the target flags field is clear and a Dword value
when the bit is set.
This value is added to the address derived from the target entry point. This field is a
Word value when the '32-bit Additive Flag' bit in the target flags field is clear and a
Dword value when the bit is set.
MOD ORD# = D[BIWJ Ordinal index into the Import Module Name Table.
This value is an ordered index in to the Import Module Name Table for the module
containing the procedure entry point. It is a Byte value when the '16-bit Object
Number/Module Ordinal' Flag bit in the target flags field is clear and a Word value
when the bit is set. The loader creates a table of pointers with each pointer in the
table corresponds to the modules named in the Import Module Name Table. This
value is used by the loader to index into this table created by the loader to locate the
referenced module.
PROCEDURE NAME OFFSET = D[WIDJ Offset into the Import Procedure Name
Table.
This field is an offset into the Import Procedure Name Table. It is a Word value
when the '32-bit Target Offset Flag' bit in the target flags field is clear and a Dword
value when the bit is set.
ADDITIVE = D[WIDJ Additive fixup value.
This field exists in the fixup record only when the 'Additive Fixup Flag' bit in the
target flags field is set. When the 'Additive Fixup Flag' is clear the fixup record does
not contain this field and is immediately followed by the next fixup record (or by the
source offset list for this fixup record).
This value is added to the address derived from the target entry point. This field is a
Word value when the '32-bit Additive Flag' bit in the target flags field is clear and a
Dword value when the bit is set.
This value is added to the address derived from the target entry point. This field is a
Word value when the '32-bit Additive Flag' bit in the target flags field is clear and a
Dword value when the bit is set.
To determine the length of the import module name table subtract the import module name
table offset from the import procedure name table offset. These values are located in the linear
EXE header. The end of the import module name table is not terminated by a special character,
it is followed directly by the import procedure name table.
This defines the length of the string in bytes. The length of each ascii name string is
limited to 255 characters.
ASCII STRING = DB ASCII String.
This is a variable length string with it's length defined in bytes by the LEN field. The
string is case sensitive and is not null terminated.
To determine the length of the import procedure name table add the fixup section size to the
fixup page table offset, this computes the offset to the end of the fixup section, then subtract the
import procedure name table offset. These values are located in the linear EXE header. The
import procedure name table is followed by the data pages section. Since the data pages section
is aligned on a 'page size' boundary, padded space may exist between the last import name string
and the first page in the data pages section. If this padded space exists it will be zero filled.
The high bit in the LEN field (bit 7) is defined as an Overload bit. This bit signifies that
additional information is contained in the linear EXE module and will be used in the
future for parameter type checking.
ASCII STRING = DB ASCII String.
This is a variable length string with it's length defined in bytes by the LEN field. The
string is case sensitive and is not null terminated.
Note: The first entry in the import procedure name table must be a null entry. That is, the LEN
field should be zero followed an empty ASCII STRING (no bytes).
Preload Pages
The Preload Pages section is an optional section in the linear EXE module that coalesces a
'preload page set' into a contiguous section. The preload page set can be defined as the set of
first used pages in the module. The preload page set can be specified by the application devel-
oper or can be derived by a tool that analyzes the programs memory usage while it is running.
By grouping the preload page set together, the preload pages can be read from the linear EXE
module with one disk read.
The structure of the preload pages is no different than if they were demand loaded. Their sizes
are determined by the Object Page Table entries that correspond. If the specified size is less than
the PAGE SIZE field given in the linear EXE module header the remainder of the page is filled
with zeros when loaded.
All pages begin on a PAGE OFFSET SHIFT boundary from the base of the preload page
section, as specified in the linear EXE header. The pages are ordered by logical page number
within this section.
Note that OS/2 2.x does not respect the preload of pages as specified in the executable file for
performance reasons.
This record structure is used to describe the iterated data for an object on a per-page basis.
Debug Information
The debug information is defined by the debugger and is not controlled by the linear EXE
format or linker. The only data defined by the linear EXE format relative to the debug informa-
tion is it's offset in the EXE file and length in bytes as defined in the linear EXE header.
To support multiple debuggers the first word of the debug information is a type field which
determines the format of the debug information.
The values defined for the type field are not enforced by the system. It is the responsi-
bility of the linker or debugging tools to follow the convention for the type field that
is defined here.