[llvm] e35fec2 - [llvm-objdump, ARM] Fix .byte directives dumping the wrong byte.

Simon Tatham via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 25 06:56:08 PDT 2022


Author: Simon Tatham
Date: 2022-07-25T14:55:33+01:00
New Revision: e35fec2c0277c27f13d06e4a3a8a3e676286daab

URL: https://github.com/llvm/llvm-project/commit/e35fec2c0277c27f13d06e4a3a8a3e676286daab
DIFF: https://github.com/llvm/llvm-project/commit/e35fec2c0277c27f13d06e4a3a8a3e676286daab.diff

LOG: [llvm-objdump,ARM] Fix .byte directives dumping the wrong byte.

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/test/tools/llvm-objdump/ELF/AArch64/elf-aarch64-mapping-symbols.test b/llvm/test/tools/llvm-objdump/ELF/AArch64/elf-aarch64-mapping-symbols.test
index 9b628d7b0ed5f..0ef05f38220c8 100644
--- a/llvm/test/tools/llvm-objdump/ELF/AArch64/elf-aarch64-mapping-symbols.test
+++ b/llvm/test/tools/llvm-objdump/ELF/AArch64/elf-aarch64-mapping-symbols.test
@@ -11,8 +11,9 @@ msgend:
 .section .myothersection,"ax", at 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

diff  --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 9e4fa7c0d9dd7..c4860885d2394 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -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;
 }
 


        


More information about the llvm-commits mailing list