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.

Linker warning about .init_array without SECTIONS specification

I'm starting off with a new project in Code Composer Studio 4.1.2.00027, for the LM3S6611 processor.

I started a new project from scratch using CCS New > New CCS Project feature, which generated a lms6611.cmd linker script (is that correct term?)

I copied the startup_ccs.c file from one of the example projects and then added my source code files.

Everything builds OK but I get a linker warning "warning: creating output section ".init_array" without a SECTIONS specification"

The only other thing I did was check the treate C files as C++ files option (cmd line option --cpp_default, -fg) for all the .c files, except the start_ccs.c file as it had compiler errors when I did that.

I can see the SECTIONS specification in the .cmd file, I don't know where .init_array is getting generated, I don't even know if this is a real problem or something I can ignore, I'm kind of stuck. Any help would be appreciated.

Thanks,

Matt Schuckmann

  • Hi Matthew,

    I think your question will be answered by the CCS folks, I am going to transfer your question to their forum.

    Lela

  • The section .init_array is generated by the compiler for your C++ global variable constructors. What the linker warning is saying is that this section is being created but the linker command file does not have a SECTIONS specification to tell it where to allocate it. The linker will still allocate it to some default region, which you can look at in the generated link map file (.map). If you wish to change the memory region where it is allocated, you need to add a SECTIONS specification for this section in the linker command file.

  • As I stated before, I have a SECTIONS specification in the linker command file.

    Maybe there is something wrong with it even though it was generated by CCS,
    Below is the linker command file:

    ******************************************************************************
     *
     * Default Linker Command file for the Texas Instruments LM3S6611
     *
     * This is part of revision 5745 of the Stellaris Peripheral Driver Library.
     *
     *****************************************************************************/

    --retain=g_pfnVectors

    /* The starting address of the application.  Normally the interrupt vectors  */
    /* must be located at the beginning of the application.                      */
    #define APP_BASE 0x00001000 //Offset the application 4K from the start to leave room for the boot loader application

    MEMORY
    {
        FLASH (RX) : origin = APP_BASE, length = 0x0001F000 //   0x00020000 - APP_BASE
        SRAM (RWX) : origin = 0x20000000, length = 0x00008000
    }

    /* The following command line options are set as part of the CCS project.    */
    /* If you are building using the command line, or for some reason want to    */
    /* define them here, you can uncomment and modify these lines as needed.     */
    /* If you are using CCS for building, it is probably better to make any such */
    /* modifications in your CCS project and leave this file alone.              */
    /*                                                                           */
    --heap_size=0                                                           
    --stack_size=256                                                        
    --library=rtsv7M3_T_le_eabi.lib                                          




    /* Section allocation in memory */

    SECTIONS
    {
        .intvecs:   > APP_BASE
        .text   :   > FLASH
        .const  :   > FLASH
        .cinit  :   > FLASH
        .pinit  :   > FLASH

        .vtable :   > 0x20000000
        .data   :   > SRAM
        .bss    :   > SRAM
        .sysmem :   > SRAM
        .stack  :   > SRAM
    }

    __STACK_TOP = __stack + 256;

  • The SECTIONS specification is there but missing allocation for the .init_array section. You can add a line within the SECTIONS specification such as shown below to avoid the warning:

    SECTIONS
    {
        .intvecs:   > APP_BASE
        .text   :   > FLASH
        ...
       .init_array > FLASH
       ...
       ...
    }

     

  • Sweet thank you, I'm surprised CCS new project wizard didn't add that and that that it isn't showing in the sample linker command file in the manual.

    Matt Schuckmann

  • For most cases, the default linker command file will suffice when working with C source files, since this .init_array section is only generated for C++ global variable constructors. Also the default allocation done by the linker when you don't specify a memory region would likely be ok, but it is always best to heed such warnings and have control over the allocation.

  • I just started working with the C++ compiler (as opposed to C).

    The .init_array : > FLASH

    Solved my problem as well. The program built -- but with the warning.

    There are other issues as well with having to declare some functions as extern -- for interrupt vectors.

    Is there any document showing a clean way to set up a C++ program with the Eclipse system and compiler -- version CCS 5.2 actual Compiler 5.02 I believe.

    I cannot fiind any document that explains these C++ quirks.

  • Thank you everyone for diagnosing and pointing out this problem.  If you look at the projects that are provided in StellarisWare, you will see that this section appears in the linker command files.  However, for the linker command scripts that are bundled with CCS to be used with the new project wizard, we have not added this section.  We will change this and it will be picked up in a future release of CCS.  In the meantime, if you plan to use C++, you can either modify the provided linker script to add this section, or else use a linker script from one of the StellarisWare projects.

  • Dave Robinson said:
    There are other issues as well with having to declare some functions as extern -- for interrupt vectors.

    I don't know what you mean.  Please start a new thread, not another post in this mostly unrelated thread, which details this problem.  We will need a test case, for sure.

    Thanks and regards,

    -George