]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
as_bad_subtract
authorAlan Modra <amodra@gmail.com>
Wed, 21 Jul 2021 05:09:29 +0000 (14:39 +0930)
committerAlan Modra <amodra@gmail.com>
Wed, 21 Jul 2021 10:05:34 +0000 (19:35 +0930)
Many places report errors of the nature "can't resolve a - b".
This provides a utility function to report such errors consistently.
I removed the section reporting and quotes around symbol names while I
was at it.  Compare
ifunc-2.s:4: Error: can't resolve `bar1' {.text.1 section} - `foo1' {.text.1 section}
with
ifunc-2.s:4: Error: can't resolve bar1 - foo1

In many cases the section names don't help the user very much in
figuring out what went wrong, and the quotes if present arguably ought
to be placed around the entire expression:
can't resolve `bar1 - foo1'

The patch also tidies some tc_get_reloc functions that leak memory on
error paths.

* write.h (as_bad_subtract): Declare.
* write.c (as_bad_subtract): New function.
(fixup_segment): Use as_bad_subtract.
* config/tc-arc.c (md_apply_fix): Likewise.
* config/tc-avr.c (md_apply_fix, tc_gen_reloc): Likewise.
* config/tc-cris.c (md_apply_fix): Likewise.
* config/tc-d10v.c (md_apply_fix): Likewise.
* config/tc-d30v.c (md_apply_fix): Likewise.
* config/tc-ft32.c (md_apply_fix): Likewise.
* config/tc-h8300.c (tc_gen_reloc): Likewise.
* config/tc-m68hc11.c (md_apply_fix): Likewise.
* config/tc-mmix.c (mmix_frob_file): Likewise.
* config/tc-mn10200.c (tc_gen_reloc): Likewise.
* config/tc-nds32.c (nds32_apply_fix): Likewise.
* config/tc-pru.c (md_apply_fix): Likewise.
* config/tc-riscv.c (md_apply_fix): Likewise.
* config/tc-s12z.c (md_apply_fix): Likewise.
* config/tc-s390.c (md_apply_fix): Likewise.
* config/tc-tilegx.c (md_apply_fix): Likewise.
* config/tc-tilepro.c (md_apply_fix): Likewise.
* config/tc-v850.c (md_apply_fix): Likewise.
* config/tc-vax.c (md_apply_fix): Likewise.
* config/tc-xc16x.c (tc_gen_reloc): Likewise.
* config/tc-xgate.c (md_apply_fix): Likewise.
* config/tc-xstormy16.c (xstormy16_md_apply_fix): Likewise.
* config/tc-xtensa.c (md_apply_fix): Likewise.
* config/tc-z80.c (tc_gen_reloc): Likewise.
* config/tc-spu.c (md_apply_fix): Likewise.
(tc_gen_reloc): Delete dead code.  Free memory on error.
* config/tc-cr16.c (tc_gen_reloc): Use as_bad_subtract.  Free
on error.
* config/tc-crx.c (tc_gen_reloc): Likewise.
* config/tc-ppc.c (tc_gen_reloc): Likewise.
* testsuite/gas/i386/ifunc-2.l: Adjust to suit changed error message.
* testsuite/gas/mips/lui-2.l: Likewise.
* testsuite/gas/tic6x/reloc-bad-1.l: Likewise.

33 files changed:
gas/config/tc-arc.c
gas/config/tc-avr.c
gas/config/tc-cr16.c
gas/config/tc-cris.c
gas/config/tc-crx.c
gas/config/tc-d10v.c
gas/config/tc-d30v.c
gas/config/tc-ft32.c
gas/config/tc-h8300.c
gas/config/tc-m68hc11.c
gas/config/tc-mmix.c
gas/config/tc-mn10200.c
gas/config/tc-nds32.c
gas/config/tc-ppc.c
gas/config/tc-pru.c
gas/config/tc-riscv.c
gas/config/tc-s12z.c
gas/config/tc-s390.c
gas/config/tc-spu.c
gas/config/tc-tilegx.c
gas/config/tc-tilepro.c
gas/config/tc-v850.c
gas/config/tc-vax.c
gas/config/tc-xc16x.c
gas/config/tc-xgate.c
gas/config/tc-xstormy16.c
gas/config/tc-xtensa.c
gas/config/tc-z80.c
gas/testsuite/gas/i386/ifunc-2.l
gas/testsuite/gas/mips/lui-2.l
gas/testsuite/gas/tic6x/reloc-bad-1.l
gas/write.c
gas/write.h

index 3cd33dace48c0029bed3001a4c2da97f6f5e643f..d03dc72b401becc32c81aeed10aa169b7f584e5a 100644 (file)
@@ -2936,12 +2936,7 @@ md_apply_fix (fixS *fixP,
        }
       else
        {
-         as_bad_where (fixP->fx_file, fixP->fx_line,
-                       _("can't resolve `%s' {%s section} - `%s' {%s section}"),
-                       fx_addsy ? S_GET_NAME (fx_addsy) : "0",
-                       segment_name (add_symbol_segment),
-                       S_GET_NAME (fx_subsy),
-                       segment_name (sub_symbol_segment));
+         as_bad_subtract (fixP);
          return;
        }
     }
index 397f22d550276723d272ec3509cd9f906dd9fe05..40dcce7dca53bb089cb5a31cbbd95a21a8acea83 100644 (file)
@@ -1548,7 +1548,7 @@ md_apply_fix (fixS *fixP, valueT * valP, segT seg)
              fixP->fx_r_type = BFD_RELOC_AVR_DIFF32;
              break;
            default:
-             as_bad_where (fixP->fx_file, fixP->fx_line, _("expression too complex"));
+             as_bad_subtract (fixP);
              break;
          }
 
@@ -1560,7 +1560,7 @@ md_apply_fix (fixS *fixP, valueT * valP, segT seg)
   }
   /* We don't actually support subtracting a symbol.  */
   if (fixP->fx_subsy != (symbolS *) NULL)
-    as_bad_where (fixP->fx_file, fixP->fx_line, _("expression too complex"));
+    as_bad_subtract (fixP);
 
   /* For the DIFF relocs, write the value into the object file while still
      keeping fx_done FALSE, as both the difference (recorded in the object file)
@@ -1824,7 +1824,7 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED,
 
   if (fixp->fx_subsy != NULL)
     {
-      as_bad_where (fixp->fx_file, fixp->fx_line, _("expression too complex"));
+      as_bad_subtract (fixp);
       return NULL;
     }
 
index cbe113ef0938cf4c56e9059c26baa25e85a6e6a2..8925650b592056cd765d9f314efba3ac9395c965 100644 (file)
@@ -573,14 +573,10 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS * fixP)
       else
        {
          /* We only resolve difference expressions in the same section.  */
-         as_bad_where (fixP->fx_file, fixP->fx_line,
-                       _("can't resolve `%s' {%s section} - `%s' {%s section}"),
-                       fixP->fx_addsy ? S_GET_NAME (fixP->fx_addsy) : "0",
-                       segment_name (fixP->fx_addsy
-                                     ? S_GET_SEGMENT (fixP->fx_addsy)
-                                     : absolute_section),
-                       S_GET_NAME (fixP->fx_subsy),
-                       segment_name (S_GET_SEGMENT (fixP->fx_addsy)));
+         as_bad_subtract (fixP);
+         free (reloc->sym_ptr_ptr);
+         free (reloc);
+         return NULL;
        }
     }
 #ifdef OBJ_ELF
index 94a32e3340deae8b5cb40d85cd8d3e002b52da13..02ce2acfe006d1191eec9caad4143093a535f58c 100644 (file)
@@ -4050,8 +4050,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg)
 
   /* We can't actually support subtracting a symbol.  */
   if (fixP->fx_subsy != (symbolS *) NULL)
-    as_bad_where (fixP->fx_file, fixP->fx_line,
-                 _("expression too complex"));
+    as_bad_subtract (fixP);
 
   /* This operand-type is scaled.  */
   if (fixP->fx_r_type == BFD_RELOC_CRIS_LAPCQ_OFFSET)
index d33a0bf076657de368b766dfb93e557175238ad5..ebf38f69538d3b5d6f487c900d1f58c3b2505be1 100644 (file)
@@ -317,14 +317,10 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS * fixP)
       else
        {
          /* We only resolve difference expressions in the same section.  */
-         as_bad_where (fixP->fx_file, fixP->fx_line,
-                       _("can't resolve `%s' {%s section} - `%s' {%s section}"),
-                       fixP->fx_addsy ? S_GET_NAME (fixP->fx_addsy) : "0",
-                       segment_name (fixP->fx_addsy
-                                     ? S_GET_SEGMENT (fixP->fx_addsy)
-                                     : absolute_section),
-                       S_GET_NAME (fixP->fx_subsy),
-                       segment_name (S_GET_SEGMENT (fixP->fx_addsy)));
+         as_bad_subtract (fixP);
+         free (reloc->sym_ptr_ptr);
+         free (reloc);
+         return NULL;
        }
     }
 
index 1d92f34c43c373897d0b85362479204e4ddec367..b6437b113521f8c01fc321239a3df153007599d5 100644 (file)
@@ -1503,7 +1503,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
 
   /* We don't actually support subtracting a symbol.  */
   if (fixP->fx_subsy != (symbolS *) NULL)
-    as_bad_where (fixP->fx_file, fixP->fx_line, _("expression too complex"));
+    as_bad_subtract (fixP);
 
   op_type = fixP->fx_r_type;
   if (op_type & 2048)
index 957182ac2aa55f6827e9d13b7f8b4aba12fabf48..c48e4a3bba378aad393c3ca7bbe95a05af3cd5b4 100644 (file)
@@ -1906,7 +1906,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
 
   /* We don't support subtracting a symbol.  */
   if (fixP->fx_subsy != (symbolS *) NULL)
-    as_bad_where (fixP->fx_file, fixP->fx_line, _("expression too complex"));
+    as_bad_subtract (fixP);
 
   /* Fetch the instruction, insert the fully resolved operand
      value, and stuff the instruction back again.  */
index 91b8c36ec1836744951bd54b3d3bfd731a808c47..928920f82e71975ccc5b2341a63a156c4e4df9b6 100644 (file)
@@ -570,8 +570,7 @@ md_apply_fix (fixS *fixP ATTRIBUTE_UNUSED,
              fixP->fx_r_type = BFD_RELOC_FT32_DIFF32;
              break;
            default:
-             as_bad_where (fixP->fx_file, fixP->fx_line,
-                           _("expression too complex"));
+             as_bad_subtract (fixP);
              break;
          }
 
@@ -584,7 +583,7 @@ md_apply_fix (fixS *fixP ATTRIBUTE_UNUSED,
 
   /* We don't actually support subtracting a symbol.  */
   if (fixP->fx_subsy != (symbolS *) NULL)
-    as_bad_where (fixP->fx_file, fixP->fx_line, _("expression too complex"));
+    as_bad_subtract (fixP);
 
   switch (fixP->fx_r_type)
     {
index e1f359aec0178aebdfbe2883890c12780d505aca..545c15e6ac691c98e461f8ddfc7036f4910b3d70 100644 (file)
@@ -2298,8 +2298,7 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
       if ((S_GET_SEGMENT (fixp->fx_addsy) != S_GET_SEGMENT (fixp->fx_subsy))
          || S_GET_SEGMENT (fixp->fx_addsy) == undefined_section)
        {
-         as_bad_where (fixp->fx_file, fixp->fx_line,
-                       _("Difference of symbols in different sections is not supported"));
+         as_bad_subtract (fixp);
          return NULL;
        }
     }
index b31f5cade67bf1570012feb139c2e0f4c16ab9b1..a6e876c3f912cdf035006283ec09d9c74575b78b 100644 (file)
@@ -4334,7 +4334,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
 
   /* We don't actually support subtracting a symbol.  */
   if (fixP->fx_subsy != (symbolS *) NULL)
-    as_bad_where (fixP->fx_file, fixP->fx_line, _("Expression too complex."));
+    as_bad_subtract (fixP);
 
   /* Patch the instruction with the resolved operand.  Elf relocation
      info will also be generated to take care of linker/loader fixups.
index d51a0198619f8c7d858bc9e38ead59f5a4c49342..04a799a5a690bc9e3a7ee844a2d58b3a794f8b81 100644 (file)
@@ -3742,8 +3742,7 @@ mmix_frob_file (void)
       /* This case isn't doable in general anyway, methinks.  */
       if (fixP->fx_subsy != NULL)
        {
-         as_bad_where (fixP->fx_file, fixP->fx_line,
-                       _("GREG expression too complicated"));
+         as_bad_subtract (fixP);
          continue;
        }
 
index 6323e54dc27091e0c4f821d2943983f83d3c4b64..cbec5652dfad2196b7dfea56dcf98db8bcd5a51b 100644 (file)
@@ -762,14 +762,7 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
        /* FIXME: We should try more ways to resolve difference expressions
           here.  At least this is better than silently ignoring the
           subtrahend.  */
-       as_bad_where (fixp->fx_file, fixp->fx_line,
-                     _("can't resolve `%s' {%s section} - `%s' {%s section}"),
-                     fixp->fx_addsy ? S_GET_NAME (fixp->fx_addsy) : "0",
-                     segment_name (fixp->fx_addsy
-                                   ? S_GET_SEGMENT (fixp->fx_addsy)
-                                   : absolute_section),
-                     S_GET_NAME (fixp->fx_subsy),
-                     segment_name (S_GET_SEGMENT (fixp->fx_addsy)));
+       as_bad_subtract (fixp);
     }
 
   reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
index 4ff667caf61e219a08c63265b5985b3604683bcc..0ab436c5f19cd405ec84d731ec467b7cc2ff5507 100644 (file)
@@ -7825,8 +7825,7 @@ nds32_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
          /* cvt_frag_to_fill () has called output_leb128 () for us.  */
          break;
        default:
-         as_bad_where (fixP->fx_file, fixP->fx_line,
-                       _("expression too complex"));
+         as_bad_subtract (fixP);
          return;
        }
     }
index 567f8011a5f5fbaf338f850d03012726ba93f74c..3eaeb892387422300b61c4a63aeb527258392070 100644 (file)
@@ -7476,7 +7476,7 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
     }
   reloc->addend = fixp->fx_addnumber;
 
-  if (fixp->fx_subsy && fixp->fx_addsy)
+  if (fixp->fx_subsy != NULL)
     {
       relocs[1] = reloc = XNEW (arelent);
       relocs[2] = NULL;
@@ -7490,9 +7490,11 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
 
       if (reloc->howto == (reloc_howto_type *) NULL)
         {
-          as_bad_where (fixp->fx_file, fixp->fx_line,
-            _("reloc %d not supported by object file format"),
-            BFD_RELOC_PPC_NEG);
+         as_bad_subtract (fixp);
+         free (relocs[1]->sym_ptr_ptr);
+         free (relocs[1]);
+         free (relocs[0]->sym_ptr_ptr);
+         free (relocs[0]);
          relocs[0] = NULL;
         }
     }
index 14876f4fe4fcdbb95c52102d438b4fb6b58c0227..16678b1333305c6ab059cdc6ff8a363781f7185d 100644 (file)
@@ -742,8 +742,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
          diffval /= 4;
          break;
        default:
-         as_bad_where (fixP->fx_file, fixP->fx_line,
-                       _("expression too complex"));
+         as_bad_subtract (fixP);
          break;
        }
 
@@ -753,7 +752,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
   }
   /* We don't actually support subtracting a symbol.  */
   if (fixP->fx_subsy != (symbolS *) NULL)
-    as_bad_where (fixP->fx_file, fixP->fx_line, _("expression too complex"));
+    as_bad_subtract (fixP);
 
   /* For the DIFF relocs, write the value into the object file while still
      keeping fx_done FALSE, as both the difference (recorded in the object file)
index df37579c843010fbcac23d10a6190cd349704a7c..460667e4349f6b8685b18ae700631b0848181c4c 100644 (file)
@@ -3201,8 +3201,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
     }
 
   if (fixP->fx_subsy != NULL)
-    as_bad_where (fixP->fx_file, fixP->fx_line,
-                 _("unsupported symbol subtraction"));
+    as_bad_subtract (fixP);
 
   /* Add an R_RISCV_RELAX reloc if the reloc is relaxable.  */
   if (relaxable && fixP->fx_tcbit && fixP->fx_addsy != NULL)
index 6ec4d5c63b853dbc864fcdb195d384885f8be6f3..11a412d33ca5a053b6e102c8a0f4649149d73b4c 100644 (file)
@@ -3933,7 +3933,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
 
   /* We don't actually support subtracting a symbol.  */
   if (fixP->fx_subsy != (symbolS *) NULL)
-    as_bad_where (fixP->fx_file, fixP->fx_line, _("Expression too complex."));
+    as_bad_subtract (fixP);
 
   /*
     Patch the instruction with the resolved operand.  Elf relocation
index 064dd33ad4e5d0ad6382dab7fc3ad8e615144822..a203436878de46118b40e786054136a573c158ce 100644 (file)
@@ -2254,10 +2254,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
   where = fixP->fx_frag->fr_literal + fixP->fx_where;
 
   if (fixP->fx_subsy != NULL)
-    as_bad_where (fixP->fx_file, fixP->fx_line,
-                 _("cannot emit relocation %s against subsy symbol %s"),
-                 bfd_get_reloc_code_name (fixP->fx_r_type),
-                 S_GET_NAME (fixP->fx_subsy));
+    as_bad_subtract (fixP);
 
   if (fixP->fx_addsy != NULL)
     {
index f9055a55d2d8b1d66ae8a7d4704fca089a704615..11fafa1a390541ee7da6d20214039f8126ca99c3 100644 (file)
@@ -868,12 +868,7 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
   arelent *reloc;
   reloc = XNEW (arelent);
   reloc->sym_ptr_ptr = XNEW (asymbol *);
-  if (fixp->fx_addsy)
-    *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
-  else if (fixp->fx_subsy)
-    *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_subsy);
-  else
-    abort ();
+  *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
   reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
   if (reloc->howto == (reloc_howto_type *) NULL)
@@ -881,6 +876,8 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
       as_bad_where (fixp->fx_file, fixp->fx_line,
                    _("reloc %d not supported by object file format"),
                    (int) fixp->fx_r_type);
+      free (reloc->sym_ptr_ptr);
+      free (reloc);
       return NULL;
     }
   reloc->addend = fixp->fx_addnumber;
@@ -957,7 +954,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
   if (fixP->fx_subsy != (symbolS *) NULL)
     {
       /* We can't actually support subtracting a symbol.  */
-      as_bad_where (fixP->fx_file, fixP->fx_line, _("expression too complex"));
+      as_bad_subtract (fixP);
     }
 
   if (fixP->fx_addsy != NULL)
index e041b4a64d714f045d8103a893a4625b9005c926..97062c0d3652ad7e7007c62b6ce75523a6a56a6c 100644 (file)
@@ -1476,7 +1476,7 @@ md_apply_fix (fixS *fixP, valueT * valP, segT seg ATTRIBUTE_UNUSED)
   if (fixP->fx_subsy != (symbolS *) NULL)
     {
       /* We can't actually support subtracting a symbol.  */
-      as_bad_where (fixP->fx_file, fixP->fx_line, _("expression too complex"));
+      as_bad_subtract (fixP);
     }
 
   /* Correct relocation types for pc-relativeness.  */
index 365b621ccdd14239582a47a8d6bc1e209a578e34..11893bc34caa7588e890f8a92b54d2141274bd5a 100644 (file)
@@ -1334,7 +1334,7 @@ md_apply_fix (fixS *fixP, valueT * valP, segT seg ATTRIBUTE_UNUSED)
   if (fixP->fx_subsy != (symbolS *) NULL)
     {
       /* We can't actually support subtracting a symbol.  */
-      as_bad_where (fixP->fx_file, fixP->fx_line, _("expression too complex"));
+      as_bad_subtract (fixP);
     }
 
   /* Correct relocation types for pc-relativeness.  */
index 5bfebba564317015de716c53b6018232c91e2019..81449d05741bdf506010eb91497863c727f1ccca 100644 (file)
@@ -3447,8 +3447,7 @@ md_apply_fix (fixS *fixP, valueT *valueP, segT seg ATTRIBUTE_UNUSED)
            value -= S_GET_VALUE (fixP->fx_subsy);
          else
            /* We don't actually support subtracting a symbol.  */
-           as_bad_where (fixP->fx_file, fixP->fx_line,
-                         _("expression too complex"));
+           as_bad_subtract (fixP);
        }
       fixP->fx_addnumber = value;
     }
index f439f1b52dcb83f7d5b6c51e253ac6633ab96ad2..efffc7d1fd2884099e1cd1c3473fccbe8bcee387 100644 (file)
@@ -279,7 +279,7 @@ md_apply_fix (fixS *fixP, valueT *valueP, segT seg ATTRIBUTE_UNUSED)
   valueT value = * valueP;
 
   if (fixP->fx_subsy != (symbolS *) NULL)
-    as_bad_where (fixP->fx_file, fixP->fx_line, _("expression too complex"));
+    as_bad_subtract (fixP);
 
   if (fixP->fx_addsy == NULL)
     fixP->fx_done = 1;
index 7d89a37166d623bea0afa32875280f69912b666f..12d90703153ef3b8e8ebddf594262ac889e29987 100644 (file)
@@ -283,13 +283,12 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
   arelent *rel;
   bfd_reloc_code_real_type r_type;
 
-  if (fixp->fx_addsy && fixp->fx_subsy)
+  if (fixp->fx_subsy)
     {
       if ((S_GET_SEGMENT (fixp->fx_addsy) != S_GET_SEGMENT (fixp->fx_subsy))
          || S_GET_SEGMENT (fixp->fx_addsy) == undefined_section)
        {
-         as_bad_where (fixp->fx_file, fixp->fx_line,
-                       _("Difference of symbols in different sections is not supported"));
+         as_bad_subtract (fixp);
          return NULL;
        }
     }
index 5f5d16521918dffd8b47a6209daff44da8d28ffa..f97540a32dcaa1cf23984ac1768bd489b347f8ac 100644 (file)
@@ -660,7 +660,7 @@ md_apply_fix (fixS * fixP, valueT * valP, segT seg ATTRIBUTE_UNUSED)
 
   /* We don't actually support subtracting a symbol.  */
   if (fixP->fx_subsy != (symbolS *) NULL)
-    as_bad_where (fixP->fx_file, fixP->fx_line, _("Expression too complex."));
+    as_bad_subtract (fixP);
 
   where = fixP->fx_frag->fr_literal + fixP->fx_where;
   opcode = bfd_getl16 (where);
index 3edf384350af3569f76a98092f96a375587c5ace..deb10810b06c2f5f755ce02ee120a2e22e0d3648 100644 (file)
@@ -479,7 +479,7 @@ xstormy16_md_apply_fix (fixS *   fixP,
 
   /* We don't actually support subtracting a symbol.  */
   if (fixP->fx_subsy != (symbolS *) NULL)
-    as_bad_where (fixP->fx_file, fixP->fx_line, _("expression too complex"));
+    as_bad_subtract (fixP);
 
   if ((int) fixP->fx_r_type >= (int) BFD_RELOC_UNUSED)
     {
index 452d4a757e907e145f3379e5872434402bb37d3b..b8634f782f88ec213fd4a846b8cb63805ea538be 100644 (file)
@@ -6006,7 +6006,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg)
   if (fixP->fx_subsy && !(linkrelax && (fixP->fx_r_type == BFD_RELOC_32
                                        || fixP->fx_r_type == BFD_RELOC_16
                                        || fixP->fx_r_type == BFD_RELOC_8)))
-    as_bad_where (fixP->fx_file, fixP->fx_line, _("expression too complex"));
+    as_bad_subtract (fixP);
 
   switch (fixP->fx_r_type)
     {
index 303296b7dab0e7609d27010a96a1b23ac6bed2a8..052982fc65e13b33b562aa70ee66ac100890699d 100644 (file)
@@ -3853,7 +3853,7 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED , fixS *fixp)
 
   if (fixp->fx_subsy != NULL)
     {
-      as_bad_where (fixp->fx_file, fixp->fx_line, _("expression too complex"));
+      as_bad_subtract (fixp);
       return NULL;
     }
 
index 0ed314b0ec540844f7197e48085d7450d0fe4e83..280a0c60d1bf8909d177f53bd1d81922d841caf4 100644 (file)
@@ -1,61 +1,61 @@
 .*/ifunc-2\.s: Assembler messages:
-.*/ifunc-2\.s:4: Error: can't resolve `bar1' {\.text\.1 section} - `foo1' {\.text\.1 section}
-.*/ifunc-2\.s:5: Error: can't resolve `bar2' {\.text\.2 section} - `foo2' {\.text\.2 section}
-.*/ifunc-2\.s:6: Error: can't resolve `bar1' {\.text\.1 section} - `bar2' {\.text\.2 section}
-.*/ifunc-2\.s:7: Error: can't resolve `bar2' {\.text\.2 section} - `bar1' {\.text\.1 section}
-.*/ifunc-2\.s:8: Error: can't resolve `\.text\.1' {\.text\.1 section} - `bar1' {\.text\.1 section}
-.*/ifunc-2\.s:9: Error: can't resolve `\.text\.1' {\.text\.1 section} - `bar2' {\.text\.2 section}
-.*/ifunc-2\.s:10: Error: can't resolve `bar1' {\.text\.1 section} - `abs1' {\*ABS\* section}
-.*/ifunc-2\.s:11: Error: can't resolve `abs1' {\*ABS\* section} - `bar1' {\.text\.1 section}
-.*/ifunc-2\.s:12: Error: can't resolve `\.text\.1' {\.text\.1 section} - `bar1' {\.text\.1 section}
-.*/ifunc-2\.s:19: Error: can't resolve `bar1' {\.text\.1 section} - `foo1' {\.text\.1 section}
-.*/ifunc-2\.s:20: Error: can't resolve `bar2' {\.text\.2 section} - `foo2' {\.text\.2 section}
-.*/ifunc-2\.s:21: Error: can't resolve `bar1' {\.text\.1 section} - `bar2' {\.text\.2 section}
-.*/ifunc-2\.s:22: Error: can't resolve `bar2' {\.text\.2 section} - `bar1' {\.text\.1 section}
-.*/ifunc-2\.s:23: Error: can't resolve `\.text\.1' {\.text\.1 section} - `bar1' {\.text\.1 section}
-.*/ifunc-2\.s:24: Error: can't resolve `\.text\.1' {\.text\.1 section} - `bar2' {\.text\.2 section}
-.*/ifunc-2\.s:25: Error: can't resolve `bar1' {\.text\.1 section} - `abs1' {\*ABS\* section}
-.*/ifunc-2\.s:26: Error: can't resolve `abs1' {\*ABS\* section} - `bar1' {\.text\.1 section}
-.*/ifunc-2\.s:27: Error: can't resolve `\.text\.1' {\.text\.1 section} - `bar1' {\.text\.1 section}
-.*/ifunc-2\.s:34: Error: can't resolve `bar1' {\.text\.1 section} - `foo1' {\.text\.1 section}
-.*/ifunc-2\.s:35: Error: can't resolve `bar2' {\.text\.2 section} - `foo2' {\.text\.2 section}
-.*/ifunc-2\.s:36: Error: can't resolve `bar1' {\.text\.1 section} - `bar2' {\.text\.2 section}
-.*/ifunc-2\.s:37: Error: can't resolve `bar2' {\.text\.2 section} - `bar1' {\.text\.1 section}
-.*/ifunc-2\.s:38: Error: can't resolve `\.text\.1' {\.text\.1 section} - `bar1' {\.text\.1 section}
-.*/ifunc-2\.s:39: Error: can't resolve `\.text\.1' {\.text\.1 section} - `bar2' {\.text\.2 section}
-.*/ifunc-2\.s:40: Error: can't resolve `bar1' {\.text\.1 section} - `abs1' {\*ABS\* section}
-.*/ifunc-2\.s:41: Error: can't resolve `abs1' {\*ABS\* section} - `bar1' {\.text\.1 section}
-.*/ifunc-2\.s:42: Error: can't resolve `\.text\.1' {\.text\.1 section} - `bar1' {\.text\.1 section}
-.*/ifunc-2\.s:44: Error: can't resolve `abs1' {\*ABS\* section} - `abs2' {\*ABS\* section}
-.*/ifunc-2\.s:45: Error: can't resolve `abs2' {\*ABS\* section} - `abs1' {\*ABS\* section}
-.*/ifunc-2\.s:50: Error: can't resolve `abs1' {\*ABS\* section} - `abs2' {\*ABS\* section}
-.*/ifunc-2\.s:51: Error: can't resolve `abs2' {\*ABS\* section} - `abs1' {\*ABS\* section}
-.*/ifunc-2\.s:56: Error: can't resolve `abs1' {\*ABS\* section} - `abs2' {\*ABS\* section}
-.*/ifunc-2\.s:57: Error: can't resolve `abs2' {\*ABS\* section} - `abs1' {\*ABS\* section}
-.*/ifunc-2\.s:62: Error: can't resolve `bar1' {\.text\.1 section} - `foo1' {\.text\.1 section}
-.*/ifunc-2\.s:63: Error: can't resolve `bar2' {\.text\.2 section} - `foo2' {\.text\.2 section}
-.*/ifunc-2\.s:64: Error: can't resolve `bar1' {\.text\.1 section} - `bar2' {\.text\.2 section}
-.*/ifunc-2\.s:65: Error: can't resolve `bar2' {\.text\.2 section} - `bar1' {\.text\.1 section}
-.*/ifunc-2\.s:66: Error: can't resolve `\.text\.2' {\.text\.2 section} - `bar1' {\.text\.1 section}
-.*/ifunc-2\.s:67: Error: can't resolve `\.text\.2' {\.text\.2 section} - `bar2' {\.text\.2 section}
-.*/ifunc-2\.s:68: Error: can't resolve `bar2' {\.text\.2 section} - `abs1' {\*ABS\* section}
-.*/ifunc-2\.s:69: Error: can't resolve `abs1' {\*ABS\* section} - `bar2' {\.text\.2 section}
-.*/ifunc-2\.s:70: Error: can't resolve `\.text\.2' {\.text\.2 section} - `bar2' {\.text\.2 section}
-.*/ifunc-2\.s:77: Error: can't resolve `bar1' {\.text\.1 section} - `foo1' {\.text\.1 section}
-.*/ifunc-2\.s:78: Error: can't resolve `bar2' {\.text\.2 section} - `foo2' {\.text\.2 section}
-.*/ifunc-2\.s:79: Error: can't resolve `bar1' {\.text\.1 section} - `bar2' {\.text\.2 section}
-.*/ifunc-2\.s:80: Error: can't resolve `bar2' {\.text\.2 section} - `bar1' {\.text\.1 section}
-.*/ifunc-2\.s:81: Error: can't resolve `\.text\.2' {\.text\.2 section} - `bar1' {\.text\.1 section}
-.*/ifunc-2\.s:82: Error: can't resolve `\.text\.2' {\.text\.2 section} - `bar2' {\.text\.2 section}
-.*/ifunc-2\.s:83: Error: can't resolve `bar2' {\.text\.2 section} - `abs1' {\*ABS\* section}
-.*/ifunc-2\.s:84: Error: can't resolve `abs1' {\*ABS\* section} - `bar2' {\.text\.2 section}
-.*/ifunc-2\.s:85: Error: can't resolve `\.text\.2' {\.text\.2 section} - `bar2' {\.text\.2 section}
-.*/ifunc-2\.s:92: Error: can't resolve `bar1' {\.text\.1 section} - `foo1' {\.text\.1 section}
-.*/ifunc-2\.s:93: Error: can't resolve `bar2' {\.text\.2 section} - `foo2' {\.text\.2 section}
-.*/ifunc-2\.s:94: Error: can't resolve `bar1' {\.text\.1 section} - `bar2' {\.text\.2 section}
-.*/ifunc-2\.s:95: Error: can't resolve `bar2' {\.text\.2 section} - `bar1' {\.text\.1 section}
-.*/ifunc-2\.s:96: Error: can't resolve `\.text\.2' {\.text\.2 section} - `bar1' {\.text\.1 section}
-.*/ifunc-2\.s:97: Error: can't resolve `\.text\.2' {\.text\.2 section} - `bar2' {\.text\.2 section}
-.*/ifunc-2\.s:98: Error: can't resolve `bar2' {\.text\.2 section} - `abs1' {\*ABS\* section}
-.*/ifunc-2\.s:99: Error: can't resolve `abs1' {\*ABS\* section} - `bar2' {\.text\.2 section}
-.*/ifunc-2\.s:100: Error: can't resolve `\.text\.2' {\.text\.2 section} - `bar2' {\.text\.2 section}
+.*/ifunc-2\.s:4: Error: can't resolve bar1 - foo1
+.*/ifunc-2\.s:5: Error: can't resolve bar2 - foo2
+.*/ifunc-2\.s:6: Error: can't resolve bar1 - bar2
+.*/ifunc-2\.s:7: Error: can't resolve bar2 - bar1
+.*/ifunc-2\.s:8: Error: can't resolve \.text\.1 - bar1
+.*/ifunc-2\.s:9: Error: can't resolve \.text\.1 - bar2
+.*/ifunc-2\.s:10: Error: can't resolve bar1 - abs1
+.*/ifunc-2\.s:11: Error: can't resolve abs1 - bar1
+.*/ifunc-2\.s:12: Error: can't resolve \.text\.1 - bar1
+.*/ifunc-2\.s:19: Error: can't resolve bar1 - foo1
+.*/ifunc-2\.s:20: Error: can't resolve bar2 - foo2
+.*/ifunc-2\.s:21: Error: can't resolve bar1 - bar2
+.*/ifunc-2\.s:22: Error: can't resolve bar2 - bar1
+.*/ifunc-2\.s:23: Error: can't resolve \.text\.1 - bar1
+.*/ifunc-2\.s:24: Error: can't resolve \.text\.1 - bar2
+.*/ifunc-2\.s:25: Error: can't resolve bar1 - abs1
+.*/ifunc-2\.s:26: Error: can't resolve abs1 - bar1
+.*/ifunc-2\.s:27: Error: can't resolve \.text\.1 - bar1
+.*/ifunc-2\.s:34: Error: can't resolve bar1 - foo1
+.*/ifunc-2\.s:35: Error: can't resolve bar2 - foo2
+.*/ifunc-2\.s:36: Error: can't resolve bar1 - bar2
+.*/ifunc-2\.s:37: Error: can't resolve bar2 - bar1
+.*/ifunc-2\.s:38: Error: can't resolve \.text\.1 - bar1
+.*/ifunc-2\.s:39: Error: can't resolve \.text\.1 - bar2
+.*/ifunc-2\.s:40: Error: can't resolve bar1 - abs1
+.*/ifunc-2\.s:41: Error: can't resolve abs1 - bar1
+.*/ifunc-2\.s:42: Error: can't resolve \.text\.1 - bar1
+.*/ifunc-2\.s:44: Error: can't resolve abs1 - abs2
+.*/ifunc-2\.s:45: Error: can't resolve abs2 - abs1
+.*/ifunc-2\.s:50: Error: can't resolve abs1 - abs2
+.*/ifunc-2\.s:51: Error: can't resolve abs2 - abs1
+.*/ifunc-2\.s:56: Error: can't resolve abs1 - abs2
+.*/ifunc-2\.s:57: Error: can't resolve abs2 - abs1
+.*/ifunc-2\.s:62: Error: can't resolve bar1 - foo1
+.*/ifunc-2\.s:63: Error: can't resolve bar2 - foo2
+.*/ifunc-2\.s:64: Error: can't resolve bar1 - bar2
+.*/ifunc-2\.s:65: Error: can't resolve bar2 - bar1
+.*/ifunc-2\.s:66: Error: can't resolve \.text\.2 - bar1
+.*/ifunc-2\.s:67: Error: can't resolve \.text\.2 - bar2
+.*/ifunc-2\.s:68: Error: can't resolve bar2 - abs1
+.*/ifunc-2\.s:69: Error: can't resolve abs1 - bar2
+.*/ifunc-2\.s:70: Error: can't resolve \.text\.2 - bar2
+.*/ifunc-2\.s:77: Error: can't resolve bar1 - foo1
+.*/ifunc-2\.s:78: Error: can't resolve bar2 - foo2
+.*/ifunc-2\.s:79: Error: can't resolve bar1 - bar2
+.*/ifunc-2\.s:80: Error: can't resolve bar2 - bar1
+.*/ifunc-2\.s:81: Error: can't resolve \.text\.2 - bar1
+.*/ifunc-2\.s:82: Error: can't resolve \.text\.2 - bar2
+.*/ifunc-2\.s:83: Error: can't resolve bar2 - abs1
+.*/ifunc-2\.s:84: Error: can't resolve abs1 - bar2
+.*/ifunc-2\.s:85: Error: can't resolve \.text\.2 - bar2
+.*/ifunc-2\.s:92: Error: can't resolve bar1 - foo1
+.*/ifunc-2\.s:93: Error: can't resolve bar2 - foo2
+.*/ifunc-2\.s:94: Error: can't resolve bar1 - bar2
+.*/ifunc-2\.s:95: Error: can't resolve bar2 - bar1
+.*/ifunc-2\.s:96: Error: can't resolve \.text\.2 - bar1
+.*/ifunc-2\.s:97: Error: can't resolve \.text\.2 - bar2
+.*/ifunc-2\.s:98: Error: can't resolve bar2 - abs1
+.*/ifunc-2\.s:99: Error: can't resolve abs1 - bar2
+.*/ifunc-2\.s:100: Error: can't resolve \.text\.2 - bar2
index 635f97d2a8cdaee14ab15c35b219523e17d4c091..713bd79804897091adea6a2344b510f356f39ac0 100644 (file)
@@ -1,5 +1,5 @@
 .*\.s: Assembler messages:
 .*\.s:10: Error: invalid operands \(\*UND\* and \*UND\* sections\) for `/'
 .*\.s:7: Error: PC-relative reference to a different section
-.*\.s:8: Error: can't resolve `baz' {\*UND\* section} - `bar' {\*UND\* section}
-.*\.s:9: Error: can't resolve `\.text' {\.text section} - `baz' {\*UND\* section}
+.*\.s:8: Error: can't resolve baz - bar
+.*\.s:9: Error: can't resolve \.text - baz
index 9a94d3e72b08414c05061f7194bb98231555c174..29272121cc2e4f98e400a2603c1d73a4e2d00b5a 100644 (file)
@@ -1,2 +1,2 @@
 [^:]*: Assembler messages:
-[^:]*:8: Error: can't resolve `a' \{\*UND\* section\} - `b' \{\*UND\* section\}
+[^:]*:8: Error: can't resolve a - b
index 2d67f167ff0a85444edd00cf36b1e3db10da2430..253dfc476f8c9cd894f5debd4cf4a93ed03f9b52 100644 (file)
@@ -899,6 +899,15 @@ adjust_reloc_syms (bfd *abfd ATTRIBUTE_UNUSED,
   dump_section_relocs (abfd, sec, stderr);
 }
 
+void
+as_bad_subtract (fixS *fixp)
+{
+  as_bad_where (fixp->fx_file, fixp->fx_line,
+               _("can't resolve %s - %s"),
+               fixp->fx_addsy ? S_GET_NAME (fixp->fx_addsy) : "0",
+               S_GET_NAME (fixp->fx_subsy));
+}
+
 /* fixup_segment()
 
    Go through all the fixS's in a segment and see which ones can be
@@ -1021,12 +1030,7 @@ fixup_segment (fixS *fixP, segT this_segment)
                as_bad_where (fixP->fx_file, fixP->fx_line,
                              _("register value used as expression"));
              else
-               as_bad_where (fixP->fx_file, fixP->fx_line,
-                             _("can't resolve `%s' {%s section} - `%s' {%s section}"),
-                             fixP->fx_addsy ? S_GET_NAME (fixP->fx_addsy) : "0",
-                             segment_name (add_symbol_segment),
-                             S_GET_NAME (fixP->fx_subsy),
-                             segment_name (sub_symbol_segment));
+               as_bad_subtract (fixP);
            }
          else if (sub_symbol_segment != undefined_section
                   && ! bfd_is_com_section (sub_symbol_segment)
index dc61c888fab7cfe799a5c496ce03893947265dcd..74d07bff0eac237ddec1c9a5b4b6e94c8253f6c9 100644 (file)
@@ -184,5 +184,6 @@ extern fixS *fix_at_start (fragS *, unsigned long, symbolS *,
 extern fixS *fix_new_exp (fragS *, unsigned long, unsigned long,
                          expressionS *, int, bfd_reloc_code_real_type);
 extern void write_print_statistics (FILE *);
+extern void as_bad_subtract (fixS *);
 
 #endif /* __write_h__ */