Function name identification in shared objects

I am porting an ODBC from Windows to Linux .
The driver is written in C
The way ODBC works on Linux is that the application makes an ODBC Manager ( ODBCM ) ODBCM , which in turn loads the appropriate driver and passes the function call.

Suppose my driver, which is compiled into a shared object, provides two functions A and B
The ODBCM function is ODBCM to be call function A , and function A is call function B
In fact, what happens is that when function A calls function B , function B' (with the same name as B , is located in the libodbc shared object and is loaded by Linux using ODBC ).

I feel that there should be either a compile-time flag or a post compilation library modifier tool that will fix this problem.
I am currently browsing the library one function at a time, doing the following:

 _B(){ // rename old functions ... } B() { // add new wrapper function return _B(); // which just calls old } _A() { ... _B(); // Change calls to renamed functions ... } 

Which slowly changes and feels shreds.

+4
source share
1 answer

Try associating your .so with the -Bsymbolic linker option (pass -Wl,-Bsymbolic to the gcc command line). This binds all the internal symbols of the library during the link, so they will not be dynamically linked later.

+6
source

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


All Articles