How the operating system works--the stack frame of the function

Source: Internet
Author: User

1 Framework Model

Call Command:

1) The address A of the next instruction in the EIP is stored at the top of the stack;

2) Set the EIP to point to the code where the program is called.

RET directive: Restore address A to the EIP

This changes the invocation of the function to the sequential execution of the instruction flow.

2 Framework Formation

Initial stack

1) Call XXX (function), when performing call, Cs:eip the original value to the call next instruction, the value is saved to the top of the stack, and then cs:eip the value, point to the entry address of XXX.

CS:EIP is pressed stack

2) Enter XXX

First instruction: PUSHL%EBP

Base address stack for superior functions

Second instruction: Movl%esp,%EBP

Creates a new function call stack in the original stack's address space

General operations in the body of a function, which may be stacked, stacked
3) Exit XXX

MOVL%ebp,%esp

POPL%EBP

After executing this command, EBP points to the original address

Ret

Cs:eip out the Stack

How the operating system works--the stack frame of the function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.