This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] RS6000 and PowerPC CPU types


The RS6000COFF_C section of coff_set_arch_mach_hook() attempts to infer
the architecture and machine from the o_cputype field of the a.out header.

On AIX, o_cputype is usually 0, meaning that the CPU can be anything.
coff_set_arch_mach_hook() interprets that to mean the following:
  - if the binary format is XCOFF64, the CPU is a 620
  - otherwise, the CPU is a 6000

This is not strictly correct, because (a) there are 64-bit CPUs other than
the 620 (e.g. the 630) and (b) the 620 can run non-XCOFF64 binaries.

AIX GDB cares somewhat about the particular CPU being debugged, so I made
an attempt to correct the above.  I also added checks for all CPU types
documented in /usr/include/aouthdr.h and removed the corresponding "We
don't handle all cases here" FIXME.

Here's the patch.  Okay to apply?

Nick Duffek
nsd@cygnus.com

Index: bfd/coffcode.h
===================================================================
RCS file: /cvs/src/src/bfd/coffcode.h,v
retrieving revision 1.40
diff -u -r1.40 coffcode.h
--- bfd/coffcode.h	2000/04/29 02:41:36	1.40
+++ bfd/coffcode.h	2000/05/05 03:43:57
@@ -1951,7 +1951,7 @@
 	      }
 	  }
 
-	/* FIXME: We don't handle all cases here.  */
+	/* These cases are taken from AIX /usr/include/aouthdr.h. */
 	switch (cputype)
 	  {
 	  default:
@@ -1964,29 +1964,51 @@
 	    machine = 0;
 #else
 	    arch = bfd_arch_rs6000;
-#ifdef XCOFF64
-	    machine = 620;
-#else
-	    machine = 6000;
-#endif
+	    machine = 0;
 #endif /* POWERMAC */
 	    break;
 
 	  case 1:
+	  case 3:
+	  case 5:
 	    arch = bfd_arch_powerpc;
-	    machine = 601;
+	    machine = 0;
 	    break;
 	  case 2: /* 64 bit PowerPC */
 	    arch = bfd_arch_powerpc;
+	    machine = 64;
+	    break;
+	  case 4:
+	    arch = bfd_arch_rs6000;
+	    machine = 6000;
+	    break;
+	  case 6:
+	    arch = bfd_arch_powerpc;
+	    machine = 601;
+	    break;
+	  case 7:
+	    arch = bfd_arch_powerpc;
+	    machine = 603;
+	    break;
+	  case 8:
+	    arch = bfd_arch_powerpc;
+	    machine = 604;
+	    break;
+	  case 10:
+	    arch = bfd_arch_rs6000;
+	    machine = 6001;
+	    break;
+	  case 16:
+	    arch = bfd_arch_powerpc;
 	    machine = 620;
 	    break;
-	  case 3:
+	  case 17:
 	    arch = bfd_arch_powerpc;
-	    machine = 0;
+	    machine = 35;
 	    break;
-	  case 4:
+	  case 224:
 	    arch = bfd_arch_rs6000;
-	    machine = 6000;
+	    machine = 6002;
 	    break;
 	  }
       }
Index: bfd/cpu-powerpc.c
===================================================================
RCS file: /cvs/src/src/bfd/cpu-powerpc.c,v
retrieving revision 1.2
diff -u -r1.2 cpu-powerpc.c
--- bfd/cpu-powerpc.c	2000/04/26 15:09:43	1.2
+++ bfd/cpu-powerpc.c	2000/05/05 03:43:58
@@ -59,7 +59,7 @@
     "powerpc:603",
     3,
     false, /* not the default */
-    powerpc_compatible, 
+    powerpc_compatible,
     bfd_default_scan,
     &arch_info_struct[1]
   },
@@ -73,7 +73,7 @@
     "powerpc:604",
     3,
     false, /* not the default */
-    powerpc_compatible, 
+    powerpc_compatible,
     bfd_default_scan,
     &arch_info_struct[2]
   },
@@ -87,7 +87,7 @@
     "powerpc:403",
     3,
     false, /* not the default */
-    powerpc_compatible, 
+    powerpc_compatible,
     bfd_default_scan,
     &arch_info_struct[3]
   },
@@ -101,21 +101,49 @@
     "powerpc:601",
     3,
     false, /* not the default */
-    powerpc_compatible, 
+    powerpc_compatible,
     bfd_default_scan,
     &arch_info_struct[4]
   },
-  { 
-    32,	/* 32 bits in a word */
+  {
+    64,	/* 64 bits in a word */
+    64,	/* 64 bits in an address */
+    8,	/* 8 bits in a byte */
+    bfd_arch_powerpc,
+    64, /* PowerPC common architecture 64 bit mode */
+    "powerpc",
+    "powerpc:common64",
+    3,
+    false, /* not the default */
+    powerpc_compatible,
+    bfd_default_scan,
+    &arch_info_struct[5]
+  },
+  {
+    64,	/* 64 bits in a word */
     64,	/* 64 bits in an address */
     8,	/* 8 bits in a byte */
     bfd_arch_powerpc,
-    620, /* for the mpc620 */
+    620, /* for the mpc620 in 64-bit mode */
     "powerpc",
     "powerpc:620",
     3,
+    false, /* not the default */
+    powerpc_compatible,
+    bfd_default_scan,
+    &arch_info_struct[6]
+  },
+  {
+    64,	/* 64 bits in a word */
+    64,	/* 64 bits in an address */
+    8,	/* 8 bits in a byte */
+    bfd_arch_powerpc,
+    35, /* for the A35 in 64-bit mode */
+    "powerpc",
+    "powerpc:A35",
+    3,
     false, /* not the default */
-    powerpc_compatible, 
+    powerpc_compatible,
     bfd_default_scan,
     0
   }
@@ -132,7 +160,7 @@
     "powerpc:common",
     3,
     true, /* the default */
-    powerpc_compatible, 
+    powerpc_compatible,
     bfd_default_scan,
     &arch_info_struct[0]
   };
Index: bfd/cpu-rs6000.c
===================================================================
RCS file: /cvs/src/src/bfd/cpu-rs6000.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 cpu-rs6000.c
--- bfd/cpu-rs6000.c	1999/05/03 07:28:55	1.1.1.1
+++ bfd/cpu-rs6000.c	2000/05/05 03:43:58
@@ -53,18 +53,64 @@
   /*NOTREACHED*/
 }
 
+static const bfd_arch_info_type arch_info_struct[] =
+{
+  {
+    32,	/* 32 bits in a word */
+    32,	/* 32 bits in an address */
+    8,	/* 8 bits in a byte */
+    bfd_arch_rs6000,
+    6000, /* POWER common architecture */
+    "rs6000",
+    "rs6000:common",
+    3,
+    false, /* not the default */
+    rs6000_compatible,
+    bfd_default_scan,
+    &arch_info_struct[1]
+  },
+  {
+    32,	/* 32 bits in a word? */
+    32,	/* 32 bits in an address? */
+    8,	/* 8 bits in a byte */
+    bfd_arch_rs6000,
+    6001, /* RS1 implementation of POWER architecture */
+    "rs6000",
+    "rs6000:RS1",
+    3,
+    false, /* not the default */
+    rs6000_compatible,
+    bfd_default_scan,
+    &arch_info_struct[2]
+  },
+  {
+    64,	/* 64 bits in a word? */
+    64,	/* 64 bits in an address? */
+    8,	/* 8 bits in a byte */
+    bfd_arch_rs6000,
+    6002, /* RS2 implementation of POWER architecture */
+    "rs6000",
+    "rs6000:RS2",
+    3,
+    false, /* not the default */
+    rs6000_compatible,
+    bfd_default_scan,
+    0
+  }
+};
+
 const bfd_arch_info_type bfd_rs6000_arch =
   {
     32,	/* 32 bits in a word */
     32,	/* 32 bits in an address */
     8,	/* 8 bits in a byte */
     bfd_arch_rs6000,
-    6000,	/* only 1 machine */
+    0, /* old object, POWER assumed */
     "rs6000",
-    "rs6000:6000",
+    "rs6000:POWER",
     3,
-    true, /* the one and only */
+    true, /* the default */
     rs6000_compatible,
     bfd_default_scan,
-    0,
+    &arch_info_struct[0]
   };

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]