mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-01 05:01:59 +01:00
[llvm-readobj] Fix printing format
We were printing every character, even those that weren't printable. It doesn't really make sense for this option. The string content was sticked to its address, added two spaces in between. Differential Revision: https://reviews.llvm.org/D48271 llvm-svn: 336058
This commit is contained in:
parent
50dc237abc
commit
406504e4b7
8
test/tools/llvm-readobj/print-section.test
Normal file
8
test/tools/llvm-readobj/print-section.test
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
RUN: llvm-readobj -p .text %p/Inputs/elf-groups.x86_64 \
|
||||||
|
RUN: | FileCheck %s
|
||||||
|
|
||||||
|
CHECK: [000000] UH..H....E.
|
||||||
|
CHECK: [00000f] .E.x.E..
|
||||||
|
CHECK: [00001a] ..}..
|
||||||
|
CHECK: [000023] .}..
|
||||||
|
CHECK: [00002b] 1.H...].
|
@ -3275,6 +3275,11 @@ void GNUStyle<ELFT>::printProgramHeaders(const ELFO *Obj) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void printAsPrintable(raw_ostream &W, StringRef S) {
|
||||||
|
for (char C : S)
|
||||||
|
W << (isprint(C) ? C : '.');
|
||||||
|
}
|
||||||
|
|
||||||
template <class ELFT>
|
template <class ELFT>
|
||||||
void GNUStyle<ELFT>::printSectionAsString(const ELFO *Obj,
|
void GNUStyle<ELFT>::printSectionAsString(const ELFO *Obj,
|
||||||
StringRef SectionName) {
|
StringRef SectionName) {
|
||||||
@ -3298,8 +3303,9 @@ void GNUStyle<ELFT>::printSectionAsString(const ELFO *Obj,
|
|||||||
CurrentWord++;
|
CurrentWord++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
OS << format("[%6tx]", CurrentWord - SecContent);
|
OS << format("[%6tx] ", CurrentWord - SecContent);
|
||||||
OS << format(" %.*s\n", WordSize, CurrentWord);
|
printAsPrintable(OS, StringRef(CurrentWord, WordSize));
|
||||||
|
OS << '\n';
|
||||||
CurrentWord += WordSize + 1;
|
CurrentWord += WordSize + 1;
|
||||||
}
|
}
|
||||||
OS.flush();
|
OS.flush();
|
||||||
@ -4361,8 +4367,9 @@ void LLVMStyle<ELFT>::printSectionAsString(const ELFO *Obj,
|
|||||||
W.startLine() << "["
|
W.startLine() << "["
|
||||||
<< to_string(
|
<< to_string(
|
||||||
format_hex_no_prefix((CurrentWord - SecContent), 6))
|
format_hex_no_prefix((CurrentWord - SecContent), 6))
|
||||||
<< "]";
|
<< "] ";
|
||||||
W.startLine() << format(" %.*s\n", WordSize, CurrentWord);
|
printAsPrintable(W.startLine(), StringRef(CurrentWord, WordSize));
|
||||||
|
W.startLine() << '\n';
|
||||||
CurrentWord += WordSize + 1;
|
CurrentWord += WordSize + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user