Change entrypoint to be a get-style method of class Module, having a boolean param which define if the entrypoint is to be returned with or without the leading underscore. Internal entrypoint string holds entrypoint without leading underscore.

This makes both mingw and msvc backend happy about entry point names.

svn path=/trunk/; revision=22405
This commit is contained in:
Aleksey Bragin 2006-06-18 20:30:52 +00:00
parent 7985065a7a
commit 9b0d10bbbc
4 changed files with 33 additions and 21 deletions

View file

@ -2302,7 +2302,7 @@ MingwKernelModuleHandler::GenerateKernelModuleTarget ()
string linkerParameters = ssprintf ( "-Wl,-T,%s%cntoskrnl.lnk -Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -shared",
module.GetBasePath ().c_str (),
cSep,
module.entrypoint.c_str (),
module.GetEntryPoint(true).c_str (),
module.baseaddress.c_str () );
GenerateLinkerCommand ( dependencies,
"${gcc}",
@ -2389,7 +2389,7 @@ MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ()
string dependencies = linkDepsMacro + " " + objectsMacro;
string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -shared",
module.entrypoint.c_str (),
module.GetEntryPoint(true).c_str (),
module.baseaddress.c_str () );
GenerateLinkerCommand ( dependencies,
"${gcc}",
@ -2437,7 +2437,7 @@ MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ()
string dependencies = linkDepsMacro + " " + objectsMacro;
string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -shared",
module.entrypoint.c_str (),
module.GetEntryPoint(true).c_str (),
module.baseaddress.c_str () );
GenerateLinkerCommand ( dependencies,
"${gcc}",
@ -2484,7 +2484,7 @@ MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ()
string dependencies = linkDepsMacro + " " + objectsMacro;
string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib -shared",
module.entrypoint.c_str (),
module.GetEntryPoint(true).c_str (),
module.baseaddress.c_str () );
GenerateLinkerCommand ( dependencies,
"${gcc}",
@ -2531,7 +2531,7 @@ MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ()
string dependencies = linkDepsMacro + " " + objectsMacro;
string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib",
module.entrypoint.c_str (),
module.GetEntryPoint(true).c_str (),
module.baseaddress.c_str () );
GenerateLinkerCommand ( dependencies,
"${gcc}",
@ -2584,7 +2584,7 @@ MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ()
linker = "${gcc}";
string linkerParameters = ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -shared",
module.entrypoint.c_str (),
module.GetEntryPoint(true).c_str (),
module.baseaddress.c_str () );
GenerateLinkerCommand ( dependencies,
linker,
@ -2637,7 +2637,7 @@ MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ()
linker = "${gcc}";
string linkerParameters = ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
module.entrypoint.c_str (),
module.GetEntryPoint(true).c_str (),
module.baseaddress.c_str () );
GenerateLinkerCommand ( dependencies,
linker,
@ -2690,7 +2690,7 @@ MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ()
linker = "${gcc}";
string linkerParameters = ssprintf ( "-Wl,--subsystem,windows -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
module.entrypoint.c_str (),
module.GetEntryPoint(true).c_str (),
module.baseaddress.c_str () );
GenerateLinkerCommand ( dependencies,
linker,
@ -3255,7 +3255,7 @@ MingwTestModuleHandler::GenerateTestModuleTarget ()
linker = "${gcc}";
string linkerParameters = ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
module.entrypoint.c_str (),
module.GetEntryPoint(true).c_str (),
module.baseaddress.c_str () );
GenerateLinkerCommand ( dependencies,
linker,

View file

@ -393,7 +393,7 @@ MSVCBackend::_generate_vcproj ( const Module& module )
fprintf ( OUT, "\t\t\t\tGenerateManifest=\"FALSE\"\r\n" );
fprintf ( OUT, "\t\t\t\tSubSystem=\"%d\"\r\n", 3 );
fprintf ( OUT, "\t\t\t\tDriver=\"%d\"\r\n", 1 );
fprintf ( OUT, "\t\t\t\tEntryPointSymbol=\"%s\"\r\n", module.entrypoint == "" ? "DriverEntry" : module.entrypoint.c_str ());
fprintf ( OUT, "\t\t\t\tEntryPointSymbol=\"%s\"\r\n", module.GetEntryPoint(false) == "" ? "DriverEntry" : module.GetEntryPoint(false).c_str ());
fprintf ( OUT, "\t\t\t\tBaseAddress=\"%s\"\r\n", baseaddr == "" ? "0x10000" : baseaddr.c_str ());
}
else if ( exe )
@ -424,7 +424,7 @@ MSVCBackend::_generate_vcproj ( const Module& module )
}
else if ( dll )
{
fprintf ( OUT, "\t\t\t\tEntryPointSymbol=\"%s\"\r\n", module.entrypoint == "" ? "DllMain" : module.entrypoint.c_str ());
fprintf ( OUT, "\t\t\t\tEntryPointSymbol=\"%s\"\r\n", module.GetEntryPoint(false) == "" ? "DllMain" : module.GetEntryPoint(false).c_str ());
fprintf ( OUT, "\t\t\t\tBaseAddress=\"%s\"\r\n", baseaddr == "" ? "0x40000" : baseaddr.c_str ());
}
fprintf ( OUT, "\t\t\t\tTargetMachine=\"%d\"/>\r\n", 1 );

View file

@ -825,29 +825,29 @@ Module::GetDefaultModuleEntrypoint () const
switch ( type )
{
case Kernel:
return "_NtProcessStartup";
return "NtProcessStartup";
case KernelModeDLL:
case KernelModeDriver:
case ExportDriver:
return "_DriverEntry@8";
return "DriverEntry@8";
case NativeDLL:
return "_DllMainCRTStartup@12";
return "DllMainCRTStartup@12";
case NativeCUI:
return "_NtProcessStartup@4";
return "NtProcessStartup@4";
case Win32DLL:
return "_DllMain@12";
return "DllMain@12";
case Win32CUI:
case Test:
if ( isUnicode )
return "_wmainCRTStartup";
return "wmainCRTStartup";
else
return "_mainCRTStartup";
return "mainCRTStartup";
case Win32SCR:
case Win32GUI:
if ( isUnicode )
return "_wWinMainCRTStartup";
return "wWinMainCRTStartup";
else
return "_WinMainCRTStartup";
return "WinMainCRTStartup";
case BuildTool:
case StaticLibrary:
case ObjectLibrary:
@ -1038,6 +1038,17 @@ Module::GetInvocationTarget ( const int index ) const
index );
}
string
Module::GetEntryPoint(bool leadingUnderscore) const
{
string result = "";
if (leadingUnderscore)
result = "_";
result += entrypoint;
return result;
}
bool
Module::HasFileWithExtension (
const IfableData& data,

View file

@ -285,7 +285,6 @@ public:
std::string name;
std::string guid;
std::string extension;
std::string entrypoint;
std::string baseaddress;
std::string payload;
std::string path;
@ -328,6 +327,7 @@ public:
std::string GetPath () const; // "path/foo.exe"
std::string GetPathWithPrefix ( const std::string& prefix ) const; // "path/prefixfoo.exe"
std::string GetPathToBaseDir() const; // "../" offset to rootdirectory
std::string GetEntryPoint(bool leadingUnderscore) const;
void GetTargets ( string_list& ) const;
std::string GetInvocationTarget ( const int index ) const;
bool HasFileWithExtension ( const IfableData&, const std::string& extension ) const;
@ -339,6 +339,7 @@ private:
std::string GetDefaultModuleExtension () const;
std::string GetDefaultModuleEntrypoint () const;
std::string GetDefaultModuleBaseaddress () const;
std::string entrypoint;
void ProcessXMLSubElement ( const XMLElement& e,
const std::string& path,
ParseContext& parseContext );