Created
May 22, 2018 20:45
-
-
Save betaveros/dee9c68543244b9b2e85376d94ae5dee to your computer and use it in GitHub Desktop.
function pointers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0000000100000f40 <__Z1av>: | |
100000f40: 55 push rbp | |
100000f41: 48 89 e5 mov rbp,rsp | |
100000f44: b8 03 00 00 00 mov eax,0x3 | |
100000f49: 5d pop rbp | |
100000f4a: c3 ret | |
100000f4b: 0f 1f 44 00 00 nop DWORD PTR [rax+rax*1+0x0] | |
0000000100000f50 <_main>: | |
100000f50: 55 push rbp | |
100000f51: 48 89 e5 mov rbp,rsp | |
100000f54: 48 8d 05 ef ff ff ff lea rax,[rip+0xffffffffffffffef] # 100000f4a <__Z1av+0xa> | |
100000f5b: 48 89 05 b6 00 00 00 mov QWORD PTR [rip+0xb6],rax # 100001018 <_f> | |
100000f62: ff d0 call rax | |
100000f64: 89 c1 mov ecx,eax | |
100000f66: 48 8d 3d 2d 00 00 00 lea rdi,[rip+0x2d] # 100000f9a <_main+0x4a> | |
100000f6d: 31 c0 xor eax,eax | |
100000f6f: 89 ce mov esi,ecx | |
100000f71: e8 04 00 00 00 call 100000f7a <_main+0x2a> | |
100000f76: 31 c0 xor eax,eax | |
100000f78: 5d pop rbp | |
100000f79: c3 ret |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0000000100000f10 <__Z1av>: | |
100000f10: 55 push rbp | |
100000f11: 48 89 e5 mov rbp,rsp | |
100000f14: b8 03 00 00 00 mov eax,0x3 | |
100000f19: 5d pop rbp | |
100000f1a: c3 ret | |
100000f1b: 0f 1f 44 00 00 nop DWORD PTR [rax+rax*1+0x0] | |
0000000100000f20 <_main>: | |
100000f20: 55 push rbp | |
100000f21: 48 89 e5 mov rbp,rsp | |
100000f24: 48 83 ec 10 sub rsp,0x10 | |
100000f28: 48 8d 05 e1 ff ff ff lea rax,[rip+0xffffffffffffffe1] # 100000f10 <__Z1av> | |
100000f2f: c7 45 fc 00 00 00 00 mov DWORD PTR [rbp-0x4],0x0 | |
100000f36: 48 89 05 db 00 00 00 mov QWORD PTR [rip+0xdb],rax # 100001018 <_f> | |
100000f3d: 48 8b 05 d4 00 00 00 mov rax,QWORD PTR [rip+0xd4] # 100001018 <_f> | |
100000f44: 48 05 0a 00 00 00 add rax,0xa | |
100000f4a: 48 89 05 c7 00 00 00 mov QWORD PTR [rip+0xc7],rax # 100001018 <_f> | |
100000f51: ff 15 c1 00 00 00 call QWORD PTR [rip+0xc1] # 100001018 <_f> | |
100000f57: 48 8d 3d 38 00 00 00 lea rdi,[rip+0x38] # 100000f96 <_main+0x76> | |
100000f5e: 89 c6 mov esi,eax | |
100000f60: b0 00 mov al,0x0 | |
100000f62: e8 0d 00 00 00 call 100000f74 <_main+0x54> | |
100000f67: 31 f6 xor esi,esi | |
100000f69: 89 45 f8 mov DWORD PTR [rbp-0x8],eax | |
100000f6c: 89 f0 mov eax,esi | |
100000f6e: 48 83 c4 10 add rsp,0x10 | |
100000f72: 5d pop rbp | |
100000f73: c3 ret |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int (*f)(); | |
int a() { | |
return 3; | |
} | |
int main() { | |
f = &a; | |
f = (int(*)()) (((char*) f) + 10); | |
printf("%d\n", f()); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment