From 5a50d6f575cb6db690b8455adfd85d4a5a90d09c Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 12 Jul 1997 23:28:11 +0000 Subject: [PATCH] Fix PIC case. --- sysdeps/mips/bsd-_setjmp.S | 13 ++++++--- sysdeps/mips/bsd-setjmp.S | 13 ++++++--- sysdeps/mips/elf/start.S | 55 ++++++++++++-------------------------- sysdeps/mips/setjmp.S | 22 ++++++++++----- sysdeps/unix/mips/brk.S | 44 ++++++++---------------------- sysdeps/unix/mips/sysdep.S | 25 ++++++++++++++--- sysdeps/unix/mips/sysdep.h | 26 ++++++++++++++++-- sysdeps/unix/mips/wait.S | 6 ++--- 8 files changed, 110 insertions(+), 94 deletions(-) diff --git a/sysdeps/mips/bsd-_setjmp.S b/sysdeps/mips/bsd-_setjmp.S index f519f193592..819a7018c4d 100644 --- a/sysdeps/mips/bsd-_setjmp.S +++ b/sysdeps/mips/bsd-_setjmp.S @@ -23,14 +23,19 @@ #include +/* XXX Must this be __PIC__ ? --drepper */ #ifdef PIC .option pic2 #endif ENTRY (_setjmp) + .set noreorder #ifdef PIC .cpload t9 + la t9, C_SYMBOL_NAME (__sigsetjmp) + jr t9 +#else + j C_SYMBOL_NAME (__sigsetjmp) #endif - la t9, C_SYMBOL_NAME (__sigsetjmp) - nop - jr t9 - li a1, 0 /* Pass a second argument of zero. */ + move a1,zero /* Pass a second argument of zero. */ + .set reorder + .end _setjmp diff --git a/sysdeps/mips/bsd-setjmp.S b/sysdeps/mips/bsd-setjmp.S index 9a22700718a..f220404c2c4 100644 --- a/sysdeps/mips/bsd-setjmp.S +++ b/sysdeps/mips/bsd-setjmp.S @@ -23,14 +23,19 @@ #include +/* XXX Must this be __PIC__ ? --drepper */ #ifdef PIC .option pic2 #endif ENTRY (setjmp) + .set noreorder #ifdef PIC .cpload t9 + la t9, C_SYMBOL_NAME (__sigsetjmp) + jr t9 +#else + j C_SYMBOL_NAME (__sigsetjmp) #endif - la t9, C_SYMBOL_NAME (__sigsetjmp) - nop - jr t9 - li a1, 1 /* Pass a second argument of one. */ + li a1, 1 /* Pass a second argument of one. */ + .set reorder + .end setjmp diff --git a/sysdeps/mips/elf/start.S b/sysdeps/mips/elf/start.S index 355a4a905ca..ce9ad9c7ec8 100644 --- a/sysdeps/mips/elf/start.S +++ b/sysdeps/mips/elf/start.S @@ -17,6 +17,12 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include + +#ifndef ENTRY_POINT +#error ENTRY_POINT needs to be defined for start.S on MIPS/ELF. +#endif + /* This is the canonical entry point, usually the first thing in the text segment. The SVR4/Mips ABI (pages 3-31, 3-32) says that when the entry point runs, most registers' values are unspecified, except for: @@ -53,8 +59,8 @@ #endif .text - .globl _start -_start: + .globl ENTRY_POINT +ENTRY_POINT: #ifdef PIC SET_GP #endif @@ -81,20 +87,9 @@ nofini: the prologue of __libc_init_first, we preload them to prevent clobbering the stack tops. In Hurd case, stack pointer ($29) may be VM_MAX_ADDRESS here. If so, we must modify it. */ -#if (__mips64) - dli $4, 0x10000000000 - bne $29, $4, 1f - dsubu $29, 32 - sd $0, 0($29) - sd $0, 8($29) - sd $0, 16($29) - sd $0, 24($29) -1: - ld $4, 0($29) - ld $5, 8($29) - ld $6, 16($29) - ld $7, 24($29) -#else /* __mips64 */ +#if 0 + jal mach_host_self +#endif li $4, 0x80000000 bne $29, $4, 1f subu $29, 16 @@ -107,23 +102,14 @@ nofini: lw $5, 4($29) lw $6, 8($29) lw $7, 12($29) -#endif /* __mips64 */ - jal __libc_init_first #ifdef PIC SET_GP #endif -#if (__mips64) - ld $4, 0($29) - ld $5, 8($29) - ld $6, 16($29) - ld $7, 24($29) -#else /* __mips64 */ lw $4, 0($29) lw $5, 4($29) lw $6, 8($29) lw $7, 12($29) -#endif /* __mips64 */ /* Call `_init', which is the entry point to our own `.init' section; and register with `atexit' to have `exit' call @@ -145,19 +131,11 @@ nofini: /* Extract the arguments and environment as encoded on the stack and set up the arguments for `main': argc, argv, envp. */ -#if (__mips64) - ld $4, 0($29) /* argc */ - daddu $5, $29, 8 /* argv */ - dsll $6, $4, 3 - daddu $6, $6, 8 - daddu $6, $5, $6 /* envp = &argv[argc + 1] */ -#else /* __mips64 */ lw $4, 0($29) /* argc */ addu $5, $29, 4 /* argv */ sll $6, $4, 2 addu $6, $6, 4 addu $6, $5, $6 /* envp = &argv[argc + 1] */ -#endif /* __mips64 */ /* Call the user's main function, and exit with its value. */ jal main @@ -172,10 +150,11 @@ hlt: b hlt /* Crash if somehow it does return. */ .data .globl __data_start __data_start: -#if (__mips64) - .dword 0 -#else /* __mips64 */ - .word 0 -#endif /* __mips64 */ + .long 0 .weak data_start data_start = __data_start + + .comm errno, 4, 4 +#ifdef __ELF__ + .type errno, @object +#endif diff --git a/sysdeps/mips/setjmp.S b/sysdeps/mips/setjmp.S index bc42dcb03ba..607b5f268d9 100644 --- a/sysdeps/mips/setjmp.S +++ b/sysdeps/mips/setjmp.S @@ -26,10 +26,20 @@ #endif ENTRY (__sigsetjmp) #ifdef PIC - .cpload t9 + .set noreorder + .cpload t9 + .set reorder #endif - move a2, sp - move a3, fp - la t9, __sigsetjmp_aux - nop - jr t9 + move a2, sp +#ifdef fp + move a3, fp +#else + move a3, $fp +#endif +#ifdef PIC + la t9, __sigsetjmp_aux + jr t9 +#else + j __sigsetjmp_aux +#endif + .end __sigsetjmp diff --git a/sysdeps/unix/mips/brk.S b/sysdeps/unix/mips/brk.S index 197672669bf..e38f735b927 100644 --- a/sysdeps/unix/mips/brk.S +++ b/sysdeps/unix/mips/brk.S @@ -24,46 +24,24 @@ #endif #ifndef HAVE_GNU_LD -#define __end end +#define _end end #endif -.data -.sdata + .data ENTRY(__curbrk) - .word __end + .word 0 .end __curbrk -.text -.set noreorder -.set noat -ENTRY(__brk) - /* Minimum is one page. */ - lui v0, 4096 - lw v0, __end - nop - - /* If they ask for less than a page, givvem the whole - thing anyway. */ - sltu AT, a0, v0 - beq AT, zero, down1 - nop - move a0, v0 -down1: - li v0, SYS_brk - syscall - bne a3, zero, error - - /* Update __curbrk and exit cleanly. */ - lui AT, 4096 + .text +SYSCALL__(brk, 1) + .set reorder + /* Handle the query case. */ + bnez a0, 1f + move a0,v0 +1: /* Update __curbrk and exit cleanly. */ sw a0, __curbrk - j ra move v0, zero - - /* What a horrible way to die. */ -error: j syscall_error - nop - nop - nop + jr ra .end __brk weak_alias (__brk, brk) diff --git a/sysdeps/unix/mips/sysdep.S b/sysdeps/unix/mips/sysdep.S index 0cfc3027703..ac8335fe5b4 100644 --- a/sysdeps/unix/mips/sysdep.S +++ b/sysdeps/unix/mips/sysdep.S @@ -21,10 +21,23 @@ #define _ERRNO_H #include -/* .globl errno */ -.set noreorder + .comm errno, 4 +#ifdef __ELF__ + .type errno, @object +#endif + + .set noreorder -ENTRY(syscall_error) +ENTRY(__syscall_error) +#ifdef __PIC__ + .set noat + move $1, $31 + bltzal $0, 0f + nop +0: .cpload $31 + move $31, $1 + .set at +#endif #if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN /* We translate the system's EWOULDBLOCK error into EAGAIN. The GNU C library always defines EWOULDBLOCK==EAGAIN. @@ -40,4 +53,8 @@ skip: /* And just kick back a -1. */ j ra li v0, -1 - .end syscall_error + END(__syscall_error) + +/* We provide this alias for compatilility with other Unices + like IRIX 5 */ +weak_alias (__syscall_error, syscall_error) diff --git a/sysdeps/unix/mips/sysdep.h b/sysdeps/unix/mips/sysdep.h index 2f148d09380..cbafbdcd9ac 100644 --- a/sysdeps/unix/mips/sysdep.h +++ b/sysdeps/unix/mips/sysdep.h @@ -32,19 +32,41 @@ /* Note that while it's better structurally, going back to call syscall_error can make things confusing if you're debugging---it looks like it's jumping backwards into the previous fn. */ +#ifdef __PIC__ + #define PSEUDO(name, syscall_name, args) \ + .align 2; \ + 99: la t9,syscall_error; \ + jr t9; \ + ENTRY(name) \ + .set noreorder; \ + .cpload t9; \ + li v0, SYS_##syscall_name; \ + syscall; \ + .set reorder; \ + bne a3, zero, 99b; \ +syse1: +#else #define PSEUDO(name, syscall_name, args) \ .set noreorder; \ .align 2; \ 99: j syscall_error; \ - nop; \ ENTRY(name) \ + .set noreorder; \ li v0, SYS_##syscall_name; \ syscall; \ + .set reorder; \ bne a3, zero, 99b; \ - nop; \ syse1: +#endif + +#undef PSEUDO_END +#define PSEUDO_END(sym) .end sym #define ret j ra ; nop + +#undef END +#define END(sym) .end sym + #define r0 v0 #define r1 v1 /* The mips move insn is d,s. */ diff --git a/sysdeps/unix/mips/wait.S b/sysdeps/unix/mips/wait.S index a544156c4ea..9ea55bc7d0f 100644 --- a/sysdeps/unix/mips/wait.S +++ b/sysdeps/unix/mips/wait.S @@ -28,14 +28,14 @@ ENTRY(__wait) li v0, SYS_wait syscall - beq a3, zero, noerror + beqz a3, noerror nop - j syscall_error + j __syscall_error nop noerror: /* If the arg is not NULL, store v1 there. */ - beq a0, zero, noarg + beqz a0, noarg nop sw v1, 0(a0) nop -- 2.47.3