Frage

I am working on a C program (under Linux ) that relies on shared libraries as plugins.

I provide each plugin with several functions from a static library of mine. In order to change the workflow of my program, I need to know at runtime whether a plugin is going to call a certain function included from the aforementioned library.

What I need is the C equivalent of:

readelf -a ${PLUGIN_NAME} | grep ${FUNCTION_NAME}

Is that possible to exploit the <dlfcn.h> library in order to achieve that ? Needless to say, I prefer not executing the oneliner above in a system() call.

Thanks

War es hilfreich?

Lösung

You can try LibELF which allows you to manipulate ELF binaries (i.e. read sections). Very nice examples you can find here.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top