X32 ABI explained

The x32 ABI is an application binary interface (ABI) and one of the interfaces of the Linux kernel. The x32 ABI provides 32-bit integers, long and pointers (ILP32) on Intel and AMD 64-bit hardware. The ABI allows programs to take advantage of the benefits of x86-64 instruction set (larger number of CPU registers, better floating-point performance, faster position-independent code, shared libraries, function parameters passed via registers, faster syscall instruction) while using 32-bit pointers and thus avoiding the overhead of 64-bit pointers.[1] [2] [3]

Details

Though the x32 ABI limits the program to a virtual address space of 4 GiB, it also decreases the memory footprint of the program by making pointers smaller. This can allow it to run faster by fitting more code and more data into cache.[1] [2] [3] The best results during testing were with the 181.mcf SPEC CPU 2000 benchmark, in which the x32 ABI version was 40% faster than the x86-64 version.[3] [4] On average, x32 is 5–8% faster on the SPEC CPU integer benchmarks compared to x86-64. There is no speed advantage over x86-64 in the SPEC CPU floating-point benchmarks.[5] There are also some application benchmarks that demonstrate the advantages of the x32 ABI.[6] [7]

ABI comparison! Feature! i386 ABI! x32 ABI! x86-64 ABI
Pointers4 bytes8 bytes
Max. memory per process4 GiB128 TiB
Integer registers6 (PIC)15
FP registers816
64-bit arithmeticNoYes
Floating-point arithmeticx87SSE
Calling conventionMemoryRegisters
PIC prologue2–3 instructionsNone

History

Running a userspace that consists mostly of programs compiled in ILP32 mode and which also have principal access to 64-bit CPU instructions has not been uncommon, especially in the field of "classic RISC" chips. For example, the Solaris operating system does so for both SPARC and x86-64. On the Linux side, Debian also ships an ILP32 userspace. The underlying reason is the somewhat "more expensive" nature of LP64 code,[8] just like it has been shown for x86-64. In that regard, the x32 ABI extends the ILP32-on-64bit concept to the x86-64 platform.

Several people had discussed the benefits of an x86-64 ABI with 32-bit pointers in the years since the Athlon 64's release in 2003, notably Donald Knuth in 2008.[9] There was little publicly visible progress towards implementing such a mode until August 27, 2011, when Hans Peter Anvin announced to the Linux kernel mailing list that he and H. J. Lu had been working on the x32 ABI.[10]

That same day, Linus Torvalds replied with a concern that the use of 32-bit time values in the x32 ABI could cause problems in the future.[11] [12] This is because the use of 32-bit time values would cause the time values to overflow in the year 2038.[11] [12] Following this request, the developers of the x32 ABI changed the time values to 64-bit.[13]

A presentation at the Linux Plumbers Conference on September 7, 2011, covered the x32 ABI.[2]

The x32 ABI was merged into the Linux kernel for the 3.4 release with support being added to the GNU C Library in version 2.16.[14]

In December 2018 there was discussion as to whether to deprecate the x32 ABI, which has not happened as of April 2023.[15] Neither it has happenedas of May 2024, and even more, it got some new development.[16]

Adoption

Linux distribution More information
DebianX32 Port
GentooMultilib via use-flags
Yocto ProjectX32 ABI
T2 SDEx86-64

External links

Notes and References

  1. News: Kernel Log: x32 ABI gets around 64-bit drawbacks . https://web.archive.org/web/20111028081253/http://www.h-online.com/open/features/Kernel-Log-x32-ABI-gets-around-64-bit-drawbacks-1342061.html. 28 October 2011. www.h-online.com . Thorsten Leemhuis . 2011-09-13 . 2011-11-01.
  2. News: x32 - a native 32-bit ABI for x86-64 . linuxplumbersconf.org . 2012-06-12.
  3. News: x32-abi . Google Sites . 2011-11-01.
  4. News: 181.mcf SPEC CPU2000 Benchmark Description File . Standard Performance Evaluation Corporation . 1999-10-14 . 2011-11-01.
  5. News: X32 - A Native 32bit ABI For X86-64 . H. J. Lu . H. Peter Anvin . Milind Girkar . September 2011.
  6. Rauschmayr . Nathalie . Streit . Achim . 2013 . Evaluation of x32-ABI in the Context of LHC Applications . Procedia Computer Science . 18 . 2233–2240 . 10.1016/j.procs.2013.05.394 . free .
  7. Web site: Applications that Profit from the Underrated x32-ABI. www.sempria.de. 22 May 2023.
  8. Web site: Are 64-bit Binaries Really Slower than 32-bit Binaries?. 2004-01-22. 2014-03-25. Tony Bourke.
  9. Web site: Recent News: A Flame About 64-bit Pointers . Donald Knuth . February 2008 . 15 May 2012.
  10. Web site: RFD: x32 ABI system call numbers . H. Peter Anvin . 27 August 2011 . 15 May 2012.
  11. News: The x32 system call ABI . LWN.net . Jonathan Corbet . 2011-08-29 . 2011-11-01.
  12. News: Re: RFD: x32 ABI system call numbers . LWN.net . Linus Torvalds . 2011-08-26 . 2016-02-26.
  13. X32 project status update . libc-alpha . H. J. . Lu . 2011-11-24 . 2019-10-17 .
  14. The GNU C Library version 2.16 is now available. . 30 June 2012 . 27 December 2016 . libc-alpha . O'Donell . Carlos.
  15. Web site: Can we drop upstream Linux x32 support? . LKML . 13 March 2019.
  16. Web site: The first half of the 6.10 merge window . LWN . 17 May 2024.