View Single Post
Posts: 7 | Thanked: 0 times | Joined on Jun 2010
#9
Thank you for all the resources

After reading through some of these documents, I realize it will take some time to learn arm assembly, so could someone possibly give me a "leg up" so to speak? Here is the source code for a C program and the output of gdb and I would like if someone could help me understand the logical flow of the program. Like if you could step me through the programs disassembly and explain each step?

Main.c:
Code:
#include <stdio.h>
int main()

{
  
   printf("Hello, world!\n");

   return 0;

}
GDB output:
Code:
(gdb) break main
Breakpoint 1 at 0x838c: file main.c, line 5.
(gdb) run
Starting program: /home/user/a.out 

Breakpoint 1, main () at main.c:5
5	  printf("Hello, world!\n");
(gdb) disassemble main
Dump of assembler code for function main:
0x00008380 <main+0>:	mov	r12, sp
0x00008384 <main+4>:	push	{r11, r12, lr, pc}
0x00008388 <main+8>:	sub	r11, r12, #4	; 0x4
0x0000838c <main+12>:	ldr	r0, [pc, #8]	; 0x839c <main+28>
0x00008390 <main+16>:	bl	0x82cc <printf>
0x00008394 <main+20>:	mov	r0, #0	; 0x0
0x00008398 <main+24>:	ldm	sp, {r11, sp, pc}
0x0000839c <main+28>:	andeq	r8, r0, r8, lsr #8
End of assembler dump.
(gdb) x/s 0x8428
0x8428:	 "Hello, world!\n"
My main problem with understanding the disassembly is that my last command reveals the "Hello, world!\n" string at the address 0x00008428, yet I see nowhere in the programs disassembly where it points to this address to printf() it?

Again, any help is appreciated!