This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Ignore the first entry returned by svr4_current_sos_via_xfer_libraries for dynamically linked programs
- From: Ben Cheng <bccheng at google dot com>
- To: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Tue, 4 Jun 2013 13:36:38 -0700
- Subject: Re: [PATCH] Ignore the first entry returned by svr4_current_sos_via_xfer_libraries for dynamically linked programs
- References: <CAPk6zkCTrkS960JAG70PdTaTAE=FQ1y4V2CneiNutSu6CG8rwA at mail dot gmail dot com> <20130604180722 dot GA23588 at host2 dot jankratochvil dot net> <CAPk6zkAcnGG4Jg=S_N_zBXefsaW0QjMc-m3B7Z-riQgZfkL24Q at mail dot gmail dot com> <20130604202301 dot GA8999 at host2 dot jankratochvil dot net>
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