Thoughts on the problem of Csapp lab3 in middle pressure stack

Source: Internet
Author: User


There was a question and no special attention, I came back today to see the mail found that some classmates and I discuss the function call stack problem.



Talk less, directly on the comparison test chart:

Figure one: Csapp Lab3 's Getbuf disassembly results



Figure II: I tested, excerpt part of the GETBUF implementation, and then very simple to test the Getbuf disassembly results, disassembly results such as


How on earth did I test it:

unsigned long long getbuf () {  char buf[36];  Volatile char* variable_length;  int i;  unsigned long long Val;  return val% 40;} int main () {    getbuf ();    return 0;}

Individuals still feel that the test code is not a problem. The main thing is to observe how the BUF array is compressed. Preserving the other local variables is possible, theoretically without affecting the size of the new stack that the ESP self-decrement opens.


But ... but.

Q1:

Children's shoes can be clearly seen here the results of the two disassembly are different.

The former opens up the 0x30 size of the stack frame

The latter opened up the 0x40 size of the stack frame.


Q2:

Using Csapp's executable program, GDB debugs and then looks at the disassembler.

Observe the address of the register RBP and BUF.


That is, buf array distance from the stack base address (RBP register point), the difference between the size of 0x30.

There should be only buf array elements in this area, and no other variables or registers are pressed to stack. So I suspect this buf array (originally only 36byte) is aligned to 48byte (0x30), but this is not explained, because if you follow the 64-bit operating system, 8byte alignment, as long as the alignment to

0x28 on it, no 0x30. The difference between the 8byte here is a question.





There is a master passing, implore guidance ...






Thoughts on the problem of Csapp lab3 in middle pressure stack

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.