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.

CCS/MSP432P401R: GCC empty project template for MSP432: add __attribute__((used)) to interruptVectors[]

Part Number: MSP432P401R

Tool/software: Code Composer Studio

Hi,

similarly to the TI compiler, gcc will optimize unused functions and variables out. Therefore, the attribute used should be added to the array of interrupt handlers (in the file startup_msp432p401r_gcc.c), which will prevent gcc from removing the interrupt handlers.

Please add this to the default templates, as this might cause very weird problems for users.

Cheers,

Dan

  • Dan,

    Which version of the tools are you using? The reason is that I created a simple project using all the defaults in my CCSv7 and I can see the .intvecs was fully allocated when the optimizer is fully on. Also, I compared the startup file of my project with one of the GCC examples of the Simplelink MSP432 SDK (msp432p401_adc14_21) and their differences are only on the entry point - the project template calls GCC's _mainCRTStartup() and the project initializes .bss manually and calls main() directly.

    I ported the example project to my template-based project and it worked fine as well. Please check attached the project I used.

    Regards,

    Rafael

    1663.msp432_gcc_test.zip

  • Hi Rafael,
    I am primarily using gcc without code composer (only turned it on to get a up-to date empty project). Currently I am running gcc from ARM (version 6.2.1). There, omitting the attribute used results in the .intvecs section being empty, but with it the interrupt handlers are present. I am not too fond of compiler internals, so you might consider it a bug if gcc optimizes the handlers out which were explicitly put in a section, but specifying __attribute__((used)) fixes the problem.
    Since the attribute won't hurt for lower versions of gcc and seems to be compatible with TI's compiler, I would advocate for including it by default for future compatibility.

    Cheers,
    Dan
  • Dan,

    Thank you for the information. I will forward this to the MSP432 product group (they own the startup files).

    Regards,
    Rafael
  • Hey Dan,

    Just to make sure that I understand you correctly, you're using GCC compiler without CCS and seeing that the .intvecs section is empty but the handlers are linked (I assume in .text). The following line will result with the requested change:

    void (* const interruptVectors[])(void) __attribute__ ((section (".intvecs"))) __attribute__((used))=
    {
    ...
    }

    I cannot recreate the issue in CCS with ARM GCC 4.9.3, the __attribute__((used)) makes no difference. The map file shows that the .intvecs section is 0xe4 long.

    Maybe the CCS GCC linker does it a bit differently. Could you please tell me what linker options you using so I recreate it with the standalone GCC support package?

    Thanks,

    Bob Heilmaier

  • Hi Bob,

    yes, I am using standalone GCC. I just figured out what the issue was, I put the Interrupt Vectors in a cpp files and put it in an extern "C" {}. Then the .intvecs section is empty in the map file (the handlers are still present). When I put everything in the C file, the intvecs section is there (does not matter whether used is specified or not).

    Don't know why this happens, maybe it is a bug the optimizer of gcc.

    Cheers,

    Dan

  • Hey Dan,

    good to hear that you're not gated by this issue.

    I'll try to get in touch with our experts and hope to come back soon with some details.

    Thanks,
    Bob