This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
darwin: fix SO name in "info sharedlibrary" (was: "RFC: solib.c:solib_map_sections so->so_name clobbering")
- From: Joel Brobecker <brobecker at adacore dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Thu, 28 Mar 2013 18:53:04 -0700
- Subject: darwin: fix SO name in "info sharedlibrary" (was: "RFC: solib.c:solib_map_sections so->so_name clobbering")
- References: <87r4s83lu5 dot fsf at fleche dot redhat dot com> <20130328011107 dot GA17105 at adacore dot com> <87li97cz5j dot fsf at fleche dot redhat dot com> <20130328232724 dot GF4758 at adacore dot com>
> > 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
>From c77cdff7df21b5351f471faaf4d34dd423c7c385 Mon Sep 17 00:00:00 2001
From: Joel Brobecker <brobecker@adacore.com>
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