Index: test/tools/llvm-readobj/print-section.test =================================================================== --- /dev/null +++ test/tools/llvm-readobj/print-section.test @@ -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...]. Index: tools/llvm-readobj/ELFDumper.cpp =================================================================== --- tools/llvm-readobj/ELFDumper.cpp +++ tools/llvm-readobj/ELFDumper.cpp @@ -3243,8 +3243,14 @@ CurrentWord++; continue; } - OS << format("[%6tx]", CurrentWord - SecContent); - OS << format(" %.*s\n", WordSize, CurrentWord); + OS << format("[%6tx] ", CurrentWord - SecContent); + for (size_t i = 0; i < WordSize; ++i) { + if (isprint(CurrentWord[i])) + OS << CurrentWord[i]; + else + OS << '.'; + } + OS << '\n'; CurrentWord += WordSize + 1; } OS.flush(); @@ -4270,8 +4276,14 @@ W.startLine() << "[" << to_string( format_hex_no_prefix((CurrentWord - SecContent), 6)) - << "]"; - W.startLine() << format(" %.*s\n", WordSize, CurrentWord); + << "] "; + for (size_t i = 0; i < WordSize; ++i) { + if (isprint(CurrentWord[i])) + W.startLine() << CurrentWord[i]; + else + W.startLine() << '.'; + } + W.startLine() << '\n'; CurrentWord += WordSize + 1; } }