123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
- "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
- <!ENTITY % general-entities SYSTEM "../general.ent">
- %general-entities;
- ]>
- <sect1 id="ch-system-binutils" role="wrap">
- <?dbhtml filename="binutils.html"?>
- <sect1info condition="script">
- <productname>binutils</productname>
- <productnumber>&binutils-version;</productnumber>
- <address>&binutils-url;</address>
- </sect1info>
- <title>Binutils-&binutils-version;</title>
- <indexterm zone="ch-system-binutils">
- <primary sortas="a-Binutils">Binutils</primary>
- </indexterm>
- <sect2 role="package">
- <title/>
- <para>Binutils 包含汇编器、链接器以及其他用于处理目标文件的工具。</para>
- <segmentedlist>
- <segtitle>&buildtime;</segtitle>
- <segtitle>&diskspace;</segtitle>
- <seglistitem>
- <seg>&binutils-ch6-sbu;</seg>
- <seg>&binutils-ch6-du;</seg>
- </seglistitem>
- </segmentedlist>
- </sect2>
- <sect2 role="installation">
- <title>安装 Binutils</title>
- <para>进行简单测试,确认伪终端(PTY)在 chroot 环境中能正常工作:</para>
- <screen><userinput remap="test">expect -c "spawn ls"</userinput></screen>
- <para>该命令应该输出:</para>
- <screen><computeroutput>spawn ls</computeroutput></screen>
- <!--para>If, instead, the output includes the message below, then the environment
- is not set up for proper PTY operation. This issue needs to be resolved before
- running the test suites for Binutils and GCC:</para-->
- <para>如果输出不是上面这样,而是下面的消息,就说明环境没有为 PTY
- 的正常工作设置好。
- 在运行 Binutils 和 GCC 的测试套件前必须解决这个问题。</para>
- <screen><computeroutput>The system has no more ptys.
- Ask your system administrator to create more.</computeroutput></screen>
- <para>Binutils 文档推荐在一个专用的构建目录中构建 Binutils:</para>
- <screen><userinput remap="pre">mkdir -v build
- cd build</userinput></screen>
- <para>准备安装 Binutils:</para>
- <screen><userinput remap="configure">../configure --prefix=/usr \
- --enable-gold \
- --enable-ld=default \
- --enable-plugins \
- --enable-shared \
- --disable-werror \
- --enable-64-bit-bfd \
- --with-system-zlib</userinput></screen>
- <variablelist>
- <title>配置选项的含义:</title>
- <varlistentry>
- <term><parameter>--enable-gold</parameter></term>
- <listitem>
- <para>构建 gold 链接器,并且将它(和默认链接器一起)安装为
- ld.gold。
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><parameter>--enable-ld=default</parameter></term>
- <listitem>
- <para>构建传统的 bfd 链接器,并且将它安装为 ld (默认链接器)
- 和 ld.bfd。</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><parameter>--enable-plugins</parameter></term>
- <listitem>
- <para>启用链接器插件支持。</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><parameter>--enable-64-bit-bfd</parameter></term>
- <listitem>
- <para>(在字长较小的宿主平台上)启用 64 位支持。
- 在 64 位平台上可能不需要,但无害。</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><parameter>--with-system-zlib</parameter></term>
- <listitem>
- <para>使用安装好的 zlib 库,而不是构建附带的版本。</para>
- </listitem>
- </varlistentry>
- </variablelist>
- <para>编译该软件包:</para>
- <screen><userinput remap="make">make tooldir=/usr</userinput></screen>
- <variablelist>
- <title>make 命令选项的含义:</title>
- <varlistentry>
- <term><parameter>tooldir=/usr</parameter></term>
- <listitem>
- <!--para>Normally, the tooldir (the directory where the executables will
- ultimately be located) is set to <filename
- class="directory">$(exec_prefix)/$(target_alias)</filename>. For
- example, x86_64 machines would expand that to <filename
- class="directory">/usr/x86_64-unknown-linux-gnu</filename>. Because this is
- a custom system, this target-specific directory in <filename
- class="directory">/usr</filename> is not required. <filename
- class="directory">$(exec_prefix)/$(target_alias)</filename> would be
- used if the system was used to cross-compile (for example, compiling a
- package on an Intel machine that generates code that can be executed
- on PowerPC machines).</para-->
- <para>一般来说,工具目录(最终存放该软件包中可执行文件的目录)
- 被设定为
- <filename class="directory">$(exec_prefix)/$(target_alias)
- </filename>。例如,在 x86_64 机器上,它将展开为
- <filename class="directory">/usr/x86_64-unknown-linux-gnu
- </filename>。因为 LFS 是定制系统,不需要
- <filename class="directory">/usr</filename>
- 中的特定目标工具目录。如果系统用于交叉编译
- (例如,在 Intel 机器上编译软件包,
- 生成可以在 PowerPC 机器上执行的代码),,
- 就会使用
- <filename class="directory">$(exec_prefix)/$(target_alias)
- </filename> 目录。</para>
- </listitem>
- </varlistentry>
- </variablelist>
- <important>
- <para>本节中,Binutils 的测试套件被认为是十分关键的,
- 在任何情况下都不能跳过。</para>
- </important>
- <para>测试编译结果:</para>
- <screen><userinput remap="test">make -k check</userinput></screen>
- <para>已知名为 debug_msg.sh 的一个测试可能失败。</para>
- <para>安装该软件包:</para>
- <screen><userinput remap="install">make tooldir=/usr install</userinput></screen>
- </sect2>
- <sect2 id="contents-binutils" role="content">
- <title>Binutils 的内容</title>
- <segmentedlist>
- <segtitle>安装的程序</segtitle>
- <segtitle>安装的库</segtitle>
- <segtitle>安装的目录</segtitle>
- <seglistitem>
- <seg>addr2line, ar, as, c++filt, elfedit, gprof, ld, ld.bfd, ld.gold, nm,
- objcopy, objdump, ranlib, readelf, size, strings, 以及 strip</seg>
- <seg>libbfd.{a,so} 和 libopcodes.{a,so}</seg>
- <seg>/usr/lib/ldscripts</seg>
- </seglistitem>
- </segmentedlist>
- <variablelist>
- <bridgehead renderas="sect3">简要描述</bridgehead>
- <?dbfo list-presentation="list"?>
- <?dbhtml list-presentation="table"?>
- <varlistentry id="addr2line">
- <term><command>addr2line</command></term>
- <listitem>
- <!--para>Translates program addresses to file names and line numbers;
- given an address and the name of an executable, it uses the debugging
- information in the executable to determine which source file and line
- number are associated with the address</para-->
- <para>将程序中的地址翻译成文件名和行号;
- 给定一个内存地址以及可执行程序的名字,
- 该程序使用可执行文件中的调试信息,
- 确定与该地址相关的源代码文件和行号。</para>
- <indexterm zone="ch-system-binutils addr2line">
- <primary sortas="b-addr2line">addr2line</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="ar">
- <term><command>ar</command></term>
- <listitem>
- <para>创建、修改、提取档案文件</para>
- <indexterm zone="ch-system-binutils ar">
- <primary sortas="b-ar">ar</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="as">
- <term><command>as</command></term>
- <listitem>
- <para>一个能够汇编 <command>gcc</command>
- 输出的汇编代码并生成目标文件的汇编器</para>
- <indexterm zone="ch-system-binutils as">
- <primary sortas="b-as">as</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="c-filt">
- <term><command>c++filt</command></term>
- <listitem>
- <para>被链接器用于 demangle C++ 和 Java 符号,
- 防止重载函数冲突。</para>
- <indexterm zone="ch-system-binutils c-filt">
- <primary sortas="b-c++filt">c++filt</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="elfedit">
- <term><command>elfedit</command></term>
- <listitem>
- <para>更改 ELF 文件的 ELF 头</para>
- <indexterm zone="ch-system-binutils elfedit">
- <primary sortas="b-elfedit">elfedit</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="gprof">
- <term><command>gprof</command></term>
- <listitem>
- <para>显示函数调用图性能分析数据</para>
- <indexterm zone="ch-system-binutils gprof">
- <primary sortas="b-gprof">gprof</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="ld">
- <term><command>ld</command></term>
- <listitem>
- <para>一个链接器,将一些对象文件和档案文件组合为一个单独的文件,
- 重定位它们的数据,并绑定符号引用</para>
- <indexterm zone="ch-system-binutils ld">
- <primary sortas="b-ld">ld</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="ld.gold">
- <term><command>ld.gold</command></term>
- <listitem>
- <para>ld 的一个裁减版,只支持 ELF 目标文件格式</para>
- <indexterm zone="ch-system-binutils ld.gold">
- <primary sortas="b-ld.gold">ld.gold</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="ld.bfd">
- <term><command>ld.bfd</command></term>
- <listitem>
- <para><command>ld</command> 的硬链接</para>
- <indexterm zone="ch-system-binutils ld.bfd">
- <primary sortas="b-ld.bfd">ld.bfd</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="nm">
- <term><command>nm</command></term>
- <listitem>
- <para>列出给定目标文件中的符号</para>
- <indexterm zone="ch-system-binutils nm">
- <primary sortas="b-nm">nm</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="objcopy">
- <term><command>objcopy</command></term>
- <listitem>
- <para>将一种目标文件翻译成另一种</para>
- <indexterm zone="ch-system-binutils objcopy">
- <primary sortas="b-objcopy">objcopy</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="objdump">
- <term><command>objdump</command></term>
- <listitem>
- <para>显示给定目标文件的信息,通过命令行选项指定要显示哪些信息;
- 这些信息对开发编译工具的程序员很有用</para>
- <indexterm zone="ch-system-binutils objdump">
- <primary sortas="b-objdump">objdump</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="ranlib">
- <term><command>ranlib</command></term>
- <listitem>
- <para>生成档案文件内容的索引,并将索引存入档案文件;
- 索引列出档案文件中所有可重定位目标文件定义的符号</para>
- <indexterm zone="ch-system-binutils ranlib">
- <primary sortas="b-ranlib">ranlib</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="readelf">
- <term><command>readelf</command></term>
- <listitem>
- <para>显示 ELF 格式二进制文件的信息</para>
- <indexterm zone="ch-system-binutils readelf">
- <primary sortas="b-readelf">readelf</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="size">
- <term><command>size</command></term>
- <listitem>
- <para>列出给定文件各个段的大小和文件总大小</para>
- <indexterm zone="ch-system-binutils size">
- <primary sortas="b-size">size</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="strings">
- <term><command>strings</command></term>
- <listitem>
- <para>对于每个给定文件,输出其中长度不小于给定长度
- (默认是 4)的可打印字符序列;对于目标文件,
- 它默认只输出可加载的已初始化数据段中的字符串,
- 对于其他文件,它扫描整个文件
- </para>
- <indexterm zone="ch-system-binutils strings">
- <primary sortas="b-strings">strings</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="strip">
- <term><command>strip</command></term>
- <listitem>
- <para>移除目标文件中的符号</para>
- <indexterm zone="ch-system-binutils strip">
- <primary sortas="b-strip">strip</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="libbfd">
- <term><filename class="libraryfile">libbfd</filename></term>
- <listitem>
- <para>二进制文件描述符库</para>
- <indexterm zone="ch-system-binutils libbfd">
- <primary sortas="c-libbfd">libbfd</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="libopcodes">
- <term><filename class="libraryfile">libopcodes</filename></term>
- <listitem>
- <para>一个用于处理操作码 —— 处理器指令的
- <quote>可读文本</quote>版本的库;
- 它被 <command>objdump</command> 等构建工具所使用</para>
- <indexterm zone="ch-system-binutils libopcodes">
- <primary sortas="c-libopcodes">libopcodes</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- </variablelist>
- </sect2>
- </sect1>
|