arnold
arnold

Reputation: 465

calling function in shared lib file with no symbol table

I have a .so lib file that is not written by me. this is on a QNX arm-le system with eclipse as ide.

If i open the file with ida pro , i can see a lot of exported functions.

I want to call one of these functions.

I tried :

    handle = dlopen ("/tmp/lib.so", RTLD_LAZY);
    if (!handle) {
       fputs (dlerror(), stderr);
       exit(1);
    }

    cosine = dlsym(handle, "cos");
    if ((error = dlerror()) != NULL)  {
        fputs(error, stderr);
        exit(1);
    }

That gives

unknown symbol: _ZTVN10__cxxabiv120__si_class_type_infoE
unknown symbol: _ZTVN10__cxxabiv120__si_class_type_infoE
unknown symbol: _ZTVN10__cxxabiv120__si_class_type_infoE
unknown symbol: _ZTISt9exception
Unresolved symbols

Upvotes: 0

Views: 1220

Answers (2)

Employed Russian
Employed Russian

Reputation: 213375

You are not distinguishing between dlopen and dlsym errors (you should).

The error you get is from dlopen, and it means that /tmp/lib.so has dependency on your standard C++ runtime library (usually libstdc++.so) symbols, but was not itself linked against libstdc++.so.

To fix this, you must make libstdc++.so available, by either

  • linking your test program with g++ instead of gcc, or adding -lstdc++ to the link line, or
  • calling dlopen("libstdc++.so", RTLD_GLOBAL) before trying to dlopen /tmp/lib.so.

Upvotes: 2

unwind
unwind

Reputation: 399703

That is quite clearly the (mangled) name of a C++ symbol, which implies that the library you're trying to use was written in C++. You should try linking your program against the standard C++ runtime library.

Upvotes: 2

Related Questions