0001-add-nios2-tls-macros-from-glibc.patch 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. From bf6fcd59d1ff51584a703b1d78c9e8fd4f808917 Mon Sep 17 00:00:00 2001
  2. From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  3. Date: Sat, 28 Nov 2020 11:44:00 +0100
  4. Subject: [PATCH] add nios2 tls macros from glibc
  5. Retrieved from
  6. https://github.com/bminor/glibc/blob/master/sysdeps/nios2/tls-macros.h
  7. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  8. [Retrieved from:
  9. https://github.com/wbx-github/uclibc-ng-test/commit/bf6fcd59d1ff51584a703b1d78c9e8fd4f808917]
  10. ---
  11. test/tls/tls-macros-nios2.h | 46 +++++++++++++++++++++++++++++++++++++
  12. test/tls/tls-macros.h | 4 ++++
  13. 2 files changed, 50 insertions(+)
  14. create mode 100644 test/tls/tls-macros-nios2.h
  15. diff --git a/test/tls/tls-macros-nios2.h b/test/tls/tls-macros-nios2.h
  16. new file mode 100644
  17. index 0000000..7029530
  18. --- /dev/null
  19. +++ b/test/tls/tls-macros-nios2.h
  20. @@ -0,0 +1,46 @@
  21. +#define TLS_LE(x) \
  22. + ({ int *__result; \
  23. + asm ("addi %0, r23, %%tls_le(" #x ")" \
  24. + : "=r" (__result)); \
  25. + __result; })
  26. +
  27. +#define TLS_IE(x) \
  28. + ({ int *__result; \
  29. + int __tmp; \
  30. + asm ("nextpc %0 ; " \
  31. + "1: movhi %1, %%hiadj(_gp_got - 1b) ; " \
  32. + "addi %1, %1, %%lo(_gp_got - 1b) ; " \
  33. + "add %0, %0, %1 ; " \
  34. + "ldw %1, %%tls_ie(" #x ")(%0) ; " \
  35. + "add %1, r23, %1" \
  36. + : "=&r" (__tmp), "=&r" (__result)); \
  37. + __result; })
  38. +
  39. +#define TLS_LD(x) \
  40. + ({ char *__result; \
  41. + char *__result2; \
  42. + int *__result3; \
  43. + int __tmp; \
  44. + extern void *__tls_get_addr (void *); \
  45. + asm ("nextpc %0 ; " \
  46. + "1: movhi %1, %%hiadj(_gp_got - 1b) ; " \
  47. + "addi %1, %1, %%lo(_gp_got - 1b) ; " \
  48. + "add %0, %0, %1 ; " \
  49. + "addi %0, %0, %%tls_ldm(" #x ")" \
  50. + : "=r" (__result), "=r" (__tmp)); \
  51. + __result2 = (char *)__tls_get_addr (__result); \
  52. + asm ("addi %0, %1, %%tls_ldo(" #x ")" \
  53. + : "=r" (__result3) : "r" (__result2)); \
  54. + __result3; })
  55. +
  56. +#define TLS_GD(x) \
  57. + ({ int *__result; \
  58. + int __tmp; \
  59. + extern void *__tls_get_addr (void *); \
  60. + asm ("nextpc %0 ; " \
  61. + "1: movhi %1, %%hiadj(_gp_got - 1b) ; " \
  62. + "addi %1, %1, %%lo(_gp_got - 1b) ; " \
  63. + "add %0, %0, %1 ; " \
  64. + "addi %0, %0, %%tls_gd(" #x ")" \
  65. + : "=r" (__result), "=r" (__tmp)); \
  66. + (int *)__tls_get_addr (__result); })
  67. diff --git a/test/tls/tls-macros.h b/test/tls/tls-macros.h
  68. index 4a4e916..087b365 100644
  69. --- a/test/tls/tls-macros.h
  70. +++ b/test/tls/tls-macros.h
  71. @@ -64,6 +64,10 @@
  72. #include <tls-macros-mips.h>
  73. #endif
  74. +#ifdef __nios2__
  75. +#include <tls-macros-nios2.h>
  76. +#endif
  77. +
  78. #if defined(__powerpc__) && !defined(__powerpc64__)
  79. #include <tls-macros-powerpc.h>
  80. #endif