This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[patch] allocate name of anonymous objfiles properly
- From: David Carlton <carlton at bactrian dot org>
- To: gdb-patches at sources dot redhat dot com
- Date: 30 Apr 2003 17:57:36 -0700
- Subject: [patch] allocate name of anonymous objfiles properly
In my earlier patch to make sure that anonymous objfiles have a name,
I neglected to ensure that the name is allocated properly. This can
cause problems if an objfile is unloaded and loaded again, because in
that case somebody will try to free the name, which you can't do if
the name is a constant string. Oops.
This patch fixes that; I've tested it with GCC 3.2, DWARF 2,
i686-pc-linux-gnu. It seems obvious; I'll commit it on Friday unless
somebody objects.
David Carlton
carlton@bactrian.org
2003-04-30 David Carlton <carlton@bactrian.org>
* objfiles.c (allocate_objfile): For anonymous objfiles, allocate
the name with mstrsave.
Index: objfiles.c
===================================================================
RCS file: /cvs/src/src/gdb/objfiles.c,v
retrieving revision 1.29
diff -u -p -r1.29 objfiles.c
--- objfiles.c 25 Feb 2003 21:36:18 -0000 1.29
+++ objfiles.c 1 May 2003 00:41:31 -0000
@@ -325,7 +325,7 @@ allocate_objfile (bfd *abfd, int flags)
}
else
{
- objfile->name = "<<anonymous objfile>>";
+ objfile->name = mstrsave (objfile->md, "<<anonymous objfile>>");
}
/* Initialize the section indexes for this objfile, so that we can