语法高亮,滚动条美化,设置页面调整

This commit is contained in:
fofolee
2019-04-19 02:41:09 +08:00
parent 1e8f76c000
commit 359d29ee0b
1590 changed files with 12328 additions and 11441 deletions

View File

@@ -3,7 +3,7 @@
<h2 id="补充说明">补充说明</h2>
<p><strong>objdump命令</strong> 是用查看目标文件或者可执行的目标文件的构成的gcc工具。</p>
<h3 id="选项">选项</h3>
<pre><code>--archive-headers
<pre><code class="language-bash">--archive-headers
-a
显示档案库的成员信息,类似ls -l将lib*.a的信息列出。
@@ -122,8 +122,8 @@ objdump -b oasys -m vax -h fu.o
@file 可以将选项集中到一个文件中,然后使用这个@file选项载入。</code></pre>
<h3 id="实例">实例</h3>
<p>首先,在给出后面大部分测试所基于的源代码以及编译指令。 源代码如下: </p>
<pre><code>root@localhost [test]# nl mytest.cpp </code></pre>
<pre><code>void printTest() {
<pre><code class="language-bash">root@localhost [test]# nl mytest.cpp </code></pre>
<pre><code class="language-bash">void printTest() {
char a;
a = &#39;a&#39;;
}
@@ -133,27 +133,27 @@ int a = 2;
a+=2;
} </code></pre>
<p>对以上源代码进行编译,如下: </p>
<pre><code>[root@localhost test]# g++ -c -g mytest.cpp </code></pre>
<pre><code class="language-bash">[root@localhost test]# g++ -c -g mytest.cpp </code></pre>
<p>这里生成的文件是mytest.o为了方便测试包含了调试的信息对可执行文件的测试显示的结果类似。 </p>
<p><strong>查看当前使用的objdump的版本号 </strong></p>
<pre><code>[root@localhost test]# objdump -V
<pre><code class="language-bash">[root@localhost test]# objdump -V
GNU objdump 2.17.50.0.6-14.el5 20061020
Copyright 2005 free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License. This program has absolutely no warranty. </code></pre>
<p><strong>查看档案库文件中的信息: </strong></p>
<pre><code>[root@localhost test]# objdump -a libmy2.a
<pre><code class="language-bash">[root@localhost test]# objdump -a libmy2.a
In archive libmy2.a:
myfile.o: file format elf32-i386
rwxrwxrwx 0/0 2724 Nov 16 16:06 2009 myfile.o
mytest.o: file format elf32-i386
rw-r--r-- 0/0 727 Jul 13 15:32 2011 mytest.o </code></pre>
<p>**这里libmy2.a是一个使用ar命令将多个*.o目标文件打包而生成的静态库。命令的输出类似<code>ar -tv</code>,相比较<code>ar -tv</code>输出如下: **</p>
<pre><code>[root@localhost test]# ar -tv libmy2.a
<pre><code class="language-bash">[root@localhost test]# ar -tv libmy2.a
rwxrwxrwx 0/0 2724 Nov 16 16:06 2009 myfile.o
rw-r--r-- 0/0 727 Jul 13 15:32 2011 mytest.o </code></pre>
<p>显示可用的架构和目标结构列表: </p>
<pre><code>[root@localhost test]# objdump -i
<pre><code class="language-bash">[root@localhost test]# objdump -i
BFD header file version 2.17.50.0.6-14.el5 20061020
elf32-i386
(header little endian, data little endian)
@@ -207,14 +207,14 @@ trad-core
i386 tekhex binary ihex --------- </code></pre>
<p>这里,显示的信息是相对于 -b 或者 -m 选项可用的架构和目标格式列表。 </p>
<p><strong>显示mytest.o文件中的text段的内容 </strong></p>
<pre><code>[root@localhost test]# objdump --section=.text -s mytest.o
<pre><code class="language-bash">[root@localhost test]# objdump --section=.text -s mytest.o
mytest.o: file format elf32-i386
Contents of section .text:
0000 5589e583 ec10c645 ff61c9c3 5589e583 U......E.a..U...
0010 ec10c745 fc020000 008345fc 02c9c3 ...E......E.... </code></pre>
<p>这里注意,不能单独使用-j或者section例如<code>objdump --section=.text mytest.o</code>是不会运行成功的。 </p>
<p><strong>反汇编mytest.o中的text段内容并尽可能用源代码形式表示 </strong></p>
<pre><code>[root@localhost test]# objdump -j .text -S mytest.o
<pre><code class="language-bash">[root@localhost test]# objdump -j .text -S mytest.o
mytest.o: file format elf32-i386
Disassembly of section .text:
00000000 &lt;_Z9printTestv&gt;:
@@ -245,7 +245,7 @@ void printTest2()
1e: c3 ret </code></pre>
<p>这里注意,不能单独使用-j或者section例如<code>objdump -j .text mytest.o是不会运行成功的</code>。另外-S命令对于包含调试信息的目标文件显示的效果比较好如果编译时没有指定g++的-g选项那么目标文件就不包含调试信息那么显示效果就差多了。 </p>
<p><strong>反汇编出mytest.o的源代码: </strong></p>
<pre><code>[root@localhost test]# objdump -S mytest.o
<pre><code class="language-bash">[root@localhost test]# objdump -S mytest.o
mytest.o: file format elf32-i386
Disassembly of section .text:
@@ -278,7 +278,7 @@ void printTest2()
1e: c3 ret </code></pre>
<p>这里,尤其当编译的时候指定了-g这种调试参数时反汇编的效果比较明显。隐含了-d参数。 </p>
<p><strong>显示文件的符号表入口: </strong></p>
<pre><code>[root@localhost test]# objdump -t mytest.o
<pre><code class="language-bash">[root@localhost test]# objdump -t mytest.o
mytest.o: file format elf32-i386
SYMBOL TABLE:
@@ -299,12 +299,12 @@ SYMBOL TABLE:
00000000 *UND* 00000000 __gxx_personality_v0
0000000c g F .text 00000013 _Z10printTest2v </code></pre>
<p>这里,输出的信息类似<code>nm -s</code>命令的输出相比较之下nm命令的输出如下 </p>
<pre><code>[root@localhost test]# nm -s mytest.o
<pre><code class="language-bash">[root@localhost test]# nm -s mytest.o
0000000c T _Z10printTest2v
00000000 T _Z9printTestv
U __gxx_personality_v0 </code></pre>
<p><strong>显示文件的符号表入口,将底层符号解码并表示成用户级别: </strong></p>
<pre><code>[root@localhost test]# objdump -t -C mytest.o
<pre><code class="language-bash">[root@localhost test]# objdump -t -C mytest.o
mytest.o: file format elf32-i386
SYMBOL TABLE:
00000000 l df *ABS* 00000000 mytest.cpp
@@ -325,7 +325,7 @@ SYMBOL TABLE:
0000000c g F .text 00000013 printTest2() </code></pre>
<p>这里,和没-C相比printTest2函数可读性增加了。 </p>
<p><strong>反汇编目标文件的特定机器码段: </strong></p>
<pre><code>[root@localhost test]# objdump -d mytest.o
<pre><code class="language-bash">[root@localhost test]# objdump -d mytest.o
mytest.o: file format elf32-i386
Disassembly of section .text:
@@ -347,7 +347,7 @@ Disassembly of section .text:
1e: c3 ret </code></pre>
<p>这里对text段的内容进行了反汇编。 </p>
<p><strong>反汇编特定段,并将汇编代码对应的文件名称和行号对应上: </strong></p>
<pre><code>[root@localhost test]# objdump -d -l mytest.o
<pre><code class="language-bash">[root@localhost test]# objdump -d -l mytest.o
mytest.o: file format elf32-i386
Disassembly of section .text:
@@ -378,7 +378,7 @@ _Z10printTest2v():
1e: c3 ret </code></pre>
<p>这里,项“-d”从objfile中反汇编那些特定指令机器码的section而使用“-l”指定用文件名和行号标注相应的目标代码仅仅和-d、-D或者-r一起使用使用-ld和使用-d的区别不是很大在源码级调试的时候有用要求编译时使用了-g之类的调试编译选项。 </p>
<p><strong>显示目标文件各个段的头部摘要信息: </strong></p>
<pre><code>[root@localhost test]# objdump -h mytest.o
<pre><code class="language-bash">[root@localhost test]# objdump -h mytest.o
mytest.o: file format elf32-i386
Sections: