summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libexec/ld.so/mips64/archdep.h101
-rw-r--r--libexec/ld.so/mips64/ldasm.S66
-rw-r--r--libexec/ld.so/mips64/rtld_machine.c105
-rw-r--r--libexec/ld.so/mips64/syscall.h130
4 files changed, 214 insertions, 188 deletions
diff --git a/libexec/ld.so/mips64/archdep.h b/libexec/ld.so/mips64/archdep.h
index d1f13ee8228..dd5b113d4ae 100644
--- a/libexec/ld.so/mips64/archdep.h
+++ b/libexec/ld.so/mips64/archdep.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: archdep.h,v 1.1 2004/08/11 17:11:45 pefo Exp $ */
+/* $OpenBSD: archdep.h,v 1.2 2004/09/09 17:47:43 pefo Exp $ */
/*
* Copyright (c) 1998-2002 Opsycon AB, Sweden.
@@ -37,62 +37,71 @@
#define RTLD_PROTECT_PLT
-#define DL_MALLOC_ALIGN 4 /* Arch constraint or otherwise */
+#define DL_MALLOC_ALIGN 16 /* Arch constraint or otherwise */
#define MACHID EM_MIPS /* ELF e_machine ID value checked */
-#define RELTYPE Elf32_Rel
-#define RELSIZE sizeof(Elf32_Rel)
+//static inline void
+//RELOC_REL(Elf_Rel *r, const Elf_Sym *s, Elf_Addr *p, unsigned long v)
+//{
+//}
+#define RELOC_REL(relp, symp, adrp, val) \
+do { \
+ if (ELF64_R_TYPE(relp->r_info) == R_MIPS_REL32_64) { \
+ if (ELF64_R_SYM(rp->r_info) != 0) \
+ *adrp = symp->st_value + val; \
+ else \
+ *adrp += val; \
+ } else if (ELF64_R_TYPE(relp->r_info) != R_MIPS_NONE) { \
+ _dl_exit(ELF64_R_TYPE(relp->r_info)+100); \
+ } \
+} while (0)
static inline void
-RELOC_REL(Elf_Rel *r, const Elf_Sym *s, Elf_Addr *p, unsigned long v)
-{
-}
-
-static inline void
-RELOC_RELA(Elf32_Rela *r, const Elf32_Sym *s, Elf32_Addr *p, unsigned long v)
+RELOC_RELA(Elf64_Rela *r, const Elf64_Sym *s, Elf64_Addr *p, unsigned long v)
{
_dl_exit(20);
}
struct elf_object;
-static inline void
-RELOC_GOT(struct elf_object *dynld, long loff)
-{
- Elf32_Addr *gotp;
- int i, n;
- const Elf_Sym *sp;
-
- /* Do all local gots */
- gotp = dynld->dyn.pltgot;
- n = dynld->Dyn.info[DT_MIPS_LOCAL_GOTNO - DT_LOPROC + DT_NUM];
-
- for (i = ((gotp[1] & 0x80000000) ? 2 : 1); i < n; i++) {
- gotp[i] += loff;
- }
- gotp += n;
-
- /* Do symbol referencing gots. There should be no global... */
- n = dynld->Dyn.info[DT_MIPS_SYMTABNO - DT_LOPROC + DT_NUM] -
- dynld->Dyn.info[DT_MIPS_GOTSYM - DT_LOPROC + DT_NUM];
- sp = dynld->dyn.symtab;
- sp += dynld->Dyn.info[DT_MIPS_GOTSYM - DT_LOPROC + DT_NUM];
-
- while (n--) {
- if (sp->st_shndx == SHN_UNDEF ||
- sp->st_shndx == SHN_COMMON) {
- _dl_exit(6);
- } else if (ELF32_ST_TYPE(sp->st_info) == STT_FUNC) {
- *gotp += loff;
- } else {
- *gotp = sp->st_value + loff;
- }
- gotp++;
- sp++;
- }
- dynld->status |= STAT_GOT_DONE;
-}
+#define RELOC_GOT(obj, off) \
+do { \
+ struct elf_object *__dynld = obj; \
+ long __loff = off; \
+ Elf64_Addr *gotp; \
+ int i, n; \
+ const Elf_Sym *sp; \
+ \
+ /* Do all local gots */ \
+ gotp = __dynld->dyn.pltgot; \
+ n = __dynld->Dyn.info[DT_MIPS_LOCAL_GOTNO - DT_LOPROC + DT_NUM];\
+ \
+ for (i = ((gotp[1] & 0x0000000080000000) ? 2 : 1); i < n; i++) {\
+ gotp[i] += __loff; \
+ } \
+ gotp += n; \
+ \
+ /* Do symbol referencing gots. There should be no global... */ \
+ n = __dynld->Dyn.info[DT_MIPS_SYMTABNO - DT_LOPROC + DT_NUM] - \
+ __dynld->Dyn.info[DT_MIPS_GOTSYM - DT_LOPROC + DT_NUM]; \
+ sp = __dynld->dyn.symtab; \
+ sp += __dynld->Dyn.info[DT_MIPS_GOTSYM - DT_LOPROC + DT_NUM]; \
+ \
+ while (n--) { \
+ if (sp->st_shndx == SHN_UNDEF || \
+ sp->st_shndx == SHN_COMMON) { \
+ _dl_exit(6); \
+ } else if (ELF64_ST_TYPE(sp->st_info) == STT_FUNC) { \
+ *gotp += __loff; \
+ } else { \
+ *gotp = sp->st_value + __loff; \
+ } \
+ gotp++; \
+ sp++; \
+ } \
+ __dynld->status |= STAT_GOT_DONE; \
+} while(0)
#define GOT_PERMS PROT_READ
diff --git a/libexec/ld.so/mips64/ldasm.S b/libexec/ld.so/mips64/ldasm.S
index a4d4c078ab1..d6d7319aeb5 100644
--- a/libexec/ld.so/mips64/ldasm.S
+++ b/libexec/ld.so/mips64/ldasm.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldasm.S,v 1.1 2004/08/11 17:11:45 pefo Exp $ */
+/* $OpenBSD: ldasm.S,v 1.2 2004/09/09 17:47:43 pefo Exp $ */
/*
* Copyright (c) 1998-2002 Opsycon AB, Sweden.
@@ -27,6 +27,7 @@
*/
#include <machine/asm.h>
+#include <sys/syscall.h>
/* Stack at this stage is:
* struct stack {
@@ -37,36 +38,53 @@
* };
*/
-LEAF(_dl_start) /* Not really LEAF, but we simplify */
- addu sp, -64 # Some space.
- .cprestore 12
+FRAMESZ= MKFSIZ(4,16)
+GPOFF= FRAMESZ-2*REGSZ
+RAOFF= FRAMESZ-1*REGSZ
- la a1, 1f
+LEAF(_dl_start, FRAMESZ) /* Not really LEAF, but we simplify */
+ PTR_SUBU sp, FRAMESZ # Some space.
+ SETUP_GP64(GPOFF, _dl_start)
+
+ LA s1, 1f
bgezal zero, 1f
1:
- subu s0, ra, a1 # This is the load offset
- addu a0, sp, 64 # Where stack info is.
- addu a1, sp, 16 # Where fast AUX info will be.
- la t9, _dl_boot_bind
- addu t9, s0
- jalr t9 # Relocate ourself.
- lw a3, 64(sp) # argc
- addu a0, sp, 68 # argv
- addi a1, a0, 4
- sll a3, a3, 2
- addu a1, a3
- addu a3, sp, 16 # Where fast AUX info will be.
- move a2, s0 # Load offset
- jal _dl_boot # Go do the linking.
+ # This is a hack to change protection of .rodata so it
+ # can be relocated. A better way to find the location
+ # of .rodata should probably be used.
+ li v0, SYS_mprotect
+ or a0, ra, 0xfff
+ xor a0, 0xfff
+ li a1, 0x8000
+ li a2, 7 /* (PROT_READ|PROT_WRITE|PROT_EXEC) */
+ syscall
+
+ PTR_SUBU s0, ra, s1 # This is the load offset
+ PTR_ADDU a0, sp, FRAMESZ # Where stack info is.
+ PTR_ADDU a1, sp, 0 # Where fast AUX info will be.
+ LA t9, _dl_boot_bind
+ PTR_ADDU t9, s0
+ jalr t9 # Relocate ourself.
+
+ REG_L a3, FRAMESZ(sp) # argc
+ PTR_ADDU a0, sp, FRAMESZ+REGSZ # argv
+ PTR_ADDU a1, a0, REGSZ
+ PTR_SLL a3, a3, LOGREGSZ
+ PTR_ADDU a1, a3
+ PTR_ADDU a3, sp, 0 # Where fast AUX info will be.
+ move a2, s0 # Load offset
+ jal _dl_boot # Go do the linking.
- addu sp, 64 # Restore stack pointer.
- move t9, v0 # Entry address from _dl_boot.
- j t9 # Go execute the 'real' program.
+ RESTORE_GP64
+ PTR_ADDU sp, FRAMESZ # Restore stack pointer.
+ move t9, v0 # Entry address from _dl_boot.
+ j t9 # Go execute the 'real' program.
END(_dl_start)
-LEAF(_dl__syscall)
- li v0, 0 # Indirect syscall.
+LEAF(_dl__syscall, 0)
+ li v0, SYS___syscall # Indirect syscall.
+ syscall
bne a3, zero, 1f
j ra
1:
diff --git a/libexec/ld.so/mips64/rtld_machine.c b/libexec/ld.so/mips64/rtld_machine.c
index 7f347c23162..96754eb326a 100644
--- a/libexec/ld.so/mips64/rtld_machine.c
+++ b/libexec/ld.so/mips64/rtld_machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld_machine.c,v 1.1 2004/08/11 17:11:45 pefo Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.2 2004/09/09 17:47:43 pefo Exp $ */
/*
* Copyright (c) 1998-2004 Opsycon AB, Sweden.
@@ -42,39 +42,55 @@ _dl_md_reloc(elf_object_t *object, int rel, int relsz)
int i;
int numrel;
int fails = 0;
- Elf32_Addr loff;
- Elf32_Rel *relocs;
+ struct load_list *load_list;
+ Elf64_Addr loff;
+ Elf64_Rel *relocs;
loff = object->load_offs;
- numrel = object->Dyn.info[relsz] / sizeof(Elf32_Rel);
- relocs = (Elf32_Rel *)(object->Dyn.info[rel]);
+ numrel = object->Dyn.info[relsz] / sizeof(Elf64_Rel);
+ relocs = (Elf64_Rel *)(object->Dyn.info[rel]);
if (relocs == NULL)
return(0);
+ /*
+ * Change protection of all write protected segments in the
+ * object so we can do relocations in the .rodata section.
+ * After relocation restore protection.
+ */
+ load_list = object->load_list;
+ while (load_list != NULL) {
+ if ((load_list->prot & PROT_WRITE) == 0)
+ _dl_mprotect(load_list->start, load_list->size,
+ load_list->prot|PROT_WRITE);
+ load_list = load_list->next;
+ }
+
+
+ DL_DEB(("relocating %d\n", numrel));
for (i = 0; i < numrel; i++, relocs++) {
- Elf32_Addr r_addr = relocs->r_offset + loff;
- Elf32_Addr ooff = 0;
- const Elf32_Sym *sym, *this;
+ Elf64_Addr r_addr = relocs->r_offset + loff;
+ Elf64_Addr ooff = 0;
+ const Elf64_Sym *sym, *this;
const char *symn;
int type;
- if (ELF32_R_SYM(relocs->r_info) == 0xffffff)
+ if (ELF64_R_SYM(relocs->r_info) == 0xffffff)
continue;
sym = object->dyn.symtab;
- sym += ELF32_R_SYM(relocs->r_info);
+ sym += ELF64_R_SYM(relocs->r_info);
this = sym;
symn = object->dyn.strtab + sym->st_name;
- type = ELF32_R_TYPE(relocs->r_info);
+ type = ELF64_R_TYPE(relocs->r_info);
- if (ELF32_R_SYM(relocs->r_info) &&
- !(ELF32_ST_BIND(sym->st_info) == STB_LOCAL &&
- ELF32_ST_TYPE (sym->st_info) == STT_NOTYPE)) {
+ if (ELF64_R_SYM(relocs->r_info) &&
+ !(ELF64_ST_BIND(sym->st_info) == STB_LOCAL &&
+ ELF64_ST_TYPE (sym->st_info) == STT_NOTYPE)) {
ooff = _dl_find_symbol(symn, _dl_objects, &this, NULL,
SYM_SEARCH_ALL | SYM_NOWARNNOTFOUND | SYM_PLT,
sym->st_size, object);
- if (!this && ELF32_ST_BIND(sym->st_info) == STB_GLOBAL) {
+ if (!this && ELF64_ST_BIND(sym->st_info) == STB_GLOBAL) {
_dl_printf("%s: can't resolve reference '%s'\n",
_dl_progname, symn);
fails++;
@@ -82,14 +98,22 @@ _dl_md_reloc(elf_object_t *object, int rel, int relsz)
}
- switch (ELF32_R_TYPE(relocs->r_info)) {
- case R_MIPS_REL32:
- if (ELF32_ST_BIND(sym->st_info) == STB_LOCAL &&
- (ELF32_ST_TYPE(sym->st_info) == STT_SECTION ||
- ELF32_ST_TYPE(sym->st_info) == STT_NOTYPE) ) {
- *(u_int32_t *)r_addr += loff + sym->st_value;
+ switch (ELF64_R_TYPE(relocs->r_info)) {
+ case R_MIPS_REL32_64:
+ if (ELF64_ST_BIND(sym->st_info) == STB_LOCAL &&
+ (ELF64_ST_TYPE(sym->st_info) == STT_SECTION ||
+ ELF64_ST_TYPE(sym->st_info) == STT_NOTYPE) ) {
+ *(u_int64_t *)r_addr += loff + sym->st_value;
} else if (this) {
- *(u_int32_t *)r_addr += this->st_value + ooff;
+ /* XXX Handle non aligned relocs. .eh_frame
+ * XXX in libstdc++ seems to have them... */
+ if (((long)r_addr & 7)) {
+ u_int64_t robj;
+ _dl_bcopy((char *)r_addr, &robj, sizeof(robj));
+ robj += this->st_value + ooff;
+ _dl_bcopy(&robj, (char *)r_addr, sizeof(robj));
+ } else
+ *(u_int64_t *)r_addr += this->st_value + ooff;
}
break;
@@ -97,12 +121,19 @@ _dl_md_reloc(elf_object_t *object, int rel, int relsz)
break;
default:
- _dl_printf("%s: unsupported relocation '%s'\n",
- _dl_progname, symn);
+ _dl_printf("%s: unsupported relocation '%d'\n",
+ _dl_progname, ELF64_R_TYPE(relocs->r_info));
_dl_exit(1);
}
}
-
+ DL_DEB(("done %d fails\n", fails));
+ load_list = object->load_list;
+ while (load_list != NULL) {
+ if ((load_list->prot & PROT_WRITE) == 0)
+ _dl_mprotect(load_list->start, load_list->size,
+ load_list->prot);
+ load_list = load_list->next;
+ }
return(fails);
}
@@ -119,12 +150,12 @@ void
_dl_md_reloc_got(elf_object_t *object, int lazy)
{
int i, n;
- Elf32_Addr loff;
- Elf32_Addr ooff;
- Elf32_Addr *gotp;
- Elf32_Addr plt_addr;
- const Elf32_Sym *symp;
- const Elf32_Sym *this;
+ Elf64_Addr loff;
+ Elf64_Addr ooff;
+ Elf64_Addr *gotp;
+ Elf64_Addr plt_addr;
+ const Elf64_Sym *symp;
+ const Elf64_Sym *this;
const char *strt;
if (object->status & STAT_GOT_DONE)
@@ -140,13 +171,13 @@ _dl_md_reloc_got(elf_object_t *object, int lazy)
/*
* Set up pointers for run time (lazy) resolving.
*/
- gotp[0] = (int)_dl_rt_resolve;
- if (gotp[1] & 0x80000000) {
- gotp[1] = (int)object | 0x80000000;
+ gotp[0] = (long)_dl_rt_resolve;
+ if (gotp[1] & 0x0000000080000000) {
+ gotp[1] = (long)object | 0x0000000080000000;
}
/* First do all local references. */
- for (i = ((gotp[1] & 0x80000000) ? 2 : 1); i < n; i++) {
+ for (i = ((gotp[1] & 0x0000000080000000) ? 2 : 1); i < n; i++) {
gotp[i] += loff;
DL_DEB(("got: '%p' = %x\n", &gotp[i], gotp[i]));
}
@@ -191,7 +222,7 @@ _dl_md_reloc_got(elf_object_t *object, int lazy)
*/
while (n--) {
if (symp->st_shndx == SHN_UNDEF &&
- ELF32_ST_TYPE(symp->st_info) == STT_FUNC) {
+ ELF64_ST_TYPE(symp->st_info) == STT_FUNC) {
DL_DEB(("got: '%s' = %x\n", strt + symp->st_name, symp->st_value));
if (symp->st_value == 0 || !lazy) {
this = 0;
@@ -212,7 +243,7 @@ _dl_md_reloc_got(elf_object_t *object, int lazy)
symp->st_size, object);
if (this)
*gotp = this->st_value + ooff;
- } else if (ELF32_ST_TYPE(symp->st_info) == STT_FUNC) {
+ } else if (ELF64_ST_TYPE(symp->st_info) == STT_FUNC) {
*gotp += loff;
} else { /* XXX ??? */ /* Resolve all others immediatly */
*gotp = symp->st_value + loff;
diff --git a/libexec/ld.so/mips64/syscall.h b/libexec/ld.so/mips64/syscall.h
index 17a8c981747..1524eafbe93 100644
--- a/libexec/ld.so/mips64/syscall.h
+++ b/libexec/ld.so/mips64/syscall.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: syscall.h,v 1.1 2004/08/11 17:11:45 pefo Exp $ */
+/* $OpenBSD: syscall.h,v 1.2 2004/09/09 17:47:44 pefo Exp $ */
/*
* Copyright (c) 1998-2002 Opsycon AB, Sweden.
@@ -45,18 +45,18 @@ extern long _dl__syscall(quad_t val, ...);
* any dynamic address resolving has been done.
*/
-extern inline int
+extern inline void
_dl_exit(int status)
{
register int __status __asm__ ("$2");
__asm__ volatile (
- "move $2,%1\n\t"
"move $4,%2\n\t"
+ "li $2,%1\n\t"
"syscall"
: "=r" (__status)
- : "0" (SYS_exit), "r" (status)
- : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9",
+ : "I" (SYS_exit), "r" (status)
+ : "$3", "$4", "$5", "$6", "$7", "$8", "$9",
"$10","$11","$12","$13","$14","$15","$24","$25");
while (1)
;
@@ -68,16 +68,16 @@ _dl_open(const char* addr, int flags)
register int status __asm__ ("$2");
__asm__ volatile (
- "move $2,%1\n\t"
"move $4,%2\n\t"
"move $5,%3\n\t"
+ "li $2,%1\n\t"
"syscall\n\t"
"beq $7,$0,1f\n\t"
"li $2,-1\n\t"
"1:"
: "=r" (status)
- : "0" (SYS_open), "r" (addr), "r" (flags)
- : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9",
+ : "I" (SYS_open), "r" (addr), "r" (flags)
+ : "$3", "$4", "$5", "$6", "$7", "$8", "$9",
"$10","$11","$12","$13","$14","$15","$24","$25");
return status;
}
@@ -88,15 +88,15 @@ _dl_close(int fd)
register int status __asm__ ("$2");
__asm__ volatile (
- "move $2,%1\n\t"
"move $4,%2\n\t"
+ "li $2,%1\n\t"
"syscall\n\t"
"beq $7,$0,1f\n\t"
"li $2,-1\n\t"
"1:"
: "=r" (status)
- : "0" (SYS_close), "r" (fd)
- : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9",
+ : "I" (SYS_close), "r" (fd)
+ : "$3", "$4", "$5", "$6", "$7", "$8", "$9",
"$10","$11","$12","$13","$14","$15","$24","$25");
return status;
}
@@ -107,17 +107,17 @@ _dl_write(int fd, const char* buf, size_t len)
register ssize_t status __asm__ ("$2");
__asm__ volatile (
- "move $2,%1\n\t"
"move $4,%2\n\t"
"move $5,%3\n\t"
"move $6,%4\n\t"
+ "li $2,%1\n\t"
"syscall\n\t"
"beq $7,$0,1f\n\t"
"li $2,-1\n\t"
"1:"
: "=r" (status)
- : "0" (SYS_write), "r" (fd), "r" (buf), "r" (len)
- : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9",
+ : "I" (SYS_write), "r" (fd), "r" (buf), "r" (len)
+ : "$3", "$4", "$5", "$6", "$7", "$8", "$9",
"$10","$11","$12","$13","$14","$15","$24","$25");
return status;
}
@@ -128,57 +128,26 @@ _dl_read(int fd, const char* buf, size_t len)
register ssize_t status __asm__ ("$2");
__asm__ volatile (
- "move $2,%1\n\t"
"move $4,%2\n\t"
"move $5,%3\n\t"
"move $6,%4\n\t"
+ "li $2,%1\n\t"
"syscall\n\t"
"beq $7,$0,1f\n\t"
"li $2,-1\n\t"
"1:"
: "=r" (status)
- : "0" (SYS_read), "r" (fd), "r" (buf), "r" (len)
- : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9",
+ : "I" (SYS_read), "r" (fd), "r" (buf), "r" (len)
+ : "$3", "$4", "$5", "$6", "$7", "$8", "$9",
"$10","$11","$12","$13","$14","$15","$24","$25");
return status;
}
extern inline void *
-_dl_mmap(void *addr, size_t size, int prot, int flags, int fd, off_t f_offset)
+_dl_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset)
{
- register void * malloc_buffer __asm__ ("$2");
-
- __asm__ volatile (
- "move $2,%1\n\t"
- "addiu $29,-40\n\t"
- "move $6,%2\n\t"
- "move $7,%3\n\t"
- "sw %4,16($29)\n\t"
- "sw %5,20($29)\n\t"
-#ifdef __MIPSEL__
- "li $4,197\n\t"
- "li $5,0\n\t"
- "sw %6,24($29)\n\t"
- "sw $0,28($29)\n\t"
- "sw %7,32($29)\n\t"
- "sw $0,36($29)\n\t"
-#endif
-#ifdef __MIPSEB__
- "li $4,0\n\t"
- "li $5,197\n\t"
- "sw %6,24($29)\n\t"
- "sw $0,28($29)\n\t"
- "sw $0,32($29)\n\t"
- "sw %7,36($29)\n\t"
-#endif
- "syscall\n\t"
- "addiu $29,40"
- : "=r" (malloc_buffer)
- : "0" (SYS___syscall), "r" (addr), "r" (size), "r" (prot),
- "r" (flags), "r" (fd), "r" ((int)f_offset)
- : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9",
- "$10","$11","$12","$13","$14","$15","$24","$25");
- return malloc_buffer;
+ return((void *)_dl__syscall((quad_t)SYS_mmap, addr, len, prot,
+ flags, fd, 0, offset));
}
extern inline int
@@ -187,16 +156,16 @@ _dl_munmap(const void* addr, size_t len)
register int status __asm__ ("$2");
__asm__ volatile (
- "move $2,%1\n\t"
"move $4,%2\n\t"
"move $5,%3\n\t"
+ "li $2,%1\n\t"
"syscall\n\t"
"beq $7,$0,1f\n\t"
"li $2,-1\n\t"
"1:"
: "=r" (status)
- : "0" (SYS_munmap), "r" (addr), "r" (len)
- : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9",
+ : "I" (SYS_munmap), "r" (addr), "r" (len)
+ : "$3", "$4", "$5", "$6", "$7", "$8", "$9",
"$10","$11","$12","$13","$14","$15","$24","$25");
return status;
}
@@ -207,14 +176,14 @@ _dl_mprotect(const void *addr, size_t size, int prot)
register int status __asm__ ("$2");
__asm__ volatile (
- "move $2,%1\n\t"
"move $4,%2\n\t"
"move $5,%3\n\t"
"move $6,%4\n\t"
+ "li $2,%1\n\t"
"syscall"
: "=r" (status)
- : "0" (SYS_mprotect), "r" (addr), "r" (size), "r" (prot)
- : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9",
+ : "I" (SYS_mprotect), "r" (addr), "r" (size), "r" (prot)
+ : "$3", "$4", "$5", "$6", "$7", "$8", "$9",
"$10","$11","$12","$13","$14","$15","$24","$25");
return status;
}
@@ -225,13 +194,13 @@ _dl_stat(const char *addr, struct stat *sb)
register int status __asm__ ("$2");
__asm__ volatile (
- "move $2,%1\n\t"
"move $4,%2\n\t"
"move $5,%3\n\t"
+ "li $2,%1\n\t"
"syscall"
: "=r" (status)
- : "0" (SYS_stat), "r" (addr), "r" (sb)
- : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9",
+ : "I" (SYS_stat), "r" (addr), "r" (sb)
+ : "$3", "$4", "$5", "$6", "$7", "$8", "$9",
"$10","$11","$12","$13","$14","$15","$24","$25");
return status;
}
@@ -242,13 +211,13 @@ _dl_fstat(const int fd, struct stat *sb)
register int status __asm__ ("$2");
__asm__ volatile (
- "move $2,%1\n\t"
"move $4,%2\n\t"
"move $5,%3\n\t"
+ "li $2,%1\n\t"
"syscall"
: "=r" (status)
- : "0" (SYS_fstat), "r" (fd), "r" (sb)
- : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9",
+ : "I" (SYS_fstat), "r" (fd), "r" (sb)
+ : "$3", "$4", "$5", "$6", "$7", "$8", "$9",
"$10","$11","$12","$13","$14","$15","$24","$25");
return status;
}
@@ -259,17 +228,17 @@ _dl_fcntl(int fd, int cmd, int flag)
register int status __asm__ ("$2");
__asm__ volatile (
- "move $2,%1\n\t"
"move $4,%2\n\t"
"move $5,%3\n\t"
"move $6,%4\n\t"
+ "li $2,%1\n\t"
"syscall\n\t"
"beq $7,$0,1f\n\t"
"li $2,-1\n\t"
"1:"
: "=r" (status)
- : "0" (SYS_fcntl), "r" (fd), "r" (cmd), "r" (flag)
- : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9",
+ : "I" (SYS_fcntl), "r" (fd), "r" (cmd), "r" (flag)
+ : "$3", "$4", "$5", "$6", "$7", "$8", "$9",
"$10","$11","$12","$13","$14","$15","$24","$25");
return status;
}
@@ -279,18 +248,19 @@ _dl_getdirentries(int fd, char *buf, int nbytes, long *basep)
{
register int status __asm__ ("$2");
- __asm__ volatile ("move $2,%1\n\t"
+ __asm__ volatile (
"move $4,%2\n\t"
"move $5,%3\n\t"
"move $6,%4\n\t"
"move $7,%5\n\t"
+ "li $2,%1\n\t"
"syscall\n\t"
"beq $7,$0,1f\n\t"
"li $2,-1\n\t"
"1:"
: "=r" (status)
- : "0" (SYS_getdirentries), "r" (fd), "r" (buf), "r" (nbytes), "r" (basep)
- : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9",
+ : "I" (SYS_getdirentries), "r" (fd), "r" (buf), "r" (nbytes), "r" (basep)
+ : "$3", "$4", "$5", "$6", "$7", "$8", "$9",
"$10","$11","$12","$13","$14","$15","$24","$25");
return status;
}
@@ -301,11 +271,11 @@ _dl_issetugid(void)
register int status __asm__ ("$2");
__asm__ volatile (
- "move $2,%1\n\t"
+ "li $2,%1\n\t"
"syscall"
: "=r" (status)
- : "0" (SYS_issetugid)
- : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9",
+ : "I" (SYS_issetugid)
+ : "$3", "$4", "$5", "$6", "$7", "$8", "$9",
"$10","$11","$12","$13","$14","$15","$24","$25");
return status;
}
@@ -329,14 +299,14 @@ _dl_sigprocmask(int how, const sigset_t *set, sigset_t *oset)
}
__asm__ volatile (
- "li $2,%1\n\t"
"move $4,%2\n\t"
"move $5,%3\n\t"
+ "li $2,%1\n\t"
"syscall\n\t"
"move %0, $2"
: "=r" (sig_store)
: "I" (SYS_sigprocmask), "r" (how), "r" (sig_store1)
- : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9",
+ : "$3", "$4", "$5", "$6", "$7", "$8", "$9",
"$10","$11","$12","$13","$14","$15","$24","$25");
if (oset != NULL)
*oset = sig_store;
@@ -350,23 +320,21 @@ _dl_sysctl(int *name, u_int namelen, void *oldp, size_t *oldplen, void *newp,
register int status __asm__ ("$2");
__asm__ volatile (
- "move $2,%1\n\t"
- "addiu $29,-40\n\t"
"move $4,%2\n\t"
"move $5,%3\n\t"
"move $6,%4\n\t"
"move $7,%5\n\t"
- "sw %6,16($29)\n\t"
- "sw %7,20($29)\n\t"
+ "move $8,%6\n\t"
+ "move $9,%7\n\t"
+ "li $2,%1\n\t"
"syscall\n\t"
- "addiu $29,40\n\t"
"beqz $2,1f\n\t"
"li $2,-1\n\t"
"1:"
: "=r" (status)
- : "r" (SYS___sysctl), "r" (name), "r" (namelen), "r" (oldp),
+ : "I" (SYS___sysctl), "r" (name), "r" (namelen), "r" (oldp),
"r" (oldplen), "r" (newp), "r" (newlen)
- : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9",
+ : "$3", "$4", "$5", "$6", "$7", "$8", "$9",
"$10","$11","$12","$13","$14","$15","$24","$25");
return status;
}