resolve.S 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. #define sl r10
  21. #define fp r11
  22. #define ip r12
  23. .text
  24. .globl _dl_linux_resolve
  25. .type _dl_linux_resolve,%function
  26. .align 4;
  27. _dl_linux_resolve:
  28. stmdb sp!, {r0, r1, r2, r3, sl, fp}
  29. sub r1, ip, lr
  30. sub r1, r1, #4
  31. add r1, r1, r1
  32. ldr r0, [lr, #-4]
  33. mov r3,r0
  34. bl _dl_linux_resolver
  35. mov ip, r0
  36. ldmia sp!, {r0, r1, r2, r3, sl, fp, lr}
  37. mov pc,ip
  38. .size _dl_linux_resolve, .-_dl_linux_resolve