ce426f
commit a1b85ae88b1a664e93ca0182c82f7763dd5a1754
ce426f
Author: Florian Weimer <fweimer@redhat.com>
ce426f
Date:   Mon Nov 9 16:52:31 2015 +0100
ce426f
ce426f
    ld.so: Add original DSO name if overridden by audit module [BZ #18251]
ce426f
ce426f
Index: b/elf/Makefile
ce426f
===================================================================
ce426f
--- a/elf/Makefile
ce426f
+++ b/elf/Makefile
ce426f
@@ -119,7 +119,8 @@ $(inst_auditdir)/sotruss-lib.so: $(objpf
ce426f
 endif
ce426f
 
ce426f
 tests = tst-tls1 tst-tls2 tst-tls9 tst-leaks1 \
ce426f
-	tst-array1 tst-array2 tst-array3 tst-array4 tst-array5
ce426f
+	tst-array1 tst-array2 tst-array3 tst-array4 tst-array5 \
ce426f
+	tst-audit11 tst-audit12
ce426f
 tests-static = tst-tls1-static tst-tls2-static tst-stackguard1-static \
ce426f
 	       tst-leaks1-static tst-array1-static tst-array5-static \
ce426f
 	       tst-ptrguard1-static
ce426f
@@ -216,7 +217,9 @@ modules-names = testobj1 testobj2 testob
ce426f
 		tst-initorder2a tst-initorder2b tst-initorder2c \
ce426f
 		tst-initorder2d \
ce426f
 		tst-relsort1mod1 tst-relsort1mod2 tst-array2dep \
ce426f
-		tst-array5dep
ce426f
+		tst-array5dep \
ce426f
+		tst-audit11mod1 tst-audit11mod2 tst-auditmod11 \
ce426f
+		tst-audit12mod1 tst-audit12mod2 tst-audit12mod3 tst-auditmod12
ce426f
 ifeq (yesyes,$(have-fpie)$(build-shared))
ce426f
 modules-names += tst-piemod1
ce426f
 tests += tst-pie1
ce426f
@@ -1210,3 +1213,15 @@ $(objpfx)tst-unused-dep.out: $(objpfx)te
ce426f
 	  --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
ce426f
 	  $< > $@
ce426f
 	cmp $@ /dev/null > /dev/null
ce426f
+
ce426f
+$(objpfx)tst-audit11.out: $(objpfx)tst-auditmod11.so $(objpfx)tst-audit11mod1.so
ce426f
+$(objpfx)tst-audit11: $(libdl)
ce426f
+tst-audit11-ENV = LD_AUDIT=$(objpfx)tst-auditmod11.so
ce426f
+$(objpfx)tst-audit11mod1.so: $(objpfx)tst-audit11mod2.so
ce426f
+LDFLAGS-tst-audit11mod2.so = -Wl,--version-script=tst-audit11mod2.map,-soname,tst-audit11mod2.so
ce426f
+
ce426f
+$(objpfx)tst-audit12.out: $(objpfx)tst-auditmod12.so $(objpfx)tst-audit12mod1.so $(objpfx)tst-audit12mod3.so
ce426f
+$(objpfx)tst-audit12: $(libdl)
ce426f
+tst-audit12-ENV = LD_AUDIT=$(objpfx)tst-auditmod12.so
ce426f
+$(objpfx)tst-audit12mod1.so: $(objpfx)tst-audit12mod2.so
ce426f
+LDFLAGS-tst-audit12mod2.so = -Wl,--version-script=tst-audit12mod2.map
ce426f
Index: b/elf/dl-load.c
ce426f
===================================================================
ce426f
--- a/elf/dl-load.c
ce426f
+++ b/elf/dl-load.c
ce426f
@@ -909,9 +909,10 @@ lose (int code, int fd, const char *name
ce426f
 static
ce426f
 #endif
ce426f
 struct link_map *
ce426f
-_dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp,
ce426f
-			char *realname, struct link_map *loader, int l_type,
ce426f
-			int mode, void **stack_endp, Lmid_t nsid)
ce426f
+_dl_map_object_from_fd (const char *name, const char *origname, int fd,
ce426f
+			struct filebuf *fbp, char *realname,
ce426f
+			struct link_map *loader, int l_type, int mode,
ce426f
+			void **stack_endp, Lmid_t nsid)
ce426f
 {
ce426f
   struct link_map *l = NULL;
ce426f
   const ElfW(Ehdr) *header;
ce426f
@@ -1582,6 +1583,17 @@ cannot enable executable stack as shared
ce426f
   l->l_dev = st.st_dev;
ce426f
   l->l_ino = st.st_ino;
ce426f
 
ce426f
+#ifdef SHARED
ce426f
+  /* When auditing is used the recorded names might not include the
ce426f
+     name by which the DSO is actually known.  Add that as well.  */
ce426f
+  if (__glibc_unlikely (origname != NULL))
ce426f
+    add_name_to_object (l, origname);
ce426f
+#else
ce426f
+  /* Audit modules only exist when linking is dynamic so ORIGNAME
ce426f
+     cannot be non-NULL.  */
ce426f
+  assert (origname == NULL);
ce426f
+#endif
ce426f
+
ce426f
   /* When we profile the SONAME might be needed for something else but
ce426f
      loading.  Add it right away.  */
ce426f
   if (__builtin_expect (GLRO(dl_profile) != NULL, 0)
ce426f
@@ -2081,6 +2093,7 @@ _dl_map_object (struct link_map *loader,
ce426f
 		int type, int trace_mode, int mode, Lmid_t nsid)
ce426f
 {
ce426f
   int fd;
ce426f
+  const char *origname = NULL;
ce426f
   char *realname;
ce426f
   char *name_copy;
ce426f
   struct link_map *l;
ce426f
@@ -2144,6 +2157,7 @@ _dl_map_object (struct link_map *loader,
ce426f
 	{
ce426f
 	  if (afct->objsearch != NULL)
ce426f
 	    {
ce426f
+	      const char *before = name;
ce426f
 	      name = afct->objsearch (name, &loader->l_audit[cnt].cookie,
ce426f
 				      LA_SER_ORIG);
ce426f
 	      if (name == NULL)
ce426f
@@ -2152,6 +2166,15 @@ _dl_map_object (struct link_map *loader,
ce426f
 		  fd = -1;
ce426f
 		  goto no_file;
ce426f
 		}
ce426f
+	      if (before != name && strcmp (before, name) != 0)
ce426f
+		{
ce426f
+		  if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_FILES))
ce426f
+		    _dl_debug_printf ("audit changed filename %s -> %s\n",
ce426f
+				      before, name);
ce426f
+
ce426f
+		  if (origname == NULL)
ce426f
+		    origname = before;
ce426f
+		}
ce426f
 	    }
ce426f
 
ce426f
 	  afct = afct->next;
ce426f
@@ -2371,8 +2394,8 @@ _dl_map_object (struct link_map *loader,
ce426f
     }
ce426f
 
ce426f
   void *stack_end = __libc_stack_end;
ce426f
-  return _dl_map_object_from_fd (name, fd, &fb, realname, loader, type, mode,
ce426f
-				 &stack_end, nsid);
ce426f
+  return _dl_map_object_from_fd (name, origname, fd, &fb, realname, loader,
ce426f
+				 type, mode, &stack_end, nsid);
ce426f
 }
ce426f
 
ce426f
 
ce426f
Index: b/elf/tst-audit11.c
ce426f
===================================================================
ce426f
--- /dev/null
ce426f
+++ b/elf/tst-audit11.c
ce426f
@@ -0,0 +1,36 @@
ce426f
+/* Test version symbol binding can find a DSO replaced by la_objsearch.
ce426f
+   Copyright (C) 2015 Free Software Foundation, Inc.
ce426f
+   This file is part of the GNU C Library.
ce426f
+
ce426f
+   The GNU C Library is free software; you can redistribute it and/or
ce426f
+   modify it under the terms of the GNU Lesser General Public
ce426f
+   License as published by the Free Software Foundation; either
ce426f
+   version 2.1 of the License, or (at your option) any later version.
ce426f
+
ce426f
+   The GNU C Library is distributed in the hope that it will be useful,
ce426f
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
ce426f
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
ce426f
+   Lesser General Public License for more details.
ce426f
+
ce426f
+   You should have received a copy of the GNU Lesser General Public
ce426f
+   License along with the GNU C Library; if not, see
ce426f
+   <http://www.gnu.org/licenses/>.  */
ce426f
+
ce426f
+#include <dlfcn.h>
ce426f
+#include <stdio.h>
ce426f
+
ce426f
+int
ce426f
+do_test (void)
ce426f
+{
ce426f
+  puts ("Start");
ce426f
+  if (dlopen ("$ORIGIN/tst-audit11mod1.so", RTLD_LAZY) == NULL)
ce426f
+    {
ce426f
+      printf ("module not loaded: %s\n", dlerror ());
ce426f
+      return 1;
ce426f
+    }
ce426f
+  puts ("OK");
ce426f
+  return 0;
ce426f
+}
ce426f
+
ce426f
+#define TEST_FUNCTION do_test ()
ce426f
+#include "../test-skeleton.c"
ce426f
Index: b/elf/tst-audit11mod1.c
ce426f
===================================================================
ce426f
--- /dev/null
ce426f
+++ b/elf/tst-audit11mod1.c
ce426f
@@ -0,0 +1,24 @@
ce426f
+/* DSO directly opened by tst-audit11.
ce426f
+   Copyright (C) 2015 Free Software Foundation, Inc.
ce426f
+   This file is part of the GNU C Library.
ce426f
+
ce426f
+   The GNU C Library is free software; you can redistribute it and/or
ce426f
+   modify it under the terms of the GNU Lesser General Public
ce426f
+   License as published by the Free Software Foundation; either
ce426f
+   version 2.1 of the License, or (at your option) any later version.
ce426f
+
ce426f
+   The GNU C Library is distributed in the hope that it will be useful,
ce426f
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
ce426f
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
ce426f
+   Lesser General Public License for more details.
ce426f
+
ce426f
+   You should have received a copy of the GNU Lesser General Public
ce426f
+   License along with the GNU C Library; if not, see
ce426f
+   <http://www.gnu.org/licenses/>.  */
ce426f
+
ce426f
+extern int f2 (void);
ce426f
+int
ce426f
+f1 (void)
ce426f
+{
ce426f
+  return f2 ();
ce426f
+}
ce426f
Index: b/elf/tst-audit11mod2.c
ce426f
===================================================================
ce426f
--- /dev/null
ce426f
+++ b/elf/tst-audit11mod2.c
ce426f
@@ -0,0 +1,23 @@
ce426f
+/* DSO indirectly opened by tst-audit11, with symbol versioning.
ce426f
+   Copyright (C) 2015 Free Software Foundation, Inc.
ce426f
+   This file is part of the GNU C Library.
ce426f
+
ce426f
+   The GNU C Library is free software; you can redistribute it and/or
ce426f
+   modify it under the terms of the GNU Lesser General Public
ce426f
+   License as published by the Free Software Foundation; either
ce426f
+   version 2.1 of the License, or (at your option) any later version.
ce426f
+
ce426f
+   The GNU C Library is distributed in the hope that it will be useful,
ce426f
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
ce426f
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
ce426f
+   Lesser General Public License for more details.
ce426f
+
ce426f
+   You should have received a copy of the GNU Lesser General Public
ce426f
+   License along with the GNU C Library; if not, see
ce426f
+   <http://www.gnu.org/licenses/>.  */
ce426f
+
ce426f
+int
ce426f
+f2 (void)
ce426f
+{
ce426f
+  return 42;
ce426f
+}
ce426f
Index: b/elf/tst-audit11mod2.map
ce426f
===================================================================
ce426f
--- /dev/null
ce426f
+++ b/elf/tst-audit11mod2.map
ce426f
@@ -0,0 +1,22 @@
ce426f
+/* Symbol versioning for the DSO indirectly opened by tst-audit11.
ce426f
+   Copyright (C) 2015 Free Software Foundation, Inc.
ce426f
+   This file is part of the GNU C Library.
ce426f
+
ce426f
+   The GNU C Library is free software; you can redistribute it and/or
ce426f
+   modify it under the terms of the GNU Lesser General Public
ce426f
+   License as published by the Free Software Foundation; either
ce426f
+   version 2.1 of the License, or (at your option) any later version.
ce426f
+
ce426f
+   The GNU C Library is distributed in the hope that it will be useful,
ce426f
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
ce426f
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
ce426f
+   Lesser General Public License for more details.
ce426f
+
ce426f
+   You should have received a copy of the GNU Lesser General Public
ce426f
+   License along with the GNU C Library; if not, see
ce426f
+   <http://www.gnu.org/licenses/>.  */
ce426f
+
ce426f
+V1 {
ce426f
+  global: f2;
ce426f
+  local: *;
ce426f
+};
ce426f
Index: b/elf/tst-audit12.c
ce426f
===================================================================
ce426f
--- /dev/null
ce426f
+++ b/elf/tst-audit12.c
ce426f
@@ -0,0 +1,49 @@
ce426f
+/* Test that symbol is bound to a DSO replaced by la_objsearch.
ce426f
+   Copyright (C) 2015 Free Software Foundation, Inc.
ce426f
+   This file is part of the GNU C Library.
ce426f
+
ce426f
+   The GNU C Library is free software; you can redistribute it and/or
ce426f
+   modify it under the terms of the GNU Lesser General Public
ce426f
+   License as published by the Free Software Foundation; either
ce426f
+   version 2.1 of the License, or (at your option) any later version.
ce426f
+
ce426f
+   The GNU C Library is distributed in the hope that it will be useful,
ce426f
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
ce426f
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
ce426f
+   Lesser General Public License for more details.
ce426f
+
ce426f
+   You should have received a copy of the GNU Lesser General Public
ce426f
+   License along with the GNU C Library; if not, see
ce426f
+   <http://www.gnu.org/licenses/>.  */
ce426f
+
ce426f
+#include <dlfcn.h>
ce426f
+#include <stdio.h>
ce426f
+
ce426f
+int
ce426f
+do_test (void)
ce426f
+{
ce426f
+  puts ("Start");
ce426f
+  void *h = dlopen ("$ORIGIN/tst-audit12mod1.so", RTLD_LAZY);
ce426f
+  if (h == NULL)
ce426f
+    {
ce426f
+      printf ("module not loaded: %s\n", dlerror ());
ce426f
+      return 1;
ce426f
+    }
ce426f
+  int (*fp) (void) = (int (*) (void)) dlsym (h, "f1");
ce426f
+  if (fp == NULL)
ce426f
+    {
ce426f
+      printf ("function f1 not found: %s\n", dlerror ());
ce426f
+      return 1;
ce426f
+    }
ce426f
+  int res = fp ();
ce426f
+  if (res != 43)
ce426f
+    {
ce426f
+      puts ("incorrect function f2 called");
ce426f
+      return 1;
ce426f
+    }
ce426f
+  printf ("%d is OK\n", res);
ce426f
+  return 0;
ce426f
+}
ce426f
+
ce426f
+#define TEST_FUNCTION do_test ()
ce426f
+#include "../test-skeleton.c"
ce426f
Index: b/elf/tst-audit12mod1.c
ce426f
===================================================================
ce426f
--- /dev/null
ce426f
+++ b/elf/tst-audit12mod1.c
ce426f
@@ -0,0 +1,24 @@
ce426f
+/* DSO directly opened by tst-audit12.
ce426f
+   Copyright (C) 2015 Free Software Foundation, Inc.
ce426f
+   This file is part of the GNU C Library.
ce426f
+
ce426f
+   The GNU C Library is free software; you can redistribute it and/or
ce426f
+   modify it under the terms of the GNU Lesser General Public
ce426f
+   License as published by the Free Software Foundation; either
ce426f
+   version 2.1 of the License, or (at your option) any later version.
ce426f
+
ce426f
+   The GNU C Library is distributed in the hope that it will be useful,
ce426f
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
ce426f
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
ce426f
+   Lesser General Public License for more details.
ce426f
+
ce426f
+   You should have received a copy of the GNU Lesser General Public
ce426f
+   License along with the GNU C Library; if not, see
ce426f
+   <http://www.gnu.org/licenses/>.  */
ce426f
+
ce426f
+extern int f2 (void);
ce426f
+int
ce426f
+f1 (void)
ce426f
+{
ce426f
+  return f2 ();
ce426f
+}
ce426f
Index: b/elf/tst-audit12mod2.c
ce426f
===================================================================
ce426f
--- /dev/null
ce426f
+++ b/elf/tst-audit12mod2.c
ce426f
@@ -0,0 +1,23 @@
ce426f
+/* Replaced DSO referenced by tst-audit12mod1.so, for tst-audit12.
ce426f
+   Copyright (C) 2015 Free Software Foundation, Inc.
ce426f
+   This file is part of the GNU C Library.
ce426f
+
ce426f
+   The GNU C Library is free software; you can redistribute it and/or
ce426f
+   modify it under the terms of the GNU Lesser General Public
ce426f
+   License as published by the Free Software Foundation; either
ce426f
+   version 2.1 of the License, or (at your option) any later version.
ce426f
+
ce426f
+   The GNU C Library is distributed in the hope that it will be useful,
ce426f
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
ce426f
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
ce426f
+   Lesser General Public License for more details.
ce426f
+
ce426f
+   You should have received a copy of the GNU Lesser General Public
ce426f
+   License along with the GNU C Library; if not, see
ce426f
+   <http://www.gnu.org/licenses/>.  */
ce426f
+
ce426f
+int
ce426f
+f2 (void)
ce426f
+{
ce426f
+  return 42;
ce426f
+}
ce426f
Index: b/elf/tst-audit12mod2.map
ce426f
===================================================================
ce426f
--- /dev/null
ce426f
+++ b/elf/tst-audit12mod2.map
ce426f
@@ -0,0 +1,22 @@
ce426f
+/* Symbol versioning for tst-audit12mod2.so used by tst-audit12.
ce426f
+   Copyright (C) 2015 Free Software Foundation, Inc.
ce426f
+   This file is part of the GNU C Library.
ce426f
+
ce426f
+   The GNU C Library is free software; you can redistribute it and/or
ce426f
+   modify it under the terms of the GNU Lesser General Public
ce426f
+   License as published by the Free Software Foundation; either
ce426f
+   version 2.1 of the License, or (at your option) any later version.
ce426f
+
ce426f
+   The GNU C Library is distributed in the hope that it will be useful,
ce426f
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
ce426f
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
ce426f
+   Lesser General Public License for more details.
ce426f
+
ce426f
+   You should have received a copy of the GNU Lesser General Public
ce426f
+   License along with the GNU C Library; if not, see
ce426f
+   <http://www.gnu.org/licenses/>.  */
ce426f
+
ce426f
+V1 {
ce426f
+  global: f2;
ce426f
+  local: *;
ce426f
+};
ce426f
Index: b/elf/tst-audit12mod3.c
ce426f
===================================================================
ce426f
--- /dev/null
ce426f
+++ b/elf/tst-audit12mod3.c
ce426f
@@ -0,0 +1,23 @@
ce426f
+/* Replacement DSO loaded by the audit module, for tst-audit12.
ce426f
+   Copyright (C) 2015 Free Software Foundation, Inc.
ce426f
+   This file is part of the GNU C Library.
ce426f
+
ce426f
+   The GNU C Library is free software; you can redistribute it and/or
ce426f
+   modify it under the terms of the GNU Lesser General Public
ce426f
+   License as published by the Free Software Foundation; either
ce426f
+   version 2.1 of the License, or (at your option) any later version.
ce426f
+
ce426f
+   The GNU C Library is distributed in the hope that it will be useful,
ce426f
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
ce426f
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
ce426f
+   Lesser General Public License for more details.
ce426f
+
ce426f
+   You should have received a copy of the GNU Lesser General Public
ce426f
+   License along with the GNU C Library; if not, see
ce426f
+   <http://www.gnu.org/licenses/>.  */
ce426f
+
ce426f
+int
ce426f
+f2 (void)
ce426f
+{
ce426f
+  return 43;
ce426f
+}
ce426f
Index: b/elf/tst-auditmod11.c
ce426f
===================================================================
ce426f
--- /dev/null
ce426f
+++ b/elf/tst-auditmod11.c
ce426f
@@ -0,0 +1,39 @@
ce426f
+/* Audit module for tst-audit11.
ce426f
+   Copyright (C) 2015 Free Software Foundation, Inc.
ce426f
+   This file is part of the GNU C Library.
ce426f
+
ce426f
+   The GNU C Library is free software; you can redistribute it and/or
ce426f
+   modify it under the terms of the GNU Lesser General Public
ce426f
+   License as published by the Free Software Foundation; either
ce426f
+   version 2.1 of the License, or (at your option) any later version.
ce426f
+
ce426f
+   The GNU C Library is distributed in the hope that it will be useful,
ce426f
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
ce426f
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
ce426f
+   Lesser General Public License for more details.
ce426f
+
ce426f
+   You should have received a copy of the GNU Lesser General Public
ce426f
+   License along with the GNU C Library; if not, see
ce426f
+   <http://www.gnu.org/licenses/>.  */
ce426f
+
ce426f
+#include <link.h>
ce426f
+#include <stdio.h>
ce426f
+#include <stdlib.h>
ce426f
+#include <string.h>
ce426f
+#include <unistd.h>
ce426f
+
ce426f
+unsigned int
ce426f
+la_version (unsigned int version)
ce426f
+{
ce426f
+  return version;
ce426f
+}
ce426f
+
ce426f
+char *
ce426f
+la_objsearch (const char *name, uintptr_t *cookie, unsigned int flag)
ce426f
+{
ce426f
+  if (strcmp (name, "tst-audit11mod2.so") == 0)
ce426f
+    {
ce426f
+      return (char *) "$ORIGIN/tst-audit11mod2.so";
ce426f
+    }
ce426f
+  return (char *) name;
ce426f
+}
ce426f
Index: b/elf/tst-auditmod12.c
ce426f
===================================================================
ce426f
--- /dev/null
ce426f
+++ b/elf/tst-auditmod12.c
ce426f
@@ -0,0 +1,43 @@
ce426f
+/* Audit module for tst-audit12.
ce426f
+   Copyright (C) 2015 Free Software Foundation, Inc.
ce426f
+   This file is part of the GNU C Library.
ce426f
+
ce426f
+   The GNU C Library is free software; you can redistribute it and/or
ce426f
+   modify it under the terms of the GNU Lesser General Public
ce426f
+   License as published by the Free Software Foundation; either
ce426f
+   version 2.1 of the License, or (at your option) any later version.
ce426f
+
ce426f
+   The GNU C Library is distributed in the hope that it will be useful,
ce426f
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
ce426f
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
ce426f
+   Lesser General Public License for more details.
ce426f
+
ce426f
+   You should have received a copy of the GNU Lesser General Public
ce426f
+   License along with the GNU C Library; if not, see
ce426f
+   <http://www.gnu.org/licenses/>.  */
ce426f
+
ce426f
+#include <link.h>
ce426f
+#include <stdio.h>
ce426f
+#include <stdlib.h>
ce426f
+#include <string.h>
ce426f
+#include <unistd.h>
ce426f
+
ce426f
+unsigned int
ce426f
+la_version (unsigned int version)
ce426f
+{
ce426f
+  return version;
ce426f
+}
ce426f
+
ce426f
+char *
ce426f
+la_objsearch (const char *name, uintptr_t *cookie, unsigned int flag)
ce426f
+{
ce426f
+  const char target[] = "tst-audit12mod2.so";
ce426f
+
ce426f
+  size_t namelen = strlen (name);
ce426f
+  if (namelen >= sizeof (target) - 1
ce426f
+      && strcmp (name + namelen - (sizeof (target) - 1), target) == 0)
ce426f
+    {
ce426f
+      return (char *) "$ORIGIN/tst-audit12mod3.so";
ce426f
+    }
ce426f
+  return (char *) name;
ce426f
+}
ce426f
Index: b/sysdeps/mach/hurd/dl-sysdep.c
ce426f
===================================================================
ce426f
--- a/sysdeps/mach/hurd/dl-sysdep.c
ce426f
+++ b/sysdeps/mach/hurd/dl-sysdep.c
ce426f
@@ -187,7 +187,7 @@ unfmh();			/* XXX */
ce426f
 	    assert_perror (err);
ce426f
 
ce426f
 	    lastslash = strrchr (p, '/');
ce426f
-	    l = _dl_map_object_from_fd (lastslash ? lastslash + 1 : p,
ce426f
+	    l = _dl_map_object_from_fd (lastslash ? lastslash + 1 : p, NULL,
ce426f
 					memobj, strdup (p), 0);
ce426f
 
ce426f
 	    /* Squirrel away the memory object port where it