The difference between i386: x64-32 vs i386 vs i386: x86_64

Can someone explain the difference between the three architectures? In fact, when I created a 64-bit application on Linux, I received an error message:

skipping incompatible library.a when searching for library.a 

Then I used objdump -f in this library, and I got the following result:

 ao: file format elf32-x86-64 architecture: i386:x64-32, flags 0x00000011: HAS_RELOC, HAS_SYMS start address 0x00000000 

Does this mean that the library is 32 bits? Is this the reason I get the linker error?

+6
source share
2 answers

There are 3 regular ABIs that can be used on standard Intel-compatible machines (not Itanium).

  • A classic 32-bit architecture, often called "x86" for short, which has triples such as i[3-6]86-linux-gnu . Registers and pointers are 32 bits.
  • AMD's 64-bit extension, often called "amd64" for short, which has the GNU x86_64-linux-gnu triple. Registers and pointers - 64 bits.
  • New "x32" ABI with triple x86_64-linux-gnux32 . Registers are 64 bits, but pointers are only 32 bits, which saves a lot of memory when working with a large number of pointers. It also provides access to all other 64-bit processor functions.

Each of the above has its own system call interface, its own ld.so , its own complete set of libraries, etc. But you can run all 3 in the same kernel.

On Linux, their loaders are:

 % objdump -f /lib/ld-linux.so.2 /lib64/ld-linux-x86-64.so.2 /libx32/ld-linux-x32.so.2 /lib/ld-linux.so.2: file format elf32-i386 architecture: i386, flags 0x00000150: HAS_SYMS, DYNAMIC, D_PAGED start address 0x00000a90 /lib64/ld-linux-x86-64.so.2: file format elf64-x86-64 architecture: i386:x86-64, flags 0x00000150: HAS_SYMS, DYNAMIC, D_PAGED start address 0x0000000000000c90 /libx32/ld-linux-x32.so.2: file format elf32-x86-64 architecture: i386:x64-32, flags 0x00000150: HAS_SYMS, DYNAMIC, D_PAGED start address 0x00000960 

Now, if you get a message about โ€œskipping an incompatible libraryโ€, it means that something went wrong with your configuration. Make sure that you do not have bad variables in the environment or are transferred to the command line or files installed outside the control of the package manager.

+8
source

Besides the usual full 64-bit and good old 32-bit ABI, there is a special ABI (inspired by the SGI n32 envirnment), where the pointers are 32bit (so they are 32-bit applications), but it is designed to work on a 64-bit host and has a full access to all x64 goodies:

  • native x64 registers and math
  • more registers
  • SSE2 / 3/4, AVX1 / 2 / ...
  • 4Gb full address space on a 64-bit host

It is called x32 ABI, link: https://en.wikipedia.org/wiki/X32_ABI

UPDATE

On an Ubuntu system, I have to install two packages (with folders) in order to get x32 to work:

  > sudo apt install gcc-multilib > sudo apt install libx32stdc++-5-dev 

Then simlple C ++ is compiled - code with g++ -mx32 hellow.cpp , making x32 executable

 > file a.out ./a.out: ELF 32-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /libx32/ld-linux-x32.so.2, for GNU/Linux 3.4.0 
+3
source

All Articles