about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--elf/dl-load.c3
-rw-r--r--elf/dl-open.c11
-rw-r--r--elf/dl-reloc.c8
-rw-r--r--elf/rtld.c12
-rw-r--r--sysdeps/generic/ldsodefs.h4
6 files changed, 32 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 82bd124a4e..8911e9750d 100644
--- 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]
diff --git a/elf/dl-load.c b/elf/dl-load.c
index c77c259156..0deb51e445 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -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.  */
diff --git a/elf/dl-open.c b/elf/dl-open.c
index f825aa0437..75dc7bc406 100644
--- a/elf/dl-open.c
+++ b/elf/dl-open.c
@@ -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)
diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c
index a303cb4ce6..28f08de3e7 100644
--- a/elf/dl-reloc.c
+++ b/elf/dl-reloc.c
@@ -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
diff --git a/elf/rtld.c b/elf/rtld.c
index 5282d2c71f..bfe9564463 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -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.  */
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
index e00b173f49..943369bb24 100644
--- a/sysdeps/generic/ldsodefs.h
+++ b/sysdeps/generic/ldsodefs.h
@@ -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.  */