Handle indirect calls to functions in external modules
authorCasper Hornstrup <chorns@users.sourceforge.net>
Sun, 20 Nov 2005 13:12:33 +0000 (13:12 +0000)
committerCasper Hornstrup <chorns@users.sourceforge.net>
Sun, 20 Nov 2005 13:12:33 +0000 (13:12 +0000)
svn path=/trunk/; revision=19359

reactos/tools/rbuild/testsupportcode.cpp

index 713bc3e..3c5be7a 100644 (file)
@@ -139,7 +139,16 @@ TestSupportCode::GetStubsFilename ( Module& module )
 }
 
 string
-GetImportSymbol ( const StubbedSymbol& symbol )
+GetLinkerSymbol ( const StubbedSymbol& symbol )
+{
+       if (symbol.symbol[0] == '@')
+               return symbol.symbol;
+       else
+               return "_" + symbol.symbol;
+}
+
+string
+GetLinkerImportSymbol ( const StubbedSymbol& symbol )
 {
        if (symbol.symbol[0] == '@')
                return "__imp_" + symbol.symbol;
@@ -147,25 +156,39 @@ GetImportSymbol ( const StubbedSymbol& symbol )
                return "__imp__" + symbol.symbol;
 }
 
+string
+GetIndirectCallTargetSymbol ( const StubbedSymbol& symbol )
+{
+       return GetLinkerSymbol ( symbol ) + "_";
+}
+
 char*
 TestSupportCode::WriteStubbedSymbolToStubsFile ( char* buffer,
                                                  const StubbedComponent& component,
                                                  const StubbedSymbol& symbol,
                                                  int stubIndex )
 {
-       string importSymbol = GetImportSymbol( symbol );
+       string linkerSymbol = GetLinkerSymbol ( symbol );
+       string linkerImportSymbol = GetLinkerImportSymbol ( symbol );
+       string indirectCallTargetSymbol = GetIndirectCallTargetSymbol ( symbol );
        buffer = buffer + sprintf ( buffer,
-                                   ".globl _%s\n",
-                                   symbol.symbol.c_str () );
+                                   ".globl %s\n",
+                                   linkerSymbol.c_str () );
        buffer = buffer + sprintf ( buffer,
                                    ".globl %s\n",
-                                   importSymbol.c_str () );
+                                   linkerImportSymbol.c_str () );
+       buffer = buffer + sprintf ( buffer,
+                                   "%s:\n",
+                                   linkerSymbol.c_str () );
+       buffer = buffer + sprintf ( buffer,
+                                   "%s:\n",
+                                   linkerImportSymbol.c_str () );
        buffer = buffer + sprintf ( buffer,
-                                   "_%s:\n",
-                                   symbol.symbol.c_str () );
+                                   "  .long %s\n",
+                                   indirectCallTargetSymbol.c_str () );
        buffer = buffer + sprintf ( buffer,
                                    "%s:\n",
-                                   importSymbol.c_str () );
+                                   indirectCallTargetSymbol.c_str () );
        buffer = buffer + sprintf ( buffer,
                                    "  pushl $%d\n",
                                    stubIndex );
@@ -194,7 +217,7 @@ TestSupportCode::WriteStubsFile ( Module& module )
        char* buf;
        char* s;
 
-       buf = (char*) malloc ( 50*1024 );
+       buf = (char*) malloc ( 512*1024 );
        if ( buf == NULL )
                throw OutOfMemoryException ();