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]

Re: mips option parsing behaviour changed accidentally?


cgd@broadcom.com wrote:
[snip]
> Thiemo,
> 
> I note that your change on 2001-10-03 to tc-mips.c (rev 1.78 of that
> file) seems to have had the effect of making the handling in
> md_parse_option for:
> 
> 	OPTION_GP32
> 	OPTION_GP64
> 	OPTION_FP32
> 	OPTION_MABI
> 
> ELF-specific.  These options used to be supported on non-ELF systems.

I doubt this for the -mabi option because it handles ELF ABI's.

> I believe this change was accidental for two reasons:
> 
> 	(1) there was no mention of it in the ChangeLog, and
> 
> 	(2) the entries in the option table for those options weren't
> 	made ELF-specific.

Sorry, that was a quick ad-hoc change which slipped trough unchecked.
For OPTION_{FP,GP}{32,64} it is accidental, for OPTION_MABI it is
intentional.

[snip]
> Anyway, so, was that change intentional, or is the patch below in order?
> 
> (If it was intentional, you should make a patch to the rest of the
> options, and make sure that the tests which use those options aren't
> even attempted for e.g. ECOFF.  However, I really don't think that's
> correct...)

Is the appended patch ok?


Thiemo


2001-10-18  Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>

	/gas/ChangeLog
	* config/tc-mips.c (load_register): Cast signedness mismatches.
	(support_64bit_objects): Define for OBJ_ELF only.
	(OPTION_MABI): Likewise.
	(OPTION_32, OPTION_N32, OPTION_N64, OPTION_MABI): Allow for ELF
	targets only.
	(OPTION_GP32, OPTION_GP64, OPTION_FP32): Re-allow these options for
	non-ELF compilation.
	(md_show_usage): Show -mabi usage.

	/gas/testsuite/ChangeLog
	* gas/mips/mips.exp (mips-abi32, mips-abi32-pic): Don't try these
	tests for ecoff.


diff -BurpNX /bigdisk/src/binutils-exclude src-orig/gas/config/tc-mips.c src/gas/config/tc-mips.c
--- src-orig/gas/config/tc-mips.c	Sat Oct 13 19:41:13 2001
+++ src/gas/config/tc-mips.c	Thu Oct 18 12:41:14 2001
@@ -685,7 +685,9 @@ static void mips16_immed PARAMS ((char *
 static int my_getSmallParser PARAMS ((char **, unsigned int *, int *));
 static int my_getSmallExpression PARAMS ((expressionS *, char *));
 static void my_getExpression PARAMS ((expressionS *, char *));
+#ifdef OBJ_ELF
 static int support_64bit_objects PARAMS((void));
+#endif
 static symbolS *get_symbol PARAMS ((void));
 static void mips_align PARAMS ((int to, int fill, symbolS *label));
 static void s_align PARAMS ((int));
@@ -3348,7 +3350,7 @@ load_register (counter, reg, ep, dbl)
       int shift, bit;
       unsigned long hi, lo;
 
-      if (hi32.X_add_number == 0xffffffff)
+      if (hi32.X_add_number == (offsetT) 0xffffffff)
 	{
 	  if ((lo32.X_add_number & 0xffff8000) == 0xffff8000)
 	    {
@@ -3487,7 +3489,7 @@ load_register (counter, reg, ep, dbl)
     {
       expressionS mid16;
 
-      if ((freg == 0) && (lo32.X_add_number == 0xffffffff))
+      if ((freg == 0) && (lo32.X_add_number == (offsetT) 0xffffffff))
 	{
 	  macro_build ((char *) NULL, counter, &lo32, "lui", "t,u", reg,
 		       (int) BFD_RELOC_HI16);
@@ -4043,7 +4045,7 @@ macro (ip)
       if (sreg == 0
 	  || (HAVE_32BIT_GPRS
 	      && imm_expr.X_op == O_constant
-	      && imm_expr.X_add_number == 0xffffffff))
+	      && imm_expr.X_add_number == (offsetT) 0xffffffff))
 	goto do_false;
       if (imm_expr.X_op != O_constant)
 	as_bad (_("Unsupported large constant"));
@@ -4186,7 +4188,7 @@ macro (ip)
       if (sreg == 0
 	  || (HAVE_32BIT_GPRS
 	      && imm_expr.X_op == O_constant
-	      && imm_expr.X_add_number == 0xffffffff))
+	      && imm_expr.X_add_number == (offsetT) 0xffffffff))
 	goto do_true;
       if (imm_expr.X_op != O_constant)
 	as_bad (_("Unsupported large constant"));
@@ -9378,6 +9380,7 @@ md_number_to_chars (buf, val, n)
     number_to_chars_littleendian (buf, val, n);
 }
 
+#ifdef OBJ_ELF
 static int support_64bit_objects(void)
 {
   const char **list, **l;
@@ -9396,6 +9399,7 @@ static int support_64bit_objects(void)
   free (list);
   return (*l != NULL);
 }
+#endif /* OBJ_ELF */
 
 CONST char *md_shortopts = "nO::g::G:";
 
@@ -9444,8 +9448,10 @@ struct option md_longopts[] =
   {"m3900", no_argument, NULL, OPTION_M3900},
 #define OPTION_NO_M3900 (OPTION_MD_BASE + 20)
   {"no-m3900", no_argument, NULL, OPTION_NO_M3900},
+#ifdef OBJ_ELF
 #define OPTION_MABI (OPTION_MD_BASE + 21)
   {"mabi", required_argument, NULL, OPTION_MABI},
+#endif
 #define OPTION_M7000_HILO_FIX (OPTION_MD_BASE + 22)
   {"mfix7000", no_argument, NULL, OPTION_M7000_HILO_FIX},
 #define OPTION_NO_M7000_HILO_FIX (OPTION_MD_BASE + 23)
@@ -9748,21 +9754,37 @@ md_parse_option (c, arg)
       break;
 
 #ifdef OBJ_ELF
-      /* The -32 and -64 options tell the assembler to output the 32
-         bit or the 64 bit MIPS ELF format.  */
+      /* The -32, -n32 and -64 options are shortcuts for -mabi=32, -mabi=n32
+	 and -mabi=64.  */
     case OPTION_32:
+      if (OUTPUT_FLAVOR != bfd_target_elf_flavour)
+	{
+	  as_bad (_("-32 is supported only for ELF format"));
+	  return 0;
+	}
       mips_abi = O32_ABI;
       break;
 
     case OPTION_N32:
+      if (OUTPUT_FLAVOR != bfd_target_elf_flavour)
+	{
+	  as_bad (_("-n32 is supported only for ELF format"));
+	  return 0;
+	}
       mips_abi = N32_ABI;
       break;
 
     case OPTION_64:
+      if (OUTPUT_FLAVOR != bfd_target_elf_flavour)
+	{
+	  as_bad (_("-64 is supported only for ELF format"));
+	  return 0;
+	}
       mips_abi = N64_ABI;
       if (! support_64bit_objects())
 	as_fatal (_("No compiled in support for 64 bit object file format"));
       break;
+#endif /* OBJ_ELF */
 
     case OPTION_GP32:
       mips_gp32 = 1;
@@ -9782,7 +9804,13 @@ md_parse_option (c, arg)
 	mips_abi = NO_ABI;
       break;
 
+#ifdef OBJ_ELF
     case OPTION_MABI:
+      if (OUTPUT_FLAVOR != bfd_target_elf_flavour)
+	{
+	  as_bad (_("-mabi is supported only for ELF format"));
+	  return 0;
+	}
       if (strcmp (arg, "32") == 0)
 	mips_abi = O32_ABI;
       else if (strcmp (arg, "o64") == 0)
@@ -9928,6 +9956,19 @@ MIPS options:\n\
 -KPIC, -call_shared	generate SVR4 position independent code\n\
 -non_shared		do not generate position independent code\n\
 -xgot			assume a 32 bit GOT\n\
+-mabi=ABI		create ABI conformant object file for:\n"));
+
+  first = 1;
+
+  show (stream, "32", &column, &first);
+  show (stream, "o64", &column, &first);
+  show (stream, "n32", &column, &first);
+  show (stream, "64", &column, &first);
+  show (stream, "eabi", &column, &first);
+			     
+  fputc ('\n', stream);
+
+  fprintf (stream, _("\
 -32			create o32 ABI object file (default)\n\
 -n32			create n32 ABI object file\n\
 -64			create 64 ABI object file\n"));
diff -BurpNX /bigdisk/src/binutils-exclude src-orig/gas/testsuite/gas/mips/mips.exp src/gas/testsuite/gas/mips/mips.exp
--- src-orig/gas/testsuite/gas/mips/mips.exp	Sat Aug 25 04:21:54 2001
+++ src/gas/testsuite/gas/mips/mips.exp	Thu Oct 18 11:48:25 2001
@@ -129,7 +129,9 @@ if { [istarget mips*-*-*] } then {
     run_dump_test "mips-gp32-fp64"
     run_dump_test "mips-gp64-fp32"
     run_dump_test "mips-gp64-fp64"
-    run_dump_test "mips-abi32"
+    if ![istarget *-*-ecoff*] { 
+	run_dump_test "mips-abi32"
+    }
 
     if $svr4pic {
 	# Make sure that -mcpu=FOO and -mFOO are equivalent.  Assemble a file
@@ -147,8 +149,9 @@ if { [istarget mips*-*-*] } then {
  	run_dump_test "mips-gp32-fp64-pic"
  	run_dump_test "mips-gp64-fp32-pic"
  	run_dump_test "mips-gp64-fp64-pic"
-	run_dump_test "mips-abi32-pic"
-
+	if ![istarget *-*-ecoff*] { 
+	    run_dump_test "mips-abi32-pic"
+	}
 	run_dump_test "elf${el}-rel"
 	if [istarget mips64*-*-*] { 
 	    run_dump_test "elf${el}-rel2"


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