aboutsummaryrefslogtreecommitdiffstats
path: root/chapter06/binutils.xml
blob: cee1136c751ff195bc45dcf70da00d021a0bfe90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
  <!ENTITY % general-entities SYSTEM "../general.ent">
  %general-entities;
]>
<sect1 id="ch-system-binutils" xreflabel="Binutils" role="wrap">
<title>Binutils-&binutils-version;</title>
<?dbhtml filename="binutils.html"?>

<indexterm zone="ch-system-binutils"><primary sortas="a-Binutils">Binutils</primary></indexterm>

<sect2 role="package"><title/>
<para>The Binutils package contains a linker, an assembler, and other tools for
handling object files.</para>

<segmentedlist>
<segtitle>&buildtime;</segtitle>
<segtitle>&diskspace;</segtitle>
<seglistitem><seg>1.4 SBU</seg><seg>167 MB</seg></seglistitem>
</segmentedlist>

<segmentedlist>
<segtitle>Binutils installation depends on</segtitle>
<seglistitem><seg>Bash, Coreutils, Diffutils, GCC, Gettext,
Glibc, Grep, Make, Perl, Sed, Texinfo</seg></seglistitem>
</segmentedlist>
</sect2>

<sect2 role="installation">
<title>Installation of Binutils</title>

<para>Now is an appropriate time to verify that your pseudo terminals (PTYs) are
working properly inside the chroot environment. We will again quickly check that
everything is set up correctly by performing a simple test:</para>

<screen><userinput>expect -c "spawn ls"</userinput></screen>

<para>If you receive the message:</para>

<blockquote><screen>The system has no more ptys.  Ask your system administrator to create more.</screen></blockquote>

<para>Your chroot environment is not set up for proper PTY operation. In this
case there is no point in running the test suites for Binutils and GCC until you
are able to resolve the issue.</para>

<para>This package is known to behave badly when you have changed its
default optimization flags (including the -march and -mcpu options).
Therefore, if you have defined any environment variables that override
default optimizations, such as CFLAGS and CXXFLAGS, we recommend un-setting
or modifying them when building Binutils.</para>

<para>The Binutils documentation recommends building Binutils outside of the
source directory in a dedicated build directory:</para>

<screen><userinput>mkdir ../binutils-build
cd ../binutils-build</userinput></screen>

<para>Now prepare Binutils for compilation:</para>

<screen><userinput>../binutils-&binutils-version;/configure --prefix=/usr --enable-shared</userinput></screen>

<para>Compile the package:</para>

<screen><userinput>make tooldir=/usr</userinput></screen>

<para>Normally, the <emphasis>tooldir</emphasis> (the directory where the
executables end up) is set to $(exec_prefix)/$(target_alias), which expands
into, for example, <filename>/usr/i686-pc-linux-gnu</filename>. Since we only
build for our own system, we don't need this target specific directory in
<filename>/usr</filename>. That setup 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>

<important><para>The test suite for Binutils in this section is considered
<emphasis>critical</emphasis>. Our advice is to not skip it under any
circumstances.</para></important>

<para>Test the results:</para>

<screen><userinput>make -k check</userinput></screen>

<para>The test suite notes from <xref linkend="ch-tools-binutils-pass2"/> are still
very much appropriate here. Be sure to refer back there should you have any
doubts.</para>

<para>Install the package:</para>

<screen><userinput>make tooldir=/usr install</userinput></screen>

<para>Install the <emphasis>libiberty</emphasis> header file that is needed by
some packages:</para>

<screen><userinput>cp ../binutils-&binutils-version;/include/libiberty.h /usr/include</userinput></screen>

</sect2>


<sect2 id="contents-binutils" role="content"><title>Contents of Binutils</title>

<segmentedlist>
<segtitle>Installed programs</segtitle>
<segtitle>Installed libraries</segtitle>
<seglistitem><seg>addr2line, ar, as, c++filt, gprof, ld, nm, objcopy, objdump, 
ranlib, readelf, size, strings and strip</seg>
<seg>libiberty.a, libbfd.[a,so] and libopcodes.[a,so]</seg></seglistitem>
</segmentedlist>

<variablelist><title>Short descriptions</title>

<varlistentry>
<term id="addr2line"><command>addr2line</command></term>
<listitem>
<indexterm zone="ch-system-binutils addr2line"><primary sortas="b-addr2line">addr2line</primary></indexterm>
<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 figure out which source
file and line number are associated with the address.</para>
</listitem>
</varlistentry>

<varlistentry>
<term id="ar"><command>ar</command></term>
<listitem>
<indexterm zone="ch-system-binutils ar"><primary sortas="b-ar">ar</primary></indexterm>
<para>creates, modifies, and extracts from archives. An archive
is a single file holding a collection of other files in a structure that makes
it possible to retrieve the original individual files (called members of
the archive).</para>
</listitem>
</varlistentry>

<varlistentry>
<term id="as"><command>as</command></term>
<listitem>
<indexterm zone="ch-system-binutils as"><primary sortas="b-as">as</primary></indexterm>
<para>is an assembler. It assembles the output of gcc into object files.</para>
</listitem>
</varlistentry>

<varlistentry>
<term id="c-filt"><command>c++filt</command></term>
<listitem>
<indexterm zone="ch-system-binutils c-filt"><primary sortas="b-c++filt">c++filt</primary></indexterm>
<para>is used by the linker to de-mangle C++ and
Java symbols, to keep overloaded functions from clashing.</para>
</listitem>
</varlistentry>

<varlistentry>
<term id="gprof"><command>gprof</command></term>
<listitem>
<indexterm zone="ch-system-binutils gprof"><primary sortas="b-gprof">gprof</primary></indexterm>
<para>displays call graph profile data.</para>
</listitem>
</varlistentry>

<varlistentry>
<term id="ld"><command>ld</command></term>
<listitem>
<indexterm zone="ch-system-binutils ld"><primary sortas="b-ld">ld</primary></indexterm>
<para>is a linker. It combines a number of object and archive files into a single file, 
relocating their data and tying up symbol references.</para>
</listitem>
</varlistentry>

<varlistentry>
<term id="nm"><command>nm</command></term>
<listitem>
<indexterm zone="ch-system-binutils nm"><primary sortas="b-nm">nm</primary></indexterm>
<para>lists the symbols occurring in a given object file.</para>
</listitem>
</varlistentry>

<varlistentry>
<term id="objcopy"><command>objcopy</command></term>
<listitem>
<indexterm zone="ch-system-binutils objcopy"><primary sortas="b-objcopy">objcopy</primary></indexterm>
<para>is used to translate one type of object file into another.</para>
</listitem>
</varlistentry>

<varlistentry>
<term id="objdump"><command>objdump</command></term>
<listitem>
<indexterm zone="ch-system-binutils objdump"><primary sortas="b-objdump">objdump</primary></indexterm>
<para>displays information about the given object file, with options controlling what 
particular information to display. The information shown is mostly only useful to 
programmers who are working on the compilation tools.</para>
</listitem>
</varlistentry>

<varlistentry>
<term id="ranlib"><command>ranlib</command></term>
<listitem>
<indexterm zone="ch-system-binutils ranlib"><primary sortas="b-ranlib">ranlib</primary></indexterm>
<para>generates an index of the contents of an
archive, and stores it in the archive. The index lists all the symbols defined
by archive members that are relocatable object files.</para>
</listitem>
</varlistentry>

<varlistentry>
<term id="readelf"><command>readelf</command></term>
<listitem>
<indexterm zone="ch-system-binutils readelf"><primary sortas="b-readelf">readelf</primary></indexterm>
<para>displays information about elf type binaries.</para>
</listitem>
</varlistentry>

<varlistentry>
<term id="size"><command>size</command></term>
<listitem>
<indexterm zone="ch-system-binutils size"><primary sortas="b-size">size</primary></indexterm>
<para>lists the section sizes -- and the grand total -- for the given object files.</para>
</listitem>
</varlistentry>

<varlistentry>
<term id="strings"><command>strings</command></term>
<listitem>
<indexterm zone="ch-system-binutils strings"><primary sortas="b-strings">strings</primary></indexterm>
<para>outputs, for each given file, the sequences
of printable characters that are of at least the specified length (defaulting to 4).
For object files it prints, by default, only the strings from the initializing
and loading sections. For other types of files it scans the whole file.</para>
</listitem>
</varlistentry>

<varlistentry>
<term id="strip"><command>strip</command></term>
<listitem>
<indexterm zone="ch-system-binutils strip"><primary sortas="b-strip">strip</primary></indexterm>
<para>discards symbols from object files.</para>
</listitem>
</varlistentry>

<varlistentry>
<term id="libiberty"><command>libiberty</command></term>
<listitem>
<indexterm zone="ch-system-binutils libiberty"><primary sortas="c-libiberty">libiberty</primary></indexterm>
<para>contains routines used by various GNU
programs, including getopt, obstack, strerror, strtol and strtoul.</para>
</listitem>
</varlistentry>

<varlistentry>
<term id="libbfd"><command>libbfd</command></term>
<listitem>
<indexterm zone="ch-system-binutils libbfd"><primary sortas="c-libbfd">libbfd</primary></indexterm>
<para>is the Binary File Descriptor library.</para>
</listitem>
</varlistentry>

<varlistentry>
<term id="libopcodes"><command>libopcodes</command></term>
<listitem>
<indexterm zone="ch-system-binutils libopcodes"><primary sortas="c-libopcodes">libopcodes</primary></indexterm>
<para>is a library for dealing with opcodes.
It is used for building utilities like objdump. Opcodes are the <quote>readable
text</quote> versions of instructions for the processor.</para>
</listitem>
</varlistentry>
</variablelist>

</sect2>

</sect1>