From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7936 invoked by alias); 4 Jun 2013 20:45:26 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 7919 invoked by uid 89); 4 Jun 2013 20:45:24 -0000 X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.1 Received: from mail-oa0-f41.google.com (HELO mail-oa0-f41.google.com) (209.85.219.41) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 04 Jun 2013 20:45:24 +0000 Received: by mail-oa0-f41.google.com with SMTP id n9so542520oag.14 for ; Tue, 04 Jun 2013 13:45:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:x-gm-message-state; bh=dRoY67hq669MLAdPxoUPMYxAal2qhGFgvtFU4AmoOys=; b=nX7cxoawveqMrj2FuuUK8bynSALvS+eXhnqvXvB1F6YKSzXIh16emibvp5yP2dQ6MY 3Zk5ujdwsqZ7Lx2PrdHY7iOhsniiDru0j8JnyxNifCX56dvjtbvuj36gac30PBd8We0T aSzDuVB7XR1wve8VD21/Rz1w9IiXE/6I/y54BDCcWLKpWWfqAdRv7LmA8b881fj1FtIN SqLUZ+CDspy42IqLFHNLDgdi5vu8hzQjNB5MTfSEpZ2HKEi+ch4KZssf2vS2U/SJ+g9Y cYKLBCHG8DDHe+Zihm3CbTDRrluCzk7/qrZeeAiksNbc6XLTWjU4siU/Y3GDV2v34i4s jiyQ== MIME-Version: 1.0 X-Received: by 10.60.55.97 with SMTP id r1mr12760611oep.85.1370378722406; Tue, 04 Jun 2013 13:45:22 -0700 (PDT) Received: by 10.182.22.49 with HTTP; Tue, 4 Jun 2013 13:45:22 -0700 (PDT) In-Reply-To: References: <20130604180722.GA23588@host2.jankratochvil.net> <20130604202301.GA8999@host2.jankratochvil.net> Date: Tue, 04 Jun 2013 20:45:00 -0000 Message-ID: Subject: Re: [PATCH] Ignore the first entry returned by svr4_current_sos_via_xfer_libraries for dynamically linked programs From: Ben Cheng To: Jan Kratochvil Cc: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 X-Gm-Message-State: ALoCoQkaD0Nof3HeVdntr/RN6qKEezjsd1Q9D7MCX/5ktL/KxHsMPTfW8tCiVGLf+csfkpiP4FWjCLykShUNc3BxQimSPJzke5Eu+2eUPG5crSZpg3kwLz4a5UpzsFQtPMwqPB3qhf10uSqG99q0qs9QYdObhsHrRYTWCEdJCQ9eE5MUltgu8SiK9QssG33SlkAdZsPSCL3x6ICtC0bylwQhGaFzh+kjEQ== X-SW-Source: 2013-06/txt/msg00058.txt.bz2 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 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 > 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 "" 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 and >> solib-svr4.c falls back to the memory reads where it copes with static >> executables fine. >> >> >> Thanks, >> Jan