forked from OSchip/llvm-project
[llvm-objdump] Improve newline consistency between different pieces of information
When dumping multiple pieces of information (e.g. --all-headers), there is sometimes no separator between two pieces. This patch uses the "\nheader:\n" style, which generally improves compatibility with GNU objdump. Note: objdump -t/-T does not add a newline before "SYMBOL TABLE:" and "DYNAMIC SYMBOL TABLE:". We add a newline to be consistent with other information. `objdump -d` prints two empty lines before the first 'Disassembly of section'. We print just one with this patch. Differential Revision: https://reviews.llvm.org/D101796
This commit is contained in:
parent
a617e2064d
commit
0c2e2f88fb
|
@ -28,6 +28,7 @@
|
|||
# DYLIB-NEXT: adrp x8, [[#]] ; 0x[[#GOT]]
|
||||
# DYLIB-NEXT: ldr w8, [x8]
|
||||
# DYLIB-NEXT: ret
|
||||
# DYLIB-EMPTY:
|
||||
# DYLIB-NEXT: Sections:
|
||||
# DYLIB-NEXT: Idx Name Size VMA Type
|
||||
# DYLIB: [[#]] __got 00000008 [[#%.8x,GOT]] DATA
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
# DYLIB-NEXT: adrp x8, [[#]] ; 0x[[#GOT]]
|
||||
# DYLIB-NEXT: ldr x8, [x8] ; literal pool symbol address: _bar
|
||||
# DYLIB-NEXT: ret
|
||||
# DYLIB-EMPTY:
|
||||
# DYLIB-NEXT: Sections:
|
||||
# DYLIB-NEXT: Idx Name Size VMA Type
|
||||
# DYLIB: [[#]] __got 00000010 {{0*}}[[#GOT]] DATA
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
# DYLIB-NEXT: adrp x8, [[#]] ; 0x[[#TLV]]
|
||||
# DYLIB-NEXT: ldr x8, [x8] ; literal pool symbol address: _bar
|
||||
# DYLIB-NEXT: ret
|
||||
# DYLIB-EMPTY:
|
||||
# DYLIB-NEXT: Sections:
|
||||
# DYLIB-NEXT: Idx Name Size VMA Type
|
||||
# DYLIB: [[#]] __thread_ptrs 00000010 {{0*}}[[#TLV]] DATA
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
; RUN: printf ".type my_kernel.kd, @object \nmy_kernel.kd:\n.size my_kernel.kd, 64\n" > %t1.sym_info
|
||||
; RUN: llvm-objdump --disassemble-symbols=my_kernel.kd %t.o \
|
||||
; RUN: | tail -n +9 > %t1.sym_content
|
||||
; RUN: | tail -n +8 > %t1.sym_content
|
||||
; RUN: cat %t1.sym_info %t1.sym_content > %t1.s
|
||||
|
||||
; RUN: llvm-mc %t1.s --triple=amdgcn-amd-amdhsa -mcpu=gfx908 -filetype=obj -o %t-re-assemble.o
|
||||
|
|
|
@ -3,17 +3,17 @@
|
|||
; RUN: split-file %s %t.dir
|
||||
|
||||
; RUN: llvm-mc %t.dir/1.s --triple=amdgcn-amd-amdhsa -mcpu=gfx908 -mattr=-xnack -filetype=obj -o %t1
|
||||
; RUN: llvm-objdump --disassemble-symbols=my_kernel_1.kd %t1 | tail -n +8 \
|
||||
; RUN: llvm-objdump --disassemble-symbols=my_kernel_1.kd %t1 | tail -n +7 \
|
||||
; RUN: | llvm-mc --triple=amdgcn-amd-amdhsa -mcpu=gfx908 -mattr=-xnack -filetype=obj -o %t1-re-assemble
|
||||
; RUN: diff %t1 %t1-re-assemble
|
||||
|
||||
; RUN: llvm-mc %t.dir/2.s --triple=amdgcn-amd-amdhsa -mcpu=gfx908 -mattr=-xnack -filetype=obj -o %t2
|
||||
; RUN: llvm-objdump --disassemble-symbols=my_kernel_2.kd %t2 | tail -n +8 \
|
||||
; RUN: llvm-objdump --disassemble-symbols=my_kernel_2.kd %t2 | tail -n +7 \
|
||||
; RUN: | llvm-mc --triple=amdgcn-amd-amdhsa -mcpu=gfx908 -mattr=-xnack -filetype=obj -o %t2-re-assemble
|
||||
; RUN: diff %t2 %t2-re-assemble
|
||||
|
||||
; RUN: llvm-mc %t.dir/3.s --triple=amdgcn-amd-amdhsa -mcpu=gfx908 -mattr=-xnack -filetype=obj -o %t3
|
||||
; RUN: llvm-objdump --disassemble-symbols=my_kernel_3.kd %t3 | tail -n +8 \
|
||||
; RUN: llvm-objdump --disassemble-symbols=my_kernel_3.kd %t3 | tail -n +7 \
|
||||
; RUN: | llvm-mc --triple=amdgcn-amd-amdhsa -mcpu=gfx908 -mattr=-xnack -filetype=obj -o %t3-re-assemble
|
||||
; RUN: diff %t3 %t3-re-assemble
|
||||
|
||||
|
|
|
@ -3,17 +3,17 @@
|
|||
; RUN: split-file %s %t.dir
|
||||
|
||||
; RUN: llvm-mc %t.dir/1.s --triple=amdgcn-amd-amdhsa -mcpu=gfx908 -mattr=-xnack -filetype=obj -o %t1
|
||||
; RUN: llvm-objdump --disassemble-symbols=my_kernel_1.kd %t1 | tail -n +8 \
|
||||
; RUN: llvm-objdump --disassemble-symbols=my_kernel_1.kd %t1 | tail -n +7 \
|
||||
; RUN: | llvm-mc --triple=amdgcn-amd-amdhsa -mcpu=gfx908 -mattr=-xnack -filetype=obj -o %t1-re-assemble
|
||||
; RUN: diff %t1 %t1-re-assemble
|
||||
|
||||
; RUN: llvm-mc %t.dir/2.s --triple=amdgcn-amd-amdhsa -mcpu=gfx908 -mattr=-xnack -filetype=obj -o %t2
|
||||
; RUN: llvm-objdump --disassemble-symbols=my_kernel_2.kd %t2 | tail -n +8 \
|
||||
; RUN: llvm-objdump --disassemble-symbols=my_kernel_2.kd %t2 | tail -n +7 \
|
||||
; RUN: | llvm-mc --triple=amdgcn-amd-amdhsa -mcpu=gfx908 -mattr=-xnack -filetype=obj -o %t2-re-assemble
|
||||
; RUN: diff %t2 %t2-re-assemble
|
||||
|
||||
; RUN: llvm-mc %t.dir/3.s --triple=amdgcn-amd-amdhsa -mcpu=gfx908 -mattr=-xnack -filetype=obj -o %t3
|
||||
; RUN: llvm-objdump --disassemble-symbols=my_kernel_3.kd %t3 | tail -n +8 \
|
||||
; RUN: llvm-objdump --disassemble-symbols=my_kernel_3.kd %t3 | tail -n +7 \
|
||||
; RUN: | llvm-mc --triple=amdgcn-amd-amdhsa -mcpu=gfx908 -mattr=-xnack -filetype=obj -o %t3-re-assemble
|
||||
; RUN: diff %t3 %t3-re-assemble
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
; RUN: llvm-mc %s --triple=amdgcn-amd-amdhsa -mcpu=gfx908 -mattr=-xnack -filetype=obj -o %t1
|
||||
; RUN: llvm-objdump --disassemble-symbols=my_kernel.kd %t1 \
|
||||
; RUN: | tail -n +8 | llvm-mc --triple=amdgcn-amd-amdhsa -mcpu=gfx908 -mattr=-xnack -filetype=obj -o %t2
|
||||
; RUN: | tail -n +7 | llvm-mc --triple=amdgcn-amd-amdhsa -mcpu=gfx908 -mattr=-xnack -filetype=obj -o %t2
|
||||
; RUN: diff %t1 %t2
|
||||
|
||||
; RUN: llvm-objdump -s -j .text %t1 | FileCheck --check-prefix=OBJDUMP %s
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
; RUN: llvm-mc %s --triple=amdgcn-amd-amdhsa -mcpu=gfx908 -mattr=-xnack -filetype=obj -o %t1
|
||||
; RUN: llvm-objdump --disassemble-symbols=my_kernel.kd %t1 \
|
||||
; RUN: | tail -n +8 | llvm-mc --triple=amdgcn-amd-amdhsa -mcpu=gfx908 -mattr=-xnack -filetype=obj -o %t2
|
||||
; RUN: | tail -n +7 | llvm-mc --triple=amdgcn-amd-amdhsa -mcpu=gfx908 -mattr=-xnack -filetype=obj -o %t2
|
||||
; RUN: llvm-objdump -s -j .text %t2 | FileCheck --check-prefix=OBJDUMP %s
|
||||
|
||||
;; Not running lit-test over gfx10 (see kd-zeroed-gfx10.s for details).
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
# RUN: llvm-objdump -t %t | cmp - %t.txt
|
||||
# RUN: FileCheck %s --input-file=%t.txt --match-full-lines --strict-whitespace
|
||||
|
||||
# CHECK:SYMBOL TABLE:
|
||||
# CHECK:{{.*}}file format elf64-x86-64
|
||||
#CHECK-EMPTY:
|
||||
# CHECK-NEXT:SYMBOL TABLE:
|
||||
# CHECK-NEXT:0000000000000000 l df *ABS* 0000000000000000 a.c
|
||||
# CHECK-NEXT:0000000000000000 l d .text 0000000000000000 .text
|
||||
# CHECK-NEXT:0000000000002000 l O .data 0000000000000000 local_object
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
# RUN: yaml2obj %s -o %t
|
||||
# RUN: llvm-objdump -p %t | FileCheck --strict-whitespace %s
|
||||
|
||||
# CHECK: Version definitions:
|
||||
# CHECK: Dynamic Section:
|
||||
# CHECK-EMPTY:
|
||||
# CHECK-NEXT: Version definitions:
|
||||
# CHECK-NEXT: 1 0x01 0x075bcd15 foo
|
||||
# CHECK-NEXT: 2 0x02 0x3ade68b1 VERSION_1
|
||||
# CHECK-NEXT: VERSION_2
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
# RUN: yaml2obj %s -o %t
|
||||
# RUN: llvm-objdump -p %t | FileCheck %s
|
||||
# RUN: llvm-objdump -p %t | FileCheck %s --strict-whitespace --match-full-lines
|
||||
|
||||
# CHECK: Version References:
|
||||
# CHECK-NEXT: required from dso.so.0:
|
||||
# CHECK-NEXT: 0x000004d2 0x0a 03 v1
|
||||
# CHECK-NEXT: 0x0000162e 0x0b 04 v2
|
||||
# CHECK-NEXT: required from dso.so.1:
|
||||
# CHECK-NEXT: 0x000011d7 0x0c 02 v3
|
||||
# CHECK:Dynamic Section:
|
||||
# CHECK-EMPTY:
|
||||
# CHECK-NEXT:Version References:
|
||||
# CHECK-NEXT: required from dso.so.0:
|
||||
# CHECK-NEXT: 0x000004d2 0x0a 03 v1
|
||||
# CHECK-NEXT: 0x0000162e 0x0b 04 v2
|
||||
# CHECK-NEXT: required from dso.so.1:
|
||||
# CHECK-NEXT: 0x000011d7 0x0c 02 v3
|
||||
|
||||
--- !ELF
|
||||
FileHeader:
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
RUN: llvm-objdump --macho -h %p/Inputs/hello.obj.macho-x86_64 | FileCheck %s
|
||||
RUN: llvm-objdump --macho -h %p/Inputs/hello.obj.macho-x86_64 | FileCheck %s --strict-whitespace --match-full-lines
|
||||
|
||||
CHECK: Sections:
|
||||
CHECK: Idx Name Size VMA Type
|
||||
CHECK: 0 __text 0000003b 0000000000000000 TEXT
|
||||
CHECK: 1 __cstring 0000000d 000000000000003b DATA
|
||||
CHECK: 2 __compact_unwind 00000020 0000000000000048 DATA
|
||||
CHECK: 3 __eh_frame 00000040 0000000000000068 DATA
|
||||
CHECK:{{^$}}
|
||||
CHECK-NEXT:Sections:
|
||||
CHECK-NEXT:Idx Name Size VMA Type
|
||||
CHECK-NEXT: 0 __text 0000003b 0000000000000000 TEXT
|
||||
CHECK-NEXT: 1 __cstring 0000000d 000000000000003b DATA
|
||||
CHECK-NEXT: 2 __compact_unwind 00000020 0000000000000048 DATA
|
||||
CHECK-NEXT: 3 __eh_frame 00000040 0000000000000068 DATA
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
# CHECK: : file format elf64-x86-64
|
||||
# CHECK-EMPTY:
|
||||
# CHECK-EMPTY:
|
||||
# CHECK-NEXT: Disassembly of section .text:
|
||||
# CHECK-EMPTY:
|
||||
# CHECK-NEXT: 0000000000000000 <foo>:
|
||||
|
|
|
@ -5,7 +5,9 @@
|
|||
# RUN: llvm-objdump -T %t1 | \
|
||||
# RUN: FileCheck %s --match-full-lines --strict-whitespace --check-prefix=DYNSYM
|
||||
|
||||
# DYNSYM:DYNAMIC SYMBOL TABLE:
|
||||
# DYNSYM:{{.*}}file format elf64-x86-64
|
||||
# DYNSYM-EMPTY:
|
||||
# DYNSYM-NEXT:DYNAMIC SYMBOL TABLE:
|
||||
# DYNSYM-NEXT:0000000000000000 l DO .data 0000000000000000 localsym
|
||||
# DYNSYM-NEXT:0000000000000000 g DO .data 0000000000000000 globalsym
|
||||
# DYNSYM-NEXT:0000000000000000 u DO .data 0000000000000000 uniqueglobalsym
|
||||
|
|
|
@ -7,15 +7,21 @@
|
|||
## in the following order which provides GNU objdump compatability.
|
||||
|
||||
# CHECK: file format elf64-x86-64
|
||||
# CHECK-EMPTY:
|
||||
# CHECK-NEXT: architecture: x86_64
|
||||
# CHECK-NEXT: start address: 0x0000000000000000
|
||||
# CHECK-EMPTY:
|
||||
# CHECK-NEXT: Program Header:
|
||||
# CHECK: Dynamic Section:
|
||||
# CHECK: Sections:
|
||||
# CHECK: SYMBOL TABLE:
|
||||
# CHECK: RELOCATION RECORDS FOR [.text]:
|
||||
# CHECK-NEXT: Program Header:
|
||||
# CHECK-EMPTY:
|
||||
# CHECK-NEXT: Dynamic Section:
|
||||
# CHECK: INIT
|
||||
# CHECK-EMPTY:
|
||||
# CHECK-NEXT: Sections:
|
||||
# CHECK: 6 .shstrtab 0000002e 0000000000000000
|
||||
# CHECK-EMPTY:
|
||||
# CHECK-NEXT: SYMBOL TABLE:
|
||||
# CHECK-NEXT: 0000000000000000 l .text 0000000000000000 foo
|
||||
# CHECK-EMPTY:
|
||||
# CHECK-NEXT: RELOCATION RECORDS FOR [.text]:
|
||||
|
||||
## Check how we dump the archives.
|
||||
## Check we dump the appropriate headers for each file in the archive.
|
||||
|
|
|
@ -180,7 +180,7 @@ static void printDynamicSection(const ELFFile<ELFT> &Elf, StringRef Filename) {
|
|||
MaxLen = std::max(MaxLen, Elf.getDynamicTagAsString(Dyn.d_tag).size());
|
||||
std::string TagFmt = " %-" + std::to_string(MaxLen) + "s ";
|
||||
|
||||
outs() << "Dynamic Section:\n";
|
||||
outs() << "\nDynamic Section:\n";
|
||||
for (const typename ELFT::Dyn &Dyn : DynamicEntries) {
|
||||
if (Dyn.d_tag == ELF::DT_NULL)
|
||||
continue;
|
||||
|
@ -208,7 +208,7 @@ static void printDynamicSection(const ELFFile<ELFT> &Elf, StringRef Filename) {
|
|||
|
||||
template <class ELFT>
|
||||
static void printProgramHeaders(const ELFFile<ELFT> &Obj, StringRef FileName) {
|
||||
outs() << "Program Header:\n";
|
||||
outs() << "\nProgram Header:\n";
|
||||
auto ProgramHeaderOrError = Obj.program_headers();
|
||||
if (!ProgramHeaderOrError) {
|
||||
reportWarning("unable to read program headers: " +
|
||||
|
@ -275,13 +275,12 @@ static void printProgramHeaders(const ELFFile<ELFT> &Obj, StringRef FileName) {
|
|||
<< ((Phdr.p_flags & ELF::PF_W) ? "w" : "-")
|
||||
<< ((Phdr.p_flags & ELF::PF_X) ? "x" : "-") << "\n";
|
||||
}
|
||||
outs() << "\n";
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
static void printSymbolVersionDependency(ArrayRef<uint8_t> Contents,
|
||||
StringRef StrTab) {
|
||||
outs() << "Version References:\n";
|
||||
outs() << "\nVersion References:\n";
|
||||
|
||||
const uint8_t *Buf = Contents.data();
|
||||
while (Buf) {
|
||||
|
@ -307,7 +306,7 @@ template <class ELFT>
|
|||
static void printSymbolVersionDefinition(const typename ELFT::Shdr &Shdr,
|
||||
ArrayRef<uint8_t> Contents,
|
||||
StringRef StrTab) {
|
||||
outs() << "Version definitions:\n";
|
||||
outs() << "\nVersion definitions:\n";
|
||||
|
||||
const uint8_t *Buf = Contents.data();
|
||||
uint32_t VerdefIndex = 1;
|
||||
|
|
|
@ -1656,7 +1656,7 @@ void objdump::printRelocations(const ObjectFile *Obj) {
|
|||
|
||||
for (std::pair<SectionRef, std::vector<SectionRef>> &P : SecToRelSec) {
|
||||
StringRef SecName = unwrapOrError(P.first.getName(), Obj->getFileName());
|
||||
outs() << "RELOCATION RECORDS FOR [" << SecName << "]:\n";
|
||||
outs() << "\nRELOCATION RECORDS FOR [" << SecName << "]:\n";
|
||||
uint32_t OffsetPadding = (Obj->getBytesInAddress() > 4 ? 16 : 8);
|
||||
uint32_t TypePadding = 24;
|
||||
outs() << left_justify("OFFSET", OffsetPadding) << " "
|
||||
|
@ -1679,7 +1679,6 @@ void objdump::printRelocations(const ObjectFile *Obj) {
|
|||
<< "\n";
|
||||
}
|
||||
}
|
||||
outs() << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1739,16 +1738,13 @@ void objdump::printSectionHeaders(const ObjectFile *Obj) {
|
|||
size_t NameWidth = getMaxSectionNameWidth(Obj);
|
||||
size_t AddressWidth = 2 * Obj->getBytesInAddress();
|
||||
bool HasLMAColumn = shouldDisplayLMA(Obj);
|
||||
outs() << "\nSections:\n";
|
||||
if (HasLMAColumn)
|
||||
outs() << "Sections:\n"
|
||||
"Idx "
|
||||
<< left_justify("Name", NameWidth) << " Size "
|
||||
outs() << "Idx " << left_justify("Name", NameWidth) << " Size "
|
||||
<< left_justify("VMA", AddressWidth) << " "
|
||||
<< left_justify("LMA", AddressWidth) << " Type\n";
|
||||
else
|
||||
outs() << "Sections:\n"
|
||||
"Idx "
|
||||
<< left_justify("Name", NameWidth) << " Size "
|
||||
outs() << "Idx " << left_justify("Name", NameWidth) << " Size "
|
||||
<< left_justify("VMA", AddressWidth) << " Type\n";
|
||||
|
||||
uint64_t Idx;
|
||||
|
@ -1777,7 +1773,6 @@ void objdump::printSectionHeaders(const ObjectFile *Obj) {
|
|||
Name.str().c_str(), Size)
|
||||
<< format_hex_no_prefix(VMA, AddressWidth) << " " << Type << "\n";
|
||||
}
|
||||
outs() << "\n";
|
||||
}
|
||||
|
||||
void objdump::printSectionContents(const ObjectFile *Obj) {
|
||||
|
@ -1833,7 +1828,7 @@ void objdump::printSectionContents(const ObjectFile *Obj) {
|
|||
void objdump::printSymbolTable(const ObjectFile *O, StringRef ArchiveName,
|
||||
StringRef ArchitectureName, bool DumpDynamic) {
|
||||
if (O->isCOFF() && !DumpDynamic) {
|
||||
outs() << "SYMBOL TABLE:\n";
|
||||
outs() << "\nSYMBOL TABLE:\n";
|
||||
printCOFFSymbolTable(cast<const COFFObjectFile>(O));
|
||||
return;
|
||||
}
|
||||
|
@ -1841,13 +1836,13 @@ void objdump::printSymbolTable(const ObjectFile *O, StringRef ArchiveName,
|
|||
const StringRef FileName = O->getFileName();
|
||||
|
||||
if (!DumpDynamic) {
|
||||
outs() << "SYMBOL TABLE:\n";
|
||||
outs() << "\nSYMBOL TABLE:\n";
|
||||
for (auto I = O->symbol_begin(); I != O->symbol_end(); ++I)
|
||||
printSymbol(O, *I, FileName, ArchiveName, ArchitectureName, DumpDynamic);
|
||||
return;
|
||||
}
|
||||
|
||||
outs() << "DYNAMIC SYMBOL TABLE:\n";
|
||||
outs() << "\nDYNAMIC SYMBOL TABLE:\n";
|
||||
if (!O->isELF()) {
|
||||
reportWarning(
|
||||
"this operation is not currently supported for this file format",
|
||||
|
@ -2119,7 +2114,7 @@ static void printFileHeaders(const ObjectFile *O) {
|
|||
|
||||
StringRef Fmt = O->getBytesInAddress() > 4 ? "%016" PRIx64 : "%08" PRIx64;
|
||||
outs() << "start address: "
|
||||
<< "0x" << format(Fmt.data(), Address) << "\n\n";
|
||||
<< "0x" << format(Fmt.data(), Address) << "\n";
|
||||
}
|
||||
|
||||
static void printArchiveChild(StringRef Filename, const Archive::Child &C) {
|
||||
|
@ -2216,7 +2211,7 @@ static void dumpObject(ObjectFile *O, const Archive *A = nullptr,
|
|||
outs() << A->getFileName() << "(" << O->getFileName() << ")";
|
||||
else
|
||||
outs() << O->getFileName();
|
||||
outs() << ":\tfile format " << O->getFileFormatName().lower() << "\n\n";
|
||||
outs() << ":\tfile format " << O->getFileFormatName().lower() << "\n";
|
||||
}
|
||||
|
||||
if (HasStartAddressFlag || HasStopAddressFlag)
|
||||
|
|
Loading…
Reference in New Issue