diff --git a/bfd/coffgen.c b/bfd/coffgen.c
index 030dbc1dc79..98d6f98d575 100644
--- a/bfd/coffgen.c
+++ b/bfd/coffgen.c
@@ -3310,8 +3310,7 @@ _bfd_coff_free_cached_info (bfd *abfd)
   struct coff_tdata *tdata;
 
   if (bfd_family_coff (abfd)
-      && (bfd_get_format (abfd) == bfd_object
-	  || bfd_get_format (abfd) == bfd_core)
+      && bfd_get_format (abfd) == bfd_object
       && (tdata = coff_data (abfd)) != NULL)
     {
       if (tdata->section_by_index)
diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index e891f510e08..e80e4db0d79 100644
--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -1003,7 +1003,12 @@ pd_disable (inferior *inf)
     return;
   if (!data->pd_active)
     return;
-  pthdb_session_destroy (data->pd_session);
+  /* For core files, all threads are terminated. Calling
+     pthdb_session_destroy (data->pd_session) on it is incorrect
+     and will cause undefined behaviour.  So skip it since we
+     are cleaning.  For binaries clean up.  */
+  if (target_has_execution ())
+    pthdb_session_destroy (data->pd_session);
 
   pid_to_prc (&inferior_ptid);
   data->pd_active = 0;
