This is the mail archive of the binutils@sources.redhat.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]
Other format: [Raw text]

tc-ppc.c warnings and option fixes


I'm applying these separately from the gas reloc patch to make them
easier to review.

The warning fix is fairly obvious as tc-ppc.c may be compiled with a
32 bit BFD.  The other tweaks are to prevent gas blowing up when given
inappropriate options.  -a64 won't work without a 64-bit BFD, hence
the change to md_parse_option.  Also, -a64 can't work with
bfd_arch_rs6000 as that bfd_arch has no 64 bit support.  So select
ppc_cpu to ensure bfd_arch_powerpc will be used.  It might be better
to limit rs6000-*-* to 32 bit, and if so that can be fixed later,
along with turning off 64 bit support in bfd for those targets.

Lastly, the change to ppc_arch is a tweak so that I can renumber
bfd_mach_rs6k and bfd_mach_ppc at some later stage.  Currently
they are both zero, which is also used to mean the default machine.

	* config/tc-ppc.c (PPC_HIGHER, PPC_HIGHEST): Fix warning.
	(md_parse_option): No -a64 without BFD64.
	(ppc_set_cpu): Select appropriate cpu when ppc_obj64.
	(ppc_arch): Use bfd_mach_rs6k for bfd_arch_rs6000.

Index: gas/config/tc-ppc.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-ppc.c,v
retrieving revision 1.55
diff -u -p -r1.55 tc-ppc.c
--- gas/config/tc-ppc.c	21 Aug 2002 23:37:34 -0000	1.55
+++ gas/config/tc-ppc.c	4 Sep 2002 13:11:03 -0000
@@ -68,14 +68,14 @@ static int set_target_endian = 0;
 #define PPC_HA(v) PPC_HI ((v) + 0x8000)
 
 /* #higher(value) denotes bits 32 through 47 of the indicated value.  */
-#define PPC_HIGHER(v) (((v) >> 32) & 0xffff)
+#define PPC_HIGHER(v) (((v) >> 16 >> 16) & 0xffff)
 
 /* #highera(value) denotes bits 32 through 47 of the indicated value,
    compensating for #lo() being treated as a signed number.  */
 #define PPC_HIGHERA(v) PPC_HIGHER ((v) + 0x8000)
 
 /* #highest(value) denotes bits 48 through 63 of the indicated value.  */
-#define PPC_HIGHEST(v) (((v) >> 48) & 0xffff)
+#define PPC_HIGHEST(v) (((v) >> 24 >> 24) & 0xffff)
 
 /* #highesta(value) denotes bits 48 through 63 of the indicated value,
    compensating for #lo being treated as a signed number.  */
@@ -867,7 +867,13 @@ md_parse_option (c, arg)
       /* a64 and a32 determine whether to use XCOFF64 or XCOFF32.  */
     case 'a':
       if (strcmp (arg, "64") == 0)
-	ppc_obj64 = 1;
+	{
+#ifdef BFD64
+	  ppc_obj64 = 1;
+#else
+	  as_fatal (_("%s unsupported"), "-a64");
+#endif
+	}
       else if (strcmp (arg, "32") == 0)
 	ppc_obj64 = 0;
       else
@@ -1100,8 +1106,10 @@ ppc_set_cpu ()
 
   if (ppc_cpu == 0)
     {
-      if (strncmp (default_os, "aix", 3) == 0
-	  && default_os[3] >= '4' && default_os[3] <= '9')
+      if (ppc_obj64)
+	ppc_cpu = PPC_OPCODE_PPC | PPC_OPCODE_CLASSIC | PPC_OPCODE_64;
+      else if (strncmp (default_os, "aix", 3) == 0
+	       && default_os[3] >= '4' && default_os[3] <= '9')
 	ppc_cpu = PPC_OPCODE_COMMON | PPC_OPCODE_32;
       else if (strncmp (default_os, "aix3", 4) == 0)
 	ppc_cpu = PPC_OPCODE_POWER | PPC_OPCODE_32;
@@ -1147,7 +1155,12 @@ ppc_arch ()
 unsigned long
 ppc_mach ()
 {
-  return ppc_obj64 ? bfd_mach_ppc64 : bfd_mach_ppc;
+  if (ppc_obj64)
+    return bfd_mach_ppc64;
+  else if (ppc_arch () == bfd_arch_rs6000)
+    return bfd_mach_rs6k;
+  else
+    return bfd_mach_ppc;
 }
 
 extern char*

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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