mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-24 14:00:30 +00:00
hurd: Fix exec usage of mach_setup_thread
Exec needs that mach_setup_thread does *not* set up TLS since it works on another task, so we have to split this into mach_setup_tls. * mach/mach.h (__mach_setup_tls, mach_setup_tls): Add prototypes. * mach/setup-thread.c (__mach_setup_thread): Move TLS setup to... (__mach_setup_tls): ... new function. (mach_setup_tls): New alias. * hurd/hurdsig.c (_hurdsig_init): Call __mach_setup_tls after __mach_setup_thread. * sysdeps/mach/hurd/profil.c (update_waiter): Likewise. * sysdeps/mach/hurd/setitimer.c (setitimer_locked): Likewise. * mach/Versions [libc] (mach_setup_tls): Add symbol. * sysdeps/mach/hurd/i386/libc.abilist (mach_setup_tls): Likewise.
This commit is contained in:
parent
d4b54bdff0
commit
42fc12ef73
11
ChangeLog
11
ChangeLog
@ -4,6 +4,17 @@
|
|||||||
initialization...
|
initialization...
|
||||||
(init): ... before initializing libpthread.
|
(init): ... before initializing libpthread.
|
||||||
|
|
||||||
|
* mach/mach.h (__mach_setup_tls, mach_setup_tls): Add prototypes.
|
||||||
|
* mach/setup-thread.c (__mach_setup_thread): Move TLS setup to...
|
||||||
|
(__mach_setup_tls): ... new function.
|
||||||
|
(mach_setup_tls): New alias.
|
||||||
|
* hurd/hurdsig.c (_hurdsig_init): Call __mach_setup_tls after
|
||||||
|
__mach_setup_thread.
|
||||||
|
* sysdeps/mach/hurd/profil.c (update_waiter): Likewise.
|
||||||
|
* sysdeps/mach/hurd/setitimer.c (setitimer_locked): Likewise.
|
||||||
|
* mach/Versions [libc] (mach_setup_tls): Add symbol.
|
||||||
|
* sysdeps/mach/hurd/i386/libc.abilist (mach_setup_tls): Likewise.
|
||||||
|
|
||||||
2018-07-31 Carlos O'Donell <carlos@redhat.com>
|
2018-07-31 Carlos O'Donell <carlos@redhat.com>
|
||||||
|
|
||||||
* manual/install.texi: Update versions.
|
* manual/install.texi: Update versions.
|
||||||
|
@ -1280,6 +1280,8 @@ _hurdsig_init (const int *intarray, size_t intarraysize)
|
|||||||
(vm_address_t *) &__hurd_sigthread_stack_base,
|
(vm_address_t *) &__hurd_sigthread_stack_base,
|
||||||
&stacksize);
|
&stacksize);
|
||||||
assert_perror (err);
|
assert_perror (err);
|
||||||
|
err = __mach_setup_tls (_hurd_msgport_thread);
|
||||||
|
assert_perror (err);
|
||||||
|
|
||||||
__hurd_sigthread_stack_end = __hurd_sigthread_stack_base + stacksize;
|
__hurd_sigthread_stack_end = __hurd_sigthread_stack_base + stacksize;
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ libc {
|
|||||||
mach_port_allocate; mach_port_allocate_name; mach_port_deallocate;
|
mach_port_allocate; mach_port_allocate_name; mach_port_deallocate;
|
||||||
mach_port_insert_right; mach_reply_port;
|
mach_port_insert_right; mach_reply_port;
|
||||||
mach_setup_thread;
|
mach_setup_thread;
|
||||||
|
mach_setup_tls;
|
||||||
mach_task_self;
|
mach_task_self;
|
||||||
mach_thread_self;
|
mach_thread_self;
|
||||||
mig_allocate; mig_dealloc_reply_port; mig_deallocate;
|
mig_allocate; mig_dealloc_reply_port; mig_deallocate;
|
||||||
|
@ -96,5 +96,8 @@ kern_return_t mach_setup_thread (task_t task, thread_t thread, void *pc,
|
|||||||
vm_address_t *stack_base,
|
vm_address_t *stack_base,
|
||||||
vm_size_t *stack_size);
|
vm_size_t *stack_size);
|
||||||
|
|
||||||
|
/* Give THREAD a TLS area. */
|
||||||
|
kern_return_t __mach_setup_tls (thread_t thread);
|
||||||
|
kern_return_t mach_setup_tls (thread_t thread);
|
||||||
|
|
||||||
#endif /* mach.h */
|
#endif /* mach.h */
|
||||||
|
@ -42,7 +42,6 @@ __mach_setup_thread (task_t task, thread_t thread, void *pc,
|
|||||||
vm_address_t stack;
|
vm_address_t stack;
|
||||||
vm_size_t size;
|
vm_size_t size;
|
||||||
int anywhere;
|
int anywhere;
|
||||||
tcbhead_t *tcb;
|
|
||||||
|
|
||||||
size = stack_size ? *stack_size ? : STACK_SIZE : STACK_SIZE;
|
size = stack_size ? *stack_size ? : STACK_SIZE : STACK_SIZE;
|
||||||
stack = stack_base ? *stack_base ? : 0 : 0;
|
stack = stack_base ? *stack_base ? : 0 : 0;
|
||||||
@ -52,10 +51,6 @@ __mach_setup_thread (task_t task, thread_t thread, void *pc,
|
|||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
tcb = _dl_allocate_tls (NULL);
|
|
||||||
if (tcb == NULL)
|
|
||||||
return KERN_RESOURCE_SHORTAGE;
|
|
||||||
|
|
||||||
if (stack_size)
|
if (stack_size)
|
||||||
*stack_size = size;
|
*stack_size = size;
|
||||||
|
|
||||||
@ -78,9 +73,24 @@ __mach_setup_thread (task_t task, thread_t thread, void *pc,
|
|||||||
if (error = __vm_protect (task, stack, __vm_page_size, 0, VM_PROT_NONE))
|
if (error = __vm_protect (task, stack, __vm_page_size, 0, VM_PROT_NONE))
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
if (error = __thread_set_state (thread, MACHINE_NEW_THREAD_STATE_FLAVOR,
|
return __thread_set_state (thread, MACHINE_NEW_THREAD_STATE_FLAVOR,
|
||||||
(natural_t *) &ts, tssize))
|
(natural_t *) &ts, tssize);
|
||||||
return error;
|
}
|
||||||
|
|
||||||
|
weak_alias (__mach_setup_thread, mach_setup_thread)
|
||||||
|
|
||||||
|
/* Give THREAD a TLS area. */
|
||||||
|
kern_return_t
|
||||||
|
__mach_setup_tls (thread_t thread)
|
||||||
|
{
|
||||||
|
kern_return_t error;
|
||||||
|
struct machine_thread_state ts;
|
||||||
|
mach_msg_type_number_t tssize = MACHINE_THREAD_STATE_COUNT;
|
||||||
|
tcbhead_t *tcb;
|
||||||
|
|
||||||
|
tcb = _dl_allocate_tls (NULL);
|
||||||
|
if (tcb == NULL)
|
||||||
|
return KERN_RESOURCE_SHORTAGE;
|
||||||
|
|
||||||
if (error = __thread_get_state (thread, MACHINE_THREAD_STATE_FLAVOR,
|
if (error = __thread_get_state (thread, MACHINE_THREAD_STATE_FLAVOR,
|
||||||
(natural_t *) &ts, &tssize))
|
(natural_t *) &ts, &tssize))
|
||||||
@ -91,8 +101,7 @@ __mach_setup_thread (task_t task, thread_t thread, void *pc,
|
|||||||
|
|
||||||
error = __thread_set_state (thread, MACHINE_THREAD_STATE_FLAVOR,
|
error = __thread_set_state (thread, MACHINE_THREAD_STATE_FLAVOR,
|
||||||
(natural_t *) &ts, tssize);
|
(natural_t *) &ts, tssize);
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
weak_alias (__mach_setup_thread, mach_setup_thread)
|
weak_alias (__mach_setup_tls, mach_setup_tls)
|
||||||
|
@ -1228,6 +1228,7 @@ GLIBC_2.2.6 mach_port_deallocate F
|
|||||||
GLIBC_2.2.6 mach_port_insert_right F
|
GLIBC_2.2.6 mach_port_insert_right F
|
||||||
GLIBC_2.2.6 mach_reply_port F
|
GLIBC_2.2.6 mach_reply_port F
|
||||||
GLIBC_2.2.6 mach_setup_thread F
|
GLIBC_2.2.6 mach_setup_thread F
|
||||||
|
GLIBC_2.2.6 mach_setup_tls F
|
||||||
GLIBC_2.2.6 mach_task_self F
|
GLIBC_2.2.6 mach_task_self F
|
||||||
GLIBC_2.2.6 mach_thread_self F
|
GLIBC_2.2.6 mach_thread_self F
|
||||||
GLIBC_2.2.6 madvise F
|
GLIBC_2.2.6 madvise F
|
||||||
|
@ -70,6 +70,8 @@ update_waiter (u_short *sample_buffer, size_t size, size_t offset, u_int scale)
|
|||||||
if (! err)
|
if (! err)
|
||||||
err = __mach_setup_thread (__mach_task_self (), profile_thread,
|
err = __mach_setup_thread (__mach_task_self (), profile_thread,
|
||||||
&profile_waiter, NULL, NULL);
|
&profile_waiter, NULL, NULL);
|
||||||
|
if (! err)
|
||||||
|
err = __mach_setup_tls(profile_thread);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
err = 0;
|
err = 0;
|
||||||
|
@ -221,11 +221,12 @@ setitimer_locked (const struct itimerval *new, struct itimerval *old,
|
|||||||
goto out;
|
goto out;
|
||||||
_hurd_itimer_thread_stack_base = 0; /* Anywhere. */
|
_hurd_itimer_thread_stack_base = 0; /* Anywhere. */
|
||||||
_hurd_itimer_thread_stack_size = __vm_page_size; /* Small stack. */
|
_hurd_itimer_thread_stack_size = __vm_page_size; /* Small stack. */
|
||||||
if (err = __mach_setup_thread (__mach_task_self (),
|
if ((err = __mach_setup_thread (__mach_task_self (),
|
||||||
_hurd_itimer_thread,
|
_hurd_itimer_thread,
|
||||||
&timer_thread,
|
&timer_thread,
|
||||||
&_hurd_itimer_thread_stack_base,
|
&_hurd_itimer_thread_stack_base,
|
||||||
&_hurd_itimer_thread_stack_size))
|
&_hurd_itimer_thread_stack_size))
|
||||||
|
|| (err = __mach_setup_tls(_hurd_itimer_thread)))
|
||||||
{
|
{
|
||||||
__thread_terminate (_hurd_itimer_thread);
|
__thread_terminate (_hurd_itimer_thread);
|
||||||
_hurd_itimer_thread = MACH_PORT_NULL;
|
_hurd_itimer_thread = MACH_PORT_NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user