summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2011-11-29 19:44:14 +0000
committerDaniel Dunbar <daniel@zuster.org>2011-11-29 19:44:14 +0000
commit1626d864159d42d1c5a492c1cb686f629e81f815 (patch)
treea3e3bf4ed15fe3106da33854e11829264c792ed8
parentd25fa8d63f05aae6fd13ed8ed0d71040caf95e5c (diff)
downloadcompiler-rt-1626d864159d42d1c5a492c1cb686f629e81f815.tar.gz
compiler-rt-1626d864159d42d1c5a492c1cb686f629e81f815.tar.bz2
compiler-rt-1626d864159d42d1c5a492c1cb686f629e81f815.tar.xz
lib/int_util: My refactoring to allow shared utility code had a fatal flaw when
multiple .a files would end up with duplicate strong definitions. This could cause link failures in certain scenarios when both definitions got loaded. - The best solution I see for this (aside from not factoring out the utility code) is to mark the definitions weak. Better solutions appreciated! git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@145427 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/int_util.c11
-rw-r--r--lib/int_util.h3
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/int_util.c b/lib/int_util.c
index 2dc4d2ee..f1947686 100644
--- a/lib/int_util.c
+++ b/lib/int_util.c
@@ -11,6 +11,16 @@
#include "int_util.h"
#include "int_lib.h"
+/* NOTE: The definitions in this file are declared weak because we clients to be
+ * able to arbitrarily package individual functions into separate .a files. If
+ * we did not declare these weak, some link situations might end up seeing
+ * duplicate strong definitions of the same symbol.
+ *
+ * We can't use this solution for kernel use (which may not support weak), but
+ * currently expect that when built for kernel use all the functionality is
+ * packaged into a single library.
+ */
+
#ifdef KERNEL_USE
extern void panic(const char *, ...) __attribute__((noreturn));
@@ -24,6 +34,7 @@ void compilerrt_abort_impl(const char *file, int line, const char *function) {
/* Get the system definition of abort() */
#include <stdlib.h>
+__attribute__((weak))
__attribute__((visibility("hidden")))
void compilerrt_abort_impl(const char *file, int line, const char *function) {
abort();
diff --git a/lib/int_util.h b/lib/int_util.h
index 797204f0..17d77223 100644
--- a/lib/int_util.h
+++ b/lib/int_util.h
@@ -24,6 +24,9 @@
__FUNCTION__)
void compilerrt_abort_impl(const char *file, int line,
const char *function)
+#ifndef KERNEL_USE
+ __attribute__((weak))
+#endif
__attribute__((noreturn)) __attribute__((visibility("hidden")));
#endif /* INT_UTIL_H */