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).

  • 相关阅读:
    words you learn through youtube and so on in daily life
    python 随笔
    Zookeeper 指南
    Mac 后台服务
    Elasticsearch 指南
    架构之灰度部署
    架构之CDN缓存
    架构之微服务(zookeeper)
    架构之微服务(etcd)
    架构之微服务设计(Nginx + Upsync)
  • 原文地址:https://www.cnblogs.com/bittorrent/p/2706739.html
Copyright © 2011-2022 走看看