+ if (! strcmp (gdb->so_original_name, i->so_original_name))
+ break;
+
+ i_link = &i->next;
+ i = *i_link;
+ }
+
+ /* If the shared object appears on the inferior's list too, then
+ it's still loaded, so we don't need to do anything. Delete
+ it from the inferior's list, and leave it on GDB's list. */
+ if (i)
+ {
+ *i_link = i->next;
+ free_so (i);
+ gdb_link = &gdb->next;
+ gdb = *gdb_link;
+ }
+
+ /* If it's not on the inferior's list, remove it from GDB's tables. */
+ else
+ {
+ *gdb_link = gdb->next;
+
+ /* Unless the user loaded it explicitly, free SO's objfile. */
+ if (gdb->objfile && ! (gdb->objfile->flags & OBJF_USERLOADED))
+ free_objfile (gdb->objfile);
+
+ /* Some targets' section tables might be referring to
+ sections from so->abfd; remove them. */
+ remove_target_sections (gdb->abfd);
+
+ free_so (gdb);
+ gdb = *gdb_link;
+ }
+ }
+
+ /* Now the inferior's list contains only shared objects that don't
+ appear in GDB's list --- those that are newly loaded. Add them
+ to GDB's shared object list. */
+ if (inferior)
+ {
+ struct so_list *i;
+
+ /* Add the new shared objects to GDB's list. */
+ *gdb_link = inferior;
+
+ /* Fill in the rest of each of the `struct so_list' nodes. */
+ for (i = inferior; i; i = i->next)
+ {
+ i->from_tty = from_tty;
+
+ /* Fill in the rest of the `struct so_list' node. */
+ catch_errors (solib_map_sections, i,
+ "Error while mapping shared library sections:\n",
+ RETURN_MASK_ALL);