diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2004-05-27 21:59:08 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2004-05-27 21:59:08 +0000 |
commit | 916a578d973defb0d42221e8f80337f10de162e6 (patch) | |
tree | 1cb03d5a51dd9a4e5fda79bd5930f1ac633cce4c | |
parent | c4518ad51ee34b19820a133d68042d4a774a96f6 (diff) |
fake plabel32 relocs for dyn.init/fini instead of an evil md macro hook
-rw-r--r-- | libexec/ld.so/hppa/rtld_machine.c | 37 | ||||
-rw-r--r-- | libexec/ld.so/loader.c | 10 |
2 files changed, 29 insertions, 18 deletions
diff --git a/libexec/ld.so/hppa/rtld_machine.c b/libexec/ld.so/hppa/rtld_machine.c index cb8d10050af..84ac8d7c167 100644 --- a/libexec/ld.so/hppa/rtld_machine.c +++ b/libexec/ld.so/hppa/rtld_machine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtld_machine.c,v 1.2 2004/05/25 21:56:49 deraadt Exp $ */ +/* $OpenBSD: rtld_machine.c,v 1.3 2004/05/27 21:59:07 mickey Exp $ */ /* * Copyright (c) 2004 Michael Shalayeff @@ -48,7 +48,7 @@ typedef struct hppa_plabel { Elf_Addr pc; - Elf_Addr sl; + Elf_Addr *sl; SPLAY_ENTRY(hppa_plabel) node; } hppa_plabel_t; SPLAY_HEAD(_dl_md_plabels, hppa_plabel) _dl_md_plabel_root; @@ -72,15 +72,12 @@ SPLAY_PROTOTYPE(_dl_md_plabels, hppa_plabel, node, _dl_md_plcmp); SPLAY_GENERATE(_dl_md_plabels, hppa_plabel, node, _dl_md_plcmp); Elf_Addr -_dl_md_plabel(const elf_object_t *obj, const Elf_Sym *sym, const Elf_RelA *rela) +_dl_md_plabel(Elf_Addr pc, Elf_Addr *sl) { hppa_plabel_t key, *p; - if (ELF_ST_TYPE(sym->st_info) != STT_FUNC) - return (0); - - key.pc = obj->load_offs + sym->st_value + rela->r_addend; - key.sl = (Elf_Addr)obj->dyn.pltgot; + key.pc = pc; + key.sl = sl; p = SPLAY_FIND(_dl_md_plabels, &_dl_md_plabel_root, &key); if (p == NULL) { p = _dl_malloc(sizeof(*p)); @@ -112,6 +109,22 @@ _dl_md_reloc(elf_object_t *object, int rel, int relasz) if (rela == NULL) return (0); + if (object->dyn.init && !((Elf_Addr)object->dyn.init & 2)) { + Elf_Addr addr = _dl_md_plabel((Elf_Addr)object->dyn.init, + object->dyn.pltgot); + DL_DEB(("PLABEL32: %x(_init) -> 0x%x in %s\n", + object->dyn.init, addr, object->load_name)); + object->dyn.init = (void *)addr; + } + + if (object->dyn.fini && !((Elf_Addr)object->dyn.fini & 2)) { + Elf_Addr addr = _dl_md_plabel((Elf_Addr)object->dyn.fini, + object->dyn.pltgot); + DL_DEB(("PLABEL32: %x(_fini) -> 0x%x in %s\n", + object->dyn.fini, addr, object->load_name)); + object->dyn.fini = (void *)addr; + } + for (i = 0; i < numrela; i++, rela++) { const elf_object_t *sobj; const Elf_Sym *sym, *this; @@ -172,7 +185,13 @@ _dl_md_reloc(elf_object_t *object, int rel, int relasz) case RELOC_PLABEL32: if (ELF_R_SYM(rela->r_info)) { - *pt = _dl_md_plabel(sobj, this, rela); + if (ELF_ST_TYPE(this->st_info) != STT_FUNC) { + DL_DEB(("[%x]PLABEL32: bad\n", i)); + break; + } + *pt = _dl_md_plabel(sobj->load_offs + + this->st_value + rela->r_addend, + sobj->dyn.pltgot); DL_DEB(("[%x]PLABEL32: %s:%s -> 0x%x in %s\n", i, symn, object->load_name, *pt, sobj->load_name)); diff --git a/libexec/ld.so/loader.c b/libexec/ld.so/loader.c index 155b078a5e1..f7a5cb4d70f 100644 --- a/libexec/ld.so/loader.c +++ b/libexec/ld.so/loader.c @@ -1,4 +1,4 @@ -/* $OpenBSD: loader.c,v 1.80 2004/05/26 19:14:14 mickey Exp $ */ +/* $OpenBSD: loader.c,v 1.81 2004/05/27 21:59:07 mickey Exp $ */ /* * Copyright (c) 1998 Per Fogelstrom, Opsycon AB @@ -87,11 +87,7 @@ _dl_run_dtors(elf_object_t *object) if (object->dyn.fini) { DL_DEB(("doing dtors @%p: [%s]\n", object->dyn.fini, object->load_name)); -#ifdef MD_CALL - MD_CALL(object, object->dyn.fini, NULL); -#else (*object->dyn.fini)(); -#endif } if (object->next) _dl_run_dtors(object->next); @@ -682,11 +678,7 @@ _dl_call_init(elf_object_t *object) if (object->dyn.init) { DL_DEB(("doing ctors @%p: [%s]\n", object->dyn.init, object->load_name)); -#ifdef MD_CALL - MD_CALL(object, object->dyn.init, NULL); -#else (*object->dyn.init)(); -#endif } /* What about loops? */ |