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/TMS320C6657: problem in ti_cpp_init

Part Number: TMS320C6657

Tool/software: TI C/C++ Compiler

Hello,

I'm using compiler 7.4.24 and my C++ design is stuck in ti_cpp_init.

It is probably a problem of static initialization order.

Is there a way to force the order in .init_array ?

Regards,

David

  • I understand that throught .init_array ti_cpp_init calls some generated code.

    Is it possible to have access to the C/C++ generated code in order to do some symbolic debug ?

  • David Pardessus said:
    Is there a way to force the order in .init_array ?

    Yes.  I presume your linker command file has an entry similar to ...

        .init_array > RAM

    Change that to something similar to ...

        .init_array
        {
           file3.obj(.init_array)  /* LAST  */
           file2.obj(.init_array)
           file1.obj(.init_array)  /* FIRST */
           *(.init_array)
        } > RAM
    

    Line 1 starts the creation of an output section named .init_array.  Lines 3-5 specify that this output section is made up of those input sections also named .init_array, from object files with those names.  At startup time, the constructors for the global objects in file1.obj are called first, followed by file2.obj, then file3.obj.  I hate to admit I don't know why it works this way.  That needs more investigation.  To verify the order in which the constructors are called, look for lines like these in the linker map file ...

    .init_array 
    *          0    80007018    0000000c     
                      80007018    00000004     file1.obj (.init_array)
                      8000701c    00000004     file2.obj (.init_array)
                      80007020    00000004     file3.obj (.init_array)
    

    That is the order in which they get called.

    For the case of multiple objects getting constructed from within a single file, there is no way to control the order.

    You may get a linker diagnostic similar to ...

    "linker_command_file.cmd", line 6: warning: section specifier matches no
       sections; potential matches are consumed by section specifier at
       "linker_command_file.cmd", line 3

    That just means the specification *(.init_array) matches no input sections.  It can be ignored.

    Thanks and regards,

    -George

  • David Pardessus said:
    Is it possible to have access to the C/C++ generated code in order to do some symbolic debug ?

    All of the compiler RTS library source code, including the startup code, is part of the compiler distribution.  If you have Code Composer Studio installed on a Windows system, this would be a typical directory path ...

    C:\ti\ccs930\ccs\tools\compiler\ti-cgt-c6000_8.3.5\lib\src

    Thanks and regards,

    -George

  • Hello,

    Forcing init_array in the linker command file works (note on 7.4.24, the order is not reversed) but doesn't resolve my problem (I'm stuck in another init method)

    Concerning the generated code, I already have access to the rts source : my need is to debug the source of the __sti_name_of_obj_xxxxx methods (called by init_array) which does initialization things in my back.

    Indeed, it seems to be generated code that does more things than just simply call the constructor

    Regards,

    David

  • David Pardessus said:
    my need is to debug the source of the __sti_name_of_obj_xxxxx methods (called by init_array) which does initialization things in my back.

    Those methods never exist in the form of C++ code, only assembly code auto-generated by the compiler.  

    Here is one idea to consider.  Build with the compiler options --opt_level=0 --src_interlist.  This optimizes the code at the lowest level, tells the compiler to keep the auto-generated assembly code, and adds comments to that code that make it easier to understand.  The assembly files have the extension .asm.  You will be able to read through the comments to see what a specific method does.

    Thanks and regards,

    -George