projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
support STB_GNU_UNIQUE symbol bindings in dynamic linker
[musl]
/
src
/
ldso
/
dynlink.c
diff --git
a/src/ldso/dynlink.c
b/src/ldso/dynlink.c
index
3a0bf95
..
f4c32ff
100644
(file)
--- a/
src/ldso/dynlink.c
+++ b/
src/ldso/dynlink.c
@@
-101,7
+101,7
@@
static int runtime;
static int ldd_mode;
static int ldso_fail;
static int noload;
static int ldd_mode;
static int ldso_fail;
static int noload;
-static jmp_buf rtld_fail;
+static jmp_buf
*
rtld_fail;
static pthread_rwlock_t lock;
static struct debug debug;
static size_t tls_cnt, tls_offset, tls_align = 4*sizeof(size_t);
static pthread_rwlock_t lock;
static struct debug debug;
static size_t tls_cnt, tls_offset, tls_align = 4*sizeof(size_t);
@@
-190,7
+190,7
@@
static Sym *gnu_lookup(const char *s, uint32_t h1, struct dso *dso)
}
#define OK_TYPES (1<<STT_NOTYPE | 1<<STT_OBJECT | 1<<STT_FUNC | 1<<STT_COMMON | 1<<STT_TLS)
}
#define OK_TYPES (1<<STT_NOTYPE | 1<<STT_OBJECT | 1<<STT_FUNC | 1<<STT_COMMON | 1<<STT_TLS)
-#define OK_BINDS (1<<STB_GLOBAL | 1<<STB_WEAK)
+#define OK_BINDS (1<<STB_GLOBAL | 1<<STB_WEAK
| 1<<STB_GNU_UNIQUE
)
static struct symdef find_sym(struct dso *dso, const char *s, int need_def)
{
static struct symdef find_sym(struct dso *dso, const char *s, int need_def)
{
@@
-255,7
+255,7
@@
static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stri
snprintf(errbuf, sizeof errbuf,
"Error relocating %s: %s: symbol not found",
dso->name, name);
snprintf(errbuf, sizeof errbuf,
"Error relocating %s: %s: symbol not found",
dso->name, name);
- if (runtime) longjmp(rtld_fail, 1);
+ if (runtime) longjmp(
*
rtld_fail, 1);
dprintf(2, "%s\n", errbuf);
ldso_fail = 1;
continue;
dprintf(2, "%s\n", errbuf);
ldso_fail = 1;
continue;
@@
-613,14
+613,14
@@
static void load_deps(struct dso *p)
snprintf(errbuf, sizeof errbuf,
"Error loading shared library %s: %m (needed by %s)",
p->strings + p->dynv[i+1], p->name);
snprintf(errbuf, sizeof errbuf,
"Error loading shared library %s: %m (needed by %s)",
p->strings + p->dynv[i+1], p->name);
- if (runtime) longjmp(rtld_fail, 1);
+ if (runtime) longjmp(
*
rtld_fail, 1);
dprintf(2, "%s\n", errbuf);
ldso_fail = 1;
continue;
}
if (runtime) {
tmp = realloc(*deps, sizeof(*tmp)*(ndeps+2));
dprintf(2, "%s\n", errbuf);
ldso_fail = 1;
continue;
}
if (runtime) {
tmp = realloc(*deps, sizeof(*tmp)*(ndeps+2));
- if (!tmp) longjmp(rtld_fail, 1);
+ if (!tmp) longjmp(
*
rtld_fail, 1);
tmp[ndeps++] = dep;
tmp[ndeps] = 0;
*deps = tmp;
tmp[ndeps++] = dep;
tmp[ndeps] = 0;
*deps = tmp;
@@
-702,8
+702,10
@@
static void do_fini()
size_t *fn = (size_t *)(p->base + dyn[DT_FINI_ARRAY])+n;
while (n--) ((void (*)(void))*--fn)();
}
size_t *fn = (size_t *)(p->base + dyn[DT_FINI_ARRAY])+n;
while (n--) ((void (*)(void))*--fn)();
}
+#ifndef NO_LEGACY_INITFINI
if (dyn[0] & (1<<DT_FINI))
((void (*)(void))(p->base + dyn[DT_FINI]))();
if (dyn[0] & (1<<DT_FINI))
((void (*)(void))(p->base + dyn[DT_FINI]))();
+#endif
}
}
}
}
@@
-723,8
+725,10
@@
static void do_init_fini(struct dso *p)
p->fini_next = fini_head;
fini_head = p;
}
p->fini_next = fini_head;
fini_head = p;
}
+#ifndef NO_LEGACY_INITFINI
if (dyn[0] & (1<<DT_INIT))
((void (*)(void))(p->base + dyn[DT_INIT]))();
if (dyn[0] & (1<<DT_INIT))
((void (*)(void))(p->base + dyn[DT_INIT]))();
+#endif
if (dyn[0] & (1<<DT_INIT_ARRAY)) {
size_t n = dyn[DT_INIT_ARRAYSZ]/sizeof(size_t);
size_t *fn = (void *)(p->base + dyn[DT_INIT_ARRAY]);
if (dyn[0] & (1<<DT_INIT_ARRAY)) {
size_t n = dyn[DT_INIT_ARRAYSZ]/sizeof(size_t);
size_t *fn = (void *)(p->base + dyn[DT_INIT_ARRAY]);
@@
-1053,6
+1057,7
@@
void *dlopen(const char *file, int mode)
size_t orig_tls_cnt, orig_tls_offset, orig_tls_align;
size_t i;
int cs;
size_t orig_tls_cnt, orig_tls_offset, orig_tls_align;
size_t i;
int cs;
+ jmp_buf jb;
if (!file) return head;
if (!file) return head;
@@
-1067,7
+1072,8
@@
void *dlopen(const char *file, int mode)
orig_tail = tail;
noload = mode & RTLD_NOLOAD;
orig_tail = tail;
noload = mode & RTLD_NOLOAD;
- if (setjmp(rtld_fail)) {
+ rtld_fail = &jb;
+ if (setjmp(*rtld_fail)) {
/* Clean up anything new that was (partially) loaded */
if (p && p->deps) for (i=0; p->deps[i]; i++)
if (p->deps[i]->global < 0)
/* Clean up anything new that was (partially) loaded */
if (p && p->deps) for (i=0; p->deps[i]; i++)
if (p->deps[i]->global < 0)