public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
* Adding CFI statements to ARM's assembly code
@ 2009-12-21 16:30 Thomas Schwinge
  2009-12-21 16:55 ` Adding CFI statements to ARM's assembly code: syscall stub infrastructure Thomas Schwinge
  2009-12-31 16:57 ` Adding CFI statements to ARM's assembly code Joseph S. Myers
  0 siblings, 2 replies; 24+ messages in thread
From: Thomas Schwinge @ 2009-12-21 16:30 UTC (permalink / raw)
  To: libc-ports

[-- Attachment #1: Type: text/plain, Size: 2082 bytes --]

Hello!

I'm working on adding CFI statements to ARM's assembly code, for a better
debugging experience, especially when stepping through the syscall stubs,
where GDB currently doesn't have proper frame unwinding information
available, and thus can't do correct backtraces, etc.


I will be sending follow-up emails to this message; these will contain
further patches.

In spirit with previous ARM code enhancements,
(cf. <http://sourceware.org/ml/libc-ports/2009-12/msg00012.html>), only
the EABI and NPTL code will be changed.


The first patch.  We need to use .cfi_sections to advise the assembler to
not emit .eh_frame sections (which would be incorrect to do on ARM), but
instead only .debug_frame.  This CFI statement is a 2009-10-01 binutils
addition by Jakub Jelinek,
<http://sourceware.org/ml/binutils/2009-10/msg00028.html>, which we
require to be supported, and thus we fail to configure if it's not
supported.  This hard requirement has been suggested and discussed in the
following thread:
<http://sourceware.org/ml/libc-alpha/2009-12/msg00032.html>.


2009-12-21  Thomas Schwinge  <thomas@codesourcery.com>

	* sysdeps/arm/configure.in: New file.

diff --git a/glibc-ports-mainline/sysdeps/arm/configure.in b/glibc-ports-mainline/sysdeps/arm/configure.in
new file mode 100644
index 0000000..9f4ff3b
--- /dev/null
+++ b/glibc-ports-mainline/sysdeps/arm/configure.in
@@ -0,0 +1,20 @@
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+# Local configure fragment for sysdeps/arm.
+
+AC_CACHE_CHECK([whether the CFI directive .cfi_sections is supported],
+  [libc_cv_asm_cfi_directive_sections],
+  [cat > conftest.s <<EOF
+	.text
+	.cfi_sections .debug_frame, .eh_frame
+	.cfi_startproc
+	.cfi_endproc
+EOF
+  if AC_TRY_COMMAND(${CC-cc} $ASFLAGS -c conftest.s 1>&AS_MESSAGE_LOG_FD); then
+    libc_cv_asm_cfi_directive_sections=yes
+  else
+    libc_cv_asm_cfi_directive_sections=no
+  fi
+  rm -f conftest*])
+if test $libc_cv_asm_cfi_directive_sections != yes; then
+  AC_MSG_ERROR([need .cfi_sections in this configuration])
+fi


Regards,
 Thomas

[-- Attachment #2: Type: application/pgp-signature, Size: 196 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Adding CFI statements to ARM's assembly code: syscall stub infrastructure
  2009-12-21 16:30 Adding CFI statements to ARM's assembly code Thomas Schwinge
@ 2009-12-21 16:55 ` Thomas Schwinge
  2009-12-22  9:46   ` Adding CFI statements to ARM's assembly code: syscall function Thomas Schwinge
                     ` (3 more replies)
  2009-12-31 16:57 ` Adding CFI statements to ARM's assembly code Joseph S. Myers
  1 sibling, 4 replies; 24+ messages in thread
From: Thomas Schwinge @ 2009-12-21 16:55 UTC (permalink / raw)
  To: libc-ports

[-- Attachment #1: Type: text/plain, Size: 15399 bytes --]

Hello!

This patch adds CFI statements to the main syscall stub infrastructure.


2009-12-21  Thomas Schwinge  <thomas@codesourcery.com>

	* sysdeps/arm/sysdep.h (ENTRY, END): Add CFI statements.
	* sysdeps/unix/arm/sysdep.S (__syscall_error): Likewise.
	* sysdeps/unix/sysv/linux/arm/eabi/nptl/sysdep-cancel.h
	(PSEUDO, DOCARGS_0, RESTORE_LR_0, DOCARGS_1, UNDOCARGS_1, DOCARGS_2)
	(UNDOCARGS_2, DOCARGS_3, UNDOCARGS_3, DOCARGS_4, UNDOCARGS_4)
	(DOCARGS_5, UNDOCARGS_5, RESTORE_LR_5, DOCARGS_6, UNDOCARGS_6):
	Likewise.
	[__ASSEMBLER__] (SINGLE_THREAD_P): Likewise.
	* sysdeps/unix/sysv/linux/arm/eabi/sysdep.h (DO_CALL): Likewise.
	* sysdeps/unix/sysv/linux/arm/sysdep.h
	(POP_PC, SYSCALL_ERROR_HANDLER (__local_syscall_error))
	(DOARGS_5, UNDOARGS_5, DOARGS_6, UNDOARGS_6, DOARGS_7, UNDOARGS_7):
	Likewise.
	* sysdeps/unix/sysv/linux/arm/eabi/sigrestorer.S
	(__default_sa_restorer_v1, __default_sa_restorer_v2)
	(__default_rt_sa_restorer_v1, __default_rt_sa_restorer_v2): Add END
	statements.

diff --git a/glibc-ports-mainline/sysdeps/arm/sysdep.h b/glibc-ports-mainline/sysdeps/arm/sysdep.h
index 442d3a1..929a452 100644
--- a/glibc-ports-mainline/sysdeps/arm/sysdep.h
+++ b/glibc-ports-mainline/sysdeps/arm/sysdep.h
@@ -1,5 +1,5 @@
 /* Assembler macros for ARM.
-   Copyright (C) 1997, 1998, 2003 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998, 2003, 2009 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
@@ -81,10 +81,13 @@
   ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),function)			      \
   .align ALIGNARG(4);							      \
   C_LABEL(name)								      \
+  .cfi_sections .debug_frame;						      \
+  cfi_startproc;							      \
   CALL_MCOUNT
 
 #undef	END
 #define END(name)							      \
+  cfi_endproc;								      \
   ASM_SIZE_DIRECTIVE(name)
 
 /* If compiled for profiling, call `mcount' at the start of each function.  */
diff --git a/glibc-ports-mainline/sysdeps/unix/arm/sysdep.S b/glibc-ports-mainline/sysdeps/unix/arm/sysdep.S
index dcb427e..d3ad81b 100644
--- a/glibc-ports-mainline/sysdeps/unix/arm/sysdep.S
+++ b/glibc-ports-mainline/sysdeps/unix/arm/sysdep.S
@@ -1,5 +1,5 @@
 /* Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2002, 2003,
-   2004, 2005
+   2004, 2005, 2009
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -44,6 +44,7 @@ syscall_error:
 
 #if USE___THREAD
 	mov ip, lr
+	cfi_register (lr, ip)
 	mov r1, r0
 
 	mov r0, #0xffff0fff
@@ -66,9 +67,13 @@ syscall_error:
 1:	.word C_SYMBOL_NAME(rtld_errno) - 0b - 8
 #elif defined(_LIBC_REENTRANT)
 	str lr, [sp, #-4]!
+	cfi_adjust_cfa_offset (4)
+	cfi_rel_offset (lr, 0)
 	str r0, [sp, #-4]!
+	cfi_adjust_cfa_offset (4)
 	bl PLTJMP(C_SYMBOL_NAME(__errno_location))
 	ldr r1, [sp], #4
+	cfi_adjust_cfa_offset (-4)
 	str r1, [r0]
 	mvn r0, $0
 	ldr pc, [sp], #4	
diff --git a/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/eabi/nptl/sysdep-cancel.h b/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/eabi/nptl/sysdep-cancel.h
index 73912d5..458558b 100644
--- a/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/eabi/nptl/sysdep-cancel.h
+++ b/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/eabi/nptl/sysdep-cancel.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2004, 2005, 2009 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
@@ -36,17 +36,22 @@
   .type __##syscall_name##_nocancel,%function;				\
   .globl __##syscall_name##_nocancel;					\
   __##syscall_name##_nocancel:						\
+    .cfi_sections .debug_frame;						\
+    cfi_startproc;							\
     DO_CALL (syscall_name, args);					\
     PSEUDO_RET;								\
+    cfi_endproc;							\
   .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel;	\
   ENTRY (name);								\
     SINGLE_THREAD_P;							\
     DOARGS_##args;							\
     bne .Lpseudo_cancel;						\
+    cfi_remember_state;							\
     DO_CALL (syscall_name, 0);						\
     UNDOARGS_##args;							\
     cmn r0, $4096;							\
     PSEUDO_RET;								\
+    cfi_restore_state;							\
   .Lpseudo_cancel:							\
     .fnstart;								\
     DOCARGS_##args;	/* save syscall args etc. around CENABLE.  */	\
@@ -62,41 +67,127 @@
     mov r0, r7;		/* retrieve return value.  */			\
     RESTORE_LR_##args;							\
     UNDOARGS_##args;							\
-    cmn r0, $4096;
+    cmn r0, $4096
 
 /* DOARGS pushes four bytes on the stack for five arguments, eight bytes for
    six arguments, and nothing for fewer.  In order to preserve doubleword
    alignment, sometimes we must save an extra register.  */
 
-# define RESTART_UNWIND .fnend; .fnstart; .save {r7, lr}
-
-# define DOCARGS_0	stmfd sp!, {r7, lr}; .save {r7, lr}
+# define RESTART_UNWIND \
+  .fnend; \
+  .fnstart; \
+  .save {r7, lr}
+
+# define DOCARGS_0 \
+  stmfd sp!, {r7, lr}; \
+  cfi_adjust_cfa_offset (8); \
+  cfi_rel_offset (r7, 0); \
+  cfi_rel_offset (lr, 4); \
+  .save {r7, lr}
 # define UNDOCARGS_0
-# define RESTORE_LR_0	ldmfd sp!, {r7, lr};
-
-# define DOCARGS_1	stmfd sp!, {r0, r1, r7, lr}; .save {r7, lr}; .pad #8
-# define UNDOCARGS_1	ldr r0, [sp], #8; RESTART_UNWIND
-# define RESTORE_LR_1	RESTORE_LR_0
-
-# define DOCARGS_2	stmfd sp!, {r0, r1, r7, lr}; .save {r7, lr}; .pad #8
-# define UNDOCARGS_2	ldmfd sp!, {r0, r1}; RESTART_UNWIND
-# define RESTORE_LR_2	RESTORE_LR_0
-
-# define DOCARGS_3	stmfd sp!, {r0, r1, r2, r3, r7, lr}; .save {r7, lr}; .pad #16
-# define UNDOCARGS_3	ldmfd sp!, {r0, r1, r2, r3}; RESTART_UNWIND
-# define RESTORE_LR_3	RESTORE_LR_0
-
-# define DOCARGS_4	stmfd sp!, {r0, r1, r2, r3, r7, lr}; .save {r7, lr}; .pad #16
-# define UNDOCARGS_4	ldmfd sp!, {r0, r1, r2, r3}; RESTART_UNWIND
-# define RESTORE_LR_4	RESTORE_LR_0
-
-# define DOCARGS_5	.save {r4}; stmfd sp!, {r0, r1, r2, r3, r4, r7, lr}; .save {r7, lr}; .pad #20
-# define UNDOCARGS_5	ldmfd sp!, {r0, r1, r2, r3}; .fnend; .fnstart; .save {r4}; .save {r7, lr}; .pad #4
-# define RESTORE_LR_5	ldmfd sp!, {r4, r7, lr}
-
-# define DOCARGS_6	.save {r4, r5}; stmfd sp!, {r0, r1, r2, r3, r7, lr}; .save {r7, lr}; .pad #16
-# define UNDOCARGS_6	ldmfd sp!, {r0, r1, r2, r3}; .fnend; .fnstart; .save {r4, r5}; .save {r7, lr}
-# define RESTORE_LR_6	RESTORE_LR_0
+# define RESTORE_LR_0 \
+  ldmfd sp!, {r7, lr}; \
+  cfi_adjust_cfa_offset (-8); \
+  cfi_restore (r7); \
+  cfi_restore (lr)
+
+# define DOCARGS_1 \
+  stmfd sp!, {r0, r1, r7, lr}; \
+  cfi_adjust_cfa_offset (16); \
+  cfi_rel_offset (r7, 8); \
+  cfi_rel_offset (lr, 12); \
+  .save {r7, lr}; \
+  .pad #8
+# define UNDOCARGS_1 \
+  ldr r0, [sp], #8; \
+  cfi_adjust_cfa_offset (-8); \
+  RESTART_UNWIND
+# define RESTORE_LR_1 \
+  RESTORE_LR_0
+
+# define DOCARGS_2 \
+  stmfd sp!, {r0, r1, r7, lr}; \
+  cfi_adjust_cfa_offset (16); \
+  cfi_rel_offset (r7, 8); \
+  cfi_rel_offset (lr, 12); \
+  .save {r7, lr}; \
+  .pad #8
+# define UNDOCARGS_2 \
+  ldmfd sp!, {r0, r1}; \
+  cfi_adjust_cfa_offset (-8); \
+  RESTART_UNWIND
+# define RESTORE_LR_2 \
+  RESTORE_LR_0
+
+# define DOCARGS_3 \
+  stmfd sp!, {r0, r1, r2, r3, r7, lr}; \
+  cfi_adjust_cfa_offset (24); \
+  cfi_rel_offset (r7, 16); \
+  cfi_rel_offset (lr, 20); \
+  .save {r7, lr}; \
+  .pad #16
+# define UNDOCARGS_3 \
+  ldmfd sp!, {r0, r1, r2, r3}; \
+  cfi_adjust_cfa_offset (-16); \
+  RESTART_UNWIND
+# define RESTORE_LR_3 \
+  RESTORE_LR_0
+
+# define DOCARGS_4 \
+  stmfd sp!, {r0, r1, r2, r3, r7, lr}; \
+  cfi_adjust_cfa_offset (24); \
+  cfi_rel_offset (r7, 16); \
+  cfi_rel_offset (lr, 20); \
+  .save {r7, lr}; \
+  .pad #16
+# define UNDOCARGS_4 \
+  ldmfd sp!, {r0, r1, r2, r3}; \
+  cfi_adjust_cfa_offset (-16); \
+  RESTART_UNWIND
+# define RESTORE_LR_4 \
+  RESTORE_LR_0
+
+/* r4 is only stmfd'ed for correct stack alignment.  */
+# define DOCARGS_5 \
+  .save {r4}; \
+  stmfd sp!, {r0, r1, r2, r3, r4, r7, lr}; \
+  cfi_adjust_cfa_offset (28); \
+  cfi_rel_offset (r7, 20); \
+  cfi_rel_offset (lr, 24); \
+  .save {r7, lr}; \
+  .pad #20
+# define UNDOCARGS_5 \
+  ldmfd sp!, {r0, r1, r2, r3}; \
+  cfi_adjust_cfa_offset (-16); \
+  .fnend; \
+  .fnstart; \
+  .save {r4}; \
+  .save {r7, lr}; \
+  .pad #4
+# define RESTORE_LR_5 \
+  ldmfd sp!, {r4, r7, lr}; \
+  cfi_adjust_cfa_offset (-12); \
+  /* r4 will be marked as restored later.  */ \
+  cfi_restore (r7); \
+  cfi_restore (lr)
+
+# define DOCARGS_6 \
+  .save {r4, r5}; \
+  stmfd sp!, {r0, r1, r2, r3, r7, lr}; \
+  cfi_adjust_cfa_offset (24); \
+  cfi_rel_offset (r7, 16); \
+  cfi_rel_offset (lr, 20); \
+  .save {r7, lr}; \
+  .pad #16
+# define UNDOCARGS_6 \
+  ldmfd sp!, {r0, r1, r2, r3}; \
+  cfi_adjust_cfa_offset (-16); \
+  .fnend; \
+  .fnstart; \
+  .save {r4, r5}; \
+  .save {r7, lr}
+# define RESTORE_LR_6 \
+  RESTORE_LR_0
 
 # ifdef IS_IN_libpthread
 #  define CENABLE	bl PLTJMP(__pthread_enable_asynccancel)
@@ -136,9 +227,13 @@ extern int __local_multiple_threads attribute_hidden;
 #   define PSEUDO_PROLOGUE
 #   define SINGLE_THREAD_P						\
   stmfd	sp!, {r0, lr};							\
+  cfi_adjust_cfa_offset (8);						\
+  cfi_rel_offset (lr, 4);						\
   bl	__aeabi_read_tp;						\
   ldr	ip, [r0, #MULTIPLE_THREADS_OFFSET];				\
   ldmfd	sp!, {r0, lr};							\
+  cfi_adjust_cfa_offset (-8);						\
+  cfi_restore (lr);							\
   teq	ip, #0
 #   define SINGLE_THREAD_P_PIC(x) SINGLE_THREAD_P
 #  endif
diff --git a/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/eabi/sysdep.h b/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/eabi/sysdep.h
index a7dd40d..0490500 100644
--- a/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/eabi/sysdep.h
+++ b/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/eabi/sysdep.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005, 2006, 2007
+/* Copyright (C) 2005, 2006, 2007, 2009
    Free Software Foundation, Inc.
 
    This file is part of the GNU C Library.
@@ -100,11 +100,13 @@
 
 #undef	DO_CALL
 #define DO_CALL(syscall_name, args)		\
-    DOARGS_##args				\
+    DOARGS_##args;				\
     mov ip, r7;					\
+    cfi_register (r7, ip);			\
     ldr r7, =SYS_ify (syscall_name);		\
     swi 0x0;					\
     mov r7, ip;					\
+    cfi_restore (r7);				\
     UNDOARGS_##args
 
 #endif /* _LINUX_ARM_EABI_SYSDEP_H */
diff --git a/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/sysdep.h b/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/sysdep.h
index 3911aee..bd5b2ce 100644
--- a/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/sysdep.h
+++ b/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/sysdep.h
@@ -84,7 +84,7 @@
 
 #undef	PSEUDO_END
 #define	PSEUDO_END(name)						      \
-  SYSCALL_ERROR_HANDLER							      \
+  SYSCALL_ERROR_HANDLER;						      \
   END (name)
 
 #undef	PSEUDO_NOERRNO
@@ -129,17 +129,26 @@ __local_syscall_error:						\
        DO_RET(lr);						\
 1:     .word C_SYMBOL_NAME(rtld_errno) - 0b - 8;
 # else
-#if defined(__ARM_ARCH_4T__) && defined(__THUMB_INTERWORK__)
-#define POP_PC  ldr     lr, [sp], #4; bx lr
-#else
-#define POP_PC  ldr     pc, [sp], #4
-#endif
+#  if defined(__ARM_ARCH_4T__) && defined(__THUMB_INTERWORK__)
+#   define POP_PC \
+  ldr lr, [sp], #4; \
+  cfi_adjust_cfa_offset (-4); \
+  cfi_restore (lr); \
+  bx lr
+#  else
+#   define POP_PC  \
+  ldr pc, [sp], #4
+#  endif
 #  define SYSCALL_ERROR_HANDLER					\
 __local_syscall_error:						\
 	str	lr, [sp, #-4]!;					\
+	cfi_adjust_cfa_offset (4);				\
+	cfi_rel_offset (lr, 0);					\
 	str	r0, [sp, #-4]!;					\
+	cfi_adjust_cfa_offset (4);				\
 	bl	PLTJMP(C_SYMBOL_NAME(__errno_location)); 	\
 	ldr	r1, [sp], #4;					\
+	cfi_adjust_cfa_offset (-4);				\
 	rsb	r1, r1, #0;					\
 	str	r1, [r0];					\
 	mvn	r0, #0;						\
@@ -179,7 +188,7 @@ __local_syscall_error:						\
 
 #undef	DO_CALL
 #define DO_CALL(syscall_name, args)		\
-    DOARGS_##args				\
+    DOARGS_##args;				\
     swi SYS_ify (syscall_name); 		\
     UNDOARGS_##args
 
@@ -188,18 +197,47 @@ __local_syscall_error:						\
 #define DOARGS_2 /* nothing */
 #define DOARGS_3 /* nothing */
 #define DOARGS_4 /* nothing */
-#define DOARGS_5 str r4, [sp, $-4]!; ldr r4, [sp, $4];
-#define DOARGS_6 mov ip, sp; stmfd sp!, {r4, r5}; ldmia ip, {r4, r5};
-#define DOARGS_7 mov ip, sp; stmfd sp!, {r4, r5, r6}; ldmia ip, {r4, r5, r6};
+#define DOARGS_5 \
+  str r4, [sp, $-4]!; \
+  cfi_adjust_cfa_offset (4); \
+  cfi_rel_offset (r4, 0); \
+  ldr r4, [sp, $4]
+#define DOARGS_6 \
+  mov ip, sp; \
+  stmfd sp!, {r4, r5}; \
+  cfi_adjust_cfa_offset (8); \
+  cfi_rel_offset (r4, 0); \
+  cfi_rel_offset (r5, 4); \
+  ldmia ip, {r4, r5}
+#define DOARGS_7 \
+  mov ip, sp; \
+  stmfd sp!, {r4, r5, r6}; \
+  cfi_adjust_cfa_offset (12); \
+  cfi_rel_offset (r4, 0); \
+  cfi_rel_offset (r5, 4); \
+  cfi_rel_offset (r6, 8); \
+  ldmia ip, {r4, r5, r6}
 
 #define UNDOARGS_0 /* nothing */
 #define UNDOARGS_1 /* nothing */
 #define UNDOARGS_2 /* nothing */
 #define UNDOARGS_3 /* nothing */
 #define UNDOARGS_4 /* nothing */
-#define UNDOARGS_5 ldr r4, [sp], $4;
-#define UNDOARGS_6 ldmfd sp!, {r4, r5};
-#define UNDOARGS_7 ldmfd sp!, {r4, r5, r6};
+#define UNDOARGS_5 \
+  ldr r4, [sp], $4; \
+  cfi_adjust_cfa_offset (-4); \
+  cfi_restore (r4)
+#define UNDOARGS_6 \
+  ldmfd sp!, {r4, r5}; \
+  cfi_adjust_cfa_offset (-8); \
+  cfi_restore (r4); \
+  cfi_restore (r5)
+#define UNDOARGS_7 \
+  ldmfd sp!, {r4, r5, r6}; \
+  cfi_adjust_cfa_offset (-12); \
+  cfi_restore (r4); \
+  cfi_restore (r5); \
+  cfi_restore (r6)
 
 #else /* not __ASSEMBLER__ */
 
diff --git a/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/eabi/sigrestorer.S b/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/eabi/sigrestorer.S
index cc06a55..f0f2015 100644
--- a/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/eabi/sigrestorer.S
+++ b/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/eabi/sigrestorer.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 2005, 2009 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
@@ -43,6 +43,7 @@ ENTRY(__default_sa_restorer_v1)
 	mov	r7, $SYS_ify(sigreturn)
 	swi	0x0
 	.fnend
+END(__default_sa_restorer_v1)
 #endif
 
 	.fnstart
@@ -53,6 +54,7 @@ ENTRY(__default_sa_restorer_v2)
 	mov	r7, $SYS_ify(sigreturn)
 	swi	0x0
 	.fnend
+END(__default_sa_restorer_v2)
 
 #ifdef __NR_rt_sigreturn
 
@@ -65,6 +67,7 @@ ENTRY(__default_rt_sa_restorer_v1)
 	mov	r7, $SYS_ify(rt_sigreturn)
 	swi	0x0
 	.fnend
+END(__default_rt_sa_restorer_v1)
 #endif
 
 	.fnstart
@@ -75,5 +78,6 @@ ENTRY(__default_rt_sa_restorer_v2)
 	mov	r7, $SYS_ify(rt_sigreturn)
 	swi	0x0
 	.fnend
+END(__default_rt_sa_restorer_v2)
 
 #endif


Not updated:
sysdeps/unix/sysv/linux/arm/eabi/linuxthreads/sysdep-cancel.h,
sysdeps/unix/sysv/linux/arm/linuxthreads/sysdep-cancel.h,
sysdeps/unix/sysv/linux/arm/nptl/sysdep-cancel.h,
sysdeps/unix/sysv/linux/arm/sigrestorer.S


Regards,
 Thomas

[-- Attachment #2: Type: application/pgp-signature, Size: 196 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Adding CFI statements to ARM's assembly code: syscall function
  2009-12-21 16:55 ` Adding CFI statements to ARM's assembly code: syscall stub infrastructure Thomas Schwinge
@ 2009-12-22  9:46   ` Thomas Schwinge
  2009-12-22 10:50   ` Adding CFI statements to ARM's assembly code: memcpy, memmove Thomas Schwinge
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 24+ messages in thread
From: Thomas Schwinge @ 2009-12-22  9:46 UTC (permalink / raw)
  To: libc-ports

[-- Attachment #1: Type: text/plain, Size: 1347 bytes --]

Hello!

This patch adds CFI statements to the syscall function.


2009-12-22  Thomas Schwinge  <thomas@codesourcery.com>

	* sysdeps/unix/sysv/linux/arm/eabi/syscall.S (syscall): Add CFI
	statements.

diff --git a/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/eabi/syscall.S b/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/eabi/syscall.S
index 59ca051..f6d775e 100644
--- a/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/eabi/syscall.S
+++ b/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/eabi/syscall.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005 Free Software Foundation, Inc.
+/* Copyright (C) 2005, 2009 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
@@ -25,6 +25,11 @@
 ENTRY (syscall)
 	mov	ip, sp
 	stmfd	sp!, {r4, r5, r6, r7}
+	cfi_adjust_cfa_offset (16)
+	cfi_rel_offset (r4, 0)
+	cfi_rel_offset (r5, 4)
+	cfi_rel_offset (r6, 8)
+	cfi_rel_offset (r7, 12)
 	mov	r7, r0
 	mov	r0, r1
 	mov	r1, r2
@@ -32,6 +37,11 @@ ENTRY (syscall)
 	ldmfd	ip, {r3, r4, r5, r6}
 	swi	0x0
 	ldmfd	sp!, {r4, r5, r6, r7}
+	cfi_adjust_cfa_offset (-16)
+	cfi_restore (r4)
+	cfi_restore (r5)
+	cfi_restore (r6)
+	cfi_restore (r7)
 	cmn	r0, #4096
 	RETINSTR(cc, lr)
 	b	PLTJMP(syscall_error)


Regards,
 Thomas

[-- Attachment #2: Type: application/pgp-signature, Size: 196 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Adding CFI statements to ARM's assembly code: memcpy, memmove
  2009-12-21 16:55 ` Adding CFI statements to ARM's assembly code: syscall stub infrastructure Thomas Schwinge
  2009-12-22  9:46   ` Adding CFI statements to ARM's assembly code: syscall function Thomas Schwinge
@ 2009-12-22 10:50   ` Thomas Schwinge
  2009-12-22 12:23   ` Adding CFI statements to ARM's assembly code: mmap family Thomas Schwinge
  2009-12-22 12:37   ` Adding CFI statements to ARM's assembly code: socket syscall stub infrastructure Thomas Schwinge
  3 siblings, 0 replies; 24+ messages in thread
From: Thomas Schwinge @ 2009-12-22 10:50 UTC (permalink / raw)
  To: libc-ports

[-- Attachment #1: Type: text/plain, Size: 4308 bytes --]

Hello!

This patch adds CFI statements to memcpy and (totally analogously)
memmove.

I have depicted memcpy's control flow on a sheet of paper -- tell me if
you want to have a look at it.


2009-12-22  Thomas Schwinge  <thomas@codesourcery.com>

	* sysdeps/arm/memcpy.S (memcpy): Add CFI statements.
	* sysdeps/arm/memmove.S (memmove): Likewise.

diff --git a/glibc-ports-mainline/sysdeps/arm/memcpy.S b/glibc-ports-mainline/sysdeps/arm/memcpy.S
index 7f669a6..53c4d0a 100644
--- a/glibc-ports-mainline/sysdeps/arm/memcpy.S
+++ b/glibc-ports-mainline/sysdeps/arm/memcpy.S
@@ -56,6 +56,11 @@
 ENTRY(memcpy)
 
 		stmfd	sp!, {r0, r4, lr}
+		cfi_adjust_cfa_offset (12)
+		cfi_rel_offset (r4, 4)
+		cfi_rel_offset (lr, 8)
+
+		cfi_remember_state
 
 		subs	r2, r2, #4
 		blt	8f
@@ -69,6 +73,11 @@ ENTRY(memcpy)
 
 1:		subs	r2, r2, #(28)
 		stmfd	sp!, {r5 - r8}
+		cfi_adjust_cfa_offset (16)
+		cfi_rel_offset (r5, 0)
+		cfi_rel_offset (r6, 4)
+		cfi_rel_offset (r7, 8)
+		cfi_rel_offset (r8, 12)
 		blt	5f
 
 	CALGN(	ands	ip, r1, #31		)
@@ -121,6 +130,11 @@ ENTRY(memcpy)
 	CALGN(	bcs	2b			)
 
 7:		ldmfd	sp!, {r5 - r8}
+		cfi_adjust_cfa_offset (-16)
+		cfi_restore (r5)
+		cfi_restore (r6)
+		cfi_restore (r7)
+		cfi_restore (r8)
 
 8:		movs	r2, r2, lsl #31
 		ldrneb	r3, [r1], #1
@@ -132,11 +146,16 @@ ENTRY(memcpy)
 
 #if defined (__ARM_ARCH_4T__) && defined(__THUMB_INTERWORK__)
 		ldmfd	sp!, {r0, r4, lr}
+		cfi_adjust_cfa_offset (-12)
+		cfi_restore (r4)
+		cfi_restore (lr)
 		bx      lr
 #else
 		ldmfd	sp!, {r0, r4, pc}
 #endif
 
+		cfi_restore_state
+
 9:		rsb	ip, ip, #4
 		cmp	ip, #2
 		ldrgtb	r3, [r1], #1
@@ -169,6 +188,12 @@ ENTRY(memcpy)
 	CALGN(	bcc	15f			)
 
 11:		stmfd	sp!, {r5 - r9}
+		cfi_adjust_cfa_offset (20)
+		cfi_rel_offset (r5, 0)
+		cfi_rel_offset (r6, 4)
+		cfi_rel_offset (r7, 8)
+		cfi_rel_offset (r8, 12)
+		cfi_rel_offset (r9, 16)
 
 	PLD(	pld	[r1, #0]		)
 	PLD(	subs	r2, r2, #96		)
@@ -203,6 +228,12 @@ ENTRY(memcpy)
 	PLD(	bge	13b			)
 
 		ldmfd	sp!, {r5 - r9}
+		cfi_adjust_cfa_offset (-20)
+		cfi_restore (r5)
+		cfi_restore (r6)
+		cfi_restore (r7)
+		cfi_restore (r8)
+		cfi_restore (r9)
 
 14:		ands	ip, r2, #28
 		beq	16f
diff --git a/glibc-ports-mainline/sysdeps/arm/memmove.S b/glibc-ports-mainline/sysdeps/arm/memmove.S
index 9c9b234..026d8e2 100644
--- a/glibc-ports-mainline/sysdeps/arm/memmove.S
+++ b/glibc-ports-mainline/sysdeps/arm/memmove.S
@@ -73,6 +73,12 @@ ENTRY(memmove)
 #endif
 
 		stmfd	sp!, {r0, r4, lr}
+		cfi_adjust_cfa_offset (12)
+		cfi_rel_offset (r4, 4)
+		cfi_rel_offset (lr, 8)
+
+		cfi_remember_state
+
 		add	r1, r1, r2
 		add	r0, r0, r2
 		subs	r2, r2, #4
@@ -85,6 +91,11 @@ ENTRY(memmove)
 
 1:		subs	r2, r2, #(28)
 		stmfd	sp!, {r5 - r8}
+		cfi_adjust_cfa_offset (16)
+		cfi_rel_offset (r5, 0)
+		cfi_rel_offset (r6, 4)
+		cfi_rel_offset (r7, 8)
+		cfi_rel_offset (r8, 12)
 		blt	5f
 
 	CALGN(	ands	ip, r1, #31		)
@@ -136,6 +147,11 @@ ENTRY(memmove)
 	CALGN(	bcs	2b			)
 
 7:		ldmfd	sp!, {r5 - r8}
+		cfi_adjust_cfa_offset (-16)
+		cfi_restore (r5)
+		cfi_restore (r6)
+		cfi_restore (r7)
+		cfi_restore (r8)
 
 8:		movs	r2, r2, lsl #31
 		ldrneb	r3, [r1, #-1]!
@@ -144,13 +160,19 @@ ENTRY(memmove)
 		strneb	r3, [r0, #-1]!
 		strcsb	r4, [r0, #-1]!
 		strcsb	ip, [r0, #-1]
+
 #if defined (__ARM_ARCH_4T__) && defined (__THUMB_INTERWORK__)
 		ldmfd	sp!, {r0, r4, lr}
+		cfi_adjust_cfa_offset (-12)
+		cfi_restore (r4)
+		cfi_restore (lr)
 		bx      lr
 #else
 		ldmfd	sp!, {r0, r4, pc}
 #endif
 
+		cfi_restore_state
+
 9:		cmp	ip, #2
 		ldrgtb	r3, [r1, #-1]!
 		ldrgeb	r4, [r1, #-1]!
@@ -182,6 +204,12 @@ ENTRY(memmove)
 	CALGN(	bcc	15f			)
 
 11:		stmfd	sp!, {r5 - r9}
+		cfi_adjust_cfa_offset (20)
+		cfi_rel_offset (r5, 0)
+		cfi_rel_offset (r6, 4)
+		cfi_rel_offset (r7, 8)
+		cfi_rel_offset (r8, 12)
+		cfi_rel_offset (r9, 16)
 
 	PLD(	pld	[r1, #-4]		)
 	PLD(	subs	r2, r2, #96		)
@@ -216,6 +244,12 @@ ENTRY(memmove)
 	PLD(	bge	13b			)
 
 		ldmfd	sp!, {r5 - r9}
+		cfi_adjust_cfa_offset (-20)
+		cfi_restore (r5)
+		cfi_restore (r6)
+		cfi_restore (r7)
+		cfi_restore (r8)
+		cfi_restore (r9)
 
 14:		ands	ip, r2, #28
 		beq	16f


Regards,
 Thomas

[-- Attachment #2: Type: application/pgp-signature, Size: 196 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Adding CFI statements to ARM's assembly code: mmap family
  2009-12-21 16:55 ` Adding CFI statements to ARM's assembly code: syscall stub infrastructure Thomas Schwinge
  2009-12-22  9:46   ` Adding CFI statements to ARM's assembly code: syscall function Thomas Schwinge
  2009-12-22 10:50   ` Adding CFI statements to ARM's assembly code: memcpy, memmove Thomas Schwinge
@ 2009-12-22 12:23   ` Thomas Schwinge
  2009-12-22 12:37   ` Adding CFI statements to ARM's assembly code: socket syscall stub infrastructure Thomas Schwinge
  3 siblings, 0 replies; 24+ messages in thread
From: Thomas Schwinge @ 2009-12-22 12:23 UTC (permalink / raw)
  To: libc-ports

[-- Attachment #1: Type: text/plain, Size: 3318 bytes --]

Hello!

This patch adds CFI statements to the mmap family of functions.


2009-12-22  Thomas Schwinge  <thomas@codesourcery.com>

	* sysdeps/unix/sysv/linux/arm/eabi/mmap64.S (__mmap64): Add CFI
	statements.
	* sysdeps/unix/sysv/linux/arm/mmap.S (__mmap): Likewise.

diff --git a/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/eabi/mmap64.S b/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/eabi/mmap64.S
index 38fac06..59352f7 100644
--- a/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/eabi/mmap64.S
+++ b/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/eabi/mmap64.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2003, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 2003, 2005, 2009 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,8 +34,13 @@
 ENTRY (__mmap64)
 	ldr	ip, [sp, $LOW_OFFSET]
 	str	r5, [sp, #-4]!
+	cfi_adjust_cfa_offset (4)
+	cfi_rel_offset (r5, 0)
 	ldr	r5, [sp, $HIGH_OFFSET]
 	str	r4, [sp, #-4]!
+	cfi_adjust_cfa_offset (4)
+	cfi_rel_offset (r4, 0)
+	cfi_remember_state
 	movs	r4, ip, lsl $20		@ check that offset is page-aligned
 	mov	ip, ip, lsr $12
 	moveqs	r4, r5, lsr $12		@ check for overflow
@@ -45,11 +50,19 @@ ENTRY (__mmap64)
 	DO_CALL (mmap2, 0)
 	cmn	r0, $4096
 	ldmfd	sp!, {r4, r5}
+	cfi_adjust_cfa_offset (-8)
+	cfi_restore (r4)
+	cfi_restore (r5)
 	RETINSTR(cc, lr)
 	b	PLTJMP(syscall_error)
+
+	cfi_restore_state
 .Linval:
 	mov	r0, $-EINVAL
 	ldmfd	sp!, {r4, r5}
+	cfi_adjust_cfa_offset (-8)
+	cfi_restore (r4)
+	cfi_restore (r5)
 	b	PLTJMP(syscall_error)
 PSEUDO_END (__mmap64)
 
diff --git a/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/mmap.S b/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/mmap.S
index 9227bd7..abac9e0 100644
--- a/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/mmap.S
+++ b/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/mmap.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 2000, 2003, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 2000, 2003, 2005, 2009 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
@@ -33,8 +33,13 @@ ENTRY (__mmap)
 
 	/* shuffle args */
 	str	r5, [sp, #-4]!
+	cfi_adjust_cfa_offset (4)
+	cfi_rel_offset (r5, 0)
 	ldr	r5, [sp, #8]
 	str	r4, [sp, #-4]!
+	cfi_adjust_cfa_offset (4)
+	cfi_rel_offset (r4, 0)
+	cfi_remember_state
 	ldr	r4, [sp, #8]
 
 	/* convert offset to pages */
@@ -48,12 +53,17 @@ ENTRY (__mmap)
 	/* restore registers */
 2:
 	ldr	r4, [sp], #4
+	cfi_adjust_cfa_offset (-4)
+	cfi_restore (r4)
 	ldr	r5, [sp], #4
+	cfi_adjust_cfa_offset (-4)
+	cfi_restore (r5)
 
 	cmn	r0, $4096
 	RETINSTR(cc, lr)
 	b	PLTJMP(syscall_error)
 
+	cfi_restore_state
 .Linval:
 	mov	r0, #-EINVAL
 	b	2b
@@ -74,6 +84,7 @@ ENTRY (__mmap)
 
 	/* store args on the stack */
 	stmdb	sp!, {a1-a4}
+	cfi_adjust_cfa_offset (16)
 
 	/* do the syscall */
 	mov	a1, sp
@@ -81,6 +92,7 @@ ENTRY (__mmap)
 
 	/* pop args off the stack. */
 	add	sp, sp, #16
+	cfi_adjust_cfa_offset (-16)
 
 	cmn	r0, $4096
 	RETINSTR(cc, lr)


Not updated: sysdeps/unix/sysv/linux/arm/mmap64.S


Regards,
 Thomas

[-- Attachment #2: Type: application/pgp-signature, Size: 196 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Adding CFI statements to ARM's assembly code: socket syscall stub infrastructure
  2009-12-21 16:55 ` Adding CFI statements to ARM's assembly code: syscall stub infrastructure Thomas Schwinge
                     ` (2 preceding siblings ...)
  2009-12-22 12:23   ` Adding CFI statements to ARM's assembly code: mmap family Thomas Schwinge
@ 2009-12-22 12:37   ` Thomas Schwinge
  3 siblings, 0 replies; 24+ messages in thread
From: Thomas Schwinge @ 2009-12-22 12:37 UTC (permalink / raw)
  To: libc-ports

[-- Attachment #1: Type: text/plain, Size: 2970 bytes --]

Hello!

This patch adds CFI statements to the socket syscall stub infrastructure.
This patch should *not* be committed -- I noticed that this file is not
used at all for EABI NPTL glibc configurations only after having amended
it already, unfortunately.  Thus, I'm posting it only (unverified,
untested) in case that it's helpful for someone else.


diff --git a/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/socket.S b/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/socket.S
index 22d0c1a..0388395 100644
--- a/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/socket.S
+++ b/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/socket.S
@@ -41,19 +41,41 @@
 # endif
 #endif
 
-#define PUSHARGS_1	str a1, [sp, $-4]!
-#define PUSHARGS_2	stmfd sp!, {a1, a2}
-#define PUSHARGS_3	stmfd sp!, {a1, a2, a3}
-#define PUSHARGS_4	stmfd sp!, {a1, a2, a3, a4}
-#define PUSHARGS_5	stmfd sp!, {a1, a2, a3, a4}	/* Caller has already pushed arg 5 */
-#define PUSHARGS_6	stmfd sp!, {a1, a2, a3, a4}
-
-#define POPARGS_1	add sp, sp, #4
-#define POPARGS_2	add sp, sp, #8
-#define POPARGS_3	add sp, sp, #12
-#define POPARGS_4	add sp, sp, #16
-#define POPARGS_5	add sp, sp, #16
-#define POPARGS_6	add sp, sp, #16
+#define PUSHARGS_1 \
+  str a1, [sp, $-4]!; \
+  cfi_adjust_cfa_offset (4)
+#define PUSHARGS_2 \
+  stmfd sp!, {a1, a2}; \
+  cfi_adjust_cfa_offset (8)
+#define PUSHARGS_3 \
+  stmfd sp!, {a1, a2, a3}; \
+  cfi_adjust_cfa_offset (12)
+#define PUSHARGS_4 \
+  stmfd sp!, {a1, a2, a3, a4}; \
+  cfi_adjust_cfa_offset (16)
+#define PUSHARGS_5 \
+  /* Caller has already pushed arg 5.  */
+  PUSHARGS_4
+#define PUSHARGS_6 \
+  /* Caller has already pushed args 5, 6.  */
+  PUSHARGS_4
+
+#define POPARGS_1 \
+  add sp, sp, #4; \
+  cfi_adjust_cfa_offset (-4)
+#define POPARGS_2 \
+  add sp, sp, #8; \
+  cfi_adjust_cfa_offset (-8)
+#define POPARGS_3 \
+  add sp, sp, #12; \
+  cfi_adjust_cfa_offset (-12)
+#define POPARGS_4 \
+  add sp, sp, #16; \
+  cfi_adjust_cfa_offset (-16)
+#define POPARGS_5 \
+  POPARGS_4
+#define POPARGS_6 \
+  POPARGS_4
 
 #ifndef NARGS
 #define NARGS 3			/* If we were called with no wrapper, this is really socket() */
@@ -81,6 +103,7 @@ ENTRY (__socket)
 #if defined NEED_CANCELLATION && defined CENABLE
 	SINGLE_THREAD_P
 	bne 1f
+	cfi_remember_state
 #endif
 
         /* Do the system call trap.  */
@@ -97,8 +120,12 @@ ENTRY (__socket)
 	b PLTJMP(SYSCALL_ERROR)
 
 #if defined NEED_CANCELLATION && defined CENABLE
+	cfi_restore_state
 1:
 	str lr, [sp, #-4]!
+	cfi_adjust_cfa_offset (4)
+	cfi_rel_offset (lr, 0)
+
 	CENABLE
 	mov ip, r0
 
@@ -107,10 +134,14 @@ ENTRY (__socket)
 	swi SYS_ify(socketcall)
 
 	str r0, [sp, #-4]!
+	cfi_adjust_cfa_offset (4)
 	mov r0, ip
 	CDISABLE
 	ldr r0, [sp], #4
+	cfi_adjust_cfa_offset (-4)
 	ldr lr, [sp], #4
+	cfi_adjust_cfa_offset (-4)
+	cfi_restore (lr)
 
 	P(POPARGS_,NARGS)
 


Regards,
 Thomas

[-- Attachment #2: Type: application/pgp-signature, Size: 196 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Adding CFI statements to ARM's assembly code
  2009-12-21 16:30 Adding CFI statements to ARM's assembly code Thomas Schwinge
  2009-12-21 16:55 ` Adding CFI statements to ARM's assembly code: syscall stub infrastructure Thomas Schwinge
@ 2009-12-31 16:57 ` Joseph S. Myers
  2010-01-07 18:11   ` Thomas Schwinge
                     ` (7 more replies)
  1 sibling, 8 replies; 24+ messages in thread
From: Joseph S. Myers @ 2009-12-31 16:57 UTC (permalink / raw)
  To: Thomas Schwinge; +Cc: libc-ports

On Mon, 21 Dec 2009, Thomas Schwinge wrote:

> In spirit with previous ARM code enhancements,
> (cf. <http://sourceware.org/ml/libc-ports/2009-12/msg00012.html>), only
> the EABI and NPTL code will be changed.

Although as discussed files not relevant to EABI and NPTL do not need 
updating, all files that *are* relevant to EABI and NPTL, and that use the 
ENTRY macro so this patch series makes them use cfi_startproc, and that 
adjust stack layout or clobber call-preserved registers so they need 
nontrivial CFI, do need to be updated before the patch series can go in, 
so they don't start having inaccurate debug information.

As far as I can see, the following files need updating:

sysdeps/arm/eabi/arm-mcount.S
sysdeps/unix/sysv/linux/arm/clone.S
sysdeps/unix/sysv/linux/arm/eabi/____longjmp_chk.S
sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-forcedunwind.c
sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-resume.c
sysdeps/unix/sysv/linux/arm/nptl/pt-vfork.S
sysdeps/unix/sysv/linux/arm/nptl/vfork.S

Please let me know if your list of files still needing updating is 
different.  I think the changes in the five-patch series starting at 
<http://sourceware.org/ml/libc-ports/2009-12/msg00020.html> are correct; 
it's just that more files need updating for the series to be able to go 
in.

Updating arm-mcount.S may be of limited help to the debugger without a fix 
to GCC PR 42380, but it's still the right thing to do.

The two C files define functions using toplevel asms, and those functions 
save registers to and restore them from the stack.  They don't use ENTRY 
so do not need fixing for the patch series to go in, but correct 
.debug_frame for the point when the stack is adjusted would still be 
useful.

clone is the trickiest case.  From other architectures, I think you want 
to call cfi_endproc immediately after the syscall because the correct CFI 
will be different in the parent and in the child.  At the start of code 
for the child, you can then call cfi_startproc again and mark lr as 
undefined with cfi_undefined; backtraces in a new thread should not go 
back before clone.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Adding CFI statements to ARM's assembly code
  2009-12-31 16:57 ` Adding CFI statements to ARM's assembly code Joseph S. Myers
@ 2010-01-07 18:11   ` Thomas Schwinge
  2010-01-07 18:15   ` Adding CFI statements to ARM's assembly code: mcount Thomas Schwinge
                     ` (6 subsequent siblings)
  7 siblings, 0 replies; 24+ messages in thread
From: Thomas Schwinge @ 2010-01-07 18:11 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: libc-ports

[-- Attachment #1: Type: text/plain, Size: 1042 bytes --]

Hello!

On 2009-12-31 16:57, Joseph S. Myers wrote:
> On Mon, 21 Dec 2009, Thomas Schwinge wrote:
>> In spirit with previous ARM code enhancements,
>> (cf. <http://sourceware.org/ml/libc-ports/2009-12/msg00012.html>), only
>> the EABI and NPTL code will be changed.
>
> Although as discussed files not relevant to EABI and NPTL do not need 
> updating, all files that *are* relevant to EABI and NPTL, and that use the 
> ENTRY macro so this patch series makes them use cfi_startproc, and that 
> adjust stack layout or clobber call-preserved registers so they need 
> nontrivial CFI, do need to be updated before the patch series can go in, 
> so they don't start having inaccurate debug information.

Ack.


> As far as I can see, the following files need updating:

For easier review, I will follow up with these piece by piece.


> I think the changes in the five-patch series starting at 
> <http://sourceware.org/ml/libc-ports/2009-12/msg00020.html> are correct; 

Thanks for reviewing.


Regards,
 Thomas

[-- Attachment #2: Type: application/pgp-signature, Size: 196 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Adding CFI statements to ARM's assembly code: mcount
  2009-12-31 16:57 ` Adding CFI statements to ARM's assembly code Joseph S. Myers
  2010-01-07 18:11   ` Thomas Schwinge
@ 2010-01-07 18:15   ` Thomas Schwinge
  2010-01-08 12:09   ` Adding CFI statements to ARM's assembly code: _Unwind_Resume Thomas Schwinge
                     ` (5 subsequent siblings)
  7 siblings, 0 replies; 24+ messages in thread
From: Thomas Schwinge @ 2010-01-07 18:15 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: libc-ports

[-- Attachment #1: Type: text/plain, Size: 4243 bytes --]

Hello!

On 2009-12-31 16:57, Joseph S. Myers wrote:
> As far as I can see, the following files need updating:
>
> sysdeps/arm/eabi/arm-mcount.S

Additionally, sysdeps/arm/sysdep.h:CALL_MCOUNT needs to be updated with
CFI statements.


By the way, sysdeps/arm/sysdep.h:CALL_MCOUNT could also be trivially
updated to call __gnu_mcount_nc instead of mcount, for a minor
performance win.  (Not that I'd expect too many people to compile a
profiling-enabled glibc.)


> Updating arm-mcount.S may be of limited help to the debugger without a fix 
> to GCC PR 42380, but it's still the right thing to do.

Correct.  The number of people who stepi through a function's prologue,
having been compiled with -pg, is likely to be countable on a single
hand.  But yet, we can and should be correct in these cases, too.


This patch adds CFI statements to the mcount family of functions.

These mcount functions, as I understand it, have a special ABI in that
they shall not clobber *any* registers.


2010-01-07  Thomas Schwinge  <thomas@codesourcery.com>

	* sysdeps/arm/eabi/arm-mcount.S (__gnu_mcount_nc, _mcount): Add CFI
	statements.
	* sysdeps/arm/sysdep.h (CALL_MCOUNT): Likewise.

diff --git a/glibc-ports-mainline/sysdeps/arm/eabi/arm-mcount.S b/glibc-ports-mainline/sysdeps/arm/eabi/arm-mcount.S
index 2aa50b7..06e5f18 100644
--- a/glibc-ports-mainline/sysdeps/arm/eabi/arm-mcount.S
+++ b/glibc-ports-mainline/sysdeps/arm/eabi/arm-mcount.S
@@ -1,5 +1,5 @@
 /* Implementation of profiling support.  ARM EABI version.
-   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+   Copyright (C) 2008, 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
@@ -46,10 +46,22 @@ func:
 
 ENTRY(__gnu_mcount_nc)
 	push {r0, r1, r2, r3, lr}
+	cfi_adjust_cfa_offset (20)
+	cfi_rel_offset (r0, 0)
+	cfi_rel_offset (r1, 4)
+	cfi_rel_offset (r2, 8)
+	cfi_rel_offset (r3, 12)
+	cfi_rel_offset (lr, 16)
 	bic r1, lr, #1
 	ldr r0, [sp, #20]
 	bl __mcount_internal
 	pop {r0, r1, r2, r3, ip, lr}
+	cfi_adjust_cfa_offset (-24)
+	cfi_restore (r0)
+	cfi_restore (r1)
+	cfi_restore (r2)
+	cfi_restore (r3)
+	cfi_register (lr, ip)
 	bx ip
 END(__gnu_mcount_nc)
 
@@ -59,6 +71,13 @@ END(__gnu_mcount_nc)
 
 ENTRY(_mcount)
 	stmdb sp!, {r0, r1, r2, r3, fp, lr}
+	cfi_adjust_cfa_offset (24)
+	cfi_rel_offset (r0, 0)
+	cfi_rel_offset (r1, 4)
+	cfi_rel_offset (r2, 8)
+	cfi_rel_offset (r3, 12)
+	cfi_rel_offset (fp, 16)
+	cfi_rel_offset (lr, 20)
 #ifdef __thumb2__
 	movs r0, fp
 	ittt ne
@@ -73,6 +92,13 @@ ENTRY(_mcount)
 	ldmia sp!, {r0, r1, r2, r3, fp, pc}
 #else
 	ldmia sp!, {r0, r1, r2, r3, fp, lr}
+	cfi_adjust_cfa_offset (-24)
+	cfi_restore (r0)
+	cfi_restore (r1)
+	cfi_restore (r2)
+	cfi_restore (r3)
+	cfi_restore (fp)
+	cfi_restore (lr)
 	bx lr
 #endif
 END(_mcount)
diff --git a/glibc-ports-mainline/sysdeps/arm/sysdep.h b/glibc-ports-mainline/sysdeps/arm/sysdep.h
index 442d3a1..9ffd7df 100644
--- a/glibc-ports-mainline/sysdeps/arm/sysdep.h
+++ b/glibc-ports-mainline/sysdeps/arm/sysdep.h
@@ -1,5 +1,5 @@
 /* Assembler macros for ARM.
-   Copyright (C) 1997, 1998, 2003, 2009 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998, 2003, 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
@@ -81,10 +81,14 @@
 
 /* If compiled for profiling, call `mcount' at the start of each function.  */
 #ifdef	PROF
-#define CALL_MCOUNT			\
-	str	lr,[sp, #-4]!	;	\
-	bl	PLTJMP(mcount)	;	\
-	ldr	lr, [sp], #4	;
+#define CALL_MCOUNT \
+  str	lr,[sp, #-4]!; \
+  cfi_adjust_cfa_offset (4); \
+  cfi_rel_offset (lr, 0); \
+  bl PLTJMP(mcount); \
+  ldr lr, [sp], #4; \
+  cfi_adjust_cfa_offset (-4); \
+  cfi_restore (lr)
 #else
 #define CALL_MCOUNT		/* Do nothing.  */
 #endif


I did not test that sysdeps/arm/sysdep.h:CALL_MCOUNT does the correct
thing, as I didn't want to build a profiling-enabled glibc just for that.
If you request that to be done before accepting this hunk, please tell.


Regards,
 Thomas

[-- Attachment #2: Type: application/pgp-signature, Size: 196 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Adding CFI statements to ARM's assembly code: _Unwind_Resume
  2009-12-31 16:57 ` Adding CFI statements to ARM's assembly code Joseph S. Myers
  2010-01-07 18:11   ` Thomas Schwinge
  2010-01-07 18:15   ` Adding CFI statements to ARM's assembly code: mcount Thomas Schwinge
@ 2010-01-08 12:09   ` Thomas Schwinge
  2010-01-11 16:47   ` Adding CFI statements to ARM's assembly code: _dl_runtime_resolve, _dl_runtime_profile Thomas Schwinge
                     ` (4 subsequent siblings)
  7 siblings, 0 replies; 24+ messages in thread
From: Thomas Schwinge @ 2010-01-08 12:09 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: libc-ports

[-- Attachment #1: Type: text/plain, Size: 3965 bytes --]

Hello!

On 2009-12-31 16:57, Joseph S. Myers wrote:
> sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-forcedunwind.c
> sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-resume.c

> The two C files define functions using toplevel asms, and those functions 
> save registers to and restore them from the stack.  They don't use ENTRY 
> so do not need fixing for the patch series to go in, but correct 
> .debug_frame for the point when the stack is adjusted would still be 
> useful.

Ack.


This patch adds CFI statements to the _Unwind_Resume functions.


2010-01-08  Thomas Schwinge  <thomas@codesourcery.com>

	* sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-forcedunwind.c
	(_Unwind_Resume): Add CFI statements.
	* sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-resume.c
	(_Unwind_Resume): Likewise.

diff --git a/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-forcedunwind.c b/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-forcedunwind.c
index ed321a3..011746d 100644
--- a/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-forcedunwind.c
+++ b/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-forcedunwind.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2005, 2007, 2009 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2005, 2007, 2009, 2010 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Jakub Jelinek <jakub@redhat.com>.
 
@@ -89,7 +89,15 @@ asm (
 "	.globl	_Unwind_Resume\n"
 "	.type	_Unwind_Resume, %function\n"
 "_Unwind_Resume:\n"
+"	.cfi_sections .debug_frame\n"
+"	" CFI_STARTPROC "\n"
 "	stmfd	sp!, {r4, r5, r6, lr}\n"
+"	" CFI_ADJUST_CFA_OFFSET (16)" \n"
+"	" CFI_REL_OFFSET (r4, 0) "\n"
+"	" CFI_REL_OFFSET (r5, 4) "\n"
+"	" CFI_REL_OFFSET (r6, 8) "\n"
+"	" CFI_REL_OFFSET (lr, 12) "\n"
+"	" CFI_REMEMBER_STATE "\n"
 "	ldr	r4, 1f\n"
 "	ldr	r5, 2f\n"
 "3:	add	r4, pc, r4\n"
@@ -99,10 +107,17 @@ asm (
 "	beq	4f\n"
 "5:	mov	r0, r6\n"
 "	ldmfd	sp!, {r4, r5, r6, lr}\n"
+"	" CFI_ADJUST_CFA_OFFSET (-16) "\n"
+"	" CFI_RESTORE (r4) "\n"
+"	" CFI_RESTORE (r5) "\n"
+"	" CFI_RESTORE (r6) "\n"
+"	" CFI_RESTORE (lr) "\n"
 "	bx	r3\n"
+"	" CFI_RESTORE_STATE "\n"
 "4:	bl	pthread_cancel_init\n"
 "	ldr	r3, [r4, r5]\n"
 "	b	5b\n"
+"	" CFI_ENDPROC "\n"
 "	.align 2\n"
 #ifdef __thumb2__
 "1:	.word	_GLOBAL_OFFSET_TABLE_ - 3b - 4\n"
diff --git a/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-resume.c b/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-resume.c
index 3c780b7..cdab10e 100644
--- a/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-resume.c
+++ b/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-resume.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2005, 2010 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Jakub Jelinek <jakub@redhat.com>.
 
@@ -52,7 +52,15 @@ asm (
 "	.globl	_Unwind_Resume\n"
 "	.type	_Unwind_Resume, %function\n"
 "_Unwind_Resume:\n"
+"	.cfi_sections .debug_frame\n"
+"	" CFI_STARTPROC "\n"
 "	stmfd	sp!, {r4, r5, r6, lr}\n"
+"	" CFI_ADJUST_CFA_OFFSET (16)" \n"
+"	" CFI_REL_OFFSET (r4, 0) "\n"
+"	" CFI_REL_OFFSET (r5, 4) "\n"
+"	" CFI_REL_OFFSET (r6, 8) "\n"
+"	" CFI_REL_OFFSET (lr, 12) "\n"
+"	" CFI_REMEMBER_STATE "\n"
 "	ldr	r4, 1f\n"
 "	ldr	r5, 2f\n"
 "3:	add	r4, pc, r4\n"
@@ -62,10 +70,17 @@ asm (
 "	beq	4f\n"
 "5:	mov	r0, r6\n"
 "	ldmfd	sp!, {r4, r5, r6, lr}\n"
+"	" CFI_ADJUST_CFA_OFFSET (-16) "\n"
+"	" CFI_RESTORE (r4) "\n"
+"	" CFI_RESTORE (r5) "\n"
+"	" CFI_RESTORE (r6) "\n"
+"	" CFI_RESTORE (lr) "\n"
 "	bx	r3\n"
+"	" CFI_RESTORE_STATE "\n"
 "4:	bl	init\n"
 "	ldr	r3, [r4, r5]\n"
 "	b	5b\n"
+"	" CFI_ENDPROC "\n"
 "	.align 2\n"
 #ifdef __thumb2__
 "1:	.word	_GLOBAL_OFFSET_TABLE_ - 3b - 4\n"


Regards,
 Thomas

[-- Attachment #2: Type: application/pgp-signature, Size: 196 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Adding CFI statements to ARM's assembly code: _dl_runtime_resolve, _dl_runtime_profile
  2009-12-31 16:57 ` Adding CFI statements to ARM's assembly code Joseph S. Myers
                     ` (2 preceding siblings ...)
  2010-01-08 12:09   ` Adding CFI statements to ARM's assembly code: _Unwind_Resume Thomas Schwinge
@ 2010-01-11 16:47   ` Thomas Schwinge
  2010-01-11 16:48   ` Adding CFI statements to ARM's assembly code: longjmp family Thomas Schwinge
                     ` (3 subsequent siblings)
  7 siblings, 0 replies; 24+ messages in thread
From: Thomas Schwinge @ 2010-01-11 16:47 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: libc-ports

[-- Attachment #1: Type: text/plain, Size: 1401 bytes --]

Hello!

On 2009-12-31 16:57, Joseph S. Myers wrote:
> Please let me know if your list of files still needing updating is 
> different.

Here is an additional one: this patch restricts existing CFI statements
to .debug_frame.  There is no use for .eh_frame on ARM.


2010-01-11  Thomas Schwinge  <thomas@codesourcery.com>

	* sysdeps/arm/dl-trampoline.S (_dl_runtime_resolve)
	(_dl_runtime_profile) <CFI>: Only emit .debug_frame.

diff --git a/glibc-ports-mainline/sysdeps/arm/dl-trampoline.S b/glibc-ports-mainline/sysdeps/arm/dl-trampoline.S
index 0224fa1..de8d891 100644
--- a/glibc-ports-mainline/sysdeps/arm/dl-trampoline.S
+++ b/glibc-ports-mainline/sysdeps/arm/dl-trampoline.S
@@ -1,5 +1,5 @@
 /* PLT trampolines.  ARM version.
-   Copyright (C) 2005 Free Software Foundation, Inc.
+   Copyright (C) 2005, 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
@@ -29,6 +29,7 @@
 	.text
 	.globl _dl_runtime_resolve
 	.type _dl_runtime_resolve, #function
+	.cfi_sections .debug_frame
 	cfi_startproc
 	.align 2
 _dl_runtime_resolve:
@@ -77,6 +78,7 @@ _dl_runtime_resolve:
 #ifndef PROF
 	.globl _dl_runtime_profile
 	.type _dl_runtime_profile, #function
+	.cfi_sections .debug_frame
 	cfi_startproc
 	.align 2
 _dl_runtime_profile:


Regards,
 Thomas

[-- Attachment #2: Type: application/pgp-signature, Size: 196 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Adding CFI statements to ARM's assembly code: longjmp family
  2009-12-31 16:57 ` Adding CFI statements to ARM's assembly code Joseph S. Myers
                     ` (3 preceding siblings ...)
  2010-01-11 16:47   ` Adding CFI statements to ARM's assembly code: _dl_runtime_resolve, _dl_runtime_profile Thomas Schwinge
@ 2010-01-11 16:48   ` Thomas Schwinge
  2010-01-12 13:35   ` Adding CFI statements to ARM's assembly code Thomas Schwinge
                     ` (2 subsequent siblings)
  7 siblings, 0 replies; 24+ messages in thread
From: Thomas Schwinge @ 2010-01-11 16:48 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: libc-ports

[-- Attachment #1: Type: text/plain, Size: 2829 bytes --]

Hello!

On 2009-12-31 16:57, Joseph S. Myers wrote:
> sysdeps/unix/sysv/linux/arm/eabi/____longjmp_chk.S

Also: sysdeps/arm/eabi/__longjmp.S


2010-01-11  Thomas Schwinge  <thomas@codesourcery.com>

	* sysdeps/arm/eabi/__longjmp.S (__longjmp): Add CFI statements.
	* sysdeps/unix/sysv/linux/arm/eabi/____longjmp_chk.S (CALL_FAIL)
	(CHECK_SP): Likewise

diff --git a/glibc-ports-mainline/sysdeps/arm/eabi/__longjmp.S b/glibc-ports-mainline/sysdeps/arm/eabi/__longjmp.S
index 3059193..edabdad 100644
--- a/glibc-ports-mainline/sysdeps/arm/eabi/__longjmp.S
+++ b/glibc-ports-mainline/sysdeps/arm/eabi/__longjmp.S
@@ -1,5 +1,6 @@
 /* longjmp for ARM.
-   Copyright (C) 1997, 1998, 2005, 2006, 2009 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998, 2005, 2006, 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
@@ -31,10 +32,21 @@ ENTRY (__longjmp)
 	moveq	r0, #1		/* can't let setjmp() return zero! */
 
 #ifdef CHECK_SP
-	ldr	r4, [ip, #32]
+	ldr	r4, [ip, #32]	/* jmpbuf's sp */
+	cfi_undefined (r4)
 	CHECK_SP (r4)
 #endif
 	LOADREGS(ia, ip!, {v1-v6, sl, fp, sp, lr})
+	cfi_restore (v1)
+	cfi_restore (v2)
+	cfi_restore (v3)
+	cfi_restore (v4)
+	cfi_restore (v5)
+	cfi_restore (v6)
+	cfi_restore (sl)
+	cfi_restore (fp)
+	cfi_restore (sp)
+	cfi_restore (lr)
 
 #ifdef IS_IN_rtld
   	ldr	a2, 1f
diff --git a/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/eabi/____longjmp_chk.S b/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/eabi/____longjmp_chk.S
index f92a382..423e777 100644
--- a/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/eabi/____longjmp_chk.S
+++ b/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/eabi/____longjmp_chk.S
@@ -30,6 +30,7 @@ longjmp_msg:
 #ifdef PIC
 # define CALL_FAIL						\
 	ldr	sl, .L_GOT;					\
+	cfi_undefined (sl);					\
 .L_GOT_OFF:							\
 	add	sl, pc, sl;					\
 	ldr	r0, .Lstr;					\
@@ -48,12 +49,17 @@ longjmp_msg:
 #endif
 
 #define CHECK_SP(reg)				\
+	cfi_remember_state;			\
 	cmp	sp, reg;			\
 	bls	.Lok;				\
 	mov	r5, r0;				\
+	cfi_undefined (r5);			\
 	mov	r7, #SYS_ify(sigaltstack);	\
+	cfi_undefined (r7);			\
 	mov	r0, #0;				\
-	sub	sp, sp, #16;			\
+	sub	sp, sp, #16; /* >= sizeof (stack_t) */ \
+	cfi_adjust_cfa_offset (16);		\
+	cfi_remember_state;			\
 	mov	r1, sp;				\
 	swi	#0;				\
 	cmp	r0, #0;				\
@@ -69,8 +75,10 @@ longjmp_msg:
 	bhi	.Lok2;				\
 .Lfail:						\
 	CALL_FAIL				\
+	cfi_restore_state;			\
 .Lok2:						\
 	mov	r0, r5;				\
+	cfi_restore_state;			\
 .Lok:
 
 #include <__longjmp.S>


I did not touch sysdeps/arm/__longjmp.S, sysdeps/arm/fpu/__longjmp.S,
sysdeps/unix/sysv/linux/arm/____longjmp_chk.S.


Regards,
 Thomas

[-- Attachment #2: Type: application/pgp-signature, Size: 196 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Adding CFI statements to ARM's assembly code
  2009-12-31 16:57 ` Adding CFI statements to ARM's assembly code Joseph S. Myers
                     ` (4 preceding siblings ...)
  2010-01-11 16:48   ` Adding CFI statements to ARM's assembly code: longjmp family Thomas Schwinge
@ 2010-01-12 13:35   ` Thomas Schwinge
  2010-01-12 14:52     ` Daniel Jacobowitz
  2010-03-23 15:44     ` Joseph S. Myers
  2010-01-12 13:35   ` Adding CFI statements to ARM's assembly code: clone Thomas Schwinge
  2010-01-12 13:35   ` Adding CFI statements to ARM's assembly code: vfork family Thomas Schwinge
  7 siblings, 2 replies; 24+ messages in thread
From: Thomas Schwinge @ 2010-01-12 13:35 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: libc-ports

[-- Attachment #1: Type: text/plain, Size: 931 bytes --]

Hello!

On 2009-12-31 16:57, Joseph S. Myers wrote:
> Please let me know if your list of files still needing updating is 
> different.

Does sysdeps/unix/sysv/linux/arm/eabi/sigrestorer.S need any treatment?
It's probably not worth it.


In sysdeps/unix/sysv/linux/arm/eabi/sysdep.h:INTERNAL_SYSCALL_RAW for
[__thumb__], should we, depending on defined (__GCC_HAVE_DWARF2_CFI_ASM),
emit CFI statements to handle r7's modification and restoral?  We can't
emit CFI statements unconditionally, as it's GCC's decision whether to
emit .cfi_startproc or not, and in the latter case we're not allowed to
using them in inline assembly.


> I think the changes in the five-patch series starting at
> <http://sourceware.org/ml/libc-ports/2009-12/msg00020.html> are correct; it's
> just that more files need updating for the series to be able to go in.

This thread now contains all I have done.


Regards,
 Thomas

[-- Attachment #2: Type: application/pgp-signature, Size: 196 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Adding CFI statements to ARM's assembly code: vfork family
  2009-12-31 16:57 ` Adding CFI statements to ARM's assembly code Joseph S. Myers
                     ` (6 preceding siblings ...)
  2010-01-12 13:35   ` Adding CFI statements to ARM's assembly code: clone Thomas Schwinge
@ 2010-01-12 13:35   ` Thomas Schwinge
  7 siblings, 0 replies; 24+ messages in thread
From: Thomas Schwinge @ 2010-01-12 13:35 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: libc-ports

[-- Attachment #1: Type: text/plain, Size: 2866 bytes --]

Hello!

On 2009-12-31 16:57, Joseph S. Myers wrote:
> sysdeps/unix/sysv/linux/arm/nptl/pt-vfork.S
> sysdeps/unix/sysv/linux/arm/nptl/vfork.S

No change was needed in sysdeps/unix/sysv/linux/arm/vfork.S.


2010-01-12  Thomas Schwinge  <thomas@codesourcery.com>

	* sysdeps/unix/sysv/linux/arm/nptl/pt-vfork.S (SAVE_PID): Add CFI
	statements.
	* sysdeps/unix/sysv/linux/arm/nptl/vfork.S (SAVE_PID): Likewise.

diff --git a/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/nptl/pt-vfork.S b/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/nptl/pt-vfork.S
index 1c2e1f5..964a389 100644
--- a/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/nptl/pt-vfork.S
+++ b/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/nptl/pt-vfork.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005 Free Software Foundation, Inc.
+/* Copyright (C) 2005, 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
@@ -21,10 +21,14 @@
 /* Save the PID value.  */
 #define SAVE_PID \
 	str	lr, [sp, #-4]!;		/* Save LR.  */			\
+	cfi_adjust_cfa_offset (4);					\
+	cfi_rel_offset (lr, 0);						\
 	mov	r0, #0xffff0fff;	/* Point to the high page.  */	\
 	mov	lr, pc;			/* Save our return address.  */	\
 	sub	pc, r0, #31;		/* Jump to the TLS entry.  */	\
 	ldr	lr, [sp], #4;		/* Restore LR.  */		\
+	cfi_adjust_cfa_offset (-4);					\
+	cfi_restore (lr);						\
 	mov	r2, r0;			/* Save the TLS addr in r2.  */	\
 	ldr	r3, [r2, #PID_OFFSET];	/* Load the saved PID.  */	\
 	rsb	r0, r3, #0;		/* Negate it.  */		\
diff --git a/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/nptl/vfork.S b/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/nptl/vfork.S
index 87e055e..009d03a 100644
--- a/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/nptl/vfork.S
+++ b/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/nptl/vfork.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005 Free Software Foundation, Inc.
+/* Copyright (C) 2005, 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
@@ -21,10 +21,14 @@
 /* Save the PID value.  */
 #define SAVE_PID \
 	str	lr, [sp, #-4]!;		/* Save LR.  */			\
+	cfi_adjust_cfa_offset (4);					\
+	cfi_rel_offset (lr, 0);						\
 	mov	r0, #0xffff0fff;	/* Point to the high page.  */	\
 	mov	lr, pc;			/* Save our return address.  */	\
 	sub	pc, r0, #31;		/* Jump to the TLS entry.  */	\
 	ldr	lr, [sp], #4;		/* Restore LR.  */		\
+	cfi_adjust_cfa_offset (-4);					\
+	cfi_restore (lr);						\
 	mov	r2, r0;			/* Save the TLS addr in r2.  */	\
 	ldr	r3, [r2, #PID_OFFSET];	/* Load the saved PID.  */	\
 	rsbs	r0, r3, #0;		/* Negate it.  */		\


I did not touch sysdeps/unix/sysv/linux/arm/linuxthreads/vfork.S.


Regards,
 Thomas

[-- Attachment #2: Type: application/pgp-signature, Size: 196 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Adding CFI statements to ARM's assembly code: clone
  2009-12-31 16:57 ` Adding CFI statements to ARM's assembly code Joseph S. Myers
                     ` (5 preceding siblings ...)
  2010-01-12 13:35   ` Adding CFI statements to ARM's assembly code Thomas Schwinge
@ 2010-01-12 13:35   ` Thomas Schwinge
  2010-01-12 13:35   ` Adding CFI statements to ARM's assembly code: vfork family Thomas Schwinge
  7 siblings, 0 replies; 24+ messages in thread
From: Thomas Schwinge @ 2010-01-12 13:35 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: libc-ports

[-- Attachment #1: Type: text/plain, Size: 2067 bytes --]

Hello!

On 2009-12-31 16:57, Joseph S. Myers wrote:
> sysdeps/unix/sysv/linux/arm/clone.S

> clone is the trickiest case.  From other architectures, I think you want 
> to call cfi_endproc immediately after the syscall because the correct CFI 
> will be different in the parent and in the child.

I agree to put it *after* the syscall instruction -- do you have an idea
why i386 / x86_64 put it *before*?

> At the start of code 
> for the child, you can then call cfi_startproc again and mark lr as 
> undefined with cfi_undefined; backtraces in a new thread should not go 
> back before clone.

Right, that's how I planned to do it -- now successfully tested.


2010-01-12  Thomas Schwinge  <thomas@codesourcery.com>

	* sysdeps/unix/sysv/linux/arm/clone.S (__clone): Add CFI statements.

diff --git a/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/clone.S b/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/clone.S
index 1a19f5b..178b0f1 100644
--- a/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/clone.S
+++ b/glibc-ports-mainline/sysdeps/unix/sysv/linux/arm/clone.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 1998, 1999, 2002, 2005, 2008, 2009
+/* Copyright (C) 1996, 1997, 1998, 1999, 2002, 2005, 2008, 2009, 2010
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Pat Beirne <patb@corelcomputer.com>
@@ -52,8 +52,13 @@ ENTRY(__clone)
 	@ new sp is already in r1
 #ifdef __ARM_EABI__
 	stmfd	sp!, {r4, r7}
+	cfi_adjust_cfa_offset (8)
+	cfi_rel_offset (r4, 0)
+	cfi_rel_offset (r7, 4)
 #else
 	str	r4, [sp, #-8]!
+	cfi_adjust_cfa_offset (8)
+	cfi_rel_offset (r4, 0)
 #endif
 	ldr	r2, [sp, #8]
 	ldr	r3, [sp, #12]
@@ -64,6 +69,7 @@ ENTRY(__clone)
 #else
 	swi	SYS_ify(clone)
 #endif
+	cfi_endproc
 	cmp	r0, #0
 	beq	1f
 #ifdef __ARM_EABI__
@@ -74,6 +80,8 @@ ENTRY(__clone)
 	blt	PLTJMP(C_SYMBOL_NAME(__syscall_error))
 	RETINSTR(, lr)
 
+	cfi_startproc
+	cfi_undefined (lr)
 1:
 #ifdef RESET_PID
 	tst	ip, #CLONE_THREAD


Regards,
 Thomas

[-- Attachment #2: Type: application/pgp-signature, Size: 196 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Adding CFI statements to ARM's assembly code
  2010-01-12 13:35   ` Adding CFI statements to ARM's assembly code Thomas Schwinge
@ 2010-01-12 14:52     ` Daniel Jacobowitz
  2010-01-13  9:55       ` Thomas Schwinge
  2010-03-23 15:44     ` Joseph S. Myers
  1 sibling, 1 reply; 24+ messages in thread
From: Daniel Jacobowitz @ 2010-01-12 14:52 UTC (permalink / raw)
  To: Thomas Schwinge; +Cc: Joseph S. Myers, libc-ports

On Tue, Jan 12, 2010 at 02:35:41PM +0100, Thomas Schwinge wrote:
> Hello!
> 
> On 2009-12-31 16:57, Joseph S. Myers wrote:
> > Please let me know if your list of files still needing updating is 
> > different.
> 
> Does sysdeps/unix/sysv/linux/arm/eabi/sigrestorer.S need any treatment?
> It's probably not worth it.

I'm a bit confused about that one.  Doesn't ENTRY now generate
.cfi_startproc?  There's nothing to generate .cfi_endproc, and I
thought a mismatch would fail to compile.

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 sysdeps/unix/sysv/linux/arm/eabi/sysdep.h:INTERNAL_SYSCALL_RAW for
> [__thumb__], should we, depending on defined (__GCC_HAVE_DWARF2_CFI_ASM),
> emit CFI statements to handle r7's modification and restoral?  We can't
> emit CFI statements unconditionally, as it's GCC's decision whether to
> emit .cfi_startproc or not, and in the latter case we're not allowed to
> using them in inline assembly.

In theory, we ought to.  It's not very important since only r7 is
affected.

-- 
Daniel Jacobowitz
CodeSourcery

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Adding CFI statements to ARM's assembly code
  2010-01-12 14:52     ` Daniel Jacobowitz
@ 2010-01-13  9:55       ` Thomas Schwinge
  2010-01-13 13:57         ` Daniel Jacobowitz
  0 siblings, 1 reply; 24+ messages in thread
From: Thomas Schwinge @ 2010-01-13  9:55 UTC (permalink / raw)
  To: libc-ports

[-- Attachment #1: Type: text/plain, Size: 1576 bytes --]

Hello!

On 2010-01-12 14:52, Daniel Jacobowitz wrote:
> On Tue, Jan 12, 2010 at 02:35:41PM +0100, Thomas Schwinge wrote:
>> Does sysdeps/unix/sysv/linux/arm/eabi/sigrestorer.S need any treatment?
>> It's probably not worth it.
>
> I'm a bit confused about that one.  Doesn't ENTRY now generate
> .cfi_startproc?  There's nothing to generate .cfi_endproc, and I
> thought a mismatch would fail to compile.

You're correct, but that was part of an earlier patch:
<http://sourceware.org/ml/libc-ports/2009-12/msg00021.html>

> 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?


>> In sysdeps/unix/sysv/linux/arm/eabi/sysdep.h:INTERNAL_SYSCALL_RAW for
>> [__thumb__], should we, depending on defined (__GCC_HAVE_DWARF2_CFI_ASM),
>> emit CFI statements to handle r7's modification and restoral?  We can't
>> emit CFI statements unconditionally, as it's GCC's decision whether to
>> emit .cfi_startproc or not, and in the latter case we're not allowed to
>> using them in inline assembly.
>
> In theory, we ought to.  It's not very important since only r7 is
> affected.

Shall I put a comment into the code then?


Regards,
 Thomas

[-- Attachment #2: Type: application/pgp-signature, Size: 196 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Adding CFI statements to ARM's assembly code
  2010-01-13  9:55       ` Thomas Schwinge
@ 2010-01-13 13:57         ` Daniel Jacobowitz
  2010-03-26 11:40           ` Thomas Schwinge
  2010-03-26 11:50           ` Thomas Schwinge
  0 siblings, 2 replies; 24+ messages in thread
From: Daniel Jacobowitz @ 2010-01-13 13:57 UTC (permalink / raw)
  To: Thomas Schwinge; +Cc: libc-ports

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.

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

> Shall I put a comment into the code then?

Sounds fine.

-- 
Daniel Jacobowitz
CodeSourcery

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Adding CFI statements to ARM's assembly code
  2010-01-12 13:35   ` Adding CFI statements to ARM's assembly code Thomas Schwinge
  2010-01-12 14:52     ` Daniel Jacobowitz
@ 2010-03-23 15:44     ` Joseph S. Myers
  2010-03-26 11:58       ` Thomas Schwinge
  1 sibling, 1 reply; 24+ messages in thread
From: Joseph S. Myers @ 2010-03-23 15:44 UTC (permalink / raw)
  To: Thomas Schwinge; +Cc: libc-ports

Once the sigrestorer.S issue is resolved, I think the series

http://sourceware.org/ml/libc-ports/2009-12/msg00020.html
http://sourceware.org/ml/libc-ports/2009-12/msg00021.html
http://sourceware.org/ml/libc-ports/2009-12/msg00022.html
http://sourceware.org/ml/libc-ports/2009-12/msg00023.html
http://sourceware.org/ml/libc-ports/2009-12/msg00024.html
http://sourceware.org/ml/libc-ports/2010-01/msg00004.html
http://sourceware.org/ml/libc-ports/2010-01/msg00005.html
http://sourceware.org/ml/libc-ports/2010-01/msg00009.html
http://sourceware.org/ml/libc-ports/2010-01/msg00010.html
http://sourceware.org/ml/libc-ports/2010-01/msg00013.html
http://sourceware.org/ml/libc-ports/2010-01/msg00014.html

is ready to go in.  Please let me know if this is not the correct set of 
patches to commit for this series.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Adding CFI statements to ARM's assembly code
  2010-01-13 13:57         ` Daniel Jacobowitz
@ 2010-03-26 11:40           ` Thomas Schwinge
  2010-03-26 11:50           ` Thomas Schwinge
  1 sibling, 0 replies; 24+ messages in thread
From: Thomas Schwinge @ 2010-03-26 11:40 UTC (permalink / raw)
  To: libc-ports

[-- Attachment #1: Type: text/plain, Size: 1517 bytes --]

Hello!

On 2010-01-13 13:56, Daniel Jacobowitz wrote:
> On Wed, Jan 13, 2010 at 10:55:03AM +0100, Thomas Schwinge wrote:
>> On 2010-01-12 14:52, Daniel Jacobowitz wrote:
>>> On Tue, Jan 12, 2010 at 02:35:41PM +0100, Thomas Schwinge wrote:
>>>> In sysdeps/unix/sysv/linux/arm/eabi/sysdep.h:INTERNAL_SYSCALL_RAW for
>>>> [__thumb__], should we, depending on defined (__GCC_HAVE_DWARF2_CFI_ASM),
>>>> emit CFI statements to handle r7's modification and restoral?  We can't
>>>> emit CFI statements unconditionally, as it's GCC's decision whether to
>>>> emit .cfi_startproc or not, and in the latter case we're not allowed to
>>>> using them in inline assembly.
>>>
>>> In theory, we ought to.  It's not very important since only r7 is
>>> affected.
>>
>> Shall I put a comment into the code then?
>
> Sounds fine.

(No ChangeLog.)

diff --git a/glibc-ports-trunk-2.11/sysdeps/unix/sysv/linux/arm/eabi/sysdep.h b/glibc-ports-trunk-2.11/sysdeps/unix/sysv/linux/arm/eabi/sysdep.h
index f3fe1f6..9d90f3e 100644
--- a/glibc-ports-trunk-2.11/sysdeps/unix/sysv/linux/arm/eabi/sysdep.h
+++ b/glibc-ports-trunk-2.11/sysdeps/unix/sysv/linux/arm/eabi/sysdep.h
@@ -50,6 +50,7 @@
    For the moment the LOAD_ARGS_7 is sacrificed.
    We can't use push/pop inside the asm because that breaks
    unwinding (ie. thread cancellation).  */
+/* FIXME: the str / ldr of r7 are not covered by CFI information.  */
 #undef LOAD_ARGS_7
 #undef INTERNAL_SYSCALL_RAW
 #define INTERNAL_SYSCALL_RAW(name, err, nr, args...)		\


Regards,
 Thomas

[-- Attachment #2: Type: application/pgp-signature, Size: 196 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Adding CFI statements to ARM's assembly code
  2010-01-13 13:57         ` Daniel Jacobowitz
  2010-03-26 11:40           ` Thomas Schwinge
@ 2010-03-26 11:50           ` Thomas Schwinge
  1 sibling, 0 replies; 24+ messages in thread
From: Thomas Schwinge @ 2010-03-26 11:50 UTC (permalink / raw)
  To: libc-ports

[-- Attachment #1: Type: text/plain, Size: 4506 bytes --]

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 #2: Type: application/pgp-signature, Size: 196 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Adding CFI statements to ARM's assembly code
  2010-03-23 15:44     ` Joseph S. Myers
@ 2010-03-26 11:58       ` Thomas Schwinge
  2010-03-26 18:14         ` Joseph S. Myers
  0 siblings, 1 reply; 24+ messages in thread
From: Thomas Schwinge @ 2010-03-26 11:58 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: libc-ports

[-- Attachment #1: Type: text/plain, Size: 1161 bytes --]

Hello!

On 2010-03-23 15:44, Joseph S. Myers wrote:
> Once the sigrestorer.S issue is resolved, I think the series
> [...]
> is ready to go in.  Please let me know if this is not the correct set of 
> patches to commit for this series.

As follows:

> http://sourceware.org/ml/libc-ports/2009-12/msg00020.html

Plus: generation of configure.

> http://sourceware.org/ml/libc-ports/2009-12/msg00021.html

Include <http://sourceware.org/ml/libc-ports/2010-03/msg00033.html> in
the former one (no ChangeLog).

> http://sourceware.org/ml/libc-ports/2009-12/msg00022.html
> http://sourceware.org/ml/libc-ports/2009-12/msg00023.html
> http://sourceware.org/ml/libc-ports/2009-12/msg00024.html
> http://sourceware.org/ml/libc-ports/2010-01/msg00004.html
> http://sourceware.org/ml/libc-ports/2010-01/msg00005.html
> http://sourceware.org/ml/libc-ports/2010-01/msg00009.html
> http://sourceware.org/ml/libc-ports/2010-01/msg00010.html
> http://sourceware.org/ml/libc-ports/2010-01/msg00013.html
> http://sourceware.org/ml/libc-ports/2010-01/msg00014.html

<http://sourceware.org/ml/libc-ports/2010-03/msg00034.html>


Regards,
 Thomas

[-- Attachment #2: Type: application/pgp-signature, Size: 196 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Adding CFI statements to ARM's assembly code
  2010-03-26 11:58       ` Thomas Schwinge
@ 2010-03-26 18:14         ` Joseph S. Myers
  2010-04-01 11:07           ` Thomas Schwinge
  0 siblings, 1 reply; 24+ messages in thread
From: Joseph S. Myers @ 2010-03-26 18:14 UTC (permalink / raw)
  To: Thomas Schwinge; +Cc: libc-ports

On Fri, 26 Mar 2010, Thomas Schwinge wrote:

> Hello!
> 
> On 2010-03-23 15:44, Joseph S. Myers wrote:
> > Once the sigrestorer.S issue is resolved, I think the series
> > [...]
> > is ready to go in.  Please let me know if this is not the correct set of 
> > patches to commit for this series.
> 
> As follows:
> 
> > http://sourceware.org/ml/libc-ports/2009-12/msg00020.html
> 
> Plus: generation of configure.
> 
> > http://sourceware.org/ml/libc-ports/2009-12/msg00021.html
> 
> Include <http://sourceware.org/ml/libc-ports/2010-03/msg00033.html> in
> the former one (no ChangeLog).
> 
> > http://sourceware.org/ml/libc-ports/2009-12/msg00022.html
> > http://sourceware.org/ml/libc-ports/2009-12/msg00023.html
> > http://sourceware.org/ml/libc-ports/2009-12/msg00024.html
> > http://sourceware.org/ml/libc-ports/2010-01/msg00004.html
> > http://sourceware.org/ml/libc-ports/2010-01/msg00005.html
> > http://sourceware.org/ml/libc-ports/2010-01/msg00009.html
> > http://sourceware.org/ml/libc-ports/2010-01/msg00010.html
> > http://sourceware.org/ml/libc-ports/2010-01/msg00013.html
> > http://sourceware.org/ml/libc-ports/2010-01/msg00014.html
> 
> <http://sourceware.org/ml/libc-ports/2010-03/msg00034.html>

Thanks.  I've now committed the full set.  Please let me know if the 
resulting state of ports is different from what you expect.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Adding CFI statements to ARM's assembly code
  2010-03-26 18:14         ` Joseph S. Myers
@ 2010-04-01 11:07           ` Thomas Schwinge
  0 siblings, 0 replies; 24+ messages in thread
From: Thomas Schwinge @ 2010-04-01 11:07 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: libc-ports

[-- Attachment #1: Type: text/plain, Size: 262 bytes --]

Hello!

On 2010-03-26 18:14, Joseph S. Myers wrote:
> I've now committed the full set.  Please let me know if the 
> resulting state of ports is different from what you expect.

Thanks; I compared it to my tree, and it's all right.


Regards,
 Thomas

[-- Attachment #2: Type: application/pgp-signature, Size: 196 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2010-04-01 11:07 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-21 16:30 Adding CFI statements to ARM's assembly code Thomas Schwinge
2009-12-21 16:55 ` Adding CFI statements to ARM's assembly code: syscall stub infrastructure Thomas Schwinge
2009-12-22  9:46   ` Adding CFI statements to ARM's assembly code: syscall function Thomas Schwinge
2009-12-22 10:50   ` Adding CFI statements to ARM's assembly code: memcpy, memmove Thomas Schwinge
2009-12-22 12:23   ` Adding CFI statements to ARM's assembly code: mmap family Thomas Schwinge
2009-12-22 12:37   ` Adding CFI statements to ARM's assembly code: socket syscall stub infrastructure Thomas Schwinge
2009-12-31 16:57 ` Adding CFI statements to ARM's assembly code Joseph S. Myers
2010-01-07 18:11   ` Thomas Schwinge
2010-01-07 18:15   ` Adding CFI statements to ARM's assembly code: mcount Thomas Schwinge
2010-01-08 12:09   ` Adding CFI statements to ARM's assembly code: _Unwind_Resume Thomas Schwinge
2010-01-11 16:47   ` Adding CFI statements to ARM's assembly code: _dl_runtime_resolve, _dl_runtime_profile Thomas Schwinge
2010-01-11 16:48   ` Adding CFI statements to ARM's assembly code: longjmp family Thomas Schwinge
2010-01-12 13:35   ` Adding CFI statements to ARM's assembly code Thomas Schwinge
2010-01-12 14:52     ` Daniel Jacobowitz
2010-01-13  9:55       ` Thomas Schwinge
2010-01-13 13:57         ` Daniel Jacobowitz
2010-03-26 11:40           ` Thomas Schwinge
2010-03-26 11:50           ` Thomas Schwinge
2010-03-23 15:44     ` Joseph S. Myers
2010-03-26 11:58       ` Thomas Schwinge
2010-03-26 18:14         ` Joseph S. Myers
2010-04-01 11:07           ` Thomas Schwinge
2010-01-12 13:35   ` Adding CFI statements to ARM's assembly code: clone Thomas Schwinge
2010-01-12 13:35   ` Adding CFI statements to ARM's assembly code: vfork family Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).