From 4d582ffe096e47ba124286efb831032cbd3cdf2a Mon Sep 17 00:00:00 2001 From: ru Date: Tue, 22 Aug 2006 08:03:01 +0000 Subject: Remove alpha left-overs. --- libexec/rtld-elf/alpha/Makefile.inc | 4 - libexec/rtld-elf/alpha/ld.so.script | 135 --------- libexec/rtld-elf/alpha/reloc.c | 531 ---------------------------------- libexec/rtld-elf/alpha/rtld_machdep.h | 78 ----- libexec/rtld-elf/alpha/rtld_start.S | 211 -------------- 5 files changed, 959 deletions(-) delete mode 100644 libexec/rtld-elf/alpha/Makefile.inc delete mode 100644 libexec/rtld-elf/alpha/ld.so.script delete mode 100644 libexec/rtld-elf/alpha/reloc.c delete mode 100644 libexec/rtld-elf/alpha/rtld_machdep.h delete mode 100644 libexec/rtld-elf/alpha/rtld_start.S (limited to 'libexec/rtld-elf') diff --git a/libexec/rtld-elf/alpha/Makefile.inc b/libexec/rtld-elf/alpha/Makefile.inc deleted file mode 100644 index 0f34feb..0000000 --- a/libexec/rtld-elf/alpha/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# $FreeBSD$ - -CFLAGS+= -mno-fp-regs -LDFLAGS+= -Wl,--script,${.CURDIR}/alpha/ld.so.script diff --git a/libexec/rtld-elf/alpha/ld.so.script b/libexec/rtld-elf/alpha/ld.so.script deleted file mode 100644 index 2b5d535..0000000 --- a/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$ */ - -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 . */ -} diff --git a/libexec/rtld-elf/alpha/reloc.c b/libexec/rtld-elf/alpha/reloc.c deleted file mode 100644 index 364b59a..0000000 --- a/libexec/rtld-elf/alpha/reloc.c +++ /dev/null @@ -1,531 +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$ - */ - -/* - * Dynamic linker for ELF. - * - * John Polstra . - */ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#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; - const Ver_Entry *ve; - 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; - 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); - 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); -} diff --git a/libexec/rtld-elf/alpha/rtld_machdep.h b/libexec/rtld-elf/alpha/rtld_machdep.h deleted file mode 100644 index 397139e..0000000 --- a/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$ - */ - -#ifndef RTLD_MACHDEP_H -#define RTLD_MACHDEP_H 1 - -#include -#include - -/* - * 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 diff --git a/libexec/rtld-elf/alpha/rtld_start.S b/libexec/rtld-elf/alpha/rtld_start.S deleted file mode 100644 index 8ab7605..0000000 --- a/libexec/rtld-elf/alpha/rtld_start.S +++ /dev/null @@ -1,211 +0,0 @@ -/* $FreeBSD$ */ -/* From: NetBSD: rtld_start.S,v 1.1 1996/12/16 20:38:09 cgd Exp */ - -/* - * Copyright 1996 Matt Thomas - * 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 -#include - -.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) - -- cgit v1.1