gcc 時 -mpreferred-stack-boundary

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

转载于:https://www.cnblogs.com/bittorrent/archive/2012/09/28/2706739.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值