Q47960: Description of a Linker .MAP File
Article: Q47960
Product(s): See article
Version(s): 3.60 3.61 3.64 3.65 5.01.20 5.01.21 5.03 | 5.01.20 5.01.
Operating System(s): MS-DOS | OS/2
Keyword(s): ENDUSER | S_C S_PasCal H_FORTRAN | mspl13_basic
Last Modified: 19-SEP-1989
A .MAP file generated by the linker is a listing of the addresses and
names of a program, as follows:
Logical Segments
Groups (defined collections of logical segments)
Public Symbols listed by name
Public Symbols listed again by their relative address
Entry Point address (first executable instruction)
A linker .MAP file (with a .MAP file extension) contains the address,
size, name, and class of logical code and data segments. (One or more
logical segments of either code or data can be combined into a
physical segment of either code or data, respectively, by the linker.)
In DOS or real-mode OS/2, the addresses are 20-bit hex addresses that
are RELATIVE to the beginning of the program's load image. In
protected-mode OS/2, the hex addresses are in 32-bit segment
selector:offset notation (16 bits for the segment selector and 16 bits
for the offset) starting with segment selector 1.
The _TEXT segment names of class CODE are the code in your object
files. The various forms of near logical data segments are described
in the DGROUP diagram, which you probably already have. (Briefly,
_DATA is initialized near global data, _BSS is uninitialized near
"static" data, C_COMMON is uninitialized near data, and CONST is for
floating point constants. FAR_DATA and HUGE_DATA are global
initialized far and huge data, respectively, and FAR_BSS is global
unitialized far or huge data.)
Next in the .MAP is the ORIGIN (address) and name of the defined
groups of logical segments, notably DGROUP, which is used in our
high-level languages for grouping many logical data segments into the
"default" physical data segment. The name "default" data segment
refers to the fact the the DS register will point to this segment by
default so that offset (near) addressing can be used without loading
the DS register. Groups allow multiple logical segments to be
associated with the same starting address, so near (non-far) data in
Microsoft high-level languages is addressed relative to DGROUP.
Following the segment descriptions, under the heading of "Publics by
Name", the names of Public symbols (i.e., global or extern functions,
including numerous internal C library functions, and variables) are
listed in ASCII order (capital letters first, then lowercase letters,
and finally underscores) along with their hex relative segment:offset
addresses (or segment selector:offset in protected-mode OS/2). Public
symbols are then listed again, in order of their relative
segment:offset addresses under the heading "Publics by Value".
Only Public (e.g. global) symbols such as function and variable names
appear in the .MAP. No "static" functions or data, "auto" storage
class data (e.g. local function data), or data types are listed in the
.MAP.
A high-level language such as C creates many logical segments in
DGROUP for "internal" (e.g. undocumented) purposes, calls numerous
internal library functions, and refers to variables for the main
program initialization and start-up code. C refers to additional
initialization functions and variables for the library functions that
your program explicitly calls, still more for floating point
functions, as well as termination functions.
To get an idea of the functions automatically linked in from the C
library, generate and compare .MAP files for simple source modules
such as foo(){} or main(){}, main(){puts("hi");}, and a small program
that performs floating point arithmetic or calls a C library floating
point math function that calls "fp..." routines.
The "Program entry point" is the last item in the .MAP file. It refers
to the segment:offset address of the first instruction of the program
to be executed, relative to the lowest memory address in the .EXE load
image.
For more information on the entry point, please use the following
query:
.map file's program entry point
THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.
Copyright Microsoft Corporation 1986-2002.