[llvm-objdump,ARM] Fix .byte directives dumping the wrong byte.
authorSimon Tatham <simon.tatham@arm.com>
Mon, 25 Jul 2022 13:55:31 +0000 (14:55 +0100)
committerSimon Tatham <simon.tatham@arm.com>
Mon, 25 Jul 2022 13:55:33 +0000 (14:55 +0100)
The clause in `dumpARMELFData` that dumps a single byte as a `.byte`
directive was printing the operand of that directive as `Bytes[0]`,
not `Bytes[Index]`. In particular, this led to the `dumpBytes` output
to its left not matching it!

Reviewed By: DavidSpickett

Differential Revision: https://reviews.llvm.org/D130360

llvm/test/tools/llvm-objdump/ELF/AArch64/elf-aarch64-mapping-symbols.test
llvm/tools/llvm-objdump/llvm-objdump.cpp

index 9b628d7..0ef05f3 100644 (file)
@@ -11,8 +11,9 @@ msgend:
 .section .myothersection,"ax",@progbits
   adrp x1,mystr
 mystr:
-  .asciz "blah"
+  .ascii "blah"
   .size mystr, 4
+  .byte 0x9a
 
 # CHECK: Disassembly of section .mysection:
 # CHECK: <_start>:
@@ -27,4 +28,4 @@ mystr:
 # CHECK:        0:       01 00 00 90     adrp    x1, 0x0
 # CHECK: <mystr>:
 # CHECK:        4:       62 6c 61 68     .word
-# CHECK:        8:       00              .byte   0x01
+# CHECK:        8:       9a              .byte   0x9a
index 9e4fa7c..c486088 100644 (file)
@@ -914,7 +914,7 @@ static uint64_t dumpARMELFData(uint64_t SectionAddr, uint64_t Index,
     return 2;
   }
   dumpBytes(Bytes.slice(Index, 1), OS);
-  OS << "\t\t.byte\t" << format_hex(Bytes[0], 4);
+  OS << "\t\t.byte\t" << format_hex(Bytes[Index], 4);
   return 1;
 }