[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[patches] Fix tls-macros.h for Thumb-2
- To: patches@xxxxxxxxxx
- Subject: [patches] Fix tls-macros.h for Thumb-2
- From: "Joseph S. Myers" <joseph@xxxxxxxxxxxxxxxx>
- Date: Thu, 20 Nov 2008 17:31:43 +0000 (UTC)
I've applied this patch to trunk and 2.9 and 2.8 branches to fix the
header tls-macros.h (used in various testcases, not in building glibc
itself) for Thumb-2. The same issue as in the unwind function applies
with pc offsets; in addition, TLS_IE uses "ldr %0, [pc, %0]" which is not
valid in Thumb-2, so I added a slightly different Thumb-2 implementation
of that macro.
Index: sysdeps/arm/tls-macros.h
===================================================================
--- sysdeps/arm/tls-macros.h (revision 7378)
+++ sysdeps/arm/tls-macros.h (working copy)
@@ -1,3 +1,9 @@
+#ifdef __thumb2__
+#define ARM_PC_OFFSET "4"
+#else
+#define ARM_PC_OFFSET "8"
+#endif
+
#define TLS_LE(x) \
({ int *__result; \
void *tp = __builtin_thread_pointer (); \
@@ -10,10 +16,25 @@
: "=&r" (__result) : "r" (tp)); \
__result; })
+#ifdef __thumb2__
#define TLS_IE(x) \
({ int *__result; \
void *tp = __builtin_thread_pointer (); \
asm ("ldr %0, 1f; " \
+ "3: add %0, pc, %0;" \
+ "ldr %0, [%0];" \
+ "add %0, %1, %0; " \
+ "b 2f; " \
+ ".align 2; " \
+ "1: .word " #x "(gottpoff) + (. - 3b - 4); " \
+ "2: " \
+ : "=&r" (__result) : "r" (tp)); \
+ __result; })
+#else
+#define TLS_IE(x) \
+ ({ int *__result; \
+ void *tp = __builtin_thread_pointer (); \
+ asm ("ldr %0, 1f; " \
"3: ldr %0, [pc, %0];" \
"add %0, %1, %0; " \
"b 2f; " \
@@ -22,6 +43,7 @@
"2: " \
: "=&r" (__result) : "r" (tp)); \
__result; })
+#endif
#define TLS_LD(x) \
({ char *__result; \
@@ -31,7 +53,7 @@
"1: add %0, pc, %0; " \
"b 3f; " \
".align 2; " \
- "2: .word " #x "(tlsldm) + (. - 1b - 8); " \
+ "2: .word " #x "(tlsldm) + (. - 1b - "ARM_PC_OFFSET"); " \
"3: " \
: "=r" (__result)); \
__result = (char *)__tls_get_addr (__result); \
@@ -50,7 +72,7 @@
"1: add %0, pc, %0; " \
"b 3f; " \
".align 2; " \
- "2: .word " #x "(tlsgd) + (. - 1b - 8); " \
+ "2: .word " #x "(tlsgd) + (. - 1b - "ARM_PC_OFFSET"); " \
"3: " \
: "=r" (__result)); \
(int *)__tls_get_addr (__result); })
Index: ChangeLog.eglibc
===================================================================
--- ChangeLog.eglibc (revision 7378)
+++ ChangeLog.eglibc (working copy)
@@ -1,5 +1,11 @@
2008-11-20 Joseph Myers <joseph@xxxxxxxxxxxxxxxx>
+ * sysdeps/arm/tls-macros.h (ARM_PC_OFFSET): Define.
+ (TLS_IE): Define differently for Thumb-2.
+ (TLS_LE, TLS_LD, TLS_GD): Use ARM_PC_OFFSET.
+
+2008-11-20 Joseph Myers <joseph@xxxxxxxxxxxxxxxx>
+
* sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-forcedunwind.c
(_Unwind_Resume): Adjust offset from PC for Thumb-2.
* sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-resume.c
--
Joseph S. Myers
joseph@xxxxxxxxxxxxxxxx