2

I'm building a shared library with C++ to be used on Android, i.e. the result of my work is a standard linux .so file. The library is compiled using clang and originally I planned to create a release build without any debugging information, include it in my Android app and off we go. Technically that all works.

However, there is one downside to this: Without debugging information a call stack created due to a crash of my shared library is pretty useless because it contains no reference to the source code anymore.

Now, Google Play offers a way to submit shared libraries without debugging information and a second copy of the same library with debugging information. The library without debugging information gets packaged into the Android app and is installed on end user devices. The second copy with the debugging information resided within Google Play, i.e. is not installed on end user devices. Google Play uses that copy to turn call stacks it receives from crashes to call stacks containing references to the source code.

BUT, for the life of me I cannot figure out how to strip out the debugging information of a shared library. The debugging information is in the DWARF format version 2.

I compile my library as follows:

clang ... -g2 -gdwarf-2 -O3 ...

So, the code is optimized but contains debugging information. Inspecting the resulting .so file using objdump -g libwhatever.so reveals a lot of DWARF information.

Compiling the same library with

clang ... -g0 -O3

and inspecting it using objdump -g libwhatever.so confirms that a lot less DWARF information is contained. This is the end goal.

So, the question is how can I strip out the DWARF debugging information compiled with the first clang call shown above so that I end up with the same result that is achieved by the second clang call?

What I have tried:

strip --strip-all libwhatever.so

This had no effect at all, i.e. the output is identical to the input.

objcopy --strip-debug libwhatever.so

Same as with strip, the output is identical to the input. That is what is recommended in the link above but I just cannot make it work.

I know that it might not be a real problem to ship a library containing debugging information. However, I'm attempting to obtain more insight here to understand better how the workflows are.

ackh
  • 1,648
  • 2
  • 18
  • 36
  • Here's a good answer: https://stackoverflow.com/questions/46197810/separating-out-symbols-and-stripping-unneeded-symbols-at-the-same-time – Stephen M. Webb Sep 10 '20 at 20:07

0 Answers0