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.

Changing source of function-scope array initializations

Dear all,

I'm using TI ARM Code Generation Tools 5.1.6.

If I've got an array or structure in a function which needs initialization, this is done during run-time, and is copied from the .const section with the no_stm_memcpy_t2 function. Example:


#pragma SET_CODE_SECTION(".LIB_CODE") void foo(void) { char x[100] = {1,2,3}; // These 100 bytes for x will be copied from .const to the stack when the function is called. (void)x; }
#pragma SET_CODE_SECTION()

Can the source of these memcpy calls be changed, maybe for specific code sections? I would like to allocate these initializers to one specific memory range (maybe linked together .LIB_CODE), but would not put the whole .const section to that memory range, if possible.

Thanks in advance for your reply.

Best regards,

Laszlo Treszkai

  • Here is a solution to consider.  The compiler places this string of constants ...

    Laszlo Treszkai said:
    char x[100] = {1,2,3};

    in the section named ".const:.string".  You cannot directly affect that section name.  But, if this function is in a file by itself, you can control it in the linker command file like this ...

        special_string_section {
           file.obj(.const:.string)
        } > SPECIAL_MEMORY_RANGE
    

    Line 1 is the name of the output section.  Line 2 refers to the input section .const:.string from file.obj.  Change "file" to the source file name.  Line 3 is the name of the memory range where this output section is allocated.

    Thanks and regards,

    -George