diff options
-rw-r--r-- | libnativeloader/Android.bp | 11 | ||||
-rw-r--r-- | libnativeloader/libnativeloader_test.map | 26 | ||||
-rw-r--r-- | test/Android.bp | 28 | ||||
-rw-r--r-- | test/art-standalone-gtest-version.map | 32 | ||||
-rw-r--r-- | test/art-standalone-test-version.map | 20 |
5 files changed, 106 insertions, 11 deletions
diff --git a/libnativeloader/Android.bp b/libnativeloader/Android.bp index 3b685747aa..47b6961167 100644 --- a/libnativeloader/Android.bp +++ b/libnativeloader/Android.bp @@ -135,12 +135,11 @@ cc_defaults { cflags: ["-DANDROID"], - // The tests mock libdl_android and libnativebridge symbols, so export them - // to override the ones loaded from their libs. - ldflags: [ - "-Wl,--export-dynamic-symbol=android_*", - "-Wl,--export-dynamic-symbol=NativeBridge*", - ], + // Ordinarily, symbols are only exported if they are referenced by some + // shared object dependency. Instead, export everything using + // --export-dynamic, then restrict the visibility using the version script. + ldflags: ["-Wl,--export-dynamic"], + version_script: "libnativeloader_test.map", header_libs: [ "libnativebridge-headers", diff --git a/libnativeloader/libnativeloader_test.map b/libnativeloader/libnativeloader_test.map new file mode 100644 index 0000000000..1f26f9ffc8 --- /dev/null +++ b/libnativeloader/libnativeloader_test.map @@ -0,0 +1,26 @@ +# +# Copyright (C) 2024 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +{ + global: + # The tests mock libdl_android and libnativebridge symbols, so export them + # to override the ones loaded from their libs. + android_*; + NativeBridge*; + + local: + *; +}; diff --git a/test/Android.bp b/test/Android.bp index c3f781cc4c..6c91cf1a80 100644 --- a/test/Android.bp +++ b/test/Android.bp @@ -154,6 +154,19 @@ filegroup { srcs: ["art-gtests-target-standalone-with-boot-image-template.xml"], } +// Version script for `art_standalone_test_defaults`. +filegroup { + name: "art-standalone-test-version", + srcs: ["art-standalone-test-version.map"], +} + +// Version script for `art_standalone_gtest_defaults`. In particular, it adds +// libsigchain's libc.so interceptors. +filegroup { + name: "art-standalone-gtest-version", + srcs: ["art-standalone-gtest-version.map"], +} + // When soong builds the tests in a sandbox, the targets of symlinks // must be declared as inputs to soong modules that use them, or else // it will be a dangling symlink in the sandbox. @@ -219,6 +232,15 @@ art_cc_defaults { min_sdk_version: "31", // Same as the ART APEX. + // Link libc++ statically to avoid needing the system libc++.so, which may + // be incompatible. The linker exports symbols from an executable that are + // referenced in the .dynsym tables of shared object dependencies, so use a + // version script to restrict exports. The version script is needed for + // hiding symbols from libc++ (either libc++_static.a or vaguely-linked + // symbols in other object files) and from other libraries, such as libbase. + stl: "libc++_static", + version_script: ":art-standalone-test-version", + // Make standalone tests check their own NEEDED dependencies for disallowed // libraries. Add standalone_test_lib_check and its dependencies, except // libgtest which is expected to be added by the tests. @@ -347,11 +369,7 @@ art_cc_defaults { static_libs: [ "libart-gtest", ], - // Reduce test executable size by disabling automatic export of static lib symbols. - // Don't use --exclude-libs=ALL, because it breaks tests under ASAN by hiding __asan* symbols. - ldflags: [ - "-Wl,--exclude-libs=libart-gtest.a", - ], + version_script: ":art-standalone-gtest-version", test_for: [ "com.android.art", "com.android.art.debug", diff --git a/test/art-standalone-gtest-version.map b/test/art-standalone-gtest-version.map new file mode 100644 index 0000000000..0c66d3ff45 --- /dev/null +++ b/test/art-standalone-gtest-version.map @@ -0,0 +1,32 @@ +# +# Copyright (C) 2024 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +{ + global: + # Export libsigchain's libc.so interceptors. + sigaction; + sigaction64; + signal; + sigprocmask; + sigprocmask64; + + # Allow jni_compiler_test to find Java_MyClassNatives_bar within itself + # using dlopen(NULL, ...). + Java_MyClassNatives_*; + + local: + *; +}; diff --git a/test/art-standalone-test-version.map b/test/art-standalone-test-version.map new file mode 100644 index 0000000000..e342e43eab --- /dev/null +++ b/test/art-standalone-test-version.map @@ -0,0 +1,20 @@ +# +# Copyright (C) 2024 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +{ + local: + *; +}; |