print_insn_hexagon() read each instruction word as a host-order integer,
thus getting them inverted on a big-endian host. Instead, read into a
byte buffer and convert with ldl_le_p().

Signed-off-by: Matheus Tavares Bernardino <[email protected]>
---
 disas/hexagon.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/disas/hexagon.c b/disas/hexagon.c
index e2d3804606..62e0cba661 100644
--- a/disas/hexagon.c
+++ b/disas/hexagon.c
@@ -20,6 +20,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/bswap.h"
 #include "disas/dis-asm.h"
 #include "target/hexagon/cpu_bits.h"
 
@@ -37,9 +38,9 @@ int print_insn_hexagon(bfd_vma memaddr, struct 
disassemble_info *info)
     int i, len;
 
     for (i = 0; i < PACKET_WORDS_MAX && !found_end; i++) {
+        bfd_byte insn[sizeof(uint32_t)];
         int status = (*info->read_memory_func)(memaddr + i * sizeof(uint32_t),
-                                               (bfd_byte *)&words[i],
-                                               sizeof(uint32_t), info);
+                                               insn, sizeof(uint32_t), info);
         if (status) {
             if (i > 0) {
                 break;
@@ -47,6 +48,7 @@ int print_insn_hexagon(bfd_vma memaddr, struct 
disassemble_info *info)
             (*info->memory_error_func)(status, memaddr, info);
             return status;
         }
+        words[i] = ldl_le_p(insn);
         if (is_packet_end(words[i])) {
             found_end = true;
         }
-- 
2.37.2


Reply via email to