Skip to content

Commit d26adc2

Browse files
authored
fixes endianness in the raw loader (#1348)
Without it the target could be derived incorrectly, e.g., for arm we were deriving a bidirectional target, which is not what we want.
1 parent e9f8a90 commit d26adc2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

plugins/raw/raw_main.ml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ let doc_template = {|
5555
(declare bits (size int))
5656
(declare base-address (addr int))
5757
(declare entry-point (addr int))
58+
(declare is-little-endian (flag bool))
5859
(declare mapped (addr int) (size int) (off int))
5960
(declare code-region (addr int) (size int) (off int))
6061
(declare named-region (addr int) (size int) (name str))
@@ -66,6 +67,7 @@ let doc_template = {|
6667
(bits $bits)
6768
(base-address $base)
6869
(entry-point $entry)
70+
(is-little-endian $endian)
6971
(mapped $base $length $offset)
7072
(code-region $base $length $offset)
7173
(named-region $base $length code)
@@ -80,6 +82,10 @@ let register_loader ctxt =
8082
"arch", (ctxt-->arch);
8183
"offset", Int64.to_string @@ ctxt-->offset;
8284
"base", Bitvec.to_string @@ ctxt-->base_address;
85+
"endian", Bool.to_string begin match Arch.of_string (ctxt-->arch) with
86+
| None -> true
87+
| Some arch -> Poly.equal (Arch.endian arch) LittleEndian
88+
end;
8389
"bits", Int.to_string @@ begin
8490
match Arch.of_string (ctxt-->arch) with
8591
| None -> ctxt-->bits

0 commit comments

Comments
 (0)