简体   繁体   English

i386:x64-32 vs i386 vs i386:x86_64之间的差异

[英]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可用。

  • The classic 32-bit architecture, often called "x86" for short, which has triples like i[3-6]86-linux-gnu . 经典的32位架构,通常简称为“x86”,它有三倍于i[3-6]86-linux-gnu Registers and pointers are both 32 bits. 寄存器和指针都是32位。
  • The 64-bit extension originally from AMD, often called "amd64" for short, which has GNU triple of x86_64-linux-gnu . 最初来自AMD的64位扩展,通常简称为“amd64”,它具有x86_64-linux-gnu GNU三倍。 Registers and pointers are both 64 bits. 寄存器和指针都是64位。
  • The new "x32" ABI, with a triple of x86_64-linux-gnux32 . 新的“x32”ABI,带有x86_64-linux-gnux32 Registers are 64 bits, but pointers are only 32 bits, saving a lot of memory in pointer-heavy workflows. 寄存器是64位,但指针只有32位,在指针繁重的工作流程中节省了大量内存。 It also ensures all the other 64-bit only processor features are available. 它还确保所有其他64位处理器功能都可用。

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好东西:

  • native x64 registers and math 本机x64寄存器和数学
  • more registers 更多寄存器
  • SSE2/3/4, AVX1/2/... SSE2 / 3/4,AVX1 / 2 / ......
  • Full 4Gb address space on 64bit host 64位主机上的完整4Gb地址空间

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.

相关问题 分段故障组装i386:x86_64 - Segmentation fault assembly i386:x86_64 适用于i386和x86_64的Linux单个二进制文件 - Linux single binary for i386 and x86_64 机器类型(C ++ librairies):i386 vs x86_64 - machine type (C++ librairies) : i386 vs x86_64 i386 输入文件的架构与 i386:x86-64 不兼容 - Architecture of i386 input file is incompatible with i386:x86-64 是什么决定了在64位机器上构建的32位库是否需要x86_64或i386依赖? - What determines if a 32-bit library built on a 64-bit machine needs x86_64 or i386 dependencies? timer_create在i386系统上导致分段错误,但在x86_64系统上未引起分段错误(linux) - timer_create causing segmentation fault on i386 system, but not x86_64 system(linux) make命令给出了不兼容的i386架构(i386x86-64) - make command gives Incompatible i386 architecture(i386x86-64) GCC:输入文件“ ../window.ui.o”的i386体系结构与i386:x86-64输出不兼容 - GCC: i386 architecture of input file `../window.ui.o' is incompatible with i386:x86-64 output GDB 错误:所选架构 i386 与报告的目标架构 i386:x86-64 不兼容 - GDB error: Selected architecture i386 is not compatible with reported target architecture i386:x86-64 在R中执行库(程序包)会报告该程序包是为i386构建的,是否可以将其安装在x86_64系统上? - Executing library(package) in R reports that package was built for i386, can it be installed on an x86_64 system?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM