With the GNU ARM Toolchain installed, enter the following two lines in the terminal.
arm-elf-as --gdwarf2 -mcpu=arm7tdmi -o FILENAME.o FILENAME.s
arm-elf-ld -o FILENAME.elf FILENAME.o
Where FILENAME.s is the name of your ARM assembly code file.
A few quick notes: the parameter 'gdwarf2' is used to maintain debugging information inside the file. It will come in handy when using arm-elf-gdb. The mcpu parameter tells the assembler what architecture the file is to be targeted towards.
Alternatively, copy the following code (EDIT: and replace the three indents on lines 21, 24, and 28 with tabs!), and save it as '
makefile' in the same directory as the .s file. Anytime you need to create an ELF file using
filename.s, simply type '
make filename.elf'.
Download
makefile
#
# Makefile for ARM Projects
# Author: S Hodgson
# Date: July 2011
#
# Usage: make filename.elf
# i.e. if helloworld.s is the ARM assembly code,
# execute 'make helloworld.elf'
#
# Linker and Assembler
LD = arm-elf-ld
AS = arm-elf-as
# Flags
DBGFLAG = --gdwarf2
ARCH = -mcpu=arm7tdmi
# Create Files
%.elf : %.o
$(LD) -o $@ $^
%.o : %.s
$(AS) $(DBGFLAG) $(ARCH) -o $@ $^
# Clean - Warning: Removes ALL object and elf files
clean:
rm -rf *.o *.elf
Edit: As Patrick pointed out, the indentation MUST be tabs, not spaces...