This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
improve Xtensa error messages
- From: Bob Wilson <bwilson at tensilica dot com>
- To: binutils at sources dot redhat dot com
- Date: Fri, 15 Jul 2005 13:53:20 -0700
- Subject: improve Xtensa error messages
This patch makes some minor improvements to the error message resulting
from an out-of-range Xtensa literal. Tested with an xtensa-elf target
(which exposed some unrelated regressions that I will be looking into
shortly) and committed on the mainline.
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.
Index: elf32-xtensa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-xtensa.c,v
retrieving revision 1.56
diff -u -p -r1.56 elf32-xtensa.c
--- elf32-xtensa.c 12 Jul 2005 11:53:56 -0000 1.56
+++ elf32-xtensa.c 15 Jul 2005 20:34:26 -0000
@@ -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 *h
|| 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 *h
}
-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
}
-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