Skip to content

Commit

Permalink
mips: add CFI directives to assembler sources, NDMS-1223
Browse files Browse the repository at this point in the history
CFI directives moved to .debug_frame section (instead of .eh_frame)
since these may be removed by a strip utility.
  • Loading branch information
ksergeyv authored and eyudin committed Jan 21, 2021
1 parent e8ab109 commit ee63340
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 1 deletion.
11 changes: 11 additions & 0 deletions crt/mips/crti.s
@@ -1,19 +1,30 @@
.cfi_sections .debug_frame
.set noreorder

.section .init
.global _init
.type _init,@function
.align 2
_init:
.cfi_startproc
subu $sp,$sp,32
.cfi_adjust_cfa_offset 32
sw $gp,24($sp)
.cfi_rel_offset $gp, 24
sw $ra,28($sp)
.cfi_rel_offset $ra, 28
.cfi_endproc

.section .fini
.global _fini
.type _fini,@function
.align 2
_fini:
.cfi_startproc
subu $sp,$sp,32
.cfi_adjust_cfa_offset 32
sw $gp,24($sp)
.cfi_rel_offset $gp, 24
sw $ra,28($sp)
.cfi_rel_offset $ra, 28
.cfi_endproc
7 changes: 7 additions & 0 deletions crt/mips/crtn.s
@@ -1,13 +1,20 @@
.cfi_sections .debug_frame
.set noreorder

.section .init
.cfi_startproc
lw $gp,24($sp)
lw $ra,28($sp)
j $ra
addu $sp,$sp,32
.cfi_adjust_cfa_offset -32
.cfi_endproc

.section .fini
.cfi_startproc
lw $gp,24($sp)
lw $ra,28($sp)
j $ra
addu $sp,$sp,32
.cfi_adjust_cfa_offset -32
.cfi_endproc
7 changes: 7 additions & 0 deletions src/ldso/mips/dlsym.s
@@ -1,17 +1,24 @@
.cfi_sections .debug_frame
.set noreorder
.global dlsym
.hidden __dlsym
.type dlsym,@function
dlsym:
.cfi_startproc
lui $gp, %hi(_gp_disp)
addiu $gp, %lo(_gp_disp)
addu $gp, $gp, $25
move $6, $ra
lw $25, %call16(__dlsym)($gp)
addiu $sp, $sp, -16
.cfi_adjust_cfa_offset 16
sw $ra, 12($sp)
.cfi_rel_offset $ra, 12
jalr $25
nop
lw $ra, 12($sp)
.cfi_restore $ra
jr $ra
addiu $sp, $sp, 16
.cfi_adjust_cfa_offset -16
.cfi_endproc
5 changes: 5 additions & 0 deletions src/signal/mips/restore.s
@@ -1,15 +1,20 @@
.cfi_sections .debug_frame
.set noreorder

.global __restore_rt
.hidden __restore_rt
.type __restore_rt,@function
__restore_rt:
.cfi_startproc
li $2, 4193
syscall
.cfi_endproc

.global __restore
.hidden __restore
.type __restore,@function
__restore:
.cfi_startproc
li $2, 4119
syscall
.cfi_endproc
3 changes: 3 additions & 0 deletions src/signal/mips/sigsetjmp.s
@@ -1,3 +1,4 @@
.cfi_sections .debug_frame
.set noreorder

.global sigsetjmp
Expand All @@ -6,6 +7,7 @@
.type __sigsetjmp,@function
sigsetjmp:
__sigsetjmp:
.cfi_startproc
lui $gp, %hi(_gp_disp)
addiu $gp, %lo(_gp_disp)
beq $5, $0, 1f
Expand All @@ -31,3 +33,4 @@ __sigsetjmp:
1: lw $25, %call16(setjmp)($gp)
jr $25
nop
.cfi_endproc
5 changes: 5 additions & 0 deletions src/thread/mips/__unmapself.s
@@ -1,10 +1,15 @@
.cfi_sections .debug_frame
.set noreorder
.global __unmapself
.type __unmapself,@function
__unmapself:
.cfi_startproc
move $sp, $25
.cfi_undefined $sp
.cfi_def_cfa_offset 0
li $2, 4091
syscall
li $4, 0
li $2, 4001
syscall
.cfi_endproc
9 changes: 8 additions & 1 deletion src/thread/mips/clone.s
@@ -1,8 +1,10 @@
.cfi_sections .debug_frame
.set noreorder
.global __clone
.hidden __clone
.type __clone,@function
__clone:
.cfi_startproc
# Save function pointer and argument pointer on new thread stack
and $5, $5, -8
subu $5, $5, 16
Expand All @@ -14,23 +16,28 @@ __clone:
lw $7, 20($sp)
lw $9, 24($sp)
subu $sp, $sp, 16
.cfi_adjust_cfa_offset 16
sw $9, 16($sp)
li $2, 4120
syscall
beq $7, $0, 1f
nop
addu $sp, $sp, 16
.cfi_adjust_cfa_offset -16
jr $ra
subu $2, $0, $2
1: beq $2, $0, 1f
nop
addu $sp, $sp, 16
.cfi_adjust_cfa_offset -16
jr $ra
nop
1: lw $25, 0($sp)
1: .cfi_undefined $ra
lw $25, 0($sp)
lw $4, 4($sp)
jalr $25
nop
move $4, $2
li $2, 4001
syscall
.cfi_endproc
8 changes: 8 additions & 0 deletions src/thread/mips/syscall_cp.s
@@ -1,3 +1,4 @@
.cfi_sections .debug_frame
.set noreorder

.global __cp_begin
Expand All @@ -14,7 +15,9 @@
.hidden __syscall_cp_asm
.type __syscall_cp_asm,@function
__syscall_cp_asm:
.cfi_startproc
subu $sp, $sp, 32
.cfi_adjust_cfa_offset 32
__cp_begin:
lw $4, 0($4)
bne $4, $0, __cp_cancel
Expand All @@ -35,14 +38,17 @@ __cp_begin:
__cp_end:
beq $7, $0, 1f
addu $sp, $sp, 32
.cfi_adjust_cfa_offset -32
subu $2, $0, $2
1: jr $ra
nop

__cp_cancel:
move $2, $ra
.cfi_register $ra, $2
bal 1f
addu $sp, $sp, 32
.cfi_adjust_cfa_offset -32
.gpword .
.gpword __cancel
1: lw $3, ($ra)
Expand All @@ -51,3 +57,5 @@ __cp_cancel:
addu $25, $25, $3
jr $25
move $ra, $2
.cfi_restore $ra
.cfi_endproc
3 changes: 3 additions & 0 deletions src/unistd/mips/pipe.s
@@ -1,8 +1,10 @@
.cfi_sections .debug_frame
.set noreorder

.global pipe
.type pipe,@function
pipe:
.cfi_startproc
lui $gp, %hi(_gp_disp)
addiu $gp, %lo(_gp_disp)
addu $gp, $gp, $25
Expand All @@ -18,3 +20,4 @@ pipe:
move $2, $0
jr $ra
nop
.cfi_endproc

0 comments on commit ee63340

Please sign in to comment.