I need to work with simple ELF files in my C program.
I can't use any external libraries, but I can use elf.h.
Let's take hello.o file for source:
int Hello() { return 3; }
How could I access to Hello in ohter C program having only hello.o file?
I should probably load it to memory using mmap or sth like this. At the end I need to work with much complicated ELF files, but I don't know now, how to start.
UPDATE: I need to do this the way I described it, because it is for learning purposes. Whole problem is more complex that what I described.
For this question assume I need to write method:
int HelloFromElfO(const char* helloFile);
which would execute Hello function implemented in helloFile.
I don't want full answer. I don't need any code. I need something to start with.
I have basic knowledge about ELF file structure, but I have no idea how to work in C with binary file without any parser or sth like this.
UPDATE2:
OK, apps like readelf are very complicated. So maybe I try this way: lets say again I have hello.o mapped to memory at ptr. How can I get pointer to Hello function?
How can I get any structured data from hello.o? I mean, not pure bytes but something I can work with.
 
     
    