resolve.S 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. [--SP] = RETS;
  37. [--SP] = P0;
  38. [--SP] = R0;
  39. [--SP] = R1;
  40. [--SP] = R2;
  41. sp += -12;
  42. /* Prepare to call _dl_linux_resolver. */
  43. R0 = [P3 + 8];
  44. /* Not aligned for space reasons. */
  45. R1 = W[P1 + -4] (Z);
  46. P1 += -2;
  47. R1.H = W[P1];
  48. P3 = R3;
  49. CALL __dl_linux_resolver;
  50. /* Move aside return value that contains the FUNCDESC_VALUE. */
  51. P3 = R0;
  52. P1 = [P3];
  53. P3 = [P3 + 4];
  54. /* Restore arguments. */
  55. sp += 12;
  56. R2 = [SP++];
  57. R1 = [SP++];
  58. R0 = [SP++];
  59. P0 = [SP++];
  60. RETS = [SP++];
  61. /* Now jump to the actual function. */
  62. JUMP (P1);
  63. .size __dl_linux_resolve, . - __dl_linux_resolve