I am working with a group migrating from GCC 4.3 to 4.7 (changing from CodeSourcery 2009q1 to Linaro 4.7) for an TI ARM A15 multicore. On recompiling userland code, we note alignment trap errors and a fatal SIGBUS.
Nov 25 22:07:43 keystone-evm kernel: [ 7947.432109] Alignment trap: lte_rrm_FDD (1786) PC=0x0001a3ea Instr=0xe9ca0100 Address=0xb63ed073 FSR 0xa21
Nov 25 22:07:43 keystone-evm kernel: [ 7947.436129] Alignment trap: lte_rrm_FDD (1786) PC=0x000acc20 Instr=0xed878a00 Address=0x0036807f FSR 0xa21
Nov 25 22:07:43 keystone-evm kernel: [ 7947.436131] Alignment trap: not handling instruction ed878a00 at [<000acc20>]
Nov 25 22:07:43 keystone-evm kernel: [ 7947.436133] Unhandled fault: alignment exception (0xa21) at 0x0036807f
I note issues with access at odd numbered addresses. Adding the cflag “-mno-unaligned-access” seems not to fix the issue, so I believe the compiler is not aware it is generating unaligned accesses.
I understand one cause for this involves casting pointers to types that are not aligned w.r.t. the original data.
The current desire is to return compiler behavior to the earlier version’s and not rewrite code or data structures. Can you suggest a method to do this?
I have suggested using the the gcc aligned attribute. It seems the __packed directive may also help. Are there other ways to accomplish a fix?