diff options
author | Andre Vieira <andre.simoesdiasvieira@arm.com> | 2024-11-08 10:06:26 +0000 |
---|---|---|
committer | Andre Vieira <andre.simoesdiasvieira@arm.com> | 2024-11-08 10:06:38 +0000 |
commit | 2c9d089c901afe818f4daa841ced44b87c517d82 (patch) | |
tree | e27d8ec7783e9d8feac433ebda912d05a51c50ff /opcodes | |
parent | 39d45a7031659fcc9f169fa90d6eb2e4cb88167b (diff) | |
download | fsf-binutils-gdb-2c9d089c901afe818f4daa841ced44b87c517d82.zip fsf-binutils-gdb-2c9d089c901afe818f4daa841ced44b87c517d82.tar.gz fsf-binutils-gdb-2c9d089c901afe818f4daa841ced44b87c517d82.tar.bz2 |
arm, objdump: Make objdump use bfd's machine detection to drive disassembly
For any arm elf target, disable an old piece of code that forced disassembly to
disassemble for 'unknown architecture' which once upon a time meant it would
disassemble ANY arm instruction. This is no longer true with the addition of
Armv8.1-M Mainline, as there are conflicting encodings for different thumb
instructions.
BFD however can detect what architecture the object file was assembled for
using information in the notes section. So if available, we use that,
otherwise we default to the old 'unknown' behaviour.
With the changes above code, a mode changing 'bx lr' assembled for armv4 with
the option --fix-v4bx will result in an object file that is recognized by bfd
as one for the armv4 architecture. The disassembler now disassembles this
encoding as a BX even for Armv4 architectures, but warns the user when
disassembling for Armv4 that this instruction is only valid from Armv4T
onwards.
Remove the unused and wrongfully defined ARM_ARCH_V8A_CRC, and
define and use a ARM_ARCH_V8R_CRC to make sure instructions enabled by
-march=armv8-r+crc are disassembled correctly.
Patch up some of the tests cases, see a brief explanation for each below.
inst.d:
This test checks the assembly & disassembly of basic instructions in armv3m. I
changed the expected behaviour for teqp, cmnp cmpp and testp instructions to
properly print p when disassembling, whereas before, in the 'unknown' case it
would disassemble these as UNPREDICTABLE as they were changed in later
architectures.
nops.d:
Was missing an -march, added one to make sure we were testing the right
behavior of NOP<c> instructions.
unpredictable.d:
Was missing an -march, added armv6 as that reproduced the behaviour being
tested.
Diffstat (limited to 'opcodes')
-rw-r--r-- | opcodes/arm-dis.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/opcodes/arm-dis.c b/opcodes/arm-dis.c index d1d7ca3..b395cdc 100644 --- a/opcodes/arm-dis.c +++ b/opcodes/arm-dis.c @@ -3364,6 +3364,7 @@ static const struct mopcode32 mve_opcodes[] = %C print the PSR sub type. %U print barrier type. %P print address for pli instruction. + %T print 'from Armv4T onwards' %<bitfield>r print as an ARM register %<bitfield>T print as an ARM register + 1 @@ -3392,8 +3393,8 @@ static const struct opcode32 arm_opcodes[] = {ARM_FEATURE_CORE_LOW (ARM_EXT_V1), 0xe7f000f0, 0xfff000f0, "udf\t%{I:#%e%}"}, - {ARM_FEATURE_CORE_LOW (ARM_EXT_V4T | ARM_EXT_V5), - 0x012FFF10, 0x0ffffff0, "bx%c\t%0-3r"}, + {ARM_FEATURE_CORE_LOW (ARM_EXT_V4), + 0x012FFF10, 0x0ffffff0, "bx%c\t%0-3r%T"}, {ARM_FEATURE_CORE_LOW (ARM_EXT_V2), 0x00000090, 0x0fe000f0, "mul%20's%c\t%16-19R, %0-3R, %8-11R"}, {ARM_FEATURE_CORE_LOW (ARM_EXT_V2), @@ -10103,6 +10104,18 @@ print_insn_arm (bfd_vma pc, struct disassemble_info *info, long given) value_in_comment = print_arm_address (pc, info, given | (1 << P_BIT)); break; + case 'T': + /* Armv4 does not have a BX instruction, however, when + assembled with the --fix-v4bx option GAS will accept + and assemble a BX instruction when assembling for + Armv4. When disassembling we also disassemble it as a + BX instruction, but do make the user aware that this + instruction is only supported on HW from Armv4T + onwards. */ + if (info->mach == bfd_mach_arm_4) + func (stream, dis_style_text, "\t@ from Armv4T onwards"); + break; + case 'S': allow_unpredictable = true; /* Fall through. */ @@ -12292,7 +12305,7 @@ select_arm_features (unsigned long mach, ARM_MERGE_FEATURE_SETS (arch_fset, arch_fset, armv8_6_ext_fset); break; } - case bfd_mach_arm_8R: ARM_SET_FEATURES (ARM_ARCH_V8R); break; + case bfd_mach_arm_8R: ARM_SET_FEATURES (ARM_ARCH_V8R_CRC); break; case bfd_mach_arm_8M_BASE: ARM_SET_FEATURES (ARM_ARCH_V8M_BASE); break; case bfd_mach_arm_8M_MAIN: ARM_SET_FEATURES (ARM_ARCH_V8M_MAIN); break; case bfd_mach_arm_8_1M_MAIN: @@ -12358,10 +12371,16 @@ print_insn (bfd_vma pc, struct disassemble_info *info, bool little) { static struct arm_private_data private; - if ((info->flags & USER_SPECIFIED_MACHINE_TYPE) == 0) + if (info->flavour != bfd_target_elf_flavour + && (info->flags & USER_SPECIFIED_MACHINE_TYPE) == 0) /* If the user did not use the -m command line switch then default to disassembling all types of ARM instruction. + If this is an arm elf target, build attributes will be used to + determine info->mach, which enable us to be more accurate when + disassembling since we know what the target architecture version is. + For any other target see the comment below: + The info->mach value has to be ignored as this will be based on the default archictecture for the target and/or hints in the notes section, but it will never be greater than the current largest arm |