m68k_pic.S 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright (C) 2006 CodeSourcery Inc
  3. *
  4. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  5. *
  6. * This file defines some m68k assembly macros for handling the differences
  7. * between PIC and non-PIC.
  8. */
  9. #include <features.h>
  10. /* When assembling code for shared flat libraries, this is nonzero
  11. * if %a5 points the current library's GOT. */
  12. .equ have_current_got, 0
  13. /* Perform the equivalent of "<op> <target>", where <target> is
  14. * a text address. <tmp> is available as a temporary address
  15. * register. */
  16. .macro DO_TEXT op,target,tmp
  17. #if defined __HAVE_SHARED_FLAT__
  18. .ifne have_current_got
  19. move.l \target@GOT(%a5),\tmp
  20. .else
  21. move.l _current_shared_library_a5_offset_(%a5),\tmp
  22. move.l \target@GOT(\tmp),\tmp
  23. .endif
  24. \op (\tmp)
  25. #elif defined __PIC__
  26. lea \target-.-8,\tmp
  27. \op (%pc,\tmp)
  28. #else
  29. \op \target
  30. #endif
  31. .endm
  32. /* Do "pea <target>" when <target> is a text address.
  33. * <tmp> is available as a temporary register. */
  34. .macro PEA_TEXT target,tmp
  35. DO_TEXT pea,\target,\tmp
  36. .endm
  37. /* Likewise jsr. */
  38. .macro CALL target,tmp
  39. DO_TEXT jsr,\target,\tmp
  40. .endm
  41. /* Likewise jmp. */
  42. .macro JUMP target,tmp
  43. DO_TEXT jmp,\target,\tmp
  44. .endm
  45. /* Initialize the global pointer, if functions need to do that. */
  46. .macro INIT_GP
  47. #if defined __HAVE_SHARED_FLAT__
  48. move.l %a5,-(%sp)
  49. move.l _current_shared_library_a5_offset_(%a5),%a5
  50. #endif
  51. .endm
  52. /* Undo the effects of INIT_GP. */
  53. .macro FINI_GP
  54. #if defined __HAVE_SHARED_FLAT__
  55. move.l (%sp)+,%a5
  56. #endif
  57. .endm