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]

Add CFI information for MIPS assembly sources


This patch adds CFI information to many of the assembly sources in
MIPS glibc, similar to that for various other architectures, to
support better backtracing through such code by various tools.

This is a start on adding such CFI information rather than a patch
intended to add complete CFI information everywhere in the library.
Specifically, the following are not covered but could be covered by a
separate patch:

* Assembly sources used through inline asm in .c files (including some
complete functions generated that way through inline asm).

* The SETUP_GPX* macros.

* The bit of setcontext.S after sp is set from the saved context and
before the jump to that saved context.

* sysdeps/mips/start.S.

* sysdeps/unix/mips/sysdep.S.

For SETUP_GP64 and RESTORE_GP64, the cfi_* directives are in the
individual .S files rather than the macro definitions because the
macros can be used to save the old gp value in either a register or a
stack slot, and those need different CFI directives, so a single macro
SETUP_GP64 can't handle both cases and generate CFI at the same time.
This does mean that various callers need to condition the use of CFI
with these macro so no such CFI is generated in the o32 case when the
GP64 macros expand to empty (this is of course only needed for those
callers in .S files actually shared by o32 and non-o32 ABIs).
Although the RESTORE_GP64 doesn't actually depend on where the value
was saved, it seems better to be consistent and have the directives in
the .S files in both cases, rather than just for SETUP_GP64.

Quite a few of the changes are simply making functions consistently
use macros such as ENTRY and END at the start and end of the functions
to generate the cfi_startproc / cfi_endproc directives.  Some changes
to use ENTRY may have the effect of changing the .align directives
(which were .align 4 in some cases, now more consistently .align 2),
but I see no particular reason for the variation in those directives
in the cases where macros were previously not used at
start-of-function.

I plan to commit this patch subject to the results of testing that is
currently running, but comments or corrections are welcome.

2013-02-07  Joseph Myers  <joseph@codesourcery.com>

	* sysdeps/mips/add_n.S (__mpn_add_n): Use END.
	* sysdeps/mips/bsd-_setjmp.S (_setjmp): Likewise.
	* sysdeps/mips/bsd-setjmp.S (setjmp): Likewise.
	* sysdeps/mips/mips64/add_n.S (__mpn_add_n): Use ENTRY and END.
	* sysdeps/mips/mips64/addmul_1.S (__mpn_addmul_1): Likewise.
	* sysdeps/mips/mips64/bsd-_setjmp.S (_setjmp): Add CFI
	information.  Use END.
	* sysdeps/mips/mips64/bsd-setjmp.S (setjmp): Likewise.
	* sysdeps/mips/mips64/lshift.S (__mpn_lshift): Use ENTRY and END.
	* sysdeps/mips/mips64/mul_1.S (__mpn_mul_1): Likewise.
	* sysdeps/mips/mips64/rshift.S (__mpn_rshift): Likewise.
	* sysdeps/mips/mips64/setjmp.S (__sigsetjmp): Add CFI
	information.  Use END.
	* sysdeps/mips/mips64/sub_n.S (__mpn_sub_n): Use ENTRY and END.
	* sysdeps/mips/mips64/submul_1.S (__mpn_submul_1): Likewise.
	* sysdeps/mips/setjmp.S (__sigsetjmp): Use END.
	* sysdeps/mips/sys/asm.h (__mips_cfi_startproc): Define depending
	on [_LIBC].
	(__mips_cfi_endproc): Likewise.
	(LEAF): Use __mips_cfi_startproc.
	(NESTED): Likewise.
	(END): Use __mips_cfi_endproc.
	(EXPORT): Use __mips_cfi_startproc.
	* sysdeps/unix/mips/mips32/sysdep.h (PSEUDO): Add CFI information
	for error-handling code in both definitions.
	* sysdeps/unix/mips/mips64/n32/sysdep.h (PSEUDO): Likewise.
	* sysdeps/unix/mips/mips64/n64/sysdep.h (PSEUDO): Likewise.
	* sysdeps/unix/mips/sysdep.h (ENTRY): Use cfi_startproc.
	(END): Use cfi_endproc.
	(PSEUDO_END): Likewise.
	(PSEUDO_END_NOERRNO): Likewise.
	(PSEUDO_END_ERRVAL): Likewise.
	* sysdeps/unix/sysv/linux/mips/clone.S (__clone): Add CFI
	information.
	* sysdeps/unix/sysv/linux/mips/getcontext.S (__getcontext):
	Likewise.
	* sysdeps/unix/sysv/linux/mips/makecontext.S (__makecontext):
	Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/ioctl.S (__ioctl):
	Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/nptl/sysdep-cancel.h
	[(!NOT_IN_libc || IS_IN_libpthread || IS_IN_librt) && __PIC__]
	(PSEUDO): Use cfi_endproc before ENTRY.
	* sysdeps/unix/sysv/linux/mips/mips64/syscall.S (syscall): Add CFI
	information.
	* sysdeps/unix/sysv/linux/mips/nptl/sysdep-cancel.h [(!NOT_IN_libc
	|| IS_IN_libpthread || IS_IN_librt) && __PIC__] (PSEUDO): Use
	cfi_endproc before ENTRY.
	* sysdeps/unix/sysv/linux/mips/setcontext.S (__setcontext): Add
	CFI information.
	* sysdeps/unix/sysv/linux/mips/swapcontext.S (__swapcontext):
	Likewise.
	* sysdeps/unix/sysv/linux/mips/vfork.S (__vfork): Likewise.

diff --git a/ports/sysdeps/mips/add_n.S b/ports/sysdeps/mips/add_n.S
index 7a3848f..e83fc81 100644
--- a/ports/sysdeps/mips/add_n.S
+++ b/ports/sysdeps/mips/add_n.S
@@ -118,4 +118,4 @@ L(end):	addu	$11,$11,$2
 	sw	$11,0($4)
 	j	$31
 	or	$2,$2,$8
-	.end __mpn_add_n
+END (__mpn_add_n)
diff --git a/ports/sysdeps/mips/bsd-_setjmp.S b/ports/sysdeps/mips/bsd-_setjmp.S
index a932096..1974e4b 100644
--- a/ports/sysdeps/mips/bsd-_setjmp.S
+++ b/ports/sysdeps/mips/bsd-_setjmp.S
@@ -38,5 +38,5 @@ ENTRY (_setjmp)
 #else
 	j	C_SYMBOL_NAME (__sigsetjmp)
 #endif
-	.end	_setjmp
+END (_setjmp)
 libc_hidden_def (_setjmp)
diff --git a/ports/sysdeps/mips/bsd-setjmp.S b/ports/sysdeps/mips/bsd-setjmp.S
index 406c849..5eedcdd 100644
--- a/ports/sysdeps/mips/bsd-setjmp.S
+++ b/ports/sysdeps/mips/bsd-setjmp.S
@@ -38,4 +38,4 @@ ENTRY (setjmp)
 #else
 	j	C_SYMBOL_NAME (__sigsetjmp)
 #endif
-	.end	setjmp
+END (setjmp)
diff --git a/ports/sysdeps/mips/mips64/add_n.S b/ports/sysdeps/mips/mips64/add_n.S
index efb6cf4..020d4af 100644
--- a/ports/sysdeps/mips/mips64/add_n.S
+++ b/ports/sysdeps/mips/mips64/add_n.S
@@ -33,11 +33,7 @@
 #ifdef __PIC__
 	.option pic2
 #endif
-	.text
-	.align	2
-	.globl	__mpn_add_n
-	.ent	__mpn_add_n
-__mpn_add_n:
+ENTRY (__mpn_add_n)
 #ifdef __PIC__
 	SETUP_GP /* ??? unused */
 #endif
@@ -126,4 +122,4 @@ L(Lend):	daddu	$11,$11,$2
 	j	$31
 	or	$2,$2,$8
 
-	.end	__mpn_add_n
+END (__mpn_add_n)
diff --git a/ports/sysdeps/mips/mips64/addmul_1.S b/ports/sysdeps/mips/mips64/addmul_1.S
index 43838fd..46729a6 100644
--- a/ports/sysdeps/mips/mips64/addmul_1.S
+++ b/ports/sysdeps/mips/mips64/addmul_1.S
@@ -32,11 +32,7 @@
 #ifdef PIC
 	.option pic2
 #endif
-	.text
-	.align	4
-	.globl	__mpn_addmul_1
-	.ent	__mpn_addmul_1
-__mpn_addmul_1:
+ENTRY (__mpn_addmul_1)
 #ifdef PIC
 	SETUP_GP /* ??? unused */
 #endif
@@ -102,4 +98,4 @@ L(LC0):	ld	$10,0($4)
 	j	$31
 	daddu	$2,$9,$2	# add high product limb and carry from addition
 
-	.end	__mpn_addmul_1
+END (__mpn_addmul_1)
diff --git a/ports/sysdeps/mips/mips64/bsd-_setjmp.S b/ports/sysdeps/mips/mips64/bsd-_setjmp.S
index de36cf0..f5ef852 100644
--- a/ports/sysdeps/mips/mips64/bsd-_setjmp.S
+++ b/ports/sysdeps/mips/mips64/bsd-_setjmp.S
@@ -32,16 +32,18 @@ ENTRY (_setjmp)
 	SETUP_GP
 #endif
 	SETUP_GP64 (v0, C_SYMBOL_NAME (_setjmp))
+	cfi_register (gp, v0)
 	PTR_LA t9, C_SYMBOL_NAME (__sigsetjmp)
 #if _MIPS_SIM == _ABIO32
 	nop
 #endif	
 	RESTORE_GP64
+	cfi_restore (gp)
 	move	a1, zero		/* Pass a second argument of zero.  */
 #ifdef __PIC__
 	jr	t9
 #else
 	j	C_SYMBOL_NAME (__sigsetjmp)
 #endif
-	.end	_setjmp
+END (_setjmp)
 libc_hidden_def (_setjmp)
diff --git a/ports/sysdeps/mips/mips64/bsd-setjmp.S b/ports/sysdeps/mips/mips64/bsd-setjmp.S
index c3e26bf..fdd405e 100644
--- a/ports/sysdeps/mips/mips64/bsd-setjmp.S
+++ b/ports/sysdeps/mips/mips64/bsd-setjmp.S
@@ -32,15 +32,17 @@ ENTRY (setjmp)
 	SETUP_GP
 #endif
 	SETUP_GP64 (v0, C_SYMBOL_NAME (setjmp))
+	cfi_register (gp, v0)
 	PTR_LA t9, C_SYMBOL_NAME (__sigsetjmp)
 #if _MIPS_SIM == _ABIO32
 	nop
 #endif	
 	RESTORE_GP64
+	cfi_restore (gp)
 	dli a1, 1		/* Pass a second argument of one.  */
 #ifdef __PIC__
 	jr	t9
 #else
 	j	C_SYMBOL_NAME (__sigsetjmp)
 #endif
-	.end	setjmp
+END (setjmp)
diff --git a/ports/sysdeps/mips/mips64/lshift.S b/ports/sysdeps/mips/mips64/lshift.S
index e0b02bc..740408d 100644
--- a/ports/sysdeps/mips/mips64/lshift.S
+++ b/ports/sysdeps/mips/mips64/lshift.S
@@ -32,11 +32,7 @@
 #ifdef __PIC__
 	.option pic2
 #endif
-	.text
-	.align	2
-	.globl	__mpn_lshift
-	.ent	__mpn_lshift
-__mpn_lshift:
+ENTRY (__mpn_lshift)
 #ifdef __PIC__
 	SETUP_GP /* ??? unused */
 #endif
@@ -101,4 +97,4 @@ L(Loop):	ld	$3,-16($5)
 L(Lend):	dsll	$8,$10,$7
 	j	$31
 	sd	$8,-8($4)
-	.end	__mpn_lshift
+END (__mpn_lshift)
diff --git a/ports/sysdeps/mips/mips64/mul_1.S b/ports/sysdeps/mips/mips64/mul_1.S
index 2fe28d3..e136065 100644
--- a/ports/sysdeps/mips/mips64/mul_1.S
+++ b/ports/sysdeps/mips/mips64/mul_1.S
@@ -33,11 +33,7 @@
 #ifdef __PIC__
 	.option pic2
 #endif
-	.text
-	.align	4
-	.globl	__mpn_mul_1
-	.ent	__mpn_mul_1
-__mpn_mul_1:
+ENTRY (__mpn_mul_1)
 #ifdef __PIC__
 	SETUP_GP /* ??? unused */
 #endif
@@ -91,4 +87,4 @@ L(LC0):	mflo	$10
 	j	$31
 	daddu	$2,$9,$2	# add high product limb and carry from addition
 
-	.end	__mpn_mul_1
+END (__mpn_mul_1)
diff --git a/ports/sysdeps/mips/mips64/rshift.S b/ports/sysdeps/mips/mips64/rshift.S
index 75ac68b..0d821f2 100644
--- a/ports/sysdeps/mips/mips64/rshift.S
+++ b/ports/sysdeps/mips/mips64/rshift.S
@@ -32,11 +32,7 @@
 #ifdef __PIC__
 	.option pic2
 #endif
-	.text
-	.align	2
-	.globl	__mpn_rshift
-	.ent	__mpn_rshift
-__mpn_rshift:
+ENTRY (__mpn_rshift)
 #ifdef __PIC__
 	SETUP_GP /* ??? unused */
 #endif
@@ -98,4 +94,4 @@ L(Loop):	ld	$3,8($5)
 L(Lend):	dsrl	$8,$10,$7
 	j	$31
 	sd	$8,0($4)
-	.end	__mpn_rshift
+END (__mpn_rshift)
diff --git a/ports/sysdeps/mips/mips64/setjmp.S b/ports/sysdeps/mips/mips64/setjmp.S
index 53ed92c..e355957 100644
--- a/ports/sysdeps/mips/mips64/setjmp.S
+++ b/ports/sysdeps/mips/mips64/setjmp.S
@@ -30,6 +30,7 @@ ENTRY (__sigsetjmp)
 	SETUP_GP
 #endif
 	SETUP_GP64 (v0, C_SYMBOL_NAME (__sigsetjmp))
+	cfi_register (gp, v0)
 	move a2, sp
 	move a3, fp
 	PTR_LA t9, __sigsetjmp_aux
@@ -37,8 +38,9 @@ ENTRY (__sigsetjmp)
 	nop
 #endif	
 	RESTORE_GP64
+	cfi_restore (gp)
 #if _MIPS_SIM != _ABIO32
 	move a4, gp
 #endif
 	jr t9
-	.end __sigsetjmp
+END (__sigsetjmp)
diff --git a/ports/sysdeps/mips/mips64/sub_n.S b/ports/sysdeps/mips/mips64/sub_n.S
index ea8f4bd..dd6f691 100644
--- a/ports/sysdeps/mips/mips64/sub_n.S
+++ b/ports/sysdeps/mips/mips64/sub_n.S
@@ -33,11 +33,7 @@
 #ifdef __PIC__
 	.option pic2
 #endif
-	.text
-	.align	2
-	.globl	__mpn_sub_n
-	.ent	__mpn_sub_n
-__mpn_sub_n:
+ENTRY (__mpn_sub_n)
 #ifdef __PIC__
 	SETUP_GP /* ??? unused */
 #endif
@@ -126,4 +122,4 @@ L(Lend):	daddu	$11,$11,$2
 	j	$31
 	or	$2,$2,$8
 
-	.end	__mpn_sub_n
+END (__mpn_sub_n)
diff --git a/ports/sysdeps/mips/mips64/submul_1.S b/ports/sysdeps/mips/mips64/submul_1.S
index 22239d5..bf5d6ff 100644
--- a/ports/sysdeps/mips/mips64/submul_1.S
+++ b/ports/sysdeps/mips/mips64/submul_1.S
@@ -33,11 +33,7 @@
 #ifdef __PIC__
 	.option pic2
 #endif
-	.text
-	.align	4
-	.globl	__mpn_submul_1
-	.ent	__mpn_submul_1
-__mpn_submul_1:
+ENTRY (__mpn_submul_1)
 #ifdef __PIC__
 	SETUP_GP /* ??? unused */
 #endif
@@ -103,4 +99,4 @@ L(LC0):	ld	$10,0($4)
 	j	$31
 	daddu	$2,$9,$2	# add high product limb and carry from addition
 
-	.end	__mpn_submul_1
+END (__mpn_submul_1)
diff --git a/ports/sysdeps/mips/setjmp.S b/ports/sysdeps/mips/setjmp.S
index 7c53b97..3f923fb 100644
--- a/ports/sysdeps/mips/setjmp.S
+++ b/ports/sysdeps/mips/setjmp.S
@@ -41,4 +41,4 @@ ENTRY (__sigsetjmp)
 #else
 	j	__sigsetjmp_aux
 #endif
-	.end __sigsetjmp
+END (__sigsetjmp)
diff --git a/ports/sysdeps/mips/sys/asm.h b/ports/sysdeps/mips/sys/asm.h
index 605451a..62ff378 100644
--- a/ports/sysdeps/mips/sys/asm.h
+++ b/ports/sysdeps/mips/sys/asm.h
@@ -26,6 +26,14 @@
 # define CAT(str1,str2) __CAT(str1,str2)
 #endif
 
+#ifdef _LIBC
+# define __mips_cfi_startproc cfi_startproc
+# define __mips_cfi_endproc cfi_endproc
+#else
+# define __mips_cfi_startproc /* Empty.  */
+# define __mips_cfi_endproc /* Empty.  */
+#endif
+
 /*
  * Macros to handle different pointer/register sizes for 32/64-bit code
  *
@@ -147,7 +155,8 @@ l:							\
 		.align	2;                              \
 		.type	symbol,@function;               \
 		.ent	symbol,0;                       \
-symbol:		.frame	sp,0,ra
+symbol:		.frame	sp,0,ra;			\
+		__mips_cfi_startproc
 
 /*
  * NESTED - declare nested routine entry point
@@ -157,13 +166,15 @@ symbol:		.frame	sp,0,ra
 		.align	2;                              \
 		.type	symbol,@function;               \
 		.ent	symbol,0;                       \
-symbol:		.frame	sp, framesize, rpc
+symbol:		.frame	sp, framesize, rpc;		\
+		__mips_cfi_startproc
 
 /*
  * END - mark end of function
  */
 #ifndef END
 # define END(function)                                   \
+		__mips_cfi_endproc;			\
 		.end	function;		        \
 		.size	function,.-function
 #endif
@@ -173,7 +184,7 @@ symbol:		.frame	sp, framesize, rpc
  */
 #define	EXPORT(symbol)                                  \
 		.globl	symbol;                         \
-symbol:
+symbol:		__mips_cfi_startproc
 
 /*
  * ABS - export absolute symbol
diff --git a/ports/sysdeps/unix/mips/mips32/sysdep.h b/ports/sysdeps/unix/mips/mips32/sysdep.h
index d7d3892..5c5d769 100644
--- a/ports/sysdeps/unix/mips/mips32/sysdep.h
+++ b/ports/sysdeps/unix/mips/mips32/sysdep.h
@@ -24,8 +24,10 @@
 #ifdef __PIC__
 #define PSEUDO(name, syscall_name, args) \
   .align 2;								      \
+  cfi_startproc;							      \
   99: la t9,__syscall_error;						      \
   jr t9;								      \
+  cfi_endproc;								      \
   ENTRY(name)								      \
   .set noreorder;							      \
   .cpload t9;								      \
@@ -38,8 +40,10 @@ L(syse1):
 #define PSEUDO(name, syscall_name, args) \
   .set noreorder;							      \
   .align 2;								      \
+  cfi_startproc;							      \
   99: j __syscall_error;						      \
   nop;									      \
+  cfi_endproc;								      \
   ENTRY(name)								      \
   .set noreorder;							      \
   li v0, SYS_ify(syscall_name);						      \
diff --git a/ports/sysdeps/unix/mips/mips64/n32/sysdep.h b/ports/sysdeps/unix/mips/mips64/n32/sysdep.h
index 37a67a2..49ae769 100644
--- a/ports/sysdeps/unix/mips/mips64/n32/sysdep.h
+++ b/ports/sysdeps/unix/mips/mips64/n32/sysdep.h
@@ -26,13 +26,17 @@
 #ifdef __PIC__
 #define PSEUDO(name, syscall_name, args) \
   .align 2;								      \
+  cfi_startproc;							      \
   99:;									      \
   .set noat;								      \
   .cpsetup t9, $1, name;						      \
+  cfi_register (gp, $1);						      \
   .set at;								      \
   la t9,__syscall_error;						      \
   .cpreturn;								      \
+  cfi_restore (gp);							      \
   jr t9;								      \
+  cfi_endproc;								      \
   ENTRY(name)								      \
   li v0, SYS_ify(syscall_name);						      \
   syscall;								      \
@@ -42,8 +46,10 @@ L(syse1):
 #define PSEUDO(name, syscall_name, args) \
   .set noreorder;							      \
   .align 2;								      \
+  cfi_startproc;							      \
   99: j __syscall_error;						      \
   nop;                                                                        \
+  cfi_endproc;								      \
   ENTRY(name)								      \
   .set noreorder;							      \
   li v0, SYS_ify(syscall_name);						      \
diff --git a/ports/sysdeps/unix/mips/mips64/n64/sysdep.h b/ports/sysdeps/unix/mips/mips64/n64/sysdep.h
index 871184b..2670c68 100644
--- a/ports/sysdeps/unix/mips/mips64/n64/sysdep.h
+++ b/ports/sysdeps/unix/mips/mips64/n64/sysdep.h
@@ -26,13 +26,17 @@
 #ifdef __PIC__
 #define PSEUDO(name, syscall_name, args) \
   .align 2;								      \
+  cfi_startproc;							      \
   99:;									      \
   .set noat;								      \
   .cpsetup t9, $1, name;						      \
+  cfi_register (gp, $1);						      \
   .set at;								      \
   dla t9,__syscall_error;						      \
   .cpreturn;								      \
+  cfi_restore (gp);							      \
   jr t9;								      \
+  cfi_endproc;								      \
   ENTRY(name)								      \
   li v0, SYS_ify(syscall_name);						      \
   syscall;								      \
@@ -42,8 +46,10 @@ L(syse1):
 #define PSEUDO(name, syscall_name, args) \
   .set noreorder;							      \
   .align 2;								      \
+  cfi_startproc;							      \
   99: j __syscall_error;						      \
   nop;                                                                        \
+  cfi_endproc;								      \
   ENTRY(name)								      \
   .set noreorder;							      \
   li v0, SYS_ify(syscall_name);						      \
diff --git a/ports/sysdeps/unix/mips/sysdep.h b/ports/sysdeps/unix/mips/sysdep.h
index bab3bc0..ef5c089 100644
--- a/ports/sysdeps/unix/mips/sysdep.h
+++ b/ports/sysdeps/unix/mips/sysdep.h
@@ -27,17 +27,19 @@
   .globl name;								      \
   .align 2;								      \
   .ent name,0;								      \
-  name##:
+  name##:								      \
+  cfi_startproc;
 
 #undef END
 #define	END(function)                                   \
+		cfi_endproc;				\
 		.end	function;		        \
 		.size	function,.-function
 
 #define ret	j ra ; nop
 
 #undef PSEUDO_END
-#define PSEUDO_END(sym) .end sym; .size sym,.-sym
+#define PSEUDO_END(sym) cfi_endproc; .end sym; .size sym,.-sym
 
 #define PSEUDO_NOERRNO(name, syscall_name, args)	\
   .align 2;						\
@@ -47,7 +49,7 @@
   syscall
 
 #undef PSEUDO_END_NOERRNO
-#define PSEUDO_END_NOERRNO(sym) .end sym; .size sym,.-sym
+#define PSEUDO_END_NOERRNO(sym) cfi_endproc; .end sym; .size sym,.-sym
 
 #define ret_NOERRNO ret
 
@@ -59,7 +61,7 @@
   syscall
 
 #undef PSEUDO_END_ERRVAL
-#define PSEUDO_END_ERRVAL(sym) .end sym; .size sym,.-sym
+#define PSEUDO_END_ERRVAL(sym) cfi_endproc; .end sym; .size sym,.-sym
 
 #define ret_ERRVAL ret
 
diff --git a/ports/sysdeps/unix/sysv/linux/mips/clone.S b/ports/sysdeps/unix/sysv/linux/mips/clone.S
index 72360f9..351642d 100644
--- a/ports/sysdeps/unix/sysv/linux/mips/clone.S
+++ b/ports/sysdeps/unix/sysv/linux/mips/clone.S
@@ -47,7 +47,11 @@ NESTED(__clone,4*SZREG,sp)
 	SETUP_GP
 #endif
 	PTR_SUBU sp, FRAMESZ
+	cfi_adjust_cfa_offset (FRAMESZ)
 	SETUP_GP64 (GPOFF, __clone)
+#if _MIPS_SIM != _ABIO32
+	cfi_rel_offset (gp, GPOFF)
+#endif
 #ifdef __PIC__
 	SAVE_GP (GPOFF)
 #endif
@@ -88,26 +92,40 @@ NESTED(__clone,4*SZREG,sp)
 
 	/* Do the system call */
 	li		v0,__NR_clone
+	cfi_endproc
 	syscall
 
 	bnez		a3,L(error)
 	beqz		v0,L(thread_start)
 
 	/* Successful return from the parent */
+	cfi_startproc
+	cfi_adjust_cfa_offset (FRAMESZ)
+#if _MIPS_SIM != _ABIO32
+	cfi_rel_offset (gp, GPOFF)
+#endif
+	cfi_remember_state
 	RESTORE_GP64
+	cfi_restore (gp)
 	PTR_ADDU	sp, FRAMESZ
+	cfi_adjust_cfa_offset (-FRAMESZ)
 	ret
 
 	/* Something bad happened -- no child created */
 L(error):
+	cfi_restore_state
 #ifdef __PIC__
 	PTR_LA		t9,__syscall_error
 	RESTORE_GP64
+	cfi_restore (gp)
 	PTR_ADDU	sp, FRAMESZ
+	cfi_adjust_cfa_offset (-FRAMESZ)
 	jr		t9
 #else
 	RESTORE_GP64
+	cfi_restore (gp)
 	PTR_ADDU	sp, FRAMESZ
+	cfi_adjust_cfa_offset (-FRAMESZ)
 	j		__syscall_error
 #endif
 	END(__clone)
@@ -118,6 +136,7 @@ L(error):
 
 ENTRY(__thread_start)
 L(thread_start):
+	cfi_undefined ($31)
 	/* cp is already loaded.  */
 	SAVE_GP (GPOFF)
 	/* The stackframe has been created on entry of clone().  */
diff --git a/ports/sysdeps/unix/sysv/linux/mips/getcontext.S b/ports/sysdeps/unix/sysv/linux/mips/getcontext.S
index 0e3d35b..a52ff1c 100644
--- a/ports/sysdeps/unix/sysv/linux/mips/getcontext.S
+++ b/ports/sysdeps/unix/sysv/linux/mips/getcontext.S
@@ -54,7 +54,11 @@ NESTED (__getcontext, FRAMESZ, ra)
 # endif
 
 	PTR_ADDIU sp, -FRAMESZ
+	cfi_adjust_cfa_offset (FRAMESZ)
 	SETUP_GP64 (GPOFF, __getcontext)
+# if _MIPS_SIM != _ABIO32
+	cfi_rel_offset (gp, GPOFF)
+# endif
 	SAVE_GP (GPOFF)
 
 #else  /* ! __PIC__ */
@@ -124,19 +128,29 @@ NESTED (__getcontext, FRAMESZ, ra)
 	li	v0, SYS_ify (rt_sigprocmask)
 	syscall
 	bnez	a3, 99f
+	cfi_remember_state
 
 #ifdef __PIC__
 	RESTORE_GP64
+# if _MIPS_SIM != _ABIO32
+	cfi_restore (gp)
+# endif
 	PTR_ADDIU sp, FRAMESZ
+	cfi_adjust_cfa_offset (-FRAMESZ)
 #endif
 	move	v0, zero
 	jr	ra
 
 99:
+	cfi_restore_state
 #ifdef __PIC__
 	PTR_LA	t9, JUMPTARGET (__syscall_error)
 	RESTORE_GP64
+# if _MIPS_SIM != _ABIO32
+	cfi_restore (gp)
+# endif
 	PTR_ADDIU sp, FRAMESZ
+	cfi_adjust_cfa_offset (-FRAMESZ)
 	jr	t9
 
 #else  /* ! __PIC__ */
diff --git a/ports/sysdeps/unix/sysv/linux/mips/makecontext.S b/ports/sysdeps/unix/sysv/linux/mips/makecontext.S
index 65f1a6a..6a6130a 100644
--- a/ports/sysdeps/unix/sysv/linux/mips/makecontext.S
+++ b/ports/sysdeps/unix/sysv/linux/mips/makecontext.S
@@ -63,9 +63,13 @@ NESTED (__makecontext, FRAMESZ, ra)
 #endif
 
 	PTR_ADDIU sp, -FRAMESZ
+	cfi_adjust_cfa_offset (FRAMESZ)
 
 #ifdef __PIC__
 	SETUP_GP64 (GPOFF, __makecontext)
+# if _MIPS_SIM != _ABIO32
+	cfi_rel_offset (gp, GPOFF)
+# endif
 	SAVE_GP (GPOFF)
 #endif
 
@@ -146,7 +150,11 @@ NESTED (__makecontext, FRAMESZ, ra)
 
 #ifdef __PIC__
 	RESTORE_GP64
+# if _MIPS_SIM != _ABIO32
+	cfi_restore (gp)
+# endif
 	PTR_ADDIU sp, FRAMESZ
+	cfi_adjust_cfa_offset (-FRAMESZ)
 #endif
 	jr	ra
 
diff --git a/ports/sysdeps/unix/sysv/linux/mips/mips64/n64/ioctl.S b/ports/sysdeps/unix/sysv/linux/mips/mips64/n64/ioctl.S
index b3bed46..b1f5244 100644
--- a/ports/sysdeps/unix/sysv/linux/mips/mips64/n64/ioctl.S
+++ b/ports/sysdeps/unix/sysv/linux/mips/mips64/n64/ioctl.S
@@ -32,8 +32,10 @@ ENTRY (__ioctl)
 
 L(error):
 	SETUP_GP64 (a0, __ioctl)
+	cfi_register (gp, a0)
 	PTR_LA t9, __syscall_error
 	RESTORE_GP64
+	cfi_restore (gp)
 	jr t9
 
 PSEUDO_END (__ioctl)
diff --git a/ports/sysdeps/unix/sysv/linux/mips/mips64/nptl/sysdep-cancel.h b/ports/sysdeps/unix/sysv/linux/mips/mips64/nptl/sysdep-cancel.h
index 354eba2..6565225 100644
--- a/ports/sysdeps/unix/sysv/linux/mips/mips64/nptl/sysdep-cancel.h
+++ b/ports/sysdeps/unix/sysv/linux/mips/mips64/nptl/sysdep-cancel.h
@@ -57,6 +57,7 @@
     cfi_same_value (gp);						      \
     RESTORESTK;								      \
     ret;								      \
+    cfi_endproc;							      \
   .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel;	      \
   ENTRY (name)								      \
     SAVESTK;								      \
diff --git a/ports/sysdeps/unix/sysv/linux/mips/mips64/syscall.S b/ports/sysdeps/unix/sysv/linux/mips/mips64/syscall.S
index 839276d..5d4a405 100644
--- a/ports/sysdeps/unix/sysv/linux/mips/mips64/syscall.S
+++ b/ports/sysdeps/unix/sysv/linux/mips/mips64/syscall.S
@@ -30,7 +30,9 @@ NESTED (syscall, SZREG, ra)
 	.mask 0x00010000, -SZREG
 	.fmask 0x00000000, 0
 	PTR_ADDIU sp, -SZREG
+	cfi_adjust_cfa_offset (SZREG)
 	REG_S s0, (sp)
+	cfi_rel_offset (s0, 0)
 
 	move s0, a0
 	move a0, a1		/* shift arg1 - arg7.  */
@@ -45,15 +47,19 @@ NESTED (syscall, SZREG, ra)
 	syscall			/* Do the system call.  */
 
 	REG_L s0, (sp)
+	cfi_restore (s0)
 	PTR_ADDIU sp, SZREG
+	cfi_adjust_cfa_offset (-SZREG)
 	bne a3, zero, L(error)
 
 	ret
 
 L(error):
 	SETUP_GP64 (a0, syscall)
+	cfi_register (gp, a0)
 	PTR_LA t9, __syscall_error
 	RESTORE_GP64
+	cfi_restore (gp)
 	jr t9
 
 END (syscall)
diff --git a/ports/sysdeps/unix/sysv/linux/mips/nptl/sysdep-cancel.h b/ports/sysdeps/unix/sysv/linux/mips/nptl/sysdep-cancel.h
index e1dd672..1e0bfed 100644
--- a/ports/sysdeps/unix/sysv/linux/mips/nptl/sysdep-cancel.h
+++ b/ports/sysdeps/unix/sysv/linux/mips/nptl/sysdep-cancel.h
@@ -52,6 +52,7 @@
     .set reorder;							      \
     bne a3, zero, 99b;					       		      \
     ret;								      \
+    cfi_endproc;							      \
   .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel;	      \
   ENTRY (name)								      \
     .set noreorder;							      \
diff --git a/ports/sysdeps/unix/sysv/linux/mips/setcontext.S b/ports/sysdeps/unix/sysv/linux/mips/setcontext.S
index 42f709d..097f2aa 100644
--- a/ports/sysdeps/unix/sysv/linux/mips/setcontext.S
+++ b/ports/sysdeps/unix/sysv/linux/mips/setcontext.S
@@ -56,9 +56,13 @@ NESTED (__setcontext, FRAMESZ, ra)
 #endif
 
 	PTR_ADDIU sp, -FRAMESZ
+	cfi_adjust_cfa_offset (FRAMESZ)
 
 #ifdef __PIC__
 	SETUP_GP64 (GPOFF, __setcontext)
+# if _MIPS_SIM != _ABIO32
+	cfi_rel_offset (gp, GPOFF)
+# endif
 	SAVE_GP (GPOFF)
 #endif
 
@@ -152,6 +156,7 @@ NESTED (__setcontext, FRAMESZ, ra)
 	   and call the signal return syscall as if a signal
 	   handler exited normally.  */
 	PTR_ADDIU sp, -((RT_SIGFRAME_SIZE + ALSZ) & ALMASK)
+	cfi_adjust_cfa_offset ((RT_SIGFRAME_SIZE + ALSZ) & ALMASK)
 
 	/* Only ucontext is referred to from rt_sigreturn,
 	   copy it.  */
@@ -175,11 +180,16 @@ NESTED (__setcontext, FRAMESZ, ra)
 	   path.  Successful rt_sigreturn never returns to
 	   its calling place.  */
 	PTR_ADDIU sp, ((RT_SIGFRAME_SIZE + ALSZ) & ALMASK)
+	cfi_adjust_cfa_offset (-((RT_SIGFRAME_SIZE + ALSZ) & ALMASK))
 99:
 #ifdef __PIC__
 	PTR_LA	t9, JUMPTARGET (__syscall_error)
 	RESTORE_GP64
+# if _MIPS_SIM != _ABIO32
+	cfi_restore (gp)
+# endif
 	PTR_ADDIU sp, FRAMESZ
+	cfi_adjust_cfa_offset (-FRAMESZ)
 	jr	t9
 
 #else  /* ! __PIC__ */
diff --git a/ports/sysdeps/unix/sysv/linux/mips/swapcontext.S b/ports/sysdeps/unix/sysv/linux/mips/swapcontext.S
index d965f39..4db10b8 100644
--- a/ports/sysdeps/unix/sysv/linux/mips/swapcontext.S
+++ b/ports/sysdeps/unix/sysv/linux/mips/swapcontext.S
@@ -63,7 +63,11 @@ NESTED (__swapcontext, FRAMESZ, ra)
 # endif
 
 	PTR_ADDIU sp, -FRAMESZ
+	cfi_adjust_cfa_offset (FRAMESZ)
 	SETUP_GP64 (GPOFF, __swapcontext)
+# if _MIPS_SIM != _ABIO32
+	cfi_rel_offset (gp, GPOFF)
+# endif
 	SAVE_GP (GPOFF)
 
 #else  /* ! __PIC__ */
@@ -199,7 +203,11 @@ NESTED (__swapcontext, FRAMESZ, ra)
 #ifdef __PIC__
 	PTR_LA	t9, JUMPTARGET (__syscall_error)
 	RESTORE_GP64
+# if _MIPS_SIM != _ABIO32
+	cfi_restore (gp)
+# endif
 	PTR_ADDIU sp, FRAMESZ
+	cfi_adjust_cfa_offset (-FRAMESZ)
 	jr	t9
 
 #else  /* ! __PIC__ */
diff --git a/ports/sysdeps/unix/sysv/linux/mips/vfork.S b/ports/sysdeps/unix/sysv/linux/mips/vfork.S
index b9503c3..be8c63b 100644
--- a/ports/sysdeps/unix/sysv/linux/mips/vfork.S
+++ b/ports/sysdeps/unix/sysv/linux/mips/vfork.S
@@ -42,7 +42,11 @@ NESTED(__vfork,FRAMESZ,sp)
 	SETUP_GP
 #endif
 	PTR_SUBU sp, FRAMESZ
+	cfi_adjust_cfa_offset (FRAMESZ)
 	SETUP_GP64 (a5, __vfork)
+#if _MIPS_SIM != _ABIO32
+	cfi_register (gp, a5)
+#endif
 #ifdef __PIC__
 	SAVE_GP (GPOFF)
 #endif
@@ -63,6 +67,7 @@ NESTED(__vfork,FRAMESZ,sp)
 #endif
 
 	PTR_ADDU	sp, FRAMESZ
+	cfi_adjust_cfa_offset (-FRAMESZ)
 
 	SAVE_PID
 
@@ -75,20 +80,31 @@ NESTED(__vfork,FRAMESZ,sp)
 
 	RESTORE_PID
 
+	cfi_remember_state
 	bnez		a3,L(error)
 
 	/* Successful return from the parent or child.  */
 	RESTORE_GP64
+#if _MIPS_SIM != _ABIO32
+	cfi_restore (gp)
+#endif
 	ret
 
 	/* Something bad happened -- no child created.  */
 L(error):
+	cfi_restore_state
 #ifdef __PIC__
 	PTR_LA		t9, __syscall_error
 	RESTORE_GP64
+# if _MIPS_SIM != _ABIO32
+	cfi_restore (gp)
+# endif
 	jr		t9
 #else
 	RESTORE_GP64
+# if _MIPS_SIM != _ABIO32
+	cfi_restore (gp)
+# endif
 	j		__syscall_error
 #endif
 	END(__vfork)

-- 
Joseph S. Myers
joseph@codesourcery.com


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