当前位置:网站首页>Stack frame
Stack frame
2022-07-01 00:33:00 【Wan Xi a Shuai】
Stack frame stack frame
Every function call will maintain a stack frame (stack frame), Stack frame is mainly used to pass parameters 、 Save return address 、 Save local variables, etc . First go directly to the previous one 《 Deep understanding of computer systems 》 Original image on .
among ,%rsp Point to the top of the stack ,%rbp Point to the bottom of the stack . And the stack grows from high address to address .
The layout of local variables is determined by the compiler , It may be from a high address to a low address , It may also change from low address to high address .
Before the called function 6 Parameters will be passed in by registers , exceed 6 The part of will be passed through the stack . What needs to be noted here is , In order to get the address of the input parameter in the called function , The called function will be before 6 Parameters are pushed into the stack of the called function .
Function call procedure :
- Parameter stack . In a certain order, the parameters will exceed 6 Stack the parameters after .
- Return the address to the stack . Push an instruction address of the current code onto the stack , Function returns to continue execution .
- Jump into the address of the called function .
- EBP Push , Save the current stack frame state value .
- ESP Value is assigned to EBP.
- Allocate the current stack frame .
Function return procedure :
- Save the return value of the called function to EAX In the register .
- recovery ESP.
- The calling function stack frame saved at the bottom of the called function EBP Value pop in EBP register , Recover the calling function stack frame .
- Pop up the current stack top element , Get the return address from the stack .
Here is an example to verify the next stack frame layout :
Enter the first main Functional func Function call point :

%rbp The value is 0x7fffffffe110,%rsp The value of is 0x7fffffffe0f0. The address of the next instruction can be obtained from disassembly 0x4008f4. Based on this information, we can deduce main Functions and func The stack frame of the function is as follows :
The above stack frame information can dgb Print verification during debugging :


Reference resources :
- Deep understanding of computer systems
边栏推荐
- Combining online and offline, VR panorama is a good way to transform furniture online!
- 20220216 misc buuctf backdoor killing (d shield scanning) - clues in the packet (Base64 to image)
- Solutions to errors in installing OpenSSL for CentOS 6.3 x64 PHP 5.2.6 extensions
- Bugku CTF daily one question dark cloud invitation code
- [PHP] self developed framework qphp, used by qphp framework
- New trend of embedded software development: Devops
- 2022-2028 global 3D printing ASA consumables industry research and trend analysis report
- Error 2059 when Navicat connects to MySQL
- Never use redis expired monitoring to implement scheduled tasks!
- 2022-2028 global ultra high purity electrolytic iron sheet industry research and trend analysis report
猜你喜欢

Gateway service gateway

深入理解 Jetpack Compose 内核:SlotTable 系统

Why did kubernetes win? The changes in the container circle!

ABAQUS 2022 latest edition - perfect realistic simulation solution

The programmer's girlfriend gave me a fatigue driving test

Error 2059 when Navicat connects to MySQL

20220215-ctf-misc-buuctf-ningen--binwalk analysis --dd command separation --archpr brute force cracking

Redis - cache penetration, cache breakdown, cache avalanche

2022-2028 global PTFE lined valve industry research and trend analysis report

女朋友说:你要搞懂了MySQL三大日志,我就让你嘿嘿嘿!
随机推荐
Is it safe to choose mobile phone for stock trading account opening in Hangzhou?
How to use robots Txt and its detailed explanation
Solving the weird problem that the query conditions affect the value of query fields in MySQL query
1175. 質數排列 / 劍指 Offer II 104. 排列的數目
2022-2028 global PTFE lined valve industry research and trend analysis report
2022-2028 global weight loss ginger tea industry research and trend analysis report
6-1 exploit -ftp exploit
Software engineering best practices - project requirements analysis
女朋友说:你要搞懂了MySQL三大日志,我就让你嘿嘿嘿!
8253A寄存器浅析
To tell you the truth, ThreadLocal is really not an advanced thing
Redis based distributed lock
Pycharm useful shortcut keys
Vulnerability discovery - App application vulnerability probe type utilization and repair
Explain kubernetes backup and recovery tools velero | learn more about carina series phase III
[NLP] [textcnn] text classification
Line number of Jenkins pipeline script execution exception
MySQL index test
需求评审,测试人员应该发挥怎样的价值?两分钟让你不再懵逼
2022-2028 global rotary transmission system industry research and trend analysis report