Index: rtld.h =================================================================== RCS file: /home/ncvs/src/libexec/rtld-elf/rtld.h,v retrieving revision 1.24 diff -c -4 -r1.24 rtld.h *** rtld.h 2001/10/29 10:10:02 1.24 --- rtld.h 2002/02/09 01:22:20 *************** *** 197,204 **** --- 197,207 ---- int reloc_non_plt(Obj_Entry *, Obj_Entry *); int reloc_plt(Obj_Entry *); int reloc_jmpslots(Obj_Entry *); void _rtld_bind_start(void); + #ifdef __alpha__ + void _rtld_bind_start_old(void); + #endif const Elf_Sym *symlook_obj(const char *, unsigned long, const Obj_Entry *, bool); #endif /* } */ Index: alpha/Makefile.inc =================================================================== RCS file: /home/ncvs/src/libexec/rtld-elf/alpha/Makefile.inc,v retrieving revision 1.1 diff -c -4 -r1.1 Makefile.inc *** alpha/Makefile.inc 1999/04/09 00:28:42 1.1 --- alpha/Makefile.inc 2002/02/09 01:22:20 *************** *** 1 **** --- 1,2 ---- CFLAGS+= -mno-fp-regs + LDFLAGS+= --script ${.CURDIR}/alpha/ld.so.script Index: alpha/ld.so.script =================================================================== RCS file: ld.so.script diff -N ld.so.script *** /dev/null Fri Feb 8 17:00:47 2002 --- ld.so.script Fri Feb 8 17:22:20 2002 *************** *** 0 **** --- 1,134 ---- + /* $NetBSD: ld.so.script,v 1.2 2001/12/13 20:31:31 thorpej Exp $ */ + + OUTPUT_FORMAT("elf64-alpha", "elf64-alpha", + "elf64-alpha") + 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 . */ + } Index: alpha/reloc.c =================================================================== RCS file: /home/ncvs/src/libexec/rtld-elf/alpha/reloc.c,v retrieving revision 1.14 diff -c -4 -r1.14 reloc.c *** alpha/reloc.c 2001/10/15 18:48:41 1.14 --- alpha/reloc.c 2002/02/09 01:22:20 *************** *** 46,54 **** #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 --- 46,54 ---- #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 *************** *** 110,118 **** case R_ALPHA_RELATIVE: { if (obj != obj_rtld || (caddr_t)where < (caddr_t)_GLOBAL_OFFSET_TABLE_ || ! (caddr_t)where >= (caddr_t)&_DYNAMIC) store64(where, load64(where) + (Elf_Addr) obj->relocbase); } break; --- 110,118 ---- 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; *************** *** 475,486 **** /* Initialize the special PLT entries. */ void init_pltgot(Obj_Entry *obj) { if (obj->pltgot != NULL && (obj->pltrelsize != 0 || obj->pltrelasize != 0)) { ! /* This function will be called to perform the relocation. */ ! obj->pltgot[2] = (Elf_Addr) &_rtld_bind_start; /* Identify this shared object */ obj->pltgot[3] = (Elf_Addr) obj; } } --- 475,496 ---- /* 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; } } Index: alpha/rtld_start.S =================================================================== RCS file: /home/ncvs/src/libexec/rtld-elf/alpha/rtld_start.S,v retrieving revision 1.4 diff -c -4 -r1.4 rtld_start.S *** alpha/rtld_start.S 2000/07/08 04:10:37 1.4 --- alpha/rtld_start.S 2002/02/09 01:22:20 *************** *** 32,39 **** --- 32,40 ---- #include #include .extern _GLOBAL_OFFSET_TABLE_ + .extern _GOT_END_ LEAF(_rtld_start, 0) /* XXX */ .set noreorder br pv, $33 *************** *** 57,65 **** /* Step 2 -- Find bounds of global offset table */ lda t5, _GLOBAL_OFFSET_TABLE_ addq t8, t5, t9 /* add the displacement */ ! lda t4, _DYNAMIC addq t8, t4, t10 /* add the displacement */ /* * Step 3 -- Every entry in the global offset table needs to --- 58,66 ---- /* 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 *************** *** 86,172 **** 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, t12 jsr ra, (v0), 0 /* (*_start)(sp, cleanup, obj); */ ldgp gp, 0(ra) CALL(exit) halt END(_rtld_start) ! .set noat ! .globl _rtld_bind_start ! .ent _rtld_bind_start ! _rtld_bind_start: ! ! lda sp, -168(sp) ! .frame sp, 168, $26 ! /* Preserve all registers that C normally doesn't. */ ! stq $26, 0(sp) ! stq $0, 8(sp) ! stq $1, 16(sp) ! stq $2, 24(sp) ! stq $3, 32(sp) ! stq $4, 40(sp) ! stq $5, 48(sp) ! stq $6, 56(sp) ! stq $7, 64(sp) ! stq $8, 72(sp) ! stq $16, 80(sp) ! stq $17, 88(sp) ! stq $18, 96(sp) ! stq $19, 104(sp) ! stq $20, 112(sp) ! stq $21, 120(sp) ! stq $22, 128(sp) ! stq $23, 136(sp) ! stq $24, 144(sp) ! stq $25, 152(sp) ! stq $29, 160(sp) ! .mask 0x27ff01ff, -168 ! /* Set up our $gp */ ! br gp, $100 ! $100: ldgp gp, 0(gp) ! .prologue 1 /* Set up the arguments for _rtld_bind. */ ! subq at_reg, t12, a1 /* calculate reloc offset */ ! ldq a0, 8(t12) /* object structure */ subq a1, 20, a1 /* = (at - t11 - 20) / 12 * 24 */ addq a1, a1, a1 CALL(_rtld_bind) - /* Move the destination address into position. */ - mov $0, $27 - /* Restore program registers. */ - ldq $26, 0(sp) - ldq $0, 8(sp) - ldq $1, 16(sp) - ldq $2, 24(sp) - ldq $3, 32(sp) - ldq $4, 40(sp) - ldq $5, 48(sp) - ldq $6, 56(sp) - ldq $7, 64(sp) - ldq $8, 72(sp) - ldq $16, 80(sp) - ldq $17, 88(sp) - ldq $18, 96(sp) - ldq $19, 104(sp) - ldq $20, 112(sp) - ldq $21, 120(sp) - ldq $22, 128(sp) - ldq $23, 136(sp) - ldq $24, 144(sp) - ldq $25, 152(sp) - ldq $29, 160(sp) - /* Flush the Icache after having modified the .plt code. */ - imb - /* Clean up and turn control to the destination */ - lda sp, 168(sp) - jmp $31, ($27) - .end _rtld_bind_start /* * int cmp0_and_store_int(volatile int *p, int newval); * --- 87,216 ---- 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) + /* * int cmp0_and_store_int(volatile int *p, int newval); *