From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27849 invoked by alias); 29 Mar 2013 01:53:23 -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 27011 invoked by uid 89); 29 Mar 2013 01:53:12 -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; Fri, 29 Mar 2013 01:53:08 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id ACCB22E425; Thu, 28 Mar 2013 21:53:06 -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 Lfwoziw344as; Thu, 28 Mar 2013 21:53:06 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 7BBB72E16D; Thu, 28 Mar 2013 21:53:06 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 53883C0342; Thu, 28 Mar 2013 18:53:04 -0700 (PDT) Date: Fri, 29 Mar 2013 07:43:00 -0000 From: Joel Brobecker To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: darwin: fix SO name in "info sharedlibrary" (was: "RFC: solib.c:solib_map_sections so->so_name clobbering") Message-ID: <20130329015304.GJ4758@adacore.com> References: <87r4s83lu5.fsf@fleche.redhat.com> <20130328011107.GA17105@adacore.com> <87li97cz5j.fsf@fleche.redhat.com> <20130328232724.GF4758@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MfFXiAuoTsnnDAfZ" Content-Disposition: inline In-Reply-To: <20130328232724.GF4758@adacore.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Virus-Found: No X-SW-Source: 2013-03/txt/msg01093.txt.bz2 --MfFXiAuoTsnnDAfZ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 587 > > 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. Here is the patch. gdb/ChangeLog: * solib-darwin.c (darwin_bfd_open): Set the filename of the returned bfd to a copy of PATHNAME. Tested on x86_64-darwin, no regression. Does it look OK for the branch? Thank you, -- Joel --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-solib-darwin-Overwrite-filename-of-unpeeled-fat-bina.patch" Content-length: 1100 >From c77cdff7df21b5351f471faaf4d34dd423c7c385 Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Thu, 28 Mar 2013 21:48:36 -0400 Subject: [PATCH] solib-darwin: Overwrite filename of unpeeled fat-binary bfd. gdb/ChangeLog: * solib-darwin.c (darwin_bfd_open): Set the filename of the returned bfd to a copy of PATHNAME. --- gdb/solib-darwin.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c index b9a4be1..9b61de5 100644 --- a/gdb/solib-darwin.c +++ b/gdb/solib-darwin.c @@ -621,6 +621,16 @@ darwin_bfd_open (char *pathname) bfd_get_filename (abfd), bfd_errmsg (bfd_get_error ())); } + /* The current filename for fat-binary BFDs is a name generated + by BFD, usually a string containing the name of the architecture. + Reset its value to the actual filename. */ + { + char *data = bfd_alloc (res, strlen (pathname) + 1); + + strcpy (data, pathname); + res->filename = data; + } + gdb_bfd_unref (abfd); return res; } -- 1.7.0.4 --MfFXiAuoTsnnDAfZ--