everyone. I used newest cross_compiler(installed by sudo apt install gcc-arm-linux-gnueabi on Ubuntu 18.04,version is 7.3)to compile a simple "hello world" c program
#include <stdio.h>
int main()
{
printf("Hello World!\r\n");
return 0;
}
used command below to compile the code,i used static link
arm-linux-gnueabi-gcc -o hello hello.c -static
Then i first ran it on my raspberry pi0w,and it ran very well After that,i ran it on my s3c2440 board,which is ARM9 and very old core.However,it didnot run correctly.
# ./hello
Illegal instruction
I did not know why,and how to solve it.Then I used cross_compiler version 3.4.5 to compile it again,and the program ran smoothly this time.But it cannot run correctly on raspberry pi,after running the program,nothing happened."Hello World!" did not appear.
I used file command to check this two programs(don't know whether help or not ): the program compiled by newest compiler is:
hello: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, for GNU/Linux 3.2.0, BuildID[sha1]=6b0a4b6cb4bf672d4cf1fbd171ec62a96e622d69, not stripped
and by old compiler is:
hello_old: ELF 32-bit LSB executable, ARM, version 1 (ARM), statically linked, for GNU/Linux 2.4.3, with debug_info, not stripped
The newest arm-linux-gnueabi-gcc is
$ arm-linux-gnueabi-gcc -v
Using built-in specs.
COLLECT_GCC=arm-linux-gnueabi-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/arm-linux-gnueabi/7/lto-wrapper
Target: arm-linux-gnueabi
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 7.3.0-16ubuntu3' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --with-as=/usr/bin/arm-linux-gnueabi-as --with-ld=/usr/bin/arm-linux-gnueabi-ld --program-suffix=-7 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libquadmath --disable-libquadmath-support --enable-plugin --with-system-zlib --with-target-system-zlib --enable-multiarch --enable-multilib --disable-sjlj-exceptions --with-arch=armv5t --with-float=soft --disable-werror --enable-multilib --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=arm-linux-gnueabi --program-prefix=arm-linux-gnueabi- --includedir=/usr/arm-linux-gnueabi/include
Thread model: posix
gcc version 7.3.0 (Ubuntu/Linaro 7.3.0-16ubuntu3)
And the old cross_compiler I used is
$ arm-gcc-old -v
Reading specs from /work/gcc-3.4.5-glibc-2.3.6/bin/../lib/gcc/arm-linux/3.4.5/specs
Configured with: /work/tools/create_crosstools/crosstool-0.43/build/arm-linux/gcc-3.4.5-glibc-2.3.6/gcc-3.4.5/configure --target=arm-linux --host=i686-host_pc-linux-gnu --prefix=/work/tools/gcc-3.4.5-glibc-2.3.6 --with-float=soft --with-headers=/work/tools/gcc-3.4.5-glibc-2.3.6/arm-linux/include --with-local-prefix=/work/tools/gcc-3.4.5-glibc-2.3.6/arm-linux --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c,c++ --enable-shared --enable-c99 --enable-long-long
Thread model: posix
gcc version 3.4.5
What should I do to compile code correctly using newest compiler? The kernel on s3c2440 is
# uname -a
Linux (none) 2.6.22.6 #1 Thu May 31 14:02:09 CST 2018 armv4tl unknown
And that kernel was compiled by newest cross_compiler 7.3
Thanks!