ec2-3-226-248-180.compute-1.amazonaws.com | ToothyWiki | RecentChanges | Login | Webcomic

Binutils is a collection of programs to manage executable binary files.  It includes assemblers and disassemblers as well as libraries to link, merge and rebase object code.

[Binary File Descriptor library (libbfd)]

At a high level, binaries consist of the program code, function entry points and data storage areas.  This library can be used to split and recombine binary files into and from their constituent parts.  A number of formats of binaries are supported (most notably ELF and aout). 

Functionality is provided to rewrite program code as required to convert between different formats, including rebasing and linking multiple binaries to load into memory for execution.

This includes selecting the location in memory that the code will reside, and providing functionality for different binaries to call into each other.


The opcodes library contains functionality to assemble and disassemble human readable assembly language to and from raw machine code. 

There is support for a number of processor instruction sets, but generally only one is built at a time.  The GNU assembly language is sufficiently generic to describe most opcodes, but some processors may provide additonal custom assembly instructions.

[GNU Assembler (as)]

The GNU assembler compiles GNU assembly language files (.s) into binary object files (.o).  A number of different processor architectures are supported and can be chosen by command line parameters.

The GNU assembler is run as a stage of the GNU gcc compiler, which first compiles high-level languages to GNU assembly language.

[GNU Linker (ld)]

The GNU linker combines multiple object (.o) files, as well as other objects supported by libbfd, and outputs a single binary.  This can be used to build executables or shared objects out of multiple constituent parts.  It can also be used to output files in a format suitable for direct execution, although this is usually unnecessary as modern kernels support ELF binary files natively.

The runtime library libld.so is a cut-down version of ld that allows shared object to be linked in while processes are running.


gprof is a profiling tool that can produce information about the number of times functions in a binary are run, and how long the execution takes.

[Archive (ar)]

ar is a command to handle archive (.a) files.  Archive files are simply a bundle of object (.o) files.  The functionality and syntax is very similar to the tar (tape archive) command.


ranlib is equivalent to ar -s, and is used to extract and store a symbol table for an archive (.a) file.  This needs to be done before .a files can be linked, otherwise the linker will not find any exported symbols in the archive file.


addr2line takes program counter offsets into executable files or shared objects and uses the associated debugging information to return the file name and line number of the original source code.


When handling C++ object files, symbol names can be "mangled" to avoid name clashes, for example when linking overloaded methods based on number and types of arguments.  This tool can convert mangled C++ symbols to human readable form.


This command line tool simply displays the size of different sections of a binary in bytes.


nm uses the libbfd library to display the exported functions and data storage areas present in binary files.  The exact data that is obtained depends on the type of binary, but at a minimum this includes an offset into the binary, a unique string identifier (usually the function or variable name).


objdump is the most powerful binary analysis tool available in binutils.  It uses the libbfd library to display all information about the supplied binary.  Switches are available to show different sections, headers and version identifiers, debugging information, and a complete disassembly of the binary.


This command line tool is similar to objdump, but tailored use on ELF files.  It does not use libbfd internally.


objcopy uses libbfd to convert binary files between different formats (a.out, ELF, etc...)  It can even convert between processor architectures, with certain restrictions on handling data endianness.

Useful features include "--redefine-sym" which can rename symbols within a binary.  "--strip-debug" to remove debugging information. "--strip-unneeded" to remove unnecessary symbols.


This command line can be used to remove symbols from binary files.  It has a slightly more powerful syntax than objcopy, but similar functionality.


The strings command is the "odd one out" of binutils.  It parses through binary files and displays ASCII strings of four or more characters.  This has the effect of displaying human readable strings embedded within files. 

Traditionally most non-executable files in Unix systems would be completely human readable, so strings logically was used mainly on binaries.  For this reason, strings is part of binutils.

ec2-3-226-248-180.compute-1.amazonaws.com | ToothyWiki | RecentChanges | Login | Webcomic
Edit this page | View other revisions | Recently used referrers | List subpages
Last edited February 15, 2010 9:54 pm (viewing revision 8, which is the newest) (diff)