views:

47

answers:

2

Hi,

I was looking for a way to list .text section defined symbols on a C shared object loaded on a python program using the ctypes wrapper. In other words, i am trying to get a list of defined functions on a CDLL loaded object.

If there is no way to do this with ctypes or library ( or python binding ), another option is a python elf parsing library or a solution like http://halflifelibrary.com/wiki/Metamod-P.

Any way to do this ?

+1  A: 

Adding to the list of methods that you are trying to use to get the list of functions that is exported by the dll.

There is a script at : http://projects.scipy.org/numpy/wiki/MicrosoftToolchainSupport that dumps the symbol tables of the dll, parses it to get the public table and output the table into a .def file. It also says that this may not work if the dll is stripped.

I am not sure if there are good ELF parsers out there in Python. Adding some that I have found.

pyfunc
This is OK but the script is using subprocess module executing objdump to get the symbol table. Do you know a library or python extension ?
Jorge Niedbalski R.
A: 

FYI there is no way to get a list of defined methods on a shared object loaded using ctypes because there is no meta information on the object structure.

If you need a platform specific object parser maybe you should take a look at http://projects.scipy.org/numpy/wiki/MicrosoftToolchainSupport using the objdump routines to get defined function references on the text section.

My option do this is to write a small parser using a ELF parser library like Hachoir or the Pydevtools in order to introspect the object.

Jorge Niedbalski R.