Restore the fptr_t type of {init,fini}{,_array} that was removed when initial
support for indirect functions was added. This fixes {init,fini}_array support on hppa where each member of the array is (already) a plabel. Discussed with joerg. 4 files changed, 29 insertions(+), 39 deletions(-) : ----------------------------------------------------------------------
This commit is contained in:
parent
c0f5cd2dce
commit
45f12ca261
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: hppa_reloc.c,v 1.47 2020/05/16 16:43:00 skrll Exp $ */
|
||||
/* $NetBSD: hppa_reloc.c,v 1.48 2021/12/04 14:39:08 skrll Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002, 2004 The NetBSD Foundation, Inc.
|
||||
|
@ -31,7 +31,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: hppa_reloc.c,v 1.47 2020/05/16 16:43:00 skrll Exp $");
|
||||
__RCSID("$NetBSD: hppa_reloc.c,v 1.48 2021/12/04 14:39:08 skrll Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
@ -726,19 +726,6 @@ _rtld_relocate_plt_objects(const Obj_Entry *obj)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
_rtld_call_function_void(const Obj_Entry *obj, Elf_Addr ptr)
|
||||
{
|
||||
volatile hppa_plabel plabel;
|
||||
void (*f)(void);
|
||||
|
||||
plabel.hppa_plabel_pc = (Elf_Addr)ptr;
|
||||
plabel.hppa_plabel_sl = (Elf_Addr)(obj->pltgot);
|
||||
f = (void (*)(void))RTLD_MAKE_PLABEL(&plabel);
|
||||
|
||||
f();
|
||||
}
|
||||
|
||||
Elf_Addr
|
||||
_rtld_call_function_addr(const Obj_Entry *obj, Elf_Addr ptr)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: headers.c,v 1.69 2020/05/16 16:43:15 skrll Exp $ */
|
||||
/* $NetBSD: headers.c,v 1.70 2021/12/04 14:39:08 skrll Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1996 John D. Polstra.
|
||||
|
@ -40,7 +40,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: headers.c,v 1.69 2020/05/16 16:43:15 skrll Exp $");
|
||||
__RCSID("$NetBSD: headers.c,v 1.70 2021/12/04 14:39:08 skrll Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <err.h>
|
||||
|
@ -299,7 +299,7 @@ _rtld_digest_dynamic(const char *execname, Obj_Entry *obj)
|
|||
#ifdef HAVE_INITFINI_ARRAY
|
||||
case DT_INIT_ARRAY:
|
||||
obj->init_array =
|
||||
(Elf_Addr *)(obj->relocbase + dynp->d_un.d_ptr);
|
||||
(fptr_t *)(obj->relocbase + dynp->d_un.d_ptr);
|
||||
dbg(("headers: DT_INIT_ARRAY at %p",
|
||||
obj->init_array));
|
||||
break;
|
||||
|
@ -320,7 +320,7 @@ _rtld_digest_dynamic(const char *execname, Obj_Entry *obj)
|
|||
#ifdef HAVE_INITFINI_ARRAY
|
||||
case DT_FINI_ARRAY:
|
||||
obj->fini_array =
|
||||
(Elf_Addr *)(obj->relocbase + dynp->d_un.d_ptr);
|
||||
(fptr_t *)(obj->relocbase + dynp->d_un.d_ptr);
|
||||
dbg(("headers: DT_FINI_ARRAY at %p",
|
||||
obj->fini_array));
|
||||
break;
|
||||
|
@ -434,10 +434,19 @@ _rtld_digest_dynamic(const char *execname, Obj_Entry *obj)
|
|||
}
|
||||
|
||||
#ifdef RTLD_LOADER
|
||||
#if defined(__HAVE_FUNCTION_DESCRIPTORS)
|
||||
if (init != 0)
|
||||
obj->init = (Elf_Addr) obj->relocbase + init;
|
||||
obj->init = (void (*)(void))
|
||||
_rtld_function_descriptor_alloc(obj, NULL, init);
|
||||
if (fini != 0)
|
||||
obj->fini = (Elf_Addr) obj->relocbase + fini;
|
||||
obj->fini = (void (*)(void))
|
||||
_rtld_function_descriptor_alloc(obj, NULL, fini);
|
||||
#else
|
||||
if (init != 0)
|
||||
obj->init = (void (*)(void)) (obj->relocbase + init);
|
||||
if (fini != 0)
|
||||
obj->fini = (void (*)(void)) (obj->relocbase + fini);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (dyn_rpath != NULL) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rtld.c,v 1.209 2021/06/16 21:53:51 riastradh Exp $ */
|
||||
/* $NetBSD: rtld.c,v 1.210 2021/12/04 14:39:08 skrll Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1996 John D. Polstra.
|
||||
|
@ -40,7 +40,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: rtld.c,v 1.209 2021/06/16 21:53:51 riastradh Exp $");
|
||||
__RCSID("$NetBSD: rtld.c,v 1.210 2021/12/04 14:39:08 skrll Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -137,25 +137,25 @@ static Obj_Entry *_rtld_obj_from_addr(const void *);
|
|||
static void _rtld_fill_dl_phdr_info(const Obj_Entry *, struct dl_phdr_info *);
|
||||
|
||||
static inline void
|
||||
_rtld_call_initfini_function(const Obj_Entry *obj, Elf_Addr func, sigset_t *mask)
|
||||
_rtld_call_initfini_function(fptr_t func, sigset_t *mask)
|
||||
{
|
||||
_rtld_exclusive_exit(mask);
|
||||
_rtld_call_function_void(obj, func);
|
||||
(*func)();
|
||||
_rtld_exclusive_enter(mask);
|
||||
}
|
||||
|
||||
static void
|
||||
_rtld_call_fini_function(Obj_Entry *obj, sigset_t *mask, u_int cur_objgen)
|
||||
{
|
||||
if (obj->fini_arraysz == 0 && (obj->fini == 0 || obj->fini_called))
|
||||
if (obj->fini_arraysz == 0 && (obj->fini == NULL || obj->fini_called))
|
||||
return;
|
||||
|
||||
if (obj->fini != 0 && !obj->fini_called) {
|
||||
if (obj->fini != NULL && !obj->fini_called) {
|
||||
dbg (("calling fini function %s at %p%s", obj->path,
|
||||
(void *)obj->fini,
|
||||
obj->z_initfirst ? " (DF_1_INITFIRST)" : ""));
|
||||
obj->fini_called = 1;
|
||||
_rtld_call_initfini_function(obj, obj->fini, mask);
|
||||
_rtld_call_initfini_function(obj->fini, mask);
|
||||
}
|
||||
#ifdef HAVE_INITFINI_ARRAY
|
||||
/*
|
||||
|
@ -165,12 +165,12 @@ _rtld_call_fini_function(Obj_Entry *obj, sigset_t *mask, u_int cur_objgen)
|
|||
* the loop.
|
||||
*/
|
||||
while (obj->fini_arraysz > 0 && _rtld_objgen == cur_objgen) {
|
||||
Elf_Addr fini = *obj->fini_array++;
|
||||
fptr_t fini = *obj->fini_array++;
|
||||
obj->fini_arraysz--;
|
||||
dbg (("calling fini array function %s at %p%s", obj->path,
|
||||
(void *)fini,
|
||||
obj->z_initfirst ? " (DF_1_INITFIRST)" : ""));
|
||||
_rtld_call_initfini_function(obj, fini, mask);
|
||||
_rtld_call_initfini_function(fini, mask);
|
||||
}
|
||||
#endif /* HAVE_INITFINI_ARRAY */
|
||||
}
|
||||
|
@ -231,15 +231,15 @@ restart:
|
|||
static void
|
||||
_rtld_call_init_function(Obj_Entry *obj, sigset_t *mask, u_int cur_objgen)
|
||||
{
|
||||
if (obj->init_arraysz == 0 && (obj->init_called || obj->init == 0))
|
||||
if (obj->init_arraysz == 0 && (obj->init_called || obj->init == NULL))
|
||||
return;
|
||||
|
||||
if (!obj->init_called && obj->init != 0) {
|
||||
if (!obj->init_called && obj->init != NULL) {
|
||||
dbg (("calling init function %s at %p%s",
|
||||
obj->path, (void *)obj->init,
|
||||
obj->z_initfirst ? " (DF_1_INITFIRST)" : ""));
|
||||
obj->init_called = 1;
|
||||
_rtld_call_initfini_function(obj, obj->init, mask);
|
||||
_rtld_call_initfini_function(obj->init, mask);
|
||||
}
|
||||
|
||||
#ifdef HAVE_INITFINI_ARRAY
|
||||
|
@ -250,12 +250,12 @@ _rtld_call_init_function(Obj_Entry *obj, sigset_t *mask, u_int cur_objgen)
|
|||
* the loop.
|
||||
*/
|
||||
while (obj->init_arraysz > 0 && _rtld_objgen == cur_objgen) {
|
||||
Elf_Addr init = *obj->init_array++;
|
||||
fptr_t init = *obj->init_array++;
|
||||
obj->init_arraysz--;
|
||||
dbg (("calling init_array function %s at %p%s",
|
||||
obj->path, (void *)init,
|
||||
obj->z_initfirst ? " (DF_1_INITFIRST)" : ""));
|
||||
_rtld_call_initfini_function(obj, init, mask);
|
||||
_rtld_call_initfini_function(init, mask);
|
||||
}
|
||||
#endif /* HAVE_INITFINI_ARRAY */
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rtld.h,v 1.141 2020/09/21 16:08:57 kamil Exp $ */
|
||||
/* $NetBSD: rtld.h,v 1.142 2021/12/04 14:39:08 skrll Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1996 John D. Polstra.
|
||||
|
@ -190,8 +190,8 @@ typedef struct Struct_Obj_Entry {
|
|||
Search_Path *rpaths; /* Search path specified in object */
|
||||
Needed_Entry *needed; /* Shared objects needed by this (%) */
|
||||
|
||||
Elf_Addr init; /* Initialization function to call */
|
||||
Elf_Addr fini; /* Termination function to call */
|
||||
fptr_t init; /* Initialization function to call */
|
||||
fptr_t fini; /* Termination function to call */
|
||||
|
||||
u_int32_t mainprog:1, /* True if this is the main program */
|
||||
rtld:1, /* True if this is the dynamic linker */
|
||||
|
@ -296,9 +296,9 @@ typedef struct Struct_Obj_Entry {
|
|||
int vertabnum; /* Number of entries in vertab */
|
||||
|
||||
/* init_array/fini_array */
|
||||
Elf_Addr *init_array; /* start of init array */
|
||||
fptr_t *init_array; /* start of init array */
|
||||
size_t init_arraysz; /* # of entries in it */
|
||||
Elf_Addr *fini_array; /* start of fini array */
|
||||
fptr_t *fini_array; /* start of fini array */
|
||||
size_t fini_arraysz; /* # of entries in it */
|
||||
/* IRELATIVE relocations */
|
||||
size_t ifunc_remaining;
|
||||
|
@ -505,14 +505,8 @@ Elf_Addr _rtld_function_descriptor_alloc(const Obj_Entry *,
|
|||
const Elf_Sym *, Elf_Addr);
|
||||
const void *_rtld_function_descriptor_function(const void *);
|
||||
|
||||
void _rtld_call_function_void(const Obj_Entry *, Elf_Addr);
|
||||
Elf_Addr _rtld_call_function_addr(const Obj_Entry *, Elf_Addr);
|
||||
#else
|
||||
static inline void
|
||||
_rtld_call_function_void(const Obj_Entry *obj, Elf_Addr addr)
|
||||
{
|
||||
((void (*)(void))addr)();
|
||||
}
|
||||
static inline Elf_Addr
|
||||
_rtld_call_function_addr(const Obj_Entry *obj, Elf_Addr addr)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue