Binutils

From Gentoo Wiki
Jump to:navigation Jump to:search
This article is a stub. Please help out by expanding it - how to get started.

Binutils is a set of tools for creating and manipulating certain types of binary files. They can work on executable files, libraries, object files, assembly code, etc.

Binutils contains commands such as the ld linker, as assembler, or the strip tool for removing debug symbols.

Installation

USE flags

USE flags for sys-devel/binutils Tools necessary to build programs

+gold Build ld.gold linker
+nls Add Native Language Support (using gettext - GNU locale utilities)
+plugins Enable plugin support in tools
cet Enable Intel Control-flow Enforcement Technology.
debuginfod Enable debuginfod support via dev-libs/elfutils libdebuginfod
default-gold Set ld to point to ld.gold instead of ld.bfd
doc Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally
gprofng Enable the next-generation gprofng profiler
hardened Activate default security enhancements for toolchain (gcc, glibc, binutils)
multitarget Adds support to binutils for cross compiling (does not work with gas)
pgo Build binutils with Profile Guided Optimization (PGO) and LTO
static-libs Build static versions of dynamic libraries as well
test Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled independently)
vanilla Do not add extra patches which change default behaviour; DO NOT USE THIS ON A GLOBAL SCALE as the severity of the meaning changes drastically
zstd Enable support for ZSTD compression

Emerge

Binutils is part of the @system set, so it should always be installed.

In case needed, such as after changing USE flags:

root #emerge --ask --oneshot sys-devel/binutils

Configuration

Select a newer version

eselect module

System administrators can use the eselect binutils command to select an alternate version of binutils. This is not normally necessary, since more than one version of the binutils is not installed by default, however it may be necessitated by packages upgrades.

Built-in binutils-config utility

Selecting an alternate version of binutils can be done using the binutils-config command. First list known (installed) versions:

root #binutils-config --list-profiles
 [1] x86_64-pc-linux-gnu-2.25.1 *
 [2] x86_64-pc-linux-gnu-2.26.1

Select the newest profile. Either the integer number or the full profile name can be used to select the profile; below the profile name is used:

root #binutils-config x86_64-pc-linux-gnu-2.26.1
 * Switching to x86_64-pc-linux-gnu-2.26.1 ...                                                                                   [ ok ]

 * Please remember to run:

 *   # . /etc/profile

Usage

There are several command-line tools for binary manipulation distributed in binutils, each has its own expectation on acceptable options, arguments, and parameters. Covering them all goes beyond the scope of this article, however they may eventually be expounded upon in the future. See upstream documentation or the appropriate man page for usage on each utility.

Troubleshooting

Preserved-rebuild loop

When Portage is caught in a @preserved-rebuild loop and the only culprit failing is binutils, use the following steps to resolve the issue. First use the binutils-config command to select the latest emerged version. See Select a new version section above. After executing this step, return here and perform a --depclean:

root #emerge --ask --depclean

Finally perform a @preserved-rebuild a final time:

root #emerge --ask @preserved-rebuild

Removal

Unmerge

This package is part of the system set and should not be removed from systems. Older versions of the package can be safely removed by passing the --depclean option to emerge:

root #emerge --ask --depclean --verbose sys-devel/binutils

See also

  • GDB — used to investigate runtime errors that normally involve memory corruption