I have board with an arm920t cpu (AT91RM9200). On the target Linux:
root@test-device:/home/andy # uname -a
Linux test-device 2.6.21.201509.01 #13 Wed Jun 22 11:06:51 EEST 2016 armv4tl unknown
On the my host machine I use virtual machine Ubuntu 18.04 as a system to cross-compile. At the my Ubuntu I have 2 packages for cross-compling:
- arm-linux-gnueabi
- arm-none-eabi
Try to build simply hello world
include
int main()
{
printf("Hello world\n");
return 0;
}
I do it from each of packages
1. supersonic@ubuntu-vBox:~$ arm-linux-gnueabi-gcc -o hello_arm hello.c -static
2. supersonic@ubuntu-vBox:~$ arm-none-eabi-gcc -o hello_arm_none-eabi hello.c --specs=nosys.specs
In both cases I got 2 executables binary readelf and file utils say:
1. (arm-linux-gnueabi)
supersonic@ubuntu-vBox:~$ readelf -h hello_arm
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: ARM
Version: 0x1
Entry point address: 0x101a0
Start of program headers: 52 (bytes into file)
Start of section headers: 501788 (bytes into file)
Flags: 0x5000200, Version5 EABI, soft-float ABI
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 7
Size of section headers: 40 (bytes)
Number of section headers: 30
Section header string table index: 29
supersonic@ubuntu-vBox:~$
supersonic@ubuntu-vBox:~$ file hello_arm
hello_arm: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, for GNU/Linux 3.2.0, BuildID[sha1]=15d06e43de8c8d13d7e0110e311532a9187ca9e5, not stripped
2. (arm-none-eabi)
supersonic@ubuntu-vBox:~$ readelf -h hello_arm_none-eabi
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: ARM
Version: 0x1
Entry point address: 0x8148
Start of program headers: 52 (bytes into file)
Start of section headers: 186056 (bytes into file)
Flags: 0x5000200, Version5 EABI, soft-float ABI
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 3
Size of section headers: 40 (bytes)
Number of section headers: 27
Section header string table index: 24
supersonic@ubuntu-vBox:~$ file hello_arm_none-eabi
hello_arm_none-eabi: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, with debug_info, not stripped
Uploaded both files to the target machine, seted permission to execute
root@test-device:/home/andy # chmod +x hello_arm
root@test-device:/home/andy # chmod +x hello_arm_none-eabi
When I try to launch each of this binaries, got following results
(arm-linux-gnueabi)
root@test-device:/home/andy # ./hello_arm Illegal instruction
(arm-none-eabi)
root@test-device:/home/andy # ./hello_arm_none-eabi Segmentation fault
On the target machine located old working binary, but developer who made it in curent time not available and he contacts was lost
This is working binary readelf and file utils say about it:
supersonic@ubuntu-vBox:~$ readelf -h /media/share_rw/MTXReader
ELF Header:
Magic: 7f 45 4c 46 01 01 01 61 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: ARM
ABI Version: 0
Type: EXEC (Executable file)
Machine: ARM
Version: 0x1
Entry point address: 0xab1c
Start of program headers: 52 (bytes into file)
Start of section headers: 681968 (bytes into file)
Flags: 0x2, GNU EABI, <unknown>
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 8
Size of section headers: 40 (bytes)
Number of section headers: 38
Section header string table index: 35
supersonic@ubuntu-vBox:~$ file /media/share_rw/MTXReader
/media/share_rw/MTXReader: ELF 32-bit LSB executable, ARM, version 1 (ARM), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.0.10, with debug_info, not stripped
Also try build my "hello world" with options
1. supersonic@ubuntu-vBox:~$ arm-linux-gnueabi-gcc -o hello_arm hello.c -static -mcpu=arm920t -march=armv4t
2. supersonic@ubuntu-vBox:~$ arm-none-eabi-gcc -o hello_arm_none-eabi hello.c --specs=nosys.specs -mcpu=arm920t -march=armv4t
But with same results
Any idea why this happened and what to do?