Useful references
BFD manual
objdump man page
Executable and Linkable Format (ELF)
Microsoft Portable Executable and Common Object File Format Specification
Common Object File Format (COFF)
An In-Depth Look into the Win32 Portable Executable File Format
One can also use i386 COFF can be enabled by
running GNU Binutils' configure script with --enable-targets=i386-foobar-coff
For x86_64 COFF, as of GNU Binutils version 2.21, there is no switch to enable it, unless
one modifies bfd/config.bfd:
At the bottom of this file, add the following line:
To see all available targets which can be used in bfd/config.bfd,
do
To see all available architectures which can be used in bfd/config.bfd, do
GNU Binutils and BFD
Binary File Descriptor library supports manipulation of object files in a variety of formats ("targets").
What "targets" and "architectures" do my installed GNU Binutils support ?
Use objdump -H
and one should see something like:
....
objdump: supported targets: elf64-x86-64 elf32-i386 a.out-i386-linux pei-i386 pei-x86-64 elf64-l1om elf64-little elf64-big elf32-little elf32-big srec symbolsrec verilog tekhex binary ihex
objdump: supported architectures: i386 i386:x86-64 i8086 i386:intel i386:x86-64:intel l1om l1om:intel
....
"Targets" are really just file formats and can be used in conjuction with objdump's
-b option, and "architectures" are for disassembly and
can be used in conjuction with objdump's -m option.
objdump -i
to see more information about supported "targets".
How to make GNU Binutils support COFF/PEi ?
By default, if GNU Binutils is compiled on x86_64, then i386 & x86_64 PEi (PEi is Microsoft's extension
to the PE format, as mentioned in the comments in
bfd/peicode.h)
are supported automatically (at least for
GNU Binutils version 2.21). However, COFF is not supported by default.
targ_selvecs="${targ_selvecs} i386coff_vec x86_64coff_vec"
grep -o '[a-zA-Z0-9_-]*_vec' bfd/configure.in | grep '^[a-zA-Z0-9]'
or
grep 'extern const bfd_target' bfd/targets.c | grep -o '[a-zA-Z0-9_-]*_vec'
How to make GNU Binutils support different architectures ?
For example, to make GNU Binutils support Itanium, at the bottom of bfd/config.bfd, add the following line:
targ_archs="${targ_archs} bfd_ia64_arch"
grep -o 'bfd_[a-zA-Z0-9-]*_arch' opcodes/configure.in
Putting all together, for example, to make GNU Binutils support i386/x86_64, Itanium, and PowerPC, add the following
code to the bottom of bfd/config.bfd:
\grep -o '[a-zA-Z0-9_-]*_vec' configure.in | grep '^[a-zA-Z0-9]' | sort > $$.t1
\grep 'extern const bfd_target' targets.c | grep -o '[a-zA-Z0-9_-]*_vec' | sort > $$.t2
for t in `comm -1 -2 $$.t1 $$.t2`
do
case "$t" in
*386*|*86*64*|*ia64*|*power*|*rs6000*|mach*)
targ_selvecs="${targ_selvecs} $t"
;;
esac
done
\rm -f $$.t?
targ_archs="${targ_archs} bfd_i386_arch"
targ_archs="${targ_archs} bfd_ia64_arch"
targ_archs="${targ_archs} bfd_rs6000_arch bfd_powerpc_arch"
and run the configure script with --enable-gold=no --enable-ld=no options