简体   繁体   中英

Difference between amd64 and Intel x86-64 stack frame

I'm learn ATT asm, so I'm also reading Linux amd64 ABI, and I notice Computer Systems: A Programmer's Perspective (CSAPP) has the same content (stack frame layout). I found the stack frame layout is different, their return address is divided into difference places. CSAPP asm code seems to set up on Intel x86_x64 (is this IA-64?).

Below is amd64 stack frame layout, 3.2.1 Registers and the Stack Frame
amd64 栈帧布局

Below is CSAPP stack frame layout.
csapp 堆栈框架布局

I assume Intel x86_x64 is IA-64, so I check Linux core IA-64 ABI , and found below picture.
在此处输入图像描述

And, I found the CSAPP describes data transfer .

When a function has more than six integral arguments, the other ones are passed on the stack. Assume that procedure P calls procedure Q with n integral arguments, such that n > 6. Then the code for P must allocate a stack frame with enough storage for arguments 7 through n.

No way to correspond, I don't quite understand why there are difference. maybe I found wrong documentation.

Update: I know that amd64 is not IA-64, also know IA-64 is Intel's Itanium. I read a little bit of wiki before asking question. I think CSAPP is in Linux environment, so I should read Linux ABI, but official documentation provides architecture list doesn't contain Intel x86_64, So appear I assume Intel x86_x64 is IA-64. Sorry, I am a novice. I want to know stack frame layout of CSAPP from which architecture, I think I will work in Unix-like, so I should learn which architecture.

在此处输入图像描述

No way to correspond, I don't quite understand why there are difference. maybe I found wrong documentation. :-)

There are up to 5 different calling conventions here:

  • The System V AMD64 ABI, which includes a red zone.

  • The Linux kernel ABI for x86_64; which is System V AMD64 ABI but without any red zone.

  • Microsoft x64 calling convention; which has "shadow space" (and no red zone)

  • Whatever Linux uses on Itanium (which has nothing to do with x86_64).

  • None of the above. For pure assembly you don't have to conform to any ABI (until/unless you're calling a shared library or something written in another language).

The "csapp stack frame layout" has no red zone; so it must be one of the other possibilities. I'd assume the Microsoft x64 calling convention is the most likely (where the diagram's "saved registers" are the 32 bytes of "shadow space"); as a user-space application is more likely than kernel-space code, 80x86 is more likely than Itanium, and it doesn't make sense to have a diagram for "no calling convention, each function does what it likes".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM