珍藏 char a[5] = "king"这个king会在常量段有备份
收藏 char a[5] = "king";这个king会在常量段有备份?
之前看到的 一个帖子 没讨论完,就被结贴了,我还有疑问,现贴出来,希望大神指教
环境:ubuntu 3.2.0-38-generic-pae
工具:gcc
反汇编结果:
linux下反汇编结果 显示 “king”被直接压入栈,并未有什么备份
希望vc的朋友,贴一下反汇编的结果
------解决方案--------------------
之前看到的 一个帖子 没讨论完,就被结贴了,我还有疑问,现贴出来,希望大神指教
环境:ubuntu 3.2.0-38-generic-pae
工具:gcc
#include <stdio.h>
int main(void)
{
char a[] = "king";
return 0;
}
反汇编结果:
#include <stdio.h>
int main(void)
{
8048404: 55 push %ebp
8048405: 89 e5 mov %esp,%ebp
8048407: 83 e4 f0 and $0xfffffff0,%esp
804840a: 83 ec 10 sub $0x10,%esp
804840d: 65 a1 14 00 00 00 mov %gs:0x14,%eax
8048413: 89 44 24 0c mov %eax,0xc(%esp)
8048417: 31 c0 xor %eax,%eax
char a[] = "king";
8048419: c7 44 24 07 6b 69 6e movl $0x676e696b,0x7(%esp)
8048420: 67 // 将"king"直接压入栈,未访问其他区域
8048421: c6 44 24 0b 00 movb $0x0,0xb(%esp)
return 0;
8048426: b8 00 00 00 00 mov $0x0,%eax
}
804842b: 8b 54 24 0c mov 0xc(%esp),%edx
804842f: 65 33 15 14 00 00 00 xor %gs:0x14,%edx
8048436: 74 05 je 804843d <main+0x39>
8048438: e8 e3 fe ff ff call 8048320 <__stack_chk_fail@plt>
804843d: c9 leave
804843e: c3 ret
804843f: 90 nop
linux下反汇编结果 显示 “king”被直接压入栈,并未有什么备份
希望vc的朋友,贴一下反汇编的结果
汇编
linux
gcc
c
------解决方案--------------------
(gdb) list
1
2 #include <stdio.h>
3
4 int main(void)
5 {
6 char p[] = "king";
7 return 0;
8
9 }
(gdb) disassemble main
Dump of assembler code for function main:
0x00000000004004c0 <+0>: movl $0x0,-0x4(%rsp)