diff options
| author | thorpej <thorpej@NetBSD.org> | 2001-12-13 22:34:51 +0000 |
|---|---|---|
| committer | thorpej <thorpej@NetBSD.org> | 2001-12-13 22:34:51 +0000 |
| commit | 67925dcb0d6993be8e0fd1b4ae8d4dcf231d6f09 (patch) | |
| tree | d5c1c1501412781414164102aa3511dfcfe08d60 /libexec | |
| parent | 816077b47e1054815938b383d8c9e8ce1770efaa (diff) | |
Supply two lazy binding routines for Alpha: one that works with the
old PLT format, and one that works with the new.
XXX We currently always use _rtld_bind_start_old() in
_rtld_setup_alpha_pltgot(). We need to add code to peek
into one of the PLT entries to see which format it's in
and pick the correct binding routine.
Diffstat (limited to 'libexec')
| -rw-r--r-- | libexec/ld.elf_so/arch/alpha/Makefile.inc | 4 | ||||
| -rw-r--r-- | libexec/ld.elf_so/arch/alpha/alpha_reloc.c | 68 | ||||
| -rw-r--r-- | libexec/ld.elf_so/arch/alpha/rtld_start.S | 170 | ||||
| -rw-r--r-- | libexec/ld.elf_so/reloc.c | 10 | ||||
| -rw-r--r-- | libexec/ld.elf_so/rtld.h | 10 |
5 files changed, 177 insertions, 85 deletions
diff --git a/libexec/ld.elf_so/arch/alpha/Makefile.inc b/libexec/ld.elf_so/arch/alpha/Makefile.inc index 139e14a8170..d7c9f427332 100644 --- a/libexec/ld.elf_so/arch/alpha/Makefile.inc +++ b/libexec/ld.elf_so/arch/alpha/Makefile.inc @@ -1,6 +1,6 @@ -# $NetBSD: Makefile.inc,v 1.4 2001/12/13 20:30:48 thorpej Exp $ +# $NetBSD: Makefile.inc,v 1.5 2001/12/13 22:34:52 thorpej Exp $ -SRCS+= rtld_start.S +SRCS+= rtld_start.S alpha_reloc.c CPPFLAGS+= -fpic -mno-fp-regs -DELFSIZE=64 LDFLAGS+= -Bshareable -Bsymbolic -e _rtld_start diff --git a/libexec/ld.elf_so/arch/alpha/alpha_reloc.c b/libexec/ld.elf_so/arch/alpha/alpha_reloc.c new file mode 100644 index 00000000000..3edad5afbe5 --- /dev/null +++ b/libexec/ld.elf_so/arch/alpha/alpha_reloc.c @@ -0,0 +1,68 @@ +/* $NetBSD: alpha_reloc.c,v 1.1 2001/12/13 22:34:52 thorpej Exp $ */ + +/* + * Copyright (c) 2001 Wasabi Systems, Inc. + * All rights reserved. + * + * Written by Jason R. Thorpe for Wasabi Systems, Inc. + * + * 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 for the NetBSD Project by + * Wasabi Systems, Inc. + * 4. The name of Wasabi Systems, Inc. may not be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC + * 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 <sys/types.h> +#include <sys/stat.h> + +#include "rtld.h" + +/* + * _rtld_setup_alpha_pltgot: + * + * Set up the Alpha pltgot glue. + */ +void +_rtld_setup_alpha_pltgot(const Obj_Entry *obj) +{ + + /* + * XXX We need to look at the one of the PLT entries and + * XXX see which format it's in, and set the binding routine + * XXX appropriately. + */ + if (1) { + /* Old PLT entry format. */ + obj->pltgot[2] = (Elf_Addr) &_rtld_bind_start_old; + obj->pltgot[3] = (Elf_Addr) obj; + + return; + } + + /* New PLT entry format. */ + obj->pltgot[2] = (Elf_Addr) &_rtld_bind_start; + obj->pltgot[3] = (Elf_Addr) obj; +} diff --git a/libexec/ld.elf_so/arch/alpha/rtld_start.S b/libexec/ld.elf_so/arch/alpha/rtld_start.S index 7ad2bacdf13..9183b30879f 100644 --- a/libexec/ld.elf_so/arch/alpha/rtld_start.S +++ b/libexec/ld.elf_so/arch/alpha/rtld_start.S @@ -1,4 +1,4 @@ -/* $NetBSD: rtld_start.S,v 1.6 2001/12/13 21:34:04 thorpej Exp $ */ +/* $NetBSD: rtld_start.S,v 1.7 2001/12/13 22:34:52 thorpej Exp $ */ /* * Copyright 1996 Matt Thomas <matt@3am-software.com> @@ -105,92 +105,114 @@ LEAF_NOPROFILE(_rtld_start, 0) 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) - /* 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) + RTLD_BIND_START_PROLOGUE /* Set up the arguments for _rtld_bind. */ -#ifdef NEW_PLT_FORMAT subq at_reg, pv, a1 /* calculate offset of reloc entry */ ldq a0, 8(pv) /* object structure */ subq a1, 20, a1 /* = (at - pv - 20) / 12 * 24 */ addq a1, a1, a1 -#else + + 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 */ -#endif /* NEW_PLT_FORMAT */ + CALL(_rtld_bind) - /* 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? */ + RTLD_BIND_START_EPILOGUE - /* - * 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) -END(_rtld_bind_start) +END(_rtld_bind_start_old) diff --git a/libexec/ld.elf_so/reloc.c b/libexec/ld.elf_so/reloc.c index 51ed2913a68..a65113599dd 100644 --- a/libexec/ld.elf_so/reloc.c +++ b/libexec/ld.elf_so/reloc.c @@ -1,4 +1,4 @@ -/* $NetBSD: reloc.c,v 1.43 2001/12/13 21:41:58 rafal Exp $ */ +/* $NetBSD: reloc.c,v 1.44 2001/12/13 22:34:51 thorpej Exp $ */ /* * Copyright 1996 John D. Polstra. @@ -778,13 +778,7 @@ _rtld_relocate_objects(first, bind_now, dodebug) obj->pltgot[2] = (Elf_Addr) & _rtld_bind_start; #endif #if defined(__alpha__) - /* - * 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; + _rtld_setup_alpha_pltgot(obj); #endif #if defined(__mips__) _rtld_relocate_mips_got(obj); diff --git a/libexec/ld.elf_so/rtld.h b/libexec/ld.elf_so/rtld.h index 59e5fb20e05..d8d7cb177f3 100644 --- a/libexec/ld.elf_so/rtld.h +++ b/libexec/ld.elf_so/rtld.h @@ -1,4 +1,4 @@ -/* $NetBSD: rtld.h,v 1.30 2001/04/25 12:24:50 kleink Exp $ */ +/* $NetBSD: rtld.h,v 1.31 2001/12/13 22:34:52 thorpej Exp $ */ /* * Copyright 1996 John D. Polstra. @@ -291,6 +291,14 @@ Obj_Entry *_rtld_map_object __P((const char *, int, const struct stat *)); void _rtld_obj_free(Obj_Entry *); Obj_Entry *_rtld_obj_new(void); +#if defined(__alpha__) +/* alpha_reloc.c */ +void _rtld_setup_alpha_pltgot __P((const Obj_Entry *)); + +/* rtld_start.S */ +void _rtld_bind_start_old __P((void)); +#endif + #if defined(__mips__) /* mips_reloc.c */ void _rtld_relocate_mips_got __P((Obj_Entry *)); |
