binutils.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
  4. <!ENTITY % general-entities SYSTEM "../general.ent">
  5. %general-entities;
  6. ]>
  7. <sect1 id="ch-system-binutils" role="wrap">
  8. <?dbhtml filename="binutils.html"?>
  9. <sect1info condition="script">
  10. <productname>binutils</productname>
  11. <productnumber>&binutils-version;</productnumber>
  12. <address>&binutils-url;</address>
  13. </sect1info>
  14. <title>Binutils-&binutils-version;</title>
  15. <indexterm zone="ch-system-binutils">
  16. <primary sortas="a-Binutils">Binutils</primary>
  17. </indexterm>
  18. <sect2 role="package">
  19. <title/>
  20. <para>Binutils 包含汇编器、链接器以及其他用于处理目标文件的工具。</para>
  21. <segmentedlist>
  22. <segtitle>&buildtime;</segtitle>
  23. <segtitle>&diskspace;</segtitle>
  24. <seglistitem>
  25. <seg>&binutils-ch6-sbu;</seg>
  26. <seg>&binutils-ch6-du;</seg>
  27. </seglistitem>
  28. </segmentedlist>
  29. </sect2>
  30. <sect2 role="installation">
  31. <title>安装 Binutils</title>
  32. <para>进行简单测试,确认伪终端(PTY)在 chroot 环境中能正常工作:</para>
  33. <screen><userinput remap="test">expect -c "spawn ls"</userinput></screen>
  34. <para>该命令应该输出:</para>
  35. <screen><computeroutput>spawn ls</computeroutput></screen>
  36. <!--para>If, instead, the output includes the message below, then the environment
  37. is not set up for proper PTY operation. This issue needs to be resolved before
  38. running the test suites for Binutils and GCC:</para-->
  39. <para>如果输出不是上面这样,而是下面的消息,就说明环境没有为 PTY
  40. 的正常工作设置好。
  41. 在运行 Binutils 和 GCC 的测试套件前必须解决这个问题。</para>
  42. <screen><computeroutput>The system has no more ptys.
  43. Ask your system administrator to create more.</computeroutput></screen>
  44. <para>Binutils 文档推荐在一个专用的构建目录中构建 Binutils:</para>
  45. <screen><userinput remap="pre">mkdir -v build
  46. cd build</userinput></screen>
  47. <para>准备安装 Binutils:</para>
  48. <screen><userinput remap="configure">../configure --prefix=/usr \
  49. --enable-gold \
  50. --enable-ld=default \
  51. --enable-plugins \
  52. --enable-shared \
  53. --disable-werror \
  54. --enable-64-bit-bfd \
  55. --with-system-zlib</userinput></screen>
  56. <variablelist>
  57. <title>配置选项的含义:</title>
  58. <varlistentry>
  59. <term><parameter>--enable-gold</parameter></term>
  60. <listitem>
  61. <para>构建 gold 链接器,并且将它(和默认链接器一起)安装为
  62. ld.gold。
  63. </para>
  64. </listitem>
  65. </varlistentry>
  66. <varlistentry>
  67. <term><parameter>--enable-ld=default</parameter></term>
  68. <listitem>
  69. <para>构建传统的 bfd 链接器,并且将它安装为 ld (默认链接器)
  70. 和 ld.bfd。</para>
  71. </listitem>
  72. </varlistentry>
  73. <varlistentry>
  74. <term><parameter>--enable-plugins</parameter></term>
  75. <listitem>
  76. <para>启用链接器插件支持。</para>
  77. </listitem>
  78. </varlistentry>
  79. <varlistentry>
  80. <term><parameter>--enable-64-bit-bfd</parameter></term>
  81. <listitem>
  82. <para>(在字长较小的宿主平台上)启用 64 位支持。
  83. 在 64 位平台上可能不需要,但无害。</para>
  84. </listitem>
  85. </varlistentry>
  86. <varlistentry>
  87. <term><parameter>--with-system-zlib</parameter></term>
  88. <listitem>
  89. <para>使用安装好的 zlib 库,而不是构建附带的版本。</para>
  90. </listitem>
  91. </varlistentry>
  92. </variablelist>
  93. <para>编译该软件包:</para>
  94. <screen><userinput remap="make">make tooldir=/usr</userinput></screen>
  95. <variablelist>
  96. <title>make 命令选项的含义:</title>
  97. <varlistentry>
  98. <term><parameter>tooldir=/usr</parameter></term>
  99. <listitem>
  100. <!--para>Normally, the tooldir (the directory where the executables will
  101. ultimately be located) is set to <filename
  102. class="directory">$(exec_prefix)/$(target_alias)</filename>. For
  103. example, x86_64 machines would expand that to <filename
  104. class="directory">/usr/x86_64-unknown-linux-gnu</filename>. Because this is
  105. a custom system, this target-specific directory in <filename
  106. class="directory">/usr</filename> is not required. <filename
  107. class="directory">$(exec_prefix)/$(target_alias)</filename> would be
  108. used if the system was used to cross-compile (for example, compiling a
  109. package on an Intel machine that generates code that can be executed
  110. on PowerPC machines).</para-->
  111. <para>一般来说,工具目录(最终存放该软件包中可执行文件的目录)
  112. 被设定为
  113. <filename class="directory">$(exec_prefix)/$(target_alias)
  114. </filename>。例如,在 x86_64 机器上,它将展开为
  115. <filename class="directory">/usr/x86_64-unknown-linux-gnu
  116. </filename>。因为 LFS 是定制系统,不需要
  117. <filename class="directory">/usr</filename>
  118. 中的特定目标工具目录。如果系统用于交叉编译
  119. (例如,在 Intel 机器上编译软件包,
  120. 生成可以在 PowerPC 机器上执行的代码),,
  121. 就会使用
  122. <filename class="directory">$(exec_prefix)/$(target_alias)
  123. </filename> 目录。</para>
  124. </listitem>
  125. </varlistentry>
  126. </variablelist>
  127. <important>
  128. <para>本节中,Binutils 的测试套件被认为是十分关键的,
  129. 在任何情况下都不能跳过。</para>
  130. </important>
  131. <para>测试编译结果:</para>
  132. <screen><userinput remap="test">make -k check</userinput></screen>
  133. <para>已知名为 debug_msg.sh 的一个测试可能失败。</para>
  134. <para>安装该软件包:</para>
  135. <screen><userinput remap="install">make tooldir=/usr install</userinput></screen>
  136. </sect2>
  137. <sect2 id="contents-binutils" role="content">
  138. <title>Binutils 的内容</title>
  139. <segmentedlist>
  140. <segtitle>安装的程序</segtitle>
  141. <segtitle>安装的库</segtitle>
  142. <segtitle>安装的目录</segtitle>
  143. <seglistitem>
  144. <seg>addr2line, ar, as, c++filt, elfedit, gprof, ld, ld.bfd, ld.gold, nm,
  145. objcopy, objdump, ranlib, readelf, size, strings, 以及 strip</seg>
  146. <seg>libbfd.{a,so} 和 libopcodes.{a,so}</seg>
  147. <seg>/usr/lib/ldscripts</seg>
  148. </seglistitem>
  149. </segmentedlist>
  150. <variablelist>
  151. <bridgehead renderas="sect3">简要描述</bridgehead>
  152. <?dbfo list-presentation="list"?>
  153. <?dbhtml list-presentation="table"?>
  154. <varlistentry id="addr2line">
  155. <term><command>addr2line</command></term>
  156. <listitem>
  157. <!--para>Translates program addresses to file names and line numbers;
  158. given an address and the name of an executable, it uses the debugging
  159. information in the executable to determine which source file and line
  160. number are associated with the address</para-->
  161. <para>将程序中的地址翻译成文件名和行号;
  162. 给定一个内存地址以及可执行程序的名字,
  163. 该程序使用可执行文件中的调试信息,
  164. 确定与该地址相关的源代码文件和行号。</para>
  165. <indexterm zone="ch-system-binutils addr2line">
  166. <primary sortas="b-addr2line">addr2line</primary>
  167. </indexterm>
  168. </listitem>
  169. </varlistentry>
  170. <varlistentry id="ar">
  171. <term><command>ar</command></term>
  172. <listitem>
  173. <para>创建、修改、提取档案文件</para>
  174. <indexterm zone="ch-system-binutils ar">
  175. <primary sortas="b-ar">ar</primary>
  176. </indexterm>
  177. </listitem>
  178. </varlistentry>
  179. <varlistentry id="as">
  180. <term><command>as</command></term>
  181. <listitem>
  182. <para>一个能够汇编 <command>gcc</command>
  183. 输出的汇编代码并生成目标文件的汇编器</para>
  184. <indexterm zone="ch-system-binutils as">
  185. <primary sortas="b-as">as</primary>
  186. </indexterm>
  187. </listitem>
  188. </varlistentry>
  189. <varlistentry id="c-filt">
  190. <term><command>c++filt</command></term>
  191. <listitem>
  192. <para>被链接器用于 demangle C++ 和 Java 符号,
  193. 防止重载函数冲突。</para>
  194. <indexterm zone="ch-system-binutils c-filt">
  195. <primary sortas="b-c++filt">c++filt</primary>
  196. </indexterm>
  197. </listitem>
  198. </varlistentry>
  199. <varlistentry id="elfedit">
  200. <term><command>elfedit</command></term>
  201. <listitem>
  202. <para>更改 ELF 文件的 ELF 头</para>
  203. <indexterm zone="ch-system-binutils elfedit">
  204. <primary sortas="b-elfedit">elfedit</primary>
  205. </indexterm>
  206. </listitem>
  207. </varlistentry>
  208. <varlistentry id="gprof">
  209. <term><command>gprof</command></term>
  210. <listitem>
  211. <para>显示函数调用图性能分析数据</para>
  212. <indexterm zone="ch-system-binutils gprof">
  213. <primary sortas="b-gprof">gprof</primary>
  214. </indexterm>
  215. </listitem>
  216. </varlistentry>
  217. <varlistentry id="ld">
  218. <term><command>ld</command></term>
  219. <listitem>
  220. <para>一个链接器,将一些对象文件和档案文件组合为一个单独的文件,
  221. 重定位它们的数据,并绑定符号引用</para>
  222. <indexterm zone="ch-system-binutils ld">
  223. <primary sortas="b-ld">ld</primary>
  224. </indexterm>
  225. </listitem>
  226. </varlistentry>
  227. <varlistentry id="ld.gold">
  228. <term><command>ld.gold</command></term>
  229. <listitem>
  230. <para>ld 的一个裁减版,只支持 ELF 目标文件格式</para>
  231. <indexterm zone="ch-system-binutils ld.gold">
  232. <primary sortas="b-ld.gold">ld.gold</primary>
  233. </indexterm>
  234. </listitem>
  235. </varlistentry>
  236. <varlistentry id="ld.bfd">
  237. <term><command>ld.bfd</command></term>
  238. <listitem>
  239. <para><command>ld</command> 的硬链接</para>
  240. <indexterm zone="ch-system-binutils ld.bfd">
  241. <primary sortas="b-ld.bfd">ld.bfd</primary>
  242. </indexterm>
  243. </listitem>
  244. </varlistentry>
  245. <varlistentry id="nm">
  246. <term><command>nm</command></term>
  247. <listitem>
  248. <para>列出给定目标文件中的符号</para>
  249. <indexterm zone="ch-system-binutils nm">
  250. <primary sortas="b-nm">nm</primary>
  251. </indexterm>
  252. </listitem>
  253. </varlistentry>
  254. <varlistentry id="objcopy">
  255. <term><command>objcopy</command></term>
  256. <listitem>
  257. <para>将一种目标文件翻译成另一种</para>
  258. <indexterm zone="ch-system-binutils objcopy">
  259. <primary sortas="b-objcopy">objcopy</primary>
  260. </indexterm>
  261. </listitem>
  262. </varlistentry>
  263. <varlistentry id="objdump">
  264. <term><command>objdump</command></term>
  265. <listitem>
  266. <para>显示给定目标文件的信息,通过命令行选项指定要显示哪些信息;
  267. 这些信息对开发编译工具的程序员很有用</para>
  268. <indexterm zone="ch-system-binutils objdump">
  269. <primary sortas="b-objdump">objdump</primary>
  270. </indexterm>
  271. </listitem>
  272. </varlistentry>
  273. <varlistentry id="ranlib">
  274. <term><command>ranlib</command></term>
  275. <listitem>
  276. <para>生成档案文件内容的索引,并将索引存入档案文件;
  277. 索引列出档案文件中所有可重定位目标文件定义的符号</para>
  278. <indexterm zone="ch-system-binutils ranlib">
  279. <primary sortas="b-ranlib">ranlib</primary>
  280. </indexterm>
  281. </listitem>
  282. </varlistentry>
  283. <varlistentry id="readelf">
  284. <term><command>readelf</command></term>
  285. <listitem>
  286. <para>显示 ELF 格式二进制文件的信息</para>
  287. <indexterm zone="ch-system-binutils readelf">
  288. <primary sortas="b-readelf">readelf</primary>
  289. </indexterm>
  290. </listitem>
  291. </varlistentry>
  292. <varlistentry id="size">
  293. <term><command>size</command></term>
  294. <listitem>
  295. <para>列出给定文件各个段的大小和文件总大小</para>
  296. <indexterm zone="ch-system-binutils size">
  297. <primary sortas="b-size">size</primary>
  298. </indexterm>
  299. </listitem>
  300. </varlistentry>
  301. <varlistentry id="strings">
  302. <term><command>strings</command></term>
  303. <listitem>
  304. <para>对于每个给定文件,输出其中长度不小于给定长度
  305. (默认是 4)的可打印字符序列;对于目标文件,
  306. 它默认只输出可加载的已初始化数据段中的字符串,
  307. 对于其他文件,它扫描整个文件
  308. </para>
  309. <indexterm zone="ch-system-binutils strings">
  310. <primary sortas="b-strings">strings</primary>
  311. </indexterm>
  312. </listitem>
  313. </varlistentry>
  314. <varlistentry id="strip">
  315. <term><command>strip</command></term>
  316. <listitem>
  317. <para>移除目标文件中的符号</para>
  318. <indexterm zone="ch-system-binutils strip">
  319. <primary sortas="b-strip">strip</primary>
  320. </indexterm>
  321. </listitem>
  322. </varlistentry>
  323. <varlistentry id="libbfd">
  324. <term><filename class="libraryfile">libbfd</filename></term>
  325. <listitem>
  326. <para>二进制文件描述符库</para>
  327. <indexterm zone="ch-system-binutils libbfd">
  328. <primary sortas="c-libbfd">libbfd</primary>
  329. </indexterm>
  330. </listitem>
  331. </varlistentry>
  332. <varlistentry id="libopcodes">
  333. <term><filename class="libraryfile">libopcodes</filename></term>
  334. <listitem>
  335. <para>一个用于处理操作码 —— 处理器指令的
  336. <quote>可读文本</quote>版本的库;
  337. 它被 <command>objdump</command> 等构建工具所使用</para>
  338. <indexterm zone="ch-system-binutils libopcodes">
  339. <primary sortas="c-libopcodes">libopcodes</primary>
  340. </indexterm>
  341. </listitem>
  342. </varlistentry>
  343. </variablelist>
  344. </sect2>
  345. </sect1>