[llvm] r192827 - Create an atom with just the data that failed to disassemble.
Rafael Espindola
rafael.espindola at gmail.com
Wed Oct 16 12:03:14 PDT 2013
Author: rafael
Date: Wed Oct 16 14:03:14 2013
New Revision: 192827
URL: http://llvm.org/viewvc/llvm-project?rev=192827&view=rev
Log:
Create an atom with just the data that failed to disassemble.
Patch by Stephen Checkoway.
Modified:
llvm/trunk/lib/MC/MCObjectDisassembler.cpp
llvm/trunk/test/Object/X86/objdump-cfg-invalid-opcode.yaml
Modified: llvm/trunk/lib/MC/MCObjectDisassembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectDisassembler.cpp?rev=192827&r1=192826&r2=192827&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCObjectDisassembler.cpp (original)
+++ llvm/trunk/lib/MC/MCObjectDisassembler.cpp Wed Oct 16 14:03:14 2013
@@ -135,11 +135,13 @@ void MCObjectDisassembler::buildSectionA
Text->addInst(Inst, InstSize);
InvalidData = 0;
} else {
+ assert(InstSize && "getInstruction() consumed no bytes");
if (!InvalidData) {
Text = 0;
- InvalidData = Module->createDataAtom(CurAddr, EndAddr);
+ InvalidData = Module->createDataAtom(CurAddr, CurAddr+InstSize - 1);
}
- InvalidData->addData(Contents[Index]);
+ for (uint64_t I = 0; I < InstSize; ++I)
+ InvalidData->addData(Contents[Index+I]);
}
}
} else {
Modified: llvm/trunk/test/Object/X86/objdump-cfg-invalid-opcode.yaml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/X86/objdump-cfg-invalid-opcode.yaml?rev=192827&r1=192826&r2=192827&view=diff
==============================================================================
--- llvm/trunk/test/Object/X86/objdump-cfg-invalid-opcode.yaml (original)
+++ llvm/trunk/test/Object/X86/objdump-cfg-invalid-opcode.yaml Wed Oct 16 14:03:14 2013
@@ -6,6 +6,7 @@
# .LBL0_1:
# movq 8(%rsi), %rax
# <invalid opcode: 06>
+# nop
!ELF
FileHeader:
@@ -17,7 +18,7 @@ Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
- Content: "488B460806"
+ Content: "488B46080690"
## 0000000000000000 <main>:
@@ -39,10 +40,19 @@ Sections:
## 4: 06 (bad)
#CFG: Content: 06
+#CFG: - StartAddress: 0x0000000000000005
+#CFG: Size: 1
+#CFG: Type: Text
+
+## 5: 90 nop
+#CFG: - Inst: NOOP
+#CFG: Size: 1
+#CFG: Ops: [ ]
+
Symbols:
Global:
- Name: main
Type: STT_FUNC
Section: .text
Value: 0x0
- Size: 5
+ Size: 6
More information about the llvm-commits
mailing list