about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/env/__libc_start_main.c10
-rw-r--r--src/exit/exit.c8
-rw-r--r--src/internal/vis.h7
-rw-r--r--src/ldso/dynlink.c9
4 files changed, 20 insertions, 14 deletions
diff --git a/src/env/__libc_start_main.c b/src/env/__libc_start_main.c
index 7ffada0b..5c79be28 100644
--- a/src/env/__libc_start_main.c
+++ b/src/env/__libc_start_main.c
@@ -8,9 +8,11 @@
 
 void __init_tls(size_t *);
 
-extern void _init() __attribute__((weak));
-extern void (*const __init_array_start)() __attribute__((weak));
-extern void (*const __init_array_end)() __attribute__((weak));
+static void dummy(void) {}
+weak_alias(dummy, _init);
+
+__attribute__((__weak__, __visibility__("hidden")))
+extern void (*const __init_array_start)(void), (*const __init_array_end)(void);
 
 static void dummy1(void *p) {}
 weak_alias(dummy1, __init_ssp);
@@ -53,7 +55,7 @@ void __init_libc(char **envp, char *pn)
 
 static void libc_start_init(void)
 {
-	if (_init) _init();
+	_init();
 	uintptr_t a = (uintptr_t)&__init_array_start;
 	for (; a<(uintptr_t)&__init_array_end; a+=sizeof(void(*)()))
 		(*(void (**)())a)();
diff --git a/src/exit/exit.c b/src/exit/exit.c
index b391f338..bf7835a1 100644
--- a/src/exit/exit.c
+++ b/src/exit/exit.c
@@ -10,17 +10,17 @@ static void dummy()
  * as a consequence of linking either __toread.c or __towrite.c. */
 weak_alias(dummy, __funcs_on_exit);
 weak_alias(dummy, __stdio_exit);
+weak_alias(dummy, _fini);
 
-extern void _fini() __attribute__((weak));
-extern void (*const __fini_array_start)() __attribute__((weak));
-extern void (*const __fini_array_end)() __attribute__((weak));
+__attribute__((__weak__, __visibility__("hidden")))
+extern void (*const __fini_array_start)(void), (*const __fini_array_end)(void);
 
 static void libc_exit_fini(void)
 {
 	uintptr_t a = (uintptr_t)&__fini_array_end;
 	for (; a>(uintptr_t)&__fini_array_start; a-=sizeof(void(*)()))
 		(*(void (**)())(a-sizeof(void(*)())))();
-	if (_fini) _fini();
+	_fini();
 }
 
 weak_alias(libc_exit_fini, __libc_exit_fini);
diff --git a/src/internal/vis.h b/src/internal/vis.h
index 02bfbda8..8414179e 100644
--- a/src/internal/vis.h
+++ b/src/internal/vis.h
@@ -8,8 +8,7 @@
 
 /* Conceptually, all symbols should be protected, but some toolchains
  * fail to support copy relocations for protected data, so exclude all
- * exported data symbols. Also omit visibility for possibly-undefined
- * weak references. */
+ * exported data symbols. */
 
 __attribute__((__visibility__("default")))
 extern struct _IO_FILE *const stdin, *const stdout, *const stderr;
@@ -23,10 +22,6 @@ extern long timezone, __timezone;
 __attribute__((__visibility__("default")))
 extern char *optarg, **environ, **__environ, *tzname[2], *__tzname[2], *__progname, *__progname_full;
 
-__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(protected)
 
 #endif
diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c
index 6495aeea..4648e9ac 100644
--- a/src/ldso/dynlink.c
+++ b/src/ldso/dynlink.c
@@ -134,6 +134,15 @@ static struct fdpic_dummy_loadmap app_dummy_loadmap;
 
 struct debug *_dl_debug_addr = &debug;
 
+__attribute__((__visibility__("hidden")))
+void (*const __init_array_start)(void)=0, (*const __fini_array_start)(void)=0;
+
+__attribute__((__visibility__("hidden")))
+extern void (*const __init_array_end)(void), (*const __fini_array_end)(void);
+
+weak_alias(__init_array_start, __init_array_end);
+weak_alias(__fini_array_start, __fini_array_end);
+
 static int dl_strcmp(const char *l, const char *r)
 {
 	for (; *l==*r && *l; l++, r++);