Skip to content

Commit

Permalink
System libraries should be implicitly loaded by dlopen()
Browse files Browse the repository at this point in the history
Differential Revision: D58235364

fbshipit-source-id: 56b648c33a2736034bd3cee78ceb5fff3bda3984
  • Loading branch information
adicatana authored and facebook-github-bot committed Jun 7, 2024
1 parent 7ccbe20 commit 30016c3
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion java/com/facebook/soloader/NativeDeps.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.concurrent.locks.ReentrantReadWriteLock;
Expand Down Expand Up @@ -53,6 +54,24 @@ public final class NativeDeps {
private static volatile boolean sUseDepsFileAsync = false;
private static final ReentrantReadWriteLock sWaitForDepsFileLock = new ReentrantReadWriteLock();

private static final HashSet<String> STANDARD_SYSTEM_LIBS =
new HashSet<String>() {
{
add("libEGL.so");
add("libGLESv2.so");
add("libGLESv3.so");
add("libOpenSLES.so");
add("libandroid.so");
add("libc.so");
add("libdl.so");
add("libjnigraphics.so");
add("liblog.so");
add("libm.so");
add("libstdc++.so");
add("libz.so");
}
};

public static void loadDependencies(
String soName, ElfByteChannel bc, int loadFlags, StrictMode.ThreadPolicy threadPolicy)
throws IOException {
Expand All @@ -64,6 +83,11 @@ public static void loadDependencies(
continue;
}

if (STANDARD_SYSTEM_LIBS.contains(dependency)) {
// The linker will implicitly load these by itself.
continue;
}

SoLoader.loadDependency(dependency, loadFlags, threadPolicy);
}
}
Expand Down Expand Up @@ -153,7 +177,6 @@ public void run() {
sUseDepsFileAsync = false;
}
}
;
};

new Thread(runnable, "soloader-nativedeps-init").start();
Expand Down

0 comments on commit 30016c3

Please sign in to comment.