summaryrefslogtreecommitdiff
path: root/libnativebridge/include
AgeCommit message (Collapse)Author
2025-02-05nativebridge: Add isNativeBridgeFunctionPointer method dimitry
This method lets native bridge report if particular pointer is in the region of code executable by native bridge implementation. Bug: 393035780 Test: atest art/libnativebridge/tests Change-Id: Icaec80cb7efae5b918aed0a98216cbfaeaba330d
2024-09-11Remove remnants of init_anonymous_namespace in libnativebridge and Martin Stjernholm
in tests. It ceased to be used in https://r.android.com/1070435. #codehealth Test: atest CtsJniTestCases Test: atest art/libnativeloader Test: atest art/libnativebridge/tests Bug: 130388701 Bug: 122710865 Change-Id: Ie8fcde3b86b4913566ebb5ea3f1a4bc9b9f96316
2024-04-05Add getTrampolineForFunctionPointer method to native bridge dimitry
Add a function to native bridge that generates trampolines for guest pointers and call it for native-bridged namespaces. Bug: http://b/330367443 Test: art/libnativebridge/tests/runtests.sh --skip-target Test: ./android-cts/tools/cts-tradefed run cts -m CtsJniTestCases Change-Id: I02cab5ea6c87cb4d5065033a4b6793eb57fe0f52
2023-08-08nativebridge: Add getTrampoline2 function to pass JNICallType dimitry
NativeBridge needs to know if JNI call is @CriticalNative, starting with v7 getTrampoline2 is used in place of getTrampoline. Bug: https://issuetracker.google.com/288392666 Test: art/libnativebridge/tests/runtests.sh --skip-target Change-Id: I60a2fd6ab2fb9d19dda7bbdcbe09144797bd1d49
2022-06-20Fix modernize-use-using clang-tidy issues Stefano Cianciulli
All the // NOLINT comments introduced in this CL were meant to disable only the modernize-use-using checks, but changing the comment to be // NOLINT(modernize-use-using) as explained in https://clang.llvm.org/extra/clang-tidy/#suppressing-undesired-diagnostics will make cpplint throw an error, as also cpplint uses the // NOLINT(...) notation to suppress unwanted warnings. Test: m tidy-art Test: art/libnativebridge/tests/runtests.sh Bug: 213953102 Change-Id: I9a992e0f0ecd06f7e64fd0bbf473bec4582370f6
2021-05-10Avoid loading external libraries from ARTs internal linker namespace Martin Stjernholm
(reland). dlopen() calls in ART will use its own linker namespace (com_android_art). That's appropriate for internal libraries in the APEX, but not when ART loads libraries on behalf of external requests. In those cases we should instead use android_dlopen_ext to load them from the system namespace, i.e. the one that searches /system/lib(64). The linker config has been using allow_all_shared_libs, so any loads from com_android_art fall back to the system namespace, and hence dlopen() usually works regardless which namespace it ought to use. However we want to drop allow_all_shared_libs, so we need to figure out which dlopen's should use which namespace: 1. Several ART libraries are loaded on-demand, e.g. libart-compiler and libart-disassembler. There are also those going through the runtime plugin system, like libperfetto_hprofd and heapprofd_client_api. All these are internal or at least statically known (so we can provide links for them in the linker config), and should continue to use dlopen from the ART namespace. 2. libnativeloader loads the preloadable public libraries from system/etc/public.libraries.txt, and should use the system namespace for that. 3. libnativebridge loads the native bridge implementation specified through the command line (or ultimately the system property ro.dalvik.vm.native.bridge). It's not part of the ART APEX and not known statically, so the system namespace should be used. 4. libnativeloader also loads JNI libraries from classloader namespaces, but has a fallback if no such namespace can be found based on caller location. Fall back to the system namespace to handle libraries loaded during the preload phase in the zygote. 5. JVMTI agents are loaded by dalvik.system.VMDebug.attachAgent(). Treat these too as external libraries - they are loaded in a way similar to JNI libraries through OpenNativeLibrary in libnativeloader, so are covered by #4. They are normally loaded by apps with a classloader, but a special case is adbconnection which loads libjdwp.so in the ART APEX without one and hence falls back to the system namespace. We therefore need to create a link for it (https://r.android.com/1690889, https://r.android.com/1690795). All cases #2-#5 are covered by libnativeloader and libnativebridge. Introduce OpenSystemLibrary, and since libnativeloader depends on libnativebridge, put it in the latter to be usable from both. It's only an internal dependency not exposed in the APEX stubs. (Another possibility could be to put it in the generic toolbox lib libartbase, but it's split into -d and non-d variants, and we don't want to split libnative{loader,bridge} that way.) Since libnativeloader_test no longer needs to mock dlopen we can simplify it to a more regular test that loads the tested libs dynamically. This relands https://r.android.com/1673312 without setting ANDROID_ADDITIONAL_PUBLIC_LIBRARIES in run-test-jar, because that made libnativeloader try to preload internal libraries from the system namespace. Test: mmm art Test: atest art/libnativeloader Test: atest CtsJniTestCases Test: Cuttlefish app compat test that uses NDK translation Test: Manual tests with Android Studio TI agents (http://g/art-module-team/7Jy3Tg7LCh0) Test: art/test/testrunner/testrunner.py --target --64 --optimizing in chroot on cuttlefish Bug: 130340935 Change-Id: I7fb32faacc1c214402b58125d8190e97bbbcfad2
2021-05-09Revert "Avoid loading external libraries from ARTs internal linker namespace." Calin Juravle
This reverts commit 582448f29f2f2529202bf868d00ba5d3d3776bb6. Reason for revert: breaks tests Change-Id: I2e0b2a28d4644b314887673d4aef4f1094aea289
2021-05-07Avoid loading external libraries from ARTs internal linker namespace. Martin Stjernholm
dlopen() calls in ART will use its own linker namespace (com_android_art). That's appropriate for internal libraries in the APEX, but not when ART loads libraries on behalf of external requests. In those cases we should instead use android_dlopen_ext to load them from the system namespace, i.e. the one that searches /system/lib(64). The linker config has been using allow_all_shared_libs, so any loads from com_android_art fall back to the system namespace, and hence dlopen() usually works regardless which namespace it ought to use. However we want to drop allow_all_shared_libs, so we need to figure out which dlopen's should use which namespace: 1. Several ART libraries are loaded on-demand, e.g. libart-compiler and libart-disassembler. There are also those going through the runtime plugin system, like libperfetto_hprofd and heapprofd_client_api. All these are internal or at least statically known (so we can provide links for them in the linker config), and should continue to use dlopen from the ART namespace. 2. libnativeloader loads the preloadable public libraries from system/etc/public.libraries.txt, and should use the system namespace for that. 3. libnativebridge loads the native bridge implementation specified through the command line (or ultimately the system property ro.dalvik.vm.native.bridge). It's not part of the ART APEX and not known statically, so the system namespace should be used. 4. libnativeloader also loads JNI libraries from classloader namespaces, but has a fallback if no such namespace can be found based on caller location. Fall back to the system namespace to handle libraries loaded during the preload phase in the zygote. 5. JVMTI agents are loaded by dalvik.system.VMDebug.attachAgent(). Treat these too as external libraries - they are loaded in a way similar to JNI libraries through OpenNativeLibrary in libnativeloader, so are covered by #4. They are normally loaded by apps with a classloader, but a special case is adbconnection which loads libjdwp.so in the ART APEX without one and hence falls back to the system namespace. We therefore need to create a link for it (https://r.android.com/1690889, https://r.android.com/1690795). All cases #2-#5 are covered by libnativeloader and libnativebridge. Introduce OpenSystemLibrary, and since libnativeloader depends on libnativebridge, put it in the latter to be usable from both. It's only an internal dependency not exposed in the APEX stubs. (Another possibility could be to put it in the generic toolbox lib libartbase, but it's split into -d and non-d variants, and we don't want to split libnative{loader,bridge} that way.) Since libnativeloader_test no longer needs to mock dlopen we can simplify it to a more regular test that loads the tested libs dynamically. Test: mmm art Test: atest art/libnativeloader Test: atest CtsJniTestCases Test: Cuttlefish app compat test that uses NDK translation Test: Manual tests with Android Studio TI agents (http://g/art-module-team/7Jy3Tg7LCh0) Bug: 130340935 Change-Id: I2513472c4e1c44f0fcb01a6b4f6eccbb03718f1d
2020-01-21nativebridge: Add PreZygoteFork callback Lev Rumyantsev
It's required to clean-up the emulated enviroment (e.g. close file descriptors) after emulated execution in doPreload() in app-zygote. Test: NativeBridge6PreZygoteFork_test Test: CtsSeccompHostTestCases android.seccomp.cts.SeccompHostJUnit4DeviceTest testAppZygoteSyscalls both for Q.sdk_gphone_x86_arm.armeabi-v7a Bug: 146904103 Change-Id: Id192a1647c2f405570bf196daf65b3f2a9faca42
2019-10-16Remove temporary CPPLINT.cfg files Orion Hodson
Temporary CPPLINT.cfg files were introduced when move libnativeloader and libnativebridge under art/. Bug: 141749154 Test: mm cpplint-art-all Change-Id: I85e75180138a512aef025f1e5275e20d8d1d14b0
2019-10-11Move libnative{bridge,loader} to art/ Orion Hodson
This change moves system/core/libnative{bridge,loader} under art/. Bug: 137364733 Test: m Change-Id: I9be7333d00fcd3f36cd80520e50a30ea840187ad