From d878444cd92ee5a62ff20be322ffef98b3218421 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Sun, 9 Jun 2013 17:08:47 +0000 Subject: [PATCH] gdb/gdbserver/ Fix compatibility with Android Bionic. * linux-low.c (linux_qxfer_libraries_svr4): Ignore first entry even if it is not empty. --- gdb/gdbserver/ChangeLog | 6 ++++ gdb/gdbserver/linux-low.c | 77 ++++++++++++++++++++++++++--------------------- 2 files changed, 49 insertions(+), 34 deletions(-) diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 6564961..604a414 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,9 @@ +2013-06-09 Jan Kratochvil + + Fix compatibility with Android Bionic. + * linux-low.c (linux_qxfer_libraries_svr4): Ignore first entry even if + it is not empty. + 2013-06-07 Pedro Alves PR server/14823 diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index 4247b11..f7e510e 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -5851,45 +5851,54 @@ linux_qxfer_libraries_svr4 (const char *annex, unsigned char *readbuf, break; } - /* Not checking for error because reading may stop before - we've got PATH_MAX worth of characters. */ - libname[0] = '\0'; - linux_read_memory (l_name, libname, sizeof (libname) - 1); - libname[sizeof (libname) - 1] = '\0'; - if (libname[0] != '\0') + /* Ignore the first entry even if it has valid name as the first entry + corresponds to the main executable. The first entry should not be + skipped if the dynamic loader was loaded late by a static executable + (see solib-svr4.c parameter ignore_first). But in such case the main + executable does not have PT_DYNAMIC present and this function already + exited above due to failed get_r_debug. */ + if (lm_prev == 0) { - /* 6x the size for xml_escape_text below. */ - size_t len = 6 * strlen ((char *) libname); - char *name; - - if (!header_done) + sprintf (p, " main-lm=\"0x%lx\"", (unsigned long) lm_addr); + p = p + strlen (p); + } + else + { + /* Not checking for error because reading may stop before + we've got PATH_MAX worth of characters. */ + libname[0] = '\0'; + linux_read_memory (l_name, libname, sizeof (libname) - 1); + libname[sizeof (libname) - 1] = '\0'; + if (libname[0] != '\0') { - /* Terminate `", - name, (unsigned long) lm_addr, - (unsigned long) l_addr, (unsigned long) l_ld); - free (name); - } - else if (lm_prev == 0) - { - sprintf (p, " main-lm=\"0x%lx\"", (unsigned long) lm_addr); - p = p + strlen (p); + document = xrealloc (document, 2 * allocated); + allocated *= 2; + p = document + document_len; + } + + name = xml_escape_text ((char *) libname); + p += sprintf (p, "", + name, (unsigned long) lm_addr, + (unsigned long) l_addr, (unsigned long) l_ld); + free (name); + } } lm_prev = lm_addr; -- 2.7.4