diff options
author | torne <torne@chromium.org> | 2015-02-18 13:37:16 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-18 21:37:59 +0000 |
commit | 9d90d85f73ca46847047ccbda270f25b637ccc86 (patch) | |
tree | 2c173d1a8a25f40aeccbd011c1e09a6d5946eafc /build/android | |
parent | bf551a2b26ff9228329da910e8c656eb5ed4a2e9 (diff) | |
download | chromium_src-9d90d85f73ca46847047ccbda270f25b637ccc86.zip chromium_src-9d90d85f73ca46847047ccbda270f25b637ccc86.tar.gz chromium_src-9d90d85f73ca46847047ccbda270f25b637ccc86.tar.bz2 |
android: Hide JNI exports by default.
Hide JNI exported functions in Android binaries by default, unless the
target in question has explicitly set "use_native_jni_exports" to
indicate that it relies on the JVM's automatic symbol lookup mechanism.
The functions are simply demoted to hidden visibility; the code will
remain unless the linker determines that it is unreferenced and strips
it via --gc-sections.
This ensures that binaries by default actually test the explicit JNI
registration codepaths, which are required for compatibility with the
crazy linker, while still allowing binaries that do not require crazy
linker compatibility to choose to use the automatic mechanism in future.
BUG=442327
Review URL: https://codereview.chromium.org/843103003
Cr-Commit-Position: refs/heads/master@{#316896}
Diffstat (limited to 'build/android')
-rw-r--r-- | build/android/android_exports.gyp | 12 | ||||
-rw-r--r-- | build/android/android_no_jni_exports.lst | 17 | ||||
-rw-r--r-- | build/android/android_webview_export_whitelist.lst (renamed from build/android/android_exports.lst) | 3 |
3 files changed, 27 insertions, 5 deletions
diff --git a/build/android/android_exports.gyp b/build/android/android_exports.gyp index c259eee..bf3424d 100644 --- a/build/android/android_exports.gyp +++ b/build/android/android_exports.gyp @@ -2,13 +2,20 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +# This target is only used when android_webview_build==1 - it implements a +# whitelist for exported symbols to minimise the binary size and prevent us +# accidentally exposing things we don't mean to expose. + { + 'variables': { + 'android_linker_script%': '<(SHARED_INTERMEDIATE_DIR)/android_webview_export_whitelist.lst', + }, 'targets': [ { 'target_name': 'android_exports', 'type': 'none', 'inputs': [ - '<(DEPTH)/build/android/android_exports.lst', + '<(DEPTH)/build/android/android_webview_export_whitelist.lst', ], 'outputs': [ '<(android_linker_script)', @@ -28,9 +35,6 @@ # Only export symbols that are specified in version script. '-Wl,--version-script=<(android_linker_script)', ], - 'ldflags!': [ - '-Wl,--exclude-libs=ALL', - ], }, }], ], diff --git a/build/android/android_no_jni_exports.lst b/build/android/android_no_jni_exports.lst new file mode 100644 index 0000000..ffc6cf7 --- /dev/null +++ b/build/android/android_no_jni_exports.lst @@ -0,0 +1,17 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# This script makes all JNI exported symbols local, to prevent the JVM from +# being able to find them, enforcing use of manual JNI function registration. +# This is used for all Android binaries by default, unless they explicitly state +# that they want JNI exported symbols to remain visible, as we need to ensure +# the manual registration path is correct to maintain compatibility with the +# crazy linker. +# Check ld version script manual: +# https://sourceware.org/binutils/docs-2.24/ld/VERSION.html#VERSION + +{ + local: + Java_*; +}; diff --git a/build/android/android_exports.lst b/build/android/android_webview_export_whitelist.lst index 6eee232..2a56a75 100644 --- a/build/android/android_exports.lst +++ b/build/android/android_webview_export_whitelist.lst @@ -2,7 +2,8 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -# Default exports specification for chromium shared libraries on android. +# Exports specification for android_webview_build==1, which uses a whitelist to +# enforce only specific symbols being exported. # Check ld version script manual: # https://sourceware.org/binutils/docs-2.24/ld/VERSION.html#VERSION |