This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

MAP FILE->Removing Unused input sections from the image

I have a working and a not-working configuration for my project (linker settings)


First lets see what it mean in the mapfile:

================================================================================

Removing Unused input sections from the image.

    Removing startup.o(RESET), (272 bytes).

1 unused section(s) (total 272 bytes) removed from the image.

================================================================================
also this is another part of the map file above
================================================================================

Memory Map of the image

  Image Entry point : 0x00000000

  Load Region LR_1 (Base: 0x00000000, Size: 0x00000a9c, Max: 0xffffffff, ABSOLUTE)

    Execution Region ER_RO (Base: 0x00000000, Size: 0x00000a94, Max: 0xffffffff, ABSOLUTE)

    Base Addr    Size         Type   Attr      Idx    E Section Name        Object

    0x00000000   0x00000008   Code   RO           78  * !!!main             __main.o(c_t__un.l)
    0x00000008   0x00000038   Code   RO          120    !!!scatter          __scatter.o(c_t__un.l)
    0x00000040   0x00000028   Code   RO          122    !!handler_copy      __scatter_copy.o(c_t__un.l)
    0x00000068   0x0000002c   Code   RO          124    !!handler_zi        __scatter_zi.o(c_t__un.l)
    0x00000094   0x00000004   Ven    RO          100    .emb_text           lib_init.o(c_t__un.l)
    0x00000098   0x00000010   Code   RO          100    .emb_text           lib_init.o(c_t__un.l)
    0x000000a8   0x00000020   Code   RO            4    .text               startup.o
    0x000000c8   0x00000048   Code   RO           10    .text               retarget.o
    0x00000110   0x0000010c   Code   RO           35    .text               lpcx.o
    0x0000021c   0x00000074   Code   RO           55    .text               serial.o
    0x00000290   0x00000004   Code   RO           69    .text               use_no_semi.o(c_t__un.l)
The above two parts of map files was from the not-working project settings


This happens when I uncheck the option Use memory layout from target dialog and enter the values 0x00000000 and 0x40000000 for RO base and RW base respectively. In this situation my program does not work (I think because of that no reset handler is defined ~ since I manually set the program counter at the start of my program in startup.s and again it can work [but manually!])

But if I check the option above every thing is fine, my program works and the above section is not removed from image file and when I reset the board the program is run correctly


And this is a part of map file in the working situation:
================================================================================

Memory Map of the image

  Image Entry point : 0x00000110

  Load Region LR_IROM1 (Base: 0x00000000, Size: 0x00000bac, Max: 0x00080000, ABSOLUTE)

    Execution Region ER_IROM1 (Base: 0x00000000, Size: 0x00000ba4, Max: 0xffffffff, ABSOLUTE)

    Base Addr    Size         Type   Attr      Idx    E Section Name        Object

    0x00000000   0x00000110   Code   RO            3    RESET               startup.o
    0x00000110   0x00000008   Code   RO           78  * !!!main             __main.o(c_t__un.l)
    0x00000118   0x00000038   Code   RO          120    !!!scatter          __scatter.o(c_t__un.l)
    0x00000150   0x00000028   Code   RO          122    !!handler_copy      __scatter_copy.o(c_t__un.l)
    0x00000178   0x0000002c   Code   RO          124    !!handler_zi        __scatter_zi.o(c_t__un.l)
    0x000001a4   0x00000004   Ven    RO          100    .emb_text           lib_init.o(c_t__un.l)
    0x000001a8   0x00000010   Code   RO          100    .emb_text           lib_init.o(c_t__un.l)
    0x000001b8   0x00000020   Code   RO            4    .text               startup.o
    0x000001d8   0x00000048   Code   RO           10    .text               retarget.o
    0x00000220   0x0000010c   Code   RO           35    .text               lpcx.o
    0x0000032c   0x00000074   Code   RO           55    .text               serial.o
    0x000003a0   0x00000004   Code   RO           69    .text               use_no_semi.o(c_t__un.l)

as you see the RESET is only defined in the map file of correct situation and it does not exist in the first map file that it had 272 bytes removed of it

Thanks

Parents
  • We recommend to use a scatter file.

    When you specify a scatter file then you need for the RESET section a first directive. This directive avoids that the segment is marked as unused.

    LR_IROM1 0x00000000 0x00040000  {  ; load region
      ER_IROM1 0x00000000  {       ; load address = execution address
       *.o (RESET, +First)
       * (+RO)
      }
      RW_IRAM1 0x40000000 0x00004000  {  ; RW data
       * (+RW +ZI)
      }
    }
    

    When you just R/O and R/W Base address you need to specify the --first command.

Reply
  • We recommend to use a scatter file.

    When you specify a scatter file then you need for the RESET section a first directive. This directive avoids that the segment is marked as unused.

    LR_IROM1 0x00000000 0x00040000  {  ; load region
      ER_IROM1 0x00000000  {       ; load address = execution address
       *.o (RESET, +First)
       * (+RO)
      }
      RW_IRAM1 0x40000000 0x00004000  {  ; RW data
       * (+RW +ZI)
      }
    }
    

    When you just R/O and R/W Base address you need to specify the --first command.

Children
No data