提交 cbc02ba2 编写于 作者: R Rich Felker

consistently use hidden visibility for cancellable syscall internals

in a few places, non-hidden symbols were referenced from asm in ways
that assumed ld-time binding. while these is no semantic reason these
symbols need to be hidden, fixing the references without making them
hidden was going to be ugly, and hidden reduces some bloat anyway.

in the asm files, .global/.hidden directives have been moved to the
top to unclutter the actual code.
上级 bc081f62
#include <sys/syscall.h>
#ifdef SHARED
__attribute__((__visibility__("hidden")))
#endif
long __syscall_cp_internal(volatile void*, long long, long long, long long, long long,
long long, long long, long long);
......@@ -8,6 +12,9 @@ struct __timespec_kernel { long long tv_sec; long long tv_nsec; };
#define __fixup(X) do { if(X) X = (unsigned long) (&(struct __timespec_kernel) \
{ .tv_sec = __tsc(X)->tv_sec, .tv_nsec = __tsc(X)->tv_nsec}); } while(0)
#ifdef SHARED
__attribute__((__visibility__("hidden")))
#endif
long __syscall_cp_asm (volatile void * foo, long long n, long long a1, long long a2, long long a3,
long long a4, long long a5, long long a6) {
switch (n) {
......
......@@ -4,10 +4,17 @@
// syscall(nr, u, v, w, x, y, z)
// x8 x0 x1 x2 x3 x4 x5
.global __cp_begin
.hidden __cp_begin
.global __cp_end
.hidden __cp_end
.global __cp_cancel
.hidden __cp_cancel
.hidden __cancel
.global __syscall_cp_asm
.hidden __syscall_cp_asm
.type __syscall_cp_asm,%function
__syscall_cp_asm:
.global __cp_begin
__cp_begin:
ldr w0,[x0]
cbnz w0,1f
......@@ -19,7 +26,6 @@ __cp_begin:
mov x4,x6
mov x5,x7
svc 0
.global __cp_end
__cp_end:
ret
......
.global __cp_begin
.hidden __cp_begin
.global __cp_end
.hidden __cp_end
.global __cp_cancel
.hidden __cp_cancel
.hidden __cancel
.global __syscall_cp_asm
.hidden __syscall_cp_asm
.type __syscall_cp_asm,%function
__syscall_cp_asm:
mov ip,sp
stmfd sp!,{r4,r5,r6,r7,lr}
.global __cp_begin
__cp_begin:
ldr r0,[r0]
cmp r0,#0
......@@ -13,13 +20,11 @@ __cp_begin:
mov r1,r3
ldmfd ip,{r2,r3,r4,r5,r6}
svc 0
.global __cp_end
__cp_end:
ldmfd sp!,{r4,r5,r6,r7,lr}
tst lr,#1
moveq pc,lr
bx lr
.global __cp_cancel
__cp_cancel:
ldmfd sp!,{r4,r5,r6,r7,lr}
b __cancel
.text
.global __cp_begin
.hidden __cp_begin
.global __cp_end
.hidden __cp_end
.global __cp_cancel
.hidden __cp_cancel
.hidden __cancel
.global __syscall_cp_asm
.hidden __syscall_cp_asm
.type __syscall_cp_asm,@function
__syscall_cp_asm:
mov 4(%esp),%ecx
......@@ -7,7 +15,6 @@ __syscall_cp_asm:
pushl %esi
pushl %edi
pushl %ebp
.global __cp_begin
__cp_begin:
movl (%ecx),%eax
testl %eax,%eax
......@@ -20,14 +27,12 @@ __cp_begin:
movl 44(%esp),%edi
movl 48(%esp),%ebp
int $128
.global __cp_end
__cp_end:
popl %ebp
popl %edi
popl %esi
popl %ebx
ret
.global __cp_cancel
__cp_cancel:
popl %ebp
popl %edi
......
.global __cp_begin
.hidden __cp_begin
.global __cp_end
.hidden __cp_end
.global __cp_cancel
.hidden __cp_cancel
.hidden __cancel
.global __syscall_cp_asm
.hidden __syscall_cp_asm
.type __syscall_cp_asm,@function
__syscall_cp_asm:
.global __cp_begin
__cp_begin:
lwi r5, r5, 0
bnei r5, __cancel@PLT
bnei r5, __cancel
addi r12, r6, 0
add r5, r7, r0
add r6, r8, r0
......@@ -13,7 +20,6 @@ __cp_begin:
lwi r9, r1, 28
lwi r10, r1, 32
brki r14, 0x8
.global __cp_end
__cp_end:
rtsd r15, 8
nop
.set noreorder
.global __cp_begin
.hidden __cp_begin
.global __cp_end
.hidden __cp_end
.global __cp_cancel
.hidden __cp_cancel
.hidden __cancel
.global __syscall_cp_asm
.hidden __syscall_cp_asm
.type __syscall_cp_asm,@function
__syscall_cp_asm:
subu $sp, $sp, 32
.global __cp_begin
__cp_begin:
lw $4, 0($4)
bne $4, $0, __cp_cancel
......@@ -22,7 +29,6 @@ __cp_begin:
sw $2, 28($sp)
lw $2, 28($sp)
syscall
.global __cp_end
__cp_end:
beq $7, $0, 1f
addu $sp, $sp, 32
......@@ -30,7 +36,6 @@ __cp_end:
1: jr $ra
nop
.global __cp_cancel
__cp_cancel:
addu $sp, $sp, 32
lw $25, %call16(__cancel)($gp)
......
.global __cp_begin
.hidden __cp_begin
.global __cp_end
.hidden __cp_end
.global __cp_cancel
.hidden __cp_cancel
.hidden __cancel
.global __syscall_cp_asm
.hidden __syscall_cp_asm
.type __syscall_cp_asm,@function
__syscall_cp_asm:
.global __cp_begin
__cp_begin:
l.lwz r3, 0(r3)
l.sfeqi r3, 0
l.bnf plt(__cancel)
l.bnf __cancel
l.ori r11, r4, 0
l.ori r3, r5, 0
l.ori r4, r6, 0
......@@ -14,7 +21,6 @@ __cp_begin:
l.lwz r7, 0(r1)
l.lwz r8, 4(r1)
l.sys 1
.global __cp_end
__cp_end:
l.jr r9
l.nop
.global __cp_begin
.hidden __cp_begin
.global __cp_end
.hidden __cp_end
.global __cp_cancel
.hidden __cp_cancel
.hidden __cancel
.global __syscall_cp_asm
.hidden __syscall_cp_asm
#r0: volatile. may be modified during linkage.
#r1: stack frame: 16 byte alignment.
#r2: tls/thread pointer on pp32
......@@ -16,11 +26,9 @@
#the fields CR2,CR2,CR4 of the cond reg must be preserved
#LR (link reg) shall contain the funcs return address
.text
.global __syscall_cp_asm
.type __syscall_cp_asm,%function
__syscall_cp_asm:
# at enter: r3 = pointer to self->cancel, r4: syscall no, r5: first arg, r6: 2nd, r7: 3rd, r8: 4th, r9: 5th, r10: 6th
.global __cp_begin
__cp_begin:
# r3 holds first argument, its a pointer to self->cancel.
# we must compare the dereferenced value with 0 and jump to __cancel if its not
......@@ -42,7 +50,6 @@ __cp_begin:
mr 7, 9 # arg5
mr 8, 10 # arg6
sc
.global __cp_end
__cp_end:
bnslr+ # return if no summary overflow.
#else negate result.
......
......@@ -3,7 +3,13 @@
#include "syscall.h"
#include "libc.h"
long __cancel()
#ifdef SHARED
#define hidden __attribute__((__visibility__("hidden")))
#else
#define hidden
#endif
hidden long __cancel()
{
pthread_t self = __pthread_self();
if (self->canceldisable == PTHREAD_CANCEL_ENABLE || self->cancelasync)
......@@ -16,12 +22,14 @@ long __cancel()
* definition of __cp_cancel to undo those adjustments and call __cancel.
* Otherwise, __cancel provides a definition for __cp_cancel. */
weak_alias(__cancel, __cp_cancel);
hidden weak_alias(__cancel, __cp_cancel);
hidden
long __syscall_cp_asm(volatile void *, syscall_arg_t,
syscall_arg_t, syscall_arg_t, syscall_arg_t,
syscall_arg_t, syscall_arg_t, syscall_arg_t);
hidden
long __syscall_cp_c(syscall_arg_t nr,
syscall_arg_t u, syscall_arg_t v, syscall_arg_t w,
syscall_arg_t x, syscall_arg_t y, syscall_arg_t z)
......@@ -52,7 +60,7 @@ static void cancel_handler(int sig, siginfo_t *si, void *ctx)
pthread_t self = __pthread_self();
ucontext_t *uc = ctx;
const char *ip = ((char **)&uc->uc_mcontext)[CANCEL_REG_IP];
extern const char __cp_begin[1], __cp_end[1];
hidden extern const char __cp_begin[1], __cp_end[1];
a_barrier();
if (!self->cancel || self->canceldisable == PTHREAD_CANCEL_DISABLE) return;
......
.text
.global __cp_begin
.hidden __cp_begin
.global __cp_end
.hidden __cp_end
.global __cp_cancel
.hidden __cp_cancel
.hidden __cancel
.global __syscall_cp_asm
.hidden __syscall_cp_asm
.type __syscall_cp_asm, @function
__syscall_cp_asm:
.global __cp_begin
__cp_begin:
mov.l @r4, r4
tst r4, r4
......@@ -15,7 +22,7 @@ __cp_begin:
1:
.align 2
L1: .long __cancel@PLT-(1b-.)
L1: .long __cancel-(1b-.)
2: mov r5, r3
mov r6, r4
......@@ -26,7 +33,6 @@ L1: .long __cancel@PLT-(1b-.)
mov.l @(12,r15), r1
trapa #22
.global __cp_end
__cp_end:
! work around hardware bug
or r0, r0
......
.text
.global __cp_begin
.hidden __cp_begin
.global __cp_end
.hidden __cp_end
.global __cp_cancel
.hidden __cp_cancel
.hidden __cancel
.global __syscall_cp_internal
.hidden __syscall_cp_internal
.type __syscall_cp_internal,@function
__syscall_cp_internal:
.global __cp_begin
__cp_begin:
mov (%rdi),%eax
test %eax,%eax
......@@ -18,6 +25,5 @@ __cp_begin:
mov 16(%rsp),%r9
mov %r11,8(%rsp)
syscall
.global __cp_end
__cp_end:
ret
.text
.global __cp_begin
.hidden __cp_begin
.global __cp_end
.hidden __cp_end
.global __cp_cancel
.hidden __cp_cancel
.hidden __cancel
.global __syscall_cp_asm
.hidden __syscall_cp_asm
.type __syscall_cp_asm,@function
__syscall_cp_asm:
.global __cp_begin
__cp_begin:
mov (%rdi),%eax
test %eax,%eax
......@@ -18,6 +25,5 @@ __cp_begin:
mov 16(%rsp),%r9
mov %r11,8(%rsp)
syscall
.global __cp_end
__cp_end:
ret
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册