From 39624db737b70fa6a4f374262d014aa4b73e7456 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Fri, 10 Jun 2005 07:22:28 +0000 Subject: Finish updating mips for the new ABI --- ldso/ldso/mips/dl-startup.h | 72 ++++++++++++++++++++++++++++++--------------- ldso/ldso/mips/resolve.S | 38 +++++++++++++++++++----- 2 files changed, 78 insertions(+), 32 deletions(-) (limited to 'ldso') diff --git a/ldso/ldso/mips/dl-startup.h b/ldso/ldso/mips/dl-startup.h index f369f77f1..fdc5d5717 100644 --- a/ldso/ldso/mips/dl-startup.h +++ b/ldso/ldso/mips/dl-startup.h @@ -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" ); /* diff --git a/ldso/ldso/mips/resolve.S b/ldso/ldso/mips/resolve.S index 8b492947d..6dc89643e 100644 --- a/ldso/ldso/mips/resolve.S +++ b/ldso/ldso/mips/resolve.S @@ -11,6 +11,7 @@ * Copyright (C) 2002 Steven J. Hill * */ + .text .align 2 .globl _dl_runtime_resolve @@ -19,27 +20,48 @@ _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 + -- cgit v1.2.3