in testfile.c
Code: Select all
void entry_func()
{
return;
}
Code: Select all
testfile.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <entry_func>:
0: 55 push %rbp
1: 48 89 e5 mov %rsp,%rbp
4: 90 nop
5: 5d pop %rbp
6: c3 retq
Then, I find entry_func's address (lookup the symbol).
Code: Select all
char *store = find_symbol("entry_func");
for (int x = 0; x < 7; ++x) printf("%x ", store[x]);
printf("\n");
Code: Select all
55 48 89 e5 90 5d c3
finally ->
Code: Select all
void (*fp)();
fp = store;
printf("calling\n");
fp();
printf("called\n");
Should this not work? seems the .o file is parsed and loaded correctly as of the memory dump.
Do I need to do something prior to calling fp() (set up certain registers or somesuch)?