This is the mail archive of the libc-ports@sources.redhat.com mailing list for the libc-ports project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Adding CFI statements to ARM's assembly code


Hello!

On 2010-01-13 13:56, Daniel Jacobowitz wrote:
> On Wed, Jan 13, 2010 at 10:55:03AM +0100, Thomas Schwinge wrote:
>> > The signal restorer functions are somewhat special.  It's easiest to
>> > not give them CFI, because GDB and GCC know how to handle them if they
>> > don't have CFI.  If you do, we have to be pretty careful with it
>> > (and e.g. use .cfi_signal_frame).
>> 
>> In my reading of binutils' gas/dw2gencfi.c, .cfi_signal_frame is not
>> relevant to .debug_frame sections, but only to .eh_frame (which on the
>> other hand is not relevant for ARM); cf. use of signal_frame in
>> output_cie.  But perhaps I'm missing something?
>
> gas only emits it for .eh_frame, you are correct.  However, it could
> emit it for .debug_frame too; GDB will parse it.

I fixed this in GAS.


> The easiest solution is most likely to avoid .cfi_startproc in this
> file.  For instance you could redefine cfi_startproc.

We settled on doing it properly; so here is a patch to add CFI
statements to the sa_restorer functions.

This has been tested with __default_sa_restorer_v2 (the other ones are
totally analoguous) by disabling all tramp_frame_prepend_unwinder
invocations in GDB's arm-linux-tdep.c.  A proper solution for GDB is
awaiting discussion,
<http://sourceware.org/ml/gdb/2010-03/msg00183.html>.


2010-03-26  Thomas Schwinge  <thomas@codesourcery.com>

	* sysdeps/unix/sysv/linux/arm/eabi/sigrestorer.S (cfi_startproc):
	Redefine for signal frames.
	(__default_sa_restorer_v1, __default_sa_restorer_v2)
	(__default_rt_sa_restorer_v1, __default_rt_sa_restorer_v2): Add CFI
	statements.

diff --git a/glibc-ports-trunk-2.11/sysdeps/unix/sysv/linux/arm/eabi/sigrestorer.S b/glibc-ports-trunk-2.11/sysdeps/unix/sysv/linux/arm/eabi/sigrestorer.S
index f0f2015..09ff9c7 100644
--- a/glibc-ports-trunk-2.11/sysdeps/unix/sysv/linux/arm/eabi/sigrestorer.S
+++ b/glibc-ports-trunk-2.11/sysdeps/unix/sysv/linux/arm/eabi/sigrestorer.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999, 2005, 2009 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 2005, 2009, 2010 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -34,50 +34,89 @@
    Because the signal frame layout changed in 2.6.18, we provide two
    copies of these functions with different unwind information.  */
 
+/* Used in ENTRY.  */
+#undef cfi_startproc
+#define cfi_startproc \
+	.cfi_startproc simple; \
+	.cfi_signal_frame
+
+/* The CFA is not computed / used correctly here; this is neither trivial to
+   do, nor is it needed.  */
+#define CFI \
+	cfi_def_cfa (sp, 0); \
+	cfi_offset (r0, OFFSET + 0 * 4); \
+	cfi_offset (r1, OFFSET + 1 * 4); \
+	cfi_offset (r2, OFFSET + 2 * 4); \
+	cfi_offset (r3, OFFSET + 3 * 4); \
+	cfi_offset (r4, OFFSET + 4 * 4); \
+	cfi_offset (r5, OFFSET + 5 * 4); \
+	cfi_offset (r6, OFFSET + 6 * 4); \
+	cfi_offset (r7, OFFSET + 7 * 4); \
+	cfi_offset (r8, OFFSET + 8 * 4); \
+	cfi_offset (r9, OFFSET + 9 * 4); \
+	cfi_offset (r10, OFFSET + 10 * 4); \
+	cfi_offset (r11, OFFSET + 11 * 4); \
+	cfi_offset (r12, OFFSET + 12 * 4); \
+	cfi_offset (r13, OFFSET + 13 * 4); \
+	cfi_offset (r14, OFFSET + 14 * 4); \
+	cfi_offset (r15, OFFSET + 15 * 4)
+
 #ifndef __ASSUME_SIGFRAME_V2
+#define OFFSET 12
 	.fnstart
 	.save {r0-r15}
-	.pad #12
+	.pad #OFFSET
 	nop
 ENTRY(__default_sa_restorer_v1)
+	CFI
 	mov	r7, $SYS_ify(sigreturn)
 	swi	0x0
 	.fnend
 END(__default_sa_restorer_v1)
-#endif
+#undef OFFSET
+#endif /* __ASSUME_SIGFRAME_V2 */
 
+#define OFFSET 32
 	.fnstart
 	.save {r0-r15}
-	.pad #32
+	.pad #OFFSET
 	nop
 ENTRY(__default_sa_restorer_v2)
+	CFI
 	mov	r7, $SYS_ify(sigreturn)
 	swi	0x0
 	.fnend
 END(__default_sa_restorer_v2)
+#undef OFFSET
 
 #ifdef __NR_rt_sigreturn
 
 #ifndef __ASSUME_SIGFRAME_V2
+#define OFFSET 168
 	.fnstart
 	.save {r0-r15}
-	.pad #168
+	.pad #OFFSET
 	nop
 ENTRY(__default_rt_sa_restorer_v1)
+	CFI
 	mov	r7, $SYS_ify(rt_sigreturn)
 	swi	0x0
 	.fnend
 END(__default_rt_sa_restorer_v1)
-#endif
+#undef OFFSET
+#endif /* __ASSUME_SIGFRAME_V2 */
 
+#define OFFSET 160
 	.fnstart
 	.save {r0-r15}
-	.pad #160
+	.pad #OFFSET
 	nop
 ENTRY(__default_rt_sa_restorer_v2)
+	CFI
 	mov	r7, $SYS_ify(rt_sigreturn)
 	swi	0x0
 	.fnend
 END(__default_rt_sa_restorer_v2)
+#undef OFFSET
 
-#endif
+#endif /* __NR_rt_sigreturn */


Regards,
 Thomas

Attachment: pgp00000.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]