* [hurd,commited 0/4] Fix more hurd initialization for ifunc support
@ 2020-11-11 20:43 Samuel Thibault
2020-11-11 20:43 ` [hurd,commited 1/4] htl: Fix spurious symbols in namespaces Samuel Thibault
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Samuel Thibault @ 2020-11-11 20:43 UTC (permalink / raw)
To: libc-alpha; +Cc: Samuel Thibault, commit-hurd
Samuel Thibault (4):
htl: Fix spurious symbols in namespaces
htl: Keep thread signals blocked during its initialization
htl: Initialize later
hurd: Notify the proc server later during initialization
htl/Versions | 4 +-
htl/libpthread_syms.a | 2 +-
htl/pt-create.c | 12 ++-
htl/pt-internal.h | 3 +
hurd/Versions | 3 -
hurd/hurdinit.c | 36 ++++---
sysdeps/htl/pt-attr-getstackaddr.c | 2 +-
sysdeps/htl/pt-attr-getstacksize.c | 2 +-
sysdeps/htl/pt-attr-setstack.c | 2 +-
sysdeps/htl/pt-attr-setstackaddr.c | 2 +-
sysdeps/htl/pt-attr-setstacksize.c | 2 +-
sysdeps/hurd/include/hurd.h | 3 +
sysdeps/mach/hurd/htl/pt-sysdep.c | 19 +---
sysdeps/mach/hurd/i386/init-first.c | 109 ++++++----------------
sysdeps/mach/hurd/i386/libc.abilist | 1 -
sysdeps/mach/hurd/i386/libpthread.abilist | 1 -
sysdeps/mach/i386/sysdep.h | 10 --
sysdeps/mach/sysdep.h | 8 --
18 files changed, 81 insertions(+), 140 deletions(-)
--
2.28.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [hurd,commited 1/4] htl: Fix spurious symbols in namespaces
2020-11-11 20:43 [hurd,commited 0/4] Fix more hurd initialization for ifunc support Samuel Thibault
@ 2020-11-11 20:43 ` Samuel Thibault
2020-11-11 20:43 ` [hurd, commited 2/4] htl: Keep thread signals blocked during its initialization Samuel Thibault
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Samuel Thibault @ 2020-11-11 20:43 UTC (permalink / raw)
To: libc-alpha; +Cc: Samuel Thibault, commit-hurd
pthread_attr_{{get,set}stack{addr,size},setstack} were defining a strong alias
for no reason, turning them to weak.
---
sysdeps/htl/pt-attr-getstackaddr.c | 2 +-
sysdeps/htl/pt-attr-getstacksize.c | 2 +-
sysdeps/htl/pt-attr-setstack.c | 2 +-
sysdeps/htl/pt-attr-setstackaddr.c | 2 +-
sysdeps/htl/pt-attr-setstacksize.c | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/sysdeps/htl/pt-attr-getstackaddr.c b/sysdeps/htl/pt-attr-getstackaddr.c
index a35a940578..663cd02b41 100644
--- a/sysdeps/htl/pt-attr-getstackaddr.c
+++ b/sysdeps/htl/pt-attr-getstackaddr.c
@@ -25,4 +25,4 @@ __pthread_attr_getstackaddr (const pthread_attr_t *attr, void **stackaddr)
*stackaddr = attr->__stackaddr;
return 0;
}
-strong_alias (__pthread_attr_getstackaddr, pthread_attr_getstackaddr)
+weak_alias (__pthread_attr_getstackaddr, pthread_attr_getstackaddr)
diff --git a/sysdeps/htl/pt-attr-getstacksize.c b/sysdeps/htl/pt-attr-getstacksize.c
index e4f6f68186..0fc61662a5 100644
--- a/sysdeps/htl/pt-attr-getstacksize.c
+++ b/sysdeps/htl/pt-attr-getstacksize.c
@@ -25,4 +25,4 @@ __pthread_attr_getstacksize (const pthread_attr_t *attr, size_t * stacksize)
*stacksize = attr->__stacksize;
return 0;
}
-strong_alias (__pthread_attr_getstacksize, pthread_attr_getstacksize)
+weak_alias (__pthread_attr_getstacksize, pthread_attr_getstacksize)
diff --git a/sysdeps/htl/pt-attr-setstack.c b/sysdeps/htl/pt-attr-setstack.c
index 3c7a7e69b1..56e8ee87c1 100644
--- a/sysdeps/htl/pt-attr-setstack.c
+++ b/sysdeps/htl/pt-attr-setstack.c
@@ -47,4 +47,4 @@ __pthread_attr_setstack (pthread_attr_t *attr, void *stackaddr, size_t stacksize
return 0;
}
-strong_alias (__pthread_attr_setstack, pthread_attr_setstack)
+weak_alias (__pthread_attr_setstack, pthread_attr_setstack)
diff --git a/sysdeps/htl/pt-attr-setstackaddr.c b/sysdeps/htl/pt-attr-setstackaddr.c
index 57d03ce269..7d09047929 100644
--- a/sysdeps/htl/pt-attr-setstackaddr.c
+++ b/sysdeps/htl/pt-attr-setstackaddr.c
@@ -25,4 +25,4 @@ __pthread_attr_setstackaddr (pthread_attr_t *attr, void *stackaddr)
attr->__stackaddr = stackaddr;
return 0;
}
-strong_alias (__pthread_attr_setstackaddr, pthread_attr_setstackaddr)
+weak_alias (__pthread_attr_setstackaddr, pthread_attr_setstackaddr)
diff --git a/sysdeps/htl/pt-attr-setstacksize.c b/sysdeps/htl/pt-attr-setstacksize.c
index a82ac68aca..b1cbcdb636 100644
--- a/sysdeps/htl/pt-attr-setstacksize.c
+++ b/sysdeps/htl/pt-attr-setstacksize.c
@@ -25,4 +25,4 @@ __pthread_attr_setstacksize (pthread_attr_t *attr, size_t stacksize)
attr->__stacksize = stacksize;
return 0;
}
-strong_alias (__pthread_attr_setstacksize, pthread_attr_setstacksize)
+weak_alias (__pthread_attr_setstacksize, pthread_attr_setstacksize)
--
2.28.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [hurd, commited 2/4] htl: Keep thread signals blocked during its initialization
2020-11-11 20:43 [hurd,commited 0/4] Fix more hurd initialization for ifunc support Samuel Thibault
2020-11-11 20:43 ` [hurd,commited 1/4] htl: Fix spurious symbols in namespaces Samuel Thibault
@ 2020-11-11 20:43 ` Samuel Thibault
2020-11-11 20:43 ` [hurd,commited 3/4] htl: Initialize later Samuel Thibault
2020-11-11 20:43 ` [hurd, commited 4/4] hurd: Notify the proc server later during initialization Samuel Thibault
3 siblings, 0 replies; 5+ messages in thread
From: Samuel Thibault @ 2020-11-11 20:43 UTC (permalink / raw)
To: libc-alpha; +Cc: Samuel Thibault, commit-hurd
One may send signals immediately after creating a thread. We need to block them
until the thread is ready to run signal handlers.
---
htl/pt-create.c | 12 ++++++++++--
htl/pt-internal.h | 3 +++
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/htl/pt-create.c b/htl/pt-create.c
index 7ac875cbf7..9364c40453 100644
--- a/htl/pt-create.c
+++ b/htl/pt-create.c
@@ -46,6 +46,8 @@ unsigned int __pthread_total;
static void
entry_point (struct __pthread *self, void *(*start_routine) (void *), void *arg)
{
+ int err;
+
___pthread_self = self;
__resp = &self->res_state;
@@ -60,6 +62,10 @@ entry_point (struct __pthread *self, void *(*start_routine) (void *), void *arg)
__pthread_startup ();
+ /* We can now unleash signals. */
+ err = __pthread_sigstate (self, SIG_SETMASK, &self->init_sigset, 0, 0);
+ assert_perror (err);
+
if (self->c11)
{
/* The function pointer of the c11 thread start is cast to an incorrect
@@ -201,11 +207,13 @@ __pthread_create_internal (struct __pthread **thread,
shall be empty." If the currnet thread is not a pthread then we
just inherit the process' sigmask. */
if (__pthread_num_threads == 1)
- err = __sigprocmask (0, 0, &sigset);
+ err = __sigprocmask (0, 0, &pthread->init_sigset);
else
- err = __pthread_sigstate (_pthread_self (), 0, 0, &sigset, 0);
+ err = __pthread_sigstate (_pthread_self (), 0, 0, &pthread->init_sigset, 0);
assert_perror (err);
+ /* But block the signals for now, until the thread is fully initialized. */
+ __sigfillset (&sigset);
err = __pthread_sigstate (pthread, SIG_SETMASK, &sigset, 0, 1);
assert_perror (err);
diff --git a/htl/pt-internal.h b/htl/pt-internal.h
index e0baa6bcda..9dffa0e32e 100644
--- a/htl/pt-internal.h
+++ b/htl/pt-internal.h
@@ -102,6 +102,9 @@ struct __pthread
/* Indicates whether is a C11 thread created by thrd_creat. */
bool c11;
+ /* Initial sigset for the thread. */
+ sigset_t init_sigset;
+
/* Thread context. */
struct pthread_mcontext mcontext;
--
2.28.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [hurd,commited 3/4] htl: Initialize later
2020-11-11 20:43 [hurd,commited 0/4] Fix more hurd initialization for ifunc support Samuel Thibault
2020-11-11 20:43 ` [hurd,commited 1/4] htl: Fix spurious symbols in namespaces Samuel Thibault
2020-11-11 20:43 ` [hurd, commited 2/4] htl: Keep thread signals blocked during its initialization Samuel Thibault
@ 2020-11-11 20:43 ` Samuel Thibault
2020-11-11 20:43 ` [hurd, commited 4/4] hurd: Notify the proc server later during initialization Samuel Thibault
3 siblings, 0 replies; 5+ messages in thread
From: Samuel Thibault @ 2020-11-11 20:43 UTC (permalink / raw)
To: libc-alpha; +Cc: Samuel Thibault, commit-hurd
Since htl does not actually need a stack switch, we can initialize it
like nptl is, avoiding all sorts of startup issues with ifunc.
More precisely, htl defines __pthread_initialize_minimal instead of the
elder _cthread_init_routine. We can then drop the stack switching dances.
---
htl/Versions | 4 +-
htl/libpthread_syms.a | 2 +-
hurd/Versions | 3 -
sysdeps/mach/hurd/htl/pt-sysdep.c | 19 +---
sysdeps/mach/hurd/i386/init-first.c | 106 +++++-----------------
sysdeps/mach/hurd/i386/libc.abilist | 1 -
sysdeps/mach/hurd/i386/libpthread.abilist | 1 -
sysdeps/mach/i386/sysdep.h | 10 --
sysdeps/mach/sysdep.h | 8 --
9 files changed, 32 insertions(+), 122 deletions(-)
diff --git a/htl/Versions b/htl/Versions
index 832cc5d814..4e23c2ed64 100644
--- a/htl/Versions
+++ b/htl/Versions
@@ -43,8 +43,6 @@ libpthread {
__pthread_mutex_transfer_np;
- _cthread_init_routine;
-
cthread_detach;
cthread_fork;
cthread_keycreate;
@@ -168,6 +166,8 @@ libpthread {
}
GLIBC_PRIVATE {
+ __pthread_initialize_minimal;
+
__shm_directory;
__pthread_threads;
diff --git a/htl/libpthread_syms.a b/htl/libpthread_syms.a
index 3801ec93c8..48dadfbd5f 100644
--- a/htl/libpthread_syms.a
+++ b/htl/libpthread_syms.a
@@ -1,6 +1,6 @@
/* pthread initializer is weak in glibc. It must be included if glibc
is to start threading. */
-EXTERN(_cthread_init_routine)
+EXTERN(__pthread_initialize_minimal)
/* Weak references in glibc that must be filled if glibc is to be
thread safe. */
diff --git a/hurd/Versions b/hurd/Versions
index 9b5448ab2f..aa27f0f098 100644
--- a/hurd/Versions
+++ b/hurd/Versions
@@ -143,9 +143,6 @@ libc {
__cthread_fork; __cthread_detach;
__pthread_getattr_np; __pthread_attr_getstack;
- # variables used for detecting cthreads
- _cthread_exit_routine; _cthread_init_routine;
-
# cthreads functions with stubs in libc
__cthread_keycreate; __cthread_getspecific; __cthread_setspecific;
}
diff --git a/sysdeps/mach/hurd/htl/pt-sysdep.c b/sysdeps/mach/hurd/htl/pt-sysdep.c
index 0963b44878..8ca549dd73 100644
--- a/sysdeps/mach/hurd/htl/pt-sysdep.c
+++ b/sysdeps/mach/hurd/htl/pt-sysdep.c
@@ -28,13 +28,6 @@
__thread struct __pthread *___pthread_self;
-/* Forward. */
-static void *init_routine (void);
-
-/* OK, the name of this variable isn't really appropriate, but I don't
- want to change it yet. */
-void *(*_cthread_init_routine) (void) = &init_routine;
-
static void
reset_pthread_total (void)
{
@@ -45,7 +38,7 @@ reset_pthread_total (void)
/* This function is called from the Hurd-specific startup code. It
should return a new stack pointer for the main thread. The caller
will switch to this new stack before doing anything serious. */
-static void *
+static void
_init_routine (void *stack)
{
struct __pthread *thread;
@@ -54,7 +47,7 @@ _init_routine (void *stack)
if (__pthread_threads != NULL)
/* Already initialized */
- return 0;
+ return;
/* Initialize the library. */
___pthread_init ();
@@ -96,14 +89,12 @@ _init_routine (void *stack)
/* Make MiG code thread aware. */
__mig_init (thread->stackaddr);
-
- return thread->mcontext.sp;
}
-static void *
-init_routine (void)
+void
+__pthread_initialize_minimal (void)
{
- return _init_routine (0);
+ _init_routine (__libc_stack_end);
}
#ifdef SHARED
diff --git a/sysdeps/mach/hurd/i386/init-first.c b/sysdeps/mach/hurd/i386/init-first.c
index 5e66602d4b..6c35dc8104 100644
--- a/sysdeps/mach/hurd/i386/init-first.c
+++ b/sysdeps/mach/hurd/i386/init-first.c
@@ -46,9 +46,6 @@ extern int __libc_argc attribute_hidden;
extern char **__libc_argv attribute_hidden;
extern char **_dl_argv;
-extern void *(*_cthread_init_routine) (void) __attribute__ ((weak));
-void (*_cthread_exit_routine) (int status) __attribute__ ((__noreturn__));
-
/* Things that want to be run before _hurd_init or much anything else.
Importantly, these are called before anything tries to use malloc. */
DEFINE_HOOK (_hurd_preinit_hook, (void));
@@ -96,10 +93,6 @@ init1 (int argc, char *arg0, ...)
++envp;
d = (void *) ++envp;
- /* Initialize libpthread if linked in. */
- if (__pthread_initialize_minimal != NULL)
- __pthread_initialize_minimal ();
-
if ((void *) d == argv[0])
/* No Hurd data block to process. */
return;
@@ -145,7 +138,6 @@ init (int *data)
int argc = *data;
char **argv = (void *) (data + 1);
char **envp = &argv[argc + 1];
- struct hurd_startup_data *d;
/* Since the cthreads initialization code uses malloc, and the
malloc initialization code needs to get at the environment, make
@@ -154,11 +146,13 @@ init (int *data)
stored. */
__environ = envp;
+#ifndef SHARED
+ struct hurd_startup_data *d;
+
while (*envp)
++envp;
d = (void *) ++envp;
-#ifndef SHARED
/* If we are the bootstrap task started by the kernel,
then after the environment pointers there is no Hurd
data block; the argument strings start there. */
@@ -190,79 +184,27 @@ init (int *data)
__libc_setup_tls ();
#endif
- /* After possibly switching stacks, call `init1' (above) with the user
- code as the return address, and the argument data immediately above
- that on the stack. */
-
- if (&_cthread_init_routine && _cthread_init_routine)
- {
- /* Initialize cthreads, which will allocate us a new stack to run on. */
- int *newsp = (*_cthread_init_routine) ();
- struct hurd_startup_data *od;
-
- void switch_stacks (void);
-
- __libc_stack_end = newsp;
-
- /* Copy the argdata from the old stack to the new one. */
- newsp = memcpy (newsp - ((char *) &d[1] - (char *) data), data,
- (char *) d - (char *) data);
-
-#ifdef SHARED
- /* And readjust the dynamic linker's idea of where the argument
- vector lives. */
- assert (_dl_argv == argv);
- _dl_argv = (void *) (newsp + 1);
-#endif
-
- /* Set up the Hurd startup data block immediately following
- the argument and environment pointers on the new stack. */
- od = ((void *) newsp + ((char *) d - (char *) data));
- if ((void *) argv[0] == d)
- /* We were started up by the kernel with arguments on the stack.
- There is no Hurd startup data, so zero the block. */
- memset (od, 0, sizeof *od);
- else
- /* Copy the Hurd startup data block to the new stack. */
- *od = *d;
-
- /* Push the user code address on the top of the new stack. It will
- be the return address for `init1'; we will jump there with NEWSP
- as the stack pointer. */
- /* The following expression would typically be written as
- ``__builtin_return_address (0)''. But, for example, GCC 4.4.6 doesn't
- recognize that this read operation may alias the following write
- operation, and thus is free to reorder the two, clobbering the
- original return address. */
- *--newsp = *((int *) __builtin_frame_address (0) + 1);
- /* GCC 4.4.6 also wants us to force loading *NEWSP already here. */
- asm volatile ("# %0" : : "X" (*newsp));
- *((void **) __builtin_frame_address (0) + 1) = &switch_stacks;
- /* Force NEWSP into %eax and &init1 into %ecx, which are not restored
- by function return. */
- asm volatile ("# a %0 c %1" : : "a" (newsp), "c" (&init1));
- }
- else
- {
- int usercode;
-
- void call_init1 (void);
-
- /* The argument data is just above the stack frame we will unwind by
- returning. Mutate our own return address to run the code below. */
- /* The following expression would typically be written as
- ``__builtin_return_address (0)''. But, for example, GCC 4.4.6 doesn't
- recognize that this read operation may alias the following write
- operation, and thus is free to reorder the two, clobbering the
- original return address. */
- usercode = *((int *) __builtin_frame_address (0) + 1);
- /* GCC 4.4.6 also wants us to force loading USERCODE already here. */
- asm volatile ("# %0" : : "X" (usercode));
- *((void **) __builtin_frame_address (0) + 1) = &call_init1;
- /* Force USERCODE into %eax and &init1 into %ecx, which are not
- restored by function return. */
- asm volatile ("# a %0 c %1" : : "a" (usercode), "c" (&init1));
- }
+ /* Call `init1' (above) with the user code as the return address, and the
+ argument data immediately above that on the stack. */
+
+ int usercode;
+
+ void call_init1 (void);
+
+ /* The argument data is just above the stack frame we will unwind by
+ returning. Mutate our own return address to run the code below. */
+ /* The following expression would typically be written as
+ ``__builtin_return_address (0)''. But, for example, GCC 4.4.6 doesn't
+ recognize that this read operation may alias the following write
+ operation, and thus is free to reorder the two, clobbering the
+ original return address. */
+ usercode = *((int *) __builtin_frame_address (0) + 1);
+ /* GCC 4.4.6 also wants us to force loading USERCODE already here. */
+ asm volatile ("# %0" : : "X" (usercode));
+ *((void **) __builtin_frame_address (0) + 1) = &call_init1;
+ /* Force USERCODE into %eax and &init1 into %ecx, which are not
+ restored by function return. */
+ asm volatile ("# a %0 c %1" : : "a" (usercode), "c" (&init1));
DIAG_POP_NEEDS_COMMENT; /* -Warray-bounds. */
}
diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist
index e2ff0e8b9e..7a5eb66b85 100644
--- a/sysdeps/mach/hurd/i386/libc.abilist
+++ b/sysdeps/mach/hurd/i386/libc.abilist
@@ -2333,4 +2333,3 @@ HURD_CTHREADS_0.3 __spin_lock_init F
HURD_CTHREADS_0.3 __spin_lock_solid F
HURD_CTHREADS_0.3 __spin_try_lock F
HURD_CTHREADS_0.3 __spin_unlock F
-HURD_CTHREADS_0.3 _cthread_exit_routine D 0x4
diff --git a/sysdeps/mach/hurd/i386/libpthread.abilist b/sysdeps/mach/hurd/i386/libpthread.abilist
index a1e0a7183b..b9c9b75c28 100644
--- a/sysdeps/mach/hurd/i386/libpthread.abilist
+++ b/sysdeps/mach/hurd/i386/libpthread.abilist
@@ -10,7 +10,6 @@ GLIBC_2.12 __pthread_spin_init F
GLIBC_2.12 __pthread_spin_lock F
GLIBC_2.12 __pthread_spin_trylock F
GLIBC_2.12 __pthread_spin_unlock F
-GLIBC_2.12 _cthread_init_routine D 0x4
GLIBC_2.12 _cthreads_flockfile F
GLIBC_2.12 _cthreads_ftrylockfile F
GLIBC_2.12 _cthreads_funlockfile F
diff --git a/sysdeps/mach/i386/sysdep.h b/sysdeps/mach/i386/sysdep.h
index e849f120f9..c132b3a4c3 100644
--- a/sysdeps/mach/i386/sysdep.h
+++ b/sysdeps/mach/i386/sysdep.h
@@ -39,16 +39,6 @@
envp = p; \
} while (0)
-#define CALL_WITH_SP(fn, info, sp) \
- do { \
- void **ptr = (void **) sp; \
- *--(__typeof (info) *) ptr = info; \
- ptr[-1] = ptr; \
- --ptr; \
- asm volatile ("movl %0, %%esp; call %1" : : \
- "g" (ptr), "m" (*(long int *) (fn)) : "%esp"); \
- } while (0)
-
#define RETURN_TO(sp, pc, retval) \
asm volatile ("movl %0, %%esp; jmp %*%1 # %2" \
: : "g" (sp), "r" (pc), "a" (retval))
diff --git a/sysdeps/mach/sysdep.h b/sysdeps/mach/sysdep.h
index ba65015253..13ea04d980 100644
--- a/sysdeps/mach/sysdep.h
+++ b/sysdeps/mach/sysdep.h
@@ -62,14 +62,6 @@
#error SNARF_ARGS not defined by sysdeps/mach/MACHINE/sysdep.h
#endif
-/* Call the C function FN with no arguments,
- on a stack starting at SP (as returned by *_cthread_init_routine).
- You don't need to deal with FN returning; it shouldn't. */
-#ifndef CALL_WITH_SP
-#define CALL_WITH_SP(fn, sp)
-#error CALL_WITH_SP not defined by sysdeps/mach/MACHINE/sysdep.h
-#endif
-
/* LOSE can be defined as the `halt' instruction or something
similar which will cause the process to die in a characteristic
way suggesting a bug. */
--
2.28.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [hurd, commited 4/4] hurd: Notify the proc server later during initialization
2020-11-11 20:43 [hurd,commited 0/4] Fix more hurd initialization for ifunc support Samuel Thibault
` (2 preceding siblings ...)
2020-11-11 20:43 ` [hurd,commited 3/4] htl: Initialize later Samuel Thibault
@ 2020-11-11 20:43 ` Samuel Thibault
3 siblings, 0 replies; 5+ messages in thread
From: Samuel Thibault @ 2020-11-11 20:43 UTC (permalink / raw)
To: libc-alpha; +Cc: Samuel Thibault, commit-hurd
Notifying the proc server is an involved task, and unleashes various signal
handling etc. so we have to do this after e.g. ifunc relocations are
completed.
---
hurd/hurdinit.c | 36 ++++++++++++++++++++---------
sysdeps/hurd/include/hurd.h | 3 +++
sysdeps/mach/hurd/i386/init-first.c | 3 +++
3 files changed, 31 insertions(+), 11 deletions(-)
diff --git a/hurd/hurdinit.c b/hurd/hurdinit.c
index a884b78de6..e4ec005b48 100644
--- a/hurd/hurdinit.c
+++ b/hurd/hurdinit.c
@@ -34,6 +34,10 @@ sigset_t _hurdsig_traced;
char **__libc_argv;
int __libc_argc;
+static int *_hurd_intarray;
+static size_t _hurd_intarraysize;
+static mach_port_t *_hurd_portarray;
+static size_t _hurd_portarraysize;
error_t
_hurd_ports_use (int which, error_t (*operate) (mach_port_t))
@@ -87,17 +91,10 @@ _hurd_init (int flags, char **argv,
if (intarraysize > INIT_TRACEMASK)
_hurdsig_traced = intarray[INIT_TRACEMASK];
- /* Tell the proc server we exist, if it does. */
- if (portarray[INIT_PORT_PROC] != MACH_PORT_NULL)
- _hurd_new_proc_init (argv, intarray, intarraysize);
-
- /* All done with init ints and ports. */
- __vm_deallocate (__mach_task_self (),
- (vm_address_t) intarray,
- intarraysize * sizeof (int));
- __vm_deallocate (__mach_task_self (),
- (vm_address_t) portarray,
- portarraysize * sizeof (mach_port_t));
+ _hurd_intarray = intarray;
+ _hurd_intarraysize = intarraysize;
+ _hurd_portarray = portarray;
+ _hurd_portarraysize = portarraysize;
if (flags & EXEC_SECURE)
{
@@ -113,6 +110,23 @@ _hurd_init (int flags, char **argv,
RUN_HOOK (_hurd_subinit, ());
}
libc_hidden_def (_hurd_init)
+
+void
+_hurd_libc_proc_init (char **argv)
+{
+ /* Tell the proc server we exist, if it does. */
+ if (_hurd_portarray[INIT_PORT_PROC] != MACH_PORT_NULL)
+ _hurd_new_proc_init (argv, _hurd_intarray, _hurd_intarraysize);
+
+ /* All done with init ints and ports. */
+ __vm_deallocate (__mach_task_self (),
+ (vm_address_t) _hurd_intarray,
+ _hurd_intarraysize * sizeof (int));
+ __vm_deallocate (__mach_task_self (),
+ (vm_address_t) _hurd_portarray,
+ _hurd_portarraysize * sizeof (mach_port_t));
+}
+libc_hidden_def (_hurd_libc_proc_init)
\f
#include <hurd/signal.h>
diff --git a/sysdeps/hurd/include/hurd.h b/sysdeps/hurd/include/hurd.h
index dc877173b5..7da9af2656 100644
--- a/sysdeps/hurd/include/hurd.h
+++ b/sysdeps/hurd/include/hurd.h
@@ -1,6 +1,8 @@
#ifndef _HURD_H
#include_next <hurd.h>
+void _hurd_libc_proc_init (char **argv);
+
/* Like __USEPORT, but cleans fd on cancel. */
#define __USEPORT_CANCEL(which, expr) \
HURD_PORT_USE_CANCEL (&_hurd_ports[INIT_PORT_##which], (expr))
@@ -8,5 +10,6 @@
#ifndef _ISOMAC
libc_hidden_proto (_hurd_exec_paths)
libc_hidden_proto (_hurd_init)
+libc_hidden_proto (_hurd_libc_proc_init)
#endif
#endif
diff --git a/sysdeps/mach/hurd/i386/init-first.c b/sysdeps/mach/hurd/i386/init-first.c
index 6c35dc8104..a3d2fdaba0 100644
--- a/sysdeps/mach/hurd/i386/init-first.c
+++ b/sysdeps/mach/hurd/i386/init-first.c
@@ -63,6 +63,9 @@ posixland_init (int argc, char **argv, char **envp)
{
/* Set the FPU control word to the proper default value. */
__setfpucw (__fpu_control);
+
+ /* Now we have relocations etc. we can start signals etc. */
+ _hurd_libc_proc_init (argv);
}
else
{
--
2.28.0
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-11-11 20:43 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-11 20:43 [hurd,commited 0/4] Fix more hurd initialization for ifunc support Samuel Thibault
2020-11-11 20:43 ` [hurd,commited 1/4] htl: Fix spurious symbols in namespaces Samuel Thibault
2020-11-11 20:43 ` [hurd, commited 2/4] htl: Keep thread signals blocked during its initialization Samuel Thibault
2020-11-11 20:43 ` [hurd,commited 3/4] htl: Initialize later Samuel Thibault
2020-11-11 20:43 ` [hurd, commited 4/4] hurd: Notify the proc server later during initialization Samuel Thibault
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).