From 9fc1f92d215e6fa06fad071cea39e3b35d29247a Mon Sep 17 00:00:00 2001 From: Casper Hornstrup Date: Sun, 20 Nov 2005 13:12:33 +0000 Subject: [PATCH] Handle indirect calls to functions in external modules svn path=/trunk/; revision=19359 --- reactos/tools/rbuild/testsupportcode.cpp | 41 ++++++++++++++++++------ 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/reactos/tools/rbuild/testsupportcode.cpp b/reactos/tools/rbuild/testsupportcode.cpp index 713bc3e759c..3c5be7a32b5 100644 --- a/reactos/tools/rbuild/testsupportcode.cpp +++ b/reactos/tools/rbuild/testsupportcode.cpp @@ -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 (); -- 2.17.1