resolve.S 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* Copyright (C) 2003 Red Hat, Inc.
  2. * Contributed by Alexandre Oliva <aoliva@redhat.com>
  3. *
  4. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  5. */
  6. /* The function below is tail-called by resolver stubs when a
  7. lazily-bound function is called. It must preserve all
  8. registers that could be used to pass arguments to the actual
  9. function. Upon _dl_linux_resolve entry, GR14 holds the
  10. address of a lazy PLT entry, so @(GR14,-4) is the lazy
  11. relocation number that we have to pass to _dl_linux_resolver.
  12. GR15 holds the caller's GOT, from which we extract the
  13. elf_resolve* that _dl_linux_resolver needs as well.
  14. _dl_linux_resolver() figures out where the jump symbol is
  15. _really_ supposed to have jumped to and returns that to us.
  16. Once we have that, we prepare to tail-call the actual
  17. function, clean up after ourselves, restoring the original
  18. arguments, then jump to the fixed up address. */
  19. .text
  20. .p2align 4
  21. .hidden _dl_linux_resolve
  22. .global _dl_linux_resolve
  23. .type _dl_linux_resolve,@function
  24. _dl_linux_resolve:
  25. /* Preserve arguments. */
  26. addi sp, -8*4, sp
  27. stdi gr8, @(sp, 8)
  28. stdi gr10, @(sp, 16)
  29. stdi gr12, @(sp, 24)
  30. movsg lr,gr8
  31. st gr8, @(sp,gr0)
  32. /* Prepare to call _dl_linux_resolver. */
  33. ldi @(gr15, 8), gr8
  34. ldi @(gr14, -4), gr9
  35. mov.p gr5, gr15
  36. call _dl_linux_resolver
  37. /* Move aside return value that contains the FUNCDESC_VALUE. */
  38. ldd @(gr8,gr0),gr14
  39. /* Restore arguments. */
  40. ld @(sp, gr0), gr8
  41. movgs gr8,lr
  42. lddi @(sp, 24), gr12
  43. lddi @(sp, 16), gr10
  44. lddi @(sp, 8), gr8
  45. addi sp, 8*4, sp
  46. /* Now jump to the actual function. */
  47. jmpl @(gr14, gr0)
  48. .size _dl_linux_resolve, . - _dl_linux_resolve