﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-心無雜念的空白-文章分类-嵌入式</title><link>http://www.cppblog.com/lshain/category/19182.html</link><description>Beyond this world...</description><language>zh-cn</language><lastBuildDate>Thu, 30 Aug 2012 22:21:16 GMT</lastBuildDate><pubDate>Thu, 30 Aug 2012 22:21:16 GMT</pubDate><ttl>60</ttl><item><title>文件名处理函数</title><link>http://www.cppblog.com/lshain/articles/172548.html</link><dc:creator>Lshain</dc:creator><author>Lshain</author><pubDate>Tue, 24 Apr 2012 00:49:00 GMT</pubDate><guid>http://www.cppblog.com/lshain/articles/172548.html</guid><description><![CDATA[<div>makefile 文件名处理函数</div><div></div><div>1. $(dir NAMES...)</div><div>函数名称：取目录函数--dir</div><div>函数功能: 从文件名序列"NAMES..."中取出各个文件名中的目录部分.</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 文件名的目录部分就是包含在文件名中的最后一个斜线("/")(包括斜线)之前的部分.</div><div>返回值: 空格分隔的文件名序列"NAMES..."中每个文件的目录部分.</div><div>函数说明: 如果文件名没有斜线，则认为此文件为当前目录("./")下的文件.</div><div></div><div>2. $(notdir NAMES...)</div><div>函数名称：取文件名函数--notdir</div><div>函数功能: 从文件名序列"NAMES..."中取出各个文件名中的非目录部分.</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 文件名的目录部分就是包含在文件名中的最后一个斜线("/")(包括斜线)之前的部分.</div><div>返回值: 空格分隔的文件名序列"NAMES..."中每个文件的非目录部分.</div><div>函数说明: 如果"NAMES..."中存在不包含斜线的文件名, 则不改变此文件名. 以反斜线结尾的</div><div>&nbsp; &nbsp; &nbsp; 文件名, 使用空串代替, 因此当&#8220;NAMES...&#8221;中存在多个这样的文件名时, 返回结果中分隔</div><div>&nbsp; &nbsp; &nbsp; 各个文件名的空格数不确定！(这是此函数的一个缺陷, 可以将结果调用strip函数格式化一下)</div><div>&nbsp; &nbsp; &nbsp;&nbsp;</div><div>3. $(suffix NAMES...)</div><div>函数名称：取后缀函数--suffix</div><div>函数功能: 从文件名序列"NAMES..."中取出各个文件名的后缀.</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 后缀就是以文件名中的最后一个"."(包括".")开始的部分. 如果文件名中不包含".", 则为空.</div><div>返回值: 空格分隔的文件名序列"NAMES..."中每个文件的后缀序列.</div><div>函数说明: 如果"NAMES..."是多个文件名时, 返回值是多个以空格分隔的单词序列. 如果文件名没有后缀</div><div>&nbsp; &nbsp; &nbsp; 部分, 则返回空.</div><div>&nbsp; &nbsp; &nbsp;&nbsp;</div><div>4. $(basename NAMES...)</div><div>函数名称：取前缀函数--basename</div><div>函数功能: 从文件名序列"NAMES..."中取出各个文件名的前缀.</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 前缀就是以文件名中的最后一个"."(不包括".")之前的部分. 如果文件名中不包含".", 则为其自身.</div><div>返回值: 空格分隔的文件名序列"NAMES..."中每个文件的前缀序列.</div><div>函数说明: 如果"NAMES..."是多个文件名时, 返回值是多个以空格分隔的单词序列. 如果文件名没有前缀</div><div>&nbsp; &nbsp; &nbsp; 部分, 则返回空.</div><div>&nbsp; &nbsp; &nbsp;&nbsp;</div><div>5. $(addsuffix SUFFIX, NAMES...)</div><div>函数名称：加后缀函数--addsuffix</div><div>函数功能: 为文件名序列"NAMES..."中的各个文件名添加后缀"SUFFIX"字串.</div><div>返回值: 单空格分隔的添加了后缀的文件名序列"NAMES...".</div><div></div><div>6. $(addprefix PREFIX, NAMES...)</div><div>函数名称：加前缀函数--addprefix</div><div>函数功能: 为文件名序列"NAMES..."中的各个文件名添加前缀"PREFIX"字串.</div><div>返回值: 单空格分隔的添加了前缀的文件名序列"NAMES...". &nbsp;</div><div></div><div>7. $(join LIST1, LIST2)</div><div>函数名称：单词连接函数--join.</div><div>函数功能：将字串"LIST1"和字串"LIST2"各单词进行对应连接.</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 就是将"LIST2"中的第一个单词追加"LIST1"第一个单词字后合并为一个单词;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 将"LIST2"中的第二个单词追加到"LIST1"的第一个单词之后并合并为一个单词, ...依次列推.</div><div>返回值：单空格分割的合并后的字(文件名)序列.</div><div>函数说明：如果"LIST1"和"LIST2"中的字数目不一致时, 两者中多余部分将被作为返回序列的一部分.</div><div></div><div>8. $(wildcard PATTERN)</div><div>函数名称：获取匹配模式文件名函数--wildcard</div><div>函数功能：列出当前目录下所有符合模式"PATTERN"格式的文件名.</div><div>返回值：空格分割的, 存在当前目录下的所有符合模式"PATTERN"的文件名.</div><div>函数说明："PATTERN"使用shell可识别的通配符, 包括"?"(单字符),"*"(多字符)等.</div><div></div><img src ="http://www.cppblog.com/lshain/aggbug/172548.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/lshain/" target="_blank">Lshain</a> 2012-04-24 08:49 <a href="http://www.cppblog.com/lshain/articles/172548.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>内嵌函数</title><link>http://www.cppblog.com/lshain/articles/172547.html</link><dc:creator>Lshain</dc:creator><author>Lshain</author><pubDate>Tue, 24 Apr 2012 00:49:00 GMT</pubDate><guid>http://www.cppblog.com/lshain/articles/172547.html</guid><description><![CDATA[<div>makefile 内嵌函数</div><div>1. $(subst FROM, TO, TEXT)</div><div>函数名称：字符串替换函数--subst</div><div>函数功能: 把串&#8221;TEXT&#8220;中的&#8220;FROM&#8221;字串替换为&#8220;TO&#8221;</div><div>返回值: 替换后的新字符串.&nbsp;</div><div></div><div>*2. $(patsubst PATTERN, REPLACEMENT, TEXT)</div><div>函数名称：字符串模式替换函数--patsubst</div><div>函数功能: 搜索&#8221;TEXT&#8220;中以空格分开的单词, 将符合模式"PATTERN"的部分替换为"REPLACEMENT".&nbsp;</div><div>&nbsp; &nbsp; &nbsp; 参数&#8220;PATTERN&#8221;中可以使用模式通配符"%"来代表一个单词中的若干字符.&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 如果参数"REPLACEMENT"中也包含一个"%", 那么"REPLACEMENT"中的"%"将是"PATTERN"</div><div>&nbsp; &nbsp; &nbsp; 中那个"%"所代表的字符串. 在"PATTERN"和"REPLACEMENT"中, 只有第一个"%"被作为模式</div><div>&nbsp; &nbsp; &nbsp; 字符来处理, 之后出现的不再作为模式字符(而是作为一个字符).</div><div>返回值: 替换后的新字符串串.&nbsp;</div><div></div><div>3. $(strip STRINT)</div><div>函数名称：去空格函数--strip</div><div>函数功能: 去掉字符串"STRINT"开头和结尾的空字符, 并将其中多个连续的空字符合并为一个空字符.</div><div>返回值: 无前导和结尾空字符，使用单一空格分隔的多单词字符串.</div><div>函数说明: 空字符包括空格，[Tab]等不可显字符.</div><div></div><div>4. $(findstring FIND, IN)</div><div>函数名称：查找字符串函数--findstring</div><div>函数功能: 搜索字符串"IN", 查找"FIND"字符串.</div><div>返回值: 如果在"IN"之中存在"FIND", 则返回"FIND", or 返回空.</div><div>函数说明: 字符串"IN"之中可以包含空格, [Tab]. 搜索是严格的文本匹配.</div><div></div><div>5. $(filter PATTERN..., text)</div><div>函数名称：过滤函数--filter</div><div>函数功能: 过滤字符串"TEXT"中所有不符合模式"PATTERN"的单词, 保留所有符合此模式的单词.</div><div>&nbsp; &nbsp; &nbsp; 可以使用多个模式. 模式中一般需要包含模式字符"%". 存在多个模式时, 模式表达式之</div><div>&nbsp; &nbsp; &nbsp; 间使用空格分隔. &nbsp; &nbsp;</div><div>返回值: 空格分隔的"TEXT"字符串中所有符合模式"PATTERN"的字符串.</div><div>函数说明: "filter"函数可以用来去除一个变量中的某些字符串. 选择我们需要的字符串子集.</div><div></div><div>6. $(filter-out PATTERN..., TEXT)</div><div>函数名称：返过滤函数--filter-out</div><div>函数功能: 和"filter"函数实现的功能相反. 过滤字符串"TEXT"中所有符合模式"PATTERN"的单词,&nbsp;</div><div>&nbsp; &nbsp; &nbsp; 保留所有不符合此模式的单词. 可以使用多个模式. 模式中一般需要包含模式字符"%".&nbsp;</div><div>&nbsp; &nbsp; &nbsp; 存在多个模式时, 模式表达式之间使用空格分隔. &nbsp; &nbsp;</div><div>返回值: 空格分隔的"TEXT"字符串中所有不符合模式"PATTERN"的字符串.</div><div>函数说明: "filter-out"函数也可以用来去除一个变量中的某些字符串. 选择我们需要的字符串子集.</div><div></div><div>7. $(sort LIST)</div><div>函数名称：排序函数--sort</div><div>函数功能: 给字串"LIST"中的单词以首字母为准进行升序排序, 并去掉重复的单词.</div><div>返回值: 空格分隔的没有重复单词的字串.</div><div>函数说明: 两个功能, 排序和去重. 可以单独使用其中一个功能.</div><div></div><div>8. $(word N, TEXT)</div><div>函数名称：取单词函数--word</div><div>函数功能: 取字串"TEXT"中的第N个单词(索引从1开始).</div><div>返回值: 返回字串"TEXT"中的第N个单词.</div><div>函数说明: 如果"N"的值大于字串'TEXT'中单词的数目, 返回空字符串. 如果&#8220;N&#8221;为0, 则出错.</div><div></div><div>8. $(wordlist S, E, TEXT)</div><div>函数名称：取字串函数--wordlist</div><div>函数功能: 从字串"TEXT"中取出从索引"S"开始到"E"(包括"E")的单词串(索引从1开始).</div><div>返回值: 返回字串"TEXT"中从索引"S"开始到"E"(包括"E")的单词串(索引从1开始).</div><div>函数说明: &#8220;S&#8221;和"E"都是从1开始的数字. 当"S"比"TEXT"中的字数大时, 返回空.&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 当"E"大于&#8220;TEXT&#8221;字数时， 返回从"S"开始到"TEXT"结束的单词串.&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 如果"S"大于"E", 返回空.</div><div></div><div>9. $(words TEXT) 返回"TEXT"中单词的个数.</div><div>10. $(firstword TEXT) 返回"TEXT"中第一个单词.</div><div></div><img src ="http://www.cppblog.com/lshain/aggbug/172547.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/lshain/" target="_blank">Lshain</a> 2012-04-24 08:49 <a href="http://www.cppblog.com/lshain/articles/172547.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>自动化变量</title><link>http://www.cppblog.com/lshain/articles/172546.html</link><dc:creator>Lshain</dc:creator><author>Lshain</author><pubDate>Tue, 24 Apr 2012 00:48:00 GMT</pubDate><guid>http://www.cppblog.com/lshain/articles/172546.html</guid><description><![CDATA[<div>$@</div><div>表示规则的目标文件名。</div><div>如果目标是一个文档文件（Linux中，一般称.a文件为文档文件，也称为静态库文件），那么它代表这个文档的文件名。在多目标模式规则中，它代表的是哪个触发规则被执行的目标文件名。</div><div>$%</div><div>当规则的目标文件是一个静态库文件时，代表静态库的一个成员名。例如，规则的目标是&#8220;foo.a(bar.o)&#8221;，那么，&#8220;$%&#8221;的值就为&#8220;bar.o&#8221;，&#8220;$@&#8221;的值为&#8220;foo.a&#8221;。如果目标不是静态库文件，其值为空。</div><div>$&lt;</div><div>规则的第一个依赖文件名。如果是一个目标文件使用隐含规则来重建，则它代表由隐含规则加入的第一个依赖文件。</div><div>$?</div><div>所有比目标文件更新的依赖文件列表，空格分割。如果目标是静态库文件名，代表的是库成员（.o文件）。</div><div>自动化变量&#8220;$?&#8221;在显式规则中也是非常有用的，使用它规则可以指定只对更新以后的依赖文件进行操作。例如，静态库文件&#8220;libN.a&#8221;，它由一些.o文件组成。这个规则实现了只将更新后的.o文件加入到库中：$(TARGET_LIB) : $(OBJS) ; ar -r $(TARGET_LIB) $?</div><div>$^</div><div>规则的所有依赖文件列表，使用空格分隔。如果目标是静态库文件，它所代表的只能是所有库成员（.o文件）名。一个文件可重复的出现在目标的依赖中，变量&#8220;$^&#8221;只记录它的一次引用情况。就是说变量&#8220;$^&#8221;会去掉重复的依赖文件。</div><div>$+</div><div>类似&#8220;$^&#8221;，但是它保留了依赖文件中重复出现的文件。主要用在程序链接时库的交叉引用场合。</div><div>$*</div><div>在模式规则和静态模式规则中，代表&#8220;茎&#8221;。&#8220;茎&#8221;是目标模式中&#8220;%&#8221;所代表的部分（当文件名中存在目录时，&#8220;茎&#8221;也包含目录（斜杠之前）部分）。例如：文件&#8220;dir/a.foo.b&#8221;，当目标的模式为&#8220;%.b&#8221;时，&#8220;$*&#8221;的值为&#8220;dir/a.foo&#8221;。&#8220;茎&#8221;对于构造相关文件名非常有用。</div><div>自动化变量&#8220;$*&#8221;需要两点说明：</div><div>1.对于一个明确指定的规则来说不存在&#8220;茎&#8221;，这种情况下&#8220;$*&#8221;的含义发生改变。此时，如果目标文件名带有一个可识别的后缀，那么&#8220;$*&#8221;表示文件中除后缀以外的部分。例如：&#8220;foo.c&#8221;则&#8220;$*&#8221;的值为：&#8220;foo&#8221;，因为.c是一个可识别的文件后缀名。GUN make对明确规则的这种奇怪的处理行为是为了和其它版本的make兼容。通常，在除静态规则和模式规则以外，明确指定目标文件的规则中应该避免使用这个变量。</div><div>2.当明确指定文件名的规则中目标文件名包含不可识别的后缀时，此变量为空。</div><div></div><img src ="http://www.cppblog.com/lshain/aggbug/172546.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/lshain/" target="_blank">Lshain</a> 2012-04-24 08:48 <a href="http://www.cppblog.com/lshain/articles/172546.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>foreach函数 if函数</title><link>http://www.cppblog.com/lshain/articles/172545.html</link><dc:creator>Lshain</dc:creator><author>Lshain</author><pubDate>Tue, 24 Apr 2012 00:47:00 GMT</pubDate><guid>http://www.cppblog.com/lshain/articles/172545.html</guid><description><![CDATA[<div>foreach 函数</div><div>函数"foreach"不同于其它函数. 它是一个循环函数.类似于Linux的shell中的for语句.</div><div>"foreach"函数的语法:&nbsp;</div><div>$(foreach VAR, LIST, TEXT)</div><div>函数功能：将LIST中的值依次赋值给VAR, 并执行依次TEXT描述的表达式.</div><div>返回值：空格分割的多次表达式"TEXT"的计算的结果.</div><div>eg:</div><div>dirs := a b c d</div><div>files := $(foreach dir, $(dirs), $(wildcard $(dir)/*))</div><div>"TEXT"的表达式为"$(wildcard $(dir)/*)".</div><div>表达式第一次执行时表达式为"$(wildcard a/*)";</div><div>表达式第二次执行时表达式为"$(wildcard b/*)";&nbsp;</div><div>...依次类推.</div><div>所以此函数所实现的功能就和一下语句等价:</div><div>files := $(wildcard a/* b/* c/* d/*)</div><div>当函数的"TEXT"表达式过于复杂时, 我们可以通过定义一个中间变量, 此变量代表表达式的一部分. 并在函数的"TEXT"中引用这个变量.</div><div>上边的例子也可以这样来实现：</div><div>find_files = $(wildcard $(dir)/*)</div><div>dirs := a b c d</div><div>files := $(foreach dir, $(dirs), $(find_files))</div><div></div><div>if 函数</div><div>函数"if"提供了一个在函数上下文中实现条件判断的功能.</div><div>函数语法：</div><div>$(if CONDITION, THEN-PART[,ELSE-PART])</div><div>函数功能：第一个参数"CONDITION", 在函数执行时忽略其前导和结尾空字符, 如果包含对其他变量或者函数的引用则进行展开.</div><div>1. "CONDITION"的展开结果非空, 则条件为真, 就将第二个参数"THEN_PATR"作为函数的计算表达式.</div><div>2. "CONDITION"的展开结果为空, 将第三个参数"ELSE-PART"作为函数的表达式, 函数的返回结果为有效表达式的计算结果.</div><div>返回值：根据条件决定函数的返回值是第一个或者第二个参数表达式的计算结果. 当不存在第三个参数"ELSE-PART",&nbsp;</div><div>并且"CONDITION"展开为空, 函数返回空.</div><div>SUBDIR += $(if $(SRC_DIR) $(SRC_DIR), /home/src)</div><div>函数的结果是: 如果"SRC_DIR"变量值不为空, 则将变量"SRC_DIR"指定的目录作为一个子目录; 否则将目录"/home/src"作为一个子目录.<br /></div><img src ="http://www.cppblog.com/lshain/aggbug/172545.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/lshain/" target="_blank">Lshain</a> 2012-04-24 08:47 <a href="http://www.cppblog.com/lshain/articles/172545.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>binutils 学习记录</title><link>http://www.cppblog.com/lshain/articles/155756.html</link><dc:creator>Lshain</dc:creator><author>Lshain</author><pubDate>Wed, 14 Sep 2011 07:07:00 GMT</pubDate><guid>http://www.cppblog.com/lshain/articles/155756.html</guid><description><![CDATA[<div>tools:<br />&nbsp;&nbsp;&nbsp; gcc&nbsp;&nbsp;&nbsp; -E&nbsp; 预编译&nbsp; 生成.i文件<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;-S 编译&nbsp;&nbsp;&nbsp;&nbsp; 生成.s文件<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;-c&nbsp; 汇编&nbsp;&nbsp;&nbsp; 生成.o文件<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-g 在生成的可执行程序中，加入调试信息.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 优化选项<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -ffunction-sections&nbsp;&nbsp; 将每个函数单独放到一个段中<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -fdata-sections&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 将每个变量单独放到一个段中<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-M 列出文件的依赖头文件(eg: gcc -M foo.c)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-MM 列出文件的依赖头文件, 但不包括系统文件(eg: stdio.h)<br />&nbsp; &nbsp; ar &nbsp; &nbsp; &nbsp;c &nbsp;创建归档文件<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;r &nbsp;添加新文件或替换已存在的旧文件(eg: ar r libNAME.a obj.o)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;x 解压归档文件<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;d 删除归档文0件中的内容(eg: ar d libNAME.a obj.o)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;s 生成归档索引，可以加快连接速度.( ranlib )<br />&nbsp;&nbsp;&nbsp; objdump&nbsp;&nbsp;&nbsp;&nbsp;-h&nbsp;&nbsp;&nbsp;&nbsp;以16进制显示目标文件中各段的描述<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -x&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -s&nbsp;&nbsp;&nbsp; 以16进制显示目标文件中各段的内容<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-d&nbsp;&nbsp; 显示代码段反汇编<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -r&nbsp;&nbsp; 查看.o文件中的重定位信息<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-f &nbsp; 显示目标文件的头信息<br />&nbsp;&nbsp;&nbsp; objcopy&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-j &nbsp; 抽取一个段<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-R &nbsp;删除一个段<br />&nbsp;&nbsp;&nbsp; size&nbsp; filename.o&nbsp;&nbsp; 显示pe文件的 .text代码段 .data数据段 .bss段的大小<br />&nbsp;&nbsp;&nbsp; readelf<br />&nbsp;&nbsp;&nbsp; nm&nbsp;&nbsp;filename.o&nbsp;&nbsp; 显示.o文件的符号表信息<br />&nbsp;&nbsp;&nbsp; c++filt&nbsp;函数或变量符号 解释编译后的C++变量名或函数符号<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;eg: &gt;&gt;c++filt __ZN1N1C4funcEid&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &gt;&gt;N::C::func(int, double)<br />&nbsp;&nbsp;&nbsp; strip&nbsp;Removes symbols and sections from files<br />&nbsp; &nbsp; strings 输出程序的可显字符<br />&nbsp; &nbsp; addr2line 根据地址可以查到对应的源文件和对应行(eg: addr2line -f address -e NAME.exe)</div><img src ="http://www.cppblog.com/lshain/aggbug/155756.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/lshain/" target="_blank">Lshain</a> 2011-09-14 15:07 <a href="http://www.cppblog.com/lshain/articles/155756.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>