Implement a self-relocate function for the VAX.

This commit is contained in:
mycroft 2002-09-26 22:26:26 +00:00
parent ad2a80f193
commit d437f6520b
3 changed files with 41 additions and 12 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: mdreloc.c,v 1.14 2002/09/26 20:42:12 mycroft Exp $ */
/* $NetBSD: mdreloc.c,v 1.15 2002/09/26 22:26:27 mycroft Exp $ */
#include <sys/types.h>
#include <sys/stat.h>
@ -7,6 +7,7 @@
#include "rtld.h"
void _rtld_bind_start(void);
void _rtld_relocate_nonplt_self(Elf_Dyn *, Elf_Addr);
caddr_t _rtld_bind __P((const Obj_Entry *, Elf_Word));
void
@ -16,6 +17,32 @@ _rtld_setup_pltgot(const Obj_Entry *obj)
obj->pltgot[2] = (Elf_Addr) &_rtld_bind_start;
}
void
_rtld_relocate_nonplt_self(dynp, relocbase)
Elf_Dyn *dynp;
Elf_Addr relocbase;
{
const Elf_Rela *rela = 0, *relalim;
Elf_Addr relasz = 0;
Elf_Addr *where;
for (; dynp->d_tag != DT_NULL; dynp++) {
switch (dynp->d_tag) {
case DT_RELA:
rela = (const Elf_Rela *)(relocbase + dynp->d_un.d_ptr);
break;
case DT_RELASZ:
relasz = dynp->d_un.d_val;
break;
}
}
relalim = (const Elf_Rela *)((caddr_t)rela + relasz);
for (; rela < relalim; rela++) {
where = (Elf_Addr *)(relocbase + rela->r_offset);
*where = (Elf_Addr)(relocbase + rela->r_addend);
}
}
int
_rtld_relocate_nonplt_objects(obj)
const Obj_Entry *obj;

View File

@ -1,7 +1,8 @@
/* $NetBSD: rtld_start.S,v 1.8 2002/09/12 17:43:30 mycroft Exp $ */
/* $NetBSD: rtld_start.S,v 1.9 2002/09/26 22:26:27 mycroft Exp $ */
/*
* Copyright 1996 Matt Thomas <matt@3am-software.com>
* Portions copyright 2002 Charles M. Hannum.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -44,11 +45,16 @@ ENTRY(_rtld_start, 0)
clrl %fp
subl2 $8,%sp
movab _GLOBAL_OFFSET_TABLE_,%r0
subl2 .L1,%r0
movl %sp,%r1
pushl %r0 /* relocbase */
pushl %r1 /* sp */
movab _DYNAMIC,%r0
movab _GLOBAL_OFFSET_TABLE_,%r1
subl2 .L1,%r1
pushl %r1 /* relocbase */
pushl %r0 /* &_DYNAMIC */
calls $2,_rtld_relocate_nonplt_self
movl %sp,%r0
pushl %r1 /* relocbase */
pushl %r0 /* sp */
calls $2,_rtld /* entry = _rtld(sp, relocbase) */
movq (%sp)+,%r7 /* grab cleanup and obj_main into %r7/%r8 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: rtld.c,v 1.81 2002/09/26 20:42:10 mycroft Exp $ */
/* $NetBSD: rtld.c,v 1.82 2002/09/26 22:26:26 mycroft Exp $ */
/*
* Copyright 1996 John D. Polstra.
@ -163,10 +163,6 @@ _rtld_init(mapbase, relocbase)
assert(!_rtld_objself.pltgot && !_rtld_objself.textrel);
#endif
#ifdef __vax__
_rtld_relocate_nonplt_objects(&_rtld_objself);
#endif
_rtld_add_paths(&_rtld_default_paths, RTLD_DEFAULT_LIBRARY_PATH);
/*