aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2015-04-13 19:24:51 -0400
committerRich Felker <dalias@aerifal.cx>2015-04-13 19:24:51 -0400
commit19a1fe670acb3ab9ead0fe31859ca7d4fe40dd54 (patch)
treec2a2b1e2e4ddb58416a925b1e64485ac4972f4e4 /src
parent71f099cb7db821c51d8f39dfac622c61e54d794c (diff)
downloadmusl-19a1fe670acb3ab9ead0fe31859ca7d4fe40dd54.zip
musl-19a1fe670acb3ab9ead0fe31859ca7d4fe40dd54.tar.gz
musl-19a1fe670acb3ab9ead0fe31859ca7d4fe40dd54.tar.bz2
remove remnants of support for running in no-thread-pointer mode
since 1.1.0, musl has nominally required a thread pointer to be setup. most of the remaining code that was checking for its availability was doing so for the sake of being usable by the dynamic linker. as of commit 71f099cb7db821c51d8f39dfac622c61e54d794c, this is no longer necessary; the thread pointer is now valid before any libc code (outside of dynamic linker bootstrap functions) runs. this commit essentially concludes "phase 3" of the "transition path for removing lazy init of thread pointer" project that began during the 1.1.0 release cycle.
Diffstat (limited to 'src')
-rw-r--r--src/env/__init_tls.c5
-rw-r--r--src/env/__stack_chk_fail.c3
-rw-r--r--src/errno/__errno_location.c4
-rw-r--r--src/internal/libc.h3
-rw-r--r--src/ldso/dynlink.c12
-rw-r--r--src/process/fork.c2
-rw-r--r--src/thread/pthread_cancel.c3
-rw-r--r--src/thread/pthread_create.c2
-rw-r--r--src/thread/pthread_key_create.c10
-rw-r--r--src/thread/pthread_setcancelstate.c1
10 files changed, 13 insertions, 32 deletions
diff --git a/src/env/__init_tls.c b/src/env/__init_tls.c
index ac4d9e7..67f1409 100644
--- a/src/env/__init_tls.c
+++ b/src/env/__init_tls.c
@@ -15,7 +15,6 @@ int __init_tp(void *p)
int r = __set_thread_area(TP_ADJ(p));
if (r < 0) return -1;
if (!r) libc.can_do_threads = 1;
- libc.has_thread_pointer = 1;
td->tid = __syscall(SYS_set_tid_address, &td->tid);
td->locale = &libc.global_locale;
td->robust_list.head = &td->robust_list.head;
@@ -112,8 +111,8 @@ void __init_tls(size_t *aux)
mem = builtin_tls;
}
- /* Failure to initialize thread pointer is fatal if TLS is used. */
- if (__init_tp(__copy_tls(mem)) < 0 && tls_phdr)
+ /* Failure to initialize thread pointer is always fatal. */
+ if (__init_tp(__copy_tls(mem)) < 0)
a_crash();
}
#else
diff --git a/src/env/__stack_chk_fail.c b/src/env/__stack_chk_fail.c
index 87ac473..cc55460 100644
--- a/src/env/__stack_chk_fail.c
+++ b/src/env/__stack_chk_fail.c
@@ -9,8 +9,7 @@ void __init_ssp(void *entropy)
if (entropy) memcpy(&__stack_chk_guard, entropy, sizeof(uintptr_t));
else __stack_chk_guard = (uintptr_t)&__stack_chk_guard * 1103515245;
- if (libc.has_thread_pointer)
- __pthread_self()->canary = __stack_chk_guard;
+ __pthread_self()->canary = __stack_chk_guard;
}
void __stack_chk_fail(void)
diff --git a/src/errno/__errno_location.c b/src/errno/__errno_location.c
index 49654ef..7172a1b 100644
--- a/src/errno/__errno_location.c
+++ b/src/errno/__errno_location.c
@@ -2,7 +2,5 @@
int *__errno_location(void)
{
- static int e;
- if (libc.has_thread_pointer) return &__pthread_self()->errno_val;
- return &e;
+ return &__pthread_self()->errno_val;
}
diff --git a/src/internal/libc.h b/src/internal/libc.h
index 3751cca..79d53fc 100644
--- a/src/internal/libc.h
+++ b/src/internal/libc.h
@@ -14,12 +14,11 @@ struct __locale_struct {
};
struct __libc {
- int has_thread_pointer;
int can_do_threads;
int threaded;
int secure;
- size_t *auxv;
volatile int threads_minus_1;
+ size_t *auxv;
FILE *ofl_head;
volatile int ofl_lock[2];
size_t tls_size;
diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c
index 31f5939..8b15daa 100644
--- a/src/ldso/dynlink.c
+++ b/src/ldso/dynlink.c
@@ -810,12 +810,6 @@ static struct dso *load_library(const char *name, struct dso *needed_by)
/* Add a shortname only if name arg was not an explicit pathname. */
if (pathname != name) p->shortname = strrchr(p->name, '/')+1;
if (p->tls_image) {
- if (runtime && !libc.has_thread_pointer) {
- munmap(map, p->map_len);
- free(p);
- errno = ENOSYS;
- return 0;
- }
p->tls_id = ++tls_cnt;
tls_align = MAXP2(tls_align, p->tls_align);
#ifdef TLS_ABOVE_TP
@@ -1165,8 +1159,7 @@ _Noreturn void __dls3(size_t *sp)
* thread pointer at runtime. */
libc.tls_size = sizeof builtin_tls;
if (__init_tp(__copy_tls((void *)builtin_tls)) < 0) {
- dprintf(2, "%s: Thread-local storage not supported by kernel.\n", argv[0]);
- _exit(127);
+ a_crash();
}
/* Find aux vector just past environ[] */
@@ -1352,8 +1345,7 @@ _Noreturn void __dls3(size_t *sp)
_exit(127);
}
if (__init_tp(__copy_tls(initial_tls)) < 0) {
- dprintf(2, "%s: Failed to switch to new thread pointer.\n", argv[0]);
- _exit(127);
+ a_crash();
}
} else {
size_t tmp_tls_size = libc.tls_size;
diff --git a/src/process/fork.c b/src/process/fork.c
index 8d67682..b96f002 100644
--- a/src/process/fork.c
+++ b/src/process/fork.c
@@ -22,7 +22,7 @@ pid_t fork(void)
#else
ret = syscall(SYS_clone, SIGCHLD, 0);
#endif
- if (libc.has_thread_pointer && !ret) {
+ if (!ret) {
pthread_t self = __pthread_self();
self->tid = __syscall(SYS_gettid);
self->robust_list.off = 0;
diff --git a/src/thread/pthread_cancel.c b/src/thread/pthread_cancel.c
index a507f92..7c5dda3 100644
--- a/src/thread/pthread_cancel.c
+++ b/src/thread/pthread_cancel.c
@@ -30,7 +30,7 @@ long __syscall_cp_c(syscall_arg_t nr,
long r;
int st;
- if (!libc.has_thread_pointer || (st=(self=__pthread_self())->canceldisable)
+ if ((st=(self=__pthread_self())->canceldisable)
&& (st==PTHREAD_CANCEL_DISABLE || nr==SYS_close))
return __syscall(nr, u, v, w, x, y, z);
@@ -69,7 +69,6 @@ static void cancel_handler(int sig, siginfo_t *si, void *ctx)
void __testcancel()
{
- if (!libc.has_thread_pointer) return;
pthread_t self = __pthread_self();
if (self->cancel && !self->canceldisable)
__cancel();
diff --git a/src/thread/pthread_create.c b/src/thread/pthread_create.c
index 33808ce..6963f0d 100644
--- a/src/thread/pthread_create.c
+++ b/src/thread/pthread_create.c
@@ -122,7 +122,6 @@ _Noreturn void __pthread_exit(void *result)
void __do_cleanup_push(struct __ptcb *cb)
{
- if (!libc.has_thread_pointer) return;
struct pthread *self = __pthread_self();
cb->__next = self->cancelbuf;
self->cancelbuf = cb;
@@ -130,7 +129,6 @@ void __do_cleanup_push(struct __ptcb *cb)
void __do_cleanup_pop(struct __ptcb *cb)
{
- if (!libc.has_thread_pointer) return;
__pthread_self()->cancelbuf = cb->__next;
}
diff --git a/src/thread/pthread_key_create.c b/src/thread/pthread_key_create.c
index 198ae56..a78e507 100644
--- a/src/thread/pthread_key_create.c
+++ b/src/thread/pthread_key_create.c
@@ -13,13 +13,11 @@ int __pthread_key_create(pthread_key_t *k, void (*dtor)(void *))
{
unsigned i = (uintptr_t)&k / 16 % PTHREAD_KEYS_MAX;
unsigned j = i;
+ pthread_t self = __pthread_self();
- if (libc.has_thread_pointer) {
- pthread_t self = __pthread_self();
- /* This can only happen in the main thread before
- * pthread_create has been called. */
- if (!self->tsd) self->tsd = __pthread_tsd_main;
- }
+ /* This can only happen in the main thread before
+ * pthread_create has been called. */
+ if (!self->tsd) self->tsd = __pthread_tsd_main;
if (!dtor) dtor = nodtor;
do {
diff --git a/src/thread/pthread_setcancelstate.c b/src/thread/pthread_setcancelstate.c
index 822a139..5ab8c33 100644
--- a/src/thread/pthread_setcancelstate.c
+++ b/src/thread/pthread_setcancelstate.c
@@ -3,7 +3,6 @@
int __pthread_setcancelstate(int new, int *old)
{
if (new > 2U) return EINVAL;
- if (!libc.has_thread_pointer) return ENOSYS;
struct pthread *self = __pthread_self();
if (old) *old = self->canceldisable;
self->canceldisable = new;