5.4. Installing Binutils

5.4.1. Installation of Binutils

Install Binutils by running the following commands:


./configure --prefix=$LFS/usr --disable-nls &&
make -e LDFLAGS=-all-static tooldir=$LFS/usr &&
make -e tooldir=$LFS/usr install

5.4.2. Command explanations

make -e: The -e parameter tells make that environment variables take precedence over variables defined in the Makefile file(s). This is needed in order to successfully link binutils statically.

LDFLAGS=-all-static: Setting the variable LDFLAGS to the value -all-static causes binutils to be linked statically.

tooldir=$LFS/usr: Normally, the tooldir (the directory where the executables from binutils end up in) is set to $(exec_prefix)/$(target_alias) which expands into, for example, /usr/i686-pc-linux-gnu. Since we only build for our own system, we don't need this target specific directory in $LFS/usr. That setup would be used if the system was used to cross-compile (for example compiling a package on the Intel machine that generates code that can be executed on Apple PowerPC machines).

5.4.3. Description

The Binutils package contains the gasp, gprof, ld, as, ar, nm, objcopy, objdump, ranlib, readelf, size, strings, strip, c++filt and addr2line programs

5.4.4. Description

5.4.4.1. gasp

Gasp is the Assembler Macro Preprocessor.

5.4.4.2. gprof

gprof displays call graph profile data.

5.4.4.3. ld

ld combines a number of object and archive files, relocates their data and ties up symbol references. Often the last step in building a new compiled program to run is a call to ld.

5.4.4.4. as

as is primarily intended to assemble the output of the GNU C compiler gcc for use by the linker ld.

5.4.4.5. ar

The ar program 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).

5.4.4.6. nm

nm lists the symbols from object files.

5.4.4.7. objcopy

objcopy utility copies the contents of an object file to another. objcopy uses the GNU BFD Library to read and write the object files. It can write the destination object file in a format different from that of the source object file.

5.4.4.8. objdump

objdump displays information about one or more object files. The options control what particular information to display. This information is mostly useful to programmers who are working on the compilation tools, as opposed to programmers who just want their program to compile and work.

5.4.4.9. ranlib

ranlib generates an index to the contents of an archive, and stores it in the archive. The index lists each symbol defined by a member of an archive that is a relocatable object file.

5.4.4.10. readelf

readelf displays information about elf type binaries.

5.4.4.11. size

size lists the section sizes --and the total size-- for each of the object files objfile in its argument list. By default, one line of output is generated for each object file or each module in an archive.

5.4.4.12. strings

For each file given, strings prints the printable character sequences that are at least 4 characters long (or the number specified with an option to the program) and are followed by an unprintable character. By default, it only prints the strings from the initialized and loaded sections of object files; for other types of files, it prints the strings from the whole file.

strings is mainly useful for determining the contents of non-text files.

5.4.4.13. strip

strip discards all or specific symbols from object files. The list of object files may include archives. At least one object file must be given. strip modifies the files named in its argument, rather than writing modified copies under different names.

5.4.4.14. c++filt

The C++ language provides function overloading, which means that it is possible to write many functions with the same name (providing each takes parameters of different types). All C++ function names are encoded into a low-level assembly label (this process is known as mangling). The c++filt program does the inverse mapping: it decodes (demangles) low-level names into user-level names so that the linker can keep these overloaded functions from clashing.

5.4.4.15. addr2line

addr2line translates program addresses into file names and line numbers. Given an address and an executable, it uses the debugging information in the executable to figure out which file name and line number are associated with a given address.