What is the difference between the 386 and 32 bit options in ld -V?

  • elf32_x86_64
  • elf_i386
  • i386linux
  • i386pep
  • i386pe

And, where can I find the documentation on these "emulation modes"

1 Answer 1


The “emulation” selects different linker scripts; you’ll find the scripts themselves in /usr/lib/ldscripts on your system. The emulations you’ve listed correspond to

  • elf32_x86_64: ELF for x64-32, aka x32 — 32-bit x86-64 binaries
  • elf_i386: ELF for i386 — 32-bit i386 binaries
  • i386linux: a.out for i386
  • i386pep: PE+ for x86-64 — Windows-format 64-bit binaries
  • i386pe: PE for i386 — Windows-format 32-bit binaries

The linker scripts define the output format and architecture, the search directories (where ld looks for libraries), the sections in the binary, among other things.

The linker script format is well documented (see above), but the available scripts aren’t; in most cases GCC will specify the right one, so you don’t need to worry about it, and in other cases you effectively end up needing to read the linker scripts themselves to figure out what they do.

  • 1
    Extra info: x32 is a 32bit executable format, that will only run on x86_64. It is intended to use the benefits of x86 64bit mode, but be smaller than 64bit code. All data types (except time), are same as in 32bit mode. Commented Sep 24, 2018 at 16:19
  • What's 'a.out for i386' ?
    – gfan
    Commented Sep 27, 2018 at 2:34
  • 1
    There's another format elf_x86_64 in the ld -V output. I believe it is the same thing as the elf64-x86-64 in the objdump -i ouput. Both should mean the 64-bit x86-64 binaries. Please correct me if I am wrong. Commented Nov 1, 2019 at 4:24
  • Thanks for the ldscripts/ information, very useful! However it's not the end of the story. If/when you provide your own linker script like I did then ldscripts/ are ignored, you can move them out and everything still works. Yet even with all ldscripts/ gone (for testing ld), I found there was still a difference between -melf_i386 and -melf_x86_64! Alignment. The ELF output of the former was aligned to be mmapped on 4K pages and the latter on 2M pages. This was with ld.bfd 2.32.
    – MarcH
    Commented Jan 12, 2020 at 7:10
  • If you can't find ldscripts/ on your system, they're probably built in the executable. You can extract them like this: ld --verbose > default.xc, ld --verbose --melf_x86_64 --nmagic > elf_x86_64.xn, etc.
    – MarcH
    Commented Jan 13, 2020 at 1:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .