tls-macros-or1k.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* Macros to support TLS testing, OpenRISC version.
  2. Copyright (C) 2019 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library. If not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #define TLS_LOAD_GOT \
  16. ({ register long lr __asm__ ("r9"); \
  17. long got; \
  18. asm ("l.jal 0x8\n\t" \
  19. " l.movhi %0, gotpchi(_GLOBAL_OFFSET_TABLE_-4)\n\t" \
  20. "l.ori %0, %0, gotpclo(_GLOBAL_OFFSET_TABLE_+0)\n\t" \
  21. "l.add %0, %0, %1" \
  22. : "=r" (got), "=r" (lr)); \
  23. got; })
  24. /* General Dynamic:
  25. l.movhi r17, tlsgdhi(symbol)
  26. l.ori r17, r17, tlsgdlo(symbol)
  27. l.add r17, r17, r16
  28. l.or r3, r17, r17
  29. l.jal plt(__tls_get_addr)
  30. l.nop */
  31. #define TLS_GD(x) \
  32. ({ void *__tlsgd; \
  33. extern void *__tls_get_addr (void *); \
  34. asm ("l.movhi %0, tlsgdhi(" #x ")\n\t" \
  35. "l.ori %0, %0, tlsgdlo(" #x ")\n\t" \
  36. : "=r" (__tlsgd)); \
  37. (int *) __tls_get_addr (TLS_LOAD_GOT + __tlsgd); })
  38. #define TLS_LD(x) TLS_GD(x)
  39. /* Initial Exec:
  40. l.movhi r17, gottpoffhi(symbol)
  41. l.add r17, r17, r16
  42. l.lwz r17, gottpofflo(symbol)(r17)
  43. l.add r17, r17, r10
  44. l.lbs r17, 0(r17) */
  45. #define TLS_IE(x) \
  46. ({ register long __tls __asm__ ("r10"); \
  47. void *__tlsie; \
  48. asm ("l.movhi %0, gottpoffhi(" #x ")\n\t" \
  49. "l.add %0, %0, %1\n\t" \
  50. "l.lwz %0, gottpofflo(" #x ")(%0)\n\t" \
  51. "l.add %0, %0, %2\n\t" \
  52. : "=&r" (__tlsie) : "r" (TLS_LOAD_GOT), \
  53. "r" (__tls) : "memory"); \
  54. __tlsie; })
  55. /* Local Exec:
  56. l.movhi r17, tpoffha(symbol)
  57. l.add r17, r17, r10
  58. l.addi r17, r17, tpofflo(symbol)
  59. l.lbs r17, 0(r17) */
  60. #define TLS_LE(x) \
  61. ({ register long __tls __asm__ ("r10"); \
  62. void *__tlsle; \
  63. asm ("l.movhi %0, tpoffha(" #x ")\n\t" \
  64. "l.add %0, %0, %1\n\t" \
  65. "l.addi %0, %0, tpofflo(" #x ")\n\t" \
  66. : "=&r" (__tlsle) : "r" (__tls) : "memory"); \
  67. __tlsle; })