aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf32-xtensa.c
diff options
context:
space:
mode:
authorBob Wilson <bob.wilson@acm.org>2005-07-15 20:43:37 +0000
committerBob Wilson <bob.wilson@acm.org>2005-07-15 20:43:37 +0000
commit2db662bee41b0bf700e4783c89e9c1a8e74f782d (patch)
tree61404ef90fac8890409774652b58cb3e75fdeecd /bfd/elf32-xtensa.c
parent0a665bfd86ad49ddf0ed8db24e8cb2daa617c02f (diff)
downloadgdb-2db662bee41b0bf700e4783c89e9c1a8e74f782d.zip
gdb-2db662bee41b0bf700e4783c89e9c1a8e74f782d.tar.gz
gdb-2db662bee41b0bf700e4783c89e9c1a8e74f782d.tar.bz2
* 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.
Diffstat (limited to 'bfd/elf32-xtensa.c')
-rw-r--r--bfd/elf32-xtensa.c55
1 files changed, 26 insertions, 29 deletions
diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
index b6ab7de..7950889 100644
--- a/bfd/elf32-xtensa.c
+++ b/bfd/elf32-xtensa.c
@@ -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