Author: hpoussin Date: Wed Oct 10 12:44:45 2007 New Revision: 29476
URL: http://svn.reactos.org/svn/reactos?rev=29476&view=rev Log: Cleanup the LinkerScript class and use it Patch by Marc Piulachs, marc dot puilachs at codexchange dot net See issue #2721 for more details.
Modified: trunk/reactos/ntoskrnl/ntoskrnl.rbuild trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp trunk/reactos/tools/rbuild/linkerscript.cpp trunk/reactos/tools/rbuild/module.cpp trunk/reactos/tools/rbuild/rbuild.h
Modified: trunk/reactos/ntoskrnl/ntoskrnl.rbuild URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ntoskrnl.rbuild?re... ============================================================================== --- trunk/reactos/ntoskrnl/ntoskrnl.rbuild (original) +++ trunk/reactos/ntoskrnl/ntoskrnl.rbuild Wed Oct 10 12:44:45 2007 @@ -422,4 +422,5 @@ <linkerflag>-nostartfiles</linkerflag> <linkerflag>-nostdlib</linkerflag> <linkerflag>-lgcc</linkerflag> + <linkerscript>ntoskrnl_$(ARCH).lnk</linkerscript> </module>
Modified: trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/mingw/... ============================================================================== --- trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp (original) +++ trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp Wed Oct 10 12:44:45 2007 @@ -1598,7 +1598,7 @@
string linkerScriptArgument; if ( module.linkerScript != NULL ) - linkerScriptArgument = ssprintf ( "-Wl,-T,%s", module.linkerScript->directory.c_str () ); + linkerScriptArgument = ssprintf ( "-Wl,-T,%s", backend->GetFullName ( module.linkerScript->file ).c_str () ); else linkerScriptArgument = "";
@@ -2469,9 +2469,7 @@
string dependencies = linkDepsMacro + " " + objectsMacro;
- string linkerParameters = ssprintf ( "-Wl,-T,%s%cntoskrnl_$(ARCH).lnk -Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s", - module.output->relative_path.c_str (), - cSep, + string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s", module.GetEntryPoint(true).c_str (), module.baseaddress.c_str () ); GenerateLinkerCommand ( dependencies,
Modified: trunk/reactos/tools/rbuild/linkerscript.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/linkerscript.c... ============================================================================== --- trunk/reactos/tools/rbuild/linkerscript.cpp (original) +++ trunk/reactos/tools/rbuild/linkerscript.cpp Wed Oct 10 12:44:45 2007 @@ -20,16 +20,10 @@
#include "rbuild.h"
-using std::string; -using std::vector; - -LinkerScript::LinkerScript ( const Project& project, - const Module* module, - const XMLElement& node ) - : project ( project ), - module ( module ), - node ( node ), - baseModule ( NULL ) +LinkerScript::LinkerScript ( const XMLElement& node_, + const Module& module_, + const FileLocation& file_ ) + : node(node_), module(module_), file(file_) { }
@@ -40,36 +34,4 @@ void LinkerScript::ProcessXML() { - const XMLAttribute* att; - att = node.GetAttribute ( "base", - false ); - if ( att ) - { - bool referenceResolved = false; - if ( att->value == project.name ) - { - basePath = "."; - referenceResolved = true; - } - else - { - const Module* base = project.LocateModule ( att->value ); - if ( base != NULL ) - { - baseModule = base; - basePath = base->output->relative_path; - referenceResolved = true; - } - } - if ( !referenceResolved ) - { - throw XMLInvalidBuildFileException ( - node.location, - "<linkerscript> attribute 'base' references non-existant project or module '%s'", - att->value.c_str() ); - } - directory = NormalizeFilename ( basePath + sSep + node.value ); - } - else - directory = NormalizeFilename ( node.value ); }
Modified: trunk/reactos/tools/rbuild/module.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/module.cpp?rev... ============================================================================== --- trunk/reactos/tools/rbuild/module.cpp (original) +++ trunk/reactos/tools/rbuild/module.cpp Wed Oct 10 12:44:45 2007 @@ -748,13 +748,31 @@ } else if ( e.name == "linkerscript" ) { + if ( parseContext.ifData ) + { + throw XMLInvalidBuildFileException ( + e.location, + "<linkerscript> is not a valid sub-element of <if>" ); + } if ( linkerScript ) { throw XMLInvalidBuildFileException ( e.location, "Only one <linkerscript> is valid per module" ); } - linkerScript = new LinkerScript ( project, this, e ); + size_t pos = e.value.find_last_of ( "/\" ); + if ( pos == string::npos ) + { + linkerScript = new LinkerScript ( + e, *this, FileLocation ( SourceDirectory, relative_path, e.value, &e ) ); + } + else + { + string dir = e.value.substr ( 0, pos ); + string name = e.value.substr ( pos + 1); + linkerScript = new LinkerScript ( + e, *this, FileLocation ( SourceDirectory, relative_path + sSep + dir, name, &e ) ); + } subs_invalid = true; } else if ( e.name == "component" )
Modified: trunk/reactos/tools/rbuild/rbuild.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/rbuild.h?rev=2... ============================================================================== --- trunk/reactos/tools/rbuild/rbuild.h (original) +++ trunk/reactos/tools/rbuild/rbuild.h Wed Oct 10 12:44:45 2007 @@ -625,16 +625,13 @@ class LinkerScript { public: - const Project& project; - const Module* module; - const XMLElement& node; - const Module* baseModule; - std::string directory; - std::string basePath; - - LinkerScript ( const Project& project, - const Module* module, - const XMLElement& node ); + const XMLElement& node; + const Module& module; + FileLocation file; + + LinkerScript ( const XMLElement& node, + const Module& module, + const FileLocation& file ); ~LinkerScript (); void ProcessXML(); };