Reputation: 394
I've toyed with the idea of learning an assembly language, and have decided to give ARM a try. I've decided to go with the GNU assembler, mostly because it's available in my cellphone's repository, so that I could play around with assembly anywhere, if I'm bored.
Anyway, I've searched the web, but I can't find any kind of reference for how to properly exit an ARM Linux binary. I've understood that the x86 equivalent basically sets the eax register to a number specifying the system call, and then calls system interrupt 0x80 to actually perform the system call, properly exiting the program; now I want to do something similar for ARM (and obviously the same code doesn't work, since it uses x86 specific registers and whatnot).
So yeah, basically, how would I write a minimal GAS ARM executable, simply exiting normally with exit value 0?
Upvotes: 1
Views: 1873
Reputation: 28087
.global _start
.thumb_func
_start:
mov r0, #42
mov r7, #1
svc #0
CROSS_COMPILE?=arm-linux-gnueabihf-
teensy:
$(CROSS_COMPILE)as teensy.s -o teensy.o
$(CROSS_COMPILE)ld teensy.o -o teensy
ls -l teensy
$(CROSS_COMPILE)objdump -d teensy.o
$(CROSS_COMPILE)readelf -W -a teensy
clean:
rm teensy teensy.o
Upvotes: 0
Reputation: 30999
There is some information on system calls at http://www.arm.linux.org.uk/developer/patches/viewpatch.php?id=3105/4. You can also look at page 5 of http://isec.pl/papers/into_my_arms_dsls.pdf.
Upvotes: 1