This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Alignment issues after upgrading to Linaro 4-7

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?

 

  • Hi, Scott,

    Could you send me the source code so I can try with v4.7 compiler?

    Rex

  • For the record, the toolchain used was arm-linux-gnueabihf-, which specifies hardware floating point by default (default settings copied below). ARM HW Float requires aligned operands or a SIGBUS will result. Fixed point math with unaligned operands is possible.

    THe two solutions to this issue are: 1) ensure all float operations are aligned or 2) use the multilib feature to generate software emulated floating point at a cost to performance. Multilib example is below.

     

    arm-linux-gnueabihf-gcc -print-multi-lib
    .;
    arm-linux-gnueabi;@marm@march=armv4t@mfloat-abi=soft


    arm-linux-gnueabihf-gcc -mfloat-abi=soft -marm -march=armv4t align.c

    arm-linux-gnueabihf-gcc -v
    Using built-in specs.
    COLLECT_GCC=arm-linux-gnueabihf-gcc
    COLLECT_LTO_WRAPPER=/home/stater/bin/linaro-4.7/bin/../libexec/gcc/arm-linux-gnueabihf/4.7.3/lto-wrapper
    Target: arm-linux-gnueabihf
    Configured with: /cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/src/gcc-linaro-4.7-2013.03/configure --build=i686-build_pc-linux-gnu --host=i686-build_pc-linux-gnu --target=arm-linux-gnueabihf --prefix=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/install --with-sysroot=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/install/arm-linux-gnueabihf/libc --enable-languages=c,c++,fortran --enable-multilib --with-arch=armv7-a --with-tune=cortex-a9 --with-fpu=vfpv3-d16 --with-float=hard --with-pkgversion='crosstool-NG linaro-1.13.1-4.7-2013.03-20130313 - Linaro GCC 2013.03' --with-bugurl=https://bugs.launchpad.net/gcc-linaro --enable-__cxa_atexit --enable-libmudflap --enable-libgomp --enable-libssp --with-gmp=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/arm-linux-gnueabihf/build/static --with-mpfr=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/arm-linux-gnueabihf/build/static --with-mpc=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/arm-linux-gnueabihf/build/static --with-ppl=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/arm-linux-gnueabihf/build/static --with-cloog=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/arm-linux-gnueabihf/build/static --with-libelf=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/arm-linux-gnueabihf/build/static --with-host-libstdcxx='-L/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/arm-linux-gnueabihf/build/static/lib -lpwl' --enable-threads=posix --disable-libstdcxx-pch --enable-linker-build-id --enable-gold --with-local-prefix=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/install/arm-linux-gnueabihf/libc --enable-c99 --enable-long-long --with-mode=thumb
    Thread model: posix
    gcc version 4.7.3 20130226 (prerelease) (crosstool-NG linaro-1.13.1-4.7-2013.03-20130313 - Linaro GCC 2013.03)