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.
This commit is contained in:
jdp 1998-09-16 02:54:08 +00:00
parent 82df6336ed
commit 7bf4199b5f

View File

@ -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