On Thu, Sep 27, 2012 at 4:09 AM, Michael Hope <michael.hope@linaro.org> wrote:
On 27 September 2012 01:06, Shivamurthy Shastri
<shiva.linuxworks@gmail.com> wrote:
> On Wed, Sep 26, 2012 at 6:28 PM, Fathi Boudra <fathi.boudra@linaro.org>
> wrote:
>>
>> On 26 September 2012 15:44, Shivamurthy Shastri
>> <shiva.linuxworks@gmail.com> wrote:
>> > Hi,
>> >
>> > I am using Linaro Toolchain for compiling UEFI and I am getting
>> > alignment
>> > fault as exception while running UEFI on Origen Board.
>> > When I was using other cross compilers the issue was not there.
>> > The crash report is as follows:
>> >
>> >
>> > Data Abort Exception PC at 0x4F84DCDC  CPSR 0x60000133 nZCveAifT_svc
>> >
>> > /home/shiva/workspace/armserver/uefi_origen/edk2/Build/OrigenBoard-Exynos/DEBUG_ARMLINUXGCC/ARM/FatPkg/EnhancedFatDxe/Fat/DEBUG/Fat.dll
>> > loaded at 0x4F84D000 (PE/COFF offset) 0xCDC (ELF or Mach-O offset) 0xA9C
>> > 0xF8BD6037   LDRH   r6, [sp, #0x37]
>> >   R0 0x0000000B   R1 0x0000000A   R2 0x4FCEEAD8   R3 0x80000000
>> >   R4 0x4F836010   R5 0x4F863619   R6 0x00000000   R7 0x4F837F10
>> >   R8 0xFFFFFFFF   R9 0x00000000  R10 0x00000001  R11 0x00000000
>> >  R12 0x00000000   SP 0x4FCEEA20   LR 0x4F84DCDD   PC 0x4F84DCDC
>> > DFSR 0x00000001 DFAR 0x4FCEEB17 IFSR 0x0000140B IFAR 0x00910883
>> >  Alignment fault: read from 0x4FCEEB17
>> >  Instruction Domain fault on Page at 0x00910883
>> >
>> > ASSERT
>> >
>> > /home/shiva/workspace/armserver/uefi_origen/edk2/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandler.c(304):
>> > ((BOOLEAN)(0==1))
>>
>> Could you try to add -mno-unaligned-access flag.
>> See
>> http://git.linaro.org/gitweb?p=arm/uefi/uefi-next.git;a=commitdiff;h=228b8242e9675bef9f739326281fcb027e5946e3
>>
>> Cheers,
>> --
>> Fathi Boudra
>> Linaro Release Manager | LAVA Project Manager
>> Linaro.org | Open source software for ARM SoCs
>
>
>
> I tried that, but I am unable to solve the problem.

Hi Shiva.  The instruction in your dump looks suspicious:
  LDRH   r6, [sp, #0x37]

sp should be eight byte aligned, so this ends up doing a half word
load from an odd address.  Could you upload the build log and a
pre-built version of Fat.dll somewhere so I can have a look?

Note that the CPU supports unaliged access out of reset.  You have to
manually turn the unaligned access trap on and that's probably
happening somewhere in your startup routines.

-- Michael

Hi Michael,

I was using code sourcery toolchain which has not given this problem. Meanwhile I have not changed any code of UEFI.
But, I am getting problem with the linaro toolchain. Below are the toolchain details.

CodeSourcery toolchain:
shiva@shiva:/usr/local/arm/arm/bin$ ./arm-none-linux-gnueabi-gcc -v
Using built-in specs.
Target: arm-none-linux-gnueabi
Configured with: /scratch/julian/2010q1-release-linux-lite/src/gcc-4.4-2010q1/configure --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=arm-none-linux-gnueabi --enable-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch --enable-extra-sgxxlite-multilibs --with-arch=armv5te --with-gnu-as --with-gnu-ld --with-specs='%{funwind-tables|fno-unwind-tables|mabi=*|ffreestanding|nostdlib:;:-funwind-tables} %{O2:%{!fno-remove-local-statics: -fremove-local-statics}} %{O*:%{O|O0|O1|O2|Os:;:%{!fno-remove-local-statics: -fremove-local-statics}}}' --enable-languages=c,c++ --enable-shared --disable-lto --enable-symvers=gnu --enable-__cxa_atexit --with-pkgversion='Sourcery G++ Lite 2010q1-202' --with-bugurl=https://support.codesourcery.com/GNUToolchain/ --disable-nls --prefix=/opt/codesourcery --with-sysroot=/opt/codesourcery/arm-none-linux-gnueabi/libc --with-build-sysroot=/scratch/julian/2010q1-release-linux-lite/install/arm-none-linux-gnueabi/libc --with-gmp=/scratch/julian/2010q1-release-linux-lite/obj/host-libs-2010q1-202-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --with-mpfr=/scratch/julian/2010q1-release-linux-lite/obj/host-libs-2010q1-202-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --with-ppl=/scratch/julian/2010q1-release-linux-lite/obj/host-libs-2010q1-202-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-cloog=/scratch/julian/2010q1-release-linux-lite/obj/host-libs-2010q1-202-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --disable-libgomp --enable-poison-system-directories --with-build-time-tools=/scratch/julian/2010q1-release-linux-lite/install/arm-none-linux-gnueabi/bin --with-build-time-tools=/scratch/julian/2010q1-release-linux-lite/install/arm-none-linux-gnueabi/bin
Thread model: posix
gcc version 4.4.1 (Sourcery G++ Lite 2010q1-202) 

Linaro toolchain:
shiva@shiva:/usr/local/arm/gcc-linaro-arm-linux-gnueabihf-2012.08-20120827_linux/bin$ ./arm-linux-gnueabihf-gcc -v
Using built-in specs.
COLLECT_GCC=./arm-linux-gnueabihf-gcc
COLLECT_LTO_WRAPPER=/usr/local/arm/gcc-linaro-arm-linux-gnueabihf-2012.08-20120827_linux/bin/../libexec/gcc/arm-linux-gnueabihf/4.7.2/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: /cbuild/slaves/oort12/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/src/gcc-linaro-4.7-2012.08/configure --build=i686-build_pc-linux-gnu --host=i686-build_pc-linux-gnu --target=arm-linux-gnueabihf --prefix=/cbuild/slaves/oort12/crosstool-ng/builds/arm-linux-gnueabihf-linux/install --with-sysroot=/cbuild/slaves/oort12/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-2012.08-20120827 - Linaro GCC 2012.08' --with-bugurl=https://bugs.launchpad.net/gcc-linaro --enable-__cxa_atexit --enable-libmudflap --enable-libgomp --enable-libssp --with-gmp=/cbuild/slaves/oort12/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/arm-linux-gnueabihf/build/static --with-mpfr=/cbuild/slaves/oort12/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/arm-linux-gnueabihf/build/static --with-mpc=/cbuild/slaves/oort12/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/arm-linux-gnueabihf/build/static --with-ppl=/cbuild/slaves/oort12/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/arm-linux-gnueabihf/build/static --with-cloog=/cbuild/slaves/oort12/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/arm-linux-gnueabihf/build/static --with-libelf=/cbuild/slaves/oort12/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/arm-linux-gnueabihf/build/static --with-host-libstdcxx='-L/cbuild/slaves/oort12/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/oort12/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.2 20120731 (prerelease) (crosstool-NG linaro-1.13.1-2012.08-20120827 - Linaro GCC 2012.08) 

--
Thanks and Regards,
Shiva.