resolve.S 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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, see
  14. <http://www.gnu.org/licenses/>. */
  15. /* The function below is tail-called by resolver stubs when a
  16. lazily-bound function is called. It must preserve all
  17. registers that could be used to pass arguments to the actual
  18. function. Upon _dl_linux_resolve entry, GR14 holds the
  19. address of a lazy PLT entry, so @(GR14,-4) is the lazy
  20. relocation number that we have to pass to _dl_linux_resolver.
  21. GR15 holds the caller's GOT, from which we extract the
  22. elf_resolve* that _dl_linux_resolver needs as well.
  23. _dl_linux_resolver() figures out where the jump symbol is
  24. _really_ supposed to have jumped to and returns that to us.
  25. Once we have that, we prepare to tail-call the actual
  26. function, clean up after ourselves, restoring the original
  27. arguments, then jump to the fixed up address. */
  28. .text
  29. .p2align 4
  30. .hidden __dl_linux_resolve
  31. .global __dl_linux_resolve
  32. .type __dl_linux_resolve,@function
  33. __dl_linux_resolve:
  34. /* Preserve arguments. */
  35. [--SP] = RETS;
  36. [--SP] = P0;
  37. [--SP] = R0;
  38. [--SP] = R1;
  39. [--SP] = R2;
  40. sp += -12;
  41. /* Prepare to call _dl_linux_resolver. */
  42. R0 = [P3 + 8];
  43. /* Not aligned for space reasons. */
  44. R1 = W[P1 + -4] (Z);
  45. P1 += -2;
  46. R1.H = W[P1];
  47. P3 = R3;
  48. CALL __dl_linux_resolver;
  49. /* Move aside return value that contains the FUNCDESC_VALUE. */
  50. P3 = R0;
  51. P1 = [P3];
  52. P3 = [P3 + 4];
  53. /* Restore arguments. */
  54. sp += 12;
  55. R2 = [SP++];
  56. R1 = [SP++];
  57. R0 = [SP++];
  58. P0 = [SP++];
  59. RETS = [SP++];
  60. /* Now jump to the actual function. */
  61. JUMP (P1);
  62. .size __dl_linux_resolve, . - __dl_linux_resolve