diff options
author | piman@google.com <piman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-29 20:52:15 +0000 |
---|---|---|
committer | piman@google.com <piman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-29 20:52:15 +0000 |
commit | 778da76f8a401af0eb108889e3e29506d1638bd5 (patch) | |
tree | b4f4226deffd358705a4be5753082cd8aeec2a31 /o3d | |
parent | 7c37e4c641007ccbb666be127926e7512b0db89b (diff) | |
download | chromium_src-778da76f8a401af0eb108889e3e29506d1638bd5.zip chromium_src-778da76f8a401af0eb108889e3e29506d1638bd5.tar.gz chromium_src-778da76f8a401af0eb108889e3e29506d1638bd5.tar.bz2 |
linux: unexport as many symbols as possible
See discussion on http://code.google.com/p/chromium/issues/detail?id=17557
On linux, exported symbols from a shared library can be overridden by another unit (e.g. the browser) if it exports the same ones. So compile everything with -fvisibility=hidden to make every symbol private by default, and explicitly export the ones that we care about. Also make sure that third-party deps (e.g. icu) don't explicitly export symbols.
Review URL: http://codereview.chromium.org/160317
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21992 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d')
-rw-r--r-- | o3d/base/icu38_o3d.scons | 14 | ||||
-rw-r--r-- | o3d/main.scons | 2 | ||||
-rw-r--r-- | o3d/plugin/cross/main.cc | 7 | ||||
-rw-r--r-- | o3d/plugin/cross/main.h | 6 | ||||
-rw-r--r-- | o3d/plugin/linux/main_linux.cc | 6 | ||||
-rw-r--r-- | o3d/v8/build.scons | 4 |
6 files changed, 27 insertions, 12 deletions
diff --git a/o3d/base/icu38_o3d.scons b/o3d/base/icu38_o3d.scons index 701e511..f7d5a33 100644 --- a/o3d/base/icu38_o3d.scons +++ b/o3d/base/icu38_o3d.scons @@ -397,6 +397,14 @@ def MakeObject(env, source, extra_defines): if CombinedLib: + if env.Bit('linux'): + # U_STATIC_IMPLEMENTATION gets overridden by U_COMBINED_IMPLEMENTATION, + # which on linux causes all the symbols to be exported from the shared + # library, conflicting with the browser's definition if it uses icu as well + # (e.g. Chrome). + combined_flag = [] + else: + combined_flag = ['U_COMBINED_IMPLEMENTATION'] # These empirically fail to build when U_COMMON_IMPLEMENTATION # isn't defined in addition to U_COMBINED_IMPLEMENTATION. Remove # them from the source file list and re-append them with Nodes @@ -410,13 +418,11 @@ if CombinedLib: objects = [] for n in need_common_implementation: common_input_files.remove(n) - o = MakeObject(env, n, ['U_COMMON_IMPLEMENTATION', - 'U_COMBINED_IMPLEMENTATION']) + o = MakeObject(env, n, ['U_COMMON_IMPLEMENTATION'] + combined_flag) objects.append(o) sources = common_input_files + i18n_input_files + stubdata_input_files - objects += [MakeObject(env, n, ['U_COMBINED_IMPLEMENTATION']) - for n in sources] + objects += [MakeObject(env, n, combined_flag) for n in sources] icu_lib = env.ComponentLibrary('icu', objects); diff --git a/o3d/main.scons b/o3d/main.scons index d241908..27c52f8 100644 --- a/o3d/main.scons +++ b/o3d/main.scons @@ -684,7 +684,7 @@ linux_env.Append( ['NACL_LINUX', '1'], 'SK_BUILD_FOR_UNIX' ], - CCFLAGS = ['-Wstrict-aliasing', '-m32'], + CCFLAGS = ['-Wstrict-aliasing', '-fvisibility=hidden', '-m32'], LINKFLAGS = ['-m32'], LIBS = ['pthread', 'rt', 'dl'], NACL_HTP_LIBS = ['ssl', 'crypto'], diff --git a/o3d/plugin/cross/main.cc b/o3d/plugin/cross/main.cc index d6144ca..da16756 100644 --- a/o3d/plugin/cross/main.cc +++ b/o3d/plugin/cross/main.cc @@ -148,7 +148,7 @@ namespace o3d { extern "C" { #endif -NPError OSCALL NP_GetEntryPoints(NPPluginFuncs *pluginFuncs) { +NPError EXPORT_SYMBOL OSCALL NP_GetEntryPoints(NPPluginFuncs *pluginFuncs) { HANDLE_CRASHES; pluginFuncs->version = 11; pluginFuncs->size = sizeof(*pluginFuncs); @@ -169,7 +169,7 @@ NPError OSCALL NP_GetEntryPoints(NPPluginFuncs *pluginFuncs) { return NPERR_NO_ERROR; } -char *NP_GetMIMEDescription(void) { +char * EXPORT_SYMBOL NP_GetMIMEDescription(void) { return O3D_PLUGIN_MIME_TYPE "::O3D MIME"; } @@ -177,7 +177,8 @@ char *NP_GetMIMEDescription(void) { #if !defined(O3D_INTERNAL_PLUGIN) extern "C" { -NPError NP_GetValue(void *instance, NPPVariable variable, void *value) { +NPError EXPORT_SYMBOL NP_GetValue(void *instance, NPPVariable variable, + void *value) { return o3d::NP_GetValue(instance, variable, value); } } diff --git a/o3d/plugin/cross/main.h b/o3d/plugin/cross/main.h index 29e386a..049c688 100644 --- a/o3d/plugin/cross/main.h +++ b/o3d/plugin/cross/main.h @@ -59,6 +59,12 @@ #define HANDLE_CRASHES void(0) #else // O3D_INTERNAL_PLUGIN +#if defined(OS_LINUX) +#define EXPORT_SYMBOL __attribute__((visibility ("default"))) +#else +#define EXPORT_SYMBOL +#endif + extern ExceptionManager *g_exception_manager; // BreakpadEnabler is a simple class to keep track of whether or not diff --git a/o3d/plugin/linux/main_linux.cc b/o3d/plugin/linux/main_linux.cc index 55096db..b91c9d8 100644 --- a/o3d/plugin/linux/main_linux.cc +++ b/o3d/plugin/linux/main_linux.cc @@ -622,15 +622,15 @@ namespace o3d { extern "C" { #endif -NPError OSCALL NP_Initialize(NPNetscapeFuncs *browserFuncs, - NPPluginFuncs *pluginFuncs) { +NPError EXPORT_SYMBOL OSCALL NP_Initialize(NPNetscapeFuncs *browserFuncs, + NPPluginFuncs *pluginFuncs) { NPError retval = InitializeNPNApi(browserFuncs); if (retval != NPERR_NO_ERROR) return retval; NP_GetEntryPoints(pluginFuncs); return InitializePlugin(); } -NPError OSCALL NP_Shutdown(void) { +NPError EXPORT_SYMBOL OSCALL NP_Shutdown(void) { HANDLE_CRASHES; DLOG(INFO) << "NP_Shutdown"; diff --git a/o3d/v8/build.scons b/o3d/v8/build.scons index 6fd51cc..43e332f 100644 --- a/o3d/v8/build.scons +++ b/o3d/v8/build.scons @@ -50,7 +50,7 @@ env = env.Clone( V8_MODE = 'release', V8_MODE_DIR = '$V8_SRC_DIR/obj/$V8_MODE', V8_SCONS_COM = '$PYTHON $SCONS -C $V8_SRC_DIR -f SConstruct ' - '$DEBUG_OPTS mode=$V8_MODE importenv=INCLUDE,LIB', + '$DEBUG_OPTS mode=$V8_MODE importenv=INCLUDE,LIB,CCFLAGS', SCONS = '$SCONS_DIR/scons.py', DEBUG_OPTS = ['--debug=%s' % item for item in GetOption('debug')] ) @@ -109,6 +109,8 @@ if v8_env.Bit('windows'): v8_env['ENV']['LIB'] = lib_path + ";" + v8_env['ENV']['LIB'] except KeyError: v8_env['ENV']['LIB'] = lib_path +elif v8_env.Bit('linux'): + v8_env['ENV']['CCFLAGS'] = '-fvisibility=hidden' v8_no_snapshot = v8_env.Command( v8_scons_targets_no_snapshot, |