I am working on getting the instructions associated with a certain function within a shared object file (ELF).
This shall be realized from a python script. I could do this certainly from the command line whereby the goal is not fire up cli commands from my python script. A library ought to be used instead.
The input for my script is an object filename and the name of the function like
python getInstructionStream.py main.o foo
The result should look like
00000016 <foo>:
16: 55 push ebp
17: 89 e5 mov ebp,esp
19: 83 ec 10 sub esp,0x10
1c: 8b 45 0c mov eax,DWORD PTR [ebp+0xc]
1f: 8b 55 08 mov edx,DWORD PTR [ebp+0x8]
22: 01 d0 add eax,edx
24: 89 45 fc mov DWORD PTR [ebp-0x4],eax
27: 8b 45 fc mov eax,DWORD PTR [ebp-0x4]
2a: c9 leave
2b: c3 ret
It is not a must have to show the output in any assembly syntax. A hex stream is also sufficient. Can anyone name me one or more libraries which can help me for this kind of work?
thanks for the libelf hint. I can go on from here