- 论坛徽章:
- 13
|
回复 6# nswcfd
我是直接编译成可执行文件的,所以已经链接过了,但是,fun1的地址是0x8048410,fun1()中的r_base值打印出来是0x48423a1。
fun1()代码(原始):- int fun1(int n)
- {
- long base, here;
- //printf("0x%x\n", (&n)[-1]);
- __asm__(
- "r_base = .\n\t"
- "r_here:movl r_base, %0\n\t"
- "movl r_here, %1\n\t"
- :"=a"((long)base), "=b"((long)here)
- :"a"(0), "b"(0)
- :
- );
- printf("0x%x, 0x%x\n", (unsigned int)base, (unsigned int)here);
- return 0;
- }
复制代码 fun1()代码(objdump -d):- 08048410 <fun1>:
- 8048410: 55 push %ebp
- 8048411: 89 e5 mov %esp,%ebp
- 8048413: 53 push %ebx
- 8048414: 83 ec 24 sub $0x24,%esp
- 8048417: b8 00 00 00 00 mov $0x0,%eax
- 804841c: ba 00 00 00 00 mov $0x0,%edx
- 8048421: 89 d3 mov %edx,%ebx
- 08048423 <r_here>:
- 8048423: a1 23 84 04 08 mov 0x8048423,%eax
- 8048428: 8b 1d 23 84 04 08 mov 0x8048423,%ebx
- 804842e: 89 da mov %ebx,%edx
- 8048430: 89 45 f0 mov %eax,-0x10(%ebp)
- 8048433: 89 55 f4 mov %edx,-0xc(%ebp)
- 8048436: 8b 55 f4 mov -0xc(%ebp),%edx
- 8048439: 8b 45 f0 mov -0x10(%ebp),%eax
- 804843c: 89 54 24 08 mov %edx,0x8(%esp)
- 8048440: 89 44 24 04 mov %eax,0x4(%esp)
- 8048444: c7 04 24 88 85 04 08 movl $0x8048588,(%esp)
- 804844b: e8 a0 fe ff ff call 80482f0 <printf@plt>
- 8048450: b8 00 00 00 00 mov $0x0,%eax
- 8048455: 83 c4 24 add $0x24,%esp
- 8048458: 5b pop %ebx
- 8048459: 5d pop %ebp
- 804845a: c3 ret
复制代码 可执行程序打印:
0x48423a1, 0x48423a1 // fun1()中打印的r_base、r_here值
0x48466a1
0x48493a1
|
|