mirror of
https://github.com/reactos/reactos.git
synced 2024-08-28 22:28:36 +00:00
Implement linkerscript element
svn path=/trunk/; revision=18758
This commit is contained in:
parent
dd10647983
commit
b995bcf1bd
|
@ -1417,12 +1417,18 @@ MingwModuleHandler::GenerateLinkerCommand (
|
||||||
{
|
{
|
||||||
string target ( GetTargetMacro ( module ) );
|
string target ( GetTargetMacro ( module ) );
|
||||||
string target_folder ( GetDirectory ( GetTargetFilename ( module, NULL ) ) );
|
string target_folder ( GetDirectory ( GetTargetFilename ( module, NULL ) ) );
|
||||||
string def_file = GetDefinitionFilename ();
|
string definitionFilename = GetDefinitionFilename ();
|
||||||
|
|
||||||
|
string linkerScriptArgument;
|
||||||
|
if ( module.linkerScript != NULL )
|
||||||
|
linkerScriptArgument = ssprintf ( "-Wl,-T,%s", module.linkerScript->directory.c_str () );
|
||||||
|
else
|
||||||
|
linkerScriptArgument = "";
|
||||||
|
|
||||||
fprintf ( fMakefile,
|
fprintf ( fMakefile,
|
||||||
"%s: %s %s $(RSYM_TARGET) $(PEFIXUP_TARGET) | %s\n",
|
"%s: %s %s $(RSYM_TARGET) $(PEFIXUP_TARGET) | %s\n",
|
||||||
target.c_str (),
|
target.c_str (),
|
||||||
def_file.c_str (),
|
definitionFilename.c_str (),
|
||||||
dependencies.c_str (),
|
dependencies.c_str (),
|
||||||
target_folder.c_str () );
|
target_folder.c_str () );
|
||||||
fprintf ( fMakefile, "\t$(ECHO_LD)\n" );
|
fprintf ( fMakefile, "\t$(ECHO_LD)\n" );
|
||||||
|
@ -1432,19 +1438,20 @@ MingwModuleHandler::GenerateLinkerCommand (
|
||||||
{
|
{
|
||||||
string temp_exp = ros_temp + module.name + ".temp.exp";
|
string temp_exp = ros_temp + module.name + ".temp.exp";
|
||||||
CLEAN_FILE ( temp_exp );
|
CLEAN_FILE ( temp_exp );
|
||||||
|
|
||||||
string killAt = module.mangledSymbols ? "" : "--kill-at";
|
string killAt = module.mangledSymbols ? "" : "--kill-at";
|
||||||
fprintf ( fMakefile,
|
fprintf ( fMakefile,
|
||||||
"\t${dlltool} --dllname %s --def %s --output-exp %s %s\n",
|
"\t${dlltool} --dllname %s --def %s --output-exp %s %s\n",
|
||||||
targetName.c_str (),
|
targetName.c_str (),
|
||||||
def_file.c_str (),
|
definitionFilename.c_str (),
|
||||||
temp_exp.c_str (),
|
temp_exp.c_str (),
|
||||||
killAt.c_str () );
|
killAt.c_str () );
|
||||||
|
|
||||||
fprintf ( fMakefile,
|
fprintf ( fMakefile,
|
||||||
"\t%s %s %s -o %s %s %s %s\n",
|
"\t%s %s %s -o %s %s %s %s %s\n",
|
||||||
linker.c_str (),
|
linker.c_str (),
|
||||||
linkerParameters.c_str (),
|
linkerParameters.c_str (),
|
||||||
|
linkerScriptArgument.c_str (),
|
||||||
temp_exp.c_str (),
|
temp_exp.c_str (),
|
||||||
target.c_str (),
|
target.c_str (),
|
||||||
objectsMacro.c_str (),
|
objectsMacro.c_str (),
|
||||||
|
@ -1463,9 +1470,10 @@ MingwModuleHandler::GenerateLinkerCommand (
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf ( fMakefile,
|
fprintf ( fMakefile,
|
||||||
"\t%s %s -o %s %s %s %s\n",
|
"\t%s %s -o %s %s %s %s %s\n",
|
||||||
linker.c_str (),
|
linker.c_str (),
|
||||||
linkerParameters.c_str (),
|
linkerParameters.c_str (),
|
||||||
|
linkerScriptArgument.c_str (),
|
||||||
target.c_str (),
|
target.c_str (),
|
||||||
objectsMacro.c_str (),
|
objectsMacro.c_str (),
|
||||||
libsMacro.c_str (),
|
libsMacro.c_str (),
|
||||||
|
|
|
@ -129,7 +129,7 @@ Value:
|
||||||
None.
|
None.
|
||||||
|
|
||||||
Elements:
|
Elements:
|
||||||
bootstrap, component, define, dependency, directory, file, if, importlibrary, include, invoke, library, property.
|
bootstrap, component, define, dependency, directory, file, if, importlibrary, include, invoke, library, linkerscript, property.
|
||||||
|
|
||||||
|
|
||||||
Module types
|
Module types
|
||||||
|
@ -466,6 +466,23 @@ Elements:
|
||||||
None.
|
None.
|
||||||
|
|
||||||
|
|
||||||
|
Linkerscript
|
||||||
|
------------
|
||||||
|
A linkerscript element specifies the filename of a binutils linker script.
|
||||||
|
|
||||||
|
Syntax:
|
||||||
|
<linkerscript base="mymodule">MyLinkerScript</linkerscript>
|
||||||
|
|
||||||
|
Attributes:
|
||||||
|
base - Module which the value of this element is relative to. This attribute is optional. If left out, the linker script is relative to the position of the top-level xml build file.
|
||||||
|
|
||||||
|
Value:
|
||||||
|
Relative linker script filename.
|
||||||
|
|
||||||
|
Elements:
|
||||||
|
None.
|
||||||
|
|
||||||
|
|
||||||
Property
|
Property
|
||||||
--------
|
--------
|
||||||
A property element specifies the name and value of a property that can be used for conditional processing of the xml build file.
|
A property element specifies the name and value of a property that can be used for conditional processing of the xml build file.
|
||||||
|
|
73
reactos/tools/rbuild/linkerscript.cpp
Normal file
73
reactos/tools/rbuild/linkerscript.cpp
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Casper S. Hornstrup
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
#include "pch.h"
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#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 ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
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->GetBasePath ();
|
||||||
|
referenceResolved = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( !referenceResolved )
|
||||||
|
throw InvalidBuildFileException (
|
||||||
|
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 );
|
||||||
|
}
|
|
@ -211,6 +211,7 @@ Module::Module ( const Project& project,
|
||||||
node (moduleNode),
|
node (moduleNode),
|
||||||
importLibrary (NULL),
|
importLibrary (NULL),
|
||||||
bootstrap (NULL),
|
bootstrap (NULL),
|
||||||
|
linkerScript (NULL),
|
||||||
pch (NULL),
|
pch (NULL),
|
||||||
cplusplus (false),
|
cplusplus (false),
|
||||||
host (HostDefault)
|
host (HostDefault)
|
||||||
|
@ -372,6 +373,8 @@ Module::~Module ()
|
||||||
delete linkerFlags[i];
|
delete linkerFlags[i];
|
||||||
for ( i = 0; i < stubbedComponents.size(); i++ )
|
for ( i = 0; i < stubbedComponents.size(); i++ )
|
||||||
delete stubbedComponents[i];
|
delete stubbedComponents[i];
|
||||||
|
if ( linkerScript )
|
||||||
|
delete linkerScript;
|
||||||
if ( pch )
|
if ( pch )
|
||||||
delete pch;
|
delete pch;
|
||||||
}
|
}
|
||||||
|
@ -409,6 +412,8 @@ Module::ProcessXML()
|
||||||
for ( i = 0; i < stubbedComponents.size(); i++ )
|
for ( i = 0; i < stubbedComponents.size(); i++ )
|
||||||
stubbedComponents[i]->ProcessXML();
|
stubbedComponents[i]->ProcessXML();
|
||||||
non_if_data.ProcessXML();
|
non_if_data.ProcessXML();
|
||||||
|
if ( linkerScript )
|
||||||
|
linkerScript->ProcessXML();
|
||||||
if ( pch )
|
if ( pch )
|
||||||
pch->ProcessXML();
|
pch->ProcessXML();
|
||||||
}
|
}
|
||||||
|
@ -556,6 +561,15 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
||||||
linkerFlags.push_back ( new LinkerFlag ( project, this, e ) );
|
linkerFlags.push_back ( new LinkerFlag ( project, this, e ) );
|
||||||
subs_invalid = true;
|
subs_invalid = true;
|
||||||
}
|
}
|
||||||
|
else if ( e.name == "linkerscript" )
|
||||||
|
{
|
||||||
|
if ( linkerScript )
|
||||||
|
throw InvalidBuildFileException (
|
||||||
|
e.location,
|
||||||
|
"Only one <linkerscript> is valid per module" );
|
||||||
|
linkerScript = new LinkerScript ( project, this, e );
|
||||||
|
subs_invalid = true;
|
||||||
|
}
|
||||||
else if ( e.name == "component" )
|
else if ( e.name == "component" )
|
||||||
{
|
{
|
||||||
stubbedComponents.push_back ( new StubbedComponent ( this, e ) );
|
stubbedComponents.push_back ( new StubbedComponent ( this, e ) );
|
||||||
|
|
|
@ -73,6 +73,7 @@ class ImportLibrary;
|
||||||
class If;
|
class If;
|
||||||
class CompilerFlag;
|
class CompilerFlag;
|
||||||
class LinkerFlag;
|
class LinkerFlag;
|
||||||
|
class LinkerScript;
|
||||||
class Property;
|
class Property;
|
||||||
class TestSupportCode;
|
class TestSupportCode;
|
||||||
class WineResource;
|
class WineResource;
|
||||||
|
@ -230,6 +231,7 @@ public:
|
||||||
std::vector<CompilerFlag*> compilerFlags;
|
std::vector<CompilerFlag*> compilerFlags;
|
||||||
std::vector<LinkerFlag*> linkerFlags;
|
std::vector<LinkerFlag*> linkerFlags;
|
||||||
std::vector<StubbedComponent*> stubbedComponents;
|
std::vector<StubbedComponent*> stubbedComponents;
|
||||||
|
LinkerScript* linkerScript;
|
||||||
PchFile* pch;
|
PchFile* pch;
|
||||||
bool cplusplus;
|
bool cplusplus;
|
||||||
std::string prefix;
|
std::string prefix;
|
||||||
|
@ -476,6 +478,24 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
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 );
|
||||||
|
~LinkerScript ();
|
||||||
|
void ProcessXML();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class Property
|
class Property
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -163,6 +163,7 @@ RBUILD_COMMON_SOURCES = \
|
||||||
include.cpp \
|
include.cpp \
|
||||||
installfile.cpp \
|
installfile.cpp \
|
||||||
linkerflag.cpp \
|
linkerflag.cpp \
|
||||||
|
linkerscript.cpp \
|
||||||
module.cpp \
|
module.cpp \
|
||||||
project.cpp \
|
project.cpp \
|
||||||
ssprintf.cpp \
|
ssprintf.cpp \
|
||||||
|
@ -299,6 +300,10 @@ $(RBUILD_INT_)linkerflag.o: $(RBUILD_BASE_)linkerflag.cpp $(RBUILD_HEADERS) | $(
|
||||||
$(ECHO_CC)
|
$(ECHO_CC)
|
||||||
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
|
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
$(RBUILD_INT_)linkerscript.o: $(RBUILD_BASE_)linkerscript.cpp $(RBUILD_HEADERS) | $(RBUILD_INT)
|
||||||
|
$(ECHO_CC)
|
||||||
|
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
|
||||||
|
|
||||||
$(RBUILD_INT_)module.o: $(RBUILD_BASE_)module.cpp $(RBUILD_HEADERS) | $(RBUILD_INT)
|
$(RBUILD_INT_)module.o: $(RBUILD_BASE_)module.cpp $(RBUILD_HEADERS) | $(RBUILD_INT)
|
||||||
$(ECHO_CC)
|
$(ECHO_CC)
|
||||||
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
|
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
|
||||||
|
|
Loading…
Reference in a new issue