projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
TLS (GNU/C11 thread-local storage) support for static-linked programs
[musl]
/
src
/
ldso
/
dynlink.c
diff --git
a/src/ldso/dynlink.c
b/src/ldso/dynlink.c
index
93a4b44
..
1447e20
100644
(file)
--- a/
src/ldso/dynlink.c
+++ b/
src/ldso/dynlink.c
@@
-17,6
+17,9
@@
#include <pthread.h>
#include <ctype.h>
#include <dlfcn.h>
#include <pthread.h>
#include <ctype.h>
#include <dlfcn.h>
+#include "pthread_impl.h"
+#include "libc.h"
+#undef libc
static int errflag;
static char errbuf[128];
static int errflag;
static char errbuf[128];
@@
-376,7
+379,7
@@
static int path_open(const char *name, const char *search, char *buf, size_t buf
z = strchr(s, ':');
l = z ? z-s : strlen(s);
snprintf(buf, buf_size, "%.*s/%s", l, s, name);
z = strchr(s, ':');
l = z ? z-s : strlen(s);
snprintf(buf, buf_size, "%.*s/%s", l, s, name);
- if ((fd = open(buf, O_RDONLY))>=0) return fd;
+ if ((fd = open(buf, O_RDONLY
|O_CLOEXEC
))>=0) return fd;
s += l;
}
}
s += l;
}
}
@@
-423,7
+426,7
@@
static struct dso *load_library(const char *name)
}
if (strchr(name, '/')) {
pathname = name;
}
if (strchr(name, '/')) {
pathname = name;
- fd = open(name, O_RDONLY);
+ fd = open(name, O_RDONLY
|O_CLOEXEC
);
} else {
/* Search for the name to see if it's already loaded */
for (p=head->next; p; p=p->next) {
} else {
/* Search for the name to see if it's already loaded */
for (p=head->next; p; p=p->next) {
@@
-438,7
+441,7
@@
static struct dso *load_library(const char *name)
if (fd < 0 && env_path) fd = path_open(name, env_path, buf, sizeof buf);
if (fd < 0) {
if (!sys_path) {
if (fd < 0 && env_path) fd = path_open(name, env_path, buf, sizeof buf);
if (fd < 0) {
if (!sys_path) {
- FILE *f = fopen(ETC_LDSO_PATH, "r");
+ FILE *f = fopen(ETC_LDSO_PATH, "r
be
");
if (f) {
if (getline(&sys_path, (size_t[1]){0}, f) > 0)
sys_path[strlen(sys_path)-1]=0;
if (f) {
if (getline(&sys_path, (size_t[1]){0}, f) > 0)
sys_path[strlen(sys_path)-1]=0;
@@
-788,6
+791,8
@@
void *__dynlink(int argc, char **argv)
debug.state = 0;
_dl_debug_state();
debug.state = 0;
_dl_debug_state();
+ /* Stand-in until real TLS support is added to dynamic linker */
+ __libc.tls_size = sizeof(struct pthread) + 4*sizeof(size_t);
if (ssp_used) __init_ssp(auxv);
do_init_fini(tail);
if (ssp_used) __init_ssp(auxv);
do_init_fini(tail);
@@
-802,6
+807,11
@@
void *__dynlink(int argc, char **argv)
return (void *)aux[AT_ENTRY];
}
return (void *)aux[AT_ENTRY];
}
+void *__copy_tls(unsigned char *mem, size_t cnt)
+{
+ return mem;
+}
+
void *dlopen(const char *file, int mode)
{
struct dso *volatile p, *orig_tail = tail, *next;
void *dlopen(const char *file, int mode)
{
struct dso *volatile p, *orig_tail = tail, *next;
@@
-973,7
+983,7
@@
int __dladdr(void *addr, Dl_info *info)
return 1;
}
return 1;
}
-void *__dlsym(void *
p, const char *s, void *
ra)
+void *__dlsym(void *
restrict p, const char *restrict s, void *restrict
ra)
{
void *res;
pthread_rwlock_rdlock(&lock);
{
void *res;
pthread_rwlock_rdlock(&lock);
@@
-986,7
+996,7
@@
void *dlopen(const char *file, int mode)
{
return 0;
}
{
return 0;
}
-void *__dlsym(void *
p, const char *s, void *
ra)
+void *__dlsym(void *
restrict p, const char *restrict s, void *restrict
ra)
{
return 0;
}
{
return 0;
}