How to achieve character versioning

I want to achieve something like below:

I have several versions of the library. I dynamically load the latest version of the library using dlopen (). Then I want to see if a specific function exists in this version ( along with a similar return type and a list of arguments ). If this happens, then open it and then go back to the previous version to check it out.

I have seen several posts about "versioning scripts", but I cannot use them. Also I think that searching in the symbol table will not be a solution, since it only checks the function name.

+4
source share
1 answer

A good explanation of character versioning is here . You will need the dlvsym () function from the GNU extension to search for a character by name and version:

#define _GNU_SOURCE #include <dlfcn.h> void *dlvsym(void *handle, char *symbol, char *version); 

The dlvsym () function does the same as dlsym (), but takes a version string as an optional argument. Note. C ++ symbolic names must be passed to dlvsym () in a mangled form containing a list of arguments. Unfortunately, the GCC malformed name (unlike MSVC) does not contain a return type.

See dlopen (3) for more information on the Linux manual page .

+5
source

Source: https://habr.com/ru/post/1339971/


All Articles