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 Reset the COMBRELOC cache Obj_Entry if it ...



details:   https://anonhg.NetBSD.org/src/rev/46ac1478affb
branches:  trunk
changeset: 750667:46ac1478affb
user:      skrll <skrll%NetBSD.org@localhost>
date:      Sun Jan 10 07:29:47 2010 +0000

description:
Reset the COMBRELOC cache Obj_Entry if it was freed.

Fixes PR 41482. Done slightly differently to the patch in the PR.

diffstat:

 libexec/ld.elf_so/map_object.c |   7 +++++--
 libexec/ld.elf_so/rtld.h       |   5 ++++-
 libexec/ld.elf_so/symbol.c     |  26 ++++++++++++++++++++------
 3 files changed, 29 insertions(+), 9 deletions(-)

diffs (110 lines):

diff -r bd7246620387 -r 46ac1478affb libexec/ld.elf_so/map_object.c
--- a/libexec/ld.elf_so/map_object.c    Sun Jan 10 07:06:12 2010 +0000
+++ b/libexec/ld.elf_so/map_object.c    Sun Jan 10 07:29:47 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: map_object.c,v 1.38 2009/05/19 20:44:52 christos Exp $  */
+/*     $NetBSD: map_object.c,v 1.39 2010/01/10 07:29:47 skrll Exp $     */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -34,7 +34,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: map_object.c,v 1.38 2009/05/19 20:44:52 christos Exp $");
+__RCSID("$NetBSD: map_object.c,v 1.39 2010/01/10 07:29:47 skrll Exp $");
 #endif /* not lint */
 
 #include <errno.h>
@@ -325,6 +325,9 @@
                xfree(elm);
        }
        xfree(obj);
+#ifdef COMBRELOC
+       _rtld_combreloc_reset(obj);
+#endif
 }
 
 Obj_Entry *
diff -r bd7246620387 -r 46ac1478affb libexec/ld.elf_so/rtld.h
--- a/libexec/ld.elf_so/rtld.h  Sun Jan 10 07:06:12 2010 +0000
+++ b/libexec/ld.elf_so/rtld.h  Sun Jan 10 07:29:47 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtld.h,v 1.82 2009/11/17 18:44:33 skrll Exp $   */
+/*     $NetBSD: rtld.h,v 1.83 2010/01/10 07:29:47 skrll Exp $   */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -278,6 +278,9 @@
     const Obj_Entry *, const Obj_Entry **, bool);
 const Elf_Sym *_rtld_symlook_needed(const char *, unsigned long,
     const Needed_Entry *, const Obj_Entry **, bool);
+#ifdef COMBRELOC
+void _rtld_combreloc_reset(const Obj_Entry *);
+#endif
 
 /* map_object.c */
 Obj_Entry *_rtld_map_object(const char *, int, const struct stat *);
diff -r bd7246620387 -r 46ac1478affb libexec/ld.elf_so/symbol.c
--- a/libexec/ld.elf_so/symbol.c        Sun Jan 10 07:06:12 2010 +0000
+++ b/libexec/ld.elf_so/symbol.c        Sun Jan 10 07:29:47 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: symbol.c,v 1.48 2009/09/24 21:21:34 pooka Exp $         */
+/*     $NetBSD: symbol.c,v 1.49 2010/01/10 07:29:47 skrll Exp $         */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -40,7 +40,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: symbol.c,v 1.48 2009/09/24 21:21:34 pooka Exp $");
+__RCSID("$NetBSD: symbol.c,v 1.49 2010/01/10 07:29:47 skrll Exp $");
 #endif /* not lint */
 
 #include <err.h>
@@ -236,6 +236,21 @@
        return NULL;
 }
 
+#ifdef COMBRELOC
+static const Obj_Entry *_rtld_last_refobj;
+
+/*
+ * Called when an object is freed. Reset the cached symbol look up if
+ * our last referencing or definition object just got unloaded.
+ */
+void
+_rtld_combreloc_reset(const Obj_Entry *obj)
+{
+       if (_rtld_last_refobj == obj)
+               _rtld_last_refobj = NULL;
+}
+#endif
+
 /*
  * Given a symbol number in a referencing object, find the corresponding
  * definition of the symbol.  Returns a pointer to the symbol, or NULL if
@@ -261,11 +276,10 @@
         * return the cached results.
         */
        static unsigned long last_symnum;
+       static const Obj_Entry *last_defobj;
        static const Elf_Sym *last_def;
-       static const Obj_Entry *last_refobj;
-       static const Obj_Entry *last_defobj;
 
-       if (symnum == last_symnum && refobj == last_refobj
+       if (symnum == last_symnum && refobj == _rtld_last_refobj
            && in_plt == false) {
                *defobj_out = last_defobj;
                return last_def;
@@ -319,7 +333,7 @@
                         * non-PLT lookup.
                         */
                        last_symnum = symnum;
-                       last_refobj = refobj;
+                       _rtld_last_refobj = refobj;
                        last_def = def;
                        last_defobj = defobj;
                }



Home | Main Index | Thread Index | Old Index