aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/System/DynamicLibrary.cpp
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-01-19 21:41:04 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-01-19 21:41:04 +0000
commita96084901c638ecc99cc4552180961cd6bdbcfc6 (patch)
tree0a682265a59a4db7293aaf62f180a34f2d8fb940 /llvm/lib/System/DynamicLibrary.cpp
parentdcf6f9003345581c2d5a6cf2f36352f59f586c8d (diff)
downloadllvm-a96084901c638ecc99cc4552180961cd6bdbcfc6.zip
llvm-a96084901c638ecc99cc4552180961cd6bdbcfc6.tar.gz
llvm-a96084901c638ecc99cc4552180961cd6bdbcfc6.tar.bz2
Help the lli interpreter find the stderr/stdin/stdout symbols. These are
needed for output to be generated. On Linux these are both global vars and macro definitions so we have to special case Linux. llvm-svn: 33374
Diffstat (limited to 'llvm/lib/System/DynamicLibrary.cpp')
-rw-r--r--llvm/lib/System/DynamicLibrary.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/llvm/lib/System/DynamicLibrary.cpp b/llvm/lib/System/DynamicLibrary.cpp
index d4bf0f7..b84c40f 100644
--- a/llvm/lib/System/DynamicLibrary.cpp
+++ b/llvm/lib/System/DynamicLibrary.cpp
@@ -164,11 +164,23 @@ void* DynamicLibrary::SearchForAddressOfSymbol(const char* symbolName) {
}
#undef EXPLICIT_SYMBOL
#endif
+
+// This macro returns the address of a well-known, explicit symbol
#define EXPLICIT_SYMBOL(SYM) \
if (!strcmp(symbolName, #SYM)) return &SYM
- // Try a few well known symbols just to give lli a shot at working.
- // Note that on some systems stdin, etc. are macros so we have to
- // avoid attempting to take the address of a macro :)
+
+// On linux we have a weird situation. The stderr/out/in symbols are both
+// macros and global variables because of standards requirements. So, we
+// boldly use the EXPLICIT_SYMBOL macro without checking for a #define first.
+#if defined(__linux__)
+ {
+ EXPLICIT_SYMBOL(stderr);
+ EXPLICIT_SYMBOL(stdout);
+ EXPLICIT_SYMBOL(stdin);
+ }
+#else
+ // For everything else, we want to check to make sure the symbol isn't defined
+ // as a macro before using EXPLICIT_SYMBOL.
{
#ifndef stdin
EXPLICIT_SYMBOL(stdin);
@@ -179,7 +191,11 @@ void* DynamicLibrary::SearchForAddressOfSymbol(const char* symbolName) {
#ifndef stderr
EXPLICIT_SYMBOL(stderr);
#endif
+#ifndef errno
+ EXPLICIT_SYMBOL(errno);
+#endif
}
+#endif
#undef EXPLICIT_SYMBOL
return 0;