-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Description
For Arm targets (e.g. cortex-r5), using the “.arm” directive in hand-coded assembly does not have the same behavior with the LLVM integrated assembler as for GNU as. The directive will ensure that succeeding instructions are correctly interpreted as Arm-mode instructions, but it won’t enforce a 4byte alignment on instructions (or corresponding sections). In order to do this, a user has to explicitly align sections using an alignment directive.
There is no Arm-determined specification governing the “.arm” directive alignment behavior. Further, the documentation for the .arm and .thumb directives in the GNU assembler makes no mention of alignment (https://sourceware.org/binutils/docs/as/ARM-Directives.html#ARM-Directives)
However, because the GNU assembler (GAS) implements the 4-byte alignment behavior, the LLVM integrated Arm assembler should match that behavior. This was recommended by Arm in a (now-abandoned) code review: https://reviews.llvm.org/D110580
See attached sample.s.txt
Build for GCC cross-compiler: arm-none-eabi-gcc -nostartfiles -mcpu=cortex-r5 -o sample sample.s