]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* elf32-xtensa.c (vsprint_msg): Add prototype.
authorBob Wilson <bob.wilson@acm.org>
Fri, 15 Jul 2005 20:43:37 +0000 (20:43 +0000)
committerBob Wilson <bob.wilson@acm.org>
Fri, 15 Jul 2005 20:43:37 +0000 (20:43 +0000)
        (build_encoding_error_message): Delete.  Code moved into....
        (elf_xtensa_do_reloc): ....here, and changed to give better
        error messages for out of range literals.

bfd/ChangeLog
bfd/elf32-xtensa.c

index 7d836d1e3df5824c9cb347c1f714bc40c7a4f4ce..5c2eb8160870b6b6528d5d5d122b714198fc7c4a 100644 (file)
@@ -1,3 +1,10 @@
+2005-07-15  Bob Wilson  <bob.wilson@acm.org>
+
+       * elf32-xtensa.c (vsprint_msg): Add prototype.
+       (build_encoding_error_message): Delete.  Code moved into....
+       (elf_xtensa_do_reloc): ....here, and changed to give better
+       error messages for out of range literals.
+
 2005-07-15  Alan Modra  <amodra@bigpond.net.au>
 
        * elflink.c (bfd_elf_record_link_assignment): Remove output_bfd param.
index b6ab7de9a342a388cf05c4f4de01be8438ef499f..79508891d27cc1b6737e54f2cb8bfba7693c5d7d 100644 (file)
@@ -36,7 +36,7 @@
 /* Local helper functions.  */
 
 static bfd_boolean add_extra_plt_sections (bfd *, int);
-static char *build_encoding_error_message (xtensa_opcode, bfd_vma);
+static char *vsprint_msg (const char *, const char *, int, ...) ATTRIBUTE_PRINTF(2,4);
 static bfd_reloc_status_type bfd_elf_xtensa_reloc
   (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
 static bfd_boolean do_fix_for_relocatable_link
@@ -1742,7 +1742,30 @@ elf_xtensa_do_reloc (reloc_howto_type *howto,
       || xtensa_operand_set_field (isa, opcode, opnd, fmt, slot,
                                   sbuff, newval))
     {
-      *error_message = build_encoding_error_message (opcode, relocation);
+      const char *opname = xtensa_opcode_name (isa, opcode);
+      const char *msg;
+
+      msg = "cannot encode";
+      if (is_direct_call_opcode (opcode))
+       {
+         if ((relocation & 0x3) != 0)
+           msg = "misaligned call target";
+         else
+           msg = "call target out of range";
+       }
+      else if (opcode == get_l32r_opcode ())
+       {
+         if ((relocation & 0x3) != 0)
+           msg = "misaligned literal target";
+         else if (is_alt_relocation (howto->type))
+           msg = "literal target out of range (too many literals)";
+         else if (self_address > relocation)
+           msg = "literal target out of range (try using text-section-literals)";
+         else
+           msg = "literal placed after use";
+       }
+
+      *error_message = vsprint_msg (opname, ": %s", strlen (msg) + 2, msg);
       return bfd_reloc_dangerous;
     }
 
@@ -1767,7 +1790,7 @@ elf_xtensa_do_reloc (reloc_howto_type *howto,
 }
 
 
-static char * ATTRIBUTE_PRINTF(2,4)
+static char *
 vsprint_msg (const char *origmsg, const char *fmt, int arglen, ...)
 {
   /* To reduce the size of the memory leak,
@@ -1797,32 +1820,6 @@ vsprint_msg (const char *origmsg, const char *fmt, int arglen, ...)
 }
 
 
-static char *
-build_encoding_error_message (xtensa_opcode opcode, bfd_vma target_address)
-{
-  const char *opname = xtensa_opcode_name (xtensa_default_isa, opcode);
-  const char *msg;
-
-  msg = "cannot encode";
-  if (is_direct_call_opcode (opcode))
-    {
-      if ((target_address & 0x3) != 0)
-       msg = "misaligned call target";
-      else
-       msg = "call target out of range";
-    }
-  else if (opcode == get_l32r_opcode ())
-    {
-      if ((target_address & 0x3) != 0)
-       msg = "misaligned literal target";
-      else
-       msg = "literal target out of range";
-    }
-
-  return vsprint_msg (opname, ": %s", strlen (msg) + 2, msg);
-}
-
-
 /* This function is registered as the "special_function" in the
    Xtensa howto for handling simplify operations.
    bfd_perform_relocation / bfd_install_relocation use it to