From aea7a9b9d2f9482d174ab95881b132de8472a388 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Mon, 11 Feb 2013 18:19:14 +0000 Subject: Add CFI information for MIPS assembly sources. --- ports/sysdeps/unix/mips/mips32/sysdep.h | 4 ++++ ports/sysdeps/unix/mips/mips64/n32/sysdep.h | 6 ++++++ ports/sysdeps/unix/mips/mips64/n64/sysdep.h | 6 ++++++ ports/sysdeps/unix/mips/sysdep.h | 10 ++++++---- ports/sysdeps/unix/sysv/linux/mips/clone.S | 19 +++++++++++++++---- ports/sysdeps/unix/sysv/linux/mips/getcontext.S | 11 ++++++++--- ports/sysdeps/unix/sysv/linux/mips/makecontext.S | 6 ++++-- ports/sysdeps/unix/sysv/linux/mips/mips64/n64/ioctl.S | 4 ++-- .../unix/sysv/linux/mips/mips64/nptl/sysdep-cancel.h | 1 + ports/sysdeps/unix/sysv/linux/mips/mips64/syscall.S | 8 ++++++-- .../sysdeps/unix/sysv/linux/mips/nptl/sysdep-cancel.h | 1 + ports/sysdeps/unix/sysv/linux/mips/setcontext.S | 8 ++++++-- ports/sysdeps/unix/sysv/linux/mips/swapcontext.S | 6 ++++-- ports/sysdeps/unix/sysv/linux/mips/vfork.S | 12 ++++++++---- 14 files changed, 77 insertions(+), 25 deletions(-) (limited to 'ports/sysdeps/unix') diff --git a/ports/sysdeps/unix/mips/mips32/sysdep.h b/ports/sysdeps/unix/mips/mips32/sysdep.h index d7d389253d..5c5d7695d0 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 37a67a2e69..49ae76991e 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 871184bd0f..2670c68b7d 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 bab3bc04c9..ef5c0893f3 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 72360f9621..ef801882a9 100644 --- a/ports/sysdeps/unix/sysv/linux/mips/clone.S +++ b/ports/sysdeps/unix/sysv/linux/mips/clone.S @@ -47,7 +47,8 @@ NESTED(__clone,4*SZREG,sp) SETUP_GP #endif PTR_SUBU sp, FRAMESZ - SETUP_GP64 (GPOFF, __clone) + cfi_adjust_cfa_offset (FRAMESZ) + SETUP_GP64_STACK (GPOFF, __clone) #ifdef __PIC__ SAVE_GP (GPOFF) #endif @@ -88,26 +89,35 @@ 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 */ - RESTORE_GP64 + cfi_startproc + cfi_adjust_cfa_offset (FRAMESZ) + SETUP_GP64_STACK_CFI (GPOFF) + cfi_remember_state + RESTORE_GP64_STACK 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 + RESTORE_GP64_STACK PTR_ADDU sp, FRAMESZ + cfi_adjust_cfa_offset (-FRAMESZ) jr t9 #else - RESTORE_GP64 + RESTORE_GP64_STACK PTR_ADDU sp, FRAMESZ + cfi_adjust_cfa_offset (-FRAMESZ) j __syscall_error #endif END(__clone) @@ -118,6 +128,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 0e3d35b54f..7af6825a4a 100644 --- a/ports/sysdeps/unix/sysv/linux/mips/getcontext.S +++ b/ports/sysdeps/unix/sysv/linux/mips/getcontext.S @@ -54,7 +54,8 @@ NESTED (__getcontext, FRAMESZ, ra) # endif PTR_ADDIU sp, -FRAMESZ - SETUP_GP64 (GPOFF, __getcontext) + cfi_adjust_cfa_offset (FRAMESZ) + SETUP_GP64_STACK (GPOFF, __getcontext) SAVE_GP (GPOFF) #else /* ! __PIC__ */ @@ -124,19 +125,23 @@ NESTED (__getcontext, FRAMESZ, ra) li v0, SYS_ify (rt_sigprocmask) syscall bnez a3, 99f + cfi_remember_state #ifdef __PIC__ - RESTORE_GP64 + RESTORE_GP64_STACK 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 + RESTORE_GP64_STACK 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 65f1a6aaa2..d89db01677 100644 --- a/ports/sysdeps/unix/sysv/linux/mips/makecontext.S +++ b/ports/sysdeps/unix/sysv/linux/mips/makecontext.S @@ -63,9 +63,10 @@ NESTED (__makecontext, FRAMESZ, ra) #endif PTR_ADDIU sp, -FRAMESZ + cfi_adjust_cfa_offset (FRAMESZ) #ifdef __PIC__ - SETUP_GP64 (GPOFF, __makecontext) + SETUP_GP64_STACK (GPOFF, __makecontext) SAVE_GP (GPOFF) #endif @@ -145,8 +146,9 @@ NESTED (__makecontext, FRAMESZ, ra) REG_S a1, MCONTEXT_PC(a0) #ifdef __PIC__ - RESTORE_GP64 + RESTORE_GP64_STACK 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 b3bed4663c..c5f1c350ed 100644 --- a/ports/sysdeps/unix/sysv/linux/mips/mips64/n64/ioctl.S +++ b/ports/sysdeps/unix/sysv/linux/mips/mips64/n64/ioctl.S @@ -31,9 +31,9 @@ ENTRY (__ioctl) ret L(error): - SETUP_GP64 (a0, __ioctl) + SETUP_GP64_REG (a0, __ioctl) PTR_LA t9, __syscall_error - RESTORE_GP64 + RESTORE_GP64_REG 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 354eba2f3d..6565225662 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 839276d7ad..850025c635 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,17 @@ 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) + SETUP_GP64_REG (a0, syscall) PTR_LA t9, __syscall_error - RESTORE_GP64 + RESTORE_GP64_REG 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 e1dd672528..1e0bfedecf 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 42f709d846..6ed355c97f 100644 --- a/ports/sysdeps/unix/sysv/linux/mips/setcontext.S +++ b/ports/sysdeps/unix/sysv/linux/mips/setcontext.S @@ -56,9 +56,10 @@ NESTED (__setcontext, FRAMESZ, ra) #endif PTR_ADDIU sp, -FRAMESZ + cfi_adjust_cfa_offset (FRAMESZ) #ifdef __PIC__ - SETUP_GP64 (GPOFF, __setcontext) + SETUP_GP64_STACK (GPOFF, __setcontext) SAVE_GP (GPOFF) #endif @@ -152,6 +153,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 +177,13 @@ 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 + RESTORE_GP64_STACK 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 d965f3919b..ddd3b28fde 100644 --- a/ports/sysdeps/unix/sysv/linux/mips/swapcontext.S +++ b/ports/sysdeps/unix/sysv/linux/mips/swapcontext.S @@ -63,7 +63,8 @@ NESTED (__swapcontext, FRAMESZ, ra) # endif PTR_ADDIU sp, -FRAMESZ - SETUP_GP64 (GPOFF, __swapcontext) + cfi_adjust_cfa_offset (FRAMESZ) + SETUP_GP64_STACK (GPOFF, __swapcontext) SAVE_GP (GPOFF) #else /* ! __PIC__ */ @@ -198,8 +199,9 @@ NESTED (__swapcontext, FRAMESZ, ra) 99: #ifdef __PIC__ PTR_LA t9, JUMPTARGET (__syscall_error) - RESTORE_GP64 + RESTORE_GP64_STACK 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 b9503c3943..d627923528 100644 --- a/ports/sysdeps/unix/sysv/linux/mips/vfork.S +++ b/ports/sysdeps/unix/sysv/linux/mips/vfork.S @@ -42,7 +42,8 @@ NESTED(__vfork,FRAMESZ,sp) SETUP_GP #endif PTR_SUBU sp, FRAMESZ - SETUP_GP64 (a5, __vfork) + cfi_adjust_cfa_offset (FRAMESZ) + SETUP_GP64_REG (a5, __vfork) #ifdef __PIC__ SAVE_GP (GPOFF) #endif @@ -63,6 +64,7 @@ NESTED(__vfork,FRAMESZ,sp) #endif PTR_ADDU sp, FRAMESZ + cfi_adjust_cfa_offset (-FRAMESZ) SAVE_PID @@ -75,20 +77,22 @@ NESTED(__vfork,FRAMESZ,sp) RESTORE_PID + cfi_remember_state bnez a3,L(error) /* Successful return from the parent or child. */ - RESTORE_GP64 + RESTORE_GP64_REG ret /* Something bad happened -- no child created. */ L(error): + cfi_restore_state #ifdef __PIC__ PTR_LA t9, __syscall_error - RESTORE_GP64 + RESTORE_GP64_REG jr t9 #else - RESTORE_GP64 + RESTORE_GP64_REG j __syscall_error #endif END(__vfork) -- cgit 1.4.1