X86-64 CPU Architecture and 64-bit GCC changes to program compilation processing
Jochen1986
Reprint Please specify source: http://blog.csdn.net/youkawa/article/details/45458921
- Universal registers are all extended to 64 bits, with the register name preceded by R, such as RAX, RBX, RCX, RDX, RSI and RDI;
- The instruction pointer (instruction pointer), the base address pointer (base pointer), and the stack pointer
Pointer) has also been extended to the four-bit, these special registers are called rip,rbp,rsprespectively;
- Added 8 General Register R8~R15;
- The pointer length is 64 bits i.e. 8-bytes length;
- The length of the push/pop instruction that involves the stack operation is 64 bits or 8-bytes length;
- function parameters mainly rely on 6 registers to pass, when the register is not enough to push the parameters into the stack storage. According to the order of storage parameters (from left to right) RDI, RSI, RDX, RCX, R8, R9;
- The maximum canonical address size is 0x00007fffffffffff.
- GCC allocates a function local variable to a multiple of 16 bytes , such as assigning Char a[15], then the local variable is stored back from the [rbp-0x10] address, and if Char a[17] is defined, the local variable is stored from the [rbp-0x20] address;
- GCC allocates space for function local variables in the following ways:
(1) When the function internal calls other external functions (with a call command), using SUB RSP, 0xXX instruction allocation stack space, and then use MOV [rbp-x], 0xXX form into the stack, if there is no local variable initialization, And this variable is not used behind the function, and GCC does not open space for it.
(2) When no other external functions are called inside the function, the prologue operation is performed (that is, the push RBP; mov RBP, RSP), there will be no SUB RSP, 0xXX instruction to open up the operation of the stack space, but directly using the MOV QWORD PTR [rbp-0xxx], 0xXX Way directly using the stack space;
(3) When the function internal static call Lib library function, because at this time the called function is inside the heart function, so there is no call command, still in the way (2) operation.
X86-64 CPU Architecture and 64-bit GCC changes to program compilation processing