mirror of git://git.musl-libc.org/musl
remove freeing of dynamic linker data when dlopen/dlsym are not used
this was an optimization to save/recover a minimal amount of extra memory for use by malloc, that's becoming increasingly costly to keep around. freeing this data: 1. breaks debugging with gdb (it can't find library symbols) 2. breaks thread-local storage in shared libraries it would be possible to disable freeing when TLS is used, but in addition to the above breakages, tracking whether dlopen/dlsym is used adds a cost to every symbol lookup, possibly making program startup slower for large programs. combined with the complexity, it's not worth it. we already save/recover plenty of memory in the dynamic linker with reclaim_gaps.
This commit is contained in:
parent
9b153c043e
commit
c91aa03d24
|
@ -80,7 +80,6 @@ void *__install_initial_tls(void *);
|
||||||
|
|
||||||
static struct dso *head, *tail, *libc;
|
static struct dso *head, *tail, *libc;
|
||||||
static char *env_path, *sys_path, *r_path;
|
static char *env_path, *sys_path, *r_path;
|
||||||
static int rtld_used;
|
|
||||||
static int ssp_used;
|
static int ssp_used;
|
||||||
static int runtime;
|
static int runtime;
|
||||||
static int ldd_mode;
|
static int ldd_mode;
|
||||||
|
@ -182,13 +181,9 @@ static void *find_sym(struct dso *dso, const char *s, int need_def)
|
||||||
void *def = 0;
|
void *def = 0;
|
||||||
if (dso->ghashtab) {
|
if (dso->ghashtab) {
|
||||||
gh = gnu_hash(s);
|
gh = gnu_hash(s);
|
||||||
if (gh == 0xf9040207 && !strcmp(s, "dlopen")) rtld_used = 1;
|
|
||||||
if (gh == 0xf4dc4ae && !strcmp(s, "dlsym")) rtld_used = 1;
|
|
||||||
if (gh == 0x1f4039c9 && !strcmp(s, "__stack_chk_fail")) ssp_used = 1;
|
if (gh == 0x1f4039c9 && !strcmp(s, "__stack_chk_fail")) ssp_used = 1;
|
||||||
} else {
|
} else {
|
||||||
h = sysv_hash(s);
|
h = sysv_hash(s);
|
||||||
if (h == 0x6b366be && !strcmp(s, "dlopen")) rtld_used = 1;
|
|
||||||
if (h == 0x6b3afd && !strcmp(s, "dlsym")) rtld_used = 1;
|
|
||||||
if (h == 0x595a4cc && !strcmp(s, "__stack_chk_fail")) ssp_used = 1;
|
if (h == 0x595a4cc && !strcmp(s, "__stack_chk_fail")) ssp_used = 1;
|
||||||
}
|
}
|
||||||
for (; dso; dso=dso->next) {
|
for (; dso; dso=dso->next) {
|
||||||
|
@ -862,12 +857,6 @@ void *__dynlink(int argc, char **argv)
|
||||||
|
|
||||||
do_init_fini(tail);
|
do_init_fini(tail);
|
||||||
|
|
||||||
if (!rtld_used) {
|
|
||||||
free_all(head);
|
|
||||||
free(sys_path);
|
|
||||||
reclaim((void *)builtin_dsos, 0, sizeof builtin_dsos);
|
|
||||||
}
|
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
return (void *)aux[AT_ENTRY];
|
return (void *)aux[AT_ENTRY];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue