diff options
author | Roland McGrath <roland@gnu.org> | 1995-07-10 09:40:15 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 1995-07-10 09:40:15 +0000 |
commit | d819080cbadbd4b820ba77fe8c9b5ed0cbbfe581 (patch) | |
tree | d6c0ef96e616a594bba04e704d0042365e5a77ab /sysdeps/mach/hurd | |
parent | 1f4a4317e1bafb185a22951f7921af4f9673811e (diff) | |
download | glibc-d819080cbadbd4b820ba77fe8c9b5ed0cbbfe581.tar.gz |
Mon Jul 10 05:39:21 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* sysdeps/mach/hurd/i386/init-first.c (init): Take just one arg,
DATA for the entry SP; DATA[-1] is always the return address
location. In both cthreads and non-cthreads cases, use asm to
force parameters into %eax and %ecx before return, and mutate
DATA[-1] to return to specific asm code to set up the user from
%eax and %ecx.
[PIC] (_init): Caller changed.
(__libc_init_first) [! PIC] (doinit): Use asm to effect call to init
with SP unwound to argument data ptr.
Thu Jul 6 14:28:56 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* sysdeps/mach/hurd/dl-sysdep.c (fmh): Fixed this kludge to work
when 0x08000000 and up are not mapped.
* Makerules (stamp$o-$(subdir) rule): Remove the timestamp file
before touching it.
(lib%.so): Use -Wl to get -soname to ld.
* elf/dlsym.c: Pass final arg to _dl_lookup_symbol.
* elf/Makefile (libdl.so): Pass $(LDFLAGS.so).
Diffstat (limited to 'sysdeps/mach/hurd')
-rw-r--r-- | sysdeps/mach/hurd/dl-sysdep.c | 5 | ||||
-rw-r--r-- | sysdeps/mach/hurd/i386/init-first.c | 85 |
2 files changed, 53 insertions, 37 deletions
diff --git a/sysdeps/mach/hurd/dl-sysdep.c b/sysdeps/mach/hurd/dl-sysdep.c index 471c3d1ed3..8f303bf6bb 100644 --- a/sysdeps/mach/hurd/dl-sysdep.c +++ b/sysdeps/mach/hurd/dl-sysdep.c @@ -61,14 +61,15 @@ static void fmh() { while (!(err=__vm_region(__mach_task_self(),&a,&fmhs,&x,&x,&x,&x,&p,&x))){ __mach_port_deallocate(__mach_task_self(),p); if (a+fmhs>=0x80000000U){ - max=a;break;} + max=a; break;} fmha=a+=fmhs;} if (err) assert(err==KERN_NO_SPACE); + if (!fmha)fmhs=0;else{ fmhs=max-fmha; err = __vm_map (__mach_task_self (), &fmha, fmhs, 0, 0, MACH_PORT_NULL, 0, 1, VM_PROT_NONE, VM_PROT_NONE, VM_INHERIT_COPY); - assert_perror(err); + assert_perror(err);} } /* XXX loser kludge for vm_map kernel bug */ diff --git a/sysdeps/mach/hurd/i386/init-first.c b/sysdeps/mach/hurd/i386/init-first.c index 74b15c8f2f..a23d201e58 100644 --- a/sysdeps/mach/hurd/i386/init-first.c +++ b/sysdeps/mach/hurd/i386/init-first.c @@ -96,7 +96,7 @@ init1 (int argc, char *arg0, ...) } static void -init (int *data, void *usercode, void **retaddrloc) +init (int *data) { int argc = *data; char **argv = (void *) (data + 1); @@ -144,42 +144,43 @@ init (int *data, void *usercode, void **retaddrloc) /* 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. */ - *--(void **) newsp = usercode; - /* Mutate our own return address to run the code below. */ - *retaddrloc = &&switch_stacks; + *--(int *) newsp = data[-1]; + ((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" (&init1), "c" (newsp)); - return; - 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 %ecx, %esp; jmp *%eax"); - /* NOTREACHED */ - } + by function return. */ + asm volatile ("# a %0 c %1" : : "a" (newsp), "c" (&init1)); + } else { - /* We are not switching stacks, but we must play some games with - the one we've got, similar to the stack-switching code above. */ - *retaddrloc = &&call_init1; - /* Force the user code address into %ecx and the run-time address of - `init1' into %eax, for use below. */ - asm volatile ("# a %0 c %1" : : "a" (&init1), "c" (usercode)); - return; - 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 %ecx 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 %ecx; jmp *%eax"); - /* NOTREACHED */ + /* The argument data is just above the stack frame we will unwind by + returning. Mutate our own return address to run the code below. */ + int usercode = data[-1]; + ((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; + + 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 */ } @@ -202,7 +203,7 @@ _init (int argc, ...) RUN_HOOK (_hurd_preinit_hook, ()); - init (&argc, ((void **) &argc)[-1], &((void **) &argc)[-1]); + init (&argc); } #endif @@ -213,7 +214,21 @@ __libc_init_first (int argc __attribute__ ((unused)), ...) #ifndef PIC void doinit (int *data) { - init (data, ((void **) &argc)[-1], &((void **) &data)[-1]); + /* This function gets called with the argument data at TOS. */ + void doinit1 (int argc, ...) + { + init (&argc); + } + + /* Push the user return address after the argument data, and then + jump to `doinit1' (above), so it is as if __libc_init_first's + caller had called `doinit1' with the argument data already on the + stack. */ + *--data = (&argc)[-1]; + asm volatile ("movl %0, %%esp\n" /* Switch to new outermost stack. */ + "movl $0, %%ebp\n" /* Clear outermost frame pointer. */ + "jmp *%1" : : "r" (data), "r" (&doinit1)); + /* NOTREACHED */ } /* Initialize data structures so we can do RPCs. */ |