Search code examples
binutils

What's the meaning of elfnn-<arch>.c and elfxx-<arch>.c in binutils/bfd?


I am tracing binutils source code.
I found that there are files named elfnn-<arch>.c and elfxx-<arch>.c in binutils/bfd.
What't the meaning of elfnn and elfxx?

Thanks.


Solution

  • In cases where an architecture supports only a 32-bit or a 64-bit ELF-based ABI, the code for that architecture is in a file named elf32-arch.c or elf64-arch.c, respectively. In some cases, an architecture supports both, but the implementations are very different, so you'll see both an elf32-arch.c and an elf64-arch.c source file (e.g., ppc, mips).

    But some of the more modern architectures, where 32-bit and 64-bit support were developed side by side, share a lot of the implementation (e.g., aarch64, ia64, riscv). In those cases, you'll see an elfnn-arch.c source file. This file is a template; the build process autogenerates elf32- and elf64- specializations of the file from the template. Still, a lot of code is common to both 32-bit and 64-bit without the need for specialization, so you'll find that code in an elfxx-arch.c source file, which is not a template.