Seg when executing arm-elf-gcc compiled code

Using MacPorts, I just installed arm-elf-gcc on my MacBook Pro. This worked flawlessly and everything seems to be working fine.

However, after compiling a simple hi-world test program in C and C ++ and trying to run either on the target board (based on ARM9, on which Debian Linux is installed), they immediately detect an error.

I got a little stuck on how to debug this, as the target board has limited tools and no gdb. I have successfully created and run different code using a cross compiler with Linux, so it should work.

Any ideas?

Following the suggestion, I created and launched gdbserver, I got the following in gdb on the host:

SIGSEGV program signal, segmentation error. 0x00000000 in ?? ()

I thought this might be a problem with standard c libs, so I deleted any calls and had only an empty main returning 0, it compiled with -Wall -g hello-arm.cpp -static. As a test, I compiled the same source with the Linux cross compiler, which works and crashes. The only difference that I see is that the version of compiled Linux is twice as large and the difference in the output from the file command:

arm-elf-gcc: ELF 32-bit LSB executable, ARM, version 1, statically linked, not shared

arm - * - linux: ELF 32-bit LSB executable, ARM, version 1, statically linked, for GNU / Linux 2.4.18, not stripping

+3
source share
2

- gdbserver ( ethernet) gdb, .

"Hello World", Mac, () Linux, , .

+2

. arm-elf-gcc, MacPorts, arm-unknown-linux, Linux-. pdf " GNU", :

: GNU GNU Linker, --, . , GNU . , C, ( ) .. . , , -v .

! . , : , , printf .

, dev , , Linux, arm-elf-gcc.

, , , - .

+1

Source: https://habr.com/ru/post/1773822/


All Articles