/* xtensa-dis.c. Disassembly functions for Xtensa.
- Copyright (C) 2003-2018 Free Software Foundation, Inc.
+ Copyright (C) 2003-2021 Free Software Foundation, Inc.
Contributed by Bob Wilson at Tensilica, Inc. (bwilson@tensilica.com)
This file is part of the GNU opcodes library.
unsigned operand_val)
{
xtensa_isa isa = xtensa_default_isa;
- int signed_operand_val;
+ int signed_operand_val, status;
+ bfd_byte litbuf[4];
if (show_raw_fields)
{
&operand_val, memaddr);
info->target = operand_val;
(*info->print_address_func) (info->target, info);
+ /* Also display value loaded by L32R (but not if reloc exists,
+ those tend to be wrong): */
+ if ((info->flags & INSN_HAS_RELOC) == 0
+ && !strcmp ("l32r", xtensa_opcode_name (isa, opc)))
+ status = (*info->read_memory_func) (operand_val, litbuf, 4, info);
+ else
+ status = -1;
+
+ if (status == 0)
+ {
+ unsigned literal = bfd_get_bits (litbuf, 32,
+ info->endian == BFD_ENDIAN_BIG);
+
+ (*info->fprintf_func) (info->stream, " (");
+ (*info->print_address_func) (literal, info);
+ (*info->fprintf_func) (info->stream, ")");
+ }
}
else
{
static bfd_byte *byte_buf = NULL;
static xtensa_insnbuf insn_buffer = NULL;
static xtensa_insnbuf slot_buffer = NULL;
- int first, first_slot, valid_insn = 0;
+ int first, first_slot, valid_insn;
property_table_entry *insn_block;
if (!xtensa_default_isa)
{
/* Reset insn_table_entries. */
priv.insn_table_entry_count = 0;
- if (priv.insn_table_entries)
- free (priv.insn_table_entries);
+ free (priv.insn_table_entries);
priv.insn_table_entries = NULL;
}
priv.last_section = section;
priv.insn_table_entry_count =
xtensa_read_table_entries (abfd, section,
&priv.insn_table_entries,
- XTENSA_PROP_SEC_NAME, FALSE);
+ XTENSA_PROP_SEC_NAME, false);
if (priv.insn_table_entry_count == 0)
{
- if (priv.insn_table_entries)
- free (priv.insn_table_entries);
+ free (priv.insn_table_entries);
priv.insn_table_entries = NULL;
/* Backwards compatibility support. */
priv.insn_table_entry_count =
xtensa_read_table_entries (abfd, section,
&priv.insn_table_entries,
- XTENSA_INSN_SEC_NAME, FALSE);
+ XTENSA_INSN_SEC_NAME, false);
}
priv.insn_table_cur_idx = 0;
xtensa_coalesce_insn_tables (&priv);
/* Error return. */
return -1;
- /* Don't set "isa" before the setjmp to keep the compiler from griping. */
- isa = xtensa_default_isa;
- size = 0;
- nslots = 0;
-
/* Fetch the maximum size instruction. */
bytes_fetched = fetch_data (info, memaddr);
insn_block = xtensa_find_table_entry (memaddr, info);
+ /* Don't set "isa" before the setjmp to keep the compiler from griping. */
+ isa = xtensa_default_isa;
+ size = 0;
+ nslots = 0;
+ valid_insn = 0;
+ fmt = 0;
if (!insn_block || (insn_block->flags & XTENSA_PROP_INSN))
{
/* Copy the bytes into the decode buffer. */
if (insn_block && (insn_block->flags & XTENSA_PROP_LITERAL)
&& (memaddr & 3) == 0 && bytes_fetched >= 4)
{
+ info->bytes_per_chunk = 4;
return 4;
}
else
if (nslots > 1)
(*info->fprintf_func) (info->stream, "{ ");
+ info->insn_type = dis_nonbranch;
+ info->insn_info_valid = 1;
+
first_slot = 1;
for (n = 0; n < nslots; n++)
{
(*info->fprintf_func) (info->stream, "%s",
xtensa_opcode_name (isa, opc));
+ if (xtensa_opcode_is_branch (isa, opc))
+ info->insn_type = dis_condbranch;
+ else if (xtensa_opcode_is_jump (isa, opc))
+ info->insn_type = dis_branch;
+ else if (xtensa_opcode_is_call (isa, opc))
+ info->insn_type = dis_jsr;
+
/* Print the operands (if any). */
noperands = xtensa_opcode_num_operands (isa, opc);
first = 1;