The information in this document is based on Mac OS X v Organization of This Document See Also. This document is intended for developers interested in the calling conventions used in the Mac OS X ABI on each of the supported architectures. This information is especially useful to developers of development tools. Each of these articles describes the data types that can be used to manipulate the arguments and results of function calls, how routines pass arguments to the functions they call, and how functions pass results to their callers. They also list the registers available in each architecture and whether their value is preserved after a function call.
|Published (Last):||12 February 2016|
|PDF File Size:||4.97 Mb|
|ePub File Size:||20.11 Mb|
|Price:||Free* [*Free Regsitration Required]|
Rafael Passarinho flag Denunciar. GDB is able to handle this properly, but other debugging techniques might have difficulties such as using a home- grown stack traceback function. It is also important to note that when using gcc 3. If omitting the frame pointer is not desired but optimization is, be sure to compile your program with something like the following: gcc -o myexe myexe.
RAM stores the instructions that run on the CPU, but given that the CPU is really just a huge maze of logic gates, there is a need for intermediate storage areas that are very close to the CPU and still fast enough to feed it as quickly as it can process the instructions.
Most systems have only a very small number of registers, and some of these registers have a dedicated purpose and so cannot simply be used at will. Because every function that executes has access to and can manipulate the exact same registers, there must be a set of rules that govern how registers are used between function calls.
The function caller and function callee must know exactly what to expect from the registers and how to properly use them without clobbering one another. This set of rules is called the function or procedure calling conventions. They are architecture-specific and very important to know and understand for all software developers. The purpose of this section is to give an overview of the basics of the calling conventions and should not be considered an exhaustive reference.
The ABI is basically a blueprint for how software interacts with an architecture, so there is great value in reading these documents. Now we must learn the rules for calling a function. For example, if function1 calls function2 with five parameters, how does function2 know where to find these parameters and what to do with them?
The answer to this is actually quite simple. The calling function simply pushes the function arguments onto the stack starting with the right-most parameter and working toward the left. This is illustrated in the following diagram. Recall that creating an assembly listing can be done with the following command assuming our program is called pizza.
This function contains the instructions of interest that clearly illustrate the x86 calling conventions. In particular, note these instructions: 5. Looking back at pizza. In pizza. This is illustrated in the previous assembly listing.
Index of /~milan/download/micro
Introduction to Mac OS X ABI Function Call Guide
Index of /elf