1

So we have shared library from a vendor who won't deliver their library in a static archive .a format on Linux or Android (but does on other platforms) because it would be inconvenient for them to change their build process. The issue is that need to wrap thread creation, malloc, and ton of other apis to work around bugs in the platform's nonstandard libc. We do this with LD using the "--wrap" command to redirect functions to our wraps. Unfortunately with a compiled .so, we can't relink it. Is there anyway of turning the .so into a static archive and relink it or even rewriting the link table to redirect these calls to our wraps?

Outside of disassembling, changing the library, and reassembling I can't think of any way to do this easily.

Paul Beusterien
  • 21,795
  • 5
  • 61
  • 115
Zac Bowling
  • 6,368
  • 1
  • 24
  • 26
  • Does the `LD_PRELOAD` trick help then? –  Jun 25 '13 at 18:20
  • because on android, you are fork of the Zygote process for your startup, you can't use LD_PRELOAD. You can LD_PRELOAD on subprocesses but you can't do it on your main process. I wish I could. – Zac Bowling Jun 26 '13 at 17:55

1 Answers1

1

Is there anyway of turning the .so into a static archive

No.

LD_PRELOAD seems the easiest way to achieve what you want.

because on android, you are fork of the Zygote process for your startup, you can't use LD_PRELOAD. You can LD_PRELOAD on subprocesses but you can't do it on your main process.

So in your "startup" process, modify the environment and execve the real program. Problem solved?

Employed Russian
  • 164,132
  • 27
  • 242
  • 306