Skip to content

Commit

Permalink
Add CFI start/end proc directives to arm64, i386, and ppc
Browse files Browse the repository at this point in the history
Follow-up to r353959 and r368070: do the same for other architectures.

arm32 already seems to use its own .fnstart/.fnend directives, which
appear to be ARM-specific variants of the same thing.  Likewise, MIPS
uses .frame directives.

Reviewed by:	arichardson
Differential Revision:	https://reviews.freebsd.org/D27387
  • Loading branch information
cemeyer committed Dec 5, 2020
1 parent ac4dd4c commit 78599c3
Show file tree
Hide file tree
Showing 41 changed files with 242 additions and 39 deletions.
6 changes: 4 additions & 2 deletions lib/libc/powerpc/SYS.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ ENTRY(__sys_##name); \
WEAK_REFERENCE(__sys_##name, _##name); \
_SYSCALL(name); \
bnslr; \
b CNAME(HIDENAME(cerror))
b CNAME(HIDENAME(cerror)); \
END(__sys_##name)

#define RSYSCALL(name) \
.text; \
Expand All @@ -68,4 +69,5 @@ ENTRY(__sys_##name); \
WEAK_REFERENCE(__sys_##name, _##name); \
_SYSCALL(name); \
bnslr; \
b CNAME(HIDENAME(cerror))
b CNAME(HIDENAME(cerror)); \
END(__sys_##name)
6 changes: 4 additions & 2 deletions lib/libc/powerpc64/SYS.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ ENTRY(__sys_##name); \
addi %r1,%r1,48; \
ld %r0,16(%r1); \
mtlr %r0; \
blr;
blr; \
END(__sys_##name)

#define RSYSCALL(name) \
.text; \
Expand All @@ -93,4 +94,5 @@ ENTRY(__sys_##name); \
addi %r1,%r1,48; \
ld %r0,16(%r1); \
mtlr %r0; \
blr;
blr; \
END(__sys_##name)
1 change: 1 addition & 0 deletions lib/libc/powerpc64/sys/cerror.S
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@ ENTRY_NOPROF(HIDENAME(cerror))
li %r3,-1
li %r4,-1
blr
END(HIDENAME(cerror))

.section .note.GNU-stack,"",%progbits
5 changes: 4 additions & 1 deletion lib/libthr/arch/i386/i386/_umtx_op_err.S
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@

#define SYSCALL_ERR(x) \
ENTRY(__CONCAT(x, _err)); \
mov __CONCAT($SYS_,x),%eax; int $0x80; ret
mov __CONCAT($SYS_,x),%eax; \
int $0x80; \
ret; \
END(__CONCAT(x, _err))

SYSCALL_ERR(_umtx_op)

Expand Down
1 change: 1 addition & 0 deletions lib/msun/i387/e_logf.S
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ ENTRY(logf)
flds 4(%esp)
fyl2x
ret
END(logf)

.section .note.GNU-stack,"",%progbits
1 change: 1 addition & 0 deletions lib/msun/i387/e_remainderl.S
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@ ENTRY(remainderl)
jp 1b
fstp %st(1)
ret
END(remainderl)

.section .note.GNU-stack,"",%progbits
1 change: 1 addition & 0 deletions lib/msun/i387/e_sqrtl.S
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@ ENTRY(sqrtl)
fldt 4(%esp)
fsqrt
ret
END(sqrtl)

.section .note.GNU-stack,"",%progbits
1 change: 1 addition & 0 deletions lib/msun/i387/s_llrintl.S
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ ENTRY(llrintl)
popl %eax
popl %edx
ret
END(llrintl)

.section .note.GNU-stack,"",%progbits
1 change: 1 addition & 0 deletions lib/msun/i387/s_logbl.S
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ ENTRY(logbl)
fxtract
fstp %st
ret
END(logbl)

.section .note.GNU-stack,"",%progbits
1 change: 1 addition & 0 deletions lib/msun/i387/s_lrintl.S
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ ENTRY(lrintl)
fistpl (%esp)
popl %eax
ret
END(lrintl)

.section .note.GNU-stack,"",%progbits
1 change: 1 addition & 0 deletions lib/msun/i387/s_remquol.S
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,6 @@ ENTRY(remquol)
movl 28(%esp),%ecx
movl %eax,(%ecx)
ret
END(remquol)

.section .note.GNU-stack,"",%progbits
1 change: 1 addition & 0 deletions lib/msun/i387/s_rintl.S
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@ ENTRY(rintl)
fldt 4(%esp)
frndint
ret
END(rintl)

.section .note.GNU-stack,"",%progbits
9 changes: 0 additions & 9 deletions libexec/rtld-elf/aarch64/rtld_start.S
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ END(.rtld_start)
* x17 = &_rtld_bind_start
*/
ENTRY(_rtld_bind_start)
.cfi_startproc
mov x17, sp

/* Save frame pointer and SP */
Expand Down Expand Up @@ -114,7 +113,6 @@ ENTRY(_rtld_bind_start)

/* Call into the correct function */
br x16
.cfi_endproc
END(_rtld_bind_start)

/*
Expand All @@ -128,10 +126,8 @@ END(_rtld_bind_start)
* Resolver function for TLS symbols resolved at load time
*/
ENTRY(_rtld_tlsdesc_static)
.cfi_startproc
ldr x0, [x0, #8]
ret
.cfi_endproc
END(_rtld_tlsdesc_static)

/*
Expand All @@ -140,7 +136,6 @@ END(_rtld_tlsdesc_static)
* Resolver function for weak and undefined TLS symbols
*/
ENTRY(_rtld_tlsdesc_undef)
.cfi_startproc
str x1, [sp, #-16]!
.cfi_adjust_cfa_offset 16

Expand All @@ -150,7 +145,6 @@ ENTRY(_rtld_tlsdesc_undef)

ldr x1, [sp], #16
.cfi_adjust_cfa_offset -16
.cfi_endproc
ret
END(_rtld_tlsdesc_undef)

Expand All @@ -160,8 +154,6 @@ END(_rtld_tlsdesc_undef)
* Resolver function for TLS symbols from dlopen()
*/
ENTRY(_rtld_tlsdesc_dynamic)
.cfi_startproc

/* Save registers used in fast path */
stp x1, x2, [sp, #(-2 * 16)]!
stp x3, x4, [sp, #(1 * 16)]
Expand Down Expand Up @@ -257,6 +249,5 @@ ENTRY(_rtld_tlsdesc_dynamic)
ldp x3, x4, [sp, #16]
ldp x1, x2, [sp], #(2 * 16)
.cfi_adjust_cfa_offset -2 * 16
.cfi_endproc
ret
END(_rtld_tlsdesc_dynamic)
6 changes: 6 additions & 0 deletions libexec/rtld-elf/powerpc/rtld_start.S
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ _ENTRY(.rtld_start)

li %r0,1 /* _exit() */
sc
_END(.rtld_start)

#ifdef __SPE__
/* stack space for 30 GPRs + SPEFSCR/ACC/lr/cr */
Expand Down Expand Up @@ -142,6 +143,7 @@ _ENTRY(_rtld_bind_secureplt_start)
ori %r11,%r11,0x15555556@l
mulhwu %r11,%r11,%r0 # get high half of multiplication
b 1f
_END(_rtld_bind_secureplt_start)

/*
* _rtld_bind_start()
Expand Down Expand Up @@ -264,6 +266,7 @@ _ENTRY(_rtld_bind_start)

addi %r1,%r1,STACK_SIZE # restore stack
bctr # jump to target
_END(_rtld_bind_start)


/*
Expand All @@ -284,13 +287,15 @@ _ENTRY(_rtld_powerpc_pltlongresolve)
subf %r11,%r12,%r11 # reloff
li %r12,2
srw %r11,%r11,%r12 # index = reloff/sizeof(Elf_Addr)
_END(_rtld_powerpc_pltlongresolve)
_ENTRY(_rtld_powerpc_pltresolve)
lis %r12,0 # lis 12,_rtld_bind_start@ha
addi %r12,%r12,0 # addi 12,12,_rtld_bind_start@l
mtctr %r12
lis %r12,0 # lis 12,obj@ha
addi %r12,%r12,0 # addi 12,12,obj@l
bctr
_END(_rtld_powerpc_pltresolve)

/*
* _rtld_powerpc_pltcall()
Expand All @@ -311,5 +316,6 @@ _ENTRY(_rtld_powerpc_pltcall)
lwz %r11,0(%r11) # lwz 11,jmptab@l(11)
mtctr %r11
bctr # (*jmptab[index])()
_END(_rtld_powerpc_pltcall)

.section .note.GNU-stack,"",%progbits
2 changes: 2 additions & 0 deletions libexec/rtld-elf/powerpc64/rtld_start.S
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ _ENTRY(_rtld_start)

li %r0,1 /* _exit() */
sc
_END(_rtld_start)

/*
* _rtld_bind_start()
Expand Down Expand Up @@ -175,5 +176,6 @@ _ENTRY(_rtld_bind_start)
mtlr %r0

bctr # jump to target
_END(_rtld_bind_start)

.section .note.GNU-stack,"",%progbits
2 changes: 2 additions & 0 deletions stand/libsa/powerpc/_setjmp.S
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ ASENTRY_NOPROF(_setjmp)
/* f14-f31, fpscr */
li 3, 0
blr
ASEND(_setjmp)


.extern sigsetmask
Expand Down Expand Up @@ -113,3 +114,4 @@ ASENTRY_NOPROF(_longjmp)
/* f14-f31, fpscr */
mr 3, 4
blr
ASEND(_longjmp)
13 changes: 13 additions & 0 deletions stand/powerpc/kboot/host_syscall.S
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ ENTRY(host_read)
1:
li %r3, 0
blr
END(host_read)

ENTRY(host_write)
li %r0, 4 # SYS_write
sc
blr
END(host_write)

ENTRY(host_seek)
mr %r4,%r5
Expand All @@ -26,11 +28,13 @@ ENTRY(host_seek)
li %r0, 140 # SYS_llseek
sc
blr
END(host_seek)

ENTRY(host_llseek)
li %r0, 140 # SYS_llseek
sc
blr
END(host_llseek)

ENTRY(host_open)
li %r0, 5 # SYS_open
Expand All @@ -40,45 +44,54 @@ ENTRY(host_open)
1:
li %r3, 0
blr
END(host_open)

ENTRY(host_close)
li %r0, 6 # SYS_close
sc
blr
END(host_close)

ENTRY(host_mmap)
li %r0, 90 # SYS_mmap
sc
blr
END(host_mmap)

ENTRY(host_uname)
li %r0, 122 # SYS_uname
sc
blr
END(host_uname)

ENTRY(host_gettimeofday)
li %r0, 78 # SYS_gettimeofday
sc
blr
END(host_gettimeofday)

ENTRY(host_select)
li %r0, 142 # SYS_select
sc
blr
END(host_select)

ENTRY(kexec_load)
lis %r6,21 # KEXEC_ARCH_PPC64
li %r0,268 # __NR_kexec_load
sc
blr
END(kexec_load)

ENTRY(host_reboot)
li %r0,88 # SYS_reboot
sc
blr
END(host_reboot)

ENTRY(host_getdents)
li %r0,141 # SYS_getdents
sc
blr
END(host_getdents)

1 change: 1 addition & 0 deletions stand/powerpc/uboot/start.S
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ ENTRY(syscall)
lwz %r30, 12(%r1)
mr %r1, %r11
blr
END(syscall)

/*
* Data section
Expand Down
5 changes: 3 additions & 2 deletions sys/arm64/include/asm.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@
#define _C_LABEL(x) x

#define ENTRY(sym) \
.text; .globl sym; .align 2; .type sym,#function; sym:
.text; .globl sym; .align 2; .type sym,#function; sym: \
.cfi_startproc
#define EENTRY(sym) \
.globl sym; sym:
#define END(sym) .size sym, . - sym
#define END(sym) .cfi_endproc; .size sym, . - sym
#define EEND(sym)

#define WEAK_REFERENCE(sym, alias) \
Expand Down
4 changes: 4 additions & 0 deletions sys/arm64/linux/linux_locore.asm
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,21 @@ linux_platform:
ENTRY(__kernel_rt_sigreturn)
brk #0 /* LINUXTODO: implement __kernel_rt_sigreturn */
ret
END(__kernel_rt_sigreturn)

ENTRY(__kernel_gettimeofday)
ldr x8, =LINUX_SYS_gettimeofday
svc #0
ret
END(__kernel_gettimeofday)

ENTRY(__kernel_clock_gettime)
ldr x8, =LINUX_SYS_linux_clock_gettime
svc #0
ret
END(__kernel_clock_gettime)

ENTRY(__kernel_clock_getres)
brk #0 /* LINUXTODO: implement __kernel_clock_getres */
ret
END(__kernel_clock_getres)
5 changes: 5 additions & 0 deletions sys/arm64/linux/linux_support.s
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,24 @@
ENTRY(futex_xchgl)
brk #0
ret
END(futex_xchgl)

ENTRY(futex_addl)
brk #0
ret
END(futex_addl)

ENTRY(futex_orl)
brk #0
ret
END(futex_orl)

ENTRY(futex_andl)
brk #0
ret
END(futex_andl)

ENTRY(futex_xorl)
brk #0
ret
END(futex_xorl)
Loading

0 comments on commit 78599c3

Please sign in to comment.