[PATCH] Change llvm-objdump to print (bad) for invalid instructions

Stephen Checkoway s at pahtak.org
Wed Oct 16 11:25:46 PDT 2013


On Oct 16, 2013, at 2:05 PM, Jim Grosbach <grosbach at apple.com> wrote:

> -          errs() << ToolName << ": warning: invalid instruction encoding\n";
> -          if (Size == 0)
> -            Size = 1; // skip illegible bytes
> +          Size = 1; // skip illegible bytes
> +          if (!NoShowRawInsn) {
> +            outs() << '\t';
> +            DumpBytes(StringRef(Bytes.data() + Index, Size));
> +          }
> +          outs() << "   (bad)\n”;
> 
> I don’t think you want to always set the size to ‘1’ here. Won’t that result in mis-aligned instruction decoding for fixed-width instruction sets?


That's a good point and there's a similar issue in MCObjectDisassemble.cpp. I wasn't sure if DisAsm::getInstruction() would set Size if it returns false but, looking closer at the code, I think it does.

I'll fix this and also the MCObjectDisassembler patch I sent a little while ago that Rafael said he was going to look at.

Thanks,

-- 
Stephen Checkoway









More information about the llvm-commits mailing list