xtensa: use property tables for correct disassembly

xtensa disassembler does not use information from the .xt.prop sections
to switch between code/data disassembly in text sections. This may
result in incorrect disassembly when data is interpreted as code and
disassembler loses synchronization with instruction stream. Use .xt.prop
section information to correctly interpret code and data and synchronize
with instruction stream.

2018-06-04  Max Filippov  <jcmvbkbc@gmail.com>
bfd/
	* elf32-xtensa.c (xtensa_read_table_entries): Make global.
	(compute_fill_extra_space): Drop declaration. Rename function to
	xtensa_compute_fill_extra_space.
	(compute_ebb_actions, remove_dead_literal): Update references to
	compute_fill_extra_space.

include/
	* elf/xtensa.h (xtensa_read_table_entries)
	(xtensa_compute_fill_extra_space): New declarations.

opcodes/
	* xtensa-dis.c (bfd.h, elf/xtensa.h): New includes.
	(dis_private): Add new fields for property section tracking.
	(xtensa_coalesce_insn_tables, xtensa_find_table_entry)
	(xtensa_instruction_fits): New functions.
	(fetch_data): Bump minimal fetch size to 4.
	(print_insn_xtensa): Make struct dis_private static.
	Load and prepare property table on section change.
	Don't disassemble literals. Don't disassemble instructions that
	cross property table boundaries.
This commit is contained in:
Max Filippov
2018-05-24 11:22:14 -07:00
parent 8255c61b8a
commit 4b8e28c793
6 changed files with 231 additions and 27 deletions

View File

@ -210,6 +210,14 @@ typedef struct property_table_entry_t
#define XTENSA_PROP_INSN_ABSLIT 0x00020000
extern asection *xtensa_make_property_section (asection *, const char *);
extern int
xtensa_read_table_entries (bfd *abfd,
asection *section,
property_table_entry **table_p,
const char *sec_name,
bfd_boolean output_addr);
extern int
xtensa_compute_fill_extra_space (property_table_entry *entry);
#ifdef __cplusplus
}