summaryrefslogtreecommitdiff
path: root/sysdeps/mach/hurd/i386/init-first.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1999-07-28 18:19:47 +0000
committerRoland McGrath <roland@gnu.org>1999-07-28 18:19:47 +0000
commit83ddec31c69ac3dd3a6c83db8155ac1c63b13178 (patch)
tree578caa1d634b31d2ac66c3fd4bbe443857b10eb7 /sysdeps/mach/hurd/i386/init-first.c
parent7396d8440b5278c504aa6b1b5ffda53a0d2f98b6 (diff)
1999-07-27 Mark Kettenis <kettenis@gnu.org>
* sysdeps/mach/hurd/i386/init-first.c (init): Move the inline assembler code to switch stacks and call init1 outside this function. Inside `init' the code was optimized away by gcc 2.95 since it was "clearly" unreachable. * sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler): Do something similar for the trampoline code.
Diffstat (limited to 'sysdeps/mach/hurd/i386/init-first.c')
-rw-r--r--sysdeps/mach/hurd/i386/init-first.c56
1 files changed, 33 insertions, 23 deletions
diff --git a/sysdeps/mach/hurd/i386/init-first.c b/sysdeps/mach/hurd/i386/init-first.c
index c18b6a82ac..ee7b90252b 100644
--- a/sysdeps/mach/hurd/i386/init-first.c
+++ b/sysdeps/mach/hurd/i386/init-first.c
@@ -1,5 +1,5 @@
/* Initialization code run first thing by the ELF startup code. For i386/Hurd.
- Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1995, 96, 97, 98, 99 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -157,6 +157,8 @@ init (int *data)
void *newsp = (*_cthread_init_routine) ();
struct hurd_startup_data *od;
+ void switch_stacks (void);
+
/* Copy per-thread variables from that temporary
area onto the new cthread stack. */
memcpy (__hurd_threadvar_location_from_sp (0, newsp),
@@ -181,7 +183,7 @@ init (int *data)
be the return address for `init1'; we will jump there with NEWSP
as the stack pointer. */
*--(int *) newsp = data[-1];
- ((void **) data)[-1] = &&switch_stacks;
+ ((void **) data)[-1] = switch_stacks;
/* Force NEWSP into %ecx and &init1 into %eax, which are not restored
by function return. */
asm volatile ("# a %0 c %1" : : "a" (newsp), "c" (&init1));
@@ -194,6 +196,8 @@ init (int *data)
unsigned int i;
int usercode;
+ void call_init1 (void);
+
array = malloc (__hurd_threadvar_max * sizeof (unsigned long int));
if (array == NULL)
__libc_fatal ("Can't allocate single-threaded thread variables.");
@@ -208,33 +212,39 @@ init (int *data)
/* The argument data is just above the stack frame we will unwind by
returning. Mutate our own return address to run the code below. */
usercode = data[-1];
- ((void **) data)[-1] = &&call_init1;
+ ((void **) data)[-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));
}
+}
- return;
-
+/* These bits of inline assembler used to be located inside `init'.
+ However they were optimized away by gcc 2.95. */
+
+/* The return address of `init' above, was redirected to here, so at
+ this point our stack is unwound and callers' registers restored.
+ Only %ecx and %eax are call-clobbered and thus still have the
+ values we set just above. Fetch from there the new stack pointer
+ we will run on, and jmp to the run-time address of `init1'; when it
+ returns, it will run the user code with the argument data at the
+ top of the stack. */
+asm ("
switch_stacks:
- /* Our return address was redirected to here, so at this point our stack
- is unwound and callers' registers restored. Only %ecx and %eax are
- call-clobbered and thus still have the values we set just above.
- Fetch from there the new stack pointer we will run on, and jmp to the
- run-time address of `init1'; when it returns, it will run the user
- code with the argument data at the top of the stack. */
- asm volatile ("movl %eax, %esp; jmp *%ecx");
- /* NOTREACHED */
-
- call_init1:
- /* As in the stack-switching case, at this point our stack is unwound and
- callers' registers restored, and only %ecx and %eax communicate values
- from the lines above. In this case we have stashed in %eax the user
- code return address. Push it on the top of the stack so it acts as
- init1's return address, and then jump there. */
- asm volatile ("pushl %eax; jmp *%ecx");
- /* NOTREACHED */
-}
+ movl %eax, %esp
+ jmp *%ecx
+");
+
+/* As in the stack-switching case, at this point our stack is unwound
+ and callers' registers restored, and only %ecx and %eax communicate
+ values from the lines above. In this case we have stashed in %eax
+ the user code return address. Push it on the top of the stack so
+ it acts as init1's return address, and then jump there. */
+asm ("
+ call_init1:
+ push %eax
+ jmp *%ecx
+");
#ifdef PIC