This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to read Linker Map file


"Steven Woody" <narkewoody@gmail.com> writes:
> i produced a linker map file using -M flag to 'ld'. but i found the
> file is hard to understand to me.  is there a readme file or any
> documents describing the file format in details?  thanks.

You mean, besides the linker's existing documentation?

> especially, in the map file, what is common symbols? how does it
> differ with other symbols?

A common symbol is one where one or more modules tell the linker, "I
need a block of memory N bytes long called 'foo', please arrange it
for me, and share it with other modules".  The linker collects all
these requests, and allocates memory from a common pool for them.

The C equivalent is an uninitialized global variable:

        int j;

If you do "int j;" in multiple files, they all refer to the same
memory, essentially creating one variable "j" that's common to all the
objects.

The alternatives are (1) initialized variables, where the object
itself allocates memory for it (other objects may share this memory if
they request a suitable common block), and (2) static variables, which
aren't shared.  Uninitialized static variables may come from the
common pool (without being shared) or from the .bss segment, depending
on how you specify them.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]