aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-objdump/llvm-objdump.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2021-05-04 09:56:06 -0700
committerFangrui Song <i@maskray.me>2021-05-04 09:56:07 -0700
commit0c2e2f88fbd3f3ffa2e441e08cdd17141e7bea97 (patch)
treefd7a22ad219375034929cbea061a89cd9838f6f9 /llvm/tools/llvm-objdump/llvm-objdump.cpp
parenta617e2064d694ce5ea608b24c52ee255a14c2ef7 (diff)
downloadllvm-0c2e2f88fbd3f3ffa2e441e08cdd17141e7bea97.zip
llvm-0c2e2f88fbd3f3ffa2e441e08cdd17141e7bea97.tar.gz
llvm-0c2e2f88fbd3f3ffa2e441e08cdd17141e7bea97.tar.bz2
[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
Diffstat (limited to 'llvm/tools/llvm-objdump/llvm-objdump.cpp')
-rw-r--r--llvm/tools/llvm-objdump/llvm-objdump.cpp23
1 files changed, 9 insertions, 14 deletions
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 2d5a728..0e6ffe8 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -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)