This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GCC 4.x fixes for Hurdy bits (5/5)


This one is from Roland, but I'm right now to darn tired to whip up a
ChangeLog for it, so I leave it to the lovley person who wrote the
patch.  But if said lovley person does not make a ChangeLog by the day
after tomorrow, I'll write one for him--I think.

Good night!


--- sysdeps/mach/hurd/i386/init-first.c
+++ sysdeps/mach/hurd/i386/init-first.c
@@ -271,7 +271,7 @@
       /* 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;
+      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));
@@ -319,11 +319,11 @@
    stack set up just as the user will see it, so it can switch stacks.  */
 
 void
-_dl_init_first (int argc, ...)
+_dl_init_first (void)
 {
   first_init ();
 
-  init (&argc);
+  init ((int *) __builtin_frame_address (0) + 2);
 }
 #endif
 
@@ -350,21 +350,23 @@
    This poorly-named function is called by static-start.S,
    which should not exist at all.  */
 void
-_hurd_stack_setup (volatile int argc, ...)
+_hurd_stack_setup (void)
 {
+  intptr_t caller = (intptr_t) __builtin_return_address (0);
+
   void doinit (intptr_t *data)
     {
       /* This function gets called with the argument data at TOS.  */
-      void doinit1 (volatile int argc, ...)
+      void doinit1 (void)
 	{
-	  init ((int *) &argc);
+	  init ((int *) __builtin_frame_address (0) + 2);
 	}
 
       /* 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];
+      *--data = caller;
       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) : "sp");
@@ -373,7 +375,7 @@
 
   first_init ();
 
-  _hurd_startup ((void **) &argc, &doinit);
+  _hurd_startup ((void **) __builtin_frame_address (0) + 2, &doinit);
 }
 #endif


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]