Using arm-elf-run

Jump to: navigation, search

...to simulate ARM code with WinARM/ARM-GCC

arm-elf-run is an ARM simulator that is part of GDB and is included in WinARM and the ARM-GCC packages from embdev.net.

main.c: <c>

  1. include <stdio.h>

int main(void) {

 puts("Hello World");
 return 0;

} </c>

newlib-syscalls.c

# Compile
arm-elf-gcc -o main.elf -g main.c newlib-syscalls.c

# Run
arm-elf-run main.elf
Hello World!

# Debug
arm-elf-gdb main.elf
(gdb) target sim
Connected to the simulator.
(gdb) load
Loading section .init, size 0x20 vma 0x8000
Loading section .text, size 0x2f70 vma 0x8020
Loading section .fini, size 0x1c vma 0xaf90
Loading section .rodata, size 0x1c vma 0xafac
Loading section .eh_frame, size 0x4 vma 0xafc8
Loading section .ctors, size 0x8 vma 0xb0cc
Loading section .dtors, size 0x8 vma 0xb0d4
Loading section .jcr, size 0x4 vma 0xb0dc
Loading section .data, size 0x934 vma 0xb0e0
Start address 0x8100
Transfer rate: 116896 bits in <1 sec.
(gdb) list
1       #include <stdio.h>
2        
3       int main(void)
4       {
5         puts("Hello World");
6        
7         return 0;
8       }
(gdb) break 5
Breakpoint 1 at 0x8218: file main.c, line 5.
(gdb) run
Starting program: /private/tmp/main.elf 

Breakpoint 1, main () at main.c:5
5         puts("Hello World");
(gdb) cont
Continuing.
Hello World

Program exited normally.

Questions on this topic? Ask them in the ARM GCC Forum