X-Git-Url: http://nsz.repo.hu/git/?p=musl;a=blobdiff_plain;f=src%2Fldso%2Fdynlink.c;h=1447e2059229554dd2d37a9a64c49d0cf5eb9f74;hp=93a4b44c1165035db3e2852e8db682cd9b664643;hb=8431d7972fd9be0fdcaff8516316d748e81724bb;hpb=8b28aa9c94e7c6179d70fe73afcd3fff29809d61 diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c index 93a4b44c..1447e205 100644 --- a/src/ldso/dynlink.c +++ b/src/ldso/dynlink.c @@ -17,6 +17,9 @@ #include #include #include +#include "pthread_impl.h" +#include "libc.h" +#undef libc 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); - if ((fd = open(buf, O_RDONLY))>=0) return fd; + if ((fd = open(buf, O_RDONLY|O_CLOEXEC))>=0) return fd; s += l; } } @@ -423,7 +426,7 @@ static struct dso *load_library(const char *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) { @@ -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) { - FILE *f = fopen(ETC_LDSO_PATH, "r"); + FILE *f = fopen(ETC_LDSO_PATH, "rbe"); 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(); + /* 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); @@ -802,6 +807,11 @@ void *__dynlink(int argc, char **argv) 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; @@ -973,7 +983,7 @@ int __dladdr(void *addr, Dl_info *info) 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); @@ -986,7 +996,7 @@ void *dlopen(const char *file, int mode) { 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; }