Jump to content
Nytro

Calling conventions for different C++ compilers and operating systems

Recommended Posts

Posted

Calling conventions

for different C++ compilers and operating systems

By Agner Fog. Copenhagen University College of Engineering.

Copyright © 2004 - 2011. Last updated 2011-06-08.

Contents
1 Introduction ....................................................................................................................... 3
2 The need for standardization............................................................................................. 5
3 Data representation........................................................................................................... 6
4 Data alignment .................................................................................................................. 8
5 Stack alignment................................................................................................................. 9
6 Register usage................................................................................................................ 10
6.1 Can floating point registers be used in 64-bit Windows? ........................................... 13
6.2 YMM vector registers................................................................................................ 14
6.3 Register usage in kernel code................................................................................... 14
7 Function calling conventions ........................................................................................... 16
7.1 Passing and returning objects................................................................................... 19
7.2 Passing and returning SIMD types............................................................................ 22
8 Name mangling ............................................................................................................... 24
8.1 Microsoft name mangling.......................................................................................... 28
8.2 Borland name mangling ............................................................................................ 33
8.3 Watcom name mangling ........................................................................................... 34
8.4 Gnu2 name mangling................................................................................................ 35
8.5 Gnu3-4 name mangling ............................................................................................ 37
8.6 Intel name mangling for Windows ............................................................................. 39
8.7 Intel name mangling for Linux ................................................................................... 40
8.8 Symantec and Digital Mars name mangling .............................................................. 40
8.9 Codeplay name mangling ......................................................................................... 40
8.10 Other compilers ...................................................................................................... 40
8.11 Turning off name mangling with extern "C" ............................................................. 41
8.12 Conclusion.............................................................................................................. 42
9 Exception handling and stack unwinding ......................................................................... 42
10 Initialization and termination functions........................................................................... 43
11 Virtual tables and runtime type identification.................................................................. 43
12 Communal data............................................................................................................. 44
13 Memory models............................................................................................................. 44
13.1 16-bit memory models ............................................................................................ 44
13.2 32-bit memory models ............................................................................................ 45
13.3 64-bit memory models in Windows ......................................................................... 45
13.4 64-bit memory models in Linux and BSD ................................................................ 45
13.5 64-bit memory models in Intel-based Mac (Darwin) ................................................ 45
14 Relocation of executable code....................................................................................... 46
15 Object file formats .........................................................................................................48
15.1 OMF format............................................................................................................. 48
15.2 COFF format........................................................................................................... 49
15.3 ELF format.............................................................................................................. 49
15.4 Mach-O format........................................................................................................ 50
15.5 a.out format............................................................................................................. 50
15.6 Comparison of object file formats............................................................................ 50
15.7 Conversion between object file formats................................................................... 50
15.8 Intermediate file formats ......................................................................................... 51
16 Debug information......................................................................................................... 51
17 Data endian-ness .......................................................................................................... 52
2
18 Predefined macros ........................................................................................................ 52
19 Available C++ Compilers ............................................................................................... 54
19.1 Microsoft .................................................................................................................54
19.2 Borland ...................................................................................................................54
19.3 Watcom .................................................................................................................. 54
19.4 Gnu......................................................................................................................... 54
19.5 Digital Mars............................................................................................................. 54
19.6 Codeplay ................................................................................................................ 54
19.7 Intel......................................................................................................................... 54
20 Literature...................................................................................................................... 55
20.1 ABI’s for Unix, Linux, BSD and Mac OS X (Intel-based).......................................... 55
20.2 ABIs for Windows.................................................................................................... 55
20.3 Object file format specifications............................................................................... 56
21 Copyright notice ............................................................................................................56
22 Acknowledgments ......................................................................................................... 56

Via: Software optimization resources - rohitab.com - Forums

Download:

http://agner.org/optimize/calling_conventions.pdf

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...