resolve.S 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * This function is _not_ called directly. It is jumped to (so no return
  3. * address is on the stack) when attempting to use a symbol that has not yet
  4. * been resolved. The first time a jump symbol (such as a function call inside
  5. * a shared library) is used (before it gets resolved) it will jump here to
  6. * _dl_linux_resolve. When we get called the stack looks like this:
  7. * reloc_entry
  8. * tpnt
  9. *
  10. * This function saves all the registers, puts a copy of reloc_entry and tpnt
  11. * on the stack (as function arguments) then make the function call
  12. * _dl_linux_resolver(tpnt, reloc_entry). _dl_linux_resolver() figures out
  13. * where the jump symbol is _really_ supposed to have jumped to and returns
  14. * that to us. Once we have that, we overwrite tpnt with this fixed up
  15. * address. We then clean up after ourselves, put all the registers back how we
  16. * found them, then we jump to the fixed up address, which is where the jump
  17. * symbol that got us here really wanted to jump to in the first place.
  18. * -Erik Andersen
  19. */
  20. .text
  21. .globl _dl_linux_resolve
  22. .type _dl_linux_resolve,#function
  23. .align 2
  24. _dl_linux_resolve:
  25. stmdb sp!,{r0-r3,sl,fp}
  26. sub r1, ip, lr
  27. sub r1, r1, #4
  28. add r1, r1, r1
  29. ldr r0, [lr, #-4]
  30. mov r3,r0
  31. bl _dl_linux_resolver
  32. // str r0, [lr, #-4]
  33. mov ip, r0
  34. ldmia sp!,{r0-r3,sl,fp,lr}
  35. mov pc,ip
  36. .size _dl_linux_resolve, .-_dl_linux_resolve