Commit 813edf0d authored by torne's avatar torne Committed by Commit bot

android: don't export unnecessary symbols.

Android binaries were relying on -Wl,--exclude-libs=ALL to prevent
unnecessary symbols from being exported in the final shared libraries
built in Chromium, however several changes were submitted that actually
disabled this linker flag in virtually all binaries, and thus it was not
really being used and many symbols were exported by mistake.

Remove --exclude-libs=ALL entirely from the Android build, as well as
all the places which were previously having to unset it, and instead
exclude the specific libraries which incorporate visible symbols that we
don't want: the NDK libraries which we statically link into the binary,
and a number of components of chromium which contain assembly code which
has not yet been fixed to set symbol visibilities correctly.

This reduces the number of exported symbols in the shared libraries to
only the ones we intended to export, which saves ~120KB binary size.

The GN build does not build the same set of things as static libraries,
so the list is slightly different there and several more symbols are
left in the final binaries which shouldn't be there, but are not pulled
in via a static library and so no --exclude-libs flag will ever fix it;
the symbol visibilities will need to be fixed at source.

BUG=448386
TBR=ben@chromium.org

Review URL: https://codereview.chromium.org/806533003

Cr-Commit-Position: refs/heads/master@{#317027}
parent d8c27794
...@@ -4588,9 +4588,6 @@ ...@@ -4588,9 +4588,6 @@
], ],
'conditions': [ 'conditions': [
['component=="static_library" and android_webview_build==0', { ['component=="static_library" and android_webview_build==0', {
'ldflags': [
'-Wl,--exclude-libs=ALL',
],
'target_conditions': [ 'target_conditions': [
['use_native_jni_exports==0', { ['use_native_jni_exports==0', {
# Use a linker version script to strip JNI exports from # Use a linker version script to strip JNI exports from
...@@ -4658,6 +4655,20 @@ ...@@ -4658,6 +4655,20 @@
'ldflags': [ 'ldflags': [
'--sysroot=<(android_ndk_sysroot)', '--sysroot=<(android_ndk_sysroot)',
'-nostdlib', '-nostdlib',
# Don't allow visible symbols from libgcc or stlport to be
# re-exported.
'-Wl,--exclude-libs=libgcc.a',
'-Wl,--exclude-libs=libstlport_static.a',
# Don't allow visible symbols from libraries that contain
# assembly code with symbols that aren't hidden properly.
# http://crbug.com/448386
'-Wl,--exclude-libs=libcommon_audio.a',
'-Wl,--exclude-libs=libcommon_audio_neon.a',
'-Wl,--exclude-libs=libcommon_audio_sse2.a',
'-Wl,--exclude-libs=libiSACFix.a',
'-Wl,--exclude-libs=libisac_neon.a',
'-Wl,--exclude-libs=libopus.a',
'-Wl,--exclude-libs=libvpx.a',
], ],
'libraries': [ 'libraries': [
'-l<(android_stlport_library)', '-l<(android_stlport_library)',
...@@ -4774,9 +4785,6 @@ ...@@ -4774,9 +4785,6 @@
], ],
}], }],
['_type=="shared_library" or _type=="loadable_module"', { ['_type=="shared_library" or _type=="loadable_module"', {
'ldflags!': [
'-Wl,--exclude-libs=ALL',
],
'ldflags': [ 'ldflags': [
'-Wl,-shared,-Bsymbolic', '-Wl,-shared,-Bsymbolic',
], ],
......
...@@ -449,8 +449,15 @@ config("compiler") { ...@@ -449,8 +449,15 @@ config("compiler") {
ldflags += [ ldflags += [
"-Wl,--no-undefined", "-Wl,--no-undefined",
# Don't export symbols from statically linked libraries. # Don't allow visible symbols from libgcc or stlport to be
"-Wl,--exclude-libs=ALL", # re-exported.
"-Wl,--exclude-libs=libgcc.a",
"-Wl,--exclude-libs=libstlport_static.a",
# Don't allow visible symbols from libraries that contain
# assembly code with symbols that aren't hidden properly.
# http://crbug.com/448386
"-Wl,--exclude-libs=libvpx_assembly_arm.a",
] ]
if (cpu_arch == "arm") { if (cpu_arch == "arm") {
ldflags += [ ldflags += [
......
...@@ -31,17 +31,6 @@ ...@@ -31,17 +31,6 @@
'GLES2_USE_MOJO', 'GLES2_USE_MOJO',
], ],
}, },
'all_dependent_settings': {
'conditions': [
# We need to be able to call the MojoSetGLES2Thunks() function in
# gles2_thunks.cc
['OS=="android"', {
'ldflags!': [
'-Wl,--exclude-libs=ALL',
],
}],
],
},
'sources': [ 'sources': [
'<(DEPTH)/third_party/mojo/src/mojo/public/c/gles2/gles2.h', '<(DEPTH)/third_party/mojo/src/mojo/public/c/gles2/gles2.h',
'<(DEPTH)/third_party/mojo/src/mojo/public/c/gles2/gles2_export.h', '<(DEPTH)/third_party/mojo/src/mojo/public/c/gles2/gles2_export.h',
......
...@@ -16,13 +16,6 @@ ...@@ -16,13 +16,6 @@
'native_test_launcher.cc', 'native_test_launcher.cc',
'native_test_launcher.h', 'native_test_launcher.h',
], ],
'direct_dependent_settings': {
'ldflags!': [
# JNI_OnLoad is implemented in a .a and we need to
# re-export in the .so.
'-Wl,--exclude-libs=ALL',
],
},
'dependencies': [ 'dependencies': [
'../../base/base.gyp:base', '../../base/base.gyp:base',
'../../base/base.gyp:test_support_base', '../../base/base.gyp:test_support_base',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment