Support for non-standard module base addresses
[reactos.git] / reactos / tools / rbuild / backend / mingw / modulehandler.cpp
index a9dc3a1..54f25a6 100644 (file)
@@ -1340,9 +1340,10 @@ MingwKernelModuleHandler::GenerateKernelModuleTarget ( const Module& module )
        string base_tmp = ros_junk + module.name + ".base.tmp";\r
        string junk_tmp = ros_junk + module.name + ".junk.tmp";\r
        string temp_exp = ros_junk + module.name + ".temp.exp";\r
-       string gccOptions = ssprintf ("-Wl,-T,%s" SSEP "ntoskrnl.lnk -Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,0xC0000000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll",\r
+       string gccOptions = ssprintf ("-Wl,-T,%s" SSEP "ntoskrnl.lnk -Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll",\r
                                      module.GetBasePath ().c_str (),\r
-                                     module.entrypoint.c_str () );\r
+                                     module.entrypoint.c_str (),\r
+                                     module.baseaddress.c_str () );\r
 \r
        GenerateMacrosAndTargetsTarget ( module );\r
 \r
@@ -1466,8 +1467,9 @@ MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ( const Modul
                          archiveFilename.c_str (),\r
                          importLibraryDependencies.c_str () );\r
 \r
-               string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll",\r
-                                                    module.entrypoint.c_str () );\r
+               string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll",\r
+                                                    module.entrypoint.c_str (),\r
+                                                    module.baseaddress.c_str () );\r
                GenerateLinkerCommand ( module,\r
                                        "${gcc}",\r
                                        linkerParameters,\r
@@ -1523,8 +1525,9 @@ MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ( const
                          archiveFilename.c_str (),\r
                          importLibraryDependencies.c_str () );\r
 \r
-               string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll",\r
-                                                    module.entrypoint.c_str () );\r
+               string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll",\r
+                                                    module.entrypoint.c_str (),\r
+                                                    module.baseaddress.c_str () );\r
                GenerateLinkerCommand ( module,\r
                                        "${gcc}",\r
                                        linkerParameters,\r
@@ -1576,8 +1579,9 @@ MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ( const Module& modul
                          archiveFilename.c_str (),\r
                          importLibraryDependencies.c_str () );\r
 \r
-               string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib -mdll",\r
-                                                    module.entrypoint.c_str () );\r
+               string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib -mdll",\r
+                                                    module.entrypoint.c_str (),\r
+                                                    module.baseaddress.c_str () );\r
                GenerateLinkerCommand ( module,\r
                                        "${gcc}",\r
                                        linkerParameters,\r
@@ -1633,8 +1637,9 @@ MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ( const Module& modul
                          archiveFilename.c_str (),\r
                          importLibraryDependencies.c_str () );\r
 \r
-               string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib",\r
-                                                    module.entrypoint.c_str () );\r
+               string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib",\r
+                                                    module.entrypoint.c_str (),\r
+                                                    module.baseaddress.c_str () );\r
                GenerateLinkerCommand ( module,\r
                                        "${gcc}",\r
                                        linkerParameters,\r
@@ -1712,8 +1717,9 @@ MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ( const Module& module
                else\r
                        linker = "${gcc}";\r
 \r
-               string linkerParameters = ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -mdll",\r
-                                                   module.entrypoint.c_str () );\r
+               string linkerParameters = ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -mdll",\r
+                                                    module.entrypoint.c_str (),\r
+                                                    module.baseaddress.c_str () );\r
                GenerateLinkerCommand ( module,\r
                                        linker,\r
                                        linkerParameters,\r
@@ -1770,8 +1776,9 @@ MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ( const Module& module
                else\r
                        linker = "${gcc}";\r
 \r
-               string linkerParameters = ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,0x00400000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",\r
-                                                    module.entrypoint.c_str () );\r
+               string linkerParameters = ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",\r
+                                                    module.entrypoint.c_str (),\r
+                                                    module.baseaddress.c_str () );\r
                GenerateLinkerCommand ( module,\r
                                        linker,\r
                                        linkerParameters,\r
@@ -1828,8 +1835,9 @@ MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ( const Module& module
                else\r
                        linker = "${gcc}";\r
 \r
-               string linkerParameters = ssprintf ( "-Wl,--subsystem,windows -Wl,--entry,%s -Wl,--image-base,0x00400000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",\r
-                                                    module.entrypoint.c_str () );\r
+               string linkerParameters = ssprintf ( "-Wl,--subsystem,windows -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",\r
+                                                    module.entrypoint.c_str (),\r
+                                                    module.baseaddress.c_str () );\r
                GenerateLinkerCommand ( module,\r
                                        linker,\r
                                        linkerParameters,\r