8.18. Binutils-2.37

The Binutils package contains a linker, an assembler, and other tools for handling object files.

Approximate build time: 6.3 SBU
Required disk space: 4.5 GB

8.18.1. Installation of Binutils

Verify that the PTYs are working properly by performing a simple test:

expect -c "spawn ls"

This command should output the following:

spawn ls

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:

The system has no more ptys.
Ask your system administrator to create more.

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

patch -Np1 -i ../binutils-2.37-upstream_fix-1.patch

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:

sed -i '63d' etc/texi2pod.pl
find -name \*.1 -delete

The Binutils documentation recommends building Binutils in a dedicated build directory:

mkdir -v build
cd       build

Prepare Binutils for compilation:

../configure --prefix=/usr       \
             --enable-ld=default \
             --enable-plugins    \
             --enable-shared     \
             --disable-werror    \
             --enable-64-bit-bfd \
             --with-system-zlib

The meaning of the configure parameters:

--enable-ld=default

Build the original bfd linker and install it as both ld (the default linker) and ld.bfd.

--enable-plugins

Enables plugin support for the linker.

--enable-64-bit-bfd

Enables 64-bit support (on hosts with narrower word sizes). May not be needed on 64-bit systems, but does no harm.

--with-system-zlib

Use the installed zlib library rather than building the included version.

Compile the package:

make tooldir=/usr

The meaning of the make parameter:

tooldir=/usr

Normally, the tooldir (the directory where the executables will ultimately be located) is set to $(exec_prefix)/$(target_alias). For example, x86_64 machines would expand that to /usr/x86_64-pc-linux-gnu. Because this is a custom system, this target-specific directory in /usr is not required. $(exec_prefix)/$(target_alias) 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).

[Important]

Important

The test suite for Binutils in this section is considered critical. Do not skip it under any circumstances.

Test the results:

make -k check

Three tests related to ifunc, one test related to eh5, and tests related to PR numbers 12760, 12982, 18841, 21884, 21964, 26936, and 27355 are known to fail.

Install the package:

make tooldir=/usr install -j1

Remove useless static libraries:

rm -fv /usr/lib/lib{bfd,ctf,ctf-nobfd,opcodes}.a

8.18.2. Contents of Binutils

Installed programs: addr2line, ar, as, c++filt, dwp, elfedit, gprof, ld, ld.bfd, nm, objcopy, objdump, ranlib, readelf, size, strings, and strip
Installed libraries: libbfd.so, libctf.so, libctf-nobfd.so, and libopcodes.so
Installed directory: /usr/lib/ldscripts

Short Descriptions

addr2line

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

ar

Creates, modifies, and extracts from archives

as

An assembler that assembles the output of gcc into object files

c++filt

Used by the linker to de-mangle C++ and Java symbols and to keep overloaded functions from clashing

dwp

The DWARF packaging utility

elfedit

Updates the ELF header of ELF files

gprof

Displays call graph profile data

ld

A linker that combines a number of object and archive files into a single file, relocating their data and tying up symbol references

ld.bfd

Hard link to ld

nm

Lists the symbols occurring in a given object file

objcopy

Translates one type of object file into another

objdump

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

ranlib

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

readelf

Displays information about ELF type binaries

size

Lists the section sizes and the total size for the given object files

strings

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

strip

Discards symbols from object files

libbfd

The Binary File Descriptor library

libctf

The Compat ANSI-C Type Format debugging support library

libctf-nobfd

A libctf variant which does not use libbfd functionality

libopcodes

A library for dealing with opcodes—the readable text versions of instructions for the processor; it is used for building utilities like objdump