diff options
author | Chris Lattner <sabre@nondot.org> | 2004-06-01 21:49:00 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-06-01 21:49:00 +0000 |
commit | abf1cd3ada70c14098abb705d452f75be7963ce1 (patch) | |
tree | 4e6f6e9f7fffa6168d49f8066a7644857b8ca619 /lib/ExecutionEngine/JIT/Intercept.cpp | |
parent | 7124771c5d37633a9ddb51ae9fc1fa6e816d749a (diff) |
Implement PR315: abort, don't warn, when missing external functions encountered
This fixes some critical problems building libstdc++ on cygwin.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13934 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/JIT/Intercept.cpp')
-rw-r--r-- | lib/ExecutionEngine/JIT/Intercept.cpp | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/lib/ExecutionEngine/JIT/Intercept.cpp b/lib/ExecutionEngine/JIT/Intercept.cpp index ce93ab1867..8ed9447159 100644 --- a/lib/ExecutionEngine/JIT/Intercept.cpp +++ b/lib/ExecutionEngine/JIT/Intercept.cpp @@ -60,8 +60,13 @@ void *FunctionPointers[] = { }; #endif // __linux__ -// NoopFn - Used if we have nothing else to call... -static void NoopFn() {} +// __mainFunc - If the program does not have a linked in __main function, allow +// it to run, but print a warning. +static void __mainFunc() { + fprintf(stderr, "WARNING: Program called __main but was not linked to " + "libcrtend.a.\nThis probably won't hurt anything unless the " + "program is written in C++.\n"); +} // jit_exit - Used to intercept the "exit" library call. static void jit_exit(int Status) { @@ -86,13 +91,16 @@ void *JIT::getPointerToNamedFunction(const std::string &Name) { if (Name == "exit") return (void*)&jit_exit; if (Name == "atexit") return (void*)&jit_atexit; + // If the program does not have a linked in __main function, allow it to run, + // but print a warning. + if (Name == "__main") return (void*)&__mainFunc; + // If it's an external function, look it up in the process image... void *Ptr = GetAddressOfSymbol(Name); - if (Ptr == 0) { - std::cerr << "WARNING: Cannot resolve fn '" << Name - << "' using a dummy noop function instead!\n"; - Ptr = (void*)NoopFn; - } - - return Ptr; + if (Ptr) return Ptr; + + std::cerr << "ERROR: Program used external function '" << Name + << "' which could not be resolved!\n"; + abort(); + return 0; } |