[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [HURD, PATCH] Fix stack switching at initialization time
From: |
Thomas Schwinge |
Subject: |
Re: [HURD, PATCH] Fix stack switching at initialization time |
Date: |
Fri, 16 Sep 2011 20:00:38 +0200 |
User-agent: |
Notmuch/0.7-57-g64222ef (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu) |
Hi!
Is this beast ever going to die...
On Fri, 22 Jul 2011 17:53:12 +0200, ludo@gnu.org wrote:
> Pushed a slightly different version, thanks!
>
> http://git.savannah.gnu.org/cgit/hurd/glibc.git/commit/?h=t/init-first.c&id=53b56b1101fc9bb4f295f23f54e7e19f8da8da16
Just a heads-up, and I'm afraid, but with this patch I get:
$ ./testrun.sh ./libc.so
Segmentation fault
Undoing it (see below), I'm back in service:
$ ./testrun.sh ./libc.so
GNU C Library development release version 2.11.90, by Roland McGrath et al.
[...]
This is still based on 2010-04 glibc sources, GCC 4.4, and old binutils
2.20.1.
Perhaps it'd really be best to write this in a few lines of assembly?
Undo patch:
diff --git a/sysdeps/mach/hurd/i386/init-first.c
b/sysdeps/mach/hurd/i386/init-first.c
index caf65bb..7d93638 100644
--- a/sysdeps/mach/hurd/i386/init-first.c
+++ b/sysdeps/mach/hurd/i386/init-first.c
@@ -257,8 +257,8 @@ init (int *data)
/* 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. */
- *--newsp = __builtin_return_address (0);
- * ((void **) __builtin_frame_address (0) + 1) = &switch_stacks;
+ *--newsp = data[-1];
+ data[-1] = (int) &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));
@@ -286,8 +286,8 @@ 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 = __builtin_return_address (0);
- * ((void **) __builtin_frame_address (0) + 1) = &call_init1;
+ usercode = data[-1];
+ data[-1] = (int) &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));
Grüße,
Thomas
pgpk4H7CGS31v.pgp
Description: PGP signature
- Re: [HURD, PATCH] Fix stack switching at initialization time,
Thomas Schwinge <=