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.

Compiler/TMS320F28379D: Follow up on .data, .pinit, and .switch linker symbols

Part Number: TMS320F28379D


Tool/software: TI C/C++ Compiler

The documentation spraa46a.pdf and spru513p.pdf suggest that the .data, .pinit, and .switch linker symbols will be used.   Although, the Memory Allocation tool never shows them as being utilized.  Our application works whether they are defined in the linker command file or not.   

Are these linker symbols deprecated or could I be missing something that's causing these sections to remain unused?

Kindly,

Graham

 

  • Graham,

    The section names are valid. They contain initialized data, C++ constructors, and switch case tables respectively. All should be linked to page 0 (program space) which could be either flash or RAM (it's up to you). The compiler will populate these sections automatically if your program contains initialized data, C++ constructors, and switch case statements respectively. If it does not, the sections will be empty though you will still see the symbols in the memory window and in the map file. BTW, I find it helpful to always set the "-m" linker flag so a .map file is generated on each build. You can open that with any text editor to see exactly what is linker where in memory.

    Regards,

    Richard
  • Thanks Richard,

    Creating the map file is quite useful.  Although, the .data, .pinit, and .switch linker symbols remain unused according to the map file.  

    They are in page 0, C++ is heavily utilized in this application, and there are plenty of switch statements.  

    RAMGS13 is mapped to .data, RAMGS14 is mapped to .pinit, and FLASHA is mapped to .switch.

    I must be missing something.

    Attached is the portion of the map file with the origin, length, used, and unused portions.

    Kindly,

    Graham

    ******************************************************************************
                 TMS320C2000 Linker Unix v18.1.4                   
    ******************************************************************************
    >> Linked Wed Jan 16 15:38:37 2019
    
    OUTPUT FILE NAME:   <application.out>
    ENTRY POINT SYMBOL: "_c_int00"  address: 0008d4d7
    
    
    MEMORY CONFIGURATION
    
             name            origin    length      used     unused   attr    fill
    ----------------------  --------  ---------  --------  --------  ----  --------
    PAGE 0:
      RAMM0                 00000122   000002de  0000003b  000002a3  RWIX
      UPPTXMSGRAM           00006c00   00000200  00000000  00000200  RWIX
      UPPRXMSGRAM           00006e00   00000200  00000000  00000200  RWIX
      RAMD0to1              0000b000   00001000  00000200  00000e00  RWIX
      RAMGS13               00019000   00001000  00000000  00001000  RWIX
      RAMGS14               0001a000   00001000  00000000  00001000  RWIX
      RAMGS15               0001b000   00001000  00000120  00000ee0  RWIX
      BEGIN                 00080000   00000002  00000002  00000000  RWIX
      FLASHA                00080002   00001ffe  00000000  00001ffe  RWIX
      FLASHB                00082000   00002000  00000000  00002000  RWIX
      FLASHC                00084000   00002000  00000000  00002000  RWIX
      FLASHD                00086000   00002000  00000000  00002000  RWIX
      FLASHEtoJ             00088000   00030000  00005bdf  0002a421  RWIX
      FLASHK                000b8000   00002000  00000000  00002000  RWIX
      FLASHL                000ba000   00002000  00000000  00002000  RWIX
      FLASHM                000bc000   00002000  00000000  00002000  RWIX
      FLASHN                000be000   00002000  00000000  00002000  RWIX
      RESET                 003fffc0   00000002  00000000  00000002  RWIX
    
    PAGE 1:
      BOOT_RSVD             00000002   00000120  00000000  00000120  RWIX
      RAMM1                 00000400   00000400  00000093  0000036d  RWIX
      ADCA_RESULT           00000b00   00000020  00000018  00000008  RWIX
      ADCB_RESULT           00000b20   00000020  00000018  00000008  RWIX
      ADCC_RESULT           00000b40   00000020  00000018  00000008  RWIX
      ADCD_RESULT           00000b60   00000020  00000018  00000008  RWIX
      CPU_TIMER0            00000c00   00000008  00000008  00000000  RWIX
      CPU_TIMER1            00000c08   00000008  00000008  00000000  RWIX
      CPU_TIMER2            00000c10   00000008  00000008  00000000  RWIX
      PIE_CTRL              00000ce0   00000020  0000001a  00000006  RWIX
      PIE_VECT              00000d00   00000200  000001c0  00000040  RWIX
      DMA                   00001000   00000200  000000e0  00000120  RWIX
      CLA1                  00001400   00000040  0000003e  00000002  RWIX
      CPUxCLA1toCPUxMSGRAM  00001480   00000080  00000000  00000080  RWIX
      CPUxtoCPUxCLA1MSGRAM  00001500   00000080  00000000  00000080  RWIX
      EPWM1                 00004000   00000100  00000100  00000000  RWIX
      EPWM2                 00004100   00000100  00000100  00000000  RWIX
      EPWM3                 00004200   00000100  00000100  00000000  RWIX
      EPWM4                 00004300   00000100  00000100  00000000  RWIX
      EPWM5                 00004400   00000100  00000100  00000000  RWIX
      EPWM6                 00004500   00000100  00000100  00000000  RWIX
      EPWM7                 00004600   00000100  00000100  00000000  RWIX
      EPWM8                 00004700   00000100  00000100  00000000  RWIX
      EPWM9                 00004800   00000100  00000100  00000000  RWIX
      EPWM10                00004900   00000100  00000100  00000000  RWIX
      EPWM11                00004a00   00000100  00000100  00000000  RWIX
      EPWM12                00004b00   00000100  00000100  00000000  RWIX
      ECAP1                 00005000   00000020  00000020  00000000  RWIX
      ECAP2                 00005020   00000020  00000020  00000000  RWIX
      ECAP3                 00005040   00000020  00000020  00000000  RWIX
      ECAP4                 00005060   00000020  00000020  00000000  RWIX
      ECAP5                 00005080   00000020  00000020  00000000  RWIX
      ECAP6                 000050a0   00000020  00000020  00000000  RWIX
      EQEP1                 00005100   00000040  00000022  0000001e  RWIX
      EQEP2                 00005140   00000040  00000022  0000001e  RWIX
      EQEP3                 00005180   00000040  00000022  0000001e  RWIX
      DACA                  00005c00   00000010  00000008  00000008  RWIX
      DACB                  00005c10   00000010  00000008  00000008  RWIX
      DACC                  00005c20   00000010  00000008  00000008  RWIX
      CMPSS1                00005c80   00000020  00000020  00000000  RWIX
      CMPSS2                00005ca0   00000020  00000020  00000000  RWIX
      CMPSS3                00005cc0   00000020  00000020  00000000  RWIX
      CMPSS4                00005ce0   00000020  00000020  00000000  RWIX
      CMPSS5                00005d00   00000020  00000000  00000020  RWIX
      CMPSS6                00005d20   00000020  00000000  00000020  RWIX
      CMPSS7                00005d40   00000020  00000000  00000020  RWIX
      CMPSS8                00005d60   00000020  00000000  00000020  RWIX
      SDFM1                 00005e00   00000080  00000080  00000000  RWIX
      SDFM2                 00005e80   00000080  00000080  00000000  RWIX
      MCBSPA                00006000   00000040  00000024  0000001c  RWIX
      MCBSPB                00006040   00000040  00000024  0000001c  RWIX
      SPIA                  00006100   00000010  00000010  00000000  RWIX
      SPIB                  00006110   00000010  00000010  00000000  RWIX
      SPIC                  00006120   00000010  00000010  00000000  RWIX
      SPID                  00006130   00000010  00000000  00000010  RWIX
      UPP                   00006200   00000100  00000048  000000b8  RWIX
      WD                    00007000   00000040  0000002b  00000015  RWIX
      NMIINTRUPT            00007060   00000010  00000007  00000009  RWIX
      XINT                  00007070   00000010  0000000b  00000005  RWIX
      SCIA                  00007200   00000010  00000010  00000000  RWIX
      SCIB                  00007210   00000010  00000010  00000000  RWIX
      SCIC                  00007220   00000010  00000010  00000000  RWIX
      SCID                  00007230   00000010  00000010  00000000  RWIX
      I2CA                  00007300   00000040  00000022  0000001e  RWIX
      I2CB                  00007340   00000040  00000022  0000001e  RWIX
      ADCA                  00007400   00000080  00000080  00000000  RWIX
      ADCB                  00007480   00000080  00000080  00000000  RWIX
      ADCC                  00007500   00000080  00000080  00000000  RWIX
      ADCD                  00007580   00000080  00000080  00000000  RWIX
      INPUT_XBAR            00007900   00000020  00000020  00000000  RWIX
      XBAR                  00007920   00000020  00000020  00000000  RWIX
      SYNC_SOC              00007940   00000010  00000006  0000000a  RWIX
      DMACLASRCSEL          00007980   00000040  0000001a  00000026  RWIX
      EPWM_XBAR             00007a00   00000040  00000040  00000000  RWIX
      CLB_XBAR              00007a40   00000040  00000000  00000040  RWIX
      OUTPUT_XBAR           00007a80   00000040  00000040  00000000  RWIX
      GPIOCTRL              00007c00   00000180  00000180  00000000  RWIX
      GPIODAT               00007f00   00000030  00000030  00000000  RWIX
      RAMLS0to1             00008000   00001000  000004a4  00000b5c  RWIX
      RAMLS2to3             00009000   00001000  00000400  00000c00  RWIX
      RAMLS4to5             0000a000   00001000  00000280  00000d80  RWIX
      CPU2TOCPU1RAM         0003f800   00000400  00000000  00000400  RWIX
      CPU1TOCPU2RAM         0003fc00   00000400  00000000  00000400  RWIX
      EMIF1                 00047000   00000800  00000070  00000790  RWIX
      EMIF2                 00047800   00000800  00000070  00000790  RWIX
      CANA                  00048000   00000800  00000000  00000800  RWIX
      CANB                  0004a000   00000800  00000000  00000800  RWIX
      IPC                   00050000   00000024  00000024  00000000  RWIX
      FLASHPUMPSEMAPHORE    00050024   00000002  00000002  00000000  RWIX
      DEV_CFG               0005d000   00000180  0000012e  00000052  RWIX
      ANALOG_SUBSYS         0005d180   00000080  00000048  00000038  RWIX
      CLK_CFG               0005d200   00000100  00000032  000000ce  RWIX
      CPU_SYS               0005d300   00000100  00000082  0000007e  RWIX
      ROMPREFETCH           0005e608   00000002  00000002  00000000  RWIX
      DCSM_Z1               0005f000   00000030  00000024  0000000c  RWIX
      DCSM_Z2               0005f040   00000030  00000024  0000000c  RWIX
      DCSM_COMMON           0005f070   00000010  00000008  00000008  RWIX
      MEMCFG                0005f400   00000080  00000080  00000000  RWIX
      EMIF1CONFIG           0005f480   00000020  00000020  00000000  RWIX
      EMIF2CONFIG           0005f4a0   00000020  00000020  00000000  RWIX
      ACCESSPROTECTION      0005f4c0   00000040  00000040  00000000  RWIX
      MEMORYERROR           0005f500   00000040  00000040  00000000  RWIX
      ROMWAITSTATE          0005f540   00000002  00000002  00000000  RWIX
      FLASH0_CTRL           0005f800   00000300  00000182  0000017e  RWIX
      FLASH0_ECC            0005fb00   00000040  00000028  00000018  RWIX

  • the .data, .pinit, and .switch linker symbols remain unused

    Just a quick point of terminology ... These are not the names of symbols, but the names of sections.  When you say these symbols are unused, I presume you mean these sections are empty.  I'll explain each in turn.

    The .data section is not used by the C2000 compiler.  Though this changes in future releases of the compiler.

    The .switch section contains tables for switch statements.  However, not every switch statement requires a table.  So, it is possible to have an empty .switch section even though there are many switch statements.  All that said, the larger the program, the more likely .switch section is not empty.

    The .pinit section is often described as having the C++ constructors.  This is a simplification.  What actually happens is a bit more complex.  Suppose you have a class with a non-trivial constructor ...

    class ntc {
       ntc(/* arguments here */);
    };
    
    ntc::ntc(/* arguments here */)
    {
        /* non-trivial code here */
    }

    Then, you define a global instance of this class ...

    ntc global_instance(/* arguments here */);

    This global instance of the class must be initialized before main starts.  The compiler creates a function which invokes the ntc constructor on global_instance, and puts the address of this function in the .pinit section.  Startup code, which runs before main, processes the .pinit section and calls all these functions for initializing global class objects with non-trivial constructors.  If your code never does that, then .pinit is empty.

    Thanks and regards,

    -George

  • Thanks George your response is very helpful.   

    It's quite possible that none of the switch statements in the code can be optimized.  

    Also, I avoid global instances of any object as much as is reasonable.  The code has many non-trivial class constructors, and none of them are a global instance.  That explains why the .pinit section is not used.  I did a test to confirm.

    Kindly,

    Graham