为什么在 Linux 上以 64 位模式构建的可执行文件显示机器类型为 AMD x86 64?

发布于 2025-01-06 10:18:34 字数 563 浏览 0 评论 0原文

我在尝试理解 ELF(可执行和链接格式)时遇到了这个问题。

我遵循的步骤

  1. 编写了一个简单的应用程序。 main.c 包含 int main(int argc, char **argv){ return 0;}
  2. 在linux环境下使用gcc编译。 (在英特尔笔记本电脑上完成) 最简单的命令 gcc main.c
  3. 现在,当我运行 a.out 时,它运行没有任何问题。所以构建没问题。
  4. 我使用readelf工具检索ELF信息,其中machine字段为Advanced Micro Devices X86-64。 这部分让我很困惑。

因此,我检查了 a.out 的文件头,它符合 ELF-64 规范(Value 64 - EM_X86_64)。

有人愿意解释一下,为什么在 linux 上以 64 位模式构建的可执行文件将机器类型显示为 AMD x86 64 吗?

I encountered this while trying to understand ELF (Executable and Linking Format).

Steps I followed

  1. Wrote a simple application.
    main.c containing
    int main(int argc, char **argv){ return 0;}
  2. Compiled in linux environment using gcc. (Done on intel laptop)
    Simplest command possible
    gcc main.c
  3. Now when I run a.out, it runs without any issue. So build is fine.
  4. I used readelf tool to retrieve the ELF information, where in machine field is put as Advanced Micro Devices X86-64.
    This part puzzled me.

So I checked the file header of a.out, it was as per ELF-64 specification (Value 64 - EM_X86_64).

Would anyone care to explain, why does the executable, built in 64 bit mode on linux, show machine type as AMD x86 64?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

思念绕指尖 2025-01-13 10:18:34

当 AMD 推出 x86_64 平台时,x86_64 平台被称为 AMD64 平台。最初,还不清楚英特尔是否会支持它。

您注意到 i386 不复存在多久后,许多软件都带有架构标签 i386 ?这是因为 i386 CPU 引入了软件使用的指令集。同样,AMD 引入了您的程序使用的指令集,因此它有一个架构标签,反映了第一个支持其指令集的 CPU。 (现代 32 位代码仍然经常被标记为 i686,它指的是 1995 年左右的 Pentium Pro。)

The x86_64 platform was called the AMD64 platform back when AMD introduced it. Initially, it was far from clear that Intel would ever support it.

You notice how long after i386's ceases to exist, a lot of software had the architecture tag i386? It was because i386 CPUs introduced the instruction set that software uses. Similarly, AMD introduced the instruction set your program uses, so it has an architecture tag that reflects the first CPUs that supported its instruction set. (Modern 32-bit code is still often tagged i686 which refers to the Pentium Pro, circa 1995.)

演多会厌 2025-01-13 10:18:34

有一段时间,IA-64(英特尔架构 64 位)或安腾芯片是英特尔的 64 位产品,奔腾级芯片是 IA-32 芯片。 IA-64 芯片指令集与 Pentium 代码集有很大不同,因此人们没有大量使用它。与此同时,AMD 推出了 Pentium 代码集的 64 位扩展,并得到了很多支持。过了一段时间,英特尔屈服于不可避免的局面,制造了自己的芯片,与 AMD x86/64 芯片兼容。但正是 AMD 指定了该架构,因此它获得了名称中的荣誉。

For a while, the IA-64 (Intel Architecture 64-bit) or Itanium chips were Intel's 64-bit offering, and the Pentium-class chips were the IA-32 chips. The IA-64 chip instruction set was sufficiently different from the Pentium code set that people did not pick it up in large numbers. Meanwhile, AMD came out with a 64-bit extension to the Pentium code set - and that got a lot of support. After a while, Intel bowed to the inevitable and made its own chips that were compatible with the AMD x86/64 chips. But it was AMD that specified the architecture, so it gets the credit in the name.

你的笑 2025-01-13 10:18:34

为什么可执行文件...显示机器类型为 AMD x86 64?

因为文件使用的ELF机器码是AMD注册的。有注册代码的官方列表:http://www.sco。 com/developers/gabi/latest/ch4.eheader.html(第二页的表格):

e_machine
This member's value specifies the required architecture for an individual file. 

Name    Value   Meaning
EM_NONE 0   No machine
...
EM_X86_64   62  AMD x86-64 architecture

why does the executable ... show machine type as AMD x86 64?

Because the ELF machine code, used by file, was registered by AMD. There is the official list of registered codes: http://www.sco.com/developers/gabi/latest/ch4.eheader.html (the table at second page):

e_machine
This member's value specifies the required architecture for an individual file. 

Name    Value   Meaning
EM_NONE 0   No machine
...
EM_X86_64   62  AMD x86-64 architecture
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文