Index: gdb/solib.c =================================================================== RCS file: /cvs/src/src/gdb/solib.c,v retrieving revision 1.153 diff -u -p -r1.153 solib.c --- gdb/solib.c 30 Aug 2011 02:48:05 -0000 1.153 +++ gdb/solib.c 31 Aug 2011 19:20:44 -0000 @@ -1226,7 +1226,22 @@ reload_shared_libraries_1 (int from_tty) && filename_cmp (found_pathname, so->so_name) != 0)) { if (so->objfile && ! (so->objfile->flags & OBJF_USERLOADED)) - free_objfile (so->objfile); + { + struct so_list *pivot; + int used = 0; + + for (pivot = so_list_head; pivot != NULL; pivot = pivot->next) + { + if (pivot != so && pivot->objfile == so->objfile) + { + used = 1; + break; + } + } + + if (!used) + free_objfile (so->objfile); + } remove_target_sections (so->abfd); free_so_symbols (so); }