aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1995-07-10 09:40:15 +0000
committerRoland McGrath <roland@gnu.org>1995-07-10 09:40:15 +0000
commitd819080cbadbd4b820ba77fe8c9b5ed0cbbfe581 (patch)
treed6c0ef96e616a594bba04e704d0042365e5a77ab
parent1f4a4317e1bafb185a22951f7921af4f9673811e (diff)
downloadglibc-d819080cbadbd4b820ba77fe8c9b5ed0cbbfe581.tar
glibc-d819080cbadbd4b820ba77fe8c9b5ed0cbbfe581.tar.gz
glibc-d819080cbadbd4b820ba77fe8c9b5ed0cbbfe581.tar.bz2
glibc-d819080cbadbd4b820ba77fe8c9b5ed0cbbfe581.zip
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).
-rw-r--r--ChangeLog25
-rw-r--r--Makerules6
-rw-r--r--elf/dlsym.c2
-rw-r--r--sysdeps/mach/hurd/dl-sysdep.c5
-rw-r--r--sysdeps/mach/hurd/i386/init-first.c85
5 files changed, 83 insertions, 40 deletions
diff --git a/ChangeLog b/ChangeLog
index b133e7589e..795c4cbb90 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+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).
+
Tue Jun 20 02:18:19 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* Makerules (lib%.so: lib%_pic.a): Pass -soname switch giving the
diff --git a/Makerules b/Makerules
index c6de338570..b39cea2bea 100644
--- a/Makerules
+++ b/Makerules
@@ -379,6 +379,8 @@ $(foreach o,$(object-suffixes),$(objpfx)stamp$o-$(subdir)): \
$(patsubst %,cd %;,$(objdir)) \
$(AR) cru$(verbose) ${O%-lib} \
$(patsubst $(objpfx)%,%,$^)
+# `touch' won't let me touch a world-writable file I don't own. Sigh.
+ rm -f $@
touch $@
ifdef subdir
O%-lib = $(filter ../,$(firstword $(objdir) ../))$(patsubst %,$(libtype$*),c)
@@ -553,8 +555,8 @@ ifeq (yes,$(build-shared))
# $(LDLIBS-%.so) may contain -l switches to generate run-time dependencies
# on other shared objects.
lib%.so: lib%_pic.a
- $(LINK.o) -shared -o $@ \
- -soname lib$(libprefix)$*.so$($(@F)-version) \
+ $(LINK.o) -shared -o $@ -Wl,-soname \
+ -Wl,lib$(libprefix)$(notdir $*).so$($(@F)-version) \
$(LDFLAGS.so) $(LDFLAGS-$(notdir $*).so) \
-L$(firstword $(objdir) .) -L$(common-objpfx:%/=%) \
$(LDLIBS-$(notdir $*).so) -Wl,--whole-archive $< \
diff --git a/elf/dlsym.c b/elf/dlsym.c
index dbd617ec9a..40ed850f64 100644
--- a/elf/dlsym.c
+++ b/elf/dlsym.c
@@ -33,7 +33,7 @@ dlsym (void *handle, const char *name)
void doit (void)
{
const Elf32_Sym *ref = NULL;
- value = _dl_lookup_symbol (name, &ref, map, map->l_name);
+ value = _dl_lookup_symbol (name, &ref, map, map->l_name, 1);
}
/* Confine the symbol scope to just this map. */
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. */