From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20922 invoked by alias); 28 Mar 2013 23:27:38 -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 20908 invoked by uid 89); 28 Mar 2013 23:27:31 -0000 X-Spam-SWARE-Status: No, score=-3.5 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_HOSTKARMA_NO,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,TW_CP autolearn=ham version=3.3.1 Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 28 Mar 2013 23:27:28 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 21D892E72D; Thu, 28 Mar 2013 19:27:27 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id GLaY0kbKh7En; Thu, 28 Mar 2013 19:27:27 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id E22222E16D; Thu, 28 Mar 2013 19:27:26 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id CE027C0342; Thu, 28 Mar 2013 16:27:24 -0700 (PDT) Date: Fri, 29 Mar 2013 01:59:00 -0000 From: Joel Brobecker To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: RFC: solib.c:solib_map_sections so->so_name clobbering Message-ID: <20130328232724.GF4758@adacore.com> References: <87r4s83lu5.fsf@fleche.redhat.com> <20130328011107.GA17105@adacore.com> <87li97cz5j.fsf@fleche.redhat.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="W/nzBZO5zC0uMSeA" Content-Disposition: inline In-Reply-To: <87li97cz5j.fsf@fleche.redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Virus-Found: No X-SW-Source: 2013-03/txt/msg01085.txt.bz2 --W/nzBZO5zC0uMSeA Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1056 > Joel> What do you (or others!) think? I am happy to test and submit a proper > Joel> patch. > > It sounds reasonable to me. > I'm sorry about the mess here. Thanks for the feedback, and really you should not feel sorry at all. It wasn't your mess :-). And the good news is that I feel like we are slowly making it better. Attached is the patch I tested on x86_64-linux. I am off next week, but I will also apply it to AdaCore's version of GDB to get some exposure on all the targets that we support. JIC. That will give more time for others to comment as well, if needed. gdb/ChangeLog: * solib.c (solib_map_sections): Remove code overwriting SO->SO_NAME with the bfd's filename. > Joel> We wouldn't be able to use a patch like this on the 7.6 branch, > Joel> so for Darwin, I'd restore the xstrdup below - it would be a memory > Joel> leak, but better to have a leak than not having the shared library name, > Joel> IMO. > > You can make it not leak by using bfd_alloc. Neat! I will try that before I go. Thanks again, -- Joel --W/nzBZO5zC0uMSeA Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-Do-not-overwrite-so_list-s-so_name-in-solib_map_sect.patch" Content-length: 1095 >From f7bd26fcfdbcde492d4da15d291115d714f5febd Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Thu, 28 Mar 2013 16:23:06 -0700 Subject: [PATCH] Do not overwrite so_list's so_name in solib_map_sections gdb/ChangeLog: * solib.c (solib_map_sections): Remove code overwriting SO->SO_NAME with the bfd's filename. --- gdb/solib.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/gdb/solib.c b/gdb/solib.c index 8129c0f..6978677 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -465,12 +465,6 @@ solib_map_sections (struct so_list *so) /* Leave bfd open, core_xfer_memory and "info files" need it. */ so->abfd = abfd; - /* copy full path name into so_name, so that later symbol_file_add - can find it. */ - if (strlen (bfd_get_filename (abfd)) >= SO_NAME_MAX_PATH_SIZE) - error (_("Shared library file name is too long.")); - strcpy (so->so_name, bfd_get_filename (abfd)); - if (build_section_table (abfd, &so->sections, &so->sections_end)) { error (_("Can't find the file sections in `%s': %s"), -- 1.7.10.4 --W/nzBZO5zC0uMSeA--