|
|
|
|
 如何生成符号表 - Hillside [ 2006-04-27 10:50 | 269 byte(s)]
 Re: 如何生成符号表 - daiyuwen [ 2006-04-27 13:22 | 256 byte(s)]
 Re: 如何生成符号表 - Hillside [ 2006-04-28 09:26 | 179 byte(s)]
 Re: 如何生成符号表 - grip2 [ 2006-05-16 15:48 | 2,961 byte(s)]
|
|
|
|
[Original]
[Print]
[Top]
|
书上说gdb加参数symbols <file> 可以从指定的文件中读取符号表。
请问
如何生成符号表文件?
另外加载特定符号表有什么用图?
是不是在加载符号表以后就不需要编译的时候加 -g?
本人新手才入门大家不要见笑。
|
|
|
[Original]
[Print]
[Top]
|
|
[Original]
[Print]
[Top]
|
加了-g选择后生成的ELF文件含有符号信息。加载这个文件就可以了。 你现在碰到什么样的问题了?如果在GDB里执行
b main
这样的命令能成功,说明已经有符号表了。 GDB也会在file 命令之后,告诉你它读取了什么文件里的符号表。
|
|
|
[Original]
[Print]
[Top]
|
|
[Original]
[Print]
[Top]
|
|
并没有碰到什么问题,只是在书里提到gdb有symbols这个选项能在后面指定一个特定的符号表,想知道symbols这个选项指定的符号表是如何生成的。换句话说就是想知道如何使用gdb的symbols这个选项。
|
|
|
[Original]
[Print]
[Top]
|
|
[Original]
[Print]
[Top]
|
grip2@debian:~/tmp$ gcc foo.c -o foo -ggdb
grip2@debian:~/tmp$ objcopy --only-keep-debug foo foo.dbg
grip2@debian:~/tmp$ strip -s foo
grip2@debian:~/tmp$ gdb foo
GNU gdb 6.3-debian
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-linux"...(no debugging symbols found)
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) p main
No symbol table is loaded. Use the "file" command.
(gdb) q
grip2@debian:~/tmp$ objcopy --add-gnu-debuglink=foo.dbg foo
grip2@debian:~/tmp$ gdb foo
GNU gdb 6.3-debian
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-linux"...Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) p main
$1 = {int (int, char **)} 0x8048334 <main>
(gdb) q
grip2@debian:~/tmp$ mv foo.dbg foo_sym.dbg
grip2@debian:~/tmp$ gdb foo -q
(no debugging symbols found)
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) p main
No symbol table is loaded. Use the "file" command.
(gdb) q
grip2@debian:~/tmp$ gdb --symbols=foo_sym.dbg -exec=foo -q
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) p main
$1 = {int (int, char **)} 0x8048334 <main>
(gdb) r
Starting program: /home/grip2/tmp/foo
Program exited normally.
(gdb)
|
|
|
----
为什么你要我握着你的手?因为和你在一起,我感觉很温暖
|
|
[Original]
[Print]
[Top]
|
|
|