diff options
author | Anton Korobeynikov <asl@math.spbu.ru> | 2008-02-22 10:08:31 +0000 |
---|---|---|
committer | Anton Korobeynikov <asl@math.spbu.ru> | 2008-02-22 10:08:31 +0000 |
commit | 47ccf1af3a8d0f960fc965b527fd3197c4bca7d5 (patch) | |
tree | 8064fd4c10ff24a9360f8867c648ab65991a27ed /lib/System | |
parent | 58d13af6f06feeb9e8bdc0a19c32daf70c325c9c (diff) | |
download | external_llvm-47ccf1af3a8d0f960fc965b527fd3197c4bca7d5.zip external_llvm-47ccf1af3a8d0f960fc965b527fd3197c4bca7d5.tar.gz external_llvm-47ccf1af3a8d0f960fc965b527fd3197c4bca7d5.tar.bz2 |
Provide __main hooks for cygwin & mingw32
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47479 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System')
-rw-r--r-- | lib/System/DynamicLibrary.cpp | 1 | ||||
-rw-r--r-- | lib/System/Win32/DynamicLibrary.inc | 44 |
2 files changed, 28 insertions, 17 deletions
diff --git a/lib/System/DynamicLibrary.cpp b/lib/System/DynamicLibrary.cpp index 44666a3..9c52c8a 100644 --- a/lib/System/DynamicLibrary.cpp +++ b/lib/System/DynamicLibrary.cpp @@ -118,6 +118,7 @@ void* DynamicLibrary::SearchForAddressOfSymbol(const char* symbolName) { #ifdef __CYGWIN__ { EXPLICIT_SYMBOL(_alloca); + EXPLICIT_SYMBOL(__main); } #endif diff --git a/lib/System/Win32/DynamicLibrary.inc b/lib/System/Win32/DynamicLibrary.inc index 0bb59c9..5b4d5a5 100644 --- a/lib/System/Win32/DynamicLibrary.inc +++ b/lib/System/Win32/DynamicLibrary.inc @@ -44,10 +44,17 @@ static std::vector<HMODULE> OpenedHandles; #endif extern "C" { +#if !defined(_MSC_VER) || _MSC_VER < 1500 static BOOL CALLBACK ELM_Callback(PSTR ModuleName, ModuleBaseType ModuleBase, ULONG ModuleSize, PVOID UserContext) +#else + static BOOL CALLBACK ELM_Callback(PCSTR ModuleName, + ModuleBaseType ModuleBase, + ULONG ModuleSize, + PVOID UserContext) +#endif { // Ignore VC++ runtimes prior to 7.1. Somehow some of them get loaded // into the process. @@ -93,23 +100,6 @@ DynamicLibrary::~DynamicLibrary() { } } } - -// Stack probing routines are in the support library (e.g. libgcc), but we don't -// have dynamic linking on windows. Provide a hook. -#if defined(__MINGW32__) || defined (_MSC_VER) - #define EXPLICIT_SYMBOL(SYM) \ - if (!strcmp(symbolName, #SYM)) return (void*)&SYM - #define EXPLICIT_SYMBOL2(SYMFROM, SYMTO) \ - if (!strcmp(symbolName, #SYMFROM)) return (void*)&SYMTO - #define EXPLICIT_SYMBOL_DEF(SYM) \ - extern "C" { extern void *SYM; } - - #if defined(__MINGW32__) - EXPLICIT_SYMBOL_DEF(_alloca); - #elif defined(_MSC_VER) - EXPLICIT_SYMBOL_DEF(_alloca_probe); - #endif -#endif bool DynamicLibrary::LoadLibraryPermanently(const char *filename, std::string *ErrMsg) { @@ -131,6 +121,24 @@ bool DynamicLibrary::LoadLibraryPermanently(const char *filename, return false; } +// Stack probing routines are in the support library (e.g. libgcc), but we don't +// have dynamic linking on windows. Provide a hook. +#if defined(__MINGW32__) || defined (_MSC_VER) + #define EXPLICIT_SYMBOL(SYM) \ + if (!strcmp(symbolName, #SYM)) return (void*)&SYM + #define EXPLICIT_SYMBOL2(SYMFROM, SYMTO) \ + if (!strcmp(symbolName, #SYMFROM)) return (void*)&SYMTO + #define EXPLICIT_SYMBOL_DEF(SYM) \ + extern "C" { extern void *SYM; } + + #if defined(__MINGW32__) + EXPLICIT_SYMBOL_DEF(_alloca); + EXPLICIT_SYMBOL_DEF(__main); + #elif defined(_MSC_VER) + EXPLICIT_SYMBOL_DEF(_alloca_probe); + #endif +#endif + void* DynamicLibrary::SearchForAddressOfSymbol(const char* symbolName) { // First check symbols added via AddSymbol(). std::map<std::string, void *>::iterator I = g_symbols.find(symbolName); @@ -148,6 +156,8 @@ void* DynamicLibrary::SearchForAddressOfSymbol(const char* symbolName) { #if defined(__MINGW32__) { EXPLICIT_SYMBOL(_alloca); + EXPLICIT_SYMBOL(__main); + EXPLICIT_SYMBOL2(alloca, _alloca); #undef EXPLICIT_SYMBOL #undef EXPLICIT_SYMBOL2 |