- 论坛徽章:
- 4
|
回复 14# md231
我的系统gcc编译结果和你的相反,clang编译和你的相同。
用objdump反汇编后发现
gcc反汇编结果:- 080483c4 <main>:
- 80483c4: 55 push %ebp
- 80483c5: 89 e5 mov %esp,%ebp
- 80483c7: 83 e4 f0 and $0xfffffff0,%esp
- 80483ca: 83 ec 10 sub $0x10,%esp
- 80483cd: b8 d4 84 04 08 mov $0x80484d4,%eax
- 80483d2: 8d 55 08 lea 0x8(%ebp),%edx
- 80483d5: 89 54 24 0c mov %edx,0xc(%esp)
- 80483d9: 8d 55 0c lea 0xc(%ebp),%edx
- 80483dc: 89 54 24 08 mov %edx,0x8(%esp)
- 80483e0: 8d 55 10 lea 0x10(%ebp),%edx
- 80483e3: 89 54 24 04 mov %edx,0x4(%esp)
- 80483e7: 89 04 24 mov %eax,(%esp)
- 80483ea: e8 f1 fe ff ff call 80482e0 <printf@plt>
- 80483ef: b8 00 00 00 00 mov $0x0,%eax
- 80483f4: c9 leave
- 80483f5: c3 ret
复制代码 这个比较简单,就是取各个参数的地址。
clang反汇编结果:- 080483b0 <main>:
- 80483b0: 55 push %ebp
- 80483b1: 89 e5 mov %esp,%ebp
- 80483b3: 56 push %esi
- 80483b4: 83 ec 34 sub $0x34,%esp
- 80483b7: 8b 45 10 mov 0x10(%ebp),%eax
- 80483ba: 8b 4d 0c mov 0xc(%ebp),%ecx
- 80483bd: 8b 55 08 mov 0x8(%ebp),%edx
- 80483c0: 89 45 e8 mov %eax,-0x18(%ebp)
- 80483c3: b8 00 00 00 00 mov $0x0,%eax
- 80483c8: c7 45 f8 00 00 00 00 movl $0x0,-0x8(%ebp)
- 80483cf: 89 55 f4 mov %edx,-0xc(%ebp)
- 80483d2: 89 4d f0 mov %ecx,-0x10(%ebp)
- 80483d5: 8b 4d e8 mov -0x18(%ebp),%ecx
- 80483d8: 89 4d ec mov %ecx,-0x14(%ebp)
- 80483db: 8d 55 f4 lea -0xc(%ebp),%edx
- 80483de: 89 e6 mov %esp,%esi
- 80483e0: 89 56 0c mov %edx,0xc(%esi)
- 80483e3: 8d 55 f0 lea -0x10(%ebp),%edx
- 80483e6: 89 56 08 mov %edx,0x8(%esi)
- 80483e9: 8d 55 ec lea -0x14(%ebp),%edx
- 80483ec: 89 56 04 mov %edx,0x4(%esi)
- 80483ef: c7 06 e4 84 04 08 movl $0x80484e4,(%esi)
- 80483f5: 89 45 e4 mov %eax,-0x1c(%ebp)
- 80483f8: e8 c3 fe ff ff call 80482c0 <printf@plt>
- 80483fd: 89 45 e0 mov %eax,-0x20(%ebp)
- 8048400: 8b 45 e4 mov -0x1c(%ebp),%eax
- 8048403: 83 c4 34 add $0x34,%esp
- 8048406: 5e pop %esi
- 8048407: 5d pop %ebp
- 8048408: c3 ret
复制代码 这个处理麻烦一些,可见它将参数先拷贝到自身的堆栈空间,然后取地址。所以clang取地址时已经不是原来参数的地址了。
|
|