arm非对齐访问编译器选项

-munaligned-access
-mno-unaligned-access  

Enables (or disables) reading and writing of 16- and 32- bit values from addresses that are not 16- or 32- bit aligned. By default unaligned access is disabled for all pre-ARMv6, all ARMv6-M and for ARMv8-M Baseline architectures, and enabled for all other architectures. If unaligned access is not enabled then words in packed data structures are accessed a byte at a time.

The ARM attribute Tag_CPU_unaligned_access is set in the generated object file to either true or false, depending upon the setting of this option. If unaligned access is enabled then the preprocessor symbol __ARM_FEATURE_UNALIGNED is also defined.

默认arm都是aligend-access,然而如果代码里有使用__attribute__((packed))等参数定义结构体时,会出现结构体成员是pack的也就是非对齐的,此时如果没有使能允许非对齐访问(对结构体成员赋值等操作)会导致abort。

你可能感兴趣的:(arm非对齐访问编译器选项)