aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-12-23 18:56:27 +0000
committerDouglas Gregor <dgregor@apple.com>2009-12-23 18:56:27 +0000
commit0f706ab789c29030c57da6e0b0d820b80689728d (patch)
treef9659cd97fbe6e9a636421a7706086c17e79ad9d
parent7aed44658ca96d01b3dc48c0de2379b05c823ed9 (diff)
downloadexternal_llvm-0f706ab789c29030c57da6e0b0d820b80689728d.zip
external_llvm-0f706ab789c29030c57da6e0b0d820b80689728d.tar.gz
external_llvm-0f706ab789c29030c57da6e0b0d820b80689728d.tar.bz2
Move the extern symbol declarations outside of
DynamicLibrary::SearchForAddressOfSymbol and force them to have "C" linkage. Interestingly, GCC treats the block-scoped "extern" declarations we previously had as if they were extern "C" declarations (or, at least, were in the global namespace), so that GCC bug papered over this LLVM bug. Clang and EDG get the linkage correct; this new variant seems to work for both GCC and Clang. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92020 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/System/DynamicLibrary.cpp34
-rw-r--r--lib/System/DynamicLibrarySymbolDefs.def41
2 files changed, 47 insertions, 28 deletions
diff --git a/lib/System/DynamicLibrary.cpp b/lib/System/DynamicLibrary.cpp
index 7eb9f5f..b511a3c 100644
--- a/lib/System/DynamicLibrary.cpp
+++ b/lib/System/DynamicLibrary.cpp
@@ -69,6 +69,10 @@ bool DynamicLibrary::LoadLibraryPermanently(const char *Filename,
return false;
}
+#define EXPLICIT_SYMBOL(SYM) \
+ extern "C" void *SYM;
+#include "DynamicLibrarySymbolDefs.def"
+
void* DynamicLibrary::SearchForAddressOfSymbol(const char* symbolName) {
// First check symbols added via AddSymbol().
if (ExplicitSymbols) {
@@ -93,41 +97,15 @@ void* DynamicLibrary::SearchForAddressOfSymbol(const char* symbolName) {
}
#define EXPLICIT_SYMBOL(SYM) \
- extern void *SYM; if (!strcmp(symbolName, #SYM)) return &SYM
+ if (!strcmp(symbolName, #SYM)) return &SYM;
// If this is darwin, it has some funky issues, try to solve them here. Some
// important symbols are marked 'private external' which doesn't allow
// SearchForAddressOfSymbol to find them. As such, we special case them here,
// there is only a small handful of them.
-
-#ifdef __APPLE__
- {
- EXPLICIT_SYMBOL(__ashldi3);
- EXPLICIT_SYMBOL(__ashrdi3);
- EXPLICIT_SYMBOL(__cmpdi2);
- EXPLICIT_SYMBOL(__divdi3);
- EXPLICIT_SYMBOL(__eprintf);
- EXPLICIT_SYMBOL(__fixdfdi);
- EXPLICIT_SYMBOL(__fixsfdi);
- EXPLICIT_SYMBOL(__fixunsdfdi);
- EXPLICIT_SYMBOL(__fixunssfdi);
- EXPLICIT_SYMBOL(__floatdidf);
- EXPLICIT_SYMBOL(__floatdisf);
- EXPLICIT_SYMBOL(__lshrdi3);
- EXPLICIT_SYMBOL(__moddi3);
- EXPLICIT_SYMBOL(__udivdi3);
- EXPLICIT_SYMBOL(__umoddi3);
- }
-#endif
-
-#ifdef __CYGWIN__
{
- EXPLICIT_SYMBOL(_alloca);
- EXPLICIT_SYMBOL(__main);
+#include "DynamicLibrarySymbolDefs.def"
}
-#endif
-
-#undef EXPLICIT_SYMBOL
// This macro returns the address of a well-known, explicit symbol
#define EXPLICIT_SYMBOL(SYM) \
diff --git a/lib/System/DynamicLibrarySymbolDefs.def b/lib/System/DynamicLibrarySymbolDefs.def
new file mode 100644
index 0000000..c012916
--- /dev/null
+++ b/lib/System/DynamicLibrarySymbolDefs.def
@@ -0,0 +1,41 @@
+//===-- DynamicLibrarySymbolDefs.def - Extra symbol definitions -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file enumerates the set of extra external symbol definitions needed for
+// dynamic libraries.
+//
+//===----------------------------------------------------------------------===//
+#ifndef EXPLICIT_SYMBOL
+# error Must define EXPLICIT_SYMBOL to include this definitions file
+#endif
+
+#ifdef __APPLE__
+EXPLICIT_SYMBOL(__ashldi3)
+EXPLICIT_SYMBOL(__ashrdi3)
+EXPLICIT_SYMBOL(__cmpdi2)
+EXPLICIT_SYMBOL(__divdi3)
+EXPLICIT_SYMBOL(__eprintf)
+EXPLICIT_SYMBOL(__fixdfdi)
+EXPLICIT_SYMBOL(__fixsfdi)
+EXPLICIT_SYMBOL(__fixunsdfdi)
+EXPLICIT_SYMBOL(__fixunssfdi)
+EXPLICIT_SYMBOL(__floatdidf)
+EXPLICIT_SYMBOL(__floatdisf)
+EXPLICIT_SYMBOL(__lshrdi3)
+EXPLICIT_SYMBOL(__moddi3)
+EXPLICIT_SYMBOL(__udivdi3)
+EXPLICIT_SYMBOL(__umoddi3)
+#endif
+
+#ifdef __CYGWIN__
+EXPLICIT_SYMBOL(_alloca)
+EXPLICIT_SYMBOL(__main)
+#endif
+
+#undef EXPLICIT_SYMBOL