Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/libexec/ld.elf_so Supply two lazy binding routines for Alpha...
details: https://anonhg.NetBSD.org/src/rev/348e8f86f29f
branches: trunk
changeset: 519248:348e8f86f29f
user: thorpej <thorpej%NetBSD.org@localhost>
date: Thu Dec 13 22:34:51 2001 +0000
description:
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:
libexec/ld.elf_so/arch/alpha/Makefile.inc | 4 +-
libexec/ld.elf_so/arch/alpha/alpha_reloc.c | 68 +++++++++++
libexec/ld.elf_so/arch/alpha/rtld_start.S | 170 ++++++++++++++++------------
libexec/ld.elf_so/reloc.c | 10 +-
libexec/ld.elf_so/rtld.h | 10 +-
5 files changed, 177 insertions(+), 85 deletions(-)
diffs (truncated from 329 to 300 lines):
diff -r 19ca0cd6e28a -r 348e8f86f29f libexec/ld.elf_so/arch/alpha/Makefile.inc
--- a/libexec/ld.elf_so/arch/alpha/Makefile.inc Thu Dec 13 22:33:20 2001 +0000
+++ b/libexec/ld.elf_so/arch/alpha/Makefile.inc Thu Dec 13 22:34:51 2001 +0000
@@ -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 -r 19ca0cd6e28a -r 348e8f86f29f libexec/ld.elf_so/arch/alpha/alpha_reloc.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libexec/ld.elf_so/arch/alpha/alpha_reloc.c Thu Dec 13 22:34:51 2001 +0000
@@ -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 -r 19ca0cd6e28a -r 348e8f86f29f libexec/ld.elf_so/arch/alpha/rtld_start.S
--- a/libexec/ld.elf_so/arch/alpha/rtld_start.S Thu Dec 13 22:33:20 2001 +0000
+++ b/libexec/ld.elf_so/arch/alpha/rtld_start.S Thu Dec 13 22:34:51 2001 +0000
@@ -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@localhost>
@@ -105,92 +105,114 @@
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
- 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
+ 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)
- /* 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_PROLOGUE
+
+ /* Set up the arguments for _rtld_bind. */
+ ldq a0, 8(pv) /* object structure */
+ mov at_reg, a1 /* offset of reloc entry */
- /*
- * We've patched the PLT; sync the I-stream.
- */
- imb
+ CALL(_rtld_bind)
- /* Pop the stack frame and turn control to the destination. */
- lda sp, 168(sp)
- jmp zero, (pv)
-END(_rtld_bind_start)
+ RTLD_BIND_START_EPILOGUE
+
+END(_rtld_bind_start_old)
diff -r 19ca0cd6e28a -r 348e8f86f29f libexec/ld.elf_so/reloc.c
--- a/libexec/ld.elf_so/reloc.c Thu Dec 13 22:33:20 2001 +0000
+++ b/libexec/ld.elf_so/reloc.c Thu Dec 13 22:34:51 2001 +0000
@@ -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 @@
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 */
Home |
Main Index |
Thread Index |
Old Index