Help me please with gnu assembler for arm926ejs cpu.
I try to build a simple program(test.S):
.global _start
_start:
mov r0, #2
bx lr
and success build it:
arm-none-linux-gnueabi-as -mthumb -o test.o test.S
arm-none-linux-gnueabi-ld -o test test.o
but when I run the program in the arm target linux environment, I get an error:
./test
Segmentation fault
What am I doing wrong? Can _start function be the thumb func? or It is always arm func?
Your problem is you end with
and you expect Linux to take over after that. That exact line must be the cause of
Segmentation fault
.You can try to create a minimal executable then try to bisect it to see the guts and understand how an executable is expected to behave.
See below for a working example:
compile with
and dump to see the guts
Now you should notice the odd address of
_start