resolve.S 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Linux dynamic resolving code for MIPS. Fixes up the GOT entry as
  3. * indicated in register t8 and jumps to the resolved address. Shamelessly
  4. * ripped from 'sysdeps/mips/dl-machine.h' in glibc-2.2.5.
  5. *
  6. * This file is subject to the terms and conditions of the GNU Lesser General
  7. * Public License. See the file "COPYING.LIB" in the main directory of this
  8. * archive for more details.
  9. *
  10. * Copyright (C) 1996-2001 Kazumoto Kojima <kkojima@info.kanagawa-u.ac.jp>
  11. * Copyright (C) 2002 Steven J. Hill <sjhill@realitydiluted.com>
  12. *
  13. */
  14. .text
  15. .align 2
  16. .globl _dl_runtime_resolve
  17. .type _dl_runtime_resolve,@function
  18. .ent _dl_runtime_resolve
  19. _dl_runtime_resolve:
  20. .frame $29, 40, $31
  21. .set noreorder
  22. # Save GP.
  23. move $3, $28
  24. # Save arguments and sp value on stack.
  25. subu $29, 40
  26. # Modify t9 ($25) so as to point .cpload instruction.
  27. addiu $25, 12
  28. # Compute GP.
  29. .set noreorder
  30. .cpload $25
  31. .set reorder
  32. # Save slot call pc.
  33. move $2, $31
  34. .cprestore 32
  35. # Store function arguments from registers to stack
  36. sw $15, 36($29)
  37. sw $4, 16($29)
  38. sw $5, 20($29)
  39. sw $6, 24($29)
  40. sw $7, 28($29)
  41. # Setup functions args and call __dl_runtime_resolve
  42. move $4, $24
  43. move $5, $3
  44. jal __dl_runtime_resolve
  45. # Restore function arguments from stack to registers
  46. lw $31, 36($29)
  47. lw $4, 16($29)
  48. lw $5, 20($29)
  49. lw $6, 24($29)
  50. lw $7, 28($29)
  51. # Do a tail call to the original function
  52. addiu $29, 40
  53. move $25, $2
  54. jr $25
  55. .end _dl_runtime_resolve
  56. .previous