Creating .elf from assembler

Guest #2585701
Hello,

I am trying to create an .elf file from ARM assembly code needed for 
ARMulator.

But whenever I try to compile the code with arm-elf-gcc, I get a 'bad 
instruction' error for every sing line, but compiling the code under 
keil makes no problem.

The code:
1
   AREA    test, CODE, READWRITE
2
SWI_Exit    EQU &11
3
     ENTRY
4
    ADR    r0, A
5
  MOV    r1, #15
6
  STR    r1, [r0]
7
  SWI    SWI_Exit
8
A  =    0
9
  END

Neither arm-elf-gcc -o arm.elf arm.s
nor arm-elf-gcc -mthumb -Bstatic arm.s -o arm.elf
as suggested on the ARMulator's site are working.

I am already so desperate, as I can't find any proper tutorial or any 
more information on that.
So I would very much appreciate ur guys help, as I also need that for my 
uni coursework.

Cheers,
Jimmy
Guest
arm-elf-gcc (to be more specific the GNU Assembler) has another syntax 
than Keil Assembler. You would need to rewrite this KEIL assembler 
source code. Starting points are of course the Keil User Manual and the 
GNU Assembler Manual (gas).

Keil:
http://www.keil.com/support/man/docs/armasm/armasm_CEGFDGED.htm
http://www.keil.com/support/man/docs/armasm/armasm_Chdehaic.htm

gas:
http://sourceware.org/binutils/docs/as/

The line
> AREA test, CODE, READWRITE
will translate in something like
.section test, "awx"
or
.section .test, "awx"
If you look in such kind of code, you will find examples in the net e.g.
http://www.zap.org.au/elec2041-cdrom/unsw/elec2041/experiment5.pdf
that you can use as starter.

Hint: In order to have a section test, you need the proper linker 
control script with the memory layout as well! IMHO it's much easier to 
look for an assembler tutorial with usage of the GNU toolchain than 
struggling with two unkowns - Keil/GNU translation and ARM learning.

Reply

A question of your own? This thread is over 14 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.