MIPS n64 stack alignment fix

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

MIPS n64 stack alignment fix

Daniel Jacobowitz-2
The MIPS startup code carefully realigns the stack to the size of a register
(32-bit on o32, 64-bit otherwise), but then uses PTR_S with an offset of 4
modulo 8.  There's already enough room on the stack; it should be SZREG.

--
Daniel Jacobowitz
CodeSourcery

2006-01-29  Daniel Jacobowitz  <[hidden email]>

        * sysdeps/mips/dl-machine.h (RTLD_START): Correct offsets for
        N64.

Index: libc/sysdeps/mips/dl-machine.h
===================================================================
--- libc.orig/sysdeps/mips/dl-machine.h 2006-01-29 10:51:36.000000000 -0500
+++ libc/sysdeps/mips/dl-machine.h 2006-01-29 10:51:44.000000000 -0500
@@ -266,13 +266,13 @@ do { \
  " STRINGXP(PTR_ADDU) " $7, $7, " STRINGXP (PTRSIZE) " \n\
  # Make sure the stack pointer is aligned for _dl_init_internal.\n\
  and $2, $29, -2 * " STRINGXP(SZREG) "\n\
- " STRINGXP(PTR_S) " $29, -4($2)\n\
+ " STRINGXP(PTR_S) " $29, -" STRINGXP(SZREG) "($2)\n\
  " STRINGXP(PTR_SUBIU) " $29, $2, 32\n\
  " STRINGXP(SAVE_GP(16)) "\n\
  # Call the function to run the initializers.\n\
  jal _dl_init_internal\n\
  # Restore the stack pointer for _start.\n\
- " STRINGXP(PTR_L)  " $29, 28($29)\n\
+ " STRINGXP(PTR_L)  " $29, 32-" STRINGXP(SZREG) "($29)\n\
  # Pass our finalizer function to the user in $2 as per ELF ABI.\n\
  " STRINGXP(PTR_LA) " $2, _dl_fini\n\
  # Jump to the user entry point.\n\