红联Linux门户
Linux帮助

使用gdbserver调试arm程序

发布时间:2008-08-23 10:28:14来源:红联作者:chaian
在arm板上执行cat /proc/152/maps,查看进程的maps:

引用:
00008000-00034000 r-xp 00000000 1f:03 530 /UserData/roommonitor/stream_switch
0003b000-0003c000 rw-p 0002b000 1f:03 530 /UserData/roommonitor/stream_switch
40000000-40019000 r-xp 00000000 01:00 279 /lib/ld-2.2.3.so
40020000-40021000 rw-p 00018000 01:00 279 /lib/ld-2.2.3.so
40021000-40035000 r-xp 00000000 01:00 416 /lib/libroommonitor.so
40035000-40039000 ---p 00014000 01:00 416 /lib/libroommonitor.so
40039000-4003d000 rw-p 00010000 01:00 416 /lib/libroommonitor.so
4003d000-40061000 r-xp 00000000 01:00 415 /lib/libmysdk.so
40061000-40065000 ---p 00024000 01:00 415 /lib/libmysdk.so
40065000-40069000 rw-p 00020000 01:00 415 /lib/libmysdk.so
40069000-40079000 r-xp 00000000 1f:03 630 /UserData/roommonitor/libpthread-0.9.so
40079000-40087000 rw-p 00008000 1f:03 630 /UserData/roommonitor/libpthread-0.9.so
40087000-400fe000 r-xp 00000000 01:00 281 /lib/libm-2.2.3.so
400fe000-400ff000 ---p 00077000 01:00 281 /lib/libm-2.2.3.so
400ff000-40107000 rw-p 00070000 01:00 281 /lib/libm-2.2.3.so
40107000-4010a000 r-xp 00000000 1f:03 621 /UserData/roommonitor/libdl-2.2.3.so
4010a000-4010f000 ---p 00003000 1f:03 621 /UserData/roommonitor/libdl-2.2.3.so
4010f000-40112000 rw-p 00000000 1f:03 621 /UserData/roommonitor/libdl-2.2.3.so
40112000-4021e000 r-xp 00000000 01:00 280 /lib/libc-2.2.3.so
4021e000-40222000 ---p 0010c000 01:00 280 /lib/libc-2.2.3.so
40222000-4022c000 rw-p 00108000 01:00 280 /lib/libc-2.2.3.so


在386上执行以下命令得到.text的偏移量:

引用:
[hub@localhost gdb]$ arm-linux-objdump -h libmysdk.so | grep .text
5 .rel.text 00004738 000032dc 000032dc 000032dc 2**2
10 .text 00017d70 00007d54 00007d54 00007d54 2**2
[hub@localhost gdb]$ arm-linux-objdump -h libroommonitor.so | grep .text
5 .rel.text 00002790 000028f4 000028f4 000028f4 2**2
10 .text 0000c6c8 000052ec 000052ec 000052ec 2**2
[hub@localhost gdb]$ arm-linux-objdump -h libc-2.2.3.so | grep .text
15 .text 000da754 00020210 00020210 00020210 2**4
36 .gnu.warning.getcontext 0000003c 00000000 00000000 00469c2c 2**2
37 .gnu.warning.setcontext 0000003c 00000000 00000000 00469c68 2**2
38 .gnu.warning.makecontext 00000040 00000000 00000000 00469ca4 2**2
39 .gnu.warning.swapcontext 00000040 00000000 00000000 00469ce4 2**2
[hub@localhost gdb]$ arm-linux-objdump -h libpthread-0.9.so | grep .text
13 .text 00009c78 000054c4 000054c4 000054c4 2**2


计算动态库偏移量:

引用:
4003d000+00007d54=40044D54
40021000+000052ec=400262EC
40112000+00020210=40132210
40069000+000054c4=4006E4C4


在arm板上运行gdbserver :2345 --attach 152

在386上执行以下命令:

引用:
arm-linux-gdb
symbol-file ./stream_switch
add-symbol-file ./libmysdk.so 0x40044D54
add-symbol-file ./libroommonitor.so 0x400262EC
add-symbol-file ./libc-2.2.3.so 0x40132210
add-symbol-file ./libpthread-0.9.so 0x4006E4C4
target remote 10.123.15.132:2345
bt full
文章评论

共有 0 条评论