diff options
| author | matt <matt@NetBSD.org> | 1998-08-18 18:46:16 +0000 |
|---|---|---|
| committer | matt <matt@NetBSD.org> | 1998-08-18 18:46:16 +0000 |
| commit | 74018d8df6281b7e62b35f88ea552c5a72a031b5 (patch) | |
| tree | a32efd7aa85b919caead5748c54422a45d19755f /libexec | |
| parent | ff266f0937a805e255219eb3f903c308e19fca89 (diff) | |
Untested(!!) beginning of VAX a.out shared library support. This is a work
in progress.
Diffstat (limited to 'libexec')
| -rw-r--r-- | libexec/ld.aout_so/arch/vax/md.c | 28 | ||||
| -rw-r--r-- | libexec/ld.aout_so/arch/vax/md.h | 16 | ||||
| -rw-r--r-- | libexec/ld.aout_so/arch/vax/mdprologue.S | 77 |
3 files changed, 97 insertions, 24 deletions
diff --git a/libexec/ld.aout_so/arch/vax/md.c b/libexec/ld.aout_so/arch/vax/md.c index 16de3a1ceeb..02911bfb0d3 100644 --- a/libexec/ld.aout_so/arch/vax/md.c +++ b/libexec/ld.aout_so/arch/vax/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.3 1998/07/27 07:48:22 mycroft Exp $ */ +/* $NetBSD: md.c,v 1.4 1998/08/18 18:46:16 matt Exp $ */ /* * Copyright (c) 1993 Paul Kranenburg @@ -128,23 +128,20 @@ long index; * On VAX a branch offset given in immediate mode is relative to * the end of the address itself. */ - u_long fudge = - (sizeof(sp->opcode) + sizeof(sp->addr) + offset); + u_long fudge = - (offsetof(jmpslot_t, reloc_index) + offset); - sp->opcode = JMPREL; /* XXX !!! untested !!! XXX */ -#if 0 - sp->addr = fudge; -#else + sp->mask = 0; /* save no registers */ + sp->opcode = JSB_PCREL; sp->addr[0] = fudge & 0xffff; sp->addr[1] = fudge >> 16; -#endif - sp->reloc_index = index; + sp->reloc_index[0] = index; } /* * Set up a "direct" transfer (ie. not through the run-time binder) from * jmpslot at OFFSET to ADDR. Used by `ld' when the SYMBOLIC flag is on, * and by `ld.so' after resolving the symbol. - * On the i386, we use the JMP instruction which is PC relative, so no + * On the VAX, we use the JMP instruction which is PC relative, so no * further RRS relocations will be necessary for such a jmpslot. */ void @@ -153,15 +150,12 @@ jmpslot_t *sp; long offset; u_long addr; { - u_long fudge = addr - (sizeof(sp->opcode) + sizeof(sp->addr) + offset); + u_long fudge = addr - (offsetof(jmpslot_t, reloc_index) + offset); - sp->opcode = JMPABS; /* XXX !!! untested !!! XXX */ -#if 0 - sp->addr = fudge; -#else - sp->addr[0] = fudge & 0xffff; - sp->addr[1] = fudge >> 16; -#endif + sp->mask = *(u_short *) addr; /* store the procedure entry mask */ + sp->opcode = JMP_PCREL; /* jmp to procedure + 2 */ + sp->addr[0] = (fudge + 2) & 0xffff; /* skipping entry mask */ + sp->addr[1] = (fudge + 2) >> 16; #if 0 sp->reloc_index = 0; #endif diff --git a/libexec/ld.aout_so/arch/vax/md.h b/libexec/ld.aout_so/arch/vax/md.h index ee65a03add8..3b03d6da34d 100644 --- a/libexec/ld.aout_so/arch/vax/md.h +++ b/libexec/ld.aout_so/arch/vax/md.h @@ -1,4 +1,4 @@ -/* $NetBSD: md.h,v 1.2 1998/01/05 22:00:49 cgd Exp $ */ +/* $NetBSD: md.h,v 1.3 1998/08/18 18:46:17 matt Exp $ */ /* * Copyright (c) 1993 Paul Kranenburg @@ -96,19 +96,25 @@ #define GOT_ENTRY_SIZE 4 typedef long got_t; +/* + * .word ^M<reg-mask> + * pushl #reloc_index + * jmp L^addr + */ typedef struct jmpslot { + u_short mask; u_short opcode; u_short addr[2]; - u_short reloc_index; #define JMPSLOT_RELOC_MASK 0xffff + u_short reloc_index; } jmpslot_t; /* * following defines are untested since VAX doesn't support PIC (yet?) */ -#define JMPABS 0x8F17 /* JMP + immediate mode for address */ -#define JMPREL 0x8F11 /* BRB + immediate mode for displacement */ -#define TRAP 0x00BC /* how to trap ??? CHMK ??? */ +#define JSB_PCREL 0x8F16 /* JSB + immediate mode for displacement */ +#define JMP_PCREL 0x8F17 /* JMP + immediate mode for displacement */ +#define TRAP 0x00BC /* how to trap ??? CHMK ??? */ /* * Byte swap defs for cross linking diff --git a/libexec/ld.aout_so/arch/vax/mdprologue.S b/libexec/ld.aout_so/arch/vax/mdprologue.S index cd195aa4b51..9228d65f625 100644 --- a/libexec/ld.aout_so/arch/vax/mdprologue.S +++ b/libexec/ld.aout_so/arch/vax/mdprologue.S @@ -1,5 +1,78 @@ -/* $NetBSD: mdprologue.S,v 1.2 1998/01/05 22:00:49 cgd Exp $ */ +/* $NetBSD: mdprologue.S,v 1.3 1998/08/18 18:46:16 matt Exp $ */ /* - * VAX doesn't support PIC (yet?) + * Copyright (c) 1998 Matt Thomas <matt@3am-software.com> + * 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. */ + +/* + * i386 run-time link editor entry points. + */ + +#include <sys/syscall.h> + + .text + .globl _binder, _binder_entry + +/* + * _rtl(int version, struct crt_ldso *crtp) + */ + +_rtl: # crt0 calls us here + .word 0 # no registers to save + movl 4(sp),r0 # load crtp into r0 + # setup arguments for rtld() + # Add the 1st entry in the GOT (e.g. __DYNAMIC) to the base + # address of ld.so and pushd that onto the stack. + addl3 _GLOBAL_OFFSET_TABLE_,(r0),-(sp) + pushl r0 # 2nd arg == crtp + pushl 0(ap) # 1st arg == version + calls $3,_rtld # _rtld(version, crtp, DYNAMIC) + ret + + # First call to a procedure generally comes through here for binding. + # We got here via JSB so now (sp) is pointing to the reloc_index + # inside our jmpslot_t. So we simply preserve our registers, + # pushd the address again for _binder. Save R0 on the stack that + # the JSB used. Call the actual function and return. + +_binder_entry: + pushl r5 + pushl r4 + pushl r3 + pushl r2 + pushl r1 + pushl r0 + pushl 24(sp) + calls #1, _binder # _binder(jsp) + movl r0, 24(sp) + popl r0 + popl r1 + popl r2 + popl r3 + popl r4 + popl r5 + callg (ap), @(sp)+ # return value from _binder() == actual + ret |
