|
发表于 2022-8-28 15:13:33
|
显示全部楼层
看汇编代码么
a &a &a[0] 这三个的值都是一样的,都是 leal -0x20(%ebp),%eax
- int main(void) {
- 118d: 8d 4c 24 04 leal 0x4(%esp),%ecx
- 1191: 83 e4 f0 andl $0xfffffff0,%esp
- 1194: ff 71 fc pushl -0x4(%ecx)
- 1197: 55 pushl %ebp
- 1198: 89 e5 movl %esp,%ebp
- 119a: 53 pushl %ebx
- 119b: 51 pushl %ecx
- 119c: 83 ec 20 subl $0x20,%esp
- 119f: e8 ec fe ff ff calll 1090 <__x86.get_pc_thunk.bx>
- 11a4: 81 c3 50 2e 00 00 addl $0x2e50,%ebx
- 11aa: 65 a1 14 00 00 00 movl %gs:0x14,%eax
- 11b0: 89 45 f4 movl %eax,-0xc(%ebp)
- 11b3: 31 c0 xorl %eax,%eax
- int a[5] = {1, 2, 3, 4, 5};
- 11b5: c7 45 e0 01 00 00 00 movl $0x1,-0x20(%ebp)
- 11bc: c7 45 e4 02 00 00 00 movl $0x2,-0x1c(%ebp)
- 11c3: c7 45 e8 03 00 00 00 movl $0x3,-0x18(%ebp)
- 11ca: c7 45 ec 04 00 00 00 movl $0x4,-0x14(%ebp)
- 11d1: c7 45 f0 05 00 00 00 movl $0x5,-0x10(%ebp)
- printf("%p, %p, %p\n", a, &a, &a[0]);
- 11d8: 8d 45 e0 leal -0x20(%ebp),%eax
- 11db: 50 pushl %eax
- 11dc: 8d 45 e0 leal -0x20(%ebp),%eax
- 11df: 50 pushl %eax
- 11e0: 8d 45 e0 leal -0x20(%ebp),%eax
- 11e3: 50 pushl %eax
- 11e4: 8d 83 14 e0 ff ff leal -0x1fec(%ebx),%eax
- 11ea: 50 pushl %eax
- 11eb: e8 60 fe ff ff calll 1050 <printf@plt>
- 11f0: 83 c4 10 addl $0x10,%esp
- printf("%x, %p, %x\n", *a, *&a, *&a[0]);
- 11f3: 8b 55 e0 movl -0x20(%ebp),%edx
- 11f6: 8b 45 e0 movl -0x20(%ebp),%eax
- 11f9: 52 pushl %edx
- 11fa: 8d 55 e0 leal -0x20(%ebp),%edx
- 11fd: 52 pushl %edx
- 11fe: 50 pushl %eax
- 11ff: 8d 83 20 e0 ff ff leal -0x1fe0(%ebx),%eax
- 1205: 50 pushl %eax
- 1206: e8 45 fe ff ff calll 1050 <printf@plt>
- 120b: 83 c4 10 addl $0x10,%esp
- return 0;
- 120e: b8 00 00 00 00 movl $0x0,%eax
- }
- 1213: 8b 55 f4 movl -0xc(%ebp),%edx
- 1216: 65 2b 15 14 00 00 00 subl %gs:0x14,%edx
- 121d: 74 05 je 1224 <main+0x97>
- 121f: e8 0c 00 00 00 calll 1230 <__stack_chk_fail_local>
- 1224: 8d 65 f8 leal -0x8(%ebp),%esp
- 1227: 59 popl %ecx
- 1228: 5b popl %ebx
- 1229: 5d popl %ebp
- 122a: 8d 61 fc leal -0x4(%ecx),%esp
- 122d: c3 retl
- 122e: 66 90 xchgw %ax,%ax
复制代码 |
|