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/TM4C129XNCZAD: TI ARM v20.2.3.LTS compiler doesn't seem to support code alignment

Part Number: TM4C129XNCZAD

Tool/software: TI C/C++ Compiler

The ARM Optimizing C/C++ Compiler v20.2.0.LTS User's Guide says that either of the following can be used to control the alignment of the starting address for a function:

  • The CODE_ALIGN Pragma
  • The GCC-style aligned function attribute

However, with the TI ARM v20.2.3.LTS compiler neither of those mechanisms seem to work:

  1. Trying to use the CODE_ALIGN Pragma results in warning #163-D: unrecognized #pragma
  2. Trying to use the GCC-style aligned function attribute doesn't report a warning, but the linker map shows the function starting address has not been given the requested alignment. The generated assembler, saved with --keep_asm, doesn't show any .align assembler directive used for the function.

The attached project demonstrates this, in that attempted to set 32-byte alignment on the test and main function using the two mechanisms. The addresses from the linker map show the requested alignment has not been set:

000002a9  main                          
0000029f  test                          

code_align_ARM.zip

I found the CODE_ALIGN and aligned function attribute do work with the C2000 v20.2.3.LTS compiler; in the generate assembler you can see the compiler emits .align assembler directives.

Is it a bug in the TI ARM compiler that the CODE_ALIGN and aligned function attribute don't work, or should they be removed from the user's guide?

A work-around for functions which require alignment on their starting address is to place them in their own section and specify the alignment for the section in the linker command file.

  • Thank you for notifying us of this problem, and submitting a concise test case.  I can reproduce the same result.  I filed the issue EXT_EP-10161 to have this investigated.  You are welcome to follow it at that link.

    Chester Gillon said:
    Is it a bug in the TI ARM compiler that the CODE_ALIGN and aligned function attribute don't work, or should they be removed from the user's guide?

    The pragma will either be added to the compiler, or removed from the manual.  At this point, I'm not sure which way the development team will go.

    Thanks and regards,

    -George