Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/libexec/ld.elf_so Fixed handling of DT_SONAME:
details: https://anonhg.NetBSD.org/src/rev/056da829f6c1
branches: trunk
changeset: 786667:056da829f6c1
user: christos <christos%NetBSD.org@localhost>
date: Mon May 06 19:59:29 2013 +0000
description:
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?
diffstat:
libexec/ld.elf_so/headers.c | 11 ++++++++---
libexec/ld.elf_so/load.c | 12 +++++++++---
libexec/ld.elf_so/map_object.c | 10 ++++++++--
libexec/ld.elf_so/rtld.c | 5 +++--
libexec/ld.elf_so/rtld.h | 3 ++-
libexec/ld.elf_so/symver.c | 18 ++++++++++++++++--
6 files changed, 46 insertions(+), 13 deletions(-)
diffs (206 lines):
diff -r 41afa12fab10 -r 056da829f6c1 libexec/ld.elf_so/headers.c
--- a/libexec/ld.elf_so/headers.c Mon May 06 18:53:40 2013 +0000
+++ b/libexec/ld.elf_so/headers.c Mon May 06 19:59:29 2013 +0000
@@ -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 @@
{
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 @@
break;
case DT_SONAME:
- /* Not used by the dynamic linker. */
+ dyn_soname = dynp;
break;
case DT_INIT:
@@ -358,6 +359,10 @@
_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);
+ }
}
/*
diff -r 41afa12fab10 -r 056da829f6c1 libexec/ld.elf_so/load.c
--- a/libexec/ld.elf_so/load.c Mon May 06 18:53:40 2013 +0000
+++ b/libexec/ld.elf_so/load.c Mon May 06 19:59:29 2013 +0000
@@ -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 @@
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 @@
} 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;
diff -r 41afa12fab10 -r 056da829f6c1 libexec/ld.elf_so/map_object.c
--- a/libexec/ld.elf_so/map_object.c Mon May 06 18:53:40 2013 +0000
+++ b/libexec/ld.elf_so/map_object.c Mon May 06 19:59:29 2013 +0000
@@ -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 @@
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 @@
Obj_Entry *obj;
obj = CNEW(Obj_Entry);
+ STAILQ_INIT(&obj->names);
SIMPLEQ_INIT(&obj->dldags);
SIMPLEQ_INIT(&obj->dagmembers);
return obj;
diff -r 41afa12fab10 -r 056da829f6c1 libexec/ld.elf_so/rtld.c
--- a/libexec/ld.elf_so/rtld.c Mon May 06 18:53:40 2013 +0000
+++ b/libexec/ld.elf_so/rtld.c Mon May 06 19:59:29 2013 +0000
@@ -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 @@
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;
diff -r 41afa12fab10 -r 056da829f6c1 libexec/ld.elf_so/rtld.h
--- a/libexec/ld.elf_so/rtld.h Mon May 06 18:53:40 2013 +0000
+++ b/libexec/ld.elf_so/rtld.h Mon May 06 19:59:29 2013 +0000
@@ -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 @@
#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 *);
diff -r 41afa12fab10 -r 056da829f6c1 libexec/ld.elf_so/symver.c
--- a/libexec/ld.elf_so/symver.c Mon May 06 18:53:40 2013 +0000
+++ b/libexec/ld.elf_so/symver.c Mon May 06 19:59:29 2013 +0000
@@ -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 @@
#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)
Home |
Main Index |
Thread Index |
Old Index