gnu Binary Utilities - 16. Selecting the target system

Go to the first, previous, next, last section, table of contents.

# 16. Selecting the target system

You can specify three aspects of the target system to the GNU binary file utilities, each in several ways:

- the target
- the architecture
- the linker emulation (which applies to the linker only)

In the following summaries, the lists of ways to specify values are in order of decreasing precedence. The ways listed first override those listed later.

The commands to list valid values only list the values for which the programs you are running were configured. If they were configured with ``--enable-targets=all'`, the commands list most of the available values, but a few are left out; not all targets can be configured in at once because some of them can only be configured native (on hosts with the same type as the target system).

## 16.1 Target Selection

A target is an object file format. A given target may be supported for multiple architectures (see section 16.2 Architecture selection). A target selection may also have variations for different operating systems or architectures.

The command to list valid target values is ``objdump -i'` (the first column of output contains the relevant information).

Some sample values are: ``a.out-hp300bsd'`, ``ecoff-littlemips'`, ``a.out-sunos-big'`.

You can also specify a target using a configuration triplet. This is the same sort of name that is passed to configure to specify a target. When you use a configuration triplet as an argument, it must be fully canonicalized. You can see the canonical version of a triplet by running the shell script ``config.sub'` which is included with the sources.

Some sample configuration triplets are: ``m68k-hp-bsd'`, ``mips-dec-ultrix'`, ``sparc-sun-sunos'`.

### 16.1.1 `objdump` Target

Ways to specify:

1. command line option: ``-b'` or ``--target'`
2. environment variable `GNUTARGET`
3. deduced from the input file

### 16.1.2 `objcopy` and `strip` Input Target

Ways to specify:

1. command line options: ``-I'` or ``--input-target'`, or ``-F'` or ``--target'`
2. environment variable `GNUTARGET`
3. deduced from the input file

### 16.1.3 `objcopy` and `strip` Output Target

Ways to specify:

1. command line options: ``-O'` or ``--output-target'`, or ``-F'` or ``--target'`
2. the input target (see "`objcopy` and `strip` Input Target" above)
3. environment variable `GNUTARGET`
4. deduced from the input file

### 16.1.4 `nm`, `size`, and `strings` Target

Ways to specify:

1. command line option: ``--target'`
2. environment variable `GNUTARGET`
3. deduced from the input file

### 16.1.5 Linker Input Target

Ways to specify:

1. command line option: ``-b'` or ``--format'` (see section `Options' in Using LD)
2. script command `TARGET` (see section `Option Commands' in Using LD)
3. environment variable `GNUTARGET` (see section `Environment' in Using LD)
4. the default target of the selected linker emulation (see section 16.3 Linker emulation selection)

### 16.1.6 Linker Output Target

Ways to specify:

1. command line option: ``-oformat'` (see section `Options' in Using LD)
2. script command `OUTPUT_FORMAT` (see section `Option Commands' in Using LD)
3. the linker input target (see "Linker Input Target" above)

## 16.2 Architecture selection

An architecture is a type of CPU on which an object file is to run. Its name may contain a colon, separating the name of the processor family from the name of the particular CPU.

The command to list valid architecture values is ``objdump -i'` (the second column contains the relevant information).

Sample values: ``m68k:68020'`, ``mips:3000'`, ``sparc'`.

### 16.2.1 `objdump` Architecture

Ways to specify:

1. command line option: ``-m'` or ``--architecture'`
2. deduced from the input file

### 16.2.2 `objcopy`, `nm`, `size`, `strings` Architecture

Ways to specify:

1. deduced from the input file

### 16.2.3 Linker Input Architecture

Ways to specify:

1. deduced from the input file

### 16.2.4 Linker Output Architecture

Ways to specify:

1. script command `OUTPUT_ARCH` (see section `Option Commands' in Using LD)
2. the default architecture from the linker output target (see section 16.1 Target Selection)

## 16.3 Linker emulation selection

A linker emulation is a "personality" of the linker, which gives the linker default values for the other aspects of the target system. In particular, it consists of

- the linker script
- the target
- several "hook" functions that are run at certain stages of the linking process to do special things that some targets require

The command to list valid linker emulation values is ``ld -V'`.

Sample values: ``hp300bsd'`, ``mipslit'`, ``sun4'`.

Ways to specify:

1. command line option: ``-m'` (see section `Options' in Using LD)
2. environment variable `LDEMULATION`
3. compiled-in `DEFAULT_EMULATION` from ``Makefile'`, which comes from `EMUL` in ``config/target.mt'`

Go to the first, previous, next, last section, table of contents.