aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorVictor Do Nascimento <victor.donascimento@arm.com>2024-04-16 11:49:15 +0100
committerVictor Do Nascimento <victor.donascimento@arm.com>2024-04-17 11:18:55 +0100
commit5b1c70bfe0d8f84dc28237d6150b7b9d57c791a8 (patch)
treecb4085d24c5ff0dd9d4040509b1470f8ed7b40e2 /include
parent75d277b1f506dcfbedfee3bef078dfe2b484958b (diff)
downloadbinutils-5b1c70bfe0d8f84dc28237d6150b7b9d57c791a8.zip
binutils-5b1c70bfe0d8f84dc28237d6150b7b9d57c791a8.tar.gz
binutils-5b1c70bfe0d8f84dc28237d6150b7b9d57c791a8.tar.bz2
aarch64: Remove asserts from operand qualifier decoders [PR31595]
Given that the disassembler should never abort when decoding (potentially random) data, assertion statements in the `get_*reg_qualifier_from_value' function family prove problematic. Consider the random 32-bit word W, encoded in a data segment and encountered on execution of `objdump -D <obj_name>'. If: (W & ~opcode_mask) == valid instruction Then before `print_insn_aarch64_word' has a chance to report the instruction as potentially undefined, an attempt will be made to have the qualifiers for the instruction's register operands (if any) decoded. If the relevant bits do not map onto a valid qualifier for the matched instruction-like word, an abort will be triggered and the execution of objdump aborted. As this scenario is perfectly feasible and, in light of the fact that objdump must successfully decode all sections of a given object file, it is not appropriate to assert in this family of functions. Therefore, we add a new pseudo-qualifier `AARCH64_OPND_QLF_ERR' for handling invalid qualifier-associated values and re-purpose the assertion conditions in qualifier-retrieving functions to be the predicate guarding the returning of the calculated qualifier type. If the predicate fails, we return this new qualifier and allow the caller to handle the error as appropriate. As these functions are called either from within `aarch64_extract_operand' or `do_special_decoding', both of which are expected to return non-zero values, it suffices that callers return zero upon encountering `AARCH64_OPND_QLF_ERR'. Ar present the error presented in the hypothetical scenario has been encountered in `get_sreg_qualifier_from_value', but the change is made to the whole family to keep the interface consistent. Bug: https://sourceware.org/PR31595
Diffstat (limited to 'include')
-rw-r--r--include/opcode/aarch64.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/opcode/aarch64.h b/include/opcode/aarch64.h
index 2fca952..e8fe93e 100644
--- a/include/opcode/aarch64.h
+++ b/include/opcode/aarch64.h
@@ -894,6 +894,9 @@ enum aarch64_opnd_qualifier
/* Special qualifier helping retrieve qualifier information during the
decoding time (currently not in use). */
AARCH64_OPND_QLF_RETRIEVE,
+
+ /* Special qualifier used for indicating error in qualifier retrieval. */
+ AARCH64_OPND_QLF_ERR,
};
/* Instruction class. */