/* 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
|| 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;
}
}
-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,
}
-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
*error_message = "";
*error_message = vsprint_msg (*error_message, ": (%s + 0x%lx)",
strlen (symbol->name) + 17,
- symbol->name, reloc_entry->addend);
+ symbol->name,
+ (unsigned long) reloc_entry->addend);
}
return flag;
&& !((input_section->flags & SEC_DEBUGGING) != 0
&& h->def_dynamic))
(*_bfd_error_handler)
- (_("%B(%A+0x%lx): unresolvable relocation against symbol `%s'"),
+ (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
input_bfd,
input_section,
(long) rel->r_offset,
+ howto->name,
h->root.root.string);
/* There's no point in calling bfd_perform_relocation here.
!= sec->output_section)
return FALSE;
+ /* Absolute literals in the same output section can always be
+ combined. */
+ if (reloc[i].is_abs_literal)
+ continue;
+
/* A literal with no PC-relative relocations can be moved anywhere. */
if (reloc[i].opnd != -1)
{
#define TARGET_BIG_NAME "elf32-xtensa-be"
#define ELF_ARCH bfd_arch_xtensa
-/* The new EM_XTENSA value will be recognized beginning in the Xtensa T1040
- release. However, we still have to generate files with the EM_XTENSA_OLD
- value so that pre-T1040 tools can read the files. As soon as we stop
- caring about pre-T1040 tools, the following two values should be
- swapped. At the same time, any other code that uses EM_XTENSA_OLD
- should be changed to use EM_XTENSA. */
-#define ELF_MACHINE_CODE EM_XTENSA_OLD
-#define ELF_MACHINE_ALT1 EM_XTENSA
+#define ELF_MACHINE_CODE EM_XTENSA
+#define ELF_MACHINE_ALT1 EM_XTENSA_OLD
#if XCHAL_HAVE_MMU
#define ELF_MAXPAGESIZE (1 << XCHAL_MMU_MIN_PTE_PAGE_SIZE)