eliminate use of SHARED macro to suppress visibility attributes
authorRich Felker <dalias@aerifal.cx>
Thu, 12 Nov 2015 00:29:45 +0000 (19:29 -0500)
committerRich Felker <dalias@aerifal.cx>
Thu, 12 Nov 2015 00:29:45 +0000 (19:29 -0500)
this is the first and simplest stage of removal of the SHARED macro,
which will eventually allow libc.a and libc.so to be produced from the
same object files.

the original motivation for these #ifdefs which are now being removed
was to allow building a static-only libc using a compiler that does
not support visibility. however, SHARED was the wrong condition to
test for this anyway; various assembly-language sources refer to
hidden symbols and declare them with the .hidden directive, making it
wrong to define the referenced symbols as non-hidden. if there is a
need in the future to build libc using compilers that lack visibility,
support could be moved to the build system or perhaps the __PIC__
macro could be checked instead of SHARED.

src/env/__stack_chk_fail.c
src/internal/syscall.h
src/internal/vis.h
src/signal/sigsetjmp_tail.c
src/thread/__syscall_cp.c
src/thread/pthread_cancel.c

index be0c184a635d5571471bef081a4f7d6f6e1e115d..4de82fd9d2f39bd19bf71269b9530eae82552c4e 100644 (file)
@@ -17,16 +17,7 @@ void __stack_chk_fail(void)
        a_crash();
 }
 
-#ifdef SHARED
-
 __attribute__((__visibility__("hidden")))
-void __stack_chk_fail_local(void)
-{
-       a_crash();
-}
-
-#else
+void __stack_chk_fail_local(void);
 
 weak_alias(__stack_chk_fail, __stack_chk_fail_local);
-
-#endif
index a93f6d1e0b7d60bc5e5299bdc407b6f9cd78251f..36c772df6390c5c9bfe959a3b5567065b39bc4dc 100644 (file)
@@ -17,9 +17,7 @@
 typedef long syscall_arg_t;
 #endif
 
-#ifdef SHARED
 __attribute__((visibility("hidden")))
-#endif
 long __syscall_ret(unsigned long), __syscall(syscall_arg_t, ...),
        __syscall_cp(syscall_arg_t, syscall_arg_t, syscall_arg_t, syscall_arg_t,
                     syscall_arg_t, syscall_arg_t, syscall_arg_t);
index bf7a5b206e672968c7db0931d835e53b1bff7c92..02bfbda88e5b456b8a573c540764b27e6d6f397d 100644 (file)
@@ -5,11 +5,11 @@
  * of position-independent code. */
 
 #ifndef CRT
-#ifdef SHARED
 
-/* For shared libc.so, all symbols should be protected, but some toolchains
+/* Conceptually, all symbols should be protected, but some toolchains
  * fail to support copy relocations for protected data, so exclude all
- * exported data symbols. */
+ * exported data symbols. Also omit visibility for possibly-undefined
+ * weak references. */
 
 __attribute__((__visibility__("default")))
 extern struct _IO_FILE *const stdin, *const stdout, *const stderr;
@@ -23,18 +23,10 @@ extern long timezone, __timezone;
 __attribute__((__visibility__("default")))
 extern char *optarg, **environ, **__environ, *tzname[2], *__tzname[2], *__progname, *__progname_full;
 
-#pragma GCC visibility push(protected)
-
-#elif defined(__PIC__)
-
-/* If building static libc.a as position-independent code, try to make
- * everything hidden except possibly-undefined weak references. */
-
 __attribute__((__visibility__("default")))
 extern void (*const __init_array_start)(), (*const __init_array_end)(),
        (*const __fini_array_start)(), (*const __fini_array_end)();
 
-#pragma GCC visibility push(hidden)
+#pragma GCC visibility push(protected)
 
 #endif
-#endif
index 487ad8caef2502aef0fc77c98260f3d49cab8fad..78762aa2bf8d141737a4ba52ed34fac94308aa52 100644 (file)
@@ -2,9 +2,7 @@
 #include <signal.h>
 #include "syscall.h"
 
-#ifdef SHARED
 __attribute__((__visibility__("hidden")))
-#endif
 int __sigsetjmp_tail(sigjmp_buf jb, int ret)
 {
        void *p = jb->__ss;
index faf57b1a6d4659bf9e83f89705464099172604d3..09a2be84f58395f9d31531fa161d52f44c0f275b 100644 (file)
@@ -1,9 +1,7 @@
 #include "pthread_impl.h"
 #include "syscall.h"
 
-#ifdef SHARED
 __attribute__((__visibility__("hidden")))
-#endif
 long __syscall_cp_c();
 
 static long sccp(syscall_arg_t nr,
index c4631f0817ac8049fef58605219098634c931173..a21c386697c3e399c6c86e18d6be56c77a05d284 100644 (file)
@@ -4,9 +4,7 @@
 #include "syscall.h"
 #include "libc.h"
 
-#ifdef SHARED
 __attribute__((__visibility__("hidden")))
-#endif
 long __cancel(), __syscall_cp_asm(), __syscall_cp_c();
 
 long __cancel()
@@ -47,9 +45,7 @@ static void _sigaddset(sigset_t *set, int sig)
        set->__bits[s/8/sizeof *set->__bits] |= 1UL<<(s&8*sizeof *set->__bits-1);
 }
 
-#ifdef SHARED
 __attribute__((__visibility__("hidden")))
-#endif
 extern const char __cp_begin[1], __cp_end[1], __cp_cancel[1];
 
 static void cancel_handler(int sig, siginfo_t *si, void *ctx)