Browse Source

Prepare PowerPC some more for standalone exection of ldso.
Note that every arch that wants to support standalone execution needs
to align its stack pointer in crtX since ldso will adjust the stack pointer
when adjusting argc and argv in standalone mode.

Joakim Tjernlund 19 years ago
parent
commit
447c0b1572
2 changed files with 9 additions and 0 deletions
  1. 3 0
      ldso/ldso/ldso.c
  2. 6 0
      ldso/ldso/powerpc/dl-startup.h

+ 3 - 0
ldso/ldso/ldso.c

@@ -59,6 +59,9 @@ char *_dl_debug_bindings  = 0;
 int   _dl_debug_file      = 2;
 #endif
 
+/* Needed for standalone execution. */
+unsigned long attribute_hidden _dl_skip_args = 0;
+
 #include "dl-startup.c"
 /* Forward function declarations */
 static int _dl_suid_ok(void);

+ 6 - 0
ldso/ldso/powerpc/dl-startup.h

@@ -19,6 +19,12 @@ asm(
     "	bl	_GLOBAL_OFFSET_TABLE_-4@local\n" /*  Put our GOT pointer in r31, */
     "	mflr	31\n"
     "	addi	1,1,16\n" /* Restore SP */
+    "	lwz	7,_dl_skip_args@got(31)\n" /* load EA of _dl_skip_args */
+    "	lwz	7,0(7)\n"	/* Load word from _dl_skip_args */
+    "	lwz	8,0(1)\n"	/* Load argc from stack */
+    "	subf	8,7,8\n"	/* Subtract _dl_skip_args from argc. */
+    "	slwi	7,7,2\n"	/* Multiply by 4 */
+    "	stwux	8,1,7\n"	/* Adjust the stack pointer to skip _dl_skip_args words and store adjusted argc on stack. */
 #if 0
     /* Try beeing SVR4 ABI compliant?, even though it is not needed for uClibc on Linux */
     /* argc */