Fix PIC case.

This commit is contained in:
Ulrich Drepper 1997-07-12 23:28:11 +00:00
parent 6a2c06dc40
commit 5a50d6f575
8 changed files with 110 additions and 94 deletions

View File

@ -23,14 +23,19 @@
#include <sysdep.h>
/* 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

View File

@ -23,14 +23,19 @@
#include <sysdep.h>
/* 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

View File

@ -17,6 +17,12 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <entry.h>
#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

View File

@ -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

View File

@ -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)

View File

@ -21,10 +21,23 @@
#define _ERRNO_H
#include <bits/errno.h>
/* .globl errno */
.set noreorder
.comm errno, 4
#ifdef __ELF__
.type errno, @object
#endif
ENTRY(syscall_error)
.set noreorder
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)

View File

@ -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. */

View File

@ -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