Introduction
A linker map file is a text report that a linker writes, on request, alongside the program or library it builds. It shows where everything ended up: the address and size of each section or segment, which object file and library each piece came from, and the address of each public symbol. Developers use it to find what makes a program large, to check the memory layout of firmware, and to turn a crash address into a function name when no other debug information is at hand.
The usual extension is .map, which is also used for
JavaScript source maps and other unrelated
formats.
Structure
There is no standard layout: each linker writes its own, and it can change between versions. Most map files have the same parts in some form: the program name and timestamp, a table of sections or segments with start addresses and lengths, a list of the input object files and libraries with what each contributed, and a list of public symbols sorted by name or by address. The Microsoft linker also gives the preferred load address and the entry point; the GNU linker lists the archive members it pulled in and why, and the memory regions of the linker script.
Ask for one with /MAP for the Microsoft linker, -Map=file
for the GNU linker and LLD on Linux, and -map file for Apple’s linker.
Also used for
Links
Software
- Visual Studio, whose linker writes them with
/MAP(Windows) - GNU Binutils, whose
ldwrites them with-Map(Linux, macOS, Windows) - LLD, the LLVM linker (Linux, macOS, Windows)
- Any text editor, to read them
Reference
- Command-line options in the GNU ld manual, including
-Map