On Thu, Jul 30, 2009 at 9:15 AM, Tom Tromey wrote: > It seems to me that there are not many choices. Either we must pick a > single owner, pick an order, implement something like reference counting > for BFDs, or have a separate function to clean up the BFDs. Right. Conveniently, 'struct bfd' has usrdata, which is unused in GDB. Here is a stab at reference-counted sharing of BFDs between solib and objfile. -- Paul Pluzhnikov 2009-08-03 Paul Pluzhnikov * objfiles.h (OBJF_KEEPBFD): Delete. (gdb_bfd_unref): New prototype. * objfiles.c (gdb_bfd_unref): New function. (free_objfile): Call gdb_bfd_unref. * solib.c (free_so): Likewise. (symbol_add_stub): Set refcount.