tech_log: March 2009

Monday, March 23, 2009

Examining your ARM asm of a compiled elf of u-boot

Note: u-boot.bin is in bin format, not in elf. For arm-linux-objdump dissassembly use the other image, u-boot (no extension) :
arm-linux-objdump -DSt u-boot > u-boot.dis<br /><br />
If you see the code "mixed up", i.e. some instructions that come later in C code now perceed or come in between of some instructions in asm, that might be because optimization is switched on for gcc, and it tries to find best possible arrangement of asm instructions.

For better inspection and in order that asm instructions come in the same order as the ones in the C counterpart program, find -Os optimization options in CFLAGS, and switch it off (delete it).

Saturday, March 21, 2009

qemu-arm/arm-linux-gnu-gdb Remote Debugging

1) start QEMU:
drasko@Marx:~/arm$ qemu-arm -L /usr/arm-linux-gnu/ -g 1234 hello

2) QEMU is now started and hangs on waiting on coming connetction from the remote GDB on port 1234

3) Open new terminal and start GDB:
drasko@Marx:~/arm$ arm-linux-gnu-gdbtui

4) In  GDB:(gdb) file hello
Reading symbols from /home/drasko/arm/hello...done.
(gdb) target remote localhost:1234
Remote debugging using localhost:1234
[New Thread 1]
0x40081860 in ?? () from /usr/arm-linux-gnu/lib/ld-linux.so.2
(gdb) b main
Breakpoint 1 at 0x84f4: file hello.c, line 23.
(gdb) c
Continuing.

Breakpoint 1, main () at hello.c:23
(gdb)