gcc編譯選項:
-munaligned-access
gcc編譯選項:
-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。