diff options
Diffstat (limited to 'sysdeps/unix/alpha')
-rw-r--r-- | sysdeps/unix/alpha/sysdep.S | 58 | ||||
-rw-r--r-- | sysdeps/unix/alpha/sysdep.h | 100 |
2 files changed, 105 insertions, 53 deletions
diff --git a/sysdeps/unix/alpha/sysdep.S b/sysdeps/unix/alpha/sysdep.S index 05c00918e6..50c84c1166 100644 --- a/sysdeps/unix/alpha/sysdep.S +++ b/sysdeps/unix/alpha/sysdep.S @@ -1,4 +1,4 @@ -/* Copyright (C) 1993, 1996, 1998 Free Software Foundation, Inc. +/* Copyright (C) 1993, 1996, 1998, 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Brendan Kehoe (brendan@zen.org). @@ -20,24 +20,59 @@ #include <sysdep.h> #include <features.h> +#if defined(__ELF__) && defined(PIC) + /* Put this at the end of libc's text segment so that all of + the direct branches from the syscalls are forward, and + thus predicted not taken. */ + .section .text.last, "ax", @progbits +#else .text - .align 2 +#endif -#ifdef _LIBC_REENTRANT +#ifdef PIC + /* When building a shared library, we branch here without + having loaded the GP. Nor, since it was a direct branch, + have we loaded PV with our address. Do both. */ +# define LOADGP br pv, 1f; 1: ldgp gp, 0(pv) +# define PROLOGUE .prologue 0 +#else +# define LOADGP ldgp gp, 0(pv) +# define PROLOGUE .prologue 1 +#endif + .align 4 .globl __syscall_error .ent __syscall_error __syscall_error: - ldgp gp, 0(pv) + +#if defined(_LIBC_REENTRANT) && defined(USE___THREAD) + + LOADGP + PROLOGUE + mov v0, t0 + call_pal PAL_rduniq + ldq t1, __libc_errno(gp) !gottprel + addq v0, t1, v0 + stl t0, 0(v0) + lda v0, -1 + ret + +#elif defined(_LIBC_REENTRANT) + + LOADGP lda sp, -16(sp) .frame sp, 16, ra, 0 stq ra, 0(sp) stq v0, 8(sp) .mask 0x4000001, -16 - .prologue 1 + PROLOGUE /* Find our per-thread errno address */ +#ifdef PIC + bsr ra, __errno_location !samegp +#else jsr ra, __errno_location +#endif /* Store the error value. */ ldq t0, 8(sp) @@ -49,16 +84,15 @@ __syscall_error: ldq ra, 0(sp) lda sp, 16(sp) ret - .end __syscall_error -#else -ENTRY(__syscall_error) - ldgp gp, 0(t12) - .prologue 1 +#else + LOADGP + PROLOGUE stl v0, errno lda v0, -1 ret - END(__syscall_error) -#endif /* _LIBC_REENTRANT */ +#endif + + .end __syscall_error diff --git a/sysdeps/unix/alpha/sysdep.h b/sysdeps/unix/alpha/sysdep.h index 46b5214987..f9aba3ffa2 100644 --- a/sysdeps/unix/alpha/sysdep.h +++ b/sysdeps/unix/alpha/sysdep.h @@ -27,6 +27,13 @@ # include <regdef.h> #endif +#include <tls.h> /* Defines USE___THREAD. */ + +#ifdef IS_IN_rtld +# include <dl-sysdep.h> /* Defines RTLD_PRIVATE_ERRNO. */ +#endif + + #ifdef __STDC__ #define __LABEL(x) x##: #else @@ -55,54 +62,65 @@ label of that number between those two macros! */ #ifdef PROF -#define PSEUDO(name, syscall_name, args) \ - .globl name; \ - .align 3; \ - .ent name,0; \ +# define PSEUDO_PROLOGUE \ + .frame sp, 0, ra; \ + ldgp gp,0(pv); \ + .set noat; \ + lda AT,_mcount; \ + jsr AT,(AT),_mcount; \ + .set at; \ + .prologue 1 +# define PSEUDO_LOADGP +#else +# define PSEUDO_PROLOGUE \ + .frame sp, 0, ra; \ + .prologue 0 +# define PSEUDO_LOADGP \ + br gp, 2f; \ +2: ldgp gp, 0(gp) +#endif /* PROF */ + +#if RTLD_PRIVATE_ERRNO +# define SYSCALL_ERROR_HANDLER \ + stl v0, errno(gp) !gprel; \ + lda v0, -1; \ + ret +#else +# define SYSCALL_ERROR_HANDLER \ + jmp $31, __syscall_error +#endif /* RTLD_PRIVATE_ERRNO */ + +#if defined(PIC) && !RTLD_PRIVATE_ERRNO +# define PSEUDO(name, syscall_name, args) \ + .globl name; \ + .align 4; \ + .ent name,0; \ __LABEL(name) \ - .frame sp, 0, ra; \ - ldgp gp,0(pv); \ - .set noat; \ - lda AT,_mcount; \ - jsr AT,(AT),_mcount; \ - .set at; \ - .prologue 1; \ - ldiq v0, SYS_ify(syscall_name); \ - .set noat; \ - call_pal PAL_callsys; \ - .set at; \ - bne a3, 1996f; \ + PSEUDO_PROLOGUE; \ + lda v0, SYS_ify(syscall_name); \ + call_pal PAL_callsys; \ + bne a3, __syscall_error !samegp; \ 3: +# undef PSEUDO_END +# define PSEUDO_END(sym) END(sym) #else -#define PSEUDO(name, syscall_name, args) \ - .globl name; \ - .align 3; \ - .ent name,0; \ +# define PSEUDO(name, syscall_name, args) \ + .globl name; \ + .align 4; \ + .ent name,0; \ __LABEL(name) \ - .frame sp, 0, ra \ - .prologue 0; \ - ldiq v0, SYS_ify(syscall_name); \ - .set noat; \ - call_pal PAL_callsys; \ - .set at; \ - bne a3, 1996f; \ + lda v0, SYS_ify(syscall_name); \ + call_pal PAL_callsys; \ + bne a3, 1996f; \ 3: -#endif -#undef PSEUDO_END -#ifdef PROF -#define PSEUDO_END(sym) \ +# undef PSEUDO_END +# define PSEUDO_END(sym) \ 1996: \ - jmp zero, __syscall_error; \ - END(sym) -#else -#define PSEUDO_END(sym) \ -1996: \ - br gp, 2f; \ -2: ldgp gp, 0(gp); \ - jmp zero, __syscall_error; \ - END(sym) -#endif + PSEUDO_LOADGP; \ + SYSCALL_ERROR_HANDLER; \ + END(sym) +#endif /* PIC && !RTLD_PRIVATE_ERRNO */ #define r0 v0 #define r1 a4 |