[PATCH] D135039: [llvm-objdump] --no-leading-addr: hide inline relocation offsets
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 4 10:00:31 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rGad92a3db2e43: [llvm-objdump] --no-leading-addr: hide inline relocation offsets (authored by MaskRay).
Changed prior to commit:
https://reviews.llvm.org/D135039?vs=464568&id=465062#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D135039/new/
https://reviews.llvm.org/D135039
Files:
llvm/docs/CommandGuide/llvm-objdump.rst
llvm/test/tools/llvm-objdump/X86/elf-disassemble-relocs-exec.test
llvm/tools/llvm-objdump/ObjdumpOpts.td
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
@@ -465,13 +465,16 @@
static void printRelocation(formatted_raw_ostream &OS, StringRef FileName,
const RelocationRef &Rel, uint64_t Address,
bool Is64Bits) {
- StringRef Fmt = Is64Bits ? "\t\t%016" PRIx64 ": " : "\t\t\t%08" PRIx64 ": ";
+ StringRef Fmt = Is64Bits ? "%016" PRIx64 ": " : "%08" PRIx64 ": ";
SmallString<16> Name;
SmallString<32> Val;
Rel.getTypeName(Name);
if (Error E = getRelocationValueString(Rel, Val))
reportError(std::move(E), FileName);
- OS << format(Fmt.data(), Address) << Name << "\t" << Val;
+ OS << (Is64Bits || !LeadingAddr ? "\t\t" : "\t\t\t");
+ if (LeadingAddr)
+ OS << format(Fmt.data(), Address);
+ OS << Name << "\t" << Val;
}
static void AlignToInstStartColumn(size_t Start, const MCSubtargetInfo &STI,
Index: llvm/tools/llvm-objdump/ObjdumpOpts.td
===================================================================
--- llvm/tools/llvm-objdump/ObjdumpOpts.td
+++ llvm/tools/llvm-objdump/ObjdumpOpts.td
@@ -129,7 +129,7 @@
"do not print the instruction bytes.">;
def no_leading_addr : Flag<["--"], "no-leading-addr">,
- HelpText<"When disassembling, do not print leading addresses">;
+ HelpText<"When disassembling, do not print leading addresses for instructions or inline relocations">;
def raw_clang_ast : Flag<["--"], "raw-clang-ast">,
HelpText<"Dump the raw binary contents of the clang AST section">;
Index: llvm/test/tools/llvm-objdump/X86/elf-disassemble-relocs-exec.test
===================================================================
--- llvm/test/tools/llvm-objdump/X86/elf-disassemble-relocs-exec.test
+++ llvm/test/tools/llvm-objdump/X86/elf-disassemble-relocs-exec.test
@@ -1,18 +1,31 @@
## Check that 'llvm-objdump -dr' correctly prints relocations in executables.
# RUN: yaml2obj --docnum=1 %s -o %t
-# RUN: llvm-objdump -dr %t | FileCheck %s
+# RUN: llvm-objdump -dr %t | FileCheck %s --match-full-lines --strict-whitespace
+# RUN: llvm-objdump -dr --no-leading-addr %t | FileCheck %s --check-prefix=NOADDR --match-full-lines --strict-whitespace
-# CHECK: 400000: 90 nop
-# CHECK-NEXT: 400001: bf 10 00 40 00 movl $4194320, %edi
-# CHECK-NEXT: 0000000000400002: R_X86_64_32 .rodata
-# CHECK-NEXT: 400006: e8 fc fe ff ff callq 0x3fff07
-# CHECK-NEXT: 0000000000400007: R_X86_64_PLT32 puts-0x4
-# CHECK-NEXT: 40000b: 90 nop
+# RUN: yaml2obj -DBITS=32 %s -o %t.32
+# RUN: llvm-objdump -dr --no-leading-addr %t.32 | FileCheck %s --check-prefix=NOADDR --match-full-lines --strict-whitespace
+
+# CHECK:0000000000400000 <.text>:
+# CHECK-NEXT: 400000: 90 nop
+# CHECK-NEXT: 400001: bf 10 00 40 00 movl $4194320, %edi # imm = 0x400010
+# CHECK-NEXT: 0000000000400002: R_X86_64_32 .rodata
+# CHECK-NEXT: 400006: e8 fc fe ff ff callq 0x3fff07 <puts+0x3fff07>
+# CHECK-NEXT: 0000000000400007: R_X86_64_PLT32 puts-0x4
+# CHECK-NEXT: 40000b: 90 nop
+
+# NOADDR:<.text>:
+# NOADDR-NEXT: 90 nop
+# NOADDR-NEXT: bf 10 00 40 00 movl $4194320, %edi # imm = 0x400010
+# NOADDR-NEXT: R_X86_64_32 .rodata
+# NOADDR-NEXT: e8 fc fe ff ff callq 0x3fff07 <puts+0x3fff07>
+# NOADDR-NEXT: R_X86_64_PLT32 puts-0x4
+# NOADDR-NEXT: 90 nop
--- !ELF
FileHeader:
- Class: ELFCLASS64
+ Class: ELFCLASS[[BITS=64]]
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Index: llvm/docs/CommandGuide/llvm-objdump.rst
===================================================================
--- llvm/docs/CommandGuide/llvm-objdump.rst
+++ llvm/docs/CommandGuide/llvm-objdump.rst
@@ -186,7 +186,8 @@
.. option:: --no-leading-addr
- When disassembling, do not print leading addresses.
+ When disassembling, do not print leading addresses for instructions or inline
+ relocations.
.. option:: --no-print-imm-hex
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135039.465062.patch
Type: text/x-patch
Size: 4406 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221004/4a3b3abc/attachment-0001.bin>
More information about the llvm-commits
mailing list