Subject: Re: toolchain/32074
To: None <gnats-bugs@netbsd.org>
From: Nick Hudson <skrll@netbsd.org>
List: netbsd-bugs
Date: 01/12/2006 07:49:26
--Boundary-00=_GogxDYeAWYxv7Wn
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On Wednesday 11 January 2006 23:30, Valeriy E. Ushakov wrote:
>  FreeBSD fixed that in 1998:
>
>  http://www.freebsd.org/cgi/cvsweb.cgi/src/libexec/rtld-elf/rtld.c#rev1.10

Here's a diff to our rtld.c. It works - are we happy to go with this solution?

Nick

--Boundary-00=_GogxDYeAWYxv7Wn
Content-Type: text/x-diff;
  charset="iso-8859-1";
  name="rtld.c.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="rtld.c.diff"

Index: libexec/ld.elf_so/rtld.c
===================================================================
RCS file: /cvsroot/src/libexec/ld.elf_so/rtld.c,v
retrieving revision 1.107
diff -u -p -u -r1.107 rtld.c
--- libexec/ld.elf_so/rtld.c	22 Oct 2004 05:39:57 -0000	1.107
+++ libexec/ld.elf_so/rtld.c	12 Jan 2006 07:37:47 -0000
@@ -869,10 +869,20 @@ _rtld_linkmap_add(Obj_Entry *obj)
 		_rtld_debug.r_map = l;
 		return;
 	}
-	for (prev = _rtld_debug.r_map; prev->l_next != NULL; prev = prev->l_next);
+
+	/*
+	 * Scan to the end of the list, but not past the entry for the
+	 * dynamic linker, which we want to keep at the very end.
+	 */
+	for (prev = _rtld_debug.r_map;
+	    prev->l_next != NULL && prev->l_next != &_rtld_objself.linkmap;
+	    prev = prev->l_next);
+
 	l->l_prev = prev;
+	l->l_next = prev->l_next;
+	if (l->l_next != NULL)
+		l->l_next->l_prev = l;
 	prev->l_next = l;
-	l->l_next = NULL;
 }
 
 void

--Boundary-00=_GogxDYeAWYxv7Wn--