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:
- Trying to use the CODE_ALIGN Pragma results in warning #163-D: unrecognized #pragma
- 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
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.