projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
disable global visibility override hack (vis.h) by default
[musl]
/
ldso
/
dynlink.c
diff --git
a/ldso/dynlink.c
b/ldso/dynlink.c
index
d20dbd8
..
35a90ae
100644
(file)
--- a/
ldso/dynlink.c
+++ b/
ldso/dynlink.c
@@
-129,6
+129,7
@@
static size_t static_tls_cnt;
static pthread_mutex_t init_fini_lock = { ._m_type = PTHREAD_MUTEX_RECURSIVE };
static struct fdpic_loadmap *app_loadmap;
static struct fdpic_dummy_loadmap app_dummy_loadmap;
static pthread_mutex_t init_fini_lock = { ._m_type = PTHREAD_MUTEX_RECURSIVE };
static struct fdpic_loadmap *app_loadmap;
static struct fdpic_dummy_loadmap app_dummy_loadmap;
+static struct dso *const nodeps_dummy;
struct debug *_dl_debug_addr = &debug;
struct debug *_dl_debug_addr = &debug;
@@
-1125,6
+1126,7
@@
static void load_deps(struct dso *p)
}
}
}
}
}
}
+ if (!*deps) *deps = (struct dso **)&nodeps_dummy;
}
static void load_preload(char *s)
}
static void load_preload(char *s)
@@
-1435,6
+1437,7
@@
_Noreturn void __dls3(size_t *sp)
size_t aux[AUX_CNT], *auxv;
size_t i;
char *env_preload=0;
size_t aux[AUX_CNT], *auxv;
size_t i;
char *env_preload=0;
+ char *replace_argv0=0;
size_t vdso_base;
int argc = *sp;
char **argv = (void *)(sp+1);
size_t vdso_base;
int argc = *sp;
char **argv = (void *)(sp+1);
@@
-1519,6
+1522,10
@@
_Noreturn void __dls3(size_t *sp)
if (opt[7]=='=') env_preload = opt+8;
else if (opt[7]) *argv = 0;
else if (*argv) env_preload = *argv++;
if (opt[7]=='=') env_preload = opt+8;
else if (opt[7]) *argv = 0;
else if (*argv) env_preload = *argv++;
+ } else if (!memcmp(opt, "argv0", 5)) {
+ if (opt[5]=='=') replace_argv0 = opt+6;
+ else if (opt[5]) *argv = 0;
+ else if (*argv) replace_argv0 = *argv++;
} else {
argv[0] = 0;
}
} else {
argv[0] = 0;
}
@@
-1675,6
+1682,8
@@
_Noreturn void __dls3(size_t *sp)
debug.state = 0;
_dl_debug_state();
debug.state = 0;
_dl_debug_state();
+ if (replace_argv0) argv[0] = replace_argv0;
+
errno = 0;
CRTJMP((void *)aux[AT_ENTRY], argv-1);
errno = 0;
CRTJMP((void *)aux[AT_ENTRY], argv-1);
@@
-1742,7
+1751,8
@@
void *dlopen(const char *file, int mode)
free(p->funcdescs);
if (p->rpath != p->rpath_orig)
free(p->rpath);
free(p->funcdescs);
if (p->rpath != p->rpath_orig)
free(p->rpath);
- free(p->deps);
+ if (p->deps != &nodeps_dummy)
+ free(p->deps);
unmap_library(p);
free(p);
}
unmap_library(p);
free(p);
}
@@
-1768,19
+1778,24
@@
void *dlopen(const char *file, int mode)
}
/* First load handling */
}
/* First load handling */
- if (!p->deps) {
+ int first_load = !p->deps;
+ if (first_load) {
load_deps(p);
if (!p->relocated && (mode & RTLD_LAZY)) {
prepare_lazy(p);
load_deps(p);
if (!p->relocated && (mode & RTLD_LAZY)) {
prepare_lazy(p);
-
if (p->deps)
for (i=0; p->deps[i]; i++)
+ for (i=0; p->deps[i]; i++)
if (!p->deps[i]->relocated)
prepare_lazy(p->deps[i]);
}
if (!p->deps[i]->relocated)
prepare_lazy(p->deps[i]);
}
+ }
+ if (first_load || (mode & RTLD_GLOBAL)) {
/* Make new symbols global, at least temporarily, so we can do
* relocations. If not RTLD_GLOBAL, this is reverted below. */
add_syms(p);
/* Make new symbols global, at least temporarily, so we can do
* relocations. If not RTLD_GLOBAL, this is reverted below. */
add_syms(p);
-
if (p->deps)
for (i=0; p->deps[i]; i++)
+ for (i=0; p->deps[i]; i++)
add_syms(p->deps[i]);
add_syms(p->deps[i]);
+ }
+ if (first_load) {
reloc_all(p);
}
reloc_all(p);
}
@@
-1878,7
+1893,7
@@
static void *do_dlsym(struct dso *p, const char *s, void *ra)
return p->funcdescs + (sym - p->syms);
if (sym && sym->st_value && (1<<(sym->st_info&0xf) & OK_TYPES))
return laddr(p, sym->st_value);
return p->funcdescs + (sym - p->syms);
if (sym && sym->st_value && (1<<(sym->st_info&0xf) & OK_TYPES))
return laddr(p, sym->st_value);
-
if (p->deps)
for (i=0; p->deps[i]; i++) {
+ for (i=0; p->deps[i]; i++) {
if ((ght = p->deps[i]->ghashtab)) {
if (!gh) gh = gnu_hash(s);
sym = gnu_lookup(gh, ght, p->deps[i], s);
if ((ght = p->deps[i]->ghashtab)) {
if (!gh) gh = gnu_hash(s);
sym = gnu_lookup(gh, ght, p->deps[i], s);