2.3. "Map" Files

avr-objdump is very useful, but sometimes it's necessary to see information about the link that can only be generated by the linker. A map file contains this information. A map file is useful for monitoring the sizes of your code and data. It also shows where modules are loaded and which modules were loaded from libraries. It is yet another view of your application. To get a map file, I usually add -Wl,-Map,demo.map to my link command. Relink the application using the following command to generate demo.map (a portion of which is shown in Example 2-3.

    % avr-gcc -g -mmcu=at90s2313 -Wl,-Map,demo.map -o demo.out demo.o

Some points of interest in the map file are:

(1)
The .text segment (where program instructions are stored) starts at location 0x0.
(2)
The next available address in the .text segment is location 0xec, so the instructions use up 234 bytes of FLASH.
(3)
The .data segment (where initialized static variables are stored) starts at location 0x60, which is the first address after the register bank on a 2313 processor.
(4)
The next available address in the .data segment is also location 0x60, so the application has no initialized data.
(5)
The .bss segment (where uninitialized data is stored) starts at location 0x60.
(6)
The next available address in the .bss segment is location 0x64, so the application uses 4 bytes of uninitialized data.
(7)
The .eeprom segment (where EEPROM variables are stored) starts at location 0x0.
(8)
The next available address in the .eeprom segment is also location 0x0, so there aren't any EEPROM variables.

Example 2-3. Portion of demo map file

    .text           0x00000000       0xec(1)
     *(.init)
     .init          0x00000000       0x16 /usr/local/avr/lib/crts2313.o
     *(.progmem.gcc*)
     *(.progmem*)
                    0x00000016                .=ALIGN(0x2)
     *(.text)
     .text          0x00000016       0x34 /usr/local/avr/lib/crts2313.o
                    0x00000046                _interrupt1_
                    0x00000046                _uart_trans_
                    0x00000046                _overflow0_
                    0x00000016                _init_
                    0x00000046                _uart_data_
                    0x00000046                _uart_recv_
                    0x00000048                _unexpected_
                    0x00000046                _comparator_
                    0x00000046                _interrupt0_
                    0x00000046                _output_compare1a_
                    0x00000046                _input_capture1_
                    0x00000016                _real_init_
     .text          0x0000004a       0xa2 demo.o
                    0x0000004a                _overflow1_
                    0x000000c2                ioinit
                    0x000000de                main
                    0x000000ec                .=ALIGN(0x2)
     *(.text.*)
                    0x000000ec                .=ALIGN(0x2)
     *(.fini)
                    0x000000ec                _etext=.(2)
    
    .data           0x00800060        0x0 load address 0x000000ec(3)
                    0x00800060                PROVIDE (__data_start, .)
     *(.data)
     *(.gnu.linkonce.d*)
                    0x00800060                .=ALIGN(0x2)
                    0x00800060                _edata=.(4)
    
    .bss            0x00800060        0x4(5)
                    0x00800060                PROVIDE (__bss_start, .)
     *(.bss)
     .bss           0x00800060        0x2 demo.o
     *(COMMON)
     COMMON         0x00800062        0x2 demo.o
                                      0x0 (size before relaxing)
                    0x00800062                direction
                    0x00800064                PROVIDE (__bss_end, .)
                    0x00800064                _end=.(6)
    
    .eeprom         0x00810000        0x0 load address 0x000000ec(7)
     *(.eeprom*)
                    0x00810000                __eeprom_end=.(8)