Release-to-release compatibility is critical in the games industry, where old games must be able to run on an updated PlayStation® operating system. To guard against incompatibilities from creeping in, we developed a C++ ABI test suite for all currently supported PlayStation® platforms (PlayStation®3 (PS3) and PlayStation®Vita (PS Vita) as well as PlayStation®4 (PS4)). We have contributed this test suite to the open source community for others to freely use. It can be found at http://llvm.org/svn/llvm-project/test-suite/trunk/ABI-Testsuite.
What is an ABI?
The C++ ABI defines how high level C++ constructs are implemented at a low-level. Among other things, it sets the rules that define how function name mangling is performed to allow overloaded functions, how base classes are allocated, and how virtual functions are called. Object files being linked together need to agree on these rules for the whole program to work together. Any incompatibilities in the ABI implemented by the compiler will impact how the program modules talk with each other, which can be really painful for programmers to diagnose. ABI incompatibility bugs are particularly insidious because:
- Debuggers rely on the compiler-generated debug information which is also incorrect, so they are often of limited use when attempting to analyze this kind of problem.
- Looking in isolation each file of compiled code looks valid. The malfunction appears only when they are linked together.
The C++ ABI used by most current C++ compilers, commonly known as the IA-64 ABI, or Itanium ABI, was initially developed for the Itanium 64 bit processor, but has since been adapted by many commonly used compilers, such as GNU-C++, ARMcc, Clang/LLVM and the PlayStation® compilers for PS3, PSVita and PS4. Other than the Microsoft Visual C++ compiler, it has become the de-facto standard among compiler vendors. The current public version of this ABI is available at http://mentorembedded.github.io/cxx-abi/abi.html.
What does the ABI Test-Suite do?
Our ABI test-suite tests a compiler’s implementation against an ABI specification by having C++ code that exercises each part of the ABI specification, and compares the layout generated by the compiler to the ‘correct value’. The test-suite consists of slightly over one million unique classes spread over roughly four hundred test files.
What does it test?
- Size and alignments of classes
- Offsets of fields and base classes
- Bit fields
- vtbl and VTT contents
- ctor and dtor vtables
- Name mangling
- Empty classes
- Thunks
- Init guard variables
- RTTI /typeinfo vars
How were the tests created?
Tests for name mangling were created manually, but the bulk of the test suite is devoted to testing object layout, Vtables, VTTs etc. Classes for these tests were created by studying the ABI specification, exhaustive enumeration within some parameters, and by inspecting existing codebases. Actual tests were generated by a test generator created by modifying our SNC compilers. C level struct allocation is also tested, along with bit fields, and packed attributes.
If you would like to read more, you can download the README.txt, FAQ.pdf and the Design document that can be found within the test-suite: http://llvm.org/svn/llvm-project/test-suite/trunk/ABI-Testsuite
Back to top