3

We have a situation where (simplified):

  1. test() exists in source.c
  2. source.c compiles to object.o
  3. object.o gets linked into archive archive.a
  4. archive.a gets compiled into final binary

We are attempting to change the name of test() to something else. But the linking step in (4) says the new method signature does not exist. Using gobjdump we see for certain the new renamed method exists in object.o (it is in the same SECT as other methods and is not UND).

We can see for certain that the object.o exists in archive.a. However, we are not certain (because of the complicated build system) that archive.a contains the method.

TL;DR: Is there a way to see inside an archive file and list the functions of a particular binary object inside it?

JoshuaJ
  • 929
  • 1
  • 9
  • 22
  • 1
    Is this C, or C++? C doesn't have "methods" nor "objects" in this regard. – unwind May 05 '15 at 15:02
  • This is actually a open source library of C methods that are being put into the archive but compiled into a C++ project. – JoshuaJ May 05 '15 at 15:03
  • 3
    You can use the `nm` tool to list all the functions found in the library. – πάντα ῥεῖ May 05 '15 at 15:05
  • If you are linking `archive.a` into your binary, and the linker complains about an unknown function, then that function is not in `archive.a`. At least, not in the copy of `archive.a` that you are including in the link. – John Bollinger May 05 '15 at 15:06
  • @JohnBollinger That is exactly what we were figuring, and we were trying to see if there was a way to solve this with the 'ar' tool. I will try the 'nm' tool now. – JoshuaJ May 05 '15 at 15:08
  • Well, using `nm` we have confirmed the new method does exist in the archive: `00000000000076f0 T __Z14svm_get_nr_sv2PK9svm_model` However, g++ is still complaining that it can't find it... – JoshuaJ May 05 '15 at 15:19

1 Answers1

1

Use nm. Assuming Linux, here's the man page.

Andrew Henle
  • 32,625
  • 3
  • 24
  • 56