x86-64 System V ABI记录在哪里? [英] Where is the x86-64 System V ABI documented?

查看:188
本文介绍了x86-64 System V ABI记录在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用于 http:的x86-64 System V ABI(用于Windows以外的所有设备) //x86-64.org/documentation/abi.pdf ,但该站点现在已脱离互联网.

该文档是否有新的权威目录?

解决方案

System V x86-64 psABI在GitHub上维护. HJ Lu的github页面上有具有指向当前版本链接的Wiki x86-64和i386 SystemV psABI文档,以及讨论更新的论坛.

另请参见 x86-64的版本是1.0(2018年1月)..还有一个更新的2018年12月草案版本(具有讽刺意味的是)从PDF的草案1.0"版本号中删除了草案"本身.
x32 ABI(长模式下的32位指针)是x86-64 ABI文档的一部分.请参阅第10章:ILP32编程模型.

i386的当前版本为1.1 . (请注意,某些操作系统使用的i386 ABI的较旧版本不需要16字节的堆栈对齐,仅需要4.GCC最终取决于-mpreferred-stack-boundary=4 16字节的SSE代码源对齐(可能是无意的),并最终将ABI更新为Linux,以将其作为正式要求.我尝试在对GCC错误#40838的评论.这会破坏与一些调用其他功能的手写组件的向后兼容.)

非正式地,系统V的补充. gABI (通用),位于SCO网站上.


其他链接

https://refspecs.linuxfoundation.org/托管着一份1997年的gABI副本. /p>

https://uclibc.org/specs.html 具有用于各种非x86 ISA的psABI链接. (例如,尽管ARM似乎只记录了ELF文件布局,而不记录调用约定或进程启动状态.) UNIX&的调用约定是什么?在i386和x86-64上的Linux系统调用描述了x86-64 SysV(以及i386 Linux与FreeBSD)的系统调用调用约定.

它还总结了整数args的函数调用约定. 系统调用不带FP或SSE/AVX向量args,也不带值结构,因此函数调用约定更加复杂.


Agner Fog有一个调用约定指南 (涵盖Windows与Sys V ,以及有关32位的各种约定以及编写可在任一平台上使用的函数的技巧/窍门.这是与他的优化和微体系结构指南和说明表(如果您关心性能的必读内容)分开的PDF.

Wikipedia有 x86调用约定文章,其中描述了各种约定,但大多数细节不够详尽可以将它们用于除简单整数args之外的任何内容. (例如,没有对struct-packing规则的描述).


相关: C ++ ABI

GCC和Clang(在所有体系结构上)都使用最初为Itanium开发的C ++ ABI. https://itanium-cxx-abi.github.io/cxx-abi/.例如,这与需要在寄存器中传递C ++结构/类的要求有关(例如,根据某种定义是聚合).

The x86-64 System V ABI (used on everything except Windows) used to live at http://x86-64.org/documentation/abi.pdf, but that site has now fallen off the internet.

Is there a new authoritative home for the document?

解决方案

The System V x86-64 psABI is maintained on GitHub. H.J. Lu's github page has a wiki with links to the current versions of the x86-64 and i386 SystemV psABI documents, and to the forums where updates are discussed.

See also the tag wiki for direct links to the latest versions.

As of now, the current version for x86-64 is 1.0 (January 2018). There's a more recent 2018-dec draft version which (ironically) removes the "Draft" from the "Draft 1.0" version number in the PDF itself.
The x32 ABI (32-bit pointers in long mode) is part of the x86-64 ABI doc. See Chapter 10: ILP32 Programming Model.

The current version for i386 is 1.1. (Note that some OSes use an older version of the i386 ABI which doesn't require 16-byte stack alignment, only 4. GCC ended up depending on -mpreferred-stack-boundary=4 16-byte alignment for its SSE code-gen (perhaps unintentionally), and eventually the ABI got updated for Linux to enshrine that as an official requirement. I attempted a summary in a comment on GCC bug #40838. This breaks backwards compat with some hand-written asm that calls other functions.)

Unofficially, sign-extending narrow args to 32-bit is required (for both i386 and amd64), because clang depends on it. Hopefully a future ABI revision will document that.


Naming: psABI

The Processor Supplement (psABI) docs are designed as a supplement to the less-frequently-updated System V gABI (generic), hosted on SCO's website.


Other links

Also https://refspecs.linuxfoundation.org/ hosts a copy of the gABI from 1997.

https://uclibc.org/specs.html has psABI links for various non-x86 ISAs. (Although for example the ARM one only seems to document the ELF file layout, not the calling convention or process startup state.) https://uclibc.org/docs/psABI-x86_64.pdf is an outdated copy of the x86-64 psABI (0.99.7 from 2014). The version on GitHub has clearer wording of a few things and bugfixes in some examples.


Related: What are the calling conventions for UNIX & Linux system calls on i386 and x86-64 describes the system-call calling convention for x86-64 SysV (as well as i386 Linux vs. FreeBSD).

It also summarizes the function calling conventions for integer args. System calls don't take FP or SSE/AVX vector args, or structs by value, so the function-calling convention is more complicated.


Agner Fog has a calling conventions guide (covering Windows vs. Sys V, and the various conventions for 32-bit, and tips/tricks for writing functions you can use on either platform). This is a separate PDF from his optimization and microarchitecture guides and instruction tables (which are essential reading if you care about performance.)

Wikipedia has an x86 calling conventions article which describes various conventions, but mostly not in enough detail to use them for anything other than simple integer args. (e.g. no description of struct-packing rules).


Related: C++ ABI

GCC and Clang (on all architectures) use the C++ ABI originally developed for Itanium. https://itanium-cxx-abi.github.io/cxx-abi/. This is relevant for example for what requirements a C++ struct/class need to be passed in registers (e.g. being an aggregate according to some definition).

这篇关于x86-64 System V ABI记录在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆