[PATCH v2] Add support to recognise 32 bit core file formats in AIX 7.3

Aditya Vidyadhar Kamath <[email protected]> Fri, 31 Jul 2026 12:49:27 +0530
Newsgroups gmane.comp.gnu.binutils
Message-ID <[email protected]>
From: Aditya Kamath <[email protected]>

In AIX 7.3 when we take core dump and analyse we get,
gdb/gdb /tmp/crash32 -c /tmp/core
GNU gdb (GDB) 18.0.50.20260728-git
Copyright (C) 2026 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "powerpc64-ibm-aix7.2.0.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.

+------------------------------------------------------------------------------+
| Find the GDB manual online at:                                               |
| http://www.gnu.org/software/gdb/documentation/.                              |
| For help, type "help".                                                       |
| Type "apropos word" to search for commands related to "word".                |
+------------------------------------------------------------------------------+

Reading symbols from /tmp/crash32...
"/tmp/core" is not a core dump: file format not recognized

The reason being BFD is not able to recognise the same. This patch is a fix for the same.

After applying the patch we get,
GNU gdb (GDB) 18.0.50.20260728-git
Copyright (C) 2026 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "powerpc64-ibm-aix7.2.0.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.

+------------------------------------------------------------------------------+
| Find the GDB manual online at:                                               |
| http://www.gnu.org/software/gdb/documentation/.                              |
| For help, type "help".                                                       |
| Type "apropos word" to search for commands related to "word".                |
+------------------------------------------------------------------------------+

Reading symbols from /tmp/crash32...

Core was generated by `crash32g'.
Program terminated with signal SIGSEGV, Segmentation fault.
(gdb) bt
/0  0x10000628 in main ()
/1  0x100002d4 in .__start ()
---
 bfd/rs6000-core.c | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

diff --git a/bfd/rs6000-core.c b/bfd/rs6000-core.c
index 0635960eaee..8d1c21cf85f 100644
--- a/bfd/rs6000-core.c
+++ b/bfd/rs6000-core.c
@@ -151,7 +151,10 @@ typedef union
 
 #ifdef AIX_5_CORE
 # define CORE_DUMPXX_VERSION	267312562
-# define CNEW_IS_CORE_DUMPXX(c) ((c).new_dump.c_version == CORE_DUMPXX_VERSION)
+# define CORE_DUMPXX_VERSION_AIX73	267312561
+# define CNEW_IS_CORE_DUMPXX(c) \
+  ((c).new_dump.c_version == CORE_DUMPXX_VERSION                \
+   || (c).new_dump.c_version == CORE_DUMPXX_VERSION_AIX73)
 #else
 # define CNEW_IS_CORE_DUMPXX(c) 0
 #endif
@@ -354,11 +357,19 @@ rs6000coff_core_p (bfd *abfd)
       return NULL;
     }
 
-  /* This isn't the right handler for 64-bit core files on AIX 5.x.  */
+  /* This isn't the right handler for 64-bit core files on AIX 5.x.
+     However, 32-bit processes on AIX 7.x can produce core_dumpxx format
+     cores with version 0xfeeddb1, which we need to handle here.
+     The aix5ppc-core.c handler will catch 64-bit cores.  */
   if (CORE_NEW (core) && CNEW_IS_CORE_DUMPXX (core))
     {
-      bfd_set_error (bfd_error_wrong_format);
-      return NULL;
+      /* Check if this is a 64-bit process core.  */
+      if (CNEW_PROC64 (core.new_dump))
+	{
+	  /* Let aix5ppc-core.c handle 64-bit cores.  */
+	  bfd_set_error (bfd_error_wrong_format);
+	  return NULL;
+	}
     }
 
   /* Copy fields from new or old core structure.  */
@@ -371,9 +382,9 @@ rs6000coff_core_p (bfd *abfd)
       c_lsize = CNEW_LSIZE (core.new_dump);
       c_loader = CNEW_LOADER (core.new_dump);
       c_extoff = core.new_dump.c_extctx;
-#ifndef BFD64
       proc64 = CNEW_PROC64 (core.new_dump);
     }
+#ifndef BFD64
   else
     {
       c_flag = core.old.c_flag;
@@ -382,9 +393,9 @@ rs6000coff_core_p (bfd *abfd)
       c_stackend = COLD_STACKEND;
       c_lsize = 0x7ffffff;
       c_loader = (file_ptr) (ptr_to_uint) COLD_LOADER (core.old);
-#endif
       proc64 = 0;
     }
+#endif
 
   if (proc64)
     {
@@ -440,8 +451,11 @@ rs6000coff_core_p (bfd *abfd)
     }
 
   /* Don't check the core file size for a full core, AIX 4.1 includes
-     additional shared library sections in a full core.  */
-  if (!(c_flag & (FULL_CORE | CORE_TRUNC)))
+     additional shared library sections in a full core.
+     Also skip the check for AIX 7.3 32-bit cores in core_dumpxx format,
+     as they may have additional sections beyond c_stack + c_size.  */
+  if (!(c_flag & (FULL_CORE | CORE_TRUNC))
+      && !(CORE_NEW (core) && CNEW_IS_CORE_DUMPXX (core) && !proc64))
     {
       /* If the size is wrong, it means we're misinterpreting something.  */
       if (c_stack + (file_ptr) c_size != statbuf.st_size)
-- 
2.51.2