[LLVMdev] [PATCH 2/2 v3] add visibility hidden to tls entry points

Marc Dietrich
2015-02-17T09:40:08Z

Avoid redefined symbol errors in clang. Based on a suggestion from
Rafael Ãvila de EspÃndola <rafael.espindola at gmail.com> in
http://llvm.org/bugs/show_bug.cgi?id=19778.

Signed-off-by: Marc Dietrich <marvin24 at gmx.de>
---
v2: - no change
v3: - include util directory in Makefile.am in order to avoid relative
      include paths,
    - make tls entry points array const

 src/mapi/Makefile.am        | 1 +
 src/mapi/entry_x86-64_tls.h | 4 ++--
 src/mapi/entry_x86_tls.h    | 5 +++--
 src/mapi/entry_x86_tsd.h    | 5 +++--
 4 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/mapi/Makefile.am b/src/mapi/Makefile.am
index 6794682..c42ed52 100644
--- a/src/mapi/Makefile.am
+++ b/src/mapi/Makefile.am
@@ -45,6 +45,7 @@ AM_CPPFLAGS =							\
 	$(SELINUX_CFLAGS)					\
 	-I$(top_srcdir)/include					\
 	-I$(top_srcdir)/src/mapi				\
+	-I$(top_srcdir)/src/util				\
 	-I$(top_builddir)/src/mapi

 include Makefile.sources
diff --git a/src/mapi/entry_x86-64_tls.h b/src/mapi/entry_x86-64_tls.h
index 71e9d60..2c5d64d 100644
--- a/src/mapi/entry_x86-64_tls.h
+++ b/src/mapi/entry_x86-64_tls.h
@@ -25,6 +25,7 @@
  *    Chia-I Wu <olv at lunarg.com>
  */

+#include "macros.h"
 #include "u_macros.h"

 __asm__(".text\n"
@@ -62,8 +63,7 @@ entry_patch_public(void)
 {
 }

-static char
-x86_64_entry_start[];
+extern const char HIDDEN x86_64_entry_start[];

 mapi_func
 entry_get_public(int slot)
diff --git a/src/mapi/entry_x86_tls.h b/src/mapi/entry_x86_tls.h
index fa7bc15..a66edec 100644
--- a/src/mapi/entry_x86_tls.h
+++ b/src/mapi/entry_x86_tls.h
@@ -26,6 +26,7 @@
  */

 #include <string.h>
+#include "macros.h"
 #include "u_macros.h"

 __asm__(".text");
@@ -72,8 +73,8 @@ __asm__(".text");
 extern unsigned long
 x86_current_tls();

-static char x86_entry_start[];
-static char x86_entry_end[];
+extern const char HIDDEN x86_entry_start[];
+extern const char HIDDEN x86_entry_end[];

 void
 entry_patch_public(void)
diff --git a/src/mapi/entry_x86_tsd.h b/src/mapi/entry_x86_tsd.h
index ece00fa..1de2991 100644
--- a/src/mapi/entry_x86_tsd.h
+++ b/src/mapi/entry_x86_tsd.h
@@ -25,6 +25,7 @@
  *    Chia-I Wu <olv at lunarg.com>
  */

+#include "macros.h"
 #include "u_macros.h"

 #define X86_ENTRY_SIZE 32
@@ -59,8 +60,8 @@ __asm__(".balign 32\n"
 #include <string.h>
 #include "u_execmem.h"

-static const char x86_entry_start[];
-static const char x86_entry_end[];
+extern const char HIDDEN x86_entry_start[];
+extern const char HIDDEN x86_entry_end[];

 void
 entry_patch_public(void)
--
2.2.2