Skip to content

Commit 8915677

Browse files
authored
preserves the encoding name of the instruction (#1303)
Ensures that the instruction encoding matches with the name of encoding that is used to decode it. Before this fix, the encoding name was sometimes taken from the triple, which enforced us to have the names of encoding that match with the triple. We can now safely peek any encoding name.
1 parent c54b59a commit 8915677

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

lib/arm/arm_target.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ let enable_arch () =
382382

383383

384384
let llvm_a32 = CT.Language.declare ~package "llvm-armv7"
385-
let llvm_t32 = CT.Language.declare ~package "llvm-thumbv7"
385+
let llvm_t32 = CT.Language.declare ~package "llvm-thumb"
386386
let llvm_a64 = CT.Language.declare ~package "llvm-aarch64"
387387

388388
module Dis = Disasm_expert.Basic

lib/bap_disasm/bap_disasm_basic.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,9 @@ let make_name target encoding =
561561
(Theory.Language.to_string encoding)
562562
(Theory.Target.to_string target)
563563

564+
let encoding_name encoding =
565+
KB.Name.unqualified @@ Theory.Language.name encoding
566+
564567
let register encoding construct =
565568
if Hashtbl.mem constructors encoding
566569
then invalid_argf "A disassembler backend for the encoding %s \
@@ -578,10 +581,7 @@ let register encoding construct =
578581
d.users <- d.users + 1;
579582
Hashtbl.add_exn disassemblers ~key:name ~data:d
580583
end;
581-
Ok dis)
582-
583-
let encoding_name encoding =
584-
KB.Name.unqualified @@ Theory.Language.name encoding
584+
Ok {dis with enc = encoding_name encoding})
585585

586586
let lookup target encoding =
587587
let name = make_name target encoding in
@@ -595,7 +595,7 @@ let lookup target encoding =
595595
| Some create -> create target
596596

597597
let create ?(debug_level=0) ?(cpu="") ?(attrs="") ?(backend="llvm") triple =
598-
let name = sprintf "%s-%s%s" backend triple cpu in
598+
let name = String.concat ~sep:"-" [backend; triple; cpu] ^ attrs in
599599
match Hashtbl.find disassemblers name with
600600
| Some d ->
601601
d.users <- d.users + 1;

plugins/arm/semantics/thumb.lisp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
(declare (context (target armv4+le)))
55

66
(defpackage thumb (:use core target arm))
7-
(defpackage llvm-thumbv7 (:use thumb))
7+
(defpackage llvm-thumb (:use thumb))
88

99
(in-package thumb)
1010

0 commit comments

Comments
 (0)