INF: Description of the Map File Created by LINK

ID Number: Q80437

3.x 4.x 5.0x 5.10 5.13 5.15 5.30 | 5.0x 5.10 5.13 5.15

MS-DOS | OS/2

Summary:

The mapfile field in the linker command line tells LINK to create a

map file. The field is also used to specify a filename for the map

file other than the default. The default is the same base name as the

executable with a .MAP extension. The name NUL will suppress creation

of the map file.

The /MAP file contents are as follows:

Start, Stop, Length, Name, and Class of the logical segments

Groups

Program Entry point

/MAP:ADDRESS adds the following to the information provided by /MAP:

Publics by Value

/MAP:FULL adds the following to the information provided by

/MAP:ADDRESS:

Object file contributions to a segment (given below each logical

segment)

Publics by Name

Undecorated Names of C++ Symbols

The /LI[NENUMBERS] option will add source-file line numbers and

associated addresses to the map file.

More Information:

In MS-DOS or real-mode OS/2, Start and Stop are expressed as 20-bit

hex addresses that are relative to the beginning of the program's load

image. In Windows or protected-mode OS/2, the hex addresses are

expressed in 32-bit segment:offset notation. For OS/2, the segment

value is actually a selector into a descriptor table that contains

information about the segments.

A group is a collection of logical segments not totaling more than 64K

in size. They are created with the assembler directive GROUP. For

example, Microsoft high-level languages create the group DGROUP, which

contains the segments _NULL, _DATA, CONST, C_COMMON, _BSS, and STACK

among others. Please see the article about segments created by the C

run-time library for more details.

If an MS-DOS program is overlaid, the logical segment information will

be divided into sections. The first section will be labeled as the

Resident portion of the program, and each subsequent overlay will have

its own section, labeled Overlay 1h, Overlay 2h, and so on. In

addition, the public symbols will have one of the following

attributes:

RES -- If the symbol resides in the resident portion

OVL -- If the symbol resides in an overlay

ABS -- If the symbol represents a constant value

In Windows or OS/2 protected-mode, the public symbols might have one

of the following attributes:

EXP -- If the symbol was exported

IMP -- If the symbol was imported

The program entry point is where the operating system will begin

executing the program relative to the lowest memory address where the

program code will be loaded. This address will be loaded into CS:IP

when the program begins execution. Microsoft high-level languages

require specific initialization code; the entry point is the routine

__astart.

In MS-DOS, the start segment will be the base address of the program

segment prefix (PSP) plus the size of the PSP, which is 100h bytes.

Registers DS and ES are loaded with this value when the EXE is loaded.

In C, you access this segment address by declaring the variable

extern unsigned _psp;

The absolute starting address will be program entry point, plus the

base address of the PSP, plus the size of the PSP. Also, the address

of any symbol can be found by adding its relative address in the map

file to the base address of the PSP plus the size of the PSP.

In protected-mode, there is no reliable way to determine the address

of a symbol, because segments may be moved in memory or even

discarded.

Additional reference words: Q48241