Nytro Posted January 29, 2012 Report Posted January 29, 2012 Calling conventionsfor different C++ compilers and operating systemsBy Agner Fog. Copenhagen University College of Engineering.Copyright © 2004 - 2011. Last updated 2011-06-08.Contents1 Introduction ....................................................................................................................... 32 The need for standardization............................................................................................. 53 Data representation........................................................................................................... 64 Data alignment .................................................................................................................. 85 Stack alignment................................................................................................................. 96 Register usage................................................................................................................ 106.1 Can floating point registers be used in 64-bit Windows? ........................................... 136.2 YMM vector registers................................................................................................ 146.3 Register usage in kernel code................................................................................... 147 Function calling conventions ........................................................................................... 167.1 Passing and returning objects................................................................................... 197.2 Passing and returning SIMD types............................................................................ 228 Name mangling ............................................................................................................... 248.1 Microsoft name mangling.......................................................................................... 288.2 Borland name mangling ............................................................................................ 338.3 Watcom name mangling ........................................................................................... 348.4 Gnu2 name mangling................................................................................................ 358.5 Gnu3-4 name mangling ............................................................................................ 378.6 Intel name mangling for Windows ............................................................................. 398.7 Intel name mangling for Linux ................................................................................... 408.8 Symantec and Digital Mars name mangling .............................................................. 408.9 Codeplay name mangling ......................................................................................... 408.10 Other compilers ...................................................................................................... 408.11 Turning off name mangling with extern "C" ............................................................. 418.12 Conclusion.............................................................................................................. 429 Exception handling and stack unwinding ......................................................................... 4210 Initialization and termination functions........................................................................... 4311 Virtual tables and runtime type identification.................................................................. 4312 Communal data............................................................................................................. 4413 Memory models............................................................................................................. 4413.1 16-bit memory models ............................................................................................ 4413.2 32-bit memory models ............................................................................................ 4513.3 64-bit memory models in Windows ......................................................................... 4513.4 64-bit memory models in Linux and BSD ................................................................ 4513.5 64-bit memory models in Intel-based Mac (Darwin) ................................................ 4514 Relocation of executable code....................................................................................... 4615 Object file formats .........................................................................................................4815.1 OMF format............................................................................................................. 4815.2 COFF format........................................................................................................... 4915.3 ELF format.............................................................................................................. 4915.4 Mach-O format........................................................................................................ 5015.5 a.out format............................................................................................................. 5015.6 Comparison of object file formats............................................................................ 5015.7 Conversion between object file formats................................................................... 5015.8 Intermediate file formats ......................................................................................... 5116 Debug information......................................................................................................... 5117 Data endian-ness .......................................................................................................... 52218 Predefined macros ........................................................................................................ 5219 Available C++ Compilers ............................................................................................... 5419.1 Microsoft .................................................................................................................5419.2 Borland ...................................................................................................................5419.3 Watcom .................................................................................................................. 5419.4 Gnu......................................................................................................................... 5419.5 Digital Mars............................................................................................................. 5419.6 Codeplay ................................................................................................................ 5419.7 Intel......................................................................................................................... 5420 Literature...................................................................................................................... 5520.1 ABI’s for Unix, Linux, BSD and Mac OS X (Intel-based).......................................... 5520.2 ABIs for Windows.................................................................................................... 5520.3 Object file format specifications............................................................................... 5621 Copyright notice ............................................................................................................5622 Acknowledgments ......................................................................................................... 56Via: Software optimization resources - rohitab.com - ForumsDownload:http://agner.org/optimize/calling_conventions.pdf Quote