Chapter 4. binutils binutils is a collection of various binary tools, such as the GNU linker , GNU assembler , and other utilities that allow you to inspect and manipulate object files and binaries. See Table 4.1, "Tools Included in binutils for Red Hat Developer Toolset" for a complete list of binary tools that are distributed with the Red Hat Developer Toolset version of binutils . Red Hat Developer Toolset is distributed with binutils 2.36.1 . This version is more recent than the version included in Red Hat Enterprise Linux and the release of Red Hat Developer Toolset and provides bug fixes and enhancements. Table 4.1. Tools Included in binutils for Red Hat Developer Toolset Name Description addr2line Translates addresses into file names and line numbers. ar Creates, modifies, and extracts files from archives. as The GNU assembler. c++filt Decodes mangled C++ symbols. dwp Combines DWARF object files into a single DWARF package file. elfedit Examines and edits ELF files. gprof Display profiling information. ld The GNU linker. ld.bfd An alternative to the GNU linker. ld.gold Another alternative to the GNU linker. nm Lists symbols from object files. objcopy Copies and translates object files. objdump Displays information from object files. ranlib Generates an index to the contents of an archive to make access to this archive faster. readelf Displays information about ELF files. size Lists section sizes of object or archive files. strings Displays printable character sequences in files. strip Discards all symbols from object files. 4.1. Installing binutils In Red Hat Developer Toolset, binutils are provided by the devtoolset-12-binutils package and are automatically installed with devtoolset-12-toolchain as described in Section 1.5, "Installing Red Hat Developer Toolset" . 4.2. Using the GNU Assembler To produce an object file from an assembly language program, run the as tool as follows: This creates an object file named object_file in the current working directory. Note that you can execute any command using the scl utility, causing it to be run with the Red Hat Developer Toolset binaries used in preference to the Red Hat Enterprise Linux system equivalent. This allows you to run a shell session with Red Hat Developer Toolset as as default: Note To verify the version of as you are using at any point: Red Hat Developer Toolset's as executable path will begin with /opt . Alternatively, you can use the following command to confirm that the version number matches that for Red Hat Developer Toolset as : 4.3. Using the GNU Linker To create an executable binary file or a library from object files, run the ld tool as follows: This creates a binary file named output_file in the current working directory. If the -o option is omitted, the compiler creates a file named a.out by default. Note that you can execute any command using the scl utility, causing it to be run with the Red Hat Developer Toolset binaries used in preference to the Red Hat Enterprise Linux system equivalent. This allows you to run a shell session with Red Hat Developer Toolset ld as default: Note To verify the version of ld you are using at any point: Red Hat Developer Toolset's ld executable path will begin with /opt . Alternatively, you can use the following command to confirm that the version number matches that for Red Hat Developer Toolset ld : 4.4. Using Other Binary Tools The binutils provide many binary tools other than a linker and an assembler. For a complete list of these tools, see Table 4.1, "Tools Included in binutils for Red Hat Developer Toolset" . To execute any of the tools that are a part of binutils: See Table 4.1, "Tools Included in binutils for Red Hat Developer Toolset" for a list of tools that are distributed with binutils . For example, to use the objdump tool to inspect an object file: Note that you can execute any command using the scl utility, causing it to be run with the Red Hat Developer Toolset binaries used in preference to the Red Hat Enterprise Linux system equivalent. This allows you to run a shell session with Red Hat Developer Toolset binary tools as default: Note To verify the version of binutils you are using at any point: Red Hat Developer Toolset's objdump executable path will begin with /opt . Alternatively, you can use the following command to confirm that the version number matches that for Red Hat Developer Toolset objdump : 4.5. Specifics of binutils in Red Hat Developer Toolset Static linking of libraries Certain more recent library features are statically linked into applications built with Red Hat Developer Toolset to support execution on multiple versions of Red Hat Enterprise Linux. This creates an additional minor security risk as standard Red Hat Enterprise Linux errata do not change this code. If the need arises for developers to rebuild their applications due to this risk, Red Hat will communicate this using a security erratum. Important Because of this additional security risk, developers are strongly advised not to statically link their entire application for the same reasons. Specify libraries after object files when linking In Red Hat Developer Toolset, libraries are linked using linker scripts which might specify some symbols through static archives. This is required to ensure compatibility with multiple versions of Red Hat Enterprise Linux. However, the linker scripts use the names of the respective shared object files. As a consequence, the linker uses different symbol handling rules than expected, and does not recognize symbols required by object files when the option adding the library is specified before options specifying the object files: Using a library from the Red Hat Developer Toolset in this manner results in the linker error message undefined reference to symbol . To prevent this problem, follow the standard linking practice, and specify the option adding the library after the options specifying the object files: Note that this recommendation also applies when using the base Red Hat Enterprise Linux version of binutils . 4.6. Additional Resources For more information about binutils , see the resources listed below. Installed Documentation as (1), ld (1), addr2line (1), ar (1), c++filt (1), dwp (1), elfedit (1), gprof (1), nm (1), objcopy (1), objdump (1), ranlib (1), readelf (1), size (1), strings (1), strip (1), - Manual pages for various binutils tools provide more information about their respective usage. To display a manual page for the version included in Red Hat Developer Toolset: Online Documentation Documentation for binutils - The binutils documentation provides an in-depth description of the binary tools and their usage. See Also Chapter 1, Red Hat Developer Toolset - An overview of Red Hat Developer Toolset and more information on how to install it on your system. Chapter 5, elfutils - Information on how to use elfutils , a collection of binary tools to inspect and manipulate ELF files. Chapter 2, GNU Compiler Collection (GCC) - Information on how to compile programs written in C, C++, and Fortran.

Commands:
scl enable devtoolset-12 'as option ... -o object_file source_file '
scl enable devtoolset-12 'bash'
which as
as -v
scl enable devtoolset-12 'ld option ... -o output_file object_file ...'
scl enable devtoolset-12 'bash'
which ld
ld -v
scl enable devtoolset-12 ' tool option ... file_name '
scl enable devtoolset-12 'objdump option ... object_file '
scl enable devtoolset-12 'bash'
which objdump
objdump -v
scl enable devtoolset-12 'ld -lsomelib objfile.o'
scl enable devtoolset-12 'ld objfile.o -lsomelib'
scl enable devtoolset-12 'man tool '