Sync tools to 45592
[reactos.git] / reactos / tools / rbuild / backend / mingw / modulehandler.cpp
index 8bff6ea..254ade6 100644 (file)
@@ -1423,13 +1423,13 @@ void
 MingwModuleHandler::GenerateLinkerCommand () const
 {
        string definitionFilename;
-       
+
        const FileLocation *DefinitionFilename = GetDefinitionFilename ();
 
        if ( DefinitionFilename ) {
                definitionFilename = backend->GetFullName (*DefinitionFilename);
                delete DefinitionFilename;
-       }
+}
 
        string linkerScriptArgument;
        if ( module.linkerScript != NULL ) {
@@ -1446,7 +1446,7 @@ MingwModuleHandler::GenerateLinkerCommand () const
        if ( ModuleHandlerInformations[module.type].DefaultHost == HostFalse ) {
                if ( module.cplusplus ) {
                        switch ( module.type )
-                       {
+       {
                        case Win32DLL:
                        case Win32OCX:
                        case Win32CUI:
@@ -1458,7 +1458,7 @@ MingwModuleHandler::GenerateLinkerCommand () const
                        default:
                                extraLibraries = "$$(PROJECT_CCLIBS)";
                                break;
-                       }
+       }
                } else
                        extraLibraries = "$$(PROJECT_CCLIBS)";
        }
@@ -1466,16 +1466,16 @@ MingwModuleHandler::GenerateLinkerCommand () const
        delete PassThruCacheDirectory ( new FileLocation ( module.output->directory, module.output->relative_path, "" ) );
        delete PassThruCacheDirectory ( new FileLocation ( IntermediateDirectory, module.output->relative_path, "" ) );
 
-       fprintf ( fMakefile,
+               fprintf ( fMakefile,
                          "$(eval $(call RBUILD_LINK_RULE,%s,%s,%s,%s,%s,%s,%s))\n",
                          module.name.c_str(),
                          definitionFilename.c_str(),
                          module.xmlbuildFile.c_str(),
-                         linkerScriptArgument.c_str(),
+                         linkerScriptArgument.c_str (),
                          extraLibraries.c_str(),
                          module.GetEntryPoint().c_str(),
                          module.baseaddress.c_str() );
-}
+       }
 
 void
 MingwModuleHandler::GenerateObjectFileTargets ( const IfableData& data )
@@ -1782,6 +1782,12 @@ MingwModuleHandler::GenerateOtherMacros ()
                &module.linkerFlags,
                used_defs );
 
+       /* LD automatically exports all symbols by default if -shared is specified. Prevent it from doing
+          this by adding the option -exclude-all-symbols (available since Binutils 20091017). */
+       // FIXME: Should only be applied for -shared modules, when there's a smart way to check for them.
+       if ( ModuleHandlerInformations[module.type].DefaultHost == HostFalse && !module.importLibrary )
+               fprintf ( fMakefile, "%s_LDFLAGS+=$(LDFLAG_EXCLUDE_ALL_SYMBOLS)\n", module.name.c_str() );
+       
        fprintf ( fMakefile, "\n\n" );
 }
 
@@ -1816,7 +1822,7 @@ MingwModuleHandler::GenerateRules ()
                const FileLocation* ar_target = GenerateArchiveTarget ();
 
                if ( ar_target )
-                       delete ar_target;
+               delete ar_target;
        }
 
 
@@ -2189,9 +2195,9 @@ MingwKernelModuleHandler::Process ()
 void
 MingwKernelModuleHandler::GenerateKernelModuleTarget ()
 {
-       GenerateRules ();
+               GenerateRules ();
        GenerateLinkerCommand ();
-}
+       }
 
 
 MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler (
@@ -2218,9 +2224,9 @@ MingwKernelModeDLLModuleHandler::Process ()
 void
 MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ()
 {
-       GenerateRules ();
+               GenerateRules ();
        GenerateLinkerCommand ();
-}
+       }
 
 
 MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler (
@@ -2246,9 +2252,9 @@ MingwNativeDLLModuleHandler::Process ()
 void
 MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ()
 {
-       GenerateRules ();
+               GenerateRules ();
        GenerateLinkerCommand ();
-}
+       }
 
 
 MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler (
@@ -2274,9 +2280,9 @@ MingwNativeCUIModuleHandler::Process ()
 void
 MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ()
 {
-       GenerateRules ();
+               GenerateRules ();
        GenerateLinkerCommand ();
-}
+       }
 
 
 MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler (
@@ -2343,9 +2349,9 @@ MingwWin32DLLModuleHandler::Process ()
 void
 MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ()
 {
-       GenerateRules ();
+               GenerateRules ();
        GenerateLinkerCommand ();
-}
+       }
 
 
 void
@@ -2363,9 +2369,9 @@ MingwWin32OCXModuleHandler::Process ()
 void
 MingwWin32OCXModuleHandler::GenerateWin32OCXModuleTarget ()
 {
-       GenerateRules ();
+               GenerateRules ();
        GenerateLinkerCommand ();
-}
+       }
 
 
 MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler (
@@ -2390,9 +2396,9 @@ MingwWin32CUIModuleHandler::Process ()
 void
 MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ()
 {
-       GenerateRules ();
+               GenerateRules ();
        GenerateLinkerCommand ();
-}
+       }
 
 
 MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler (
@@ -2417,9 +2423,9 @@ MingwWin32GUIModuleHandler::Process ()
 void
 MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ()
 {
-       GenerateRules ();
+               GenerateRules ();
        GenerateLinkerCommand ();
-}
+       }
 
 
 MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler (
@@ -2740,8 +2746,8 @@ MingwIsoModuleHandler::GenerateIsoModuleTarget ()
        const FileLocation *isoboot = bootModule->output;
 
        // prepare reactos.dff and reactos.inf
-       FileLocation reactosDff ( SourceDirectory,
-                                 "boot" + sSep + "bootdata" + sSep + "packages",
+       FileLocation reactosDff ( IntermediateDirectory,
+                                 "",
                                  "reactos.dff" );
        FileLocation reactosInf ( bootcdReactos.directory,
                                  bootcdReactos.relative_path,
@@ -3018,9 +3024,9 @@ MingwTestModuleHandler::GetModuleSpecificCompilationUnits ( vector<CompilationUn
 void
 MingwTestModuleHandler::GenerateTestModuleTarget ()
 {
-       GenerateRules ();
+               GenerateRules ();
        GenerateLinkerCommand ();
-}
+       }
 
 
 MingwAliasModuleHandler::MingwAliasModuleHandler (