Moved via repository copy to arch/mips

This commit is contained in:
christos 1999-01-10 17:33:59 +00:00
parent a12e7c4c86
commit 86ef105de2
4 changed files with 0 additions and 380 deletions

View File

@ -1,16 +0,0 @@
# $NetBSD: Makefile.inc,v 1.3 1998/05/11 19:30:15 mhitch Exp $
SRCS+= rtld_start.S mips_reloc.c
CPPFLAGS+= -mabicalls -G0 -fPIC -DELFSIZE=32 -I${.CURDIR}
.if (${MACHINE} == "newsmips")
# UGH! ld.so.script specifies little-endian; need to override that here
LDFLAGS+= -EB
.endif
LDFLAGS+= -Bshareable -Bsymbolic -e .rtld_start
LDFLAGS+= --script ${.CURDIR}/mips/ld.so.script
# Link ld.so for backward compatibility with old binaries
LINKS+= /usr/libexec/${PROG} /usr/libexec/ld.so

View File

@ -1,152 +0,0 @@
/* $NetBSD: ld.so.script,v 1.1 1998/03/25 04:12:32 mhitch Exp $ */
/* ldscript for MIPS ld.elf_so */
OUTPUT_FORMAT("elf32-littlemips", "elf32-bigmips",
"elf32-littlemips")
OUTPUT_ARCH(mips)
ENTRY(_start)
SEARCH_DIR(/lib); SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/local/lib); SEARCH_DIR(/usr/local/mips-dec-netbsd/lib);
/* Do we need any of these for elf?
__DYNAMIC = 0; */
SECTIONS
{
/* Read-only sections, merged into text segment: */
. = 0x5ffe0000 + SIZEOF_HEADERS;
.reginfo : { *(.reginfo) }
.dynamic : { *(.dynamic) }
.dynstr : { *(.dynstr) }
.dynsym : { *(.dynsym) }
.hash : { *(.hash) }
.rel.text :
{ *(.rel.text) *(.rel.gnu.linkonce.t*) }
.rela.text :
{ *(.rela.text) *(.rela.gnu.linkonce.t*) }
.rel.data :
{ *(.rel.data) *(.rel.gnu.linkonce.d*) }
.rela.data :
{ *(.rela.data) *(.rela.gnu.linkonce.d*) }
.rel.rodata :
{ *(.rel.rodata) *(.rel.gnu.linkonce.r*) }
.rela.rodata :
{ *(.rela.rodata) *(.rela.gnu.linkonce.r*) }
.rel.got : { *(.rel.got) }
.rela.got : { *(.rela.got) }
.rel.ctors : { *(.rel.ctors) }
.rela.ctors : { *(.rela.ctors) }
.rel.dtors : { *(.rel.dtors) }
.rela.dtors : { *(.rela.dtors) }
.rel.init : { *(.rel.init) }
.rela.init : { *(.rela.init) }
.rel.fini : { *(.rel.fini) }
.rela.fini : { *(.rela.fini) }
.rel.bss : { *(.rel.bss) }
.rela.bss : { *(.rela.bss) }
.rel.plt : { *(.rel.plt) }
.rela.plt : { *(.rela.plt) }
.rodata : { *(.rodata) *(.gnu.linkonce.r*) }
.rodata1 : { *(.rodata1) }
.init : { *(.init) } =0
.text :
{
_ftext = . ;
*(.text)
*(.stub)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
*(.gnu.linkonce.t*)
*(.mips16.fn.*)
*(.mips16.call.*)
} =0
_etext = .;
PROVIDE (etext = .);
.fini : { *(.fini) } =0
/* Adjust the address for the data segment. We want to adjust up to
the same address within the page on the next page up. It would
be more correct to do this:
. = 0x10000000;
The current expression does not correctly handle the case of a
text segment ending precisely at the end of a page; it causes the
data segment to skip a page. The above expression does not have
this problem, but it will currently (2/95) cause BFD to allocate
a single segment, combining both text and data, for this case.
This will prevent the text segment from being shared among
multiple executions of the program; I think that is more
important than losing a page of the virtual address space (note
that no actual memory is lost; the page which is skipped can not
be referenced). */
/* "Fix" for ld.so on NetBSD:
The binutils 2.8.1 ld aligns the data segment at 1MB (0x40000), but
the alignment specified in the ELF program headers specifies 4K
(0x1000). The NetBSD kernel forces the data section to be loaded
by the alignment in the program header, which thus does not match
the alignment done by ld. This line is the only difference from
the script built in to ld: force the data section alignment to
match what bfd puts into the program headers. */
. = ALIGN(0x1000) + (ALIGN(8) & (0x1000 - 1));
.data :
{
_fdata = . ;
*(.data)
*(.gnu.linkonce.d*)
CONSTRUCTORS
}
.data1 : { *(.data1) }
.ctors : { *(.ctors) }
.dtors : { *(.dtors) }
_gp = ALIGN(16) + 0x7ff0;
.got :
{
*(.got.plt) *(.got)
}
/* We want the small data sections together, so single-instruction offsets
can access them all, and initialized data all before uninitialized, so
we can shorten the on-disk segment size. */
.sdata : { *(.sdata) }
.lit8 : { *(.lit8) }
.lit4 : { *(.lit4) }
_edata = .;
PROVIDE (edata = .);
__bss_start = .;
_fbss = .;
.sbss : { *(.sbss) *(.scommon) }
.bss :
{
*(.dynbss)
*(.bss)
*(COMMON)
}
_end = . ;
PROVIDE (end = .);
/* These are needed for ELF backends which have not yet been
converted to the new style linker. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
/* These must appear regardless of . */
.gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
.gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
}

View File

@ -1,123 +0,0 @@
/* $NetBSD: mips_reloc.c,v 1.1 1998/03/25 04:12:32 mhitch Exp $ */
/*
* Copyright 1997 Michael L. Hitch <mhitch@montana.edu>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdarg.h>
#include <sys/types.h>
#include "debug.h"
#include "rtld.h"
/*
* Relocate a MIPS GOT
*/
void
_rtld_relocate_mips_got(obj)
Obj_Entry *obj;
{
Elf_Addr *got = obj->pltgot;
const Elf_Sym *sym = obj->symtab;
const Elf_Sym *def;
const Obj_Entry *defobj;
int i;
i = (got[1] & 0x80000000) ? 2 : 1;
/* Relocate the local GOT entries */
while (i < obj->local_gotno)
got[i++] += (Elf_Word)obj->relocbase;
got += obj->local_gotno;
i = obj->symtabno - obj->gotsym;
sym += obj->gotsym;
/* Now do the global GOT entries */
while (i--) {
def = _rtld_find_symdef(_rtld_objlist, 0,
sym->st_name + obj->strtab, obj, &defobj, true);
if (def != NULL) {
if (sym->st_shndx == Elf_eshn_undefined) {
#if 0 /* These don't seem to work? */
if (ELF_SYM_TYPE(sym->st_info) ==
Elf_estt_func) {
if (sym->st_value)
*got = sym->st_value +
(Elf_Word)obj->relocbase;
else
*got = def->st_value +
(Elf_Word)defobj->relocbase;
} else
#endif
*got = def->st_value +
(Elf_Word)defobj->relocbase;
} else if (sym->st_shndx == Elf_eshn_common) {
*got = def->st_value +
(Elf_Word)defobj->relocbase;
} else if (ELF_SYM_TYPE(sym->st_info) == Elf_estt_func
&& *got != sym->st_value) {
*got += (Elf_Word)obj->relocbase;
} else if (ELF_SYM_TYPE(sym->st_info) ==
Elf_estt_section && ELF_SYM_BIND(sym->st_info) ==
Elf_estb_global) {
if (sym->st_shndx == Elf_eshn_absolute)
*got = sym->st_value +
(Elf_Word)obj->relocbase;
/* else SGI stuff ignored */
} else
*got = def->st_value +
(Elf_Word)defobj->relocbase;
}
++sym;
++got;
}
}
/*
* _rtld_bind_mips(symbol_index, return_address, old_gp, stub_return_addr)
*/
caddr_t
_rtld_bind_mips(a0, a1, a2, a3)
Elf_Word a0;
Elf_Addr a1, a2, a3;
{
Elf_Addr *u = (Elf_Addr *)(a2 - 0x7ff0);
Obj_Entry *obj = (Obj_Entry *)(u[1] & 0x7fffffff);
const Elf_Sym *def;
const Obj_Entry *defobj;
def = _rtld_find_symdef(_rtld_objlist, a0 << 8, NULL, obj, &defobj,
true);
if (def) {
u[obj->local_gotno + a0 - obj->gotsym] = (Elf_Addr)
(def->st_value + defobj->relocbase);
return((caddr_t)(def->st_value + defobj->relocbase));
}
return(NULL); /* XXX */
}

View File

@ -1,89 +0,0 @@
/* $NetBSD: rtld_start.S,v 1.2 1998/04/09 04:45:08 mhitch Exp $ */
/*
* Copyright 1997 Michael L. Hitch <mhitch@montana.edu>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/regdef.h>
#include <mips/asm.h>
LEAF(rtld_start)
.set noreorder
.cpload t9
addu sp, sp, -12 # adjust stack pointer
.cprestore 0 # 0(sp) for gp
# 4(sp) for atexit
# 8(sp) for obj_main
move s0,a0 # save stack pointer from a0
addu a0, sp, 4 # _rtld argument
move s1,a3 # save ps_strings pointer
jal _C_LABEL(_rtld) # v0 = _rtld(sp)
nop # [BD if jal not expanded]
lw a1, 4(sp) # our atexit function
lw a2, 8(sp) # obj_main entry
addu sp, sp,12 # readjust stack
move a0,s0 # stack pointer
move t9,v0
jr t9 # _start(sp, cleanup, obj);
move a3,s1 # restore ps_strings
END(rtld_start)
.globl _rtld_bind_start
.ent _rtld_bind_start
_rtld_bind_start:
move v1,gp # save old GP
add t9,8 # modify T9 to point at .cpload
.cpload t9
subu sp,40 # save arguments and sp value in stack
.cprestore 32
sw t7,36(sp)
sw a0,12(sp)
sw a1,16(sp)
sw a2,20(sp)
sw a3,24(sp)
sw s0,28(sp)
move s0,sp
move a0,t8 # symbol index
move a1,t7 # old RA
move a2,v1 # old GP
move a3,ra # current RA
jal _C_LABEL(_rtld_bind_mips)
nop
move sp,s0
lw ra,36(sp)
lw a0,12(sp)
lw a1,16(sp)
lw a2,20(sp)
lw a3,24(sp)
lw s0,28(sp)
addu sp,40
move t9,v0
jr t9
nop
.end _rtld_bind_start