resolve.S 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
  3. *
  4. * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
  5. */
  6. #include <sysdep.h>
  7. #include <sys/syscall.h>
  8. ; Save the registers which resolver could possibly clobber
  9. ; r0-r9: args to the function - symbol being resolved
  10. ; r10-r12 are already clobbered by PLTn, PLT0 thus neednot be saved
  11. .macro SAVE_CALLER_SAVED
  12. push_s r0
  13. push_s r1
  14. push_s r2
  15. push_s r3
  16. st.a r4, [sp, -4]
  17. st.a r5, [sp, -4]
  18. st.a r6, [sp, -4]
  19. st.a r7, [sp, -4]
  20. st.a r8, [sp, -4]
  21. st.a r9, [sp, -4]
  22. push_s blink
  23. .endm
  24. .macro RESTORE_CALLER_SAVED_BUT_R0
  25. ld.ab blink,[sp, 4]
  26. ld.ab r9, [sp, 4]
  27. ld.ab r8, [sp, 4]
  28. ld.ab r7, [sp, 4]
  29. ld.ab r6, [sp, 4]
  30. ld.ab r5, [sp, 4]
  31. ld.ab r4, [sp, 4]
  32. pop_s r3
  33. pop_s r2
  34. pop_s r1
  35. .endm
  36. ; Upon entry, PLTn, which led us here, sets up the following regs
  37. ; r11 = Module info (tpnt pointer as expected by resolver)
  38. ; r12 = PC of the PLTn itself - needed by resolver to find
  39. ; corresponding .rela.plt entry
  40. ENTRY(_dl_linux_resolve)
  41. ; args to func being resolved, which resolver might clobber
  42. SAVE_CALLER_SAVED
  43. mov_s r1, r12
  44. bl.d _dl_linux_resolver
  45. mov r0, r11
  46. RESTORE_CALLER_SAVED_BUT_R0
  47. j_s.d [r0] ; r0 has resolved function addr
  48. pop_s r0 ; restore first arg to resolved call
  49. END(_dl_linux_resolve)