summaryrefslogtreecommitdiffstats
path: root/libexec
diff options
context:
space:
mode:
authorjdp <jdp@FreeBSD.org>1998-09-16 02:54:08 +0000
committerjdp <jdp@FreeBSD.org>1998-09-16 02:54:08 +0000
commit7bf4199b5f595761cb8b9176aeee442f69b7545c (patch)
tree111a9d23eb01f2526168ca39757279e75a8b8e80 /libexec
parent82df6336ed5758eda77ecce3b1d6da10b828c31c (diff)
downloadFreeBSD-src-7bf4199b5f595761cb8b9176aeee442f69b7545c.zip
FreeBSD-src-7bf4199b5f595761cb8b9176aeee442f69b7545c.tar.gz
Fix a bug that showed up when debugging dynamically linked programs.
References from GDB to "printf" and various other functions would find the versions in the dynamic linker itself, rather than the versions in the program's libc. This fix moves the GDB link map entry for the dynamic linker to the end of the search list, where its symbols will be found only if they are not found anywhere else. It was suggested by Doug Rabson, though I implemented it a little differently. I personally would prefer to leave the dynamic linker's entry out of the GDB search list altogether. But Doug argues that it is handy there for such things as setting breakpoints on dlopen(). So it stays for now, at least. Note, if we ever integrate the dynamic linker with libc (which has several important benefits to recommend it), this whole problem goes away.
Diffstat (limited to 'libexec')
-rw-r--r--libexec/rtld-elf/rtld.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
index 4b1eb2f..86ed413 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -22,7 +22,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: rtld.c,v 1.8 1998/09/05 03:31:00 jdp Exp $
+ * $Id: rtld.c,v 1.9 1998/09/15 21:07:52 jdp Exp $
*/
/*
@@ -1240,11 +1240,21 @@ linkmap_add(Obj_Entry *obj)
return;
}
- for (prev = r_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 = r_debug.r_map;
+ prev->l_next != NULL && prev->l_next != &obj_rtld.linkmap;
+ prev = prev->l_next)
;
+
+ /* Link in the new entry. */
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;
}
static void
OpenPOWER on IntegriCloud