aboutsummaryrefslogtreecommitdiff
path: root/opcodes/arm-dis.c
diff options
context:
space:
mode:
authorStan Shebs <shebs@codesourcery.com>2008-07-07 18:35:24 +0000
committerStan Shebs <shebs@codesourcery.com>2008-07-07 18:35:24 +0000
commitbd2e25575ca4a83f509c2d6ea3c55d93eada210c (patch)
tree3687ce773bec24395d738e8fedf9fc4826748326 /opcodes/arm-dis.c
parentb7292df399476ace3dc1eb8ae78b87e6ef91808e (diff)
downloadfsf-binutils-gdb-bd2e25575ca4a83f509c2d6ea3c55d93eada210c.zip
fsf-binutils-gdb-bd2e25575ca4a83f509c2d6ea3c55d93eada210c.tar.gz
fsf-binutils-gdb-bd2e25575ca4a83f509c2d6ea3c55d93eada210c.tar.bz2
2008-07-07 Stan Shebs <stan@codesourcery.com>
* dis-init.c (init_disassemble_info): Init endian_code field. * arm-dis.c (print_insn): Disassemble code according to setting of endian_code. (print_insn_big_arm): Detect when BE8 extension flag has been set.
Diffstat (limited to 'opcodes/arm-dis.c')
-rw-r--r--opcodes/arm-dis.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/opcodes/arm-dis.c b/opcodes/arm-dis.c
index e9a48e5..155e495 100644
--- a/opcodes/arm-dis.c
+++ b/opcodes/arm-dis.c
@@ -3974,6 +3974,7 @@ print_insn (bfd_vma pc, struct disassemble_info *info, bfd_boolean little)
int status;
int is_thumb = FALSE;
int is_data = FALSE;
+ int little_code;
unsigned int size = 4;
void (*printer) (bfd_vma, struct disassemble_info *, long);
bfd_boolean found = FALSE;
@@ -3986,6 +3987,10 @@ print_insn (bfd_vma pc, struct disassemble_info *info, bfd_boolean little)
info->disassembler_options = NULL;
}
+ /* Decide if our code is going to be little-endian, despite what the
+ function argument might say. */
+ little_code = ((info->endian_code == BFD_ENDIAN_LITTLE) || little);
+
/* First check the full symtab for a mapping symbol, even if there
are no usable non-mapping symbols for this address. */
if (info->symtab != NULL
@@ -4131,7 +4136,7 @@ print_insn (bfd_vma pc, struct disassemble_info *info, bfd_boolean little)
size = 4;
status = info->read_memory_func (pc, (bfd_byte *)b, 4, info);
- if (little)
+ if (little_code)
given = (b[0]) | (b[1] << 8) | (b[2] << 16) | (b[3] << 24);
else
given = (b[3]) | (b[2] << 8) | (b[1] << 16) | (b[0] << 24);
@@ -4147,7 +4152,7 @@ print_insn (bfd_vma pc, struct disassemble_info *info, bfd_boolean little)
size = 2;
status = info->read_memory_func (pc, (bfd_byte *)b, 2, info);
- if (little)
+ if (little_code)
given = (b[0]) | (b[1] << 8);
else
given = (b[1]) | (b[0] << 8);
@@ -4161,7 +4166,7 @@ print_insn (bfd_vma pc, struct disassemble_info *info, bfd_boolean little)
|| (given & 0xF800) == 0xE800)
{
status = info->read_memory_func (pc + 2, (bfd_byte *)b, 2, info);
- if (little)
+ if (little_code)
given = (b[0]) | (b[1] << 8) | (given << 16);
else
given = (b[1]) | (b[0] << 8) | (given << 16);
@@ -4172,7 +4177,7 @@ print_insn (bfd_vma pc, struct disassemble_info *info, bfd_boolean little)
}
if (ifthen_address != pc)
- find_ifthen_state(pc, info, little);
+ find_ifthen_state(pc, info, little_code);
if (ifthen_state)
{
@@ -4210,6 +4215,12 @@ print_insn (bfd_vma pc, struct disassemble_info *info, bfd_boolean little)
int
print_insn_big_arm (bfd_vma pc, struct disassemble_info *info)
{
+ /* Detect BE8-ness and record it in the disassembler info. */
+ if (info->flavour == bfd_target_elf_flavour
+ && info->section != NULL
+ && (elf_elfheader (info->section->owner)->e_flags & EF_ARM_BE8))
+ info->endian_code = BFD_ENDIAN_LITTLE;
+
return print_insn (pc, info, FALSE);
}