Create an atom with just the data that failed to disassemble.

Patch by Stephen Checkoway.

llvm-svn: 192827
This commit is contained in:
Rafael Espindola 2013-10-16 19:03:14 +00:00
parent 33304e3087
commit 6174e5ee68
2 changed files with 16 additions and 4 deletions

View File

@ -135,11 +135,13 @@ void MCObjectDisassembler::buildSectionAtoms(MCModule *Module) {
Text->addInst(Inst, InstSize); Text->addInst(Inst, InstSize);
InvalidData = 0; InvalidData = 0;
} else { } else {
assert(InstSize && "getInstruction() consumed no bytes");
if (!InvalidData) { if (!InvalidData) {
Text = 0; 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 { } else {

View File

@ -6,6 +6,7 @@
# .LBL0_1: # .LBL0_1:
# movq 8(%rsi), %rax # movq 8(%rsi), %rax
# <invalid opcode: 06> # <invalid opcode: 06>
# nop
!ELF !ELF
FileHeader: FileHeader:
@ -17,7 +18,7 @@ Sections:
- Name: .text - Name: .text
Type: SHT_PROGBITS Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ] Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Content: "488B460806" Content: "488B46080690"
## 0000000000000000 <main>: ## 0000000000000000 <main>:
@ -39,10 +40,19 @@ Sections:
## 4: 06 (bad) ## 4: 06 (bad)
#CFG: Content: 06 #CFG: Content: 06
#CFG: - StartAddress: 0x0000000000000005
#CFG: Size: 1
#CFG: Type: Text
## 5: 90 nop
#CFG: - Inst: NOOP
#CFG: Size: 1
#CFG: Ops: [ ]
Symbols: Symbols:
Global: Global:
- Name: main - Name: main
Type: STT_FUNC Type: STT_FUNC
Section: .text Section: .text
Value: 0x0 Value: 0x0
Size: 5 Size: 6