aboutsummaryrefslogtreecommitdiff
path: root/lib/ExecutionEngine/JIT/Intercept.cpp
diff options
context:
space:
mode:
authorBrian Gaeke <gaeke@uiuc.edu>2004-03-09 05:22:10 +0000
committerBrian Gaeke <gaeke@uiuc.edu>2004-03-09 05:22:10 +0000
commit00f0a29e1c57d56e82b585007d1e518c35e25fc4 (patch)
tree5fb504c8c25c9a9a8df6b019acf34315f571030c /lib/ExecutionEngine/JIT/Intercept.cpp
parentcf47198a49a4d493a64e9f3c9aecbbbe6112f005 (diff)
Address PR274 - '[JIT] Programs cannot resolve the fstat function'
by trying to get the compiler to generate an undefined reference for it and related functions which live in libc_nonshared.a on Linux. Linkers... sigh. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12256 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/JIT/Intercept.cpp')
-rw-r--r--lib/ExecutionEngine/JIT/Intercept.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/ExecutionEngine/JIT/Intercept.cpp b/lib/ExecutionEngine/JIT/Intercept.cpp
index 0b1b976836..e4b9cc1767 100644
--- a/lib/ExecutionEngine/JIT/Intercept.cpp
+++ b/lib/ExecutionEngine/JIT/Intercept.cpp
@@ -18,6 +18,7 @@
#include "JIT.h"
#include "Support/DynamicLinker.h"
#include <iostream>
+#include <sys/stat.h>
using namespace llvm;
// AtExitHandlers - List of functions to call when the program exits,
@@ -40,6 +41,23 @@ static void runAtExitHandlers() {
// Function stubs that are invoked instead of certain library calls
//===----------------------------------------------------------------------===//
+// Force the following functions to be linked in to anything that uses the
+// JIT. This is a hack designed to work around the all-too-clever Glibc
+// strategy of making these functions work differently when inlined vs. when
+// not inlined, and hiding their real definitions in a separate archive file
+// that the dynamic linker can't see. For more info, search for
+// 'libc_nonshared.a' on Google, or read http://llvm.cs.uiuc.edu/PR274.
+void *FunctionPointers[] = {
+ (void *) stat,
+ (void *) stat64,
+ (void *) fstat,
+ (void *) fstat64,
+ (void *) lstat,
+ (void *) lstat64,
+ (void *) atexit,
+ (void *) mknod
+};
+
// NoopFn - Used if we have nothing else to call...
static void NoopFn() {}