So, did you know that gdb sometimes fails to load symbols from an elf file correctly? What a shame...
I've googled a lot, but all I could find is unanswered questions, a few links:
http://stackoverflow.com/questions/3012 ... ct-address
http://stackoverflow.com/questions/2533 ... e-function
https://www.sourceware.org/ml/gdb/2004-07/msg00107.html
Here's an example to demonstrate:
Code: Select all
$ objdump -d ps2.so
0000000000000169 <irq1>:
169: 66 b9 00 02 mov $0x200,%cx
....
Code: Select all
(gdb) hbreak irq1
Hardware assisted breakpoint 1 at 0x205081
(gdb) disass *0x205169
No function contains specified address.
(gdb)
Anyway if any of you face the same problem, the solution is simple, use 'add-symbol-file' instead of 'symbol-file' and add 0xe8 (the size of the ELF header) to the relocation address:
Code: Select all
(gdb) add-symbol-file bin/root/lib/sys/input/ps2.so 0x2050e8
add symbol table from file "bin/root/lib/sys/input/ps2.so" at
.text_addr = 0x2050e8
(y or n) y
Reading symbols from bin/root/lib/sys/input/ps2.so...(no debugging symbols found)...done.
(gdb) hbreak irq1
Hardware assisted breakpoint 1 at 0x205169
(gdb) disass irq1
Dump of assembler code for function irq1:
...
Happy debugging!