aboutsummaryrefslogtreecommitdiffstats
path: root/tools/llvm-objdump/llvm-objdump.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/llvm-objdump/llvm-objdump.cpp')
-rw-r--r--tools/llvm-objdump/llvm-objdump.cpp35
1 files changed, 12 insertions, 23 deletions
diff --git a/tools/llvm-objdump/llvm-objdump.cpp b/tools/llvm-objdump/llvm-objdump.cpp
index 6e62aaa..7bec062 100644
--- a/tools/llvm-objdump/llvm-objdump.cpp
+++ b/tools/llvm-objdump/llvm-objdump.cpp
@@ -194,30 +194,17 @@ static const Target *getTarget(const ObjectFile *Obj = nullptr) {
return TheTarget;
}
-void llvm::DumpBytes(StringRef bytes) {
+void llvm::DumpBytes(ArrayRef<uint8_t> bytes) {
static const char hex_rep[] = "0123456789abcdef";
- // FIXME: The real way to do this is to figure out the longest instruction
- // and align to that size before printing. I'll fix this when I get
- // around to outputting relocations.
- // 15 is the longest x86 instruction
- // 3 is for the hex rep of a byte + a space.
- // 1 is for the null terminator.
- enum { OutputSize = (15 * 3) + 1 };
- char output[OutputSize];
-
- assert(bytes.size() <= 15
- && "DumpBytes only supports instructions of up to 15 bytes");
- memset(output, ' ', sizeof(output));
- unsigned index = 0;
- for (StringRef::iterator i = bytes.begin(),
- e = bytes.end(); i != e; ++i) {
- output[index] = hex_rep[(*i & 0xF0) >> 4];
- output[index + 1] = hex_rep[*i & 0xF];
- index += 3;
+ SmallString<64> output;
+
+ for (char i: bytes) {
+ output.push_back(hex_rep[(i & 0xF0) >> 4]);
+ output.push_back(hex_rep[i & 0xF]);
+ output.push_back(' ');
}
- output[sizeof(output) - 1] = 0;
- outs() << output;
+ outs() << output.c_str();
}
bool llvm::RelocAddressLess(RelocationRef a, RelocationRef b) {
@@ -412,8 +399,7 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
outs() << format("%8" PRIx64 ":", SectionAddr + Index);
if (!NoShowRawInsn) {
outs() << "\t";
- DumpBytes(StringRef(
- reinterpret_cast<const char *>(Bytes.data()) + Index, Size));
+ DumpBytes(ArrayRef<uint8_t>(Bytes.data() + Index, Size));
}
IP->printInst(&Inst, outs(), "");
outs() << CommentStream.str();
@@ -907,6 +893,9 @@ int main(int argc, char **argv) {
&& !(IndirectSymbols && MachOOpt)
&& !(DataInCode && MachOOpt)
&& !(LinkOptHints && MachOOpt)
+ && !(InfoPlist && MachOOpt)
+ && !(DylibsUsed && MachOOpt)
+ && !(DylibId && MachOOpt)
&& !(DumpSections.size() != 0 && MachOOpt)) {
cl::PrintHelpMessage();
return 2;