Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

linux

x86

x86-64

Can someone explain the difference between the three architectures? Actually when I built a 64 bit application in Linux, I got a link error saying:

skipping incompatible library.a when searching for library.a

Then I used objdump -f on that library and I got the below output:

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

Does it mean the library is 32 bit? Is that the reason I am getting the linker error?

like image 800
Santhosh Kumar Avatar asked Apr 01 '16 02:04

Santhosh Kumar


1 Answers

There are 3 common ABIs usable on standard Intel-compatible machines (not Itanium).

  • The classic 32-bit architecture, often called "x86" for short, which has triples like i[3-6]86-linux-gnu. Registers and pointers are both 32 bits.
  • The 64-bit extension originally from AMD, often called "amd64" for short, which has GNU triple of x86_64-linux-gnu. Registers and pointers are both 64 bits.
  • The new "x32" ABI, with a triple of x86_64-linux-gnux32. Registers are 64 bits, but pointers are only 32 bits, saving a lot of memory in pointer-heavy workflows. It also ensures all the other 64-bit only processor features are available.

Each of the above has its on system call interface, own ld.so, own complete set of libraries, etc. But it is possible to run all 3 on 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're getting the message about "skipping incompatible library", that means something is messed up with your configuration. Make sure you don't have bad variables in the environment or passed on the command line, or files installed outside of your package manager's control.

like image 82
o11c Avatar answered Oct 04 '22 10:10

o11c