Now I have a .so file but no related headers attached.
Are there recommended methods to analysis and use the functions inside the library?
Ok, I think it can be two parts:
"how to load the library" and "how to use the library".
First I tried to use dlopen to load it,then compiling passed but segmentation fault occurred upon execution.
I tried with system built-in library instead and it's OK
so I wondered maybe I should hook gdb with the .so during execution to see what happened?
But before that I use nm to list the function names of the shared object,it works good so I guess the shared object was not broken.
Or maybe should I try to rebuild a header from the nm results?Is this possible? how?
I still programmed with dlopen() and tried to compile with -L[library_search_path] -l[library_name]
ex: -L/home/test -ltest
and got the following errors:
/home/test/libtest.so: undefined reference to「SSL_connect」/home/test/libtest.so: undefined reference to「TLSv1_client_method」/home/test/libtest.so: undefined reference to「SSL_CTX_set_verify」/home/test/libtest.so: undefined reference to「SSL_CTX_check_private_key」/home/test/libtest.so: undefined reference to「SSL_get_peer_certificate」
I found OpenSSL has not been installed yet.
After installation was done, I compiled again with additional
then compiling works but execution failed with followings:
error while loading shared libraries: libssl.so.1.0.0: cannot open shared object file: No such file or directory
The executable can't find the libssl installed,
so I add flags with
Well, the library can be loaded now :)
Now I'm understanding how to use dlsym() with name-mangling functions...