path: root/ldso
diff options
authorRich Felker <>2018-09-05 12:43:34 -0400
committerRich Felker <>2018-09-05 14:05:14 -0400
commit9b95fd0944e4206949e90633c3fed088202810ec (patch)
tree4af9c66139abfef78854aca3200f836153727c23 /ldso
parent2de29bc994029b903a366b8a4a9f8c3c3ee2be90 (diff)
define and use internal macros for hidden visibility, weak refs
this cleans up what had become widespread direct inline use of "GNU C" style attributes directly in the source, and lowers the barrier to increased use of hidden visibility, which will be useful to recovering some of the efficiency lost when the protected visibility hack was dropped in commit dc2f368e565c37728b0d620380b849c3a1ddd78f, especially on archs where the PLT ABI is costly.
Diffstat (limited to 'ldso')
2 files changed, 13 insertions, 23 deletions
diff --git a/ldso/dlstart.c b/ldso/dlstart.c
index 4dbe1784..20d50f2c 100644
--- a/ldso/dlstart.c
+++ b/ldso/dlstart.c
@@ -1,5 +1,6 @@
#include <stddef.h>
#include "dynlink.h"
+#include "libc.h"
#ifndef START
#define START "_dlstart"
@@ -11,14 +12,13 @@
#define GETFUNCSYM(fp, sym, got) do { \
- __attribute__((__visibility__("hidden"))) void sym(); \
+ hidden void sym(); \
static void (*static_func_ptr)() = sym; \
__asm__ __volatile__ ( "" : "+m"(static_func_ptr) : : "memory"); \
*(fp) = static_func_ptr; } while(0)
-void _dlstart_c(size_t *sp, size_t *dynv)
+hidden void _dlstart_c(size_t *sp, size_t *dynv)
size_t i, aux[AUX_CNT], dyn[DYN_CNT];
size_t *rel, rel_size, base;
diff --git a/ldso/dynlink.c b/ldso/dynlink.c
index 87281ddb..b46cbafb 100644
--- a/ldso/dynlink.c
+++ b/ldso/dynlink.c
@@ -99,8 +99,7 @@ int __init_tp(void *);
void __init_libc(char **, char *);
void *__copy_tls(unsigned char *);
-const char *__libc_get_version(void);
+hidden const char *__libc_get_version(void);
static struct builtin_tls {
char c;
@@ -133,14 +132,11 @@ static struct dso *const nodeps_dummy;
struct debug *_dl_debug_addr = &debug;
-extern int __malloc_replaced;
+extern hidden int __malloc_replaced;
-void (*const __init_array_start)(void)=0, (*const __fini_array_start)(void)=0;
+hidden void (*const __init_array_start)(void)=0, (*const __fini_array_start)(void)=0;
-extern void (*const __init_array_end)(void), (*const __fini_array_end)(void);
+extern hidden 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);
@@ -306,8 +302,7 @@ static struct symdef find_sym(struct dso *dso, const char *s, int need_def)
return def;
-ptrdiff_t __tlsdesc_static(), __tlsdesc_dynamic();
+hidden ptrdiff_t __tlsdesc_static(), __tlsdesc_dynamic();
static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stride)
@@ -1332,8 +1327,7 @@ void __init_tls(size_t *auxv)
-void *__tls_get_new(tls_mod_off_t *v)
+hidden void *__tls_get_new(tls_mod_off_t *v)
pthread_t self = __pthread_self();
@@ -1401,8 +1395,7 @@ static void update_tls_size()
* linker itself, but some of the relocations performed may need to be
* replaced later due to copy relocations in the main program. */
-void __dls2(unsigned char *base, size_t *sp)
+hidden void __dls2(unsigned char *base, size_t *sp)
if (DL_FDPIC) {
void *p1 = (void *)sp[-2];
@@ -1860,8 +1853,7 @@ end:
return p;
-int __dl_invalid_handle(void *h)
+hidden int __dl_invalid_handle(void *h)
struct dso *p;
for (p=head; p; p=p->next) if (h==p) return 0;
@@ -2027,8 +2019,7 @@ int dladdr(const void *addr_arg, Dl_info *info)
return 1;
-void *__dlsym(void *restrict p, const char *restrict s, void *restrict ra)
+hidden void *__dlsym(void *restrict p, const char *restrict s, void *restrict ra)
void *res;
@@ -2063,8 +2054,7 @@ int dl_iterate_phdr(int(*callback)(struct dl_phdr_info *info, size_t size, void
return ret;
-void __dl_vseterr(const char *, va_list);
+hidden void __dl_vseterr(const char *, va_list);
static void error(const char *fmt, ...)