1

I am working with a third party vendor that I suspect either did not give me all the libraries I need or did not set up their example project to link correctly to all the necessary libraries. They just dumped a folder and project on me. Evidently, it's a complicated task to contact them. So, before I do...

Is there a way, in Linux, to scan all the shared and static ARM libraries in a directory for a function or method signature, such that I can find a library that might implement void foo(int, float); , such that I can try linking to it and see if it resolves my unresolved dependencies?

I saw some posts about using nm, but I don't know how to use it on ARM libraries or how to search for a particular function/method.

Christopher Pisz
  • 3,757
  • 4
  • 29
  • 65

1 Answers1

2

The nm tool can scan for the symbols of an induvidual library.

Symbols used for dynamic linking are in a different table as the symbols used only for compilation, so shared lib exports/imports can be scanned by the nm --dynamic flag.

All the symbols have also a single-byte type identifier, for example U means the symbols which are used by the library and T for the ones provided by it.

In the case of C++, there is also the c++filt tool to convert the cryptic C++ method names to simple ascii strings (related answer).

All of them is suited best in the ordinary command line scripting environment. For example, you can check for the Cica::Cica() constructor in all the directory structure of the PWD by this simple bash script:

for l in $(find -name "*.so*")
do
  echo "$l"
  nm --dynamic "$l"|c++filt|grep -F Cica::Cica
done
peterh
  • 11,875
  • 18
  • 85
  • 108
  • I get a lot of "File format not recognized" error. Is there anything fancy I need to do if they cross compiled it for 'ARM' architecture? – Christopher Pisz Jul 16 '18 at 23:24
  • @ChristopherPisz Yes! If you are using an amd64 architecture, then you should use a binutils which runs on amd64, but processes binaries/libraries for arm. It is one type of cross-compiler tools. You have luck, binutils-multiarch has support of practically all the today widely used architectures. – peterh Jul 16 '18 at 23:27
  • Getting very close! I get hits for "U MyClass::MyMethod", but in many many libraries. So, I have a feeling these are dependents rather than dependencies. I need to readup on nm. Is there a good manual page online for linux noobs for nm? – Christopher Pisz Jul 17 '18 at 18:53
  • @ChristopherPisz Yes, these libraries are using `MyClass::Mymethod(...)`, but they don't provide it. If you are linking libraries and objects to a binary, then the linker wants a single `T` for all the `U`s (i.e. any library/object can use that method, but exactly one should provide it). If not it is the case, you will get a wonderful linker error message. – peterh Jul 17 '18 at 18:55
  • Excellent. Thanks so much! Best answerer this month! – Christopher Pisz Jul 17 '18 at 18:57
  • @ChristopherPisz Well... ask stackoverflow. The binutils manuals are written in the dialect of the binutils developers and they are not very good for a developer wanting to use it. But I could find what I want, far before the existence of the SO, too, and your this question wasn't very badly received. – peterh Jul 17 '18 at 18:57
  • Read manuals, read google, ask SO. It is also a useful strategy to collect rep and then use them as bounties, as a precaution for a more hard problem. – peterh Jul 17 '18 at 18:58
  • 1
    @ChristopherPisz Btw, don't worry on a closure, but don't forget to click "reopen" if you think it is not a dupe. From 350 rep you can vote for reopen your own posts (from 3000, you will be able to do that with others' questions, too). – peterh Jul 17 '18 at 19:00