zoukankan      html  css  js  c++  java
  • gcc 時 mpreferredstackboundary

     1 #include <stdio.h>
     2 void function(int a,int b)
     3 {
     4 int array[5];  // total : 20 bytes.
     5 }
     6 
     7 main()
     8 {
     9 printf("this is where the return address points");
    10 }

    預設  -mpreferred-stack-boundary=4 ( the default is 4 ) i,e:one unit is 16 bytes

    Dump of assembler code for function main:
    0x00401394 <+0>: push %ebp
    0x00401395 <+1>: mov %esp,%ebp
    0x00401397 <+3>: and $0xfffffff0,%esp
    0x0040139a <+6>: sub $0x10,%esp
    0x0040139d <+9>: call 0x4018cc <__main>
    0x004013a2 <+14>: movl $0x403064,(%esp)
    0x004013a9 <+21>: call 0x401b04 <printf>
    0x004013ae <+26>: leave
    0x004013af <+27>: ret
    End of assembler dump.

     -mpreferred-stack-boundary=2 i,e: one unit is 4 bytes

    (gdb) disas main
    Dump of assembler code for function main:
    0x00401394 <+0>: push %ebp
    0x00401395 <+1>: mov %esp,%ebp
    0x00401397 <+3>: sub $0x4,%esp
    0x0040139a <+6>: call 0x4018cc <__main>
    0x0040139f <+11>: movl $0x403064,(%esp)
    0x004013a6 <+18>: call 0x401b04 <printf>
    0x004013ab <+23>: leave
    0x004013ac <+24>: ret
    End of assembler dump.

    qoute:

       -mpreferred-stack-boundary=num
    	       Attempt to keep the stack boundary aligned to a 2 raised to num
    	       byte boundary.  If -mpreferred-stack-boundary is not specified, the
    	       default is 4 (16 bytes or 128 bits).

  • 相关阅读:
    UWP AppConnection.
    Qt 多线程使用moveToThread
    C#综合细说进程、应用程序域与上下文
    C++ std::function
    商品价格加价区间的实现(策略模式)
    学习web前端三个月感悟
    triangle leetcode C++
    Linux入门视频
    轻松学习Linux之进程监视与管理
    阻止缓冲区溢出攻击
  • 原文地址:https://www.cnblogs.com/bittorrent/p/2706739.html
Copyright © 2011-2022 走看看