Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Ben Cheng <bccheng@google.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Ignore the first entry returned by svr4_current_sos_via_xfer_libraries for dynamically linked programs
Date: Tue, 04 Jun 2013 20:45:00 -0000	[thread overview]
Message-ID: <CAPk6zkB9aaTp097EcTX97UqhwQ1UasLcBcOYXsox_p2cv681rg@mail.gmail.com> (raw)
In-Reply-To: <CAPk6zkC0a-9DrKpDfn4d5mxQ1Tgm0hJ9pLMfoFhZr6OGJa34yQ@mail.gmail.com>

And it looks like reversing the order of checks for lm_prev and
libname in gdbserver/linux_qxfer_libraries_svr4:linux_qxfer_libraries_svr4()
is a possible fix for this problem.

On Tue, Jun 4, 2013 at 1:36 PM, Ben Cheng <bccheng@google.com> wrote:
> Perfect timing. :) I was playing with Android's dynamic linker and
> fount out that after setting the l_name field to NULL for the first
> entry gdb/gdbserver 7.6 start to work on Android.
>
> diff --git a/linker/linker.cpp b/linker/linker.cpp
> index c97b712..ddc16d8 100644
> --- a/linker/linker.cpp
> +++ b/linker/linker.cpp
> @@ -1644,7 +1644,8 @@ static Elf32_Addr __linker_init_post_relocation(KernelArgu
>      link_map_t* map = &(si->link_map);
>
>      map->l_addr = 0;
> -    map->l_name = args.argv[0];
> +    //map->l_name = args.argv[0];
> +    map->l_name = NULL;
>      map->l_prev = NULL;
>      map->l_next = NULL;
>
> Thanks,
> -Ben
>
> On Tue, Jun 4, 2013 at 1:23 PM, Jan Kratochvil
> <jan.kratochvil@redhat.com> wrote:
>> On Tue, 04 Jun 2013 20:18:10 +0200, Ben Cheng wrote:
>>> Hmm this problem only shows up after I refresh gdbserver from the
>>> unmodified gdb 7.6 tree. As you mentioned, gdb 7.1 did not support
>>> library-list-svr4, so when I paired gdbserver 7.1 with gdb 7.6 they
>>> also work fine.
>>
>> In such case there is a bug in FSF gdbserver as it ignores only entries with
>> name "".  Normal glibc uses name "" for the first entry for the executable but
>> Android Bionic apparently uses "<test_program>" as the first entry instead.
>>
>> The bug is in gdbserver/linux-low.c linux_qxfer_libraries_svr4() which should
>> always ignore the first entry, even if it is not "".
>>
>> The test IGNORE_FIRST does not need to be done there.  The check
>>   /* Assume that everything is a library if the dynamic loader was loaded
>>      late by a static executable.  */
>>   if (exec_bfd && bfd_get_section_by_name (exec_bfd, ".dynamic") == NULL)
>>
>> is in fact already done by gdbserver/linux-low.c get_dynamic(): If PT_DYNAMIC
>> (".dynamic") is not found gdbserver will never send <library-list-svr4/> and
>> solib-svr4.c falls back to the memory reads where it copes with static
>> executables fine.
>>
>>
>> Thanks,
>> Jan


  reply	other threads:[~2013-06-04 20:45 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-28 18:31 Ben Cheng
2013-05-29 10:17 ` Gary Benson
2013-06-04  8:58 ` Jan Kratochvil
2013-06-04 17:19   ` Ben Cheng
2013-06-04 18:07 ` Jan Kratochvil
2013-06-04 18:18   ` Ben Cheng
2013-06-04 20:23     ` Jan Kratochvil
2013-06-04 20:36       ` Ben Cheng
2013-06-04 20:45         ` Ben Cheng [this message]
2013-06-04 20:57           ` Jan Kratochvil
2013-06-04 21:21             ` Ben Cheng
2013-06-05 11:38               ` [patchv2] " Jan Kratochvil
     [not found]                 ` <51AF4C5B.5080104@redhat.com>
2013-06-09 18:08                   ` [commit] " Jan Kratochvil
2013-06-11  6:32                     ` Ben Cheng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPk6zkB9aaTp097EcTX97UqhwQ1UasLcBcOYXsox_p2cv681rg@mail.gmail.com \
    --to=bccheng@google.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox