aboutsummaryrefslogtreecommitdiff
path: root/mach
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2023-05-22 17:47:49 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2023-05-22 17:47:53 +0000
commitea752260cc40ab3411d841cb5ece8df66b27add4 (patch)
tree36f882ec8f7d0a84a9e2eb961b43edf608832e2b /mach
parentea08d8dceab27ef464b9c00a03b5c61a741a634d (diff)
downloadglibc-ea752260cc40ab3411d841cb5ece8df66b27add4.tar
glibc-ea752260cc40ab3411d841cb5ece8df66b27add4.tar.gz
glibc-ea752260cc40ab3411d841cb5ece8df66b27add4.tar.bz2
glibc-ea752260cc40ab3411d841cb5ece8df66b27add4.zip
mach: Fix mach_setup_thread_impl with NULL stack_base
This is notably necessary for running the gmon thread.
Diffstat (limited to 'mach')
-rw-r--r--mach/setup-thread.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/mach/setup-thread.c b/mach/setup-thread.c
index 0e149787f8..af16d6cb84 100644
--- a/mach/setup-thread.c
+++ b/mach/setup-thread.c
@@ -33,7 +33,7 @@ mach_setup_thread_impl (task_t task, thread_t thread, int is_call,
kern_return_t error;
struct machine_thread_state ts;
mach_msg_type_number_t tssize = MACHINE_THREAD_STATE_COUNT;
- vm_address_t stack;
+ vm_address_t stack, stack_start;
vm_size_t size;
int anywhere;
@@ -51,22 +51,22 @@ mach_setup_thread_impl (task_t task, thread_t thread, int is_call,
*stack_size = size;
#ifdef STACK_GROWTH_DOWN
- if (stack_base)
- *stack_base = stack + __vm_page_size;
+ stack_start = stack + __vm_page_size;
#elif defined (STACK_GROWTH_UP)
- if (stack_base)
- *stack_base = stack;
+ stack_start = stack;
stack += size;
#else
#error stack direction unknown
#endif
+ if (stack_base)
+ *stack_base = stack_start;
if (is_call)
- MACHINE_THREAD_STATE_SETUP_CALL (&ts, *stack_base, size, pc);
+ MACHINE_THREAD_STATE_SETUP_CALL (&ts, stack_start, size, pc);
else
{
MACHINE_THREAD_STATE_SET_PC (&ts, pc);
- MACHINE_THREAD_STATE_SET_SP (&ts, *stack_base, size);
+ MACHINE_THREAD_STATE_SET_SP (&ts, stack_start, size);
}
/* Create the red zone. */