]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
[BZ #9733]
authorUlrich Drepper <drepper@redhat.com>
Mon, 16 Mar 2009 02:16:30 +0000 (02:16 +0000)
committerUlrich Drepper <drepper@redhat.com>
Mon, 16 Mar 2009 02:16:30 +0000 (02:16 +0000)
* elf/dl-load.c (_dl_map_object_from_fd): Only call audit hooks
if we are not loading a new audit library.
* elf/dl-reloc (_dl_relocate_object): Third parameter is now a bitmask.
Only use profiling trampoline for auditing if we are not relocating
an audit library.
* elf/dl-open.c (dl_open_worker): Adjust _dl_relocate_object call.
* elf/rtld.c: Likewise.
* sysdeps/generic/ldsodefs.h: Adjust _dl_relocate_object prototype.

ChangeLog
elf/dl-load.c
elf/dl-open.c
elf/dl-reloc.c
elf/rtld.c
sysdeps/generic/ldsodefs.h

index 82bd124a4e1fd9c1f5b18a92986ead562145bd57..8911e9750d4f7a24ee6e42320a5a952795c180d5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2009-03-15  Ulrich Drepper  <drepper@redhat.com>
 
+       [BZ #9733]
+       * elf/dl-load.c (_dl_map_object_from_fd): Only call audit hooks
+       if we are not loading a new audit library.
+       * elf/dl-reloc (_dl_relocate_object): Third parameter is now a bitmask.
+       Only use profiling trampoline for auditing if we are not relocating
+       an audit library.
+       * elf/dl-open.c (dl_open_worker): Adjust _dl_relocate_object call.
+       * elf/rtld.c: Likewise.
+       * sysdeps/generic/ldsodefs.h: Adjust _dl_relocate_object prototype.
+
        * elf/rtld.c (dl_main): Extend help message for --audit option.
 
        [BZ #9759]
index c77c25915671624e967584e28e967dc9443bbd77..0deb51e445d53426e0523c436129329f71ed15f6 100644 (file)
@@ -941,7 +941,8 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp,
     {
 #ifdef SHARED
       /* Auditing checkpoint: we are going to add new objects.  */
-      if (__builtin_expect (GLRO(dl_naudit) > 0, 0))
+      if ((mode & __RTLD_AUDIT) == 0
+         && __builtin_expect (GLRO(dl_naudit) > 0, 0))
        {
          struct link_map *head = GL(dl_ns)[nsid]._ns_loaded;
          /* Do not call the functions for any auditing object.  */
index f825aa0437fa8175af1b7e3dff6a6771b21cdd65..75dc7bc406fd0bf3907ed0113d9f1d92024c56e3 100644 (file)
@@ -1,5 +1,5 @@
 /* Load a shared object at runtime, relocate it, and run its initializer.
-   Copyright (C) 1996-2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+   Copyright (C) 1996-2007, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -207,7 +207,6 @@ dl_open_worker (void *a)
   const char *file = args->file;
   int mode = args->mode;
   struct link_map *new;
-  int lazy;
   unsigned int i;
   bool any_tls = false;
   struct link_map *call_map = NULL;
@@ -366,7 +365,9 @@ dl_open_worker (void *a)
   _dl_debug_state ();
 
   /* Only do lazy relocation if `LD_BIND_NOW' is not set.  */
-  lazy = (mode & RTLD_BINDING_MASK) == RTLD_LAZY && GLRO(dl_lazy);
+  int reloc_mode = mode & __RTLD_AUDIT;
+  if (GLRO(dl_lazy))
+    reloc_mode |= mode & RTLD_LAZY;
 
   /* Relocate the objects loaded.  We do this in reverse order so that copy
      relocs of earlier objects overwrite the data written by later objects.  */
@@ -388,7 +389,7 @@ dl_open_worker (void *a)
                 start the profiling.  */
              struct link_map *old_profile_map = GL(dl_profile_map);
 
-             _dl_relocate_object (l, l->l_scope, 1, 1);
+             _dl_relocate_object (l, l->l_scope, reloc_mode | RTLD_LAZY, 1);
 
              if (old_profile_map == NULL && GL(dl_profile_map) != NULL)
                {
@@ -401,7 +402,7 @@ dl_open_worker (void *a)
            }
          else
 #endif
-           _dl_relocate_object (l, l->l_scope, lazy, 0);
+           _dl_relocate_object (l, l->l_scope, reloc_mode, 0);
        }
 
       if (l == new)
index a303cb4ce63c74a01875891a991b69130b6d2027..28f08de3e71c6a3572428b293986c24f6ed6ce61 100644 (file)
@@ -1,5 +1,5 @@
 /* Relocate a shared object and resolve its references to other loaded objects.
-   Copyright (C) 1995-2004, 2005, 2006, 2008 Free Software Foundation, Inc.
+   Copyright (C) 1995-2006, 2008, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -151,7 +151,7 @@ _dl_nothread_init_static_tls (struct link_map *map)
 
 void
 _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
-                    int lazy, int consider_profiling)
+                    int reloc_mode, int consider_profiling)
 {
   struct textrels
   {
@@ -162,10 +162,12 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
   } *textrels = NULL;
   /* Initialize it to make the compiler happy.  */
   const char *errstring = NULL;
+  int lazy = reloc_mode & RTLD_LAZY;
 
 #ifdef SHARED
   /* If we are auditing, install the same handlers we need for profiling.  */
-  consider_profiling |= GLRO(dl_audit) != NULL;
+  if ((reloc_mode & __RTLD_AUDIT) == 0)
+    consider_profiling |= GLRO(dl_audit) != NULL;
 #elif defined PROF
   /* Never use dynamic linker profiling for gprof profiling code.  */
 # define consider_profiling 0
index 5282d2c71f248a7b304eb0b0d1a41ed7809101fc..bfe956446361a399703f0e22f9e1cdf0d99834f3 100644 (file)
@@ -574,7 +574,7 @@ _dl_start (void *arg)
 struct relocate_args
 {
   struct link_map *l;
-  int lazy;
+  int reloc_mode;
 };
 
 struct map_args
@@ -613,7 +613,7 @@ relocate_doit (void *a)
 {
   struct relocate_args *args = (struct relocate_args *) a;
 
-  _dl_relocate_object (args->l, args->l->l_scope, args->lazy, 0);
+  _dl_relocate_object (args->l, args->l->l_scope, args->reloc_mode, 0);
 }
 
 static void
@@ -1909,7 +1909,9 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
          struct link_map *l = main_map;
 
          /* Relocate the main executable.  */
-         struct relocate_args args = { .l = l, .lazy = GLRO(dl_lazy) };
+         struct relocate_args args = { .l = l,
+                                       .reloc_mode = (GLRO(dl_lazy)
+                                                      ? RTLD_LAZY : 0) };
          _dl_receive_error (print_unresolved, relocate_doit, &args);
 
          /* This loop depends on the dependencies of the executable to
@@ -1986,7 +1988,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
              struct relocate_args args;
              struct link_map *l;
 
-             args.lazy = GLRO(dl_lazy);
+             args.reloc_mode = GLRO(dl_lazy) ? RTLD_LAZY : 0;
 
              l = main_map;
              while (l->l_next != NULL)
@@ -2226,7 +2228,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
            }
 
          if (l != &GL(dl_rtld_map))
-           _dl_relocate_object (l, l->l_scope, GLRO(dl_lazy),
+           _dl_relocate_object (l, l->l_scope, GLRO(dl_lazy) ? RTLD_LAZY : 0,
                                 consider_profiling);
 
          /* Add object to slot information data if necessasy.  */
index e00b173f490a5a5686ca2c697fb2336195bd6ec7..943369bb24e1a6d201e64071279b047b5a6e837b 100644 (file)
@@ -882,10 +882,10 @@ extern struct link_map *_dl_new_object (char *realname, const char *libname,
 
 /* Relocate the given object (if it hasn't already been).
    SCOPE is passed to _dl_lookup_symbol in symbol lookups.
-   If LAZY is nonzero, don't relocate its PLT.  */
+   If RTLD_LAZY is set in RELOC-MODE, don't relocate its PLT.  */
 extern void _dl_relocate_object (struct link_map *map,
                                 struct r_scope_elem *scope[],
-                                int lazy, int consider_profiling)
+                                int reloc_mode, int consider_profiling)
      attribute_hidden;
 
 /* Protect PT_GNU_RELRO area.  */