tls-macros-powerpc.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #define __TLS_CALL_CLOBBERS \
  2. "0", "4", "5", "6", "7", "8", "9", "10", "11", "12", \
  3. "lr", "ctr", "cr0", "cr1", "cr5", "cr6", "cr7"
  4. /* PowerPC32 Local Exec TLS access. */
  5. #define TLS_LE(x) \
  6. ({ int *__result; \
  7. __asm__ ("addi %0,2," #x "@tprel" \
  8. : "=r" (__result)); \
  9. __result; })
  10. /* PowerPC32 Initial Exec TLS access. */
  11. #ifdef HAVE_ASM_PPC_REL16
  12. # define TLS_IE(x) \
  13. ({ int *__result; \
  14. __asm__ ("bcl 20,31,1f\n1:\t" \
  15. "mflr %0\n\t" \
  16. "addis %0,%0,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t" \
  17. "addi %0,%0,_GLOBAL_OFFSET_TABLE_-1b@l\n\t" \
  18. "lwz %0," #x "@got@tprel(%0)\n\t" \
  19. "add %0,%0," #x "@tls" \
  20. : "=b" (__result) : \
  21. : "lr"); \
  22. __result; })
  23. #else
  24. # define TLS_IE(x) \
  25. ({ int *__result; \
  26. __asm__ ("bl _GLOBAL_OFFSET_TABLE_@local-4\n\t" \
  27. "mflr %0\n\t" \
  28. "lwz %0," #x "@got@tprel(%0)\n\t" \
  29. "add %0,%0," #x "@tls" \
  30. : "=b" (__result) : \
  31. : "lr"); \
  32. __result; })
  33. #endif
  34. /* PowerPC32 Local Dynamic TLS access. */
  35. #ifdef HAVE_ASM_PPC_REL16
  36. # define TLS_LD(x) \
  37. ({ int *__result; \
  38. __asm__ ("bcl 20,31,1f\n1:\t" \
  39. "mflr 3\n\t" \
  40. "addis 3,3,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t" \
  41. "addi 3,3,_GLOBAL_OFFSET_TABLE_-1b@l\n\t" \
  42. "addi 3,3," #x "@got@tlsld\n\t" \
  43. "bl __tls_get_addr@plt\n\t" \
  44. "addi %0,3," #x "@dtprel" \
  45. : "=r" (__result) : \
  46. : __TLS_CALL_CLOBBERS); \
  47. __result; })
  48. #else
  49. # define TLS_LD(x) \
  50. ({ int *__result; \
  51. __asm__ ("bl _GLOBAL_OFFSET_TABLE_@local-4\n\t" \
  52. "mflr 3\n\t" \
  53. "addi 3,3," #x "@got@tlsld\n\t" \
  54. "bl __tls_get_addr@plt\n\t" \
  55. "addi %0,3," #x "@dtprel" \
  56. : "=r" (__result) : \
  57. : __TLS_CALL_CLOBBERS); \
  58. __result; })
  59. #endif
  60. /* PowerPC32 General Dynamic TLS access. */
  61. #ifdef HAVE_ASM_PPC_REL16
  62. # define TLS_GD(x) \
  63. ({ register int *__result __asm__ ("r3"); \
  64. __asm__ ("bcl 20,31,1f\n1:\t" \
  65. "mflr 3\n\t" \
  66. "addis 3,3,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t" \
  67. "addi 3,3,_GLOBAL_OFFSET_TABLE_-1b@l\n\t" \
  68. "addi 3,3," #x "@got@tlsgd\n\t" \
  69. "bl __tls_get_addr@plt" \
  70. : : \
  71. : __TLS_CALL_CLOBBERS); \
  72. __result; })
  73. #else
  74. # define TLS_GD(x) \
  75. ({ register int *__result __asm__ ("r3"); \
  76. __asm__ ("bl _GLOBAL_OFFSET_TABLE_@local-4\n\t" \
  77. "mflr 3\n\t" \
  78. "addi 3,3," #x "@got@tlsgd\n\t" \
  79. "bl __tls_get_addr@plt" \
  80. : : \
  81. : __TLS_CALL_CLOBBERS); \
  82. __result; })
  83. #endif