[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[patches] Fix Thumb-2 unwinding bugs



I've applied this patch to trunk and 2.9 and 2.8 branches to fix Thumb-2 
unwinding (thread cancellation) problems.  When pc is read as an operand 
in an instruction, the result returned is generally the address of that 
instruction plus 8 in ARM mode but plus 4 in Thumb mode, so when the C 
files in glibc are built as Thumb-2 this fix is needed to the asms in 
these files.

Index: sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-resume.c
===================================================================
--- sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-resume.c	(revision 7377)
+++ sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-resume.c	(working copy)
@@ -67,7 +67,11 @@
 "	ldr	r3, [r4, r5]\n"
 "	b	5b\n"
 "	.align 2\n"
+#ifdef __thumb2__
+"1:	.word	_GLOBAL_OFFSET_TABLE_ - 3b - 4\n"
+#else
 "1:	.word	_GLOBAL_OFFSET_TABLE_ - 3b - 8\n"
+#endif
 "2:	.word	libgcc_s_resume(GOTOFF)\n"
 "	.size	_Unwind_Resume, .-_Unwind_Resume\n"
 );
Index: sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-forcedunwind.c
===================================================================
--- sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-forcedunwind.c	(revision 7377)
+++ sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-forcedunwind.c	(working copy)
@@ -90,7 +90,11 @@
 "	ldr	r3, [r4, r5]\n"
 "	b	5b\n"
 "	.align 2\n"
+#ifdef __thumb2__
+"1:	.word	_GLOBAL_OFFSET_TABLE_ - 3b - 4\n"
+#else
 "1:	.word	_GLOBAL_OFFSET_TABLE_ - 3b - 8\n"
+#endif
 "2:	.word	libgcc_s_resume(GOTOFF)\n"
 "	.size	_Unwind_Resume, .-_Unwind_Resume\n"
 );
Index: ChangeLog.eglibc
===================================================================
--- ChangeLog.eglibc	(revision 7377)
+++ ChangeLog.eglibc	(working copy)
@@ -1,3 +1,10 @@
+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
+	(_Unwind_Resume): Likewise.
+
 2008-08-08  Joseph Myers  <joseph@xxxxxxxxxxxxxxxx>
 
 	* sysdeps/m68k/bits/byteswap.h: Allow inclusion from <endian.h>.

-- 
Joseph S. Myers
joseph@xxxxxxxxxxxxxxxx