Fixed handling of DT_SONAME:
- add function to add name aliases for shared libraries loaded XXX[1]: we don't add a name during load time, only when DT_SONAME is present. - search already loaded objects in load_by_name for an already loaded object that matches our name and return it. - add missing initialization and cleanup for obj->names XXX[2]: should we make them SIMPLEQ? - Add XXX in rtld.c about getting the name of an object. NB: This makes the jdk work again without resorting to a hack of putting the build path of libjvm.so into the run path (which is a security problem). XXX: Pullup-6?
This commit is contained in:
parent
22ece21cc4
commit
a3fedff4d1
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: headers.c,v 1.50 2013/05/06 08:02:20 skrll Exp $ */
|
||||
/* $NetBSD: headers.c,v 1.51 2013/05/06 19:59:29 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1996 John D. Polstra.
|
||||
|
@ -40,7 +40,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: headers.c,v 1.50 2013/05/06 08:02:20 skrll Exp $");
|
||||
__RCSID("$NetBSD: headers.c,v 1.51 2013/05/06 19:59:29 christos Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <err.h>
|
||||
|
@ -68,6 +68,7 @@ _rtld_digest_dynamic(const char *execname, Obj_Entry *obj)
|
|||
{
|
||||
Elf_Dyn *dynp;
|
||||
Needed_Entry **needed_tail = &obj->needed;
|
||||
const Elf_Dyn *dyn_soname = NULL;
|
||||
const Elf_Dyn *dyn_rpath = NULL;
|
||||
bool use_pltrel = false;
|
||||
bool use_pltrela = false;
|
||||
|
@ -222,7 +223,7 @@ _rtld_digest_dynamic(const char *execname, Obj_Entry *obj)
|
|||
break;
|
||||
|
||||
case DT_SONAME:
|
||||
/* Not used by the dynamic linker. */
|
||||
dyn_soname = dynp;
|
||||
break;
|
||||
|
||||
case DT_INIT:
|
||||
|
@ -358,6 +359,10 @@ _rtld_digest_dynamic(const char *execname, Obj_Entry *obj)
|
|||
_rtld_add_paths(execname, &obj->rpaths, obj->strtab +
|
||||
dyn_rpath->d_un.d_val);
|
||||
}
|
||||
if (dyn_soname != NULL) {
|
||||
_rtld_object_add_name(obj, obj->strtab +
|
||||
dyn_soname->d_un.d_val);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: load.c,v 1.43 2013/05/06 08:02:20 skrll Exp $ */
|
||||
/* $NetBSD: load.c,v 1.44 2013/05/06 19:59:30 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1996 John D. Polstra.
|
||||
|
@ -40,7 +40,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: load.c,v 1.43 2013/05/06 08:02:20 skrll Exp $");
|
||||
__RCSID("$NetBSD: load.c,v 1.44 2013/05/06 19:59:30 christos Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <err.h>
|
||||
|
@ -199,7 +199,7 @@ _rtld_load_by_name(const char *name, Obj_Entry *obj, Needed_Entry **needed,
|
|||
int flags)
|
||||
{
|
||||
Library_Xform *x = _rtld_xforms;
|
||||
Obj_Entry *o = NULL;
|
||||
Obj_Entry *o;
|
||||
size_t j;
|
||||
ssize_t i;
|
||||
bool got = false;
|
||||
|
@ -210,6 +210,12 @@ _rtld_load_by_name(const char *name, Obj_Entry *obj, Needed_Entry **needed,
|
|||
} val;
|
||||
|
||||
dbg(("load by name %s %p", name, x));
|
||||
for (o = _rtld_objlist->next; o != NULL; o = o->next)
|
||||
if (_rtld_object_match_name(o, name)) {
|
||||
(*needed)->obj = o;
|
||||
return true;
|
||||
}
|
||||
|
||||
for (; x; x = x->next) {
|
||||
if (strcmp(x->name, name) != 0)
|
||||
continue;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: map_object.c,v 1.48 2013/05/06 08:02:20 skrll Exp $ */
|
||||
/* $NetBSD: map_object.c,v 1.49 2013/05/06 19:59:30 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1996 John D. Polstra.
|
||||
|
@ -34,7 +34,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: map_object.c,v 1.48 2013/05/06 08:02:20 skrll Exp $");
|
||||
__RCSID("$NetBSD: map_object.c,v 1.49 2013/05/06 19:59:30 christos Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <errno.h>
|
||||
|
@ -432,6 +432,11 @@ _rtld_obj_free(Obj_Entry *obj)
|
|||
obj->needed = needed->next;
|
||||
xfree(needed);
|
||||
}
|
||||
while (!STAILQ_EMPTY(&obj->names)) {
|
||||
Name_Entry *entry = STAILQ_FIRST(&obj->names);
|
||||
STAILQ_REMOVE_HEAD(&obj->names, link);
|
||||
free(entry);
|
||||
}
|
||||
while ((elm = SIMPLEQ_FIRST(&obj->dldags)) != NULL) {
|
||||
SIMPLEQ_REMOVE_HEAD(&obj->dldags, link);
|
||||
xfree(elm);
|
||||
|
@ -454,6 +459,7 @@ _rtld_obj_new(void)
|
|||
Obj_Entry *obj;
|
||||
|
||||
obj = CNEW(Obj_Entry);
|
||||
STAILQ_INIT(&obj->names);
|
||||
SIMPLEQ_INIT(&obj->dldags);
|
||||
SIMPLEQ_INIT(&obj->dagmembers);
|
||||
return obj;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rtld.c,v 1.165 2013/05/06 08:02:20 skrll Exp $ */
|
||||
/* $NetBSD: rtld.c,v 1.166 2013/05/06 19:59:30 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1996 John D. Polstra.
|
||||
|
@ -40,7 +40,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: rtld.c,v 1.165 2013/05/06 08:02:20 skrll Exp $");
|
||||
__RCSID("$NetBSD: rtld.c,v 1.166 2013/05/06 19:59:30 christos Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -1372,6 +1372,7 @@ dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *), void *pa
|
|||
|
||||
for (obj = _rtld_objlist; obj != NULL; obj = obj->next) {
|
||||
phdr_info.dlpi_addr = (Elf_Addr)obj->relocbase;
|
||||
/* XXX: wrong but not fixing it yet */
|
||||
phdr_info.dlpi_name = STAILQ_FIRST(&obj->names) ?
|
||||
STAILQ_FIRST(&obj->names)->name : obj->path;
|
||||
phdr_info.dlpi_phdr = obj->phdr;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rtld.h,v 1.114 2013/05/06 08:02:20 skrll Exp $ */
|
||||
/* $NetBSD: rtld.h,v 1.115 2013/05/06 19:59:30 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1996 John D. Polstra.
|
||||
|
@ -425,6 +425,7 @@ void _rtld_combreloc_reset(const Obj_Entry *);
|
|||
#endif
|
||||
|
||||
/* symver.c */
|
||||
void _rtld_object_add_name(Obj_Entry *, const char *);
|
||||
int _rtld_object_match_name(const Obj_Entry *, const char *);
|
||||
int _rtld_verify_object_versions(Obj_Entry *);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: symver.c,v 1.1 2011/06/25 05:45:12 nonaka Exp $ */
|
||||
/* $NetBSD: symver.c,v 1.2 2013/05/06 19:59:30 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright 1996, 1997, 1998, 1999, 2000 John D. Polstra.
|
||||
|
@ -59,7 +59,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: symver.c,v 1.1 2011/06/25 05:45:12 nonaka Exp $");
|
||||
__RCSID("$NetBSD: symver.c,v 1.2 2013/05/06 19:59:30 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/exec_elf.h>
|
||||
|
@ -68,6 +68,20 @@ __RCSID("$NetBSD: symver.c,v 1.1 2011/06/25 05:45:12 nonaka Exp $");
|
|||
#include "debug.h"
|
||||
#include "rtld.h"
|
||||
|
||||
void
|
||||
_rtld_object_add_name(Obj_Entry *obj, const char *name)
|
||||
{
|
||||
Name_Entry *entry;
|
||||
size_t len;
|
||||
|
||||
len = strlen(name);
|
||||
entry = xmalloc(sizeof(Name_Entry) + len);
|
||||
|
||||
if (entry != NULL) {
|
||||
strcpy(entry->name, name);
|
||||
STAILQ_INSERT_TAIL(&obj->names, entry, link);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
_rtld_object_match_name(const Obj_Entry *obj, const char *name)
|
||||
|
|
Loading…
Reference in New Issue