OSDN Git Service

Finish updating mips for the new ABI
authorEric Andersen <andersen@codepoet.org>
Fri, 10 Jun 2005 07:22:28 +0000 (07:22 -0000)
committerEric Andersen <andersen@codepoet.org>
Fri, 10 Jun 2005 07:22:28 +0000 (07:22 -0000)
ldso/ldso/mips/dl-startup.h
ldso/ldso/mips/resolve.S
libc/sysdeps/linux/mips/crt1.S

index f369f77..fdc5d57 100644 (file)
@@ -2,40 +2,64 @@
  * will work as expected and cope with whatever platform specific wierdness is
  * needed for this architecture.
  * Copyright (C) 2005 by Joakim Tjernlund
+ * Copyright (C) 2005 by Erik Andersen
  */
 
+
 asm(""
     "  .text\n"
     "  .globl  _start\n"
+    "  .ent    _start\n"
     "  .type   _start,@function\n"
     "_start:\n"
     "  .set noreorder\n"
-    "  bltzal $0, 0f\n"
-    "  nop\n"
-    "0:        .cpload $31\n"
-    "  .set reorder\n"
-    "  la $4, _DYNAMIC\n"
-    "  sw $4, -0x7ff0($28)\n"
-    "  move $4, $29\n"
-    "  la $8, coff\n"
-    "  .set noreorder\n"
-    "  bltzal $0, coff\n"
+    "  move    $25, $31\n"
+    "  bal     0f\n"
     "  nop\n"
-    "coff:     subu $8, $31, $8\n"
+    "0:\n"
+    "  .cpload $31\n"
+    "  move    $31, $25\n"
     "  .set reorder\n"
-    "  la $25, _dl_start\n"
-    "  addu $25, $8\n"
-    "  jalr $25\n"
-    "  move $17, $2\n"
-    "  lw $4, 0($29)\n"
-    "  la $5, 4($29)\n"
-    "  sll $6, $4, 2\n"
-    "  addu $6, $6, $5\n"
-    "  addu $6, $6, 4\n"
-    "  move $25, $17\n"
-    "  jr $25\n"
-    "  .size   _start,.-_start\n"
-    "  .previous\n"
+    "  la      $4, _DYNAMIC\n"
+    "  sw      $4, -0x7ff0($28)\n"
+    "  move    $4, $29\n"
+    "  subu    $29, 16\n"
+    "  la      $8, .coff\n"
+    "  bltzal  $8, .coff\n"
+    ".coff:\n"
+    "  subu    $8, $31, $8\n"
+    "  la      $25, _dl_start\n"
+    "  addu    $25, $8\n"
+    "  jalr    $25\n"
+    "  addiu   $29, 16\n"
+    "  move    $16, $28\n"
+    "  move    $17, $2\n"
+    "  lw      $2, _dl_skip_args\n"
+    "  beq     $2, $0, 1f\n"
+    "  lw      $4, 0($29)\n"
+    "  subu    $4, $2\n"
+    "  sll     $2, 2\n"
+    "  addu    $29, $2\n"
+    "  sw      $4, 0($29)\n"
+    "1:\n"
+    "  lw      $5, 0($29)\n"
+    "  la      $6, 4 ($29)\n"
+    "  sll     $7, $5, 2\n"
+    "  addu    $7, $7, $6\n"
+    "  addu    $7, $7, 4\n"
+    "  and     $2, $29, -2 * 4\n"
+    "  sw      $29, -4($2)\n"
+    "  subu    $29, $2, 32\n"
+    "  .cprestore 16\n"
+    "  lw      $29, 28($29)\n"
+    "  la      $2, _dl_fini\n"
+    "  move    $25, $17\n"
+    "  jr      $25\n"
+    ".end      _start\n"
+    ".size     _start, . -_start\n"
+    "\n\n"
+    "\n\n"
+    ".previous\n"
 );
 
 /*
index 8b49294..6dc8964 100644 (file)
@@ -11,6 +11,7 @@
  * Copyright (C) 2002 Steven J. Hill <sjhill@realitydiluted.com>
  *
  */
+
 .text
 .align 2
 .globl _dl_runtime_resolve
 _dl_runtime_resolve:
        .frame  $29, 40, $31
        .set noreorder
-       move    $3, $28         # Save GP
-       addu    $25, 8          # t9 ($25) now points at .cpload instruction
-       .cpload $25             # Compute GP
-       .set reorder
+
+       # Save GP.
+       move    $3, $28
+
+       # Save arguments and sp value on stack.
        subu    $29, 40
+
+       # Modify t9 ($25) so as to point .cpload instruction.
+       addiu   $25, 12
+
+       # Compute GP.
+       .set noreorder
+       .cpload $25
+       .set reorder
+
+       # Save slot call pc.
+       move    $2, $31
        .cprestore 32
+
+       # Store function arguments from registers to stack
        sw      $15, 36($29)
        sw      $4, 16($29)
        sw      $5, 20($29)
        sw      $6, 24($29)
        sw      $7, 28($29)
+
+       # Setup functions args and call __dl_runtime_resolve
        move    $4, $24
        move    $5, $3
-       jal     __dl_runtime_resolve
+       jal     __dl_runtime_resolve
+
+       # Restore function arguments from stack to registers
        lw      $31, 36($29)
        lw      $4, 16($29)
        lw      $5, 20($29)
        lw      $6, 24($29)
        lw      $7, 28($29)
-       addu    $29, 40
+
+       # Do a tail call to the original function
+       addiu   $29, 40
        move    $25, $2
        jr      $25
-.size _dl_runtime_resolve,.-_dl_runtime_resolve
-.end _dl_runtime_resolve
+.end   _dl_runtime_resolve
+.previous
+
index 82090ae..4c00bd0 100644 (file)
 */
 
 .text
-       .global __start
-       .type   __start,%function
-       .type   _init,%function
-       .type   _fini,%function
-       .type   main,%function
-       .type   __uClibc_main,%function
+       .globl      __start
+       .type       __start,@function
+       .type       _init,@function
+       .type       _fini,@function
+       .type       main,@function
+       .type       __uClibc_start_main,@function
 
 __start:
 #ifdef __PIC__
@@ -84,8 +84,8 @@ __start:
        bal 10f                 /* Find addr of cpload.  */
         nop
 10:
-       .cpload $31;
-       move $31, $0;
+       .cpload $31
+       move $31, $0
        .set reorder
 #else
        la $28, _gp             /* Setup GP correctly if we're non-PIC.  */
@@ -97,9 +97,9 @@ __start:
        lw $5, 0($29)           /* argc */
        addiu $6, $29, 4        /* argv  */
 
-       /* Allocate space on the stack for seven arguments (o32 only)
-          and make sure the stack is aligned to double words (8 bytes)
-          on o32 and quad words (16 bytes) on n32 and n64.  */
+       /* Allocate space on the stack for seven arguments and
+        * make sure the stack is aligned to double words (8 bytes) */
+
        and $29, -2 * 4
        subu $29, 32
        la $7, _init            /* init */