use of com.facebook.buck.android.relinker.Symbols in project buck by facebook.
the class AndroidBinaryIntegrationTest method testNativeRelinker.
@Test
public void testNativeRelinker() throws IOException, InterruptedException {
NdkCxxPlatform platform = AndroidNdkHelper.getNdkCxxPlatform(workspace, filesystem);
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
Path tmpDir = tmpFolder.newFolder("xdso");
SymbolGetter syms = new SymbolGetter(new DefaultProcessExecutor(new TestConsole()), tmpDir, platform.getObjdump(), pathResolver);
Symbols sym;
Path apkPath = workspace.buildAndReturnOutput("//apps/sample:app_xdso_dce");
sym = syms.getSymbols(apkPath, "lib/x86/libnative_xdsodce_top.so");
assertTrue(sym.global.contains("_Z10JNI_OnLoadii"));
assertTrue(sym.undefined.contains("_Z10midFromTopi"));
assertTrue(sym.undefined.contains("_Z10botFromTopi"));
assertFalse(sym.all.contains("_Z6unusedi"));
sym = syms.getSymbols(apkPath, "lib/x86/libnative_xdsodce_mid.so");
assertTrue(sym.global.contains("_Z10midFromTopi"));
assertTrue(sym.undefined.contains("_Z10botFromMidi"));
assertFalse(sym.all.contains("_Z6unusedi"));
sym = syms.getSymbols(apkPath, "lib/x86/libnative_xdsodce_bot.so");
assertTrue(sym.global.contains("_Z10botFromTopi"));
assertTrue(sym.global.contains("_Z10botFromMidi"));
assertFalse(sym.all.contains("_Z6unusedi"));
// Run some verification on the same apk with native_relinker disabled.
apkPath = workspace.buildAndReturnOutput("//apps/sample:app_no_xdso_dce");
sym = syms.getSymbols(apkPath, "lib/x86/libnative_xdsodce_top.so");
assertTrue(sym.all.contains("_Z6unusedi"));
sym = syms.getSymbols(apkPath, "lib/x86/libnative_xdsodce_mid.so");
assertTrue(sym.all.contains("_Z6unusedi"));
sym = syms.getSymbols(apkPath, "lib/x86/libnative_xdsodce_bot.so");
assertTrue(sym.all.contains("_Z6unusedi"));
}
Aggregations