2002-11-07 Richard Henderson <rth@redhat.com>
authorroland <roland>
Fri, 8 Nov 2002 02:18:47 +0000 (02:18 +0000)
committerroland <roland>
Fri, 8 Nov 2002 02:18:47 +0000 (02:18 +0000)
* elf/tls-macros.h: Add alpha versions.
* sysdeps/alpha/dl-machine.h (elf_machine_rela): Handle TLS relocs.
* sysdeps/unix/alpha/sysdep.S: Support USE___THREAD.
* sysdeps/unix/alpha/sysdep.h: Likewise.  Add SYSCALL_ERROR_HANDLER.
* sysdeps/unix/sysv/linux/alpha/brk.S: Use it.
* sysdeps/unix/sysv/linux/alpha/clone.S: Likewise.
* sysdeps/unix/sysv/linux/alpha/getitimer.S: Likewise.
* sysdeps/unix/sysv/linux/alpha/getrusage.S: Likewise.
* sysdeps/unix/sysv/linux/alpha/gettimeofday.S: Likewise.
* sysdeps/unix/sysv/linux/alpha/ieee_get_fp_control.S: Likewise.
* sysdeps/unix/sysv/linux/alpha/ieee_set_fp_control.S: Likewise.
* sysdeps/unix/sysv/linux/alpha/rt_sigaction.S: Likewise.
* sysdeps/unix/sysv/linux/alpha/select.S: Likewise.
* sysdeps/unix/sysv/linux/alpha/setitimer.S: Likewise.
* sysdeps/unix/sysv/linux/alpha/settimeofday.S: Likewise.
* sysdeps/unix/sysv/linux/alpha/sigsuspend.S: Likewise.
* sysdeps/unix/sysv/linux/alpha/syscall.S: Likewise.
* sysdeps/unix/sysv/linux/alpha/utimes.S: Likewise.
* sysdeps/unix/sysv/linux/alpha/wait4.S: Likewise.

17 files changed:
elf/tls-macros.h
sysdeps/unix/alpha/sysdep.S
sysdeps/unix/alpha/sysdep.h
sysdeps/unix/sysv/linux/alpha/brk.S
sysdeps/unix/sysv/linux/alpha/getitimer.S
sysdeps/unix/sysv/linux/alpha/getrusage.S
sysdeps/unix/sysv/linux/alpha/gettimeofday.S
sysdeps/unix/sysv/linux/alpha/ieee_get_fp_control.S
sysdeps/unix/sysv/linux/alpha/ieee_set_fp_control.S
sysdeps/unix/sysv/linux/alpha/rt_sigaction.S
sysdeps/unix/sysv/linux/alpha/select.S
sysdeps/unix/sysv/linux/alpha/setitimer.S
sysdeps/unix/sysv/linux/alpha/settimeofday.S
sysdeps/unix/sysv/linux/alpha/sigsuspend.S
sysdeps/unix/sysv/linux/alpha/syscall.S
sysdeps/unix/sysv/linux/alpha/utimes.S
sysdeps/unix/sysv/linux/alpha/wait4.S

index e8ed56c..b57e4ac 100644 (file)
                           "r12", "pr", "t");                                 \
      __l; })
 
+#elif defined __alpha__
+
+register void *__gp __asm__("$29");
+
+# define TLS_LE(x)                                                     \
+  ({ int *__l;                                                         \
+     asm ("call_pal 158\n\tlda $0," #x "($0)\t\t!tprel" : "=v"(__l));  \
+     __l; })
+
+# define TLS_IE(x)                                                     \
+  ({ char *__tp; unsigned long __o;                                    \
+     asm ("call_pal 158\n\tldq %1," #x "($gp)\t\t!gottprel"            \
+         : "=v"(__tp), "=r"(__o) : "r"(__gp));                         \
+     (int *)(__tp + __o); })
+
+# define TLS_LD(x)                                                     \
+  ({ extern void *__tls_get_addr(void *); int *__l; void *__i;         \
+     asm ("lda %0," #x "($gp)\t\t!tlsldm" : "=r" (__i) : "r"(__gp));   \
+     __i = __tls_get_addr(__i);                                                \
+     asm ("lda %0, " #x "(%1)\t\t!dtprel" : "=r"(__l) : "r"(__i));     \
+     __l; })
+         
+# define TLS_GD(x)                                                     \
+  ({ extern void *__tls_get_addr(void *); void *__i;                   \
+     asm ("lda %0," #x "($gp)\t\t!tlsgd" : "=r" (__i) : "r"(__gp));    \
+     (int *) __tls_get_addr(__i); })
+
 #else
 # error "No support for this architecture so far."
 #endif
index 05c0091..50c84c1 100644 (file)
@@ -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).
 
 #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
index 46b5214..f9aba3f 100644 (file)
 # 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
    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
index 3cd1ae0..e01abeb 100644 (file)
@@ -74,7 +74,7 @@ $ok:  stq     a0, __curbrk
        /* What a horrible way to die.  */
 $err0: ldi     v0, ENOMEM
 $err1: addq    sp, 8, sp
-       jmp     zero, __syscall_error
+       SYSCALL_ERROR_HANDLER
 
        END(__brk)
 
index 03ceea1..5432562 100644 (file)
@@ -97,7 +97,7 @@ $do32:        ldi     v0, SYS_ify(osf_getitimer)
        .align 3
 $error:
        addq    sp, 16, sp
-       jmp     zero, __syscall_error
+       SYSCALL_ERROR_HANDLER
 
 END(GETITIMER)
 
index 13762a8..dd3eced 100644 (file)
@@ -129,7 +129,7 @@ $do32:      ldi     v0, SYS_ify(osf_getrusage)
        .align 3
 $error:
        addq    sp, 16, sp
-       jmp     zero, __syscall_error
+       SYSCALL_ERROR_HANDLER
 
 END(GETRUSAGE)
 
index 60d642a..71b8c13 100644 (file)
@@ -94,7 +94,7 @@ $do32:        ldi     v0, SYS_ify(osf_gettimeofday)
        .align 3
 $error:
        addq    sp, 16, sp
-       jmp     zero, __syscall_error
+       SYSCALL_ERROR_HANDLER
 
 END(GETTIMEOFDAY)
 
index 650f7c0..89e08b3 100644 (file)
@@ -53,7 +53,7 @@ $error:
 1:     ldgp    gp, 0(gp)
 #endif
        lda     sp, 16(sp)
-       jmp     zero, __syscall_error
+       SYSCALL_ERROR_HANDLER
 
        END(__ieee_get_fp_control)
 
index 53838fe..dc1bbbb 100644 (file)
@@ -52,7 +52,7 @@ $error:
 1:     ldgp    gp, 0(gp)
 #endif
        lda     sp, 16(sp)
-       jmp     zero, __syscall_error
+       SYSCALL_ERROR_HANDLER
 
        END(__ieee_set_fp_control)
 
index e3d01af..5f166a7 100644 (file)
@@ -56,7 +56,7 @@ ENTRY(__syscall_rt_sigaction)
        br      gp,2f
 2:     ldgp    gp,0(gp)
 #endif
-       jmp     __syscall_error
+       SYSCALL_ERROR_HANDLER
 
 END(__syscall_rt_sigaction)
 
@@ -82,6 +82,6 @@ ENTRY(__syscall_rt_sigaction)
        ldgp $29,0($27)
        .prologue 1
        ldi $0,ENOSYS
-       jmp __syscall_error
+       SYSCALL_ERROR_HANDLER
 END(__syscall_rt_sigaction)
 #endif
index 57030aa..d3b206d 100644 (file)
@@ -112,7 +112,7 @@ $do32:
        .align 3
 $error:
        addq    sp, 64, sp
-       jmp     zero, __syscall_error
+       SYSCALL_ERROR_HANDLER
 
 END(SELECT)
 
index 2cc1263..fdc3d27 100644 (file)
@@ -113,7 +113,7 @@ $do32:
        .align 3
 $error:
        addq    sp, 48, sp
-       jmp     zero, __syscall_error
+       SYSCALL_ERROR_HANDLER
 
 END(SETITIMER)
 
index 03e9206..339913f 100644 (file)
@@ -94,7 +94,7 @@ $do32:
        .align 3
 $error:
        addq    sp, 16, sp
-       jmp     zero, __syscall_error
+       SYSCALL_ERROR_HANDLER
 
 END(SETTIMEOFDAY)
 
index d6a1785..955d82e 100644 (file)
@@ -47,7 +47,7 @@ error:
        br      gp, 1f
 1:     ldgp    gp, 0(gp)
 #endif
-       jmp     zero, __syscall_error
+       SYSCALL_ERROR_HANDLER
 
        END(__sigsuspend)
 
index c354bb6..10a32d5 100644 (file)
@@ -70,7 +70,7 @@ $error:
        br      gp, 2f
 2:     ldgp    gp, 0(gp)
 #endif
-       jmp     zero, __syscall_error
+       SYSCALL_ERROR_HANDLER
 
 END(__syscall)
 
index e9c16db..a939255 100644 (file)
@@ -99,7 +99,7 @@ $do32:
        .align 3
 $error:
        addq    sp, 16, sp
-       jmp     zero, __syscall_error
+       SYSCALL_ERROR_HANDLER
 
 END(UTIMES)
 
index b695047..17c5a97 100644 (file)
@@ -132,7 +132,7 @@ $do32:      ldi     v0, SYS_ify(osf_wait4)
        .align 3
 $error:
        addq    sp, 32, sp
-       jmp     zero, __syscall_error
+       SYSCALL_ERROR_HANDLER
 
 END(WAIT4)