I have two binary files generated via 'objcopy -O binary' from respective ELF files. The ELF files are built with arm-none-linux-gnueabi toolchains; one is from linaro gcc 4.6.2 and other is from codesourcery gcc 4.6.3.

I load the binary files into memory via Uboot. While the one built with Linaro executes as expected the one built with codesourcery crashes (most probably as) there is no error on Uboot prompt but the program seems to hang.

Using 'arm-none-linux-gnueabi-readelf -S' from binutils of respective toolchains does not show much difference between files except for address offsets. Are there any tools/techniques that can help in this kind of situation before I attempt runtime debugging on target.

Thanks!

有帮助吗?

解决方案

The difference turned out to be compiler option -munaligned-access. Code Sourcery toolchain enables this by default for ARMv6 and later architectures. http://gcc.gnu.org/gcc-4.7/changes.html

Although this appeared in upstream gcc in 4.7 version, Code Sourcery had added this support earlier in their tool chain.

To figure this out I tracked the data abort exception and then compiled the culprit file with -save-temps options. Comparing intermediate .s file provided the hint.

其他提示

What I can advice you is to compare default flags both compilers were built with:

/path/to/cross-compiler/bin/arm-*-*-gcc -Q -v

And preprocessor definitions:

/path/to/cross-compiler/bin/arm-*-*-gcc -dM -E - < /dev/null

The reason why your code compiled using Linaro GCC works is fact, that it may have some options enabled by default, when CodeSourcery one may have not.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top