bfd/
authorRichard Sandiford <rdsandiford@googlemail.com>
Tue, 6 May 2014 19:13:03 +0000 (20:13 +0100)
committerRichard Sandiford <rdsandiford@googlemail.com>
Tue, 6 May 2014 19:13:03 +0000 (20:13 +0100)
* elfxx-mips.h (elfxx-mips.h): Declare.
* elfxx-mips.c (mips_elf_merge_obj_attributes): Use it to report
Tag_GNU_MIPS_ABI_FP mismatches.
(_bfd_mips_fp_abi_string): New function.

bfd/ChangeLog
bfd/elfxx-mips.c
bfd/elfxx-mips.h

index db4c6fb..902dc73 100644 (file)
@@ -1,3 +1,10 @@
+2014-05-06  Richard Sandiford  <rdsandiford@googlemail.com>
+
+       * elfxx-mips.h (elfxx-mips.h): Declare.
+       * elfxx-mips.c (mips_elf_merge_obj_attributes): Use it to report
+       Tag_GNU_MIPS_ABI_FP mismatches.
+       (_bfd_mips_fp_abi_string): New function.
+
 2014-05-02  Alan Modra  <amodra@gmail.com>
 
        * targets.c: Sort bfd_target vectors somewhat alphabetically.
index d939444..f8c1e64 100644 (file)
@@ -14364,176 +14364,49 @@ mips_elf_merge_obj_attributes (bfd *ibfd, bfd *obfd)
   out_attr = elf_known_obj_attributes (obfd)[OBJ_ATTR_GNU];
   if (in_attr[Tag_GNU_MIPS_ABI_FP].i != out_attr[Tag_GNU_MIPS_ABI_FP].i)
     {
-      out_attr[Tag_GNU_MIPS_ABI_FP].type = 1;
-      if (out_attr[Tag_GNU_MIPS_ABI_FP].i == Val_GNU_MIPS_ABI_FP_ANY)
-       out_attr[Tag_GNU_MIPS_ABI_FP].i = in_attr[Tag_GNU_MIPS_ABI_FP].i;
-      else if (in_attr[Tag_GNU_MIPS_ABI_FP].i != Val_GNU_MIPS_ABI_FP_ANY)
-       switch (out_attr[Tag_GNU_MIPS_ABI_FP].i)
-         {
-         case Val_GNU_MIPS_ABI_FP_DOUBLE:
-           switch (in_attr[Tag_GNU_MIPS_ABI_FP].i)
-             {
-             case Val_GNU_MIPS_ABI_FP_SINGLE:
-               _bfd_error_handler
-                 (_("Warning: %B uses %s (set by %B), %B uses %s"),
-                  obfd, abi_fp_bfd, ibfd, "-mdouble-float", "-msingle-float");
-               break;
-
-             case Val_GNU_MIPS_ABI_FP_SOFT:
-               _bfd_error_handler
-                 (_("Warning: %B uses %s (set by %B), %B uses %s"),
-                  obfd, abi_fp_bfd, ibfd, "-mhard-float", "-msoft-float");
-               break;
-
-             case Val_GNU_MIPS_ABI_FP_64:
-               _bfd_error_handler
-                 (_("Warning: %B uses %s (set by %B), %B uses %s"),
-                  obfd, abi_fp_bfd, ibfd,
-                  "-mdouble-float", "-mips32r2 -mfp64");
-               break;
-
-             default:
-               _bfd_error_handler
-                 (_("Warning: %B uses %s (set by %B), "
-                    "%B uses unknown floating point ABI %d"),
-                  obfd, abi_fp_bfd, ibfd,
-                  "-mdouble-float", in_attr[Tag_GNU_MIPS_ABI_FP].i);
-               break;
-             }
-           break;
-
-         case Val_GNU_MIPS_ABI_FP_SINGLE:
-           switch (in_attr[Tag_GNU_MIPS_ABI_FP].i)
-             {
-             case Val_GNU_MIPS_ABI_FP_DOUBLE:
-               _bfd_error_handler
-                 (_("Warning: %B uses %s (set by %B), %B uses %s"),
-                  obfd, abi_fp_bfd, ibfd, "-msingle-float", "-mdouble-float");
-               break;
-
-             case Val_GNU_MIPS_ABI_FP_SOFT:
-               _bfd_error_handler
-                 (_("Warning: %B uses %s (set by %B), %B uses %s"),
-                  obfd, abi_fp_bfd, ibfd, "-mhard-float", "-msoft-float");
-               break;
-
-             case Val_GNU_MIPS_ABI_FP_64:
-               _bfd_error_handler
-                 (_("Warning: %B uses %s (set by %B), %B uses %s"),
-                  obfd, abi_fp_bfd, ibfd,
-                  "-msingle-float", "-mips32r2 -mfp64");
-               break;
-
-             default:
-               _bfd_error_handler
-                 (_("Warning: %B uses %s (set by %B), "
-                    "%B uses unknown floating point ABI %d"),
-                  obfd, abi_fp_bfd, ibfd,
-                  "-msingle-float", in_attr[Tag_GNU_MIPS_ABI_FP].i);
-               break;
-             }
-           break;
-
-         case Val_GNU_MIPS_ABI_FP_SOFT:
-           switch (in_attr[Tag_GNU_MIPS_ABI_FP].i)
-             {
-             case Val_GNU_MIPS_ABI_FP_DOUBLE:
-             case Val_GNU_MIPS_ABI_FP_SINGLE:
-             case Val_GNU_MIPS_ABI_FP_64:
-               _bfd_error_handler
-                 (_("Warning: %B uses %s (set by %B), %B uses %s"),
-                  obfd, abi_fp_bfd, ibfd, "-msoft-float", "-mhard-float");
-               break;
-
-             default:
-               _bfd_error_handler
-                 (_("Warning: %B uses %s (set by %B), "
-                    "%B uses unknown floating point ABI %d"),
-                  obfd, abi_fp_bfd, ibfd,
-                  "-msoft-float", in_attr[Tag_GNU_MIPS_ABI_FP].i);
-               break;
-             }
-           break;
-
-         case Val_GNU_MIPS_ABI_FP_64:
-           switch (in_attr[Tag_GNU_MIPS_ABI_FP].i)
-             {
-             case Val_GNU_MIPS_ABI_FP_DOUBLE:
-               _bfd_error_handler
-                 (_("Warning: %B uses %s (set by %B), %B uses %s"),
-                  obfd, abi_fp_bfd, ibfd,
-                  "-mips32r2 -mfp64", "-mdouble-float");
-               break;
-
-             case Val_GNU_MIPS_ABI_FP_SINGLE:
-               _bfd_error_handler
-                 (_("Warning: %B uses %s (set by %B), %B uses %s"),
-                  obfd, abi_fp_bfd, ibfd,
-                  "-mips32r2 -mfp64", "-msingle-float");
-               break;
-
-             case Val_GNU_MIPS_ABI_FP_SOFT:
-               _bfd_error_handler
-                 (_("Warning: %B uses %s (set by %B), %B uses %s"),
-                  obfd, abi_fp_bfd, ibfd, "-mhard-float", "-msoft-float");
-               break;
-
-             default:
-               _bfd_error_handler
-                 (_("Warning: %B uses %s (set by %B), "
-                    "%B uses unknown floating point ABI %d"),
-                  obfd, abi_fp_bfd, ibfd,
-                  "-mips32r2 -mfp64", in_attr[Tag_GNU_MIPS_ABI_FP].i);
-               break;
-             }
-           break;
-
-         default:
-           switch (in_attr[Tag_GNU_MIPS_ABI_FP].i)
-             {
-             case Val_GNU_MIPS_ABI_FP_DOUBLE:
-               _bfd_error_handler
-                 (_("Warning: %B uses unknown floating point ABI %d "
-                    "(set by %B), %B uses %s"),
-                  obfd, abi_fp_bfd, ibfd,
-                  out_attr[Tag_GNU_MIPS_ABI_FP].i, "-mdouble-float");
-               break;
+      int out_fp, in_fp;
 
-             case Val_GNU_MIPS_ABI_FP_SINGLE:
-               _bfd_error_handler
-                 (_("Warning: %B uses unknown floating point ABI %d "
-                    "(set by %B), %B uses %s"),
-                  obfd, abi_fp_bfd, ibfd,
-                  out_attr[Tag_GNU_MIPS_ABI_FP].i, "-msingle-float");
-               break;
-
-             case Val_GNU_MIPS_ABI_FP_SOFT:
-               _bfd_error_handler
-                 (_("Warning: %B uses unknown floating point ABI %d "
-                    "(set by %B), %B uses %s"),
-                  obfd, abi_fp_bfd, ibfd,
-                  out_attr[Tag_GNU_MIPS_ABI_FP].i, "-msoft-float");
-               break;
-
-             case Val_GNU_MIPS_ABI_FP_64:
-               _bfd_error_handler
-                 (_("Warning: %B uses unknown floating point ABI %d "
-                    "(set by %B), %B uses %s"),
-                  obfd, abi_fp_bfd, ibfd,
-                  out_attr[Tag_GNU_MIPS_ABI_FP].i, "-mips32r2 -mfp64");
-               break;
+      out_fp = out_attr[Tag_GNU_MIPS_ABI_FP].i;
+      in_fp = in_attr[Tag_GNU_MIPS_ABI_FP].i;
+      out_attr[Tag_GNU_MIPS_ABI_FP].type = 1;
+      if (out_fp == Val_GNU_MIPS_ABI_FP_ANY)
+       out_attr[Tag_GNU_MIPS_ABI_FP].i = in_fp;
+      else if (in_fp != Val_GNU_MIPS_ABI_FP_ANY)
+       {
+         const char *out_string, *in_string;
 
-             default:
-               _bfd_error_handler
-                 (_("Warning: %B uses unknown floating point ABI %d "
-                    "(set by %B), %B uses unknown floating point ABI %d"),
-                  obfd, abi_fp_bfd, ibfd,
-                  out_attr[Tag_GNU_MIPS_ABI_FP].i,
-                  in_attr[Tag_GNU_MIPS_ABI_FP].i);
-               break;
-             }
-           break;
-         }
+         out_string = _bfd_mips_fp_abi_string (out_fp);
+         in_string = _bfd_mips_fp_abi_string (in_fp);
+         /* First warn about cases involving unrecognised ABIs.  */
+         if (!out_string && !in_string)
+           _bfd_error_handler
+             (_("Warning: %B uses unknown floating point ABI %d "
+                "(set by %B), %B uses unknown floating point ABI %d"),
+              obfd, abi_fp_bfd, ibfd, out_fp, in_fp);
+         else if (!out_string)
+           _bfd_error_handler
+             (_("Warning: %B uses unknown floating point ABI %d "
+                "(set by %B), %B uses %s"),
+              obfd, abi_fp_bfd, ibfd, out_fp, in_string);
+         else if (!in_string)
+           _bfd_error_handler
+             (_("Warning: %B uses %s (set by %B), "
+                "%B uses unknown floating point ABI %d"),
+              obfd, abi_fp_bfd, ibfd, out_string, in_fp);
+         else
+           {
+             /* If one of the bfds is soft-float, the other must be
+                hard-float.  The exact choice of hard-float ABI isn't
+                really relevant to the error message.  */
+             if (in_fp == Val_GNU_MIPS_ABI_FP_SOFT)
+               out_string = "-mhard-float";
+             else if (out_fp == Val_GNU_MIPS_ABI_FP_SOFT)
+               in_string = "-mhard-float";
+             _bfd_error_handler
+               (_("Warning: %B uses %s (set by %B), %B uses %s"),
+                obfd, abi_fp_bfd, ibfd, out_string, in_string);
+           }
+       }
     }
 
   /* Check for conflicting Tag_GNU_MIPS_ABI_MSA attributes and merge
@@ -14944,6 +14817,33 @@ _bfd_mips_elf_get_target_dtag (bfd_vma dtag)
     }
 }
 
+/* Return the meaning of Tag_GNU_MIPS_ABI_FP value FP, or null if
+   not known.  */
+
+const char *
+_bfd_mips_fp_abi_string (int fp)
+{
+  switch (fp)
+    {
+      /* These strings aren't translated because they're simply
+        option lists.  */
+    case Val_GNU_MIPS_ABI_FP_DOUBLE:
+      return "-mdouble-float";
+
+    case Val_GNU_MIPS_ABI_FP_SINGLE:
+      return "-msingle-float";
+
+    case Val_GNU_MIPS_ABI_FP_SOFT:
+      return "-msoft-float";
+
+    case Val_GNU_MIPS_ABI_FP_64:
+      return "-mips32r2 -mfp64";
+
+    default:
+      return 0;
+    }
+}
+
 bfd_boolean
 _bfd_mips_elf_print_private_bfd_data (bfd *abfd, void *ptr)
 {
index e6ec673..95b98ac 100644 (file)
@@ -108,6 +108,8 @@ extern bfd_boolean _bfd_mips_elf_merge_private_bfd_data
   (bfd *, bfd *);
 extern bfd_boolean _bfd_mips_elf_set_private_flags
   (bfd *, flagword);
+extern const char * _bfd_mips_fp_abi_string
+  (int);
 extern bfd_boolean _bfd_mips_elf_print_private_bfd_data
   (bfd *, void *);
 extern bfd_boolean _bfd_mips_elf_discard_info