Target selection

Updated: May 06, 2022

A target is an object file format. A given target may be supported for multiple architectures (see 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). A sample value is elf32-i386.

Here's how to specify the target for the ELF utilities:

objdump
  1. -b command-line option
  2. GNUTARGET environment variable
  3. Deduced from the input file.
objcopy, strip

Input target:

  1. -I or -F command-line option
  2. GNUTARGET environment variable
  3. Deduced from the input file.

Output target:

  1. -O or -F command-line option
  2. Input target (see above)
  3. GNUTARGET environment variable
  4. Deduced from the input file.
nm, size, and strings
  1. --target command-line option
  2. GNUTARGET environment variable
  3. Deduced from the input file.
ld

Input target:

  1. -b command-line option
  2. TARGET script command (see “Option Commands” in Using LD in the full online GNU documentation)
  3. GNUTARGET environment variable
  4. Default target of the selected linker emulation (see Linker emulation selection,” below)

Output target:

  1. --oformat command-line option
  2. OUTPUT_FORMAT script command (see “Option Commands” in Using LD in the full online GNU documentation)
  3. Linker input target (see above).