[PATCH] D130359: [llvm-objdump, ARM] Make dumpARMELFData line up with instructions.
Simon Tatham via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 22 07:18:43 PDT 2022
simon_tatham created this revision.
simon_tatham added reviewers: MaskRay, ostannard, DavidSpickett.
Herald added subscribers: StephenFan, rupprecht, kristof.beyls, emaste.
Herald added a reviewer: jhenderson.
Herald added a project: All.
simon_tatham requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
The whitespace in output lines containing disassembled instructions
was extremely mismatched against that in `.word` lines produced from
dumping literal pools and other data in Arm ELF files. This patch
adjusts `dumpARMELFData` so that it uses the same alignment system as
in the instruction pretty-printers. Now the two classes of line are
aligned sensibly alongside each other.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D130359
Files:
llvm/test/tools/llvm-objdump/ELF/AArch64/disassemble-align.s
llvm/tools/llvm-objdump/llvm-objdump.cpp
Index: llvm/tools/llvm-objdump/llvm-objdump.cpp
===================================================================
--- llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -994,12 +994,14 @@
uint64_t End, const ObjectFile &Obj,
ArrayRef<uint8_t> Bytes,
ArrayRef<MappingSymbolPair> MappingSymbols,
- raw_ostream &OS) {
+ const MCSubtargetInfo &STI, raw_ostream &OS) {
support::endianness Endian =
Obj.isLittleEndian() ? support::little : support::big;
- OS << format("%8" PRIx64 ":\t", SectionAddr + Index);
+ size_t Start = OS.tell();
+ OS << format("%8" PRIx64 ": ", SectionAddr + Index);
if (Index + 4 <= End) {
dumpBytes(Bytes.slice(Index, 4), OS);
+ AlignToInstStartColumn(Start, STI, OS);
OS << "\t.word\t"
<< format_hex(support::endian::read32(Bytes.data() + Index, Endian),
10);
@@ -1007,13 +1009,14 @@
}
if (Index + 2 <= End) {
dumpBytes(Bytes.slice(Index, 2), OS);
- OS << "\t\t.short\t"
- << format_hex(support::endian::read16(Bytes.data() + Index, Endian),
- 6);
+ AlignToInstStartColumn(Start, STI, OS);
+ OS << "\t.short\t"
+ << format_hex(support::endian::read16(Bytes.data() + Index, Endian), 6);
return 2;
}
dumpBytes(Bytes.slice(Index, 1), OS);
- OS << "\t\t.byte\t" << format_hex(Bytes[0], 4);
+ AlignToInstStartColumn(Start, STI, OS);
+ OS << "\t.byte\t" << format_hex(Bytes[0], 4);
return 1;
}
@@ -1606,7 +1609,7 @@
if (DumpARMELFData) {
Size = dumpARMELFData(SectionAddr, Index, End, Obj, Bytes,
- MappingSymbols, FOS);
+ MappingSymbols, *STI, FOS);
} else {
// When -z or --disassemble-zeroes are given we always dissasemble
// them. Otherwise we might want to skip zero bytes we see.
Index: llvm/test/tools/llvm-objdump/ELF/AArch64/disassemble-align.s
===================================================================
--- llvm/test/tools/llvm-objdump/ELF/AArch64/disassemble-align.s
+++ llvm/test/tools/llvm-objdump/ELF/AArch64/disassemble-align.s
@@ -7,7 +7,7 @@
# CHECK-NEXT: 4: d503201f |nop
# CHECK-EMPTY:
# CHECK-NEXT:0000000000000008 <$d.1>:
-# CHECK-NEXT: 8:|ff ff 00 00|.word|0x0000ffff
+# CHECK-NEXT: 8: ff ff 00 00 |.word|0x0000ffff
add x2, x3, #4
nop
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130359.446825.patch
Type: text/x-patch
Size: 2580 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220722/7f1c0567/attachment.bin>
More information about the llvm-commits
mailing list