path: root/src
diff options
authorRich Felker <>2015-11-11 19:29:45 -0500
committerRich Felker <>2015-11-11 19:29:45 -0500
commit8a8fdf6398b85c99dffb237e47fa577e2ddc9e77 (patch)
tree8a857fd548cedb3c1664b3ee6f17c827167d73ee /src
parentdc5bd27ac4eb68e7ec84dff0fd26f2ac55360989 (diff)
eliminate use of SHARED macro to suppress visibility attributes
this is the first and simplest stage of removal of the SHARED macro, which will eventually allow libc.a and 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.
Diffstat (limited to 'src')
6 files changed, 5 insertions, 32 deletions
diff --git a/src/env/__stack_chk_fail.c b/src/env/__stack_chk_fail.c
index be0c184a..4de82fd9 100644
--- a/src/env/__stack_chk_fail.c
+++ b/src/env/__stack_chk_fail.c
@@ -17,16 +17,7 @@ void __stack_chk_fail(void)
-#ifdef SHARED
-void __stack_chk_fail_local(void)
- a_crash();
+void __stack_chk_fail_local(void);
weak_alias(__stack_chk_fail, __stack_chk_fail_local);
diff --git a/src/internal/syscall.h b/src/internal/syscall.h
index a93f6d1e..36c772df 100644
--- a/src/internal/syscall.h
+++ b/src/internal/syscall.h
@@ -17,9 +17,7 @@
typedef long syscall_arg_t;
-#ifdef SHARED
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);
diff --git a/src/internal/vis.h b/src/internal/vis.h
index bf7a5b20..02bfbda8 100644
--- a/src/internal/vis.h
+++ b/src/internal/vis.h
@@ -5,11 +5,11 @@
* of position-independent code. */
#ifndef CRT
-#ifdef SHARED
-/* For shared, 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. */
extern struct _IO_FILE *const stdin, *const stdout, *const stderr;
@@ -23,18 +23,10 @@ extern long timezone, __timezone;
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. */
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)
diff --git a/src/signal/sigsetjmp_tail.c b/src/signal/sigsetjmp_tail.c
index 487ad8ca..78762aa2 100644
--- a/src/signal/sigsetjmp_tail.c
+++ b/src/signal/sigsetjmp_tail.c
@@ -2,9 +2,7 @@
#include <signal.h>
#include "syscall.h"
-#ifdef SHARED
int __sigsetjmp_tail(sigjmp_buf jb, int ret)
void *p = jb->__ss;
diff --git a/src/thread/__syscall_cp.c b/src/thread/__syscall_cp.c
index faf57b1a..09a2be84 100644
--- a/src/thread/__syscall_cp.c
+++ b/src/thread/__syscall_cp.c
@@ -1,9 +1,7 @@
#include "pthread_impl.h"
#include "syscall.h"
-#ifdef SHARED
long __syscall_cp_c();
static long sccp(syscall_arg_t nr,
diff --git a/src/thread/pthread_cancel.c b/src/thread/pthread_cancel.c
index c4631f08..a21c3866 100644
--- a/src/thread/pthread_cancel.c
+++ b/src/thread/pthread_cancel.c
@@ -4,9 +4,7 @@
#include "syscall.h"
#include "libc.h"
-#ifdef SHARED
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
extern const char __cp_begin[1], __cp_end[1], __cp_cancel[1];
static void cancel_handler(int sig, siginfo_t *si, void *ctx)