This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

peculiar linker behavior when specifying multiple sections of lib in sections directive of cmd file

Other Parts Discussed in Thread: CONTROLSUITE

So, say you have a simple F280xx project and in a cmd file, you are trying to specify a section for the FlashAPI lib.  This is what's in the Flash API example cmd files in controlSuite.

    Flash28_API             : {
                            -lFlash2803x_API_V100.lib(.econst)
                            -lFlash2803x_API_V100.lib(.text)
                          }
                          LOAD = FLASH_A_H,
                          RUN = RAML0,
                          LOAD_START(_Flash28_API_LoadStart),
                          LOAD_SIZE(_Flash28_API_LoadSize),
                          RUN_START(_Flash28_API_RunStart),
                          PAGE = 0

When I look at the memory allocation, I notice there is no .econst section of Flash28_Erase.obj, even though I told it to include .econst.

Now, if I don't specify .econst or .text in the -l option and compile again with no other code changes, suddenly I get the .econst section of Flash28_Erase.obj, which adds another 40 bytes (which is weird because 1325 + 40 != 1366 as shown below).

    Flash28_API             : {
                            -lFlash2803x_API_V100.lib
                          }
                          LOAD = FLASH_A_H,
                          RUN = RAML0,
                          LOAD_START(_Flash28_API_LoadStart),
                          LOAD_SIZE(_Flash28_API_LoadSize),
                          RUN_START(_Flash28_API_RunStart),
                          PAGE = 0

Have tried with both CGT 6.4.x or 15.2.x

  • I realize that after looking at the .map file, the .econst is actually in there in both cases, so it's just CCS for some reason doesn't display it correctly.

    The one extra hole is peculiar though.  This is the map of when I reference only -lFlash2803x_API_V100.lib

    Flash28_API 
    *          0    003e8d00    00000556     RUN ADDR = 00008000
                      003e8d00    000000e1     Flash2803x_API_V100.lib : Flash28_Prog.obj (.text)
                      003e8de1    000000d0                             : Flash28_Erase.obj (.text)
                      003e8eb1    0000009a                             : Flash28_Erase_Pulse.obj (.text)
                      003e8f4b    00000084                             : Flash28_Internals.obj (.text)
                      003e8fcf    00000080                             : Flash28_Prog_Pulse.obj (.text)
                      003e904f    0000007d                             : Flash28_Compact_Pulse.obj (.text)
                      003e90cc    0000005b                             : Flash28_EraseSector.obj (.text)
                      003e9127    00000054                             : Flash28_CompactSector.obj (.text)
                      003e917b    00000041                             : Flash28_ClearLoop.obj (.text)
                      003e91bc    00000033                             : Flash28_ClearSector.obj (.text)
                      003e91ef    00000001     --HOLE-- [fill = 0]
                      003e91f0    00000028                             : Flash28_Erase.obj (.econst)
                      003e9218    00000016                             : Flash28_Init.obj (.text)
                      003e922e    00000014                             : Flash28_Utils.obj (.text)
                      003e9242    0000000d                             : Flash28_Delay.obj (.text)
                      003e924f    00000007                             : Flash28_DisInt.obj (.text)

    and when I reference -lFlash2803x_API_V100.lib(.econst) and -lFlash2803x_API_V100.lib(.text)

    Flash28_API 
    *          0    003e8d00    00000555     RUN ADDR = 00008000
                      003e8d00    00000028     Flash2803x_API_V100.lib : Flash28_Erase.obj (.econst)
                      003e8d28    000000e1                             : Flash28_Prog.obj (.text)
                      003e8e09    000000d0                             : Flash28_Erase.obj (.text)
                      003e8ed9    0000009a                             : Flash28_Erase_Pulse.obj (.text)
                      003e8f73    00000084                             : Flash28_Internals.obj (.text)
                      003e8ff7    00000080                             : Flash28_Prog_Pulse.obj (.text)
                      003e9077    0000007d                             : Flash28_Compact_Pulse.obj (.text)
                      003e90f4    0000005b                             : Flash28_EraseSector.obj (.text)
                      003e914f    00000054                             : Flash28_CompactSector.obj (.text)
                      003e91a3    00000041                             : Flash28_ClearLoop.obj (.text)
                      003e91e4    00000033                             : Flash28_ClearSector.obj (.text)
                      003e9217    00000016                             : Flash28_Init.obj (.text)
                      003e922d    00000014                             : Flash28_Utils.obj (.text)
                      003e9241    0000000d                             : Flash28_Delay.obj (.text)
                      003e924e    00000007                             : Flash28_DisInt.obj (.text)

  • That hole is alignment padding.