KeepSafe/ReLinker

Android Linker cannot handle lib path suffix below Android M

Opened this issue · 5 comments

alhah commented

We meet error like this:

java.lang.UnsatisfiedLinkError
dlopen failed: could not load library "libmegface-new.so" needed by "libMegviiFacepp-0.5.2.so.6453"; caused by library "libmegface-new.so" not found

Android Linker below M use exactly match to handle dependency. In our case, libMegviiFacepp-0.5.2.so depends on libmegface-new.so, and they were renamed to libMegviiFacepp-0.5.2.so.6453 & libmegface-new.so.6453. When linker load libMegviiFacepp-0.5.2.so.6453, it would try to load libmegface-new.so first, and then failed.

We pass "null" for "version" below Android M to avoid this.

Could you please add more specific steps to reproduce this. That would be very helpful.

alhah commented

Suppose our app has a lib named "A.so", and it depends on "B.so" in Android.mk(LOCAL_SHARED_LIBRARIES += B), the version code is "1234", the reproduce steps:

  1. Find a rooted device below Android M and install the app.
  2. Delete "A.so" & "B.so" in the default lib directory such as "/data/app//lib/arm"
  3. Load "A.so", then relinker will decompress apk file and rename "A.so" to "A.so.1234", also with "B.so" to "B.so.1234".
  4. The bionic linker will read "DT_NEEDED" to look for "B.so", but there is only "B.so.1234", then throw UnsatisfiedLinkError.

Thank you.

@alhah sorry for not seeing this earlier. Got lost in notifications storm.

Thanks for the reproduction steps. I'd love to get this handled better in ReLinked, but unfortunately we don't have the resources to do this right now. You think you'll be able to open a PR?
How would you think a fix would look like?

Hi @alhah, this issue only occurs for rooted phones?

alhah commented

@emarc-m It occurs for all phones below Android M, root just for explain the reproduce path. If A.so depends B.so which has been renamed to B.so.version_code, linker can not find it below Android M.