与 ABI 调用约定和架构混淆

发布于 2024-09-14 06:06:35 字数 202 浏览 8 评论 0原文

我对所有这些术语感到困惑:

ABI、调用约定和硬件架构。

ABI 与架构相关:x86-64 的 ABI 与 i386 不同。 但是您也可以定义自己的调用约定 cdecl...

那么所有这些概念之间的联系是什么? 哪一个定义另一个?

我主要认为我对 ABI 感到困惑。您在调用约定的一部分中放入了什么?

谢谢

I am getting confuse with all those terms:

ABI, calling convention, and hardware architecture.

The ABI is link with the architecture: x86-64 have a different ABI than the i386.
But then you can also define your own calling convention cdecl...

Well so what is the link between all those concept?
Which one is defining the other one?

Mostly I think I am confuse with ABI. What do you put inside a part from calling convention?

Thanks

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

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

发布评论

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

评论(1

溺深海 2024-09-21 06:06:35

这是一个很大的主题,仍然可以为您提供一些指导:

ABI(应用程序二进制接口)涵盖了需要指定的细节,以便应用程序可以在特定系统(通常使用操作系统)上运行。因此,举个例子:

  • 数据类型大小(例如,C 标准只给出了类型的最低要求。int 类型至少应与 Short 一样大,而 Short 必须为 16 位。)
  • 结构体和位域
  • 调用 的内存中的布局约定(当函数被调用时,它可以在其中找到它的参数,这些参数在寄存器中,在堆栈上等)
  • 堆栈帧(堆栈上存在什么,对调试器有用)
  • 系统调用编号
  • 其他

基本上需要的任何细节为了构建与其他一些组件(库、操作系统)一起运行的程序而已知的知识可以包含在 ABI 中。有些 ABI 指定更多细节,有些指定较少细节。

硬件架构也可以被视为一种规范,但级别更低(它是关于硬件而不是软件)。硬件架构指定了可用指令集、内存层次结构以及如何访问外设等内容。对于一种硬件架构,可以有不同的 ABI。此外,您还可以对多个(但通常相似)硬件架构使用相同的 ABI。

This is a vast topic still to give you some pointers:

The ABI (application binary interface) cover the details that need to be specified in order that application can work on a certain system (usually with an operating system). So, to get to examples:

  • data type sizes (for example C standard gives just minimum requirements for the types. int type should at least as big as short, and short has to be 16 bits.)
  • layout in memory of structures and bitfields
  • calling convention (when a function is invoked where it can find it's parameters, which in registers, which on stack etc)
  • stack frame (what it is present on the stack, useful for a debugger)
  • system call numbers
  • others

Basically any detail that needs to be known in order to build a program that runs together with some other components (libraries, OS) can be included in an ABI. Some ABI specify more and some specify less details.

The hardware architecture can be also seen as a specification but of even lower level (it's about hardware not software). The hardware architecture specifies things like the instruction set available, memory hierarchy and how to access peripherals. For one hardware architecture there can be different ABI-s. Also you can have the same ABI for multiple (but usually similar) hardware architecture.

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