Linux-Stack frames for functions

Source: Internet
Author: User

  Stack frame, the machine uses stacks to pass process parameters, store return information, save registers for later recovery, and local storage. The portion of the stack allocated for a single procedure (function call) is called a stack frame. The stack frame is actually a two pointer register,

The register%EBP is a frame pointer, and the register is%esp as a stack pointer, and when the program runs, the stack pointer can move (most of the information is accessed through the frame pointer). In short, the main function of the stack frame is to control and save a process

All the information. The stack frame structure looks like this:

 Below, we use a simple program to understand the stack frame:

  Simple function analysis, such as:

 the stack frame condition of the function :

When *p=bug, modify the position of the return value in the stack frame, so that the function is not returned normally, but into the bug function, when the Exit function is encountered, the program terminates, does not jump back to the main function to terminate.

Linux-Stack frames for functions

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.