[英]difference between i386:x64-32 vs i386 vs i386: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:
实际上当我在Linux中构建一个64位应用程序时,我收到一个链接错误说:
skipping incompatible library.a when searching for library.a
Then I used objdump -f
on that library and I got the below output: 然后我在该库上使用了
objdump -f
,得到了以下输出:
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? 这是否意味着该库是32位? Is that the reason I am getting the linker error?
这是我收到链接器错误的原因吗?
There are 3 common ABIs usable on standard Intel-compatible machines (not Itanium). 在标准的Intel兼容机器(非Itanium)上有3种常见的ABI可用。
i[3-6]86-linux-gnu
. i[3-6]86-linux-gnu
。 Registers and pointers are both 32 bits. x86_64-linux-gnu
. x86_64-linux-gnu
GNU三倍。 Registers and pointers are both 64 bits. x86_64-linux-gnux32
. x86_64-linux-gnux32
。 Registers are 64 bits, but pointers are only 32 bits, saving a lot of memory in pointer-heavy workflows. 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. 上面的每一个都有它的系统调用接口,拥有
ld.so
,拥有完整的库集等。但是可以在同一个内核上运行所有3。
On Linux, their loaders are: 在Linux上,他们的加载器是:
% 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.
确保环境中没有错误的变量或在命令行上传递,或者在包管理器控件之外安装的文件。
Beyond usual full 64bit and good old 32bit ABI there is a special ABI (inspired by SGI n32 envirnment) where pointers are 32bit (thus they are 32bit apps), but it is designed to run on 64bit host and have full access to all x64 goodies: 除了通常的完整64位和良好的旧32位ABI之外,还有一个特殊的ABI(灵感来自SGI n32环境),指针是32位(因此它们是32位应用程序),但它被设计为在64位主机上运行并且可以完全访问所有x64好东西:
It is called x32 ABI, link: https://en.wikipedia.org/wiki/X32_ABI 它被称为x32 ABI,链接: https : //en.wikipedia.org/wiki/X32_ABI
UPDATE UPDATE
On Ubuntu system I have to install two packages (with deps) to get x32 working: 在Ubuntu系统上,我必须安装两个软件包(使用deps)才能使x32正常工作:
> sudo apt install gcc-multilib
> sudo apt install libx32stdc++-5-dev
Then compiling simlple C++ code with g++ -mx32 hellow.cpp
works, making x32 executable 然后使用
g++ -mx32 hellow.cpp
编译simlple C ++代码,使x32可执行
> 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.