URN Logo
UNIX Resources » Linux » China Linux Forum » CPU 与 编译器 » 4 » 如何生成符号表
announcement 声明: 本页内容为中国Linux论坛的内容镜像,文章的版权以及其他所有的相关权利属于中国Linux论坛和相应文章的作者,如果转载,请注明文章来源及相关版权信息。
Resources
China Linux Forum(finished)
Linux Forum(finished)
FreeBSD China(finished)
linuxforum.net
  业界新闻与评论
  自由软件杂谈
  IT 人生
  Linux软件快递
  翻译作坊
  Linux图书与评论
  GNU Emacs/XEmacs
  Linux 中文环境和中文化
  Linux桌面与办公软件
  Linux 多媒体与娱乐版
  自由之窗Mozilla
  笔记本电脑上的Linux
  Gentoo
  Debian 一族
  网络管理技术
  Linux 安装与入门
  WEB服务器和FTP服务器
  域名服务器和邮件服务器
  Linux防火墙和代理服务器应用
  文件及打印服务器
  技术培训与认证
  Linux内核技术
  Linux 嵌入技术
  Linux设备驱动程序
  Linux 集群技术
  LINUX平台数据库
  系统和网络安全
  CPU 与 编译器
  系统计算研究所专栏
  Linux下的GUI软件开发
  C/C++编程版
  PHP 技 术
  Java&jsp技术
  Shell编程技术
  Perl 编 程
  Python 编 程
  XML/Web Service 技术
  永远的Unix
  FreeBSD世界
   
如何生成符号表
如何生成符号表 - 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)]
 
Subject: 如何生成符号表
Author: Hillside    Posted: 2006-04-27 10:50    Length: 269 byte(s)
[Original] [Print] [Top]
书上说gdb加参数symbols <file> 可以从指定的文件中读取符号表。
请问
如何生成符号表文件?
另外加载特定符号表有什么用图?
是不是在加载符号表以后就不需要编译的时候加 -g?

本人新手才入门大家不要见笑。
[Original] [Print] [Top]
Subject: Re: 如何生成符号表
Author: daiyuwen    Posted: 2006-04-27 13:22    Length: 256 byte(s)
[Original] [Print] [Top]
加了-g选择后生成的ELF文件含有符号信息。加载这个文件就可以了。 你现在碰到什么样的问题了?如果在GDB里执行

b main

这样的命令能成功,说明已经有符号表了。 GDB也会在file 命令之后,告诉你它读取了什么文件里的符号表。
[Original] [Print] [Top]
Subject: Re: 如何生成符号表
Author: Hillside    Posted: 2006-04-28 09:26    Length: 179 byte(s)
[Original] [Print] [Top]
并没有碰到什么问题,只是在书里提到gdb有symbols这个选项能在后面指定一个特定的符号表,想知道symbols这个选项指定的符号表是如何生成的。换句话说就是想知道如何使用gdb的symbols这个选项。
[Original] [Print] [Top]
Subject: Re: 如何生成符号表
Author: grip2    Posted: 2006-05-16 15:48    Length: 2,961 byte(s)
[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]
« Previous thread
请问在哪儿下载歌载lex和yacc
CPU 与 编译器
4
Next thread »
问一个gcc对数组处理的问题
     

Copyright © 2007 UNIX Resources Network, All Rights Reserved.      About URN | Privacy & Legal | Help | Contact us
备案序号: 京ICP备05006143    webmaster: webmaster@unixresources.net
This page created on 2008-07-17 03:47:15, cost 0.059948921203613 ms.