[Midnightbsd-cvs] src: libexec/rtld-elf: Remove unsupported arch
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Thu Nov 20 13:10:25 EST 2008
Log Message:
-----------
Remove unsupported arch
Modified Files:
--------------
src/libexec/rtld-elf:
Makefile (r1.1.1.2 -> r1.2)
Removed Files:
-------------
src/libexec/rtld-elf/alpha:
Makefile.inc
ld.so.script
reloc.c
rtld_machdep.h
rtld_start.S
src/libexec/rtld-elf/arm:
Makefile.inc
reloc.c
rtld_machdep.h
rtld_start.S
src/libexec/rtld-elf/ia64:
Makefile.inc
reloc.c
rtld_machdep.h
rtld_start.S
src/libexec/rtld-elf/powerpc:
Makefile.inc
reloc.c
rtld_machdep.h
rtld_start.S
-------------- next part --------------
Index: Makefile
===================================================================
RCS file: /home/cvs/src/libexec/rtld-elf/Makefile,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -L libexec/rtld-elf/Makefile -L libexec/rtld-elf/Makefile -u -r1.1.1.2 -r1.2
--- libexec/rtld-elf/Makefile
+++ libexec/rtld-elf/Makefile
@@ -23,7 +23,6 @@
DPADD= ${LIBC_PIC}
LDADD= -lc_pic
-.if ${MACHINE_ARCH} != "ia64"
.if ${MK_SYMVER} == "yes"
LIBCDIR= ${.CURDIR}/../../lib/libc
VERSION_DEF= ${LIBCDIR}/Versions.def
@@ -37,7 +36,6 @@
SYMBOL_MAPS+= ${.CURDIR}/${MACHINE_ARCH}/Symbol.map
.endif
.endif
-.endif
.if exists(${.CURDIR}/${MACHINE_ARCH}/Makefile.inc)
.include "${.CURDIR}/${MACHINE_ARCH}/Makefile.inc"
--- libexec/rtld-elf/alpha/ld.so.script
+++ /dev/null
@@ -1,135 +0,0 @@
-/* $NetBSD: ld.so.script,v 1.2 2001/12/13 20:31:31 thorpej Exp $ */
-/* $FreeBSD: src/libexec/rtld-elf/alpha/ld.so.script,v 1.2 2002/10/12 02:30:53 obrien Exp $ */
-
-OUTPUT_FORMAT("elf64-alpha-freebsd", "elf64-alpha-freebsd",
- "elf64-alpha-freebsd")
-OUTPUT_ARCH(alpha)
-ENTRY(__start)
-/* SEARCH_DIR(/usr/lib); JRT */
-/* Do we need any of these for elf?
- __DYNAMIC = 0; */
-SECTIONS
-{
- /* Read-only sections, merged into text segment: */
- . = 0 + SIZEOF_HEADERS;
- .hash : { *(.hash) }
- .dynsym : { *(.dynsym) }
- .dynstr : { *(.dynstr) }
- .gnu.version : { *(.gnu.version) }
- .gnu.version_d : { *(.gnu.version_d) }
- .gnu.version_r : { *(.gnu.version_r) }
- .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) }
- .init : { *(.init) } =0x47ff041f
- .text :
- {
- *(.text)
- *(.stub)
- /* .gnu.warning sections are handled specially by elf32.em. */
- *(.gnu.warning)
- *(.gnu.linkonce.t*)
- } =0x47ff041f
- _etext = .;
- PROVIDE (etext = .);
- .fini : { *(.fini) } =0x47ff041f
- .rodata : { *(.rodata) *(.gnu.linkonce.r*) }
- .rodata1 : { *(.rodata1) }
- .reginfo : { *(.reginfo) }
- /* Adjust the address for the data segment. We want to adjust up to
- the same address within the page on the next page up. */
- . = ALIGN(0x100000) + (. & (0x100000 - 1));
- .data :
- {
- *(.data)
- *(.gnu.linkonce.d*)
- CONSTRUCTORS
- }
- .data1 : { *(.data1) }
- .ctors :
- {
- *(.ctors)
- }
- .dtors :
- {
- *(.dtors)
- }
- .plt : { *(.plt) }
- .got : { *(.got.plt) *(.got) }
- PROVIDE (_GOT_END_ = .);
- .dynamic : { *(.dynamic) }
- /* 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) }
- _edata = .;
- PROVIDE (edata = .);
- __bss_start = .;
- .sbss : { *(.sbss) *(.scommon) }
- .bss :
- {
- *(.dynbss)
- *(.bss)
- *(COMMON)
- }
- . = ALIGN(64 / 8);
- _end = . ;
- PROVIDE (end = .);
- /* Stabs debugging sections. */
- .stab 0 : { *(.stab) }
- .stabstr 0 : { *(.stabstr) }
- .stab.excl 0 : { *(.stab.excl) }
- .stab.exclstr 0 : { *(.stab.exclstr) }
- .stab.index 0 : { *(.stab.index) }
- .stab.indexstr 0 : { *(.stab.indexstr) }
- .comment 0 : { *(.comment) }
- /* 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 . */
-}
--- libexec/rtld-elf/alpha/Makefile.inc
+++ /dev/null
@@ -1,4 +0,0 @@
-# $FreeBSD: src/libexec/rtld-elf/alpha/Makefile.inc,v 1.2 2002/02/18 02:24:09 peter Exp $
-
-CFLAGS+= -mno-fp-regs
-LDFLAGS+= -Wl,--script,${.CURDIR}/alpha/ld.so.script
--- libexec/rtld-elf/alpha/reloc.c
+++ /dev/null
@@ -1,529 +0,0 @@
-/*-
- * Copyright 1996, 1997, 1998, 1999 John D. Polstra.
- * 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.
- *
- * 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.
- *
- * $FreeBSD: src/libexec/rtld-elf/alpha/reloc.c,v 1.20.2.1 2005/12/30 22:13:56 marcel Exp $
- */
-
-/*
- * Dynamic linker for ELF.
- *
- * John Polstra <jdp at polstra.com>.
- */
-
-#include <sys/param.h>
-#include <sys/mman.h>
-
-#include <dlfcn.h>
-#include <err.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "debug.h"
-#include "rtld.h"
-
-extern Elf_Dyn _GOT_END_;
-
-/*
- * Macros for loading/storing unaligned 64-bit values. These are
- * needed because relocations can point to unaligned data. This
- * occurs in the DWARF2 exception frame tables generated by the
- * compiler, for instance.
- *
- * We don't use these when relocating jump slots and GOT entries,
- * since they are guaranteed to be aligned.
- */
-
-struct ualong {
- Elf_Addr x __attribute__((packed));
-};
-
-#define load64(p) (((struct ualong *)(p))->x)
-#define store64(p,v) (((struct ualong *)(p))->x = (v))
-
-/* Relocate a non-PLT object with addend. */
-static int
-reloc_non_plt_obj(Obj_Entry *obj_rtld, Obj_Entry *obj, const Elf_Rela *rela,
- SymCache *cache)
-{
- Elf_Addr *where = (Elf_Addr *) (obj->relocbase + rela->r_offset);
-
- switch (ELF_R_TYPE(rela->r_info)) {
-
- case R_ALPHA_NONE:
- break;
-
- case R_ALPHA_REFQUAD: {
- const Elf_Sym *def;
- const Obj_Entry *defobj;
-
- def = find_symdef(ELF_R_SYM(rela->r_info), obj,
- &defobj, false, cache);
- if (def == NULL)
- return -1;
- store64(where,
- (Elf_Addr) (defobj->relocbase + def->st_value) +
- load64(where) + rela->r_addend);
- }
- break;
-
- case R_ALPHA_GLOB_DAT: {
- const Elf_Sym *def;
- const Obj_Entry *defobj;
- Elf_Addr val;
-
- def = find_symdef(ELF_R_SYM(rela->r_info), obj,
- &defobj, false, cache);
- if (def == NULL)
- return -1;
- val = (Elf_Addr) (defobj->relocbase + def->st_value +
- rela->r_addend);
- if (load64(where) != val)
- store64(where, val);
- }
- break;
-
- case R_ALPHA_RELATIVE: {
- if (obj != obj_rtld ||
- (caddr_t)where < (caddr_t)_GLOBAL_OFFSET_TABLE_ ||
- (caddr_t)where >= (caddr_t)&_GOT_END_)
- store64(where,
- load64(where) + (Elf_Addr) obj->relocbase);
- }
- break;
-
- case R_ALPHA_COPY: {
- /*
- * These are deferred until all other relocations
- * have been done. All we do here is make sure
- * that the COPY relocation is not in a shared
- * library. They are allowed only in executable
- * files.
- */
- if (!obj->mainprog) {
- _rtld_error("%s: Unexpected R_COPY "
- " relocation in shared library",
- obj->path);
- return -1;
- }
- }
- break;
-
- default:
- _rtld_error("%s: Unsupported relocation type %u"
- " in non-PLT relocations\n", obj->path,
- (unsigned int)ELF_R_TYPE(rela->r_info));
- return -1;
- }
- return(0);
-}
-
-/* Process the non-PLT relocations. */
-int
-reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld)
-{
- const Elf_Rel *rellim;
- const Elf_Rel *rel;
- const Elf_Rela *relalim;
- const Elf_Rela *rela;
- SymCache *cache;
- int bytes = obj->nchains * sizeof(SymCache);
- int r = -1;
-
- /*
- * The dynamic loader may be called from a thread, we have
- * limited amounts of stack available so we cannot use alloca().
- */
- cache = mmap(NULL, bytes, PROT_READ|PROT_WRITE, MAP_ANON, -1, 0);
- if (cache == MAP_FAILED)
- cache = NULL;
-
- /* Perform relocations without addend if there are any: */
- rellim = (const Elf_Rel *) ((caddr_t) obj->rel + obj->relsize);
- for (rel = obj->rel; obj->rel != NULL && rel < rellim; rel++) {
- Elf_Rela locrela;
-
- locrela.r_info = rel->r_info;
- locrela.r_offset = rel->r_offset;
- locrela.r_addend = 0;
- if (reloc_non_plt_obj(obj_rtld, obj, &locrela, cache))
- goto done;
- }
-
- /* Perform relocations with addend if there are any: */
- relalim = (const Elf_Rela *) ((caddr_t) obj->rela + obj->relasize);
- for (rela = obj->rela; obj->rela != NULL && rela < relalim; rela++) {
- if (reloc_non_plt_obj(obj_rtld, obj, rela, cache))
- goto done;
- }
- r = 0;
-done:
- if (cache)
- munmap(cache, bytes);
- return(r);
-}
-
-/* Process the PLT relocations. */
-int
-reloc_plt(Obj_Entry *obj)
-{
- /* All PLT relocations are the same kind: either Elf_Rel or Elf_Rela. */
- if (obj->pltrelsize != 0) {
- const Elf_Rel *rellim;
- const Elf_Rel *rel;
-
- rellim = (const Elf_Rel *)((char *)obj->pltrel + obj->pltrelsize);
- for (rel = obj->pltrel; rel < rellim; rel++) {
- Elf_Addr *where;
-
- assert(ELF_R_TYPE(rel->r_info) == R_ALPHA_JMP_SLOT);
-
- /* Relocate the GOT slot pointing into the PLT. */
- where = (Elf_Addr *)(obj->relocbase + rel->r_offset);
- *where += (Elf_Addr)obj->relocbase;
- }
- } else {
- const Elf_Rela *relalim;
- const Elf_Rela *rela;
-
- relalim = (const Elf_Rela *)((char *)obj->pltrela + obj->pltrelasize);
- for (rela = obj->pltrela; rela < relalim; rela++) {
- Elf_Addr *where;
-
- assert(ELF_R_TYPE(rela->r_info) == R_ALPHA_JMP_SLOT);
-
- /* Relocate the GOT slot pointing into the PLT. */
- where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
- *where += (Elf_Addr)obj->relocbase;
- }
- }
- return 0;
-}
-
-/* Relocate the jump slots in an object. */
-int
-reloc_jmpslots(Obj_Entry *obj)
-{
- if (obj->jmpslots_done)
- return 0;
- /* All PLT relocations are the same kind: either Elf_Rel or Elf_Rela. */
- if (obj->pltrelsize != 0) {
- const Elf_Rel *rellim;
- const Elf_Rel *rel;
-
- rellim = (const Elf_Rel *)((char *)obj->pltrel + obj->pltrelsize);
- for (rel = obj->pltrel; rel < rellim; rel++) {
- Elf_Addr *where;
- const Elf_Sym *def;
- const Obj_Entry *defobj;
-
- assert(ELF_R_TYPE(rel->r_info) == R_ALPHA_JMP_SLOT);
- where = (Elf_Addr *)(obj->relocbase + rel->r_offset);
- def = find_symdef(ELF_R_SYM(rel->r_info), obj, &defobj, true,
- NULL);
- if (def == NULL)
- return -1;
- reloc_jmpslot(where,
- (Elf_Addr)(defobj->relocbase + def->st_value),
- defobj, obj, rel);
- }
- } else {
- const Elf_Rela *relalim;
- const Elf_Rela *rela;
-
- relalim = (const Elf_Rela *)((char *)obj->pltrela + obj->pltrelasize);
- for (rela = obj->pltrela; rela < relalim; rela++) {
- Elf_Addr *where;
- const Elf_Sym *def;
- const Obj_Entry *defobj;
-
- assert(ELF_R_TYPE(rela->r_info) == R_ALPHA_JMP_SLOT);
- where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
- def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj, true,
- NULL);
- if (def == NULL)
- return -1;
- reloc_jmpslot(where,
- (Elf_Addr)(defobj->relocbase + def->st_value),
- defobj, obj, (Elf_Rel *)rela);
- }
- }
- obj->jmpslots_done = true;
- return 0;
-}
-
-/* Fixup the jump slot at "where" to transfer control to "target". */
-Elf_Addr
-reloc_jmpslot(Elf_Addr *where, Elf_Addr target, const Obj_Entry *obj,
- const Obj_Entry *refobj, const Elf_Rel *rel)
-{
- Elf_Addr stubaddr;
-
- dbg(" reloc_jmpslot: where=%p, target=%p", (void *)where, (void *)target);
- stubaddr = *where;
- if (stubaddr != target) {
- int64_t delta;
- u_int32_t inst[3];
- int instct;
- Elf_Addr pc;
- int64_t idisp;
- u_int32_t *stubptr;
-
- /* Point this GOT entry directly at the target. */
- *where = target;
-
- /*
- * There may be multiple GOT tables, each with an entry
- * pointing to the stub in the PLT. But we can only find and
- * fix up the first GOT entry. So we must rewrite the stub as
- * well, to perform a call to the target if it is executed.
- *
- * When the stub gets control, register pv ($27) contains its
- * address. We adjust its value so that it points to the
- * target, and then jump indirect through it.
- *
- * Each PLT entry has room for 3 instructions. If the
- * adjustment amount fits in a signed 32-bit integer, we can
- * simply add it to register pv. Otherwise we must load the
- * GOT entry itself into the pv register.
- */
- delta = target - stubaddr;
- dbg(" stubaddr=%p, where-stubaddr=%ld, delta=%ld", (void *)stubaddr,
- (long)where - (long)stubaddr, (long)delta);
- instct = 0;
- if ((int32_t)delta == delta) {
- /*
- * We can adjust pv with a LDA, LDAH sequence.
- *
- * First build an LDA instruction to adjust the low 16 bits.
- */
- inst[instct++] = 0x08 << 26 | 27 << 21 | 27 << 16 |
- (delta & 0xffff);
- dbg(" LDA $27,%d($27)", (int16_t)delta);
- /*
- * Adjust the delta to account for the effects of the LDA,
- * including sign-extension.
- */
- delta -= (int16_t)delta;
- if (delta != 0) {
- /* Build an LDAH instruction to adjust the high 16 bits. */
- inst[instct++] = 0x09 << 26 | 27 << 21 | 27 << 16 |
- (delta >> 16 & 0xffff);
- dbg(" LDAH $27,%d($27)", (int16_t)(delta >> 16));
- }
- } else {
- int64_t dhigh;
-
- /* We must load the GOT entry from memory. */
- delta = (Elf_Addr)where - stubaddr;
- /*
- * If the GOT entry is too far away from the PLT entry,
- * then punt. This PLT entry will have to be looked up
- * manually for all GOT entries except the first one.
- * The program will still run, albeit very slowly. It's
- * extremely unlikely that this case could ever arise in
- * practice, but we might as well handle it correctly if
- * it does.
- */
- if ((int32_t)delta != delta) {
- dbg(" PLT stub too far from GOT to relocate");
- return target;
- }
- dhigh = delta - (int16_t)delta;
- if (dhigh != 0) {
- /* Build an LDAH instruction to adjust the high 16 bits. */
- inst[instct++] = 0x09 << 26 | 27 << 21 | 27 << 16 |
- (dhigh >> 16 & 0xffff);
- dbg(" LDAH $27,%d($27)", (int16_t)(dhigh >> 16));
- }
- /* Build an LDQ to load the GOT entry. */
- inst[instct++] = 0x29 << 26 | 27 << 21 | 27 << 16 |
- (delta & 0xffff);
- dbg(" LDQ $27,%d($27)", (int16_t)delta);
- }
-
- /*
- * Build a JMP or BR instruction to jump to the target. If
- * the instruction displacement fits in a sign-extended 21-bit
- * field, we can use the more efficient BR instruction.
- * Otherwise we have to jump indirect through the pv register.
- */
- pc = stubaddr + 4 * (instct + 1);
- idisp = (int64_t)(target - pc) >> 2;
- if (-0x100000 <= idisp && idisp < 0x100000) {
- inst[instct++] = 0x30 << 26 | 31 << 21 | (idisp & 0x1fffff);
- dbg(" BR $31,%p", (void *)target);
- } else {
- inst[instct++] = 0x1a << 26 | 31 << 21 | 27 << 16 |
- (idisp & 0x3fff);
- dbg(" JMP $31,($27),%d", (int)(idisp & 0x3fff));
- }
-
- /*
- * Fill in the tail of the PLT entry first for reentrancy.
- * Until we have overwritten the first instruction (an
- * unconditional branch), the remaining instructions have no
- * effect.
- */
- stubptr = (u_int32_t *)stubaddr;
- while (instct > 1) {
- instct--;
- stubptr[instct] = inst[instct];
- }
- /*
- * Commit the tail of the instruction sequence to memory
- * before overwriting the first instruction.
- */
- __asm__ __volatile__("wmb" : : : "memory");
- stubptr[0] = inst[0];
- }
-
- return target;
-}
-
-/* Process an R_ALPHA_COPY relocation. */
-static int
-do_copy_relocation(Obj_Entry *dstobj, const Elf_Rela *rela)
-{
- void *dstaddr;
- const Elf_Sym *dstsym;
- const char *name;
- unsigned long hash;
- size_t size;
- const void *srcaddr;
- const Elf_Sym *srcsym;
- Obj_Entry *srcobj;
-
- dstaddr = (void *) (dstobj->relocbase + rela->r_offset);
- dstsym = dstobj->symtab + ELF_R_SYM(rela->r_info);
- name = dstobj->strtab + dstsym->st_name;
- hash = elf_hash(name);
- size = dstsym->st_size;
-
- for (srcobj = dstobj->next; srcobj != NULL; srcobj = srcobj->next)
- if ((srcsym = symlook_obj(name, hash, srcobj, false)) != NULL)
- break;
-
- if (srcobj == NULL) {
- _rtld_error("Undefined symbol \"%s\" referenced from COPY"
- " relocation in %s", name, dstobj->path);
- return -1;
- }
-
- srcaddr = (const void *) (srcobj->relocbase + srcsym->st_value);
- memcpy(dstaddr, srcaddr, size);
- return 0;
-}
-
-/*
- * Process the special R_ALPHA_COPY relocations in the main program. These
- * copy data from a shared object into a region in the main program's BSS
- * segment.
- *
- * Returns 0 on success, -1 on failure.
- */
-int
-do_copy_relocations(Obj_Entry *dstobj)
-{
- const Elf_Rel *rellim;
- const Elf_Rel *rel;
- const Elf_Rela *relalim;
- const Elf_Rela *rela;
-
- assert(dstobj->mainprog); /* COPY relocations are invalid elsewhere */
-
- rellim = (const Elf_Rel *) ((caddr_t) dstobj->rel + dstobj->relsize);
- for (rel = dstobj->rel; dstobj->rel != NULL && rel < rellim; rel++) {
- if (ELF_R_TYPE(rel->r_info) == R_ALPHA_COPY) {
- Elf_Rela locrela;
-
- locrela.r_info = rel->r_info;
- locrela.r_offset = rel->r_offset;
- locrela.r_addend = 0;
- if (do_copy_relocation(dstobj, &locrela))
- return -1;
- }
- }
-
- relalim = (const Elf_Rela *) ((caddr_t) dstobj->rela +
- dstobj->relasize);
- for (rela = dstobj->rela; dstobj->rela != NULL && rela < relalim;
- rela++) {
- if (ELF_R_TYPE(rela->r_info) == R_ALPHA_COPY) {
- if (do_copy_relocation(dstobj, rela))
- return -1;
- }
- }
-
- return 0;
-}
-
-/* Initialize the special PLT entries. */
-void
-init_pltgot(Obj_Entry *obj)
-{
- u_int32_t *pltgot;
-
- if (obj->pltgot != NULL &&
- (obj->pltrelsize != 0 || obj->pltrelasize != 0)) {
- /*
- * This function will be called to perform the relocation.
- * Look for the ldah instruction from the old PLT format since
- * that will tell us what format we are trying to relocate.
- */
- pltgot = (u_int32_t *) obj->pltgot;
- if ((pltgot[8] & 0xffff0000) == 0x279f0000)
- obj->pltgot[2] = (Elf_Addr) &_rtld_bind_start_old;
- else
- obj->pltgot[2] = (Elf_Addr) &_rtld_bind_start;
- /* Identify this shared object */
- obj->pltgot[3] = (Elf_Addr) obj;
- }
-}
-
-void
-allocate_initial_tls(Obj_Entry *list)
-{
- void *tls;
-
- /*
- * Fix the size of the static TLS block by using the maximum
- * offset allocated so far and adding a bit for dynamic modules to
- * use.
- */
- tls_static_space = tls_last_offset + tls_last_size + RTLD_STATIC_TLS_EXTRA;
- tls = allocate_tls(list, 0, 16, 16);
- alpha_pal_wrunique((u_int64_t) tls);
-}
-
-void *__tls_get_addr(tls_index* ti)
-{
- Elf_Addr** tp = (Elf_Addr**) alpha_pal_rdunique();
-
- return tls_get_addr_common(tp, ti->ti_module, ti->ti_offset);
-}
--- libexec/rtld-elf/alpha/rtld_start.S
+++ /dev/null
@@ -1,211 +0,0 @@
-/* $FreeBSD: src/libexec/rtld-elf/alpha/rtld_start.S,v 1.6 2003/05/29 22:58:24 kan Exp $ */
-/* From: NetBSD: rtld_start.S,v 1.1 1996/12/16 20:38:09 cgd Exp */
-
-/*
- * Copyright 1996 Matt Thomas <matt at 3am-software.com>
- * Copyright 2000 John D. Polstra
- * 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/asm.h>
-#include <machine/pal.h>
-
-.extern _GLOBAL_OFFSET_TABLE_
-.extern _GOT_END_
-
-LEAF(_rtld_start, 0) /* XXX */
- .set noreorder
- br pv, $33
-$33: LDGP(pv)
-
- /* save away the stack pointer */
-
- lda s0, 0(sp) /* get argc from stack */
- lda sp, -16(sp) /* space for arguments */
-
- /* save ps_strings pointer */
- mov a3, s1
-
- /* Step 1 -- Figure out the displacement */
-
- br t2, $34 /* get our PC */
-$34: ldiq t3, $34 /* get where the linker thought we were */
- subq t2, t3, t8 /* calculate the displacement */
-
-
- /* Step 2 -- Find bounds of global offset table */
-
- lda t5, _GLOBAL_OFFSET_TABLE_
- addq t8, t5, t9 /* add the displacement */
- lda t4, _GOT_END_
- addq t8, t4, t10 /* add the displacement */
-
- /*
- * Step 3 -- Every entry in the global offset table needs to
- * modified for the displacement before any code will work.
- */
-
-$35: ldq t1, 0(t9) /* load the value */
- addq t8, t1, t1 /* add the displacement */
- stq t1, 0(t9) /* save the new value */
- lda t9, 8(t9) /* point to next entry */
- cmpult t9, t10, t1 /* are we done? */
- bne t1, $35 /* no, do more */
-
- /*
- * Ya! Things are far enough so we can do some dynamic linking!
- */
-
- lda a0, 0(s0) /* initial sp */
- lda a1, -16(s0) /* address for exit proc */
- lda a2, -8(s0) /* address for obj_main */
- CALL(_rtld) /* v0 = _rtld(sp, &exit_proc, &obj_main); */
-
- ldq a1, -16(s0) /* our atexit function */
- ldq a2, -8(s0) /* obj_main entry */
- lda sp, 16(sp) /* readjust our stack */
- mov s0, a0 /* stack pointer */
- mov s1, a3 /* ps_strings pointer */
- mov v0, pv
- jsr ra, (v0), 0 /* (*_start)(sp, cleanup, obj); */
- ldgp gp, 0(ra)
-
- CALL(exit)
- halt
-END(_rtld_start)
-
-#define RTLD_BIND_START_PROLOGUE \
- /* at_reg already used by PLT code. */ \
- .set noat ; \
- \
- /* \
- * Allocate stack frame and preserve all registers that the \
- * caller would have normally saved themselves. \
- */ \
- lda sp, -168(sp) ; \
- stq ra, 0(sp) ; \
- stq v0, 8(sp) ; \
- stq t0, 16(sp) ; \
- stq t1, 24(sp) ; \
- stq t2, 32(sp) ; \
- stq t3, 40(sp) ; \
- stq t4, 48(sp) ; \
- stq t5, 56(sp) ; \
- stq t6, 64(sp) ; \
- stq t7, 72(sp) ; \
- stq a0, 80(sp) ; \
- stq a1, 88(sp) ; \
- stq a2, 96(sp) ; \
- stq a3, 104(sp) ; \
- stq a4, 112(sp) ; \
- stq a5, 120(sp) ; \
- stq t8, 128(sp) ; \
- stq t9, 136(sp) ; \
- stq t10, 144(sp) ; \
- stq t11, 152(sp) ; \
- stq gp, 160(sp) ; \
- \
- /* \
- * Load our global pointer. Note, can't use pv, since it is \
- * already used by the PLT code. \
- */ \
- br t0, 1f ; \
-1: LDGP(t0)
-
-#define RTLD_BIND_START_EPILOGUE \
- /* Move the destination address into position. */ \
- mov v0, pv ; \
- \
- /* Restore program registers. */ \
- ldq ra, 0(sp) ; \
- ldq v0, 8(sp) ; \
- ldq t0, 16(sp) ; \
- ldq t1, 24(sp) ; \
- ldq t2, 32(sp) ; \
- ldq t3, 40(sp) ; \
- ldq t4, 48(sp) ; \
- ldq t5, 56(sp) ; \
- ldq t6, 64(sp) ; \
- ldq t7, 72(sp) ; \
- ldq a0, 80(sp) ; \
- ldq a1, 88(sp) ; \
- ldq a2, 96(sp) ; \
- ldq a3, 104(sp) ; \
- ldq a4, 112(sp) ; \
- ldq a5, 120(sp) ; \
- ldq t8, 128(sp) ; \
- ldq t9, 136(sp) ; \
- ldq t10, 144(sp) ; \
- ldq t11, 152(sp) ; \
- ldq gp, 160(sp) ; \
- /* XXX LDGP? */ \
- \
- /* \
- * We've patched the PLT; sync the I-stream. \
- */ \
- imb ; \
- \
- /* Pop the stack frame and turn control to the destination. */ \
- lda sp, 168(sp) ; \
- jmp zero, (pv)
-
-
-/*
- * Lazy binding entry point, called via PLT.
- */
-NESTED_NOPROFILE(_rtld_bind_start, 0, 168, ra, 0, 0)
-
- RTLD_BIND_START_PROLOGUE
-
- /* Set up the arguments for _rtld_bind. */
- subq at_reg, pv, a1 /* calculate reloc offset */
- ldq a0, 8(pv) /* object structure */
- subq a1, 20, a1 /* = (at - t11 - 20) / 12 * 24 */
- addq a1, a1, a1
-
- CALL(_rtld_bind)
-
- RTLD_BIND_START_EPILOGUE
-
-END(_rtld_bind_start)
-
-/*
- * Lazy binding entry point, called via PLT. This version is for the
- * old PLT entry format.
- */
-NESTED_NOPROFILE(_rtld_bind_start_old, 0, 168, ra, 0, 0)
-
- RTLD_BIND_START_PROLOGUE
-
- /* Set up the arguments for _rtld_bind. */
- ldq a0, 8(pv) /* object structure */
- mov at_reg, a1 /* offset of reloc entry */
-
- CALL(_rtld_bind)
-
- RTLD_BIND_START_EPILOGUE
-
-END(_rtld_bind_start_old)
-
--- libexec/rtld-elf/alpha/rtld_machdep.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*-
- * Copyright (c) 1999, 2000 John D. Polstra.
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
- *
- * $FreeBSD: src/libexec/rtld-elf/alpha/rtld_machdep.h,v 1.10 2004/08/03 08:50:59 dfr Exp $
- */
-
-#ifndef RTLD_MACHDEP_H
-#define RTLD_MACHDEP_H 1
-
-#include <sys/types.h>
-#include <machine/atomic.h>
-
-/*
- * This value of CACHE_LINE_SIZE is conservative. The actual size
- * is 32 on the 21064, 21064A, 21066, 21066A, and 21164. It is 64
- * on the 21264. Compaq recommends sequestering each lock in its own
- * 128-byte block to allow for future implementations with larger
- * cache lines.
- */
-#define CACHE_LINE_SIZE 128
-
-struct Struct_Obj_Entry;
-
-/* Return the address of the .dynamic section in the dynamic linker. */
-#define rtld_dynamic(obj) (&_DYNAMIC)
-
-Elf_Addr reloc_jmpslot(Elf_Addr *, Elf_Addr,
- const struct Struct_Obj_Entry *,
- const struct Struct_Obj_Entry *,
- const Elf_Rel *);
-
-#define make_function_pointer(def, defobj) \
- ((defobj)->relocbase + (def)->st_value)
-
-#define call_initfini_pointer(obj, target) \
- (((InitFunc)(target))())
-
-/* Lazy binding entry point, called via PLT. */
-void _rtld_bind_start_old(void);
-
-#define round(size, align) \
- (((size) + (align) - 1) & ~((align) - 1))
-#define calculate_first_tls_offset(size, align) \
- round(16, align)
-#define calculate_tls_offset(prev_offset, prev_size, size, align) \
- round(prev_offset + prev_size, align)
-#define calculate_tls_end(off, size) ((off) + (size))
-
-typedef struct {
- unsigned long ti_module;
- unsigned long ti_offset;
-} tls_index;
-
-extern void *__tls_get_addr(tls_index *ti);
-
-#endif
--- libexec/rtld-elf/arm/Makefile.inc
+++ /dev/null
@@ -1 +0,0 @@
-# $FreeBSD: src/libexec/rtld-elf/arm/Makefile.inc,v 1.3 2004/06/17 17:53:16 cognet Exp $
--- libexec/rtld-elf/arm/reloc.c
+++ /dev/null
@@ -1,355 +0,0 @@
-/* $NetBSD: mdreloc.c,v 1.23 2003/07/26 15:04:38 mrg Exp $ */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/libexec/rtld-elf/arm/reloc.c,v 1.4 2005/12/18 19:43:32 kan Exp $");
-#include <sys/param.h>
-#include <sys/mman.h>
-
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include "debug.h"
-#include "rtld.h"
-
-void
-init_pltgot(Obj_Entry *obj)
-{
- if (obj->pltgot != NULL) {
- obj->pltgot[1] = (Elf_Addr) obj;
- obj->pltgot[2] = (Elf_Addr) &_rtld_bind_start;
- }
-}
-
-int
-do_copy_relocations(Obj_Entry *dstobj)
-{
- const Elf_Rel *rellim;
- const Elf_Rel *rel;
-
- assert(dstobj->mainprog); /* COPY relocations are invalid elsewhere */
-
- rellim = (const Elf_Rel *) ((caddr_t) dstobj->rel + dstobj->relsize);
- for (rel = dstobj->rel; rel < rellim; rel++) {
- if (ELF_R_TYPE(rel->r_info) == R_ARM_COPY) {
- void *dstaddr;
- const Elf_Sym *dstsym;
- const char *name;
- unsigned long hash;
- size_t size;
- const void *srcaddr;
- const Elf_Sym *srcsym;
- Obj_Entry *srcobj;
- const Ver_Entry *ve;
-
- dstaddr = (void *) (dstobj->relocbase + rel->r_offset);
- dstsym = dstobj->symtab + ELF_R_SYM(rel->r_info);
- name = dstobj->strtab + dstsym->st_name;
- hash = elf_hash(name);
- size = dstsym->st_size;
- ve = fetch_ventry(dstobj, ELF_R_SYM(rel->r_info));
-
- for (srcobj = dstobj->next; srcobj != NULL; srcobj = srcobj->next)
- if ((srcsym = symlook_obj(name, hash, srcobj, ve, 0)) != NULL)
- break;
-
- if (srcobj == NULL) {
- _rtld_error("Undefined symbol \"%s\" referenced from COPY"
- " relocation in %s", name, dstobj->path);
- return -1;
- }
-
- srcaddr = (const void *) (srcobj->relocbase + srcsym->st_value);
- memcpy(dstaddr, srcaddr, size);
- }
- }
- return 0;
-}
-
-void _rtld_bind_start(void);
-void _rtld_relocate_nonplt_self(Elf_Dyn *, Elf_Addr);
-
-int open();
-int _open();
-void
-_rtld_relocate_nonplt_self(Elf_Dyn *dynp, Elf_Addr relocbase)
-{
- const Elf_Rel *rel = 0, *rellim;
- Elf_Addr relsz = 0;
- Elf_Addr *where;
- uint32_t size;
-
- for (; dynp->d_tag != DT_NULL; dynp++) {
- switch (dynp->d_tag) {
- case DT_REL:
- rel = (const Elf_Rel *)(relocbase + dynp->d_un.d_ptr);
- break;
- case DT_RELSZ:
- relsz = dynp->d_un.d_val;
- break;
- }
- }
- rellim = (const Elf_Rel *)((caddr_t)rel + relsz);
- size = (rellim - 1)->r_offset - rel->r_offset;
- for (; rel < rellim; rel++) {
- where = (Elf_Addr *)(relocbase + rel->r_offset);
-
- *where += (Elf_Addr)relocbase;
- }
-}
-/*
- * It is possible for the compiler to emit relocations for unaligned data.
- * We handle this situation with these inlines.
- */
-#define RELOC_ALIGNED_P(x) \
- (((uintptr_t)(x) & (sizeof(void *) - 1)) == 0)
-
-static __inline Elf_Addr
-load_ptr(void *where)
-{
- Elf_Addr res;
-
- memcpy(&res, where, sizeof(res));
-
- return (res);
-}
-
-static __inline void
-store_ptr(void *where, Elf_Addr val)
-{
-
- memcpy(where, &val, sizeof(val));
-}
-
-static int
-reloc_nonplt_object(Obj_Entry *obj, const Elf_Rel *rel, SymCache *cache)
-{
- Elf_Addr *where;
- const Elf_Sym *def;
- const Obj_Entry *defobj;
- Elf_Addr tmp;
- unsigned long symnum;
-
- where = (Elf_Addr *)(obj->relocbase + rel->r_offset);
- symnum = ELF_R_SYM(rel->r_info);
-
- switch (ELF_R_TYPE(rel->r_info)) {
- case R_ARM_NONE:
- break;
-
-#if 1 /* XXX should not occur */
- case R_ARM_PC24: { /* word32 S - P + A */
- Elf32_Sword addend;
-
- /*
- * Extract addend and sign-extend if needed.
- */
- addend = *where;
- if (addend & 0x00800000)
- addend |= 0xff000000;
-
- def = find_symdef(symnum, obj, &defobj, false, cache);
- if (def == NULL)
- return -1;
- tmp = (Elf_Addr)obj->relocbase + def->st_value
- - (Elf_Addr)where + (addend << 2);
- if ((tmp & 0xfe000000) != 0xfe000000 &&
- (tmp & 0xfe000000) != 0) {
- _rtld_error(
- "%s: R_ARM_PC24 relocation @ %p to %s failed "
- "(displacement %ld (%#lx) out of range)",
- obj->path, where,
- obj->strtab + obj->symtab[symnum].st_name,
- (long) tmp, (long) tmp);
- return -1;
- }
- tmp >>= 2;
- *where = (*where & 0xff000000) | (tmp & 0x00ffffff);
- dbg("PC24 %s in %s --> %p @ %p in %s",
- obj->strtab + obj->symtab[symnum].st_name,
- obj->path, (void *)*where, where, defobj->path);
- break;
- }
-#endif
-
- case R_ARM_ABS32: /* word32 B + S + A */
- case R_ARM_GLOB_DAT: /* word32 B + S */
- def = find_symdef(symnum, obj, &defobj, false, cache);
- if (def == NULL)
- return -1;
- if (__predict_true(RELOC_ALIGNED_P(where))) {
- tmp = *where + (Elf_Addr)defobj->relocbase +
- def->st_value;
- *where = tmp;
- } else {
- tmp = load_ptr(where) +
- (Elf_Addr)defobj->relocbase +
- def->st_value;
- store_ptr(where, tmp);
- }
- dbg("ABS32/GLOB_DAT %s in %s --> %p @ %p in %s",
- obj->strtab + obj->symtab[symnum].st_name,
- obj->path, (void *)tmp, where, defobj->path);
- break;
-
- case R_ARM_RELATIVE: /* word32 B + A */
- if (__predict_true(RELOC_ALIGNED_P(where))) {
- tmp = *where + (Elf_Addr)obj->relocbase;
- *where = tmp;
- } else {
- tmp = load_ptr(where) +
- (Elf_Addr)obj->relocbase;
- store_ptr(where, tmp);
- }
- dbg("RELATIVE in %s --> %p", obj->path,
- (void *)tmp);
- break;
-
- case R_ARM_COPY:
- /*
- * These are deferred until all other relocations have
- * been done. All we do here is make sure that the
- * COPY relocation is not in a shared library. They
- * are allowed only in executable files.
- */
- if (!obj->mainprog) {
- _rtld_error(
- "%s: Unexpected R_COPY relocation in shared library",
- obj->path);
- return -1;
- }
- dbg("COPY (avoid in main)");
- break;
-
- default:
- dbg("sym = %lu, type = %lu, offset = %p, "
- "contents = %p, symbol = %s",
- symnum, (u_long)ELF_R_TYPE(rel->r_info),
- (void *)rel->r_offset, (void *)load_ptr(where),
- obj->strtab + obj->symtab[symnum].st_name);
- _rtld_error("%s: Unsupported relocation type %ld "
- "in non-PLT relocations\n",
- obj->path, (u_long) ELF_R_TYPE(rel->r_info));
- return -1;
- }
- return 0;
-}
-
-/*
- * * Process non-PLT relocations
- * */
-int
-reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld)
-{
- const Elf_Rel *rellim;
- const Elf_Rel *rel;
- SymCache *cache;
- int bytes = obj->nchains * sizeof(SymCache);
- int r = -1;
-
- /* The relocation for the dynamic loader has already been done. */
- if (obj == obj_rtld)
- return (0);
- /*
- * The dynamic loader may be called from a thread, we have
- * limited amounts of stack available so we cannot use alloca().
- */
- cache = mmap(NULL, bytes, PROT_READ|PROT_WRITE, MAP_ANON, -1, 0);
- if (cache == MAP_FAILED)
- cache = NULL;
-
- rellim = (const Elf_Rel *)((caddr_t)obj->rel + obj->relsize);
- for (rel = obj->rel; rel < rellim; rel++) {
- if (reloc_nonplt_object(obj, rel, cache) < 0)
- goto done;
- }
- r = 0;
-done:
- if (cache) {
- munmap(cache, bytes);
- }
- return (r);
-}
-
-/*
- * * Process the PLT relocations.
- * */
-int
-reloc_plt(Obj_Entry *obj)
-{
- const Elf_Rel *rellim;
- const Elf_Rel *rel;
-
- rellim = (const Elf_Rel *)((char *)obj->pltrel +
- obj->pltrelsize);
- for (rel = obj->pltrel; rel < rellim; rel++) {
- Elf_Addr *where;
-
- assert(ELF_R_TYPE(rel->r_info) == R_ARM_JUMP_SLOT);
-
- where = (Elf_Addr *)(obj->relocbase + rel->r_offset);
- *where += (Elf_Addr )obj->relocbase;
- }
-
- return (0);
-}
-
-/*
- * * LD_BIND_NOW was set - force relocation for all jump slots
- * */
-int
-reloc_jmpslots(Obj_Entry *obj)
-{
- const Obj_Entry *defobj;
- const Elf_Rel *rellim;
- const Elf_Rel *rel;
- const Elf_Sym *def;
- Elf_Addr *where;
- Elf_Addr target;
-
- rellim = (const Elf_Rel *)((char *)obj->pltrel + obj->pltrelsize);
- for (rel = obj->pltrel; rel < rellim; rel++) {
- assert(ELF_R_TYPE(rel->r_info) == R_ARM_JUMP_SLOT);
- where = (Elf_Addr *)(obj->relocbase + rel->r_offset);
- def = find_symdef(ELF_R_SYM(rel->r_info), obj, &defobj,
- true, NULL);
- if (def == NULL) {
- dbg("reloc_jmpslots: sym not found");
- return (-1);
- }
-
- target = (Elf_Addr)(defobj->relocbase + def->st_value);
- reloc_jmpslot(where, target, defobj, obj,
- (const Elf_Rel *) rel);
- }
-
- obj->jmpslots_done = true;
-
- return (0);
-}
-
-Elf_Addr
-reloc_jmpslot(Elf_Addr *where, Elf_Addr target, const Obj_Entry *defobj,
- const Obj_Entry *obj, const Elf_Rel *rel)
-{
-
- assert(ELF_R_TYPE(rel->r_info) == R_ARM_JUMP_SLOT);
-
- if (*where != target)
- *where = target;
-
- return target;
-}
-
-void
-allocate_initial_tls(Obj_Entry *objs)
-{
-
-}
-
-void *
-__tls_get_addr(tls_index* ti)
-{
- return (NULL);
-}
--- libexec/rtld-elf/arm/rtld_start.S
+++ /dev/null
@@ -1,101 +0,0 @@
-/* $NetBSD: rtld_start.S,v 1.7 2002/09/12 17:18:38 mycroft Exp $ */
-
-/*-
- * Copyright (c) 1998, 2002 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Matt Thomas and by Charles M. Hannum.
- *
- * 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. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``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 FOUNDATION OR CONTRIBUTORS
- * 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/asm.h>
-__FBSDID("$FreeBSD: src/libexec/rtld-elf/arm/rtld_start.S,v 1.3 2004/09/28 14:41:15 cognet Exp $");
-
- .text
- .align 0
- .globl .rtld_start
- .type .rtld_start,%function
-.rtld_start:
- sub sp, sp, #8 /* make room for obj_main & exit proc */
- mov r4, r0 /* save ps_strings */
- ldr sl, .L2
- ldr r5, .L2+4
- ldr r0, .L2+8
-.L1:
- add sl, pc, sl
- ldr r5, [sl, r5]
- ldr r0, [sl, r0]
-
- sub r1, sl, r5 /* relocbase */
- add r0, r1, r0 /* &_DYNAMIC */
- bl _rtld_relocate_nonplt_self
- mov r1, sp
- add r2, sp, #4
- add r0, sp, #8
- bl _rtld /* call the shared loader */
- mov r3, r0 /* save entry point */
-
- ldr r2, [sp, #0] /* r2 = cleanup */
- ldr r1, [sp, #4] /* r1 = obj_main */
- add sp, sp, #8 /* restore stack */
- mov r0, r4 /* restore ps_strings */
- mov pc, r3 /* jump to the entry point */
-.L2:
- .word _GLOBAL_OFFSET_TABLE_ - (.L1+8)
- .word _GLOBAL_OFFSET_TABLE_(GOT)
- .word _DYNAMIC(GOT)
-
- .align 0
- .globl _rtld_bind_start
- .type _rtld_bind_start,%function
-/*
- * stack[0] = RA
- * ip = &GOT[n+3]
- * lr = &GOT[2]
- */
-_rtld_bind_start:
- stmdb sp!,{r0-r4,sl,fp}
-
- sub r1, ip, lr /* r1 = 4 * (n + 1) */
- sub r1, r1, #4 /* r1 = 4 * n */
- add r1, r1, r1 /* r1 = 8 * n */
-
- ldr r0, [lr, #-4] /* get obj ptr from GOT[1] */
- mov r4, ip /* save GOT location */
-
- bl _rtld_bind /* Call the binder */
-
- str r0, [r4] /* save address in GOT */
- mov ip, r0 /* save new address */
-
- ldmia sp!,{r0-r4,sl,fp,lr} /* restore the stack */
- mov pc, ip /* jump to the new address */
-
--- libexec/rtld-elf/arm/rtld_machdep.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*-
- * Copyright (c) 1999, 2000 John D. Polstra.
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
- *
- * $FreeBSD: src/libexec/rtld-elf/arm/rtld_machdep.h,v 1.5 2005/04/07 22:04:49 cognet Exp $
- */
-
-#ifndef RTLD_MACHDEP_H
-#define RTLD_MACHDEP_H 1
-
-#include <sys/types.h>
-#include <machine/atomic.h>
-
-#define CACHE_LINE_SIZE 32
-
-struct Struct_Obj_Entry;
-
-/* Return the address of the .dynamic section in the dynamic linker. */
-#define rtld_dynamic(obj) (&_DYNAMIC)
-
-Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target,
- const struct Struct_Obj_Entry *defobj,
- const struct Struct_Obj_Entry *obj,
- const Elf_Rel *rel);
-
-#define make_function_pointer(def, defobj) \
- ((defobj)->relocbase + (def)->st_value)
-
-#define call_initfini_pointer(obj, target) \
- (((InitFunc)(target))())
-
-typedef struct {
- unsigned long ti_module;
- unsigned long ti_offset;
-} tls_index;
-
-#define round(size, align) \
- (((size) + (align) - 1) & ~((align) - 1))
-#define calculate_first_tls_offset(size, align) \
- round(size, align)
-#define calculate_tls_offset(prev_offset, prev_size, size, align) \
- round(prev_offset + prev_size, align)
-#define calculate_tls_end(off, size) ((off) + (size))
-
-
-/*
- * Lazy binding entry point, called via PLT.
- */
-void _rtld_bind_start(void);
-
-extern void *__tls_get_addr(tls_index *ti);
-
-#endif
--- libexec/rtld-elf/ia64/Makefile.inc
+++ /dev/null
@@ -1 +0,0 @@
-# $FreeBSD: src/libexec/rtld-elf/ia64/Makefile.inc,v 1.2 2007/05/16 23:19:51 marcel Exp $
--- libexec/rtld-elf/ia64/reloc.c
+++ /dev/null
@@ -1,615 +0,0 @@
-/*-
- * Copyright 1996, 1997, 1998, 1999 John D. Polstra.
- * 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.
- *
- * 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.
- *
- * $FreeBSD: src/libexec/rtld-elf/ia64/reloc.c,v 1.21 2006/09/01 06:07:26 marcel Exp $
- */
-
-/*
- * Dynamic linker for ELF.
- *
- * John Polstra <jdp at polstra.com>.
- */
-
-#include <sys/param.h>
-#include <sys/mman.h>
-#include <machine/ia64_cpu.h>
-
-#include <dlfcn.h>
-#include <err.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "debug.h"
-#include "rtld.h"
-
-extern Elf_Dyn _DYNAMIC;
-
-/*
- * Macros for loading/storing unaligned 64-bit values. These are
- * needed because relocations can point to unaligned data. This
- * occurs in the DWARF2 exception frame tables generated by the
- * compiler, for instance.
- *
- * We don't use these when relocating jump slots and GOT entries,
- * since they are guaranteed to be aligned.
- *
- * XXX dfr stub for now.
- */
-#define load64(p) (*(u_int64_t *) (p))
-#define store64(p, v) (*(u_int64_t *) (p) = (v))
-
-/* Allocate an @fptr. */
-
-#define FPTR_CHUNK_SIZE 64
-
-struct fptr_chunk {
- struct fptr fptrs[FPTR_CHUNK_SIZE];
-};
-
-static struct fptr_chunk first_chunk;
-static struct fptr_chunk *current_chunk = &first_chunk;
-static struct fptr *next_fptr = &first_chunk.fptrs[0];
-static struct fptr *last_fptr = &first_chunk.fptrs[FPTR_CHUNK_SIZE];
-
-/*
- * We use static storage initially so that we don't have to call
- * malloc during init_rtld().
- */
-static struct fptr *
-alloc_fptr(Elf_Addr target, Elf_Addr gp)
-{
- struct fptr* fptr;
-
- if (next_fptr == last_fptr) {
- current_chunk = malloc(sizeof(struct fptr_chunk));
- next_fptr = ¤t_chunk->fptrs[0];
- last_fptr = ¤t_chunk->fptrs[FPTR_CHUNK_SIZE];
- }
- fptr = next_fptr;
- next_fptr++;
- fptr->target = target;
- fptr->gp = gp;
- return fptr;
-}
-
-static struct fptr **
-alloc_fptrs(Obj_Entry *obj, bool mapped)
-{
- struct fptr **fptrs;
- size_t fbytes;
-
- fbytes = obj->nchains * sizeof(struct fptr *);
-
- /*
- * Avoid malloc, if requested. Happens when relocating
- * rtld itself on startup.
- */
- if (mapped) {
- fptrs = mmap(NULL, fbytes, PROT_READ|PROT_WRITE,
- MAP_ANON, -1, 0);
- if (fptrs == MAP_FAILED)
- fptrs = NULL;
- } else {
- fptrs = malloc(fbytes);
- if (fptrs != NULL)
- memset(fptrs, 0, fbytes);
- }
-
- /*
- * This assertion is necessary to guarantee function pointer
- * uniqueness
- */
- assert(fptrs != NULL);
-
- return (obj->priv = fptrs);
-}
-
-static void
-free_fptrs(Obj_Entry *obj, bool mapped)
-{
- struct fptr **fptrs;
- size_t fbytes;
-
- fptrs = obj->priv;
- if (fptrs == NULL)
- return;
-
- fbytes = obj->nchains * sizeof(struct fptr *);
- if (mapped)
- munmap(fptrs, fbytes);
- else
- free(fptrs);
- obj->priv = NULL;
-}
-
-/* Relocate a non-PLT object with addend. */
-static int
-reloc_non_plt_obj(Obj_Entry *obj_rtld, Obj_Entry *obj, const Elf_Rela *rela,
- SymCache *cache)
-{
- struct fptr **fptrs;
- Elf_Addr *where = (Elf_Addr *) (obj->relocbase + rela->r_offset);
-
- switch (ELF_R_TYPE(rela->r_info)) {
- case R_IA_64_REL64LSB:
- /*
- * We handle rtld's relocations in rtld_start.S
- */
- if (obj != obj_rtld)
- store64(where,
- load64(where) + (Elf_Addr) obj->relocbase);
- break;
-
- case R_IA_64_DIR64LSB: {
- const Elf_Sym *def;
- const Obj_Entry *defobj;
- Elf_Addr target;
-
- def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj,
- false, cache);
- if (def == NULL)
- return -1;
-
- target = (def->st_shndx != SHN_UNDEF)
- ? (Elf_Addr)(defobj->relocbase + def->st_value) : 0;
- store64(where, target + rela->r_addend);
- break;
- }
-
- case R_IA_64_FPTR64LSB: {
- /*
- * We have to make sure that all @fptr references to
- * the same function are identical so that code can
- * compare function pointers.
- */
- const Elf_Sym *def;
- const Obj_Entry *defobj;
- struct fptr *fptr = 0;
- Elf_Addr target, gp;
- int sym_index;
-
- def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj,
- false, cache);
- if (def == NULL)
- return -1;
-
- if (def->st_shndx != SHN_UNDEF) {
- target = (Elf_Addr)(defobj->relocbase + def->st_value);
- gp = (Elf_Addr)defobj->pltgot;
-
- /* rtld is allowed to reference itself only */
- assert(!obj->rtld || obj == defobj);
- fptrs = defobj->priv;
- if (fptrs == NULL)
- fptrs = alloc_fptrs((Obj_Entry *) defobj,
- obj->rtld);
-
- sym_index = def - defobj->symtab;
-
- /*
- * Find the @fptr, using fptrs as a helper.
- */
- if (fptrs)
- fptr = fptrs[sym_index];
- if (!fptr) {
- fptr = alloc_fptr(target, gp);
- if (fptrs)
- fptrs[sym_index] = fptr;
- }
- } else
- fptr = NULL;
-
- store64(where, (Elf_Addr)fptr);
- break;
- }
-
- case R_IA_64_IPLTLSB: {
- /*
- * Relocation typically used to populate C++ virtual function
- * tables. It creates a 128-bit function descriptor at the
- * specified memory address.
- */
- const Elf_Sym *def;
- const Obj_Entry *defobj;
- struct fptr *fptr;
- Elf_Addr target, gp;
-
- def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj,
- false, cache);
- if (def == NULL)
- return -1;
-
- if (def->st_shndx != SHN_UNDEF) {
- target = (Elf_Addr)(defobj->relocbase + def->st_value);
- gp = (Elf_Addr)defobj->pltgot;
- } else {
- target = 0;
- gp = 0;
- }
-
- fptr = (void*)where;
- store64(&fptr->target, target);
- store64(&fptr->gp, gp);
- break;
- }
-
- case R_IA_64_DTPMOD64LSB: {
- const Elf_Sym *def;
- const Obj_Entry *defobj;
-
- def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj,
- false, cache);
- if (def == NULL)
- return -1;
-
- store64(where, defobj->tlsindex);
- break;
- }
-
- case R_IA_64_DTPREL64LSB: {
- const Elf_Sym *def;
- const Obj_Entry *defobj;
-
- def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj,
- false, cache);
- if (def == NULL)
- return -1;
-
- store64(where, def->st_value + rela->r_addend);
- break;
- }
-
- case R_IA_64_TPREL64LSB: {
- const Elf_Sym *def;
- const Obj_Entry *defobj;
-
- def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj,
- false, cache);
- if (def == NULL)
- return -1;
-
- /*
- * We lazily allocate offsets for static TLS as we
- * see the first relocation that references the
- * TLS block. This allows us to support (small
- * amounts of) static TLS in dynamically loaded
- * modules. If we run out of space, we generate an
- * error.
- */
- if (!defobj->tls_done) {
- if (!allocate_tls_offset((Obj_Entry*) defobj)) {
- _rtld_error("%s: No space available for static "
- "Thread Local Storage", obj->path);
- return -1;
- }
- }
-
- store64(where, defobj->tlsoffset + def->st_value + rela->r_addend);
- break;
- }
-
- case R_IA_64_NONE:
- break;
-
- default:
- _rtld_error("%s: Unsupported relocation type %u"
- " in non-PLT relocations\n", obj->path,
- (unsigned int)ELF_R_TYPE(rela->r_info));
- return -1;
- }
-
- return(0);
-}
-
-/* Process the non-PLT relocations. */
-int
-reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld)
-{
- const Elf_Rel *rellim;
- const Elf_Rel *rel;
- const Elf_Rela *relalim;
- const Elf_Rela *rela;
- SymCache *cache;
- int bytes = obj->nchains * sizeof(SymCache);
- int r = -1;
-
- /*
- * The dynamic loader may be called from a thread, we have
- * limited amounts of stack available so we cannot use alloca().
- */
- cache = mmap(NULL, bytes, PROT_READ|PROT_WRITE, MAP_ANON, -1, 0);
- if (cache == MAP_FAILED)
- cache = NULL;
-
- /* Perform relocations without addend if there are any: */
- rellim = (const Elf_Rel *) ((caddr_t) obj->rel + obj->relsize);
- for (rel = obj->rel; obj->rel != NULL && rel < rellim; rel++) {
- Elf_Rela locrela;
-
- locrela.r_info = rel->r_info;
- locrela.r_offset = rel->r_offset;
- locrela.r_addend = 0;
- if (reloc_non_plt_obj(obj_rtld, obj, &locrela, cache))
- goto done;
- }
-
- /* Perform relocations with addend if there are any: */
- relalim = (const Elf_Rela *) ((caddr_t) obj->rela + obj->relasize);
- for (rela = obj->rela; obj->rela != NULL && rela < relalim; rela++) {
- if (reloc_non_plt_obj(obj_rtld, obj, rela, cache))
- goto done;
- }
-
- r = 0;
-done:
- if (cache)
- munmap(cache, bytes);
-
- /*
- * Release temporarily mapped fptrs if relocating
- * rtld object itself. A new table will be created
- * in make_function_pointer using malloc when needed.
- */
- if (obj->rtld && obj->priv)
- free_fptrs(obj, true);
-
- return (r);
-}
-
-/* Process the PLT relocations. */
-int
-reloc_plt(Obj_Entry *obj)
-{
- /* All PLT relocations are the same kind: Elf_Rel or Elf_Rela. */
- if (obj->pltrelsize != 0) {
- const Elf_Rel *rellim;
- const Elf_Rel *rel;
-
- rellim = (const Elf_Rel *)
- ((char *)obj->pltrel + obj->pltrelsize);
- for (rel = obj->pltrel; rel < rellim; rel++) {
- Elf_Addr *where;
-
- assert(ELF_R_TYPE(rel->r_info) == R_IA_64_IPLTLSB);
-
- /* Relocate the @fptr pointing into the PLT. */
- where = (Elf_Addr *)(obj->relocbase + rel->r_offset);
- *where += (Elf_Addr)obj->relocbase;
- }
- } else {
- const Elf_Rela *relalim;
- const Elf_Rela *rela;
-
- relalim = (const Elf_Rela *)
- ((char *)obj->pltrela + obj->pltrelasize);
- for (rela = obj->pltrela; rela < relalim; rela++) {
- Elf_Addr *where;
-
- assert(ELF_R_TYPE(rela->r_info) == R_IA_64_IPLTLSB);
-
- /* Relocate the @fptr pointing into the PLT. */
- where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
- *where += (Elf_Addr)obj->relocbase;
- }
- }
- return 0;
-}
-
-/* Relocate the jump slots in an object. */
-int
-reloc_jmpslots(Obj_Entry *obj)
-{
- if (obj->jmpslots_done)
- return 0;
- /* All PLT relocations are the same kind: Elf_Rel or Elf_Rela. */
- if (obj->pltrelsize != 0) {
- const Elf_Rel *rellim;
- const Elf_Rel *rel;
-
- rellim = (const Elf_Rel *)
- ((char *)obj->pltrel + obj->pltrelsize);
- for (rel = obj->pltrel; rel < rellim; rel++) {
- Elf_Addr *where;
- const Elf_Sym *def;
- const Obj_Entry *defobj;
-
- assert(ELF_R_TYPE(rel->r_info) == R_IA_64_IPLTLSB);
- where = (Elf_Addr *)(obj->relocbase + rel->r_offset);
- def = find_symdef(ELF_R_SYM(rel->r_info), obj,
- &defobj, true, NULL);
- if (def == NULL)
- return -1;
- reloc_jmpslot(where,
- (Elf_Addr)(defobj->relocbase
- + def->st_value),
- defobj, obj, rel);
- }
- } else {
- const Elf_Rela *relalim;
- const Elf_Rela *rela;
-
- relalim = (const Elf_Rela *)
- ((char *)obj->pltrela + obj->pltrelasize);
- for (rela = obj->pltrela; rela < relalim; rela++) {
- Elf_Addr *where;
- const Elf_Sym *def;
- const Obj_Entry *defobj;
-
- where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
- def = find_symdef(ELF_R_SYM(rela->r_info), obj,
- &defobj, true, NULL);
- if (def == NULL)
- return -1;
- reloc_jmpslot(where,
- (Elf_Addr)(defobj->relocbase
- + def->st_value),
- defobj, obj, (Elf_Rel *)rela);
- }
- }
- obj->jmpslots_done = true;
- return 0;
-}
-
-/* Fixup the jump slot at "where" to transfer control to "target". */
-Elf_Addr
-reloc_jmpslot(Elf_Addr *where, Elf_Addr target, const Obj_Entry *obj,
- const Obj_Entry *refobj, const Elf_Rel *rel)
-{
- Elf_Addr stubaddr;
-
- dbg(" reloc_jmpslot: where=%p, target=%p, gp=%p",
- (void *)where, (void *)target, (void *)obj->pltgot);
- stubaddr = *where;
- if (stubaddr != target) {
-
- /*
- * Point this @fptr directly at the target. Update the
- * gp value first so that we don't break another cpu
- * which is currently executing the PLT entry.
- */
- where[1] = (Elf_Addr) obj->pltgot;
- ia64_mf();
- where[0] = target;
- ia64_mf();
- }
-
- /*
- * The caller needs an @fptr for the adjusted entry. The PLT
- * entry serves this purpose nicely.
- */
- return (Elf_Addr) where;
-}
-
-/*
- * XXX ia64 doesn't seem to have copy relocations.
- *
- * Returns 0 on success, -1 on failure.
- */
-int
-do_copy_relocations(Obj_Entry *dstobj)
-{
-
- return 0;
-}
-
-/*
- * Return the @fptr representing a given function symbol.
- */
-void *
-make_function_pointer(const Elf_Sym *sym, const Obj_Entry *obj)
-{
- struct fptr **fptrs = obj->priv;
- int index = sym - obj->symtab;
-
- if (!fptrs) {
- /*
- * This should only happen for something like
- * dlsym("dlopen"). Actually, I'm not sure it can ever
- * happen.
- */
- fptrs = alloc_fptrs((Obj_Entry *) obj, false);
- }
- if (!fptrs[index]) {
- Elf_Addr target, gp;
- target = (Elf_Addr) (obj->relocbase + sym->st_value);
- gp = (Elf_Addr) obj->pltgot;
- fptrs[index] = alloc_fptr(target, gp);
- }
- return fptrs[index];
-}
-
-void
-call_initfini_pointer(const Obj_Entry *obj, Elf_Addr target)
-{
- struct fptr fptr;
-
- fptr.gp = (Elf_Addr) obj->pltgot;
- fptr.target = target;
- dbg(" initfini: target=%p, gp=%p",
- (void *) fptr.target, (void *) fptr.gp);
- ((InitFunc) &fptr)();
-}
-
-/* Initialize the special PLT entries. */
-void
-init_pltgot(Obj_Entry *obj)
-{
- const Elf_Dyn *dynp;
- Elf_Addr *pltres = 0;
-
- /*
- * When there are no PLT relocations, the DT_IA_64_PLT_RESERVE entry
- * is bogus. Do not setup the BOR pointers in that case. An example
- * of where this happens is /usr/lib/libxpg4.so.3.
- */
- if (obj->pltrelasize == 0 && obj->pltrelsize == 0)
- return;
-
- /*
- * Find the PLT RESERVE section.
- */
- for (dynp = obj->dynamic; dynp->d_tag != DT_NULL; dynp++) {
- if (dynp->d_tag == DT_IA_64_PLT_RESERVE)
- pltres = (u_int64_t *)
- (obj->relocbase + dynp->d_un.d_ptr);
- }
- if (!pltres)
- errx(1, "Can't find DT_IA_64_PLT_RESERVE entry");
-
- /*
- * The PLT RESERVE section is used to get values to pass to
- * _rtld_bind when lazy binding.
- */
- pltres[0] = (Elf_Addr) obj;
- pltres[1] = FPTR_TARGET(_rtld_bind_start);
- pltres[2] = FPTR_GP(_rtld_bind_start);
-}
-
-void
-allocate_initial_tls(Obj_Entry *list)
-{
- void *tpval;
-
- /*
- * Fix the size of the static TLS block by using the maximum
- * offset allocated so far and adding a bit for dynamic modules to
- * use.
- */
- tls_static_space = tls_last_offset + tls_last_size + RTLD_STATIC_TLS_EXTRA;
-
- tpval = allocate_tls(list, NULL, TLS_TCB_SIZE, 16);
- __asm __volatile("mov r13 = %0" :: "r"(tpval));
-}
-
-void *__tls_get_addr(unsigned long module, unsigned long offset)
-{
- register Elf_Addr** tp __asm__("r13");
-
- return tls_get_addr_common(tp, module, offset);
-}
--- libexec/rtld-elf/ia64/rtld_start.S
+++ /dev/null
@@ -1,252 +0,0 @@
-/* $FreeBSD: src/libexec/rtld-elf/ia64/rtld_start.S,v 1.4 2006/01/28 17:56:16 marcel Exp $ */
-/* From: NetBSD: rtld_start.S,v 1.1 1996/12/16 20:38:09 cgd Exp */
-
-/*
- * Copyright 1996 Matt Thomas <matt at 3am-software.com>
- * Copyright 2000 John D. Polstra
- * 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/asm.h>
-#include <sys/syscall.h>
-
-ENTRY(_rtld_start, 0)
- alloc r2=ar.pfs,3,0,3,0
- ;;
-1: mov r14=ip // calculate gp
- addl r3=@gprel(1b),r0
- ;;
- sub gp=r14,r3
- ;;
- .section .sdata
-2: data4 @ltv(1b) // unrelocated address of 1b
- .align 8
- .previous
- add r15=@gprel(2b),gp
- ;;
- ld8 r15=[r15]
- ;;
- sub out0=r14,r15 // out0 is image base address
- br.call.sptk.many rp=_rtld_reloc // fixup image
-
- add sp=-16,sp // 16 bytes for us, 16 for _rtld
- ;;
- mov out0=in0
- add out1=16,sp // address for exit proc
- add out2=24,sp // address for obj_main
-
- br.call.sptk.many rp=_rtld // r8=_rtld(sp, &exit_proc, &obj_main)
-
- add r16=16,sp // address for exit proc
- ;;
- ld8 r15=[r16] // read exit proc
- add sp=16,sp // readjust stack
- mov b7=r8 // address of real _start
- ;;
- alloc r2=ar.pfs,0,0,3,0 // dump register frame
- mov out2=r15
- ;;
- br.call.sptk.many rp=b7 // transfer to main program
- br.call.sptk.many rp=exit // die
-END(_rtld_start)
-
-/*
- * _rtld_bind_start: lookup a lazy binding and transfer to real target
- *
- * Arguments:
- * r1 gp value for rtld
- * r15 Index in plt
- * r16 Obj_Entry of caller
- * in0-in7 Arguments for target procedure
- * rp Return address back to caller
- */
-ENTRY(_rtld_bind_start, 0)
-{ .mii
- alloc loc0=ar.pfs,8,6,3,0 // space to save r8-r11
- add r17=16-8*16,sp // leave 16 bytes for _rtld_bind
- add r18=32-8*16,sp
- ;;
-} { .mii
- mov loc2=r8 // structure return address
- add sp=-8*16,sp // space to save f8-f15
- mov loc1=rp
- ;;
-} { .mii
- stf.spill [r17]=f8,32 // save float arguments
- mov loc3=r9 // language specific
- mov loc4=r10 // language specific
-} { .mii
- stf.spill [r18]=f9,32
- mov loc5=r11 // language specific
- shl out1=r15,4 // 16 * index
- ;;
-} { .mmi
- stf.spill [r17]=f10,32
- stf.spill [r18]=f11,32
- mov out0=r16 // Obj_Entry for caller
- ;;
-} { .mmi
- stf.spill [r17]=f12,32
- stf.spill [r18]=f13,32
- shladd out1=r15,3,out1 // rela offset = 24 * index
- ;;
-} { .mmb
- stf.spill [r17]=f14,32
- stf.spill [r18]=f15,32
- br.call.sptk.many rp=_rtld_bind
-} { .mii
- ld8 r14=[r8],8 // target address
- add r17=16,sp
- add r18=32,sp
- ;;
-} { .mii
- ld8 r1=[r8] // target gp
- mov ar.pfs=loc0 // clean up
- mov rp=loc1
-} { .mmi
- ldf.fill f8=[r17],32 // restore float arguments
- ldf.fill f9=[r18],32
- mov r8=loc2 // restore structure pointer
- ;;
-} { .mmi
- ldf.fill f10=[r17],32
- ldf.fill f11=[r18],32
- mov r9=loc3
- ;;
-} { .mmi
- ldf.fill f12=[r17],32
- ldf.fill f13=[r18],32
- mov r10=loc4
- ;;
-} { .mmi
- ldf.fill f14=[r17],32
- ldf.fill f15=[r18],32
- mov r11=loc5
- ;;
-} { .mii
- nop.m 0
- mov b7=r14
- add sp=8*16,sp
- ;;
-} { .mib
- alloc r14=ar.pfs,0,0,8,0 // drop our register frame
- nop.i 0
- br.sptk.many b7 // jump to target
-}
-END(_rtld_bind_start)
-
-#define DT_NULL 0 /* Terminating entry. */
-#define DT_RELA 7 /* Address of ElfNN_Rela relocations. */
-#define DT_RELASZ 8 /* Total size of ElfNN_Rela relocations. */
-#define DT_RELAENT 9 /* Size of each ElfNN_Rela relocation entry. */
-
-#define R_IA_64_NONE 0 /* None */
-#define R_IA_64_DIR64LSB 0x27 /* word64 LSB S + A */
-#define R_IA_64_REL64LSB 0x6f /* word64 LSB BD + A */
-
-/*
- * _rtld_reloc: relocate the rtld image, apart from @fptrs.
- *
- * Assumes that rtld was linked at zero and that we only need to
- * handle REL64LSB and DIR64LSB relocations.
- *
- * Arguments:
- * r1 gp value for rtld
- * in0 rtld base address
- */
-STATIC_ENTRY(_rtld_reloc, 1)
- alloc loc0=ar.pfs,1,2,0,0
- mov loc1=rp
- ;;
- movl r15=@gprel(_DYNAMIC) // find _DYNAMIC etc.
- ;;
- add r15=r15,gp // relocate _DYNAMIC etc.
- ;;
-1: ld8 r16=[r15],8 // read r15->d_tag
- ;;
- ld8 r17=[r15],8 // and r15->d_val
- ;;
- cmp.eq p6,p0=DT_NULL,r16 // done?
-(p6) br.cond.dpnt.few 2f
- ;;
- cmp.eq p6,p0=DT_RELA,r16
- ;;
-(p6) add r18=r17,in0 // found rela section
- ;;
- cmp.eq p6,p0=DT_RELASZ,r16
- ;;
-(p6) mov r19=r17 // found rela size
- ;;
- cmp.eq p6,p0=DT_RELAENT,r16
- ;;
-(p6) mov r22=r17 // found rela entry size
- ;;
- br.sptk.few 1b
-
-2:
- ld8 r15=[r18],8 // read r_offset
- ;;
- ld8 r16=[r18],8 // read r_info
- add r15=r15,in0 // relocate r_offset
- ;;
- ld8 r17=[r18],8 // read r_addend
- sub r19=r19,r22 // update relasz
-
- extr.u r23=r16,0,32 // ELF64_R_TYPE(r16)
- ;;
- cmp.eq p6,p0=R_IA_64_NONE,r23
-(p6) br.cond.dpnt.few 3f
- ;;
- cmp.eq p6,p0=R_IA_64_DIR64LSB,r23
- ;;
-(p6) br.cond.dptk.few 4f
- ;;
- cmp.eq p6,p0=R_IA_64_REL64LSB,r23
- ;;
-(p6) br.cond.dptk.few 4f
- ;;
-
-3: cmp.ltu p6,p0=0,r19 // more?
-(p6) br.cond.dptk.few 2b // loop
-
- mov r8=0 // success return value
- ;;
- br.cond.sptk.few 9f // done
-
-4:
- ld8 r16=[r15] // read value
- ;;
- add r16=r16,in0 // relocate it
- ;;
- st8 [r15]=r16 // and store it back
- br.cond.sptk.few 3b
-
-9:
- mov ar.pfs=loc0
- mov rp=loc1
- ;;
- br.ret.sptk.few rp
-
-END(_rtld_reloc)
--- libexec/rtld-elf/ia64/rtld_machdep.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*-
- * Copyright (c) 1999, 2000 John D. Polstra.
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
- *
- * $FreeBSD: src/libexec/rtld-elf/ia64/rtld_machdep.h,v 1.6 2006/08/31 19:42:39 marcel Exp $
- */
-
-#ifndef RTLD_MACHDEP_H
-#define RTLD_MACHDEP_H 1
-
-#include <sys/types.h>
-#include <machine/atomic.h>
-
-#define CACHE_LINE_SIZE 128
-
-/*
- * Macros for cracking ia64 function pointers.
- */
-struct fptr {
- Elf_Addr target;
- Elf_Addr gp;
-};
-
-#define FPTR_TARGET(f) (((struct fptr *) (f))->target)
-#define FPTR_GP(f) (((struct fptr *) (f))->gp)
-
-/* Return the address of the .dynamic section in the dynamic linker. */
-#define rtld_dynamic(obj) (&_DYNAMIC)
-
-struct Struct_Obj_Entry;
-
-Elf_Addr reloc_jmpslot(Elf_Addr *, Elf_Addr, const struct Struct_Obj_Entry *,
- const struct Struct_Obj_Entry *, const Elf_Rel *);
-void *make_function_pointer(const Elf_Sym *, const struct Struct_Obj_Entry *);
-void call_initfini_pointer(const struct Struct_Obj_Entry *, Elf_Addr);
-
-#define TLS_TCB_SIZE 16
-
-#define round(size, align) \
- (((size) + (align) - 1) & ~((align) - 1))
-#define calculate_first_tls_offset(size, align) \
- round(TLS_TCB_SIZE, align)
-#define calculate_tls_offset(prev_offset, prev_size, size, align) \
- round(prev_offset + prev_size, align)
-#define calculate_tls_end(off, size) ((off) + (size))
-
-extern void *__tls_get_addr(unsigned long module, unsigned long offset);
-
-#endif
--- libexec/rtld-elf/powerpc/Makefile.inc
+++ /dev/null
@@ -1 +0,0 @@
-# $FreeBSD: src/libexec/rtld-elf/powerpc/Makefile.inc,v 1.1 2002/12/04 07:32:20 grehan Exp $
--- libexec/rtld-elf/powerpc/reloc.c
+++ /dev/null
@@ -1,585 +0,0 @@
-/* $NetBSD: ppc_reloc.c,v 1.10 2001/09/10 06:09:41 mycroft Exp $ */
-
-/*-
- * Copyright (C) 1998 Tsubai Masanari
- * 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.
- *
- * $FreeBSD: src/libexec/rtld-elf/powerpc/reloc.c,v 1.8 2007/07/15 22:52:15 marcel Exp $
- */
-
-#include <sys/param.h>
-#include <sys/mman.h>
-
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <machine/cpu.h>
-
-#include "debug.h"
-#include "rtld.h"
-
-#define _ppc_ha(x) ((((u_int32_t)(x) & 0x8000) ? \
- ((u_int32_t)(x) + 0x10000) : (u_int32_t)(x)) >> 16)
-#define _ppc_la(x) ((u_int32_t)(x) & 0xffff)
-
-/*
- * Process the R_PPC_COPY relocations
- */
-int
-do_copy_relocations(Obj_Entry *dstobj)
-{
- const Elf_Rela *relalim;
- const Elf_Rela *rela;
-
- /*
- * COPY relocs are invalid outside of the main program
- */
- assert(dstobj->mainprog);
-
- relalim = (const Elf_Rela *) ((caddr_t) dstobj->rela +
- dstobj->relasize);
- for (rela = dstobj->rela; rela < relalim; rela++) {
- void *dstaddr;
- const Elf_Sym *dstsym;
- const char *name;
- unsigned long hash;
- size_t size;
- const void *srcaddr;
- const Elf_Sym *srcsym = NULL;
- Obj_Entry *srcobj;
- const Ver_Entry *ve;
-
- if (ELF_R_TYPE(rela->r_info) != R_PPC_COPY) {
- continue;
- }
-
- dstaddr = (void *) (dstobj->relocbase + rela->r_offset);
- dstsym = dstobj->symtab + ELF_R_SYM(rela->r_info);
- name = dstobj->strtab + dstsym->st_name;
- hash = elf_hash(name);
- size = dstsym->st_size;
- ve = fetch_ventry(dstobj, ELF_R_SYM(rela->r_info));
-
- for (srcobj = dstobj->next; srcobj != NULL;
- srcobj = srcobj->next) {
- if ((srcsym = symlook_obj(name, hash, srcobj, ve, 0))
- != NULL) {
- break;
- }
- }
-
- if (srcobj == NULL) {
- _rtld_error("Undefined symbol \"%s\" "
- " referenced from COPY"
- " relocation in %s", name, dstobj->path);
- return (-1);
- }
-
- srcaddr = (const void *) (srcobj->relocbase+srcsym->st_value);
- memcpy(dstaddr, srcaddr, size);
- dbg("copy_reloc: src=%p,dst=%p,size=%d\n",srcaddr,dstaddr,size);
- }
-
- return (0);
-}
-
-
-/*
- * Perform early relocation of the run-time linker image
- */
-void
-reloc_non_plt_self(Elf_Dyn *dynp, Elf_Addr relocbase)
-{
- const Elf_Rela *rela = 0, *relalim;
- Elf_Addr relasz = 0;
- Elf_Addr *where;
-
- /*
- * Extract the rela/relasz values from the dynamic section
- */
- for (; dynp->d_tag != DT_NULL; dynp++) {
- switch (dynp->d_tag) {
- case DT_RELA:
- rela = (const Elf_Rela *)(relocbase+dynp->d_un.d_ptr);
- break;
- case DT_RELASZ:
- relasz = dynp->d_un.d_val;
- break;
- }
- }
-
- /*
- * Relocate these values
- */
- relalim = (const Elf_Rela *)((caddr_t)rela + relasz);
- for (; rela < relalim; rela++) {
- where = (Elf_Addr *)(relocbase + rela->r_offset);
- *where = (Elf_Addr)(relocbase + rela->r_addend);
- }
-}
-
-
-/*
- * Relocate a non-PLT object with addend.
- */
-static int
-reloc_nonplt_object(Obj_Entry *obj_rtld, Obj_Entry *obj, const Elf_Rela *rela,
- SymCache *cache)
-{
- Elf_Addr *where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
- const Elf_Sym *def;
- const Obj_Entry *defobj;
- Elf_Addr tmp;
-
- switch (ELF_R_TYPE(rela->r_info)) {
-
- case R_PPC_NONE:
- break;
-
- case R_PPC_ADDR32: /* word32 S + A */
- case R_PPC_GLOB_DAT: /* word32 S + A */
- def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj,
- false, cache);
- if (def == NULL) {
- return (-1);
- }
-
- tmp = (Elf_Addr)(defobj->relocbase + def->st_value +
- rela->r_addend);
-
- /* Don't issue write if unnecessary; avoid COW page fault */
- if (*where != tmp) {
- *where = tmp;
- }
- break;
-
- case R_PPC_RELATIVE: /* word32 B + A */
- tmp = (Elf_Addr)(obj->relocbase + rela->r_addend);
-
- /* As above, don't issue write unnecessarily */
- if (*where != tmp) {
- *where = tmp;
- }
- break;
-
- case R_PPC_COPY:
- /*
- * These are deferred until all other relocations
- * have been done. All we do here is make sure
- * that the COPY relocation is not in a shared
- * library. They are allowed only in executable
- * files.
- */
- if (!obj->mainprog) {
- _rtld_error("%s: Unexpected R_COPY "
- " relocation in shared library",
- obj->path);
- return (-1);
- }
- break;
-
- case R_PPC_JMP_SLOT:
- /*
- * These will be handled by the plt/jmpslot routines
- */
- break;
-
- case R_PPC_DTPMOD32:
- def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj,
- false, cache);
-
- if (def == NULL)
- return (-1);
-
- *where = (Elf_Addr) defobj->tlsindex;
-
- break;
-
- case R_PPC_TPREL32:
- def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj,
- false, cache);
-
- if (def == NULL)
- return (-1);
-
- /*
- * We lazily allocate offsets for static TLS as we
- * see the first relocation that references the
- * TLS block. This allows us to support (small
- * amounts of) static TLS in dynamically loaded
- * modules. If we run out of space, we generate an
- * error.
- */
- if (!defobj->tls_done) {
- if (!allocate_tls_offset((Obj_Entry*) defobj)) {
- _rtld_error("%s: No space available for static "
- "Thread Local Storage", obj->path);
- return (-1);
- }
- }
-
- *(Elf_Addr **)where = *where * sizeof(Elf_Addr)
- + (Elf_Addr *)(def->st_value + rela->r_addend
- + defobj->tlsoffset - TLS_TP_OFFSET);
-
- break;
-
- case R_PPC_DTPREL32:
- def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj,
- false, cache);
-
- if (def == NULL)
- return (-1);
-
- *where += (Elf_Addr)(def->st_value + rela->r_addend
- - TLS_DTV_OFFSET);
-
- break;
-
- default:
- _rtld_error("%s: Unsupported relocation type %d"
- " in non-PLT relocations\n", obj->path,
- ELF_R_TYPE(rela->r_info));
- return (-1);
- }
- return (0);
-}
-
-
-/*
- * Process non-PLT relocations
- */
-int
-reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld)
-{
- const Elf_Rela *relalim;
- const Elf_Rela *rela;
- SymCache *cache;
- int bytes = obj->nchains * sizeof(SymCache);
- int r = -1;
-
- /*
- * The dynamic loader may be called from a thread, we have
- * limited amounts of stack available so we cannot use alloca().
- */
- if (obj != obj_rtld) {
- cache = mmap(NULL, bytes, PROT_READ|PROT_WRITE, MAP_ANON,
- -1, 0);
- if (cache == MAP_FAILED)
- cache = NULL;
- } else
- cache = NULL;
-
- /*
- * From the SVR4 PPC ABI:
- * "The PowerPC family uses only the Elf32_Rela relocation
- * entries with explicit addends."
- */
- relalim = (const Elf_Rela *)((caddr_t)obj->rela + obj->relasize);
- for (rela = obj->rela; rela < relalim; rela++) {
- if (reloc_nonplt_object(obj_rtld, obj, rela, cache) < 0)
- goto done;
- }
- r = 0;
-done:
- if (cache) {
- munmap(cache, bytes);
- }
- return (r);
-}
-
-
-/*
- * Initialise a PLT slot to the resolving trampoline
- */
-static int
-reloc_plt_object(Obj_Entry *obj, const Elf_Rela *rela)
-{
- Elf_Word *where = (Elf_Word *)(obj->relocbase + rela->r_offset);
- Elf_Addr *pltresolve;
- Elf_Addr distance;
- int reloff;
-
- reloff = rela - obj->pltrela;
-
- if ((reloff < 0) || (reloff >= 0x8000)) {
- return (-1);
- }
-
- pltresolve = obj->pltgot + 8;
-
- distance = (Elf_Addr)pltresolve - (Elf_Addr)(where + 1);
-
- dbg(" reloc_plt_object: where=%p,pltres=%p,reloff=%x,distance=%x",
- (void *)where, (void *)pltresolve, reloff, distance);
-
- /* li r11,reloff */
- /* b pltresolve */
- where[0] = 0x39600000 | reloff;
- where[1] = 0x48000000 | (distance & 0x03fffffc);
-
- /*
- * The icache will be sync'd in init_pltgot, which is called
- * after all the slots have been updated
- */
-
- return (0);
-}
-
-
-/*
- * Process the PLT relocations.
- */
-int
-reloc_plt(Obj_Entry *obj)
-{
- const Elf_Rela *relalim;
- const Elf_Rela *rela;
-
- if (obj->pltrelasize != 0) {
-
- relalim = (const Elf_Rela *)((char *)obj->pltrela +
- obj->pltrelasize);
- for (rela = obj->pltrela; rela < relalim; rela++) {
- assert(ELF_R_TYPE(rela->r_info) == R_PPC_JMP_SLOT);
-
- if (reloc_plt_object(obj, rela) < 0) {
- return (-1);
- }
- }
- }
-
- return (0);
-}
-
-
-/*
- * LD_BIND_NOW was set - force relocation for all jump slots
- */
-int
-reloc_jmpslots(Obj_Entry *obj)
-{
- const Obj_Entry *defobj;
- const Elf_Rela *relalim;
- const Elf_Rela *rela;
- const Elf_Sym *def;
- Elf_Addr *where;
- Elf_Addr target;
-
- relalim = (const Elf_Rela *)((char *)obj->pltrela + obj->pltrelasize);
- for (rela = obj->pltrela; rela < relalim; rela++) {
- assert(ELF_R_TYPE(rela->r_info) == R_PPC_JMP_SLOT);
- where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
- def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj,
- true, NULL);
- if (def == NULL) {
- dbg("reloc_jmpslots: sym not found");
- return (-1);
- }
-
- target = (Elf_Addr)(defobj->relocbase + def->st_value);
-
-#if 0
- /* PG XXX */
- dbg("\"%s\" in \"%s\" --> %p in \"%s\"",
- defobj->strtab + def->st_name, basename(obj->path),
- (void *)target, basename(defobj->path));
-#endif
-
- reloc_jmpslot(where, target, defobj, obj,
- (const Elf_Rel *) rela);
- }
-
- obj->jmpslots_done = true;
-
- return (0);
-}
-
-
-/*
- * Update the value of a PLT jump slot. Branch directly to the target if
- * it is within +/- 32Mb, otherwise go indirectly via the pltcall
- * trampoline call and jump table.
- */
-Elf_Addr
-reloc_jmpslot(Elf_Addr *wherep, Elf_Addr target, const Obj_Entry *defobj,
- const Obj_Entry *obj, const Elf_Rel *rel)
-{
- Elf_Addr offset;
- const Elf_Rela *rela = (const Elf_Rela *) rel;
-
- dbg(" reloc_jmpslot: where=%p, target=%p",
- (void *)wherep, (void *)target);
-
- /*
- * At the PLT entry pointed at by `wherep', construct
- * a direct transfer to the now fully resolved function
- * address.
- */
- offset = target - (Elf_Addr)wherep;
-
- if (abs(offset) < 32*1024*1024) { /* inside 32MB? */
- /* b value # branch directly */
- *wherep = 0x48000000 | (offset & 0x03fffffc);
- __syncicache(wherep, 4);
- } else {
- Elf_Addr *pltcall, *jmptab;
- int distance;
- int N = obj->pltrelasize / sizeof(Elf_Rela);
- int reloff = rela - obj->pltrela;
-
- if ((reloff < 0) || (reloff >= 0x8000)) {
- return (-1);
- }
-
- pltcall = obj->pltgot;
-
- dbg(" reloc_jmpslot: indir, reloff=%d, N=%d\n",
- reloff, N);
-
- jmptab = obj->pltgot + 18 + N * 2;
- jmptab[reloff] = target;
-
- distance = (Elf_Addr)pltcall - (Elf_Addr)(wherep + 1);
-
- /* li r11,reloff */
- /* b pltcall # use indirect pltcall routine */
- wherep[0] = 0x39600000 | reloff;
- wherep[1] = 0x48000000 | (distance & 0x03fffffc);
- __syncicache(wherep, 8);
- }
-
- return (target);
-}
-
-
-/*
- * Setup the plt glue routines.
- */
-#define PLTCALL_SIZE 20
-#define PLTRESOLVE_SIZE 24
-
-void
-init_pltgot(Obj_Entry *obj)
-{
- Elf_Word *pltcall, *pltresolve;
- Elf_Word *jmptab;
- int N = obj->pltrelasize / sizeof(Elf_Rela);
-
- pltcall = obj->pltgot;
-
- if (pltcall == NULL) {
- return;
- }
-
- /*
- * From the SVR4 PPC ABI:
- *
- * 'The first 18 words (72 bytes) of the PLT are reserved for
- * use by the dynamic linker.
- * ...
- * 'If the executable or shared object requires N procedure
- * linkage table entries, the link editor shall reserve 3*N
- * words (12*N bytes) following the 18 reserved words. The
- * first 2*N of these words are the procedure linkage table
- * entries themselves. The static linker directs calls to bytes
- * (72 + (i-1)*8), for i between 1 and N inclusive. The remaining
- * N words (4*N bytes) are reserved for use by the dynamic linker.'
- */
-
- /*
- * Copy the absolute-call assembler stub into the first part of
- * the reserved PLT area.
- */
- memcpy(pltcall, _rtld_powerpc_pltcall, PLTCALL_SIZE);
-
- /*
- * Determine the address of the jumptable, which is the dyn-linker
- * reserved area after the call cells. Write the absolute address
- * of the jumptable into the absolute-call assembler code so it
- * can determine this address.
- */
- jmptab = pltcall + 18 + N * 2;
- pltcall[1] |= _ppc_ha(jmptab); /* addis 11,11,jmptab at ha */
- pltcall[2] |= _ppc_la(jmptab); /* lwz 11,jmptab at l(11) */
-
- /*
- * Skip down 32 bytes into the initial reserved area and copy
- * in the standard resolving assembler call. Into this assembler,
- * insert the absolute address of the _rtld_bind_start routine
- * and the address of the relocation object.
- */
- pltresolve = obj->pltgot + 8;
-
- memcpy(pltresolve, _rtld_powerpc_pltresolve, PLTRESOLVE_SIZE);
- pltresolve[0] |= _ppc_ha(_rtld_bind_start);
- pltresolve[1] |= _ppc_la(_rtld_bind_start);
- pltresolve[3] |= _ppc_ha(obj);
- pltresolve[4] |= _ppc_la(obj);
-
- /*
- * Sync the icache for the byte range represented by the
- * trampoline routines and call slots.
- */
- __syncicache(pltcall, 72 + N * 8);
-}
-
-void
-allocate_initial_tls(Obj_Entry *list)
-{
- register Elf_Addr **tp __asm__("r2");
- Elf_Addr **_tp;
-
- /*
- * Fix the size of the static TLS block by using the maximum
- * offset allocated so far and adding a bit for dynamic modules to
- * use.
- */
-
- tls_static_space = tls_last_offset + tls_last_size + RTLD_STATIC_TLS_EXTRA;
-
- _tp = (Elf_Addr **) ((char *) allocate_tls(list, NULL, TLS_TCB_SIZE, 8)
- + TLS_TP_OFFSET + TLS_TCB_SIZE);
-
- /*
- * XXX gcc seems to ignore 'tp = _tp;'
- */
-
- __asm __volatile("mr %0,%1" : "=r"(tp) : "r"(_tp));
-}
-
-void*
-__tls_get_addr(tls_index* ti)
-{
- register Elf_Addr **tp __asm__("r2");
- char *p;
-
- p = tls_get_addr_common((Elf_Addr**)((Elf_Addr)tp - TLS_TP_OFFSET
- - TLS_TCB_SIZE), ti->ti_module, ti->ti_offset);
-
- return (p + TLS_DTV_OFFSET);
-}
--- libexec/rtld-elf/powerpc/rtld_start.S
+++ /dev/null
@@ -1,194 +0,0 @@
-/* $NetBSD: rtld_start.S,v 1.4 2001/09/26 04:06:43 mycroft Exp $ */
-
-/*-
- * Copyright (C) 1998 Tsubai Masanari
- * 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.
- *
- * $FreeBSD: src/libexec/rtld-elf/powerpc/rtld_start.S,v 1.2 2003/05/29 22:58:26 kan Exp $
- */
-
-#include <machine/asm.h>
-
-.extern _GLOBAL_OFFSET_TABLE_
-.extern _DYNAMIC
-
-_ENTRY(.rtld_start)
- stwu %r1,-48(%r1) /* 16-byte aligned stack for reg saves +
- exit_proc & obj _rtld args +
- backchain & lrsave stack frame */
- stw %r3,16(%r1) /* argc */
- stw %r4,20(%r1) /* argv */
- stw %r5,24(%r1) /* envp */
-/* stw %r6,28(%r1) *//* obj (always 0) */
-/* stw %r7,32(%r1) *//* cleanup (always 0) */
- stw %r8,36(%r1) /* ps_strings */
-
- /*
- * Perform initial relocation of ld-elf.so. Not as easy as it
- * sounds.
- * - perform small forward branch to put PC into link reg
- * - use link-time constants to determine offset to the
- * _DYNAMIC section and the GOT. Add these to the PC to
- * convert to absolute addresses.
- * - sync icache to allow execution of the SVR4 ABI-specified
- * blrl instruction preceding the GOT
- * - Use this instruction to determine the GOT absolute address
- * - read GOT[0], which is the SVR4 ABI-specified link-time
- * value of _DYNAMIC. Subtract this value from the absolute
- * value to determine the load address
- * - call reloc_non_plt_self() to fix up ld-elf.so's relocations
- */
- bl 1f
- .long _DYNAMIC-.
- .long _GLOBAL_OFFSET_TABLE_-. /* branch lr + 4 */
-1:
- mflr %r3 /* PC value at .long */
- lwz %r4,4(%r3)
- add %r4,%r4,%r3 /* &_GLOBAL_OFFSET_TABLE-4, blrl insn. */
- dcbst %r0,%r4 /* sync i-cache with d-cache */
- sync
- icbi %r0,%r4
- isync
-
- lwz %r4,0(%r3) /* offset to _DYNAMIC */
- add %r3,%r4,%r3 /* r3 = &_DYNAMIC, absolute value */
-
- bl _GLOBAL_OFFSET_TABLE_ at local-4
- mflr %r4 /* &_GLOBAL_OFFSET_TABLE_, absolute value */
- lwz %r4,0(%r4) /* linker &_DYNAMIC, from got[0] */
- subf %r4,%r4,%r3 /* subtract to calculate relocbase */
-
- bl reloc_non_plt_self at plt /* reloc_non_plt_self(&_DYNAMIC,base) */
-
- /*
- * The _rtld() function likes to see a stack layout containing
- * { argc, argv[0], argv[1] ... argv[N], 0, env[0], ... , env[N] }
- * Since the PowerPC stack was 16-byte aligned at exec time, the
- * original stack layout has to be found by moving back a word
- * from the argv pointer.
- */
- lwz %r4,20(%r1) /* restore argv */
- addi %r3,%r4,-4 /* locate argc ptr, &argv[-1] */
-
- addi %r4,%r1,8 /* &exit_proc on stack */
- addi %r5,%r1,12 /* &obj_main on stack */
-
- bl _rtld at plt /* &_start = _rtld(sp, &exit_proc, &obj_main)*/
- mtlr %r3
-
- /*
- * Restore args, with new obj/exit proc
- */
- lwz %r3,16(%r1) /* argc */
- lwz %r4,20(%r1) /* argv */
- lwz %r5,24(%r1) /* envp */
- lwz %r6,12(%r1) /* obj */
- lwz %r7,8(%r1) /* exit proc */
- lwz %r8,36(%r1) /* ps_strings */
- addi %r1,%r1,48 /* restore original stackptr */
-
- blrl /* _start(argc, argv, envp, obj, cleanup, ps_strings) */
-
- li %r0,1 /* _exit() */
- sc
-
-/*
- * _rtld_bind_start()
- *
- * Call into the MI binder. This routine is reached via the PLT call cell,
- * and then _rtld_powerpc_pltresolve().
- * On entry, %r11 contains the index of the PLT cell, and %r12 contains
- * a pointer to the ELF object for the file.
- * Save all registers, call into the binder to resolve and fixup the external
- * routine, and then transfer to the external routine on return.
- */
- .globl _rtld_bind
-
-_ENTRY(_rtld_bind_start)
- stwu %r1,-160(%r1) # stack space for 29 regs + r0/lr/cr
- stw %r0,20(%r1) # save r0
- mflr %r0
- stw %r0,16(%r1) # save lr
- mfcr %r0
- stw %r0,12(%r1) # save cr
- stmw %r3,24(%r1) # save r3-r31
-
- mr %r3,%r12 # obj
- mulli %r4,%r11,12 # rela index * sizeof(Elf_Rela)
- bl _rtld_bind at PLT # target addr = _rtld_bind(obj, reloff)
- mtctr %r3 # move absolute target addr into ctr
-
- lmw %r3,24(%r1) # restore r3-r31
- lwz %r0,12(%r1) # restore cr
- mtcr %r0
- lwz %r0,16(%r1) # restore lr
- mtlr %r0
- lwz %r0,20(%r1) # restore r0
-
- addi %r1,%r1,160 # restore stack
- bctr # jump to target
-
-
-/*
- * _rtld_powerpc_pltresolve()
- *
- * This routine is copied into the latter part of the 72-byte reserved
- * area at the start of the PLT. The absolute address of the _rtld_bind_start
- * routine, and the ELF object for the loaded file, are inserted into
- * the code by the reloc.c:init_pltgot() routine.
- * The first time an external routine is called, the PLT slot will
- * set up %r11 to the offset of the slot, and will jump to this routine.
- * The ELF object is shifted into %r11, and _rtld_bind_start is called
- * to complete the binding.
- */
-_ENTRY(_rtld_powerpc_pltresolve)
- lis %r12,0 # lis 12,_rtld_bind_start at ha
- addi %r12,%r12,0 # addi 12,12,_rtld_bind_start at l
- mtctr %r12
- lis %r12,0 # lis 12,obj at ha
- addi %r12,%r12,0 # addi 12,12,obj at l
- bctr
-
-/*
- * _rtld_powerpc_pltcall()
- *
- * This routine is copied into the 72-byte reserved area at the
- * start of the PLT. The reloc.c:init_pltgot() routine inserts
- * the absolute address of the jumptable.
- * Control is transferred to this routine when the binder has
- * located the external routine, but determined that it is > 32Mb
- * from the PLT slot. Code is inserted into the PLT slot to set up
- * %r11 with the jumptable index, and jump to here, where the
- * absolute address of the external routine is loaded from the
- * jumptable and transferred to
- */
-_ENTRY(_rtld_powerpc_pltcall)
- slwi %r11,%r11,2 # jmptab offset = index * 4
- addis %r11,%r11,0 # addis 11,11,jmptab at ha
- lwz %r11,0(%r11) # lwz 11,jmptab at l(11)
- mtctr %r11
- bctr # (*jmptab[index])()
-
-
--- libexec/rtld-elf/powerpc/rtld_machdep.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*-
- * Copyright (c) 1999, 2000 John D. Polstra.
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
- *
- * $FreeBSD: src/libexec/rtld-elf/powerpc/rtld_machdep.h,v 1.4 2004/11/02 09:47:01 ssouhlal Exp $
- */
-
-#ifndef RTLD_MACHDEP_H
-#define RTLD_MACHDEP_H 1
-
-#include <sys/types.h>
-#include <machine/atomic.h>
-
-#define CACHE_LINE_SIZE 32
-
-struct Struct_Obj_Entry;
-
-/* Return the address of the .dynamic section in the dynamic linker. */
-#define rtld_dynamic(obj) (&_DYNAMIC)
-
-Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target,
- const struct Struct_Obj_Entry *defobj,
- const struct Struct_Obj_Entry *obj,
- const Elf_Rel *rel);
-
-#define make_function_pointer(def, defobj) \
- ((defobj)->relocbase + (def)->st_value)
-
-#define call_initfini_pointer(obj, target) \
- (((InitFunc)(target))())
-
-/*
- * Lazy binding entry point, called via PLT.
- */
-void _rtld_bind_start(void);
-
-/*
- * PLT functions. Not really correct prototypes, but the
- * symbol values are needed.
- */
-void _rtld_powerpc_pltresolve(void);
-void _rtld_powerpc_pltcall(void);
-
-/*
- * TLS
- */
-
-#define TLS_TP_OFFSET 0x7000
-#define TLS_DTV_OFFSET 0x8000
-#define TLS_TCB_SIZE 8
-
-#define round(size, align) \
- (((size) + (align) - 1) & ~((align) - 1))
-#define calculate_first_tls_offset(size, align) \
- round(8, align)
-#define calculate_tls_offset(prev_offset, prev_size, size, align) \
- round(prev_offset + prev_size, align)
-#define calculate_tls_end(off, size) ((off) + (size))
-
-typedef struct {
- unsigned long ti_module;
- unsigned long ti_offset;
-} tls_index;
-
-extern void *__tls_get_addr(tls_index* ti);
-
-#endif
More information about the Midnightbsd-cvs
mailing list