aboutsummaryrefslogtreecommitdiffstats
path: root/chapter08/binutils.xml
blob: a48c985447909243c33c52098ba34189849deb8a (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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
<?xml version="1.0" encoding="ISO-8859-1"?>
<!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>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>&binutils-fin-sbu;</seg>
        <seg>&binutils-fin-du;</seg>
      </seglistitem>
    </segmentedlist>

  </sect2>

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

    <para>Verify that the PTYs are working properly inside the chroot
    environment by performing a simple test:</para>

<screen><userinput remap="test">expect -c "spawn ls"</userinput></screen>

    <para>This command should output the following:</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>

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

    <para>Upstream has made a patch to fix a problem building some
    packages.  Apply that now:</para>

 <screen><userinput remap="pre">patch -Np1 -i ../&binutils-upstream-patch;</userinput></screen>

    <para>An error in the building system causes the shipped man pages to
    be empty.  Workaround the issue and remove the shipped man pages, so the
    man pages will be regenerated correctly:</para>

<screen><userinput remap="pre">sed -i '63d' etc/texi2pod.pl
find -name \*.1 -delete</userinput></screen>

    <para>Now remove one test that prevents the tests from running
    to completion:</para>

<screen><userinput remap="pre">sed -i '/@\tincremental_copy/d' gold/testsuite/Makefile.in</userinput></screen>

    <para>The Binutils documentation recommends building Binutils 
    in a dedicated build directory:</para>

<screen><userinput remap="pre">mkdir -v build
cd       build</userinput></screen>

    <para>Prepare Binutils for compilation:</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>The meaning of the configure parameters:</title>

      <varlistentry>
        <term><parameter>--enable-gold</parameter></term>
        <listitem>
          <para>Build the gold linker and install it as ld.gold (along side the
          default linker).</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><parameter>--enable-ld=default</parameter></term>
        <listitem>
          <para>Build the original bfd linker and install it as both ld (the
          default linker) and ld.bfd.</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><parameter>--enable-plugins</parameter></term>
        <listitem>
          <para>Enables plugin support for the linker.</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><parameter>--enable-64-bit-bfd</parameter></term>
        <listitem>
           <para>Enables 64-bit support (on hosts with narrower word sizes).
           May not be needed on 64-bit systems, but does no harm.</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><parameter>--with-system-zlib</parameter></term>
        <listitem>
          <para>Use the installed zlib library rather than building the
          included version.</para>
        </listitem>
      </varlistentry>

    </variablelist>

    <para>Compile the package:</para>

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

    <variablelist>
      <title>The meaning of the make parameter:</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-pc-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>
        </listitem>
      </varlistentry>

    </variablelist>

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

    <para>Test the results:</para>

<screen><userinput remap="test">make -k check</userinput></screen>

    <para>Four tests related to zlib are known to fail.</para>
<!--
    <para>Seven gold tests are known to fail with gcc-11.1.0</para>

    <para>Four ld tests named <quote>Run property ...</quote> are known to
    fail.</para>
 -->
    <para>Install the package:</para>

<screen><userinput remap="install">make tooldir=/usr install -j1</userinput></screen>

    <para>Remove useless static libraries:</para>

<screen><userinput remap="install">rm -fv /usr/lib/lib{bfd,ctf,ctf-nobfd,opcodes}.a</userinput></screen>

  </sect2>

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

    <segmentedlist>
      <segtitle>Installed programs</segtitle>
      <segtitle>Installed libraries</segtitle>
      <segtitle>Installed directory</segtitle>

      <seglistitem>
        <seg>addr2line, ar, as, c++filt, dwp, elfedit, gprof, ld, ld.bfd, ld.gold, nm,
        objcopy, objdump, ranlib, readelf, size, strings, and strip</seg>
        <seg>libbfd.so, libctf.so, libctf-nobfd.so, and libopcodes.so</seg>
        <seg>/usr/lib/ldscripts</seg>
      </seglistitem>
    </segmentedlist>

    <variablelist>
      <bridgehead renderas="sect3">Short Descriptions</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>
          <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>Creates, modifies, and extracts from archives</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>An assembler that assembles the output of <command>gcc</command>
          into object files</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>Used by the linker to de-mangle C++ and Java symbols and to keep
          overloaded functions from clashing</para>
          <indexterm zone="ch-system-binutils c-filt">
            <primary sortas="b-c++filt">c++filt</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="dwp">
        <term><command>dwp</command></term>
        <listitem>
          <para>The DWARF packaging utility</para>
          <indexterm zone="ch-system-binutils dwp">
            <primary sortas="dwp">dwp</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="elfedit">
        <term><command>elfedit</command></term>
        <listitem>
          <para>Updates the ELF header of ELF files</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>Displays call graph profile data</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>A linker that combines a number of object and archive files
          into a single file, relocating their data and tying up symbol
          references</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>A cut down version of ld that only supports the 
          elf object file format</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>Hard link to <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>Lists the symbols occurring in a given object file</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>Translates one type of object file into another</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>Displays information about the given object file, with options
          controlling the particular information to display; the information
          shown is useful to programmers who are working on the compilation
          tools</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>Generates an index of the contents of an archive and stores it
          in the archive; the index lists all of the symbols defined by archive
          members that are relocatable object files</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>Displays information about ELF type binaries</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>Lists the section sizes and the total size for the given
          object files</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>Outputs, for each given file, the sequences of printable
          characters that are of at least the specified length (defaulting to
          four); for object files, it prints, by default, only the strings from
          the initializing and loading sections while for other types of files, it
          scans the entire file</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>Discards symbols from object files</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>The Binary File Descriptor library</para>
          <indexterm zone="ch-system-binutils libbfd">
            <primary sortas="c-libbfd">libbfd</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="libctf">
        <term><filename class="libraryfile">libctf</filename></term>
        <listitem>
          <para>The Compat ANSI-C Type Format debugging support library</para>
          <indexterm zone="ch-system-binutils libctf">
            <primary sortas="c-libctf">libctf</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="libctf-nobfd">
        <term><filename class="libraryfile">libctf-nobfd</filename></term>
        <listitem>
          <para>A libctf variant which does not use libbfd functionality</para>
          <indexterm zone="ch-system-binutils libctf-nobfd">
            <primary sortas="c-libctf-nobfd">libctf-nobfd</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="libopcodes">
        <term><filename class="libraryfile">libopcodes</filename></term>
        <listitem>
          <para>A library for dealing with opcodes&mdash;the <quote>readable
          text</quote> versions of instructions for the processor;
          it is used for building utilities like
          <command>objdump</command></para>
          <indexterm zone="ch-system-binutils libopcodes">
            <primary sortas="c-libopcodes">libopcodes</primary>
          </indexterm>
        </listitem>
      </varlistentry>

    </variablelist>

  </sect2>

</sect1>