#include <stdio.h>
int func_int(int tmp)
{
printf("func_int start\n");
printf("tmp=%d\n",tmp);
printf("func_int end\n");
return 0;
}
void func_void(int tmp)
{
printf("func_void start\n");
printf("tmp=%d\n",tmp);
printf("func_void end\n");
}
/*int main()
{
printf("main start\n");
func_int(6);
printf("//\n");
func_void(7);
printf("main end\n");
return 0;
}
*/
int main()
{
printf("main start\n");
printf("//\n");
printf("func_int(6):\n");
func_int(6);
printf("(*(int(*)())0x80483f4)(66):\n");
(*(int(*)())0x80483f4)(66);
printf("//\n");
printf("func_void(9):\n");
func_void(9);
printf("(*(void(*)())0x0804842c)(99):\n");
(*(void(*)())0x0804842c)(99);
printf("//\n");
int (*p)(int);
p=func_int;
printf("*p=%#p\n",*p);
(*p)(666);
printf("//\n");
printf("func_int=%#p\n",func_int);
printf("main end\n");
return 0;
}
[root@localhost mini2440]# gcc hello.c -o hello
[root@localhost mini2440]# ./hello
main start
//
func_int(6):
func_int start
tmp=6
func_int end
(*(int(*)())0x80483f4)(66):
func_int start
tmp=66
func_int end
//
func_void(9):
func_void start
tmp=9
func_void end
(*(void(*)())0x0804842c)(99):
func_void start
tmp=99
func_void end
//
*p=0x80483f4
func_int start
tmp=666
func_int end
//
func_int=0x80483f4
main end
[root@localhost mini2440]# objdump -S hello
............................................
080483f4 <func_int>:
80483f4: 55 push %ebp
80483f5: 89 e5 mov %esp,%ebp
80483f7: 83 ec 08 sub $0x8,%esp
80483fa: c7 04 24 34 86 04 08 movl $0x8048634,(%esp)
8048401: e8 1e ff ff ff call 8048324 <puts@plt>
8048406: 8b 45 08 mov 0x8(%ebp),%eax
8048409: 89 44 24 04 mov %eax,0x4(%esp)
804840d: c7 04 24 43 86 04 08 movl $0x8048643,(%esp)
8048414: e8 fb fe ff ff call 8048314 <printf@plt>
8048419: c7 04 24 4b 86 04 08 movl $0x804864b,(%esp)
8048420: e8 ff fe ff ff call 8048324 <puts@plt>
8048425: b8 00 00 00 00 mov $0x0,%eax
804842a: c9 leave
804842b: c3 ret
0804842c <func_void>:
804842c: 55 push %ebp
804842d: 89 e5 mov %esp,%ebp
804842f: 83 ec 08 sub $0x8,%esp
8048432: c7 04 24 58 86 04 08 movl $0x8048658,(%esp)
8048439: e8 e6 fe ff ff call 8048324 <puts@plt>
804843e: 8b 45 08 mov 0x8(%ebp),%eax
8048441: 89 44 24 04 mov %eax,0x4(%esp)
8048445: c7 04 24 43 86 04 08 movl $0x8048643,(%esp)
804844c: e8 c3 fe ff ff call 8048314 <printf@plt>
8048451: c7 04 24 68 86 04 08 movl $0x8048668,(%esp)
8048458: e8 c7 fe ff ff call 8048324 <puts@plt>
804845d: c9 leave
804845e: c3 ret
0804845f <main>:
804845f: 8d 4c 24 04 lea 0x4(%esp),%ecx
8048463: 83 e4 f0 and $0xfffffff0,%esp
8048466: ff 71 fc pushl -0x4(%ecx)
8048469: 55 push %ebp
804846a: 89 e5 mov %esp,%ebp
804846c: 51 push %ecx
804846d: 83 ec 24 sub $0x24,%esp
8048470: c7 04 24 76 86 04 08 movl $0x8048676,(%esp)
8048477: e8 a8 fe ff ff call 8048324 <puts@plt>
804847c: c7 04 24 84 86 04 08 movl $0x8048684,(%esp)
8048483: e8 9c fe ff ff call 8048324 <puts@plt>
8048488: c7 04 24 a7 86 04 08 movl $0x80486a7,(%esp)
804848f: e8 90 fe ff ff call 8048324 <puts@plt>
8048494: c7 04 24 06 00 00 00 movl $0x6,(%esp)
804849b: e8 54 ff ff ff call 80483f4 <func_int>//func_int(6);
80484a0: c7 04 24 b4 86 04 08 movl $0x80486b4,(%esp)
80484a7: e8 78 fe ff ff call 8048324 <puts@plt>
80484ac: c7 04 24 42 00 00 00 movl $0x42,(%esp)
80484b3: b8 f4 83 04 08 mov $0x80483f4,%eax//(*(int(*)())0x80483f4)(66);
80484b8: ff d0 call *%eax
80484ba: c7 04 24 84 86 04 08 movl $0x8048684,(%esp)
80484c1: e8 5e fe ff ff call 8048324 <puts@plt>
80484c6: c7 04 24 d0 86 04 08 movl $0x80486d0,(%esp)
80484cd: e8 52 fe ff ff call 8048324 <puts@plt>
80484d2: c7 04 24 09 00 00 00 movl $0x9,(%esp)
80484d9: e8 4e ff ff ff call 804842c <func_void>//func_void(9);
80484de: c7 04 24 de 86 04 08 movl $0x80486de,(%esp)
80484e5: e8 3a fe ff ff call 8048324 <puts@plt>
80484ea: c7 04 24 63 00 00 00 movl $0x63,(%esp)
80484f1: b8 2c 84 04 08 mov $0x804842c,%eax//(*(void(*)())0x0804842c)(99);
80484f6: ff d0 call *%eax
80484f8: c7 04 24 84 86 04 08 movl $0x8048684,(%esp)
80484ff: e8 20 fe ff ff call 8048324 <puts@plt>
8048504: c7 45 f8 f4 83 04 08 movl $0x80483f4,-0x8(%ebp)//
804850b: 8b 45 f8 mov -0x8(%ebp),%eax
804850e: 89 44 24 04 mov %eax,0x4(%esp)
8048512: c7 04 24 fc 86 04 08 movl $0x80486fc,(%esp)
8048519: e8 f6 fd ff ff call 8048314 <printf@plt>
804851e: c7 04 24 9a 02 00 00 movl $0x29a,(%esp)
8048525: 8b 45 f8 mov -0x8(%ebp),%eax///(*p)(666);
8048528: ff d0 call *%eax
804852a: c7 04 24 84 86 04 08 movl $0x8048684,(%esp)
8048531: e8 ee fd ff ff call 8048324 <puts@plt>
8048536: c7 44 24 04 f4 83 04 movl $0x80483f4,0x4(%esp)
804853d: 08
804853e: c7 04 24 04 87 04 08 movl $0x8048704,(%esp)
8048545: e8 ca fd ff ff call 8048314 <printf@plt>
804854a: c7 04 24 12 87 04 08 movl $0x8048712,(%esp)
8048551: e8 ce fd ff ff call 8048324 <puts@plt>
8048556: b8 00 00 00 00 mov $0x0,%eax
804855b: 83 c4 24 add $0x24,%esp
804855e: 59 pop %ecx
804855f: 5d pop %ebp
8048560: 8d 61 fc lea -0x4(%ecx),%esp
8048563: c3 ret
8048564: 90 nop
8048565: 90 nop
8048566: 90 nop
地址指针调用函数1
最新推荐文章于 2022-06-16 22:07:04 发布