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/AWR1843: Change aligment of variables within a section

Part Number: AWR1843


Tool/software: TI C/C++ Compiler

Dear TI Team,

in our linker script we are using something like that:

    DUMMY_SECTION: fill=FILL_PATTERN, align=4, load > DUMMY
    {
    .=align(4);
        *(DUMMY_SECTION)
        .=align(4);
    }

This section contains some global variables, but these variables inside this section are not placed with a 32-bit alignment in ram. Is a special linker setting required?

If we use #pragma DATA_ALIGN(variable_in_section, 4) it works.

Regards,

Sergej

  • Please read the first part of the article Linker Command File Primer and get a good understanding of the terms input section and output section.  

    The problem is this code ...

    Sergej Pogrebnoj said:
       DUMMY_SECTION: fill=FILL_PATTERN, align=4, load > DUMMY
        {
        .=align(4);
            *(DUMMY_SECTION)
            .=align(4);
        }

    ... only affects the alignment of the output section.  The alignment of input sections within the output section remains unaffected.  

    The only way to affect the alignment of an input section is with the DATA_ALIGN pragma, or the equivalent gcc attribute aligned.  For details, please search the TI ARM compiler manual for the sub-chapter titled The DATA_ALIGN Pragma.

    Thanks and regards,

    -George

  • Thank you!

    I get it right, so there is no way to force 32 bit alignment for a input section with the linker script, just with the DATA_ALIGN pragma?

    Thanks again and regards,

    Sergej

  • Sergej Pogrebnoj said:
    there is no way to force 32 bit alignment for a input section with the linker script, just with the DATA_ALIGN pragma?

    Correct.  -George