+/* Return whether CoreHdr C is in new or old format. */
+
+#ifdef AIX_CORE_DUMPX_CORE
+# ifndef BFD64
+# define CORE_NEW(c) (!(c).old.c_entries)
+# else
+# define CORE_NEW(c) 1
+# endif
+#else
+# define CORE_NEW(c) 0
+#endif
+
+/* Return whether CoreHdr C usese core_dumpxx structure.
+
+ FIXME: the core file format version number used here definitely indicates
+ that struct core_dumpxx should be used to represent the core file header,
+ but that may not be the only such format version number. */
+
+#ifdef AIX_5_CORE
+# define CORE_DUMPXX_VERSION 267312562
+# define CNEW_IS_CORE_DUMPXX(c) ((c).new_dump.c_version == CORE_DUMPXX_VERSION)
+#else
+# define CNEW_IS_CORE_DUMPXX(c) 0
+#endif
+
+/* Return the c_stackorg field from struct core_dumpx C. */
+
+#ifdef AIX_CORE_DUMPX_CORE
+# define CNEW_STACKORG(c) (c).c_stackorg
+#else
+# define CNEW_STACKORG(c) 0
+#endif
+
+/* Return the offset to the loader region from struct core_dump C. */
+
+#ifdef AIX_CORE_DUMPX_CORE
+# define CNEW_LOADER(c) (c).c_loader
+#else
+# define CNEW_LOADER(c) 0
+#endif
+
+/* Return the offset to the loader region from struct core_dump C. */
+
+#define COLD_LOADER(c) (c).c_tab
+
+/* Return the c_lsize field from struct core_dumpx C. */
+
+#ifdef AIX_CORE_DUMPX_CORE
+# define CNEW_LSIZE(c) (c).c_lsize
+#else
+# define CNEW_LSIZE(c) 0
+#endif
+
+/* Return the c_dataorg field from struct core_dumpx C. */
+
+#ifdef AIX_CORE_DUMPX_CORE
+# define CNEW_DATAORG(c) (c).c_dataorg
+#else
+# define CNEW_DATAORG(c) 0
+#endif
+
+/* Return the c_datasize field from struct core_dumpx C. */
+
+#ifdef AIX_CORE_DUMPX_CORE
+# define CNEW_DATASIZE(c) (c).c_datasize
+#else
+# define CNEW_DATASIZE(c) 0
+#endif
+
+/* Return the c_impl field from struct core_dumpx C. */
+
+#if defined (HAVE_ST_C_IMPL) || defined (AIX_5_CORE)
+# define CNEW_IMPL(c) (c).c_impl
+#else
+# define CNEW_IMPL(c) 0
+#endif
+
+/* Return the command string from struct core_dumpx C. */
+
+#ifdef AIX_CORE_DUMPX_CORE
+# define CNEW_COMM(c) (c).c_u.U_proc.pi_comm
+#else
+# define CNEW_COMM(c) 0
+#endif
+
+/* Return the command string from struct core_dump C. */
+
+#ifdef CORE_VERSION_1
+# define COLD_COMM(c) (c).c_u.U_comm
+#else
+# define COLD_COMM(c) (c).c_u.u_comm
+#endif
+
+/* Return the struct __context64 pointer from struct core_dumpx C. */
+
+#ifdef AIX_CORE_DUMPX_CORE
+# define CNEW_CONTEXT64(c) (c).c_flt.hctx.r64
+#else
+# define CNEW_CONTEXT64(c) c
+#endif
+
+/* Return the struct mstsave pointer from struct core_dumpx C. */
+
+#ifdef AIX_CORE_DUMPX_CORE
+# define CNEW_MSTSAVE(c) (c).c_flt.hctx.r32
+#else
+# define CNEW_MSTSAVE(c) c
+#endif
+
+/* Return the struct mstsave pointer from struct core_dump C. */
+
+#ifdef CORE_VERSION_1
+# define COLD_MSTSAVE(c) (c).c_mst
+#else
+# define COLD_MSTSAVE(c) (c).c_u.u_save
+#endif
+
+/* Return whether struct core_dumpx is from a 64-bit process. */
+
+#ifdef AIX_CORE_DUMPX_CORE
+# define CNEW_PROC64(c) IS_PROC64(&(c).c_u.U_proc)
+#else
+# define CNEW_PROC64(c) 0
+#endif
+
+/* Magic end-of-stack addresses for old core dumps. This is _very_ fragile,
+ but I don't see any easy way to get that info right now. */
+
+#ifdef CORE_VERSION_1
+# define COLD_STACKEND 0x2ff23000
+#else
+# define COLD_STACKEND 0x2ff80000
+#endif
+
+/* Size of the leading portion that old and new core dump structures have in
+ common. */
+#ifdef AIX_CORE_DUMPX_CORE
+#define CORE_COMMONSZ ((long) &((struct core_dumpx *) 0)->c_entries \
+ + sizeof (((struct core_dumpx *) 0)->c_entries))
+#else
+#define CORE_COMMONSZ ((int) &((struct core_dump *) 0)->c_entries \
+ + sizeof (((struct core_dump *) 0)->c_entries))
+#endif
+/* Define prototypes for certain functions, to avoid a compiler warning
+ saying that they are missing. */
+
+const bfd_target * rs6000coff_core_p (bfd *abfd);
+bfd_boolean rs6000coff_core_file_matches_executable_p (bfd *core_bfd,
+ bfd *exec_bfd);
+char * rs6000coff_core_file_failing_command (bfd *abfd);
+int rs6000coff_core_file_failing_signal (bfd *abfd);
+
+/* Try to read into CORE the header from the core file associated with ABFD.
+ Return success. */
+
+static bfd_boolean
+read_hdr (bfd *abfd, CoreHdr *core)
+{
+ bfd_size_type size;
+
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
+ return FALSE;