diff options
Diffstat (limited to 'src/arch/arm/v7/opdefs')
-rw-r--r-- | src/arch/arm/v7/opdefs/Makefile.am | 5 | ||||
-rw-r--r-- | src/arch/arm/v7/opdefs/add_A886.d | 90 | ||||
-rw-r--r-- | src/arch/arm/v7/opdefs/b_A8818.d | 125 | ||||
-rw-r--r-- | src/arch/arm/v7/opdefs/bx_A8827.d | 2 | ||||
-rw-r--r-- | src/arch/arm/v7/opdefs/cbnz_A8829.d | 54 | ||||
-rw-r--r-- | src/arch/arm/v7/opdefs/ldr_A8865.d | 73 | ||||
-rw-r--r-- | src/arch/arm/v7/opdefs/lsl_A8894.d | 98 |
7 files changed, 446 insertions, 1 deletions
diff --git a/src/arch/arm/v7/opdefs/Makefile.am b/src/arch/arm/v7/opdefs/Makefile.am index 348cbf6..948c9da 100644 --- a/src/arch/arm/v7/opdefs/Makefile.am +++ b/src/arch/arm/v7/opdefs/Makefile.am @@ -25,13 +25,16 @@ ARMV7_DEFS = \ adc_A881.d \ adc_A882.d \ add_A885.d \ + add_A886.d \ add_A887.d \ and_A8813.d \ and_A8814.d \ + b_A8818.d \ bic_A8821.d \ bic_A8822.d \ bl_A8825.d \ bx_A8827.d \ + cbnz_A8829.d \ cmn_A8834.d \ cmn_A8835.d \ cmp_A8837.d \ @@ -40,6 +43,8 @@ ARMV7_DEFS = \ eor_A8847.d \ ldr_A8862.d \ ldr_A8864.d \ + ldr_A8865.d \ + lsl_A8894.d \ mla_A88100.d \ mls_A88101.d \ mov_A88102.d \ diff --git a/src/arch/arm/v7/opdefs/add_A886.d b/src/arch/arm/v7/opdefs/add_A886.d new file mode 100644 index 0000000..fd8f7a4 --- /dev/null +++ b/src/arch/arm/v7/opdefs/add_A886.d @@ -0,0 +1,90 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2014 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see <http://www.gnu.org/licenses/>. + */ + + +@title ADD (register, Thumb) + +@encoding(t1) { + + @half 0 0 0 1 1 0 0 Rm(3) Rn(3) Rd(3) + + @syntax <Rd> <Rn> <Rm> + + @conv { + + Rd = Register(Rd) + Rn = Register(Rn) + Rm = Register(Rm) + + } + +} + +@encoding(t2) { + + @half 0 1 0 0 0 1 0 0 DN(1) Rm(4) Rdn(3) + + @syntax <Rdn> <Rm> + + @conv { + + Rdn = Register(DN:Rdn) + Rm = Register(Rm) + + } + + @rules { + + //if (DN:Rdn) == '1101' || Rm == '1101' then SEE ADD (SP plus register); + //if n == 15 && m == 15 then UNPREDICTABLE; + //if d == 15 && InITBlock() && !LastInITBlock() then UNPREDICTABLE; + + } + +} + +@encoding(T3) { + + @word 1 1 1 0 1 0 1 1 0 0 0 S(1) Rn(4) 0 imm3(3) Rd(4) imm2(2) type(2) Rm(4) + + @syntax {S} ".W" <Rd> <Rn> <Rm> <?shift> + + @conv { + + S = SetFlags(S) + Rd = Register(Rd) + Rn = Register(Rn) + Rm = Register(Rm) + shift = DecodeImmShift(type, imm3:imm2) + + } + + @rules { + + //if Rd == '1111' && S == '1' then SEE CMN (register); + //if Rn == '1101' then SEE ADD (SP plus register); + //if d == 13 || (d == 15 && S == '0') || n == 15 || m IN {13,15} then UNPREDICTABLE; + + + } + +} diff --git a/src/arch/arm/v7/opdefs/b_A8818.d b/src/arch/arm/v7/opdefs/b_A8818.d new file mode 100644 index 0000000..50600d4 --- /dev/null +++ b/src/arch/arm/v7/opdefs/b_A8818.d @@ -0,0 +1,125 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2014 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see <http://www.gnu.org/licenses/>. + */ + + +@title B + +@encoding(t1) { + + @half 1 1 0 1 cond(4) top(1) imm8(7) + + @syntax {c} <label> + + @conv { + + c = Condition(cond) + label = SignExtend(top:imm8:'0', top, 32) + + } + + @rules { + + //if cond == '1110' then UNDEFINED; + //if cond == '1111' then SEE SVC; + + } + +} + +@encoding(t2) { + + @half 1 1 1 0 0 top(1) imm11(10) + + @syntax <label> + + @conv { + + label = SignExtend(top:imm11:'0', top, 32) + + } + + @rules { + + //if InITBlock() && !LastInITBlock() then UNPREDICTABLE; + + } + +} + +@encoding(T3) { + + @word 1 1 1 1 0 S(1) cond(4) imm6(6) 1 0 J1(1) 0 J2(1) imm11(11) + + @syntax {c} ".W" <label> + + @conv { + + c = Condition(cond) + label = SignExtend(S:J2:J1:imm6:imm11:'0', S, 32) + + } + + @rules { + + //if cond<3:1> == '111' then SEE "Related encodings"; + //if InITBlock() then UNPREDICTABLE; + + } + +} + +@encoding(T4) { + + @word 1 1 1 1 0 S(1) imm10(10) 1 0 J1(1) 1 J2(1) imm11(11) + + @syntax "b.W" <label> + + @conv { + + I1 = NOT(J1 EOR S) + I2 = NOT(J2 EOR S) + label = SignExtend(S:I1:I2:imm10:imm11:'0', S, 32) + + } + + @rules { + + //if InITBlock() && !LastInITBlock() then UNPREDICTABLE; + + } + +} + +@encoding(A1) { + + @word cond(4) 1 0 1 0 top(1) imm24(23) + + @syntax {c} <label> + + @conv { + + c = Condition(cond) + label = SignExtend(top:imm24:'00', top, 32) + + } + +} diff --git a/src/arch/arm/v7/opdefs/bx_A8827.d b/src/arch/arm/v7/opdefs/bx_A8827.d index 5acf969..45ccfd5 100644 --- a/src/arch/arm/v7/opdefs/bx_A8827.d +++ b/src/arch/arm/v7/opdefs/bx_A8827.d @@ -23,7 +23,7 @@ @title BX -@encoding(T1) { +@encoding(t1) { @half 0 1 0 0 0 1 1 1 0 Rm(4) 0 0 0 diff --git a/src/arch/arm/v7/opdefs/cbnz_A8829.d b/src/arch/arm/v7/opdefs/cbnz_A8829.d new file mode 100644 index 0000000..9ecf141 --- /dev/null +++ b/src/arch/arm/v7/opdefs/cbnz_A8829.d @@ -0,0 +1,54 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2014 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see <http://www.gnu.org/licenses/>. + */ + + +@title CBNZ, CBZ + +@encoding(t11) { + + @half 1 0 1 1 1 0 i(1) 1 imm5(5) Rn(3) + + @syntax <Rn> <label> + + @conv { + + Rn = Register(Rn) + label = ZeroExtend(i:imm5:'0', 7, 32); + + } + +} + +@encoding(t12) { + + @half 1 0 1 1 0 0 i(1) 1 imm5(5) Rn(3) + + @syntax "cbz" <Rn> <label> + + @conv { + + Rn = Register(Rn) + label = ZeroExtend(i:imm5:'0', 7, 32); + + } + +} diff --git a/src/arch/arm/v7/opdefs/ldr_A8865.d b/src/arch/arm/v7/opdefs/ldr_A8865.d new file mode 100644 index 0000000..11a8932 --- /dev/null +++ b/src/arch/arm/v7/opdefs/ldr_A8865.d @@ -0,0 +1,73 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2014 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see <http://www.gnu.org/licenses/>. + */ + + +@title LDR (register, Thumb) + +@encoding(t1) { + + @half 0 1 0 1 1 0 0 Rm(3) Rn(3) Rt(3) + + @syntax <Rgt> <access> + + @conv { + + Rgt = Register(Rt) + Rgn = Register(Rn) + Rgm = Register(Rm) + access = _MakeMemoryAccess(Rgn, Rgm, 0) + + } + + @rules { + + //if CurrentInstrSet() == InstrSet_ThumbEE then SEE "Modified operation in ThumbEE"; + + } + +} + +@encoding(T2) { + + @word 1 1 1 1 1 0 0 0 0 1 0 1 Rn(4) Rt(4) 0 0 0 0 0 0 imm2(2) Rm(4) + + @syntax "ldr.W" <Rgt>, <access> + + @conv { + + Rgt = Register(Rt) + Rgn = Register(Rn) + Rgm = Register(Rm) + shift = DecodeImmShift(0, imm2) + access = MakeShiftedMemoryAccess(Rgn, Rgm, shift, 0) + + } + + @rules { + + //if Rn == '1111' then SEE LDR (literal); + //if m IN {13,15} then UNPREDICTABLE; + //if t == 15 && InITBlock() && !LastInITBlock() then UNPREDICTABLE; + + } + +} diff --git a/src/arch/arm/v7/opdefs/lsl_A8894.d b/src/arch/arm/v7/opdefs/lsl_A8894.d new file mode 100644 index 0000000..59ac3e8 --- /dev/null +++ b/src/arch/arm/v7/opdefs/lsl_A8894.d @@ -0,0 +1,98 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2014 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see <http://www.gnu.org/licenses/>. + */ + + +@title LSL (immediate) + +@encoding(t1) { + + @half 0 0 0 0 0 imm5(5) Rm(3) Rd(3) + + @syntax <Rgd> <Rgm> <shiftv> + + @conv { + + Rgd = Register(Rd) + Rgm = Register(Rm) + shiftv = DecodeImmShiftValue(imm5) + + } + + @rules { + + if (imm5 == '00000') ; see MOV (register, Thumb) + //if (imm5 == '00000') ; see MOV (register) + + } + +} + +@encoding(T2) { + + @word 1 1 1 0 1 0 1 0 0 1 0 S(1) 1 1 1 1 0 imm3(3) Rd(4) imm2(2) 0 0 Rm(4) + + @syntax {s} <Rgd> <Rgm> <shiftv> + + @conv { + + S = SetFlags(S) + Rgd = Register(Rd) + Rgm = Register(Rm) + shiftv = DecodeImmShiftValue(imm3:imm2) + + } + + @rules { + + if ((imm3 == '000') && (imm2 == '00')) ; see MOV (register, Thumb) + //if ((imm3 == '000') && (imm2 == '00')) ; see MOV (register, Thumb) + //if (imm3:imm2) == '00000' then SEE MOV (register); + //if d IN {13,15} || m IN {13,15} then UNPREDICTABLE; + + } + +} + +@encoding(A1) { + + @word cond(4) 0 0 0 1 1 0 1 S(1) 0 0 0 0 Rd(4) imm5(5) 0 0 0 Rm(4) + + @syntax {S} {c} <Rgd> <Rgm> <shiftv> + + @conv { + + S = SetFlags(S) + c = Condition(cond) + Rgd = Register(Rd) + Rgm = Register(Rm) + shiftv = DecodeImmShiftValue(imm5) + + } + + @rules { + + //if Rd == '1111' && S == '1' then SEE SUBS PC, LR and related instructions; + //if imm5 == '00000' then SEE MOV (register); + + } + +} |