binutils工具集之---objdump
在嵌入式软件开发中,有时需要知道所生成的程序文件中的段信息以分析问题,或者需要查看c语言对应的汇编代码,此时,objdump工具就可以帮大忙了。obj——object dump:转储。
#include<stdio.h>
#include<time.h> int global1;
int global2=; static int static_global1;
static int static_global2=; void foo()
{
static int internal1;
static int internal2=;
time();
} static void bar()
{ }
int main(void)
{
int local1;
int local2=;
foo();
return ;
}



采用 -d选项,可以查看程序文件的汇编代码:

在使用-d进行反汇编时,另一个很有用的选项就是-S(大写),它的作用是告诉objdump在反汇编时同时显示汇编代码对应的c/c++源程序。

想查看对应反汇编,一定要在编译的时候加上-g选项生成debug信息,否则不会成功:


-f选项可以显示程序文件的头信息。

objdump另一个非常有用的选项是-s(小写),将它与-j参数配合使用,能查看某一个段中的具体内容。

更多指令参考man或者info介绍:
-s
--full-contents
Display the full contents of any sections requested. By default
all non-empty sections are displayed.
-S
--source
Display source code intermixed with disassembly, if possible.//这下知道为什么刚才说的要加上-g生成调试信息了把,-S并不是强制显示程序文件,而是
Implies -d. //在可能的情况下,进行显示,所以要想可能,就加上-g生成调试信息。
-d
--disassemble
Display the assembler mnemonics for the machine instructions from
objfile. This option only disassembles those sections which are
expected to contain instructions.
-D
--disassemble-all
Like -d, but disassemble the contents of all sections, not just
those expected to contain instructions.
This option also has a subtle effect on the disassembly of
instructions in code sections. When option -d is in effect objdump
will assume that any symbols present in a code section occur on the
boundary between instructions and it will refuse to disassemble
across such a boundary. When option -D is in effect however this
assumption is supressed. This means that it is possible for the
output of -d and -D to differ if, for example, data is stored in
code sections.
If the target is an ARM architecture this switch also has the
effect of forcing the disassembler to decode pieces of data found
in code sections as if they were instructions.
-h
--section-headers
--headers
Display summary information from the section headers of the object
file.
File segments may be relocated to nonstandard addresses, for
example by using the -Ttext, -Tdata, or -Tbss options to ld.
However, some object file formats, such as a.out, do not store the
starting address of the file segments. In those situations,
although ld relocates the sections correctly, using objdump -h to
list the file section headers cannot show the correct addresses.
Instead, it shows the usual addresses, which are implicit for the
target.
-m machine
--architecture=machine
Specify the architecture to use when disassembling object files.
This can be useful when disassembling object files which do not
describe architecture information, such as S-records. You can list
the available architectures with the -i option.
If the target is an ARM architecture then this switch has an
additional effect. It restricts the disassembly to only those
instructions supported by the architecture specified by machine.
If it is necessary to use this switch because the input file does
not contain any architecture information, but it is also desired to
disassemble all the instructions use -marm.
以上列出的,都是在之后arm开发板上会用到的。
binutils工具集之---objdump的更多相关文章
- binutils工具集之---addr2line
addr2line用于得到程序指令地址所对应的函数,以及函数所在的源文件名和行号. 在不少嵌入式开发环境中,编译器的名称往往不是gcc,而是想arm-rtems-gcc这样的,对于这种命名形式的编译器 ...
- Binutils工具集常用工具
GNU为GCC编译器提供了配套的辅助工具集(Binutils)http://www.gnu.org/software/binutils/ 1. addr2line ①将指定地址转换为对应的文件名和行号 ...
- 静态库动态库的编译、链接, binutils工具集, 代码段\数据段\bss段解释
#1. 如何使用静态库 制作静态库 (1)gcc *.c -c -I../include得到o文件 (2) ar rcs libMyTest.a *.o 将所有.o文件打包为静态库,r将文件插入静态库 ...
- binutils工具集之---nm
nm用于列出程序文件中的符号.建立nmtest.c文件: #include<time.h> int global1; ; static int static_global1; ; void ...
- Makefile 学习&binutils工具集,软件开发利器
gcc -E 能有效的帮助我们解决与宏有关的编译错误: gcc -S能获得一个C源程序文件的汇编程序: gcc -v能获得系统头文件的路径 生成依赖关系: gcc -M gcc -MM 生成不包含系统 ...
- binutils工具集之---ar
1.如果要将多个.o文件生成一个库文件,则存在两种类型的库,一种是静态库,在linux里面后缀是.a,另一种是动态库,后缀为.so. 当可执行程序要与静态库进行链接时,所用到的库中的函数和数据会被拷贝 ...
- binutils工具集之---objcopy,ranlib,size,strings,strip
objcopy的作用是拷贝一个目标文件的内容到另一个目标文件中.objcopy使用GNU BFD库去读或写目标文件.objcopy可以使用不同于源目标文件的格式来写目的目标文件(也即是说可以将一种格式 ...
- GNU Binutils工具
参考<程序员的自我修养---连接.装载与库> 以下内容转贴自 http://www.cnblogs.com/xuxm2007/archive/2013/02/21/2920890.html ...
- Open Source 开发工具集
Open Source 开发工具集 转自:http://www.linuxforum.net原作者:gogoliu(Pooh-Bah) 编辑器: vi:老牌编辑器,在各个unix和unix-like平 ...
随机推荐
- 剖析ASP.NET Core(Part 2)- AddMvc(译)
原文:https://www.stevejgordon.co.uk/asp-net-core-mvc-anatomy-addmvccore发布于:2017年3月环境:ASP.NET Core 1.1 ...
- SEO之巴莱多定律
SEO这个词在2007.2008年好像特别的火,尤其在2007年下半年至今,众多SEO爱好者发起了最大的一轮搜索引擎优化研究风暴,甚至最终逼迫百度等大型搜索引擎公司改变算法. SEO,确实能带来一些经 ...
- 流畅的python第九章符合Python风格的对象学习记录
对象表示形式 每门面向对象的语言至少都有一种获取对象的字符串表示形式的标准方式.Python提供了两种方式 repr()便于开发者理解的方式返回对象的字符串表示形式 str()便于用户理解的方式返回对 ...
- EasyUI-子页面增加显示tabs的一个问题
在父页面点个链接能动态看到子页面的情况太简单,请看easyUI官网:http://www.jeasyui.com/tutorial/layout/tabs2.php现在说的是在子页面点个按钮也能触发增 ...
- 职场二年级转型C++的困惑
[来信] 老师.你好.看了你的博客和採訪.不由主自地给你发私信,感觉你能解答我的问题. 学生90后,2012年毕业于某不知名院校.两年工作经验(第一年C#,第二年java,直到如今),一直想转型C++ ...
- ssh远程连接
SSH 是Secure Shell protocol 的简写,经由将联机的封包加密的技术,来进行资料的传递,安全. telnet: tcp:23 基于字符 任意客户端登录远程服务器 明文 无需验证 易 ...
- C#注释——爱你不是两三天
说到注释这个东东,我不得不说:爱你不是两三天,每天却想你很多遍...原来梁静茹同学这首歌不全然是情歌啊~ 一句注释也没有的一大片的代码有木有 看着那些无名者写的神秘代码,有没有骂一句,你妹的... ...
- NoSQL的CURD结构体的定义
NoSQL的CURD结构体的定义 flyfish 2015-7-23 參考MongoDB Wire Protocol 在这里document部分使用json表示 使用boost::property_ ...
- 【DB2】查询上月末、上年末、上年同期等信息
此处以20180612为例子 想得到上年末.上年同期.上月末这些时间点,只需要记住函数ADD_MONTHS.LAST_DAY.ADD_YEARS这些函数即可. 上年末 SELECT SUBSTR(TO ...
- JConsole的使用手册 JDK1.5(转)
一篇Sun项目主页上介绍JConsole使用的文章,前段时间性能测试的时候大概翻译了一下以便学习,今天整理一下发上来,有些地方也不知道怎么翻,就保留了原文,可能还好理解点,呵呵,水平有限,翻的不好,大 ...