mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-19 03:24:09 +00:00
Fixed an assert() exposed by fuzzing. Now, instead of assert when an invalid
instruction encoding is encountered, we just return a NULL ARMBasicMCBuilder instance and the client just returns false to indicate disassembly error. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101201 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -3257,6 +3257,9 @@ ARMBasicMCBuilder::ARMBasicMCBuilder(unsigned opc, ARMFormat format,
|
|||||||
/// are responsible for freeing up of the allocated memory. Cacheing can be
|
/// are responsible for freeing up of the allocated memory. Cacheing can be
|
||||||
/// performed by the API clients to improve performance.
|
/// performed by the API clients to improve performance.
|
||||||
ARMBasicMCBuilder *llvm::CreateMCBuilder(unsigned Opcode, ARMFormat Format) {
|
ARMBasicMCBuilder *llvm::CreateMCBuilder(unsigned Opcode, ARMFormat Format) {
|
||||||
|
// For "Unknown format", fail by returning a NULL pointer.
|
||||||
|
if ((unsigned)Format >= (array_lengthof(FuncPtrs) - 1))
|
||||||
|
return 0;
|
||||||
|
|
||||||
return new ARMBasicMCBuilder(Opcode, Format,
|
return new ARMBasicMCBuilder(Opcode, Format,
|
||||||
ARMInsts[Opcode].getNumOperands());
|
ARMInsts[Opcode].getNumOperands());
|
||||||
|
@ -171,24 +171,33 @@ typedef ARMBasicMCBuilder *BO;
|
|||||||
typedef bool (*DisassembleFP)(MCInst &MI, unsigned Opcode, uint32_t insn,
|
typedef bool (*DisassembleFP)(MCInst &MI, unsigned Opcode, uint32_t insn,
|
||||||
unsigned short NumOps, unsigned &NumOpsAdded, BO Builder);
|
unsigned short NumOps, unsigned &NumOpsAdded, BO Builder);
|
||||||
|
|
||||||
|
/// CreateMCBuilder - Return an ARMBasicMCBuilder that can build up the MC
|
||||||
|
/// infrastructure of an MCInst given the Opcode and Format of the instr.
|
||||||
|
/// Return NULL if it fails to create/return a proper builder. API clients
|
||||||
|
/// are responsible for freeing up of the allocated memory. Cacheing can be
|
||||||
|
/// performed by the API clients to improve performance.
|
||||||
|
extern ARMBasicMCBuilder *CreateMCBuilder(unsigned Opcode, ARMFormat Format);
|
||||||
|
|
||||||
/// ARMBasicMCBuilder - ARMBasicMCBuilder represents an ARM MCInst builder that
|
/// ARMBasicMCBuilder - ARMBasicMCBuilder represents an ARM MCInst builder that
|
||||||
/// knows how to build up the MCOperand list.
|
/// knows how to build up the MCOperand list.
|
||||||
class ARMBasicMCBuilder {
|
class ARMBasicMCBuilder {
|
||||||
|
friend ARMBasicMCBuilder *CreateMCBuilder(unsigned Opcode, ARMFormat Format);
|
||||||
unsigned Opcode;
|
unsigned Opcode;
|
||||||
ARMFormat Format;
|
ARMFormat Format;
|
||||||
unsigned short NumOps;
|
unsigned short NumOps;
|
||||||
DisassembleFP Disasm;
|
DisassembleFP Disasm;
|
||||||
Session *SP;
|
Session *SP;
|
||||||
|
|
||||||
|
private:
|
||||||
|
/// Opcode, Format, and NumOperands make up an ARM Basic MCBuilder.
|
||||||
|
ARMBasicMCBuilder(unsigned opc, ARMFormat format, unsigned short num);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ARMBasicMCBuilder(ARMBasicMCBuilder &B)
|
ARMBasicMCBuilder(ARMBasicMCBuilder &B)
|
||||||
: Opcode(B.Opcode), Format(B.Format), NumOps(B.NumOps), Disasm(B.Disasm),
|
: Opcode(B.Opcode), Format(B.Format), NumOps(B.NumOps), Disasm(B.Disasm),
|
||||||
SP(B.SP)
|
SP(B.SP)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/// Opcode, Format, and NumOperands make up an ARM Basic MCBuilder.
|
|
||||||
ARMBasicMCBuilder(unsigned opc, ARMFormat format, unsigned short num);
|
|
||||||
|
|
||||||
virtual ~ARMBasicMCBuilder() {}
|
virtual ~ARMBasicMCBuilder() {}
|
||||||
|
|
||||||
void setSession(Session *sp) {
|
void setSession(Session *sp) {
|
||||||
@ -236,13 +245,6 @@ private:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// CreateMCBuilder - Return an ARMBasicMCBuilder that can build up the MC
|
|
||||||
/// infrastructure of an MCInst given the Opcode and Format of the instr.
|
|
||||||
/// Return NULL if it fails to create/return a proper builder. API clients
|
|
||||||
/// are responsible for freeing up of the allocated memory. Cacheing can be
|
|
||||||
/// performed by the API clients to improve performance.
|
|
||||||
extern ARMBasicMCBuilder *CreateMCBuilder(unsigned Opcode, ARMFormat Format);
|
|
||||||
|
|
||||||
} // namespace llvm
|
} // namespace llvm
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user