resolve.S 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* Copyright (C) 2003 Red Hat, Inc.
  2. Contributed by Alexandre Oliva <aoliva@redhat.com>
  3. This file is part of uClibc.
  4. uClibc is free software; you can redistribute it and/or modify it
  5. under the terms of the GNU Lesser General Public License as
  6. published by the Free Software Foundation; either version 2.1 of the
  7. License, or (at your option) any later version.
  8. uClibc is distributed in the hope that it will be useful, but WITHOUT
  9. ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with uClibc; see the file COPYING.LIB. If not, write to
  14. the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
  15. USA. */
  16. /* The function below is tail-called by resolver stubs when a
  17. lazily-bound function is called. It must preserve all
  18. registers that could be used to pass arguments to the actual
  19. function. Upon _dl_linux_resolve entry, GR14 holds the
  20. address of a lazy PLT entry, so @(GR14,-4) is the lazy
  21. relocation number that we have to pass to _dl_linux_resolver.
  22. GR15 holds the caller's GOT, from which we extract the
  23. elf_resolve* that _dl_linux_resolver needs as well.
  24. _dl_linux_resolver() figures out where the jump symbol is
  25. _really_ supposed to have jumped to and returns that to us.
  26. Once we have that, we prepare to tail-call the actual
  27. function, clean up after ourselves, restoring the original
  28. arguments, then jump to the fixed up address. */
  29. .text
  30. .p2align 4
  31. .hidden _dl_linux_resolve
  32. .global _dl_linux_resolve
  33. .type _dl_linux_resolve,@function
  34. _dl_linux_resolve:
  35. /* Preserve arguments. */
  36. addi sp, -8*4, sp
  37. stdi gr8, @(sp, 8)
  38. stdi gr10, @(sp, 16)
  39. stdi gr12, @(sp, 24)
  40. movsg lr,gr8
  41. st gr8, @(sp,gr0)
  42. /* Prepare to call _dl_linux_resolver. */
  43. ldi @(gr15, 8), gr8
  44. ldi @(gr14, -4), gr9
  45. mov.p gr5, gr15
  46. call _dl_linux_resolver
  47. /* Move aside return value that contains the FUNCDESC_VALUE. */
  48. ldd @(gr8,gr0),gr14
  49. /* Restore arguments. */
  50. ld @(sp, gr0), gr8
  51. movgs gr8,lr
  52. lddi @(sp, 24), gr12
  53. lddi @(sp, 16), gr10
  54. lddi @(sp, 8), gr8
  55. addi sp, 8*4, sp
  56. /* Now jump to the actual function. */
  57. jmpl @(gr14, gr0)
  58. .size _dl_linux_resolve, . - _dl_linux_resolve