1

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?

1
  • In most cases you can just return from the entry point (i.e. BX LR on ARM), the OS/loader should take care of shutting down the process. Commented Feb 9, 2012 at 12:23

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

OK, I've added a new link instead of the broken one.
0

teensy.s

.global _start .thumb_func _start: mov r0, #42 mov r7, #1 svc #0 

Makefile

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 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.