diff --git a/dom/media/webspeech/synth/android/AndroidSpeechModule.cpp b/dom/media/webspeech/synth/android/AndroidSpeechModule.cpp index 0866ca862b0a..b8ac887176cc 100644 --- a/dom/media/webspeech/synth/android/AndroidSpeechModule.cpp +++ b/dom/media/webspeech/synth/android/AndroidSpeechModule.cpp @@ -38,7 +38,7 @@ static const mozilla::Module::CategoryEntry kCategories[] = { ANDROIDSPEECHSERVICE_CONTRACTID}, {nullptr}}; -static const mozilla::Module kModule = { +extern const mozilla::Module kSpeechSynthModule = { mozilla::Module::kVersion, kCIDs, kContracts, @@ -47,5 +47,3 @@ static const mozilla::Module kModule = { nullptr, nullptr, }; - -NSMODULE_DEFN(androidspeechsynth) = &kModule; diff --git a/dom/media/webspeech/synth/cocoa/OSXSpeechSynthesizerModule.cpp b/dom/media/webspeech/synth/cocoa/OSXSpeechSynthesizerModule.cpp index fda61fb83f39..13d18de69023 100644 --- a/dom/media/webspeech/synth/cocoa/OSXSpeechSynthesizerModule.cpp +++ b/dom/media/webspeech/synth/cocoa/OSXSpeechSynthesizerModule.cpp @@ -46,12 +46,11 @@ static void UnloadOSXSpeechSynthesizerModule() { OSXSpeechSynthesizerService::Shutdown(); } -static const mozilla::Module kModule = {mozilla::Module::kVersion, - kCIDs, - kContracts, - kCategories, - nullptr, - nullptr, - UnloadOSXSpeechSynthesizerModule}; - -NSMODULE_DEFN(osxsynth) = &kModule; +extern const mozilla::Module kSpeechSynthModule = { + mozilla::Module::kVersion, + kCIDs, + kContracts, + kCategories, + nullptr, + nullptr, + UnloadOSXSpeechSynthesizerModule}; diff --git a/dom/media/webspeech/synth/windows/SapiModule.cpp b/dom/media/webspeech/synth/windows/SapiModule.cpp index aa3526c840d0..9569ab643981 100644 --- a/dom/media/webspeech/synth/windows/SapiModule.cpp +++ b/dom/media/webspeech/synth/windows/SapiModule.cpp @@ -39,8 +39,6 @@ static const mozilla::Module::CategoryEntry kCategories[] = { static void UnloadSapiModule() { SapiService::Shutdown(); } -static const mozilla::Module kModule = { +extern const mozilla::Module kSpeechSynthModule = { mozilla::Module::kVersion, kCIDs, kContracts, kCategories, nullptr, nullptr, UnloadSapiModule}; - -NSMODULE_DEFN(synthsapi) = &kModule; diff --git a/dom/power/PowerManagerService.cpp b/dom/power/PowerManagerService.cpp index acaede65943f..c3d3021d4b80 100644 --- a/dom/power/PowerManagerService.cpp +++ b/dom/power/PowerManagerService.cpp @@ -173,7 +173,7 @@ static const mozilla::Module::ContractIDEntry kPowerManagerContracts[] = { // We mark the power module as being available in the GPU process because the // appshell depends on the power manager service. -static const mozilla::Module kPowerManagerModule = { +extern const mozilla::Module kPowerManagerModule = { mozilla::Module::kVersion, kPowerManagerCIDs, kPowerManagerContracts, @@ -182,5 +182,3 @@ static const mozilla::Module kPowerManagerModule = { nullptr, nullptr, mozilla::Module::ALLOW_IN_GPU_AND_SOCKET_PROCESS}; - -NSMODULE_DEFN(nsPowerManagerModule) = &kPowerManagerModule; diff --git a/layout/build/nsLayoutModule.cpp b/layout/build/nsLayoutModule.cpp index bce19792006b..7d8cc13f7768 100644 --- a/layout/build/nsLayoutModule.cpp +++ b/layout/build/nsLayoutModule.cpp @@ -270,12 +270,10 @@ void nsLayoutModuleDtor() { xpcModuleDtor(); } -static const mozilla::Module kLayoutModule = {mozilla::Module::kVersion, +extern const mozilla::Module kLayoutModule = {mozilla::Module::kVersion, nullptr, nullptr, kLayoutCategories, nullptr, nullptr, nullptr}; - -NSMODULE_DEFN(nsLayoutModule) = &kLayoutModule; diff --git a/layout/tools/layout-debug/src/nsDebugFactory.cpp b/layout/tools/layout-debug/src/nsDebugFactory.cpp index a0084fd7b8fa..35813234d781 100644 --- a/layout/tools/layout-debug/src/nsDebugFactory.cpp +++ b/layout/tools/layout-debug/src/nsDebugFactory.cpp @@ -35,8 +35,6 @@ static const mozilla::Module::CategoryEntry kLayoutDebugCategories[] = { "@mozilla.org/commandlinehandler/general-startup;1?type=layoutdebug"}, {nullptr}}; -static const mozilla::Module kLayoutDebugModule = { +extern const mozilla::Module kLayoutDebugModule = { mozilla::Module::kVersion, kLayoutDebugCIDs, kLayoutDebugContracts, kLayoutDebugCategories}; - -NSMODULE_DEFN(nsLayoutDebugModule) = &kLayoutDebugModule; diff --git a/mobile/android/components/build/nsBrowserModule.cpp b/mobile/android/components/build/nsBrowserModule.cpp index 3561a41b00aa..87d55fb04c56 100644 --- a/mobile/android/components/build/nsBrowserModule.cpp +++ b/mobile/android/components/build/nsBrowserModule.cpp @@ -47,7 +47,5 @@ static const mozilla::Module::ContractIDEntry kBrowserContracts[] = { #endif {nullptr}}; -static const mozilla::Module kBrowserModule = {mozilla::Module::kVersion, +extern const mozilla::Module kBrowserModule = {mozilla::Module::kVersion, kBrowserCIDs, kBrowserContracts}; - -NSMODULE_DEFN(nsBrowserCompsModule) = &kBrowserModule; diff --git a/netwerk/build/nsNetModule.cpp b/netwerk/build/nsNetModule.cpp index 0a8389ded980..d732133cbfe6 100644 --- a/netwerk/build/nsNetModule.cpp +++ b/netwerk/build/nsNetModule.cpp @@ -349,7 +349,7 @@ void nsNetShutdown() { gDataSniffers = nullptr; } -static const mozilla::Module kNeckoModule = { +extern const mozilla::Module kNeckoModule = { mozilla::Module::kVersion, nullptr, nullptr, @@ -358,5 +358,3 @@ static const mozilla::Module kNeckoModule = { nullptr, nullptr, mozilla::Module::ALLOW_IN_SOCKET_PROCESS}; - -NSMODULE_DEFN(necko) = &kNeckoModule; diff --git a/parser/htmlparser/nsParserModule.cpp b/parser/htmlparser/nsParserModule.cpp index 39e4c86841d5..721bfa62d5ff 100644 --- a/parser/htmlparser/nsParserModule.cpp +++ b/parser/htmlparser/nsParserModule.cpp @@ -31,12 +31,10 @@ static nsresult Initialize() { static void Shutdown() { nsHTMLTags::ReleaseTable(); } -static mozilla::Module kParserModule = {mozilla::Module::kVersion, - kParserCIDs, - nullptr, - nullptr, - nullptr, - Initialize, - Shutdown}; - -NSMODULE_DEFN(nsParserModule) = &kParserModule; +extern const mozilla::Module kParserModule = {mozilla::Module::kVersion, + kParserCIDs, + nullptr, + nullptr, + nullptr, + Initialize, + Shutdown}; diff --git a/python/mozbuild/mozbuild/action/check_binary.py b/python/mozbuild/mozbuild/action/check_binary.py index 5fd1b3c20c19..b00e36d742ce 100644 --- a/python/mozbuild/mozbuild/action/check_binary.py +++ b/python/mozbuild/mozbuild/action/check_binary.py @@ -214,73 +214,6 @@ def is_libxul(binary): return 'xul' in basename -def check_nsmodules(target, binary): - if target is HOST or not is_libxul(binary): - raise Skip() - symbols = [] - for sym in iter_symbols(binary): - if sym['addr'] == 0: - continue - name = sym['name'] - # NSModules symbols end with _NSModule or _NSModuleE when C++-mangled. - if name.endswith(('_NSModule', '_NSModuleE')): - # We don't have a valid size in the symbol list for macho and coff. - # Use our guesstimate. - size = sym['size'] or GUESSED_NSMODULE_SIZE - symbols.append((sym['addr'], size, name)) - elif name in ('__start_kPStaticModules', '__stop_kPStaticModules'): - # For coff, these symbols have a size. - if get_type(binary) not in (ELF, MACHO): - size = GUESSED_NSMODULE_SIZE - else: - size = 0 - symbols.append((sym['addr'], size, name)) - if not symbols: - raise RuntimeError('Could not find NSModules') - - def print_symbols(symbols): - for addr, size, sym in symbols: - print('%x %d %s' % (addr, size, sym)) - - symbols = sorted(symbols) - next_addr = None - # MSVC linker, when doing incremental linking, adds padding when - # merging sections. Allow there to be more space between the NSModule - # symbols, as long as they are in the right order. - test_msvc = (buildconfig.substs.get('CC_TYPE') == 'clang-cl' and \ - buildconfig.substs.get('DEVELOPER_OPTIONS')) - test_clang = (buildconfig.substs.get('CC_TYPE') == 'clang' and \ - buildconfig.substs.get('OS_ARCH') == 'WINNT') - if test_msvc or test_clang: - sym_cmp = lambda guessed, actual: guessed <= actual - else: - sym_cmp = lambda guessed, actual: guessed == actual - - for addr, size, sym in symbols: - if next_addr is not None and not sym_cmp(next_addr, addr): - print_symbols(symbols) - raise RuntimeError('NSModules are not adjacent') - next_addr = addr + size - - # The mac linker doesn't emit the start/stop symbols in the symbol table. - # We'll just assume it did the job correctly. - if get_type(binary) == MACHO: - return - - first = symbols[0][2] - last = symbols[-1][2] - # On some platforms, there are extra underscores on symbol names. - if first.lstrip('_') != 'start_kPStaticModules' or \ - last.lstrip('_') != 'stop_kPStaticModules': - print_symbols(symbols) - syms = set(sym for add, size, sym in symbols) - if 'start_kPStaticModules' not in syms: - raise RuntimeError('Could not find start_kPStaticModules symbol') - if 'stop_kPStaticModules' not in syms: - raise RuntimeError('Could not find stop_kPStaticModules symbol') - raise RuntimeError('NSModules are not ordered appropriately') - - def check_pt_load(target, binary): if target is HOST or get_type(binary) != ELF or not is_libxul(binary): raise Skip() @@ -371,8 +304,6 @@ def checks(target, binary): checks.append(check_pt_load) checks.append(check_mozglue_order) - checks.append(check_nsmodules) - retcode = 0 basename = os.path.basename(binary) for c in checks: diff --git a/security/manager/ssl/LocalCertService.cpp b/security/manager/ssl/LocalCertService.cpp index 73c9bb572fb4..7b0ed22c847e 100644 --- a/security/manager/ssl/LocalCertService.cpp +++ b/security/manager/ssl/LocalCertService.cpp @@ -468,9 +468,7 @@ static const Module::CIDEntry kLocalCertServiceCIDs[] = { static const Module::ContractIDEntry kLocalCertServiceContracts[] = { {LOCALCERTSERVICE_CONTRACTID, &kLOCALCERTSERVICE_CID}, {nullptr}}; -static const Module kLocalCertServiceModule = { +extern const Module kLocalCertServiceModule = { Module::kVersion, kLocalCertServiceCIDs, kLocalCertServiceContracts}; -NSMODULE_DEFN(LocalCertServiceModule) = &kLocalCertServiceModule; - } // namespace mozilla diff --git a/toolkit/components/kvstore/nsKeyValueModule.cpp b/toolkit/components/kvstore/nsKeyValueModule.cpp index ece57f6dc5e2..a19686457a22 100644 --- a/toolkit/components/kvstore/nsKeyValueModule.cpp +++ b/toolkit/components/kvstore/nsKeyValueModule.cpp @@ -22,7 +22,5 @@ const mozilla::Module::CIDEntry kKeyValueCIDs[] = { const mozilla::Module::ContractIDEntry kKeyValueContracts[] = { {NS_KEY_VALUE_SERVICE_CONTRACTID, &kNS_KEY_VALUE_SERVICE_CID}, {nullptr}}; -const mozilla::Module kKeyValueModule = { +extern const mozilla::Module kKeyValueModule = { mozilla::Module::kVersion, kKeyValueCIDs, kKeyValueContracts, nullptr}; - -NSMODULE_DEFN(nsKeyValueModule) = &kKeyValueModule; diff --git a/toolkit/library/StaticXULComponents.ld b/toolkit/library/StaticXULComponents.ld deleted file mode 100644 index bbf81d06684d..000000000000 --- a/toolkit/library/StaticXULComponents.ld +++ /dev/null @@ -1,7 +0,0 @@ -SECTIONS { - .data.rel.ro : { - PROVIDE_HIDDEN(__start_kPStaticModules = .); - *(kPStaticModules) - PROVIDE_HIDDEN(__stop_kPStaticModules = .); - } -} diff --git a/toolkit/library/moz.build b/toolkit/library/moz.build index 3e855cf46bd3..d2e9a265b91c 100644 --- a/toolkit/library/moz.build +++ b/toolkit/library/moz.build @@ -58,17 +58,6 @@ def Libxul(name, output_category=None): # and config/version.mk would lift the $(srcdir) RCINCLUDE = '$(DEPTH)/toolkit/library/xulrunner.rc' - # BFD ld doesn't create multiple PT_LOADs as usual when an unknown section - # exists. Using an implicit linker script to make it fold that section in - # .data.rel.ro makes it create multiple PT_LOADs. That implicit linker - # script however makes gold misbehave, first because it doesn't like that - # the linker script is given after crtbegin.o, and even past that, replaces - # the default section rules with those from the script instead of - # supplementing them. Which leads to a lib with a huge load of sections. - if CONFIG['OS_TARGET'] not in ('OpenBSD', 'WINNT') and \ - CONFIG['LINKER_KIND'] == 'bfd': - LDFLAGS += [TOPSRCDIR + '/toolkit/library/StaticXULComponents.ld'] - Libxul_defines() if CONFIG['MOZ_NEEDS_LIBATOMIC']: diff --git a/toolkit/system/androidproxy/nsAndroidSystemProxySettings.cpp b/toolkit/system/androidproxy/nsAndroidSystemProxySettings.cpp index 86f049790a87..567c7c335a14 100644 --- a/toolkit/system/androidproxy/nsAndroidSystemProxySettings.cpp +++ b/toolkit/system/androidproxy/nsAndroidSystemProxySettings.cpp @@ -72,7 +72,5 @@ static const mozilla::Module::ContractIDEntry kSysProxyContracts[] = { {NS_SYSTEMPROXYSETTINGS_CONTRACTID, &kNS_ANDROIDSYSTEMPROXYSERVICE_CID}, {nullptr}}; -static const mozilla::Module kSysProxyModule = { +extern const mozilla::Module kSysProxyModule = { mozilla::Module::kVersion, kSysProxyCIDs, kSysProxyContracts}; - -NSMODULE_DEFN(nsAndroidProxyModule) = &kSysProxyModule; diff --git a/toolkit/system/osxproxy/nsOSXSystemProxySettings.mm b/toolkit/system/osxproxy/nsOSXSystemProxySettings.mm index 615199b4b345..3ba29027f94f 100644 --- a/toolkit/system/osxproxy/nsOSXSystemProxySettings.mm +++ b/toolkit/system/osxproxy/nsOSXSystemProxySettings.mm @@ -288,7 +288,5 @@ static const mozilla::Module::CIDEntry kOSXSysProxyCIDs[] = { static const mozilla::Module::ContractIDEntry kOSXSysProxyContracts[] = { {NS_SYSTEMPROXYSETTINGS_CONTRACTID, &kNS_OSXSYSTEMPROXYSERVICE_CID}, {NULL}}; -static const mozilla::Module kOSXSysProxyModule = {mozilla::Module::kVersion, kOSXSysProxyCIDs, - kOSXSysProxyContracts}; - -NSMODULE_DEFN(nsOSXProxyModule) = &kOSXSysProxyModule; +extern const mozilla::Module kSysProxyModule = {mozilla::Module::kVersion, kOSXSysProxyCIDs, + kOSXSysProxyContracts}; diff --git a/toolkit/system/windowsDHCPClient/nsWindowsDHCPClient.cpp b/toolkit/system/windowsDHCPClient/nsWindowsDHCPClient.cpp index 3552f8869dc6..6e58e69a6bad 100644 --- a/toolkit/system/windowsDHCPClient/nsWindowsDHCPClient.cpp +++ b/toolkit/system/windowsDHCPClient/nsWindowsDHCPClient.cpp @@ -92,11 +92,9 @@ static const mozilla::Module::CIDEntry kSysDHCPClientCIDs[] = { static const mozilla::Module::ContractIDEntry kSysDHCPClientContracts[] = { {NS_DHCPCLIENT_CONTRACTID, &kNS_WINDOWSDHCPCLIENTSERVICE_CID}, {nullptr}}; -static const mozilla::Module kSysDHCPClientModule = { +extern const mozilla::Module kSysDHCPClientModule = { mozilla::Module::kVersion, kSysDHCPClientCIDs, kSysDHCPClientContracts}; -NSMODULE_DEFN(nsDHCPClientModule) = &kSysDHCPClientModule; - } // namespace windowsDHCPClient } // namespace system } // namespace toolkit diff --git a/toolkit/system/windowsproxy/nsWindowsSystemProxySettings.cpp b/toolkit/system/windowsproxy/nsWindowsSystemProxySettings.cpp index d3b6f9fa3676..f2638196510f 100644 --- a/toolkit/system/windowsproxy/nsWindowsSystemProxySettings.cpp +++ b/toolkit/system/windowsproxy/nsWindowsSystemProxySettings.cpp @@ -267,7 +267,5 @@ static const mozilla::Module::ContractIDEntry kSysProxyContracts[] = { {NS_SYSTEMPROXYSETTINGS_CONTRACTID, &kNS_WINDOWSSYSTEMPROXYSERVICE_CID}, {nullptr}}; -static const mozilla::Module kSysProxyModule = { +extern const mozilla::Module kSysProxyModule = { mozilla::Module::kVersion, kSysProxyCIDs, kSysProxyContracts}; - -NSMODULE_DEFN(nsWindowsProxyModule) = &kSysProxyModule; diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index a5a9346ff01e..8855d3520aa0 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -1283,11 +1283,9 @@ static const mozilla::Module::ContractIDEntry kXREContracts[] = { {NS_PROFILESERVICE_CONTRACTID, &kProfileServiceCID}, {nullptr}}; -static const mozilla::Module kXREModule = {mozilla::Module::kVersion, kXRECIDs, +extern const mozilla::Module kXREModule = {mozilla::Module::kVersion, kXRECIDs, kXREContracts}; -NSMODULE_DEFN(Apprunner) = &kXREModule; - nsresult ScopedXPCOMStartup::Initialize() { NS_ASSERTION(gDirServiceProvider, "Should not get here!"); diff --git a/toolkit/xre/nsEmbeddingModule.cpp b/toolkit/xre/nsEmbeddingModule.cpp index 07615c6ac9a2..34a1de1d4451 100644 --- a/toolkit/xre/nsEmbeddingModule.cpp +++ b/toolkit/xre/nsEmbeddingModule.cpp @@ -39,7 +39,5 @@ static const mozilla::Module::ContractIDEntry kEmbeddingContracts[] = { #endif {nullptr}}; -static const mozilla::Module kEmbeddingModule = { +extern const mozilla::Module kEmbeddingModule = { mozilla::Module::kVersion, kEmbeddingCIDs, kEmbeddingContracts}; - -NSMODULE_DEFN(embedcomponents) = &kEmbeddingModule; diff --git a/tools/code-coverage/nsCodeCoverageFactory.cpp b/tools/code-coverage/nsCodeCoverageFactory.cpp index ea255922cfe6..cd11fba1d4e2 100644 --- a/tools/code-coverage/nsCodeCoverageFactory.cpp +++ b/tools/code-coverage/nsCodeCoverageFactory.cpp @@ -18,7 +18,5 @@ static const mozilla::Module::CIDEntry kCodeCoverageCIDs[] = { static const mozilla::Module::ContractIDEntry kCodeCoverageContracts[] = { {"@mozilla.org/tools/code-coverage;1", &kNS_CODECOVERAGE_CID}, {nullptr}}; -static const mozilla::Module kCodeCoverageModule = { +extern const mozilla::Module kCodeCoverageModule = { mozilla::Module::kVersion, kCodeCoverageCIDs, kCodeCoverageContracts}; - -NSMODULE_DEFN(nsCodeCoverageModule) = &kCodeCoverageModule; diff --git a/widget/android/nsWidgetFactory.cpp b/widget/android/nsWidgetFactory.cpp index de44a00f1df2..b352dea123dd 100644 --- a/widget/android/nsWidgetFactory.cpp +++ b/widget/android/nsWidgetFactory.cpp @@ -122,12 +122,10 @@ static void nsWidgetAndroidModuleDtor() { nsAppShellShutdown(); } -static const mozilla::Module kWidgetModule = {mozilla::Module::kVersion, +extern const mozilla::Module kWidgetModule = {mozilla::Module::kVersion, kWidgetCIDs, kWidgetContracts, nullptr, nullptr, nsAppShellInit, nsWidgetAndroidModuleDtor}; - -NSMODULE_DEFN(nsWidgetAndroidModule) = &kWidgetModule; diff --git a/widget/cocoa/nsWidgetFactory.mm b/widget/cocoa/nsWidgetFactory.mm index 93466c4a6aca..c665ae660af7 100644 --- a/widget/cocoa/nsWidgetFactory.mm +++ b/widget/cocoa/nsWidgetFactory.mm @@ -200,7 +200,7 @@ static void nsWidgetCocoaModuleDtor() { nsAppShellShutdown(); } -static const mozilla::Module kWidgetModule = {mozilla::Module::kVersion, +extern const mozilla::Module kWidgetModule = {mozilla::Module::kVersion, kWidgetCIDs, kWidgetContracts, NULL, @@ -208,5 +208,3 @@ static const mozilla::Module kWidgetModule = {mozilla::Module::kVersion, nsAppShellInit, nsWidgetCocoaModuleDtor, mozilla::Module::ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS}; - -NSMODULE_DEFN(nsWidgetMacModule) = &kWidgetModule; diff --git a/widget/nsContentProcessWidgetFactory.cpp b/widget/nsContentProcessWidgetFactory.cpp index 32fa1b03e9e1..70d91f1f1d35 100644 --- a/widget/nsContentProcessWidgetFactory.cpp +++ b/widget/nsContentProcessWidgetFactory.cpp @@ -61,7 +61,5 @@ static const mozilla::Module::ContractIDEntry kWidgetContracts[] = { Module::CONTENT_PROCESS_ONLY}, {nullptr}}; -static const mozilla::Module kWidgetModule = {mozilla::Module::kVersion, - kWidgetCIDs, kWidgetContracts}; - -NSMODULE_DEFN(nsContentProcessWidgetModule) = &kWidgetModule; +extern const mozilla::Module kContentProcessWidgetModule = { + mozilla::Module::kVersion, kWidgetCIDs, kWidgetContracts}; diff --git a/widget/uikit/nsWidgetFactory.mm b/widget/uikit/nsWidgetFactory.mm index 3a7a35ba34be..328e153f4575 100644 --- a/widget/uikit/nsWidgetFactory.mm +++ b/widget/uikit/nsWidgetFactory.mm @@ -46,8 +46,6 @@ static void nsWidgetUIKitModuleDtor() { nsAppShellShutdown(); } -static const mozilla::Module kWidgetModule = { +extern const mozilla::Module kWidgetModule = { mozilla::Module::kVersion, kWidgetCIDs, kWidgetContracts, nullptr, nullptr, nsAppShellInit, nsWidgetUIKitModuleDtor}; - -NSMODULE_DEFN(nsWidgetUIKitModule) = &kWidgetModule; diff --git a/xpcom/build/XPCOMInit.cpp b/xpcom/build/XPCOMInit.cpp index 4cf80a3c17c5..b45b270b3de4 100644 --- a/xpcom/build/XPCOMInit.cpp +++ b/xpcom/build/XPCOMInit.cpp @@ -175,26 +175,6 @@ const mozilla::Module kXPCOMModule = { nullptr, Module::ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS}; -// FIXME: Dummy modules to avoid Windows PGO bustage when we have too few -// modules registered. -static const mozilla::Module kDummy1 = {mozilla::Module::kVersion}; -static const mozilla::Module kDummy2 = {mozilla::Module::kVersion}; -static const mozilla::Module kDummy3 = {mozilla::Module::kVersion}; -static const mozilla::Module kDummy4 = {mozilla::Module::kVersion}; -static const mozilla::Module kDummy5 = {mozilla::Module::kVersion}; -static const mozilla::Module kDummy6 = {mozilla::Module::kVersion}; -static const mozilla::Module kDummy7 = {mozilla::Module::kVersion}; -static const mozilla::Module kDummy8 = {mozilla::Module::kVersion}; - -NSMODULE_DEFN(Dummy1) = &kDummy1; -NSMODULE_DEFN(Dummy2) = &kDummy2; -NSMODULE_DEFN(Dummy3) = &kDummy3; -NSMODULE_DEFN(Dummy4) = &kDummy4; -NSMODULE_DEFN(Dummy5) = &kDummy5; -NSMODULE_DEFN(Dummy6) = &kDummy6; -NSMODULE_DEFN(Dummy7) = &kDummy7; -NSMODULE_DEFN(Dummy8) = &kDummy8; - // gDebug will be freed during shutdown. static nsIDebug2* gDebug = nullptr; diff --git a/xpcom/components/Module.h b/xpcom/components/Module.h index 2fd4c1979c50..3fa8277ca227 100644 --- a/xpcom/components/Module.h +++ b/xpcom/components/Module.h @@ -11,7 +11,6 @@ #include "nsID.h" #include "nsIFactory.h" #include "nsCOMPtr.h" // for already_AddRefed -#include "mozilla/Attributes.h" namespace mozilla { @@ -137,39 +136,4 @@ struct Module { } // namespace mozilla -#if defined(MOZILLA_INTERNAL_API) -# define NSMODULE_NAME(_name) _name##_NSModule -# if defined(_MSC_VER) || (defined(__clang__) && defined(__MINGW32__)) -# pragma section(".kPStaticModules$M", read) -# pragma comment(linker, "/merge:.kPStaticModules=.rdata") -# define NSMODULE_SECTION \ - __declspec(allocate(".kPStaticModules$M"), dllexport) -# elif defined(__GNUC__) -# if defined(__ELF__) -# define NSMODULE_SECTION \ - __attribute__((section("kPStaticModules"), visibility("default"))) -# elif defined(__MACH__) -# define NSMODULE_SECTION \ - __attribute__( \ - (section("__DATA, .kPStaticModules"), visibility("default"))) -# elif defined(_WIN32) -# define NSMODULE_SECTION \ - __attribute__((section("kPStaticModules"), dllexport)) -# endif -# endif -# if !defined(NSMODULE_SECTION) -# error Do not know how to define sections. -# endif -# if defined(MOZ_HAVE_ASAN_BLACKLIST) -# define NSMODULE_ASAN_BLACKLIST __attribute__((no_sanitize_address)) -# else -# define NSMODULE_ASAN_BLACKLIST -# endif -# define NSMODULE_DEFN(_name) \ - extern NSMODULE_SECTION NSMODULE_ASAN_BLACKLIST \ - mozilla::Module const* const NSMODULE_NAME(_name) -#else -# error Building binary XPCOM components is not supported anymore. -#endif - #endif // mozilla_Module_h diff --git a/xpcom/components/moz.build b/xpcom/components/moz.build index 4b76cc89fd26..f9a536cf48de 100644 --- a/xpcom/components/moz.build +++ b/xpcom/components/moz.build @@ -76,4 +76,7 @@ LOCAL_INCLUDES += [ if 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']: CXXFLAGS += CONFIG['TK_CFLAGS'] +if CONFIG['MOZ_LAYOUT_DEBUGGER']: + DEFINES['MOZ_LAYOUT_DEBUGGER'] = True + include('/ipc/chromium/chromium-config.mozbuild') diff --git a/xpcom/components/nsComponentManager.cpp b/xpcom/components/nsComponentManager.cpp index a4a4f02347d2..308637d4e9cd 100644 --- a/xpcom/components/nsComponentManager.cpp +++ b/xpcom/components/nsComponentManager.cpp @@ -346,87 +346,48 @@ nsComponentManagerImpl::nsComponentManagerImpl() mLock("nsComponentManagerImpl.mLock"), mStatus(NOT_INITIALIZED) {} -static nsTArray* sExtraStaticModules; - -/* NSMODULE_DEFN places NSModules in specific sections, as per Module.h. - * The linker will group them all together, and we use tricks below to - * find the start and end of the grouped list of NSModules. - * - * On Windows, all the symbols in the .kPStaticModules* sections are - * grouped together, by lexical order of the section names. The NSModules - * themselves are in .kPStaticModules$M. We use the section name - * .kPStaticModules$A to add an empty entry that will be the first, - * and the section name .kPStaticModules$Z for another empty entry that - * will be the last. We make both null pointers, and skip them in the - * AllStaticModules range-iterator. - * - * On ELF (Linux, BSDs, ...), as well as Mingw builds, the linker itself - * provides symbols for the beginning and end of the consolidated section, - * but it only does so for sections that can be represented as C identifiers, - * so the section is named `kPStaticModules` rather than `.kPStaticModules`. - * - * We also use a linker script with BFD ld so that the sections end up - * folded into the .data.rel.ro section, but that actually breaks the above - * described behavior, so the linker script contains an additional trick - * to still provide the __start and __stop symbols (the linker script - * doesn't work with gold or lld). - * - * On Darwin, a similar setup is available through the use of some - * synthesized symbols (section$...). - * - * On all platforms, the __stop_kPStaticModules symbol is past all NSModule - * pointers. - * On Windows, the __start_kPStaticModules symbol points to an empty pointer - * preceding the first NSModule pointer. On other platforms, it points to the - * first NSModule pointer. - */ - -// Dummy class to define a range-iterator for the static modules. -class AllStaticModules {}; - -#if defined(_MSC_VER) || (defined(__clang__) && defined(__MINGW32__)) - -# pragma section(".kPStaticModules$A", read) -NSMODULE_ASAN_BLACKLIST __declspec(allocate(".kPStaticModules$A"), - dllexport) extern mozilla::Module - const* const __start_kPStaticModules = nullptr; - -mozilla::Module const* const* begin(AllStaticModules& _) { - return &__start_kPStaticModules + 1; +extern const mozilla::Module kNeckoModule; +extern const mozilla::Module kParserModule; +#if defined(XP_WIN) || defined(MOZ_WIDGET_COCOA) || defined(MOZ_WIDGET_ANDROID) +extern const mozilla::Module kSpeechSynthModule; +#endif +extern const mozilla::Module kPowerManagerModule; +extern const mozilla::Module kContentProcessWidgetModule; +#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_COCOA) || defined(MOZ_WIDGET_UIKIT) +extern const mozilla::Module kWidgetModule; +#endif +extern const mozilla::Module kLayoutModule; +namespace mozilla { +extern const mozilla::Module kLocalCertServiceModule; } - -# pragma section(".kPStaticModules$Z", read) -NSMODULE_ASAN_BLACKLIST __declspec(allocate(".kPStaticModules$Z"), - dllexport) extern mozilla::Module - const* const __stop_kPStaticModules = nullptr; - -#else - -# if defined(__ELF__) || (defined(_WIN32) && defined(__GNUC__)) - -extern "C" mozilla::Module const* const __start_kPStaticModules; -extern "C" mozilla::Module const* const __stop_kPStaticModules; - -# elif defined(__MACH__) - -extern mozilla::Module const* const __start_kPStaticModules __asm( - "section$start$__DATA$.kPStaticModules"); -extern mozilla::Module const* const __stop_kPStaticModules __asm( - "section$end$__DATA$.kPStaticModules"); - -# else -# error Do not know how to find NSModules. -# endif - -static mozilla::Module const* const* begin(AllStaticModules& _) { - return &__start_kPStaticModules; +extern const mozilla::Module kKeyValueModule; +extern const mozilla::Module kXREModule; +extern const mozilla::Module kEmbeddingModule; +#if defined(XP_WIN) || defined(MOZ_WIDGET_COCOA) || defined(MOZ_WIDGET_ANDROID) +extern const mozilla::Module kSysProxyModule; +#endif +#if defined(XP_WIN) +namespace mozilla { +namespace toolkit { +namespace system { +namespace windowsDHCPClient { +extern const mozilla::Module kSysDHCPClientModule; } - +} // namespace system +} // namespace toolkit +} // namespace mozilla +#endif +#if defined(MOZ_WIDGET_ANDROID) +extern const mozilla::Module kBrowserModule; +#endif +#if defined(MOZ_LAYOUT_DEBUGGER) && !defined(MOZ_WIDGET_ANDROID) +extern const mozilla::Module kLayoutDebugModule; +#endif +#if defined(MOZ_CODE_COVERAGE) +extern const mozilla::Module kCodeCoverageModule; #endif -static mozilla::Module const* const* end(AllStaticModules& _) { - return &__stop_kPStaticModules; -} +static nsTArray* sExtraStaticModules; /* static */ void nsComponentManagerImpl::InitializeStaticModules() { @@ -486,13 +447,36 @@ nsresult nsComponentManagerImpl::Init() { nsCategoryManager::GetSingleton()->SuppressNotifications(true); RegisterModule(&kXPCOMModule); - - for (auto module : AllStaticModules()) { - if (module) { // On local Windows builds, the list may contain null - // pointers from padding. - RegisterModule(module); - } - } + RegisterModule(&kNeckoModule); + RegisterModule(&kParserModule); +#if defined(XP_WIN) || defined(MOZ_WIDGET_COCOA) || defined(MOZ_WIDGET_ANDROID) + RegisterModule(&kSpeechSynthModule); +#endif + RegisterModule(&kPowerManagerModule); + RegisterModule(&kContentProcessWidgetModule); +#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_COCOA) || defined(MOZ_WIDGET_UIKIT) + RegisterModule(&kWidgetModule); +#endif + RegisterModule(&kLayoutModule); + RegisterModule(&mozilla::kLocalCertServiceModule); + RegisterModule(&kKeyValueModule); + RegisterModule(&kXREModule); + RegisterModule(&kEmbeddingModule); +#if defined(XP_WIN) || defined(MOZ_WIDGET_COCOA) || defined(MOZ_WIDGET_ANDROID) + RegisterModule(&kSysProxyModule); +#endif +#if defined(XP_WIN) + RegisterModule(&mozilla::toolkit::system::windowsDHCPClient::kSysDHCPClientModule); +#endif +#if defined(MOZ_WIDGET_ANDROID) + RegisterModule(&kBrowserModule); +#endif +#if defined(MOZ_LAYOUT_DEBUGGER) && !defined(MOZ_WIDGET_ANDROID) + RegisterModule(&kLayoutDebugModule); +#endif +#if defined(MOZ_CODE_COVERAGE) + RegisterModule(&kCodeCoverageModule); +#endif for (uint32_t i = 0; i < sExtraStaticModules->Length(); ++i) { RegisterModule((*sExtraStaticModules)[i]);