Imports #
"fmt"
"strings"
"encoding/binary"
"errors"
"fmt"
"runtime"
"fmt"
"strings"
"bytes"
"fmt"
"fmt"
"strings"
"fmt"
"strings"
"encoding/binary"
"errors"
"fmt"
"runtime"
"fmt"
"strings"
"bytes"
"fmt"
"fmt"
"strings"
const AAA
const AAD
const AAM
const AAS
const ADC
const ADD
const ADDPD
const ADDPS
const ADDSD
const ADDSS
const ADDSUBPD
const ADDSUBPS
const AESDEC
const AESDECLAST
const AESENC
const AESENCLAST
const AESIMC
const AESKEYGENASSIST
const AH
8-bit
const AL
const AND
const ANDNPD
const ANDNPS
const ANDPD
const ANDPS
const ARPL
16-bit
const AX
const BH
const BL
const BLENDPD
const BLENDPS
const BLENDVPD
const BLENDVPS
const BOUND
const BP
const BPB
const BSF
const BSR
const BSWAP
const BT
const BTC
const BTR
const BTS
const BX
const CALL
const CBW
const CDQ
const CDQE
const CH
const CL
const CLC
const CLD
const CLFLUSH
const CLI
const CLTS
const CMC
const CMOVA
const CMOVAE
const CMOVB
const CMOVBE
const CMOVE
const CMOVG
const CMOVGE
const CMOVL
const CMOVLE
const CMOVNE
const CMOVNO
const CMOVNP
const CMOVNS
const CMOVO
const CMOVP
const CMOVS
const CMP
const CMPPD
const CMPPS
const CMPSB
const CMPSD
const CMPSD_XMM
const CMPSQ
const CMPSS
const CMPSW
const CMPXCHG
const CMPXCHG16B
const CMPXCHG8B
const COMISD
const COMISS
const CPUID
const CQO
Control registers.
const CR0
const CR1
const CR10
const CR11
const CR12
const CR13
const CR14
const CR15
const CR2
const CR3
const CR4
const CR5
const CR6
const CR7
const CR8
const CR9
const CRC32
const CS
const CVTDQ2PD
const CVTDQ2PS
const CVTPD2DQ
const CVTPD2PI
const CVTPD2PS
const CVTPI2PD
const CVTPI2PS
const CVTPS2DQ
const CVTPS2PD
const CVTPS2PI
const CVTSD2SI
const CVTSD2SS
const CVTSI2SD
const CVTSI2SS
const CVTSS2SD
const CVTSS2SI
const CVTTPD2DQ
const CVTTPD2PI
const CVTTPS2DQ
const CVTTPS2PI
const CVTTSD2SI
const CVTTSS2SI
const CWD
const CWDE
const CX
const DAA
const DAS
const DEC
const DH
const DI
const DIB
const DIV
const DIVPD
const DIVPS
const DIVSD
const DIVSS
const DL
const DPPD
const DPPS
Debug registers.
const DR0
const DR1
const DR10
const DR11
const DR12
const DR13
const DR14
const DR15
const DR2
const DR3
const DR4
const DR5
const DR6
const DR7
const DR8
const DR9
const DS
const DX
32-bit
const EAX
const EBP
const EBX
const ECX
const EDI
const EDX
const EIP
const EMMS
const ENTER
Segment registers.
const ES
const ESI
const ESP
const EXTRACTPS
These are the errors returned by Decode.
var ErrInvalidMode = *ast.CallExpr
These are the errors returned by Decode.
var ErrTruncated = *ast.CallExpr
These are the errors returned by Decode.
var ErrUnrecognized = *ast.CallExpr
387 floating point registers.
const F0
const F1
const F2
const F2XM1
const F3
const F4
const F5
const F6
const F7
const FABS
const FADD
const FADDP
const FBLD
const FBSTP
const FCHS
const FCMOVB
const FCMOVBE
const FCMOVE
const FCMOVNB
const FCMOVNBE
const FCMOVNE
const FCMOVNU
const FCMOVU
const FCOM
const FCOMI
const FCOMIP
const FCOMP
const FCOMPP
const FCOS
const FDECSTP
const FDIV
const FDIVP
const FDIVR
const FDIVRP
const FFREE
const FFREEP
const FIADD
const FICOM
const FICOMP
const FIDIV
const FIDIVR
const FILD
const FIMUL
const FINCSTP
const FIST
const FISTP
const FISTTP
const FISUB
const FISUBR
const FLD
const FLD1
const FLDCW
const FLDENV
const FLDL2E
const FLDL2T
const FLDLG2
const FLDLN2
const FLDPI
const FLDZ
const FMUL
const FMULP
const FNCLEX
const FNINIT
const FNOP
const FNSAVE
const FNSTCW
const FNSTENV
const FNSTSW
const FPATAN
const FPREM
const FPREM1
const FPTAN
const FRNDINT
const FRSTOR
const FS
const FSCALE
const FSIN
const FSINCOS
const FSQRT
const FST
const FSTP
const FSUB
const FSUBP
const FSUBR
const FSUBRP
const FTST
const FUCOM
const FUCOMI
const FUCOMIP
const FUCOMP
const FUCOMPP
const FWAIT
const FXAM
const FXCH
const FXRSTOR
const FXRSTOR64
const FXSAVE
const FXSAVE64
const FXTRACT
const FYL2X
const FYL2XP1
System registers.
const GDTR
const GS
const HADDPD
const HADDPS
const HLT
const HSUBPD
const HSUBPS
const ICEBP
const IDIV
const IDTR
const IMUL
const IN
const INC
const INSB
const INSD
const INSERTPS
const INSW
const INT
const INTO
const INVD
const INVLPG
const INVPCID
Instruction pointer.
const IP
const IRET
const IRETD
const IRETQ
const JA
const JAE
const JB
const JBE
const JCXZ
const JE
const JECXZ
const JG
const JGE
const JL
const JLE
const JMP
const JNE
const JNO
const JNP
const JNS
const JO
const JP
const JRCXZ
const JS
const LAHF
const LAR
const LCALL
const LDDQU
const LDMXCSR
const LDS
const LDTR
const LEA
const LEAVE
const LES
const LFENCE
const LFS
const LGDT
const LGS
const LIDT
const LJMP
const LLDT
const LMSW
const LODSB
const LODSD
const LODSQ
const LODSW
const LOOP
const LOOPE
const LOOPNE
const LRET
const LSL
const LSS
const LTR
const LZCNT
MMX registers.
const M0
const M1
const M2
const M3
const M4
const M5
const M6
const M7
const MASKMOVDQU
const MASKMOVQ
const MAXPD
const MAXPS
const MAXSD
const MAXSS
const MFENCE
const MINPD
const MINPS
const MINSD
const MINSS
const MONITOR
const MOV
const MOVAPD
const MOVAPS
const MOVBE
const MOVD
const MOVDDUP
const MOVDQ2Q
const MOVDQA
const MOVDQU
const MOVHLPS
const MOVHPD
const MOVHPS
const MOVLHPS
const MOVLPD
const MOVLPS
const MOVMSKPD
const MOVMSKPS
const MOVNTDQ
const MOVNTDQA
const MOVNTI
const MOVNTPD
const MOVNTPS
const MOVNTQ
const MOVNTSD
const MOVNTSS
const MOVQ
const MOVQ2DQ
const MOVSB
const MOVSD
const MOVSD_XMM
const MOVSHDUP
const MOVSLDUP
const MOVSQ
const MOVSS
const MOVSW
const MOVSX
const MOVSXD
const MOVUPD
const MOVUPS
const MOVZX
const MPSADBW
const MSW
const MUL
const MULPD
const MULPS
const MULSD
const MULSS
const MWAIT
const NEG
const NOP
const NOT
const OR
const ORPD
const ORPS
const OUT
const OUTSB
const OUTSD
const OUTSW
const PABSB
const PABSD
const PABSW
const PACKSSDW
const PACKSSWB
const PACKUSDW
const PACKUSWB
const PADDB
const PADDD
const PADDQ
const PADDSB
const PADDSW
const PADDUSB
const PADDUSW
const PADDW
const PALIGNR
const PAND
const PANDN
const PAUSE
const PAVGB
const PAVGW
const PBLENDVB
const PBLENDW
const PCLMULQDQ
const PCMPEQB
const PCMPEQD
const PCMPEQQ
const PCMPEQW
const PCMPESTRI
const PCMPESTRM
const PCMPGTB
const PCMPGTD
const PCMPGTQ
const PCMPGTW
const PCMPISTRI
const PCMPISTRM
const PEXTRB
const PEXTRD
const PEXTRQ
const PEXTRW
const PHADDD
const PHADDSW
const PHADDW
const PHMINPOSUW
const PHSUBD
const PHSUBSW
const PHSUBW
const PINSRB
const PINSRD
const PINSRQ
const PINSRW
const PMADDUBSW
const PMADDWD
const PMAXSB
const PMAXSD
const PMAXSW
const PMAXUB
const PMAXUD
const PMAXUW
const PMINSB
const PMINSD
const PMINSW
const PMINUB
const PMINUD
const PMINUW
const PMOVMSKB
const PMOVSXBD
const PMOVSXBQ
const PMOVSXBW
const PMOVSXDQ
const PMOVSXWD
const PMOVSXWQ
const PMOVZXBD
const PMOVZXBQ
const PMOVZXBW
const PMOVZXDQ
const PMOVZXWD
const PMOVZXWQ
const PMULDQ
const PMULHRSW
const PMULHUW
const PMULHW
const PMULLD
const PMULLW
const PMULUDQ
const POP
const POPA
const POPAD
const POPCNT
const POPF
const POPFD
const POPFQ
const POR
const PREFETCHNTA
const PREFETCHT0
const PREFETCHT1
const PREFETCHT2
const PREFETCHW
const PSADBW
const PSHUFB
const PSHUFD
const PSHUFHW
const PSHUFLW
const PSHUFW
const PSIGNB
const PSIGND
const PSIGNW
const PSLLD
const PSLLDQ
const PSLLQ
const PSLLW
const PSRAD
const PSRAW
const PSRLD
const PSRLDQ
const PSRLQ
const PSRLW
const PSUBB
const PSUBD
const PSUBQ
const PSUBSB
const PSUBSW
const PSUBUSB
const PSUBUSW
const PSUBW
const PTEST
const PUNPCKHBW
const PUNPCKHDQ
const PUNPCKHQDQ
const PUNPCKHWD
const PUNPCKLBW
const PUNPCKLDQ
const PUNPCKLQDQ
const PUNPCKLWD
const PUSH
const PUSHA
const PUSHAD
const PUSHF
const PUSHFD
const PUSHFQ
const PXOR
const PrefixAddr16 Prefix = 0x167
const PrefixAddr32 Prefix = 0x267
const PrefixAddrSize Prefix = 0x67
const PrefixBND Prefix = 0x2F2
const PrefixCS Prefix = 0x2E
const PrefixDS Prefix = 0x3E
const PrefixData16 Prefix = 0x166
const PrefixData32 Prefix = 0x266
Size attributes.
const PrefixDataSize Prefix = 0x66
Memory segment overrides.
const PrefixES Prefix = 0x26
const PrefixFS Prefix = 0x64
const PrefixGS Prefix = 0x65
const PrefixIgnored Prefix = 0x4000
Metadata about the role of a prefix in an instruction.
const PrefixImplicit Prefix = 0x8000
const PrefixInvalid Prefix = 0x2000
One of a kind.
const PrefixLOCK Prefix = 0xF0
Branch prediction.
const PrefixPN Prefix = 0x12E
const PrefixPT Prefix = 0x13E
const PrefixREP Prefix = 0xF3
const PrefixREPN Prefix = 0xF2
The REX prefixes must be in the range [PrefixREX, PrefixREX+0x10). the other bits are set or not according to the intended use.
const PrefixREX Prefix = 0x40
const PrefixREXB Prefix = 0x01
const PrefixREXR Prefix = 0x04
const PrefixREXW Prefix = 0x08
const PrefixREXX Prefix = 0x02
const PrefixSS Prefix = 0x36
const PrefixVEX2Bytes Prefix = 0xC5
const PrefixVEX3Bytes Prefix = 0xC4
const PrefixXACQUIRE Prefix = 0x1F2
const PrefixXRELEASE Prefix = 0x1F3
const R10
const R10B
const R10L
const R10W
const R11
const R11B
const R11L
const R11W
const R12
const R12B
const R12L
const R12W
const R13
const R13B
const R13L
const R13W
const R14
const R14B
const R14L
const R14W
const R15
const R15B
const R15L
const R15W
const R8
const R8B
const R8L
const R8W
const R9
const R9B
const R9L
const R9W
64-bit
const RAX
const RBP
const RBX
const RCL
const RCPPS
const RCPSS
const RCR
const RCX
const RDFSBASE
const RDGSBASE
const RDI
const RDMSR
const RDPMC
const RDRAND
const RDTSC
const RDTSCP
const RDX
const RET
const RIP
const ROL
const ROR
const ROUNDPD
const ROUNDPS
const ROUNDSD
const ROUNDSS
const RSI
const RSM
const RSP
const RSQRTPS
const RSQRTSS
const SAHF
const SAR
const SBB
const SCASB
const SCASD
const SCASQ
const SCASW
const SETA
const SETAE
const SETB
const SETBE
const SETE
const SETG
const SETGE
const SETL
const SETLE
const SETNE
const SETNO
const SETNP
const SETNS
const SETO
const SETP
const SETS
const SFENCE
const SGDT
const SHL
const SHLD
const SHR
const SHRD
const SHUFPD
const SHUFPS
const SI
const SIB
const SIDT
const SLDT
const SMSW
const SP
const SPB
const SQRTPD
const SQRTPS
const SQRTSD
const SQRTSS
const SS
const STC
const STD
const STI
const STMXCSR
const STOSB
const STOSD
const STOSQ
const STOSW
const STR
const SUB
const SUBPD
const SUBPS
const SUBSD
const SUBSS
const SWAPGS
const SYSCALL
const SYSENTER
const SYSEXIT
const SYSRET
const TASK
const TEST
Task registers.
const TR0
const TR1
const TR2
const TR3
const TR4
const TR5
const TR6
const TR7
const TZCNT
const UCOMISD
const UCOMISS
const UD0
const UD1
const UD2
const UNPCKHPD
const UNPCKHPS
const UNPCKLPD
const UNPCKLPS
const VERR
const VERW
const VMOVDQA
const VMOVDQU
const VMOVNTDQ
const VMOVNTDQA
const VZEROUPPER
const WBINVD
const WRFSBASE
const WRGSBASE
const WRMSR
XMM registers.
const X0
const X1
const X10
const X11
const X12
const X13
const X14
const X15
const X2
const X3
const X4
const X5
const X6
const X7
const X8
const X9
const XABORT
const XADD
const XBEGIN
const XCHG
const XEND
const XGETBV
const XLATB
const XOR
const XORPD
const XORPS
const XRSTOR
const XRSTOR64
const XRSTORS
const XRSTORS64
const XSAVE
const XSAVE64
const XSAVEC
const XSAVEC64
const XSAVEOPT
const XSAVEOPT64
const XSAVES
const XSAVES64
const XSETBV
const XTEST
const _ Reg = iota
const _ Op = iota
addr16 records the eight 16-bit addressing modes.
var addr16 = [8]Mem{...}
baseReg records the base register for argument types that specify a range of registers indexed by op, regop, or rm.
var baseReg = [...]Reg{...}
var cmppsOps = []string{...}
var decoder = [...]uint16{...}
decoderCover records coverage information for which parts of the byte code have been executed.
var decoderCover []bool
var errInternal = *ast.CallExpr
fixedArg records the fixed arguments corresponding to the given bytecodes.
var fixedArg = [...]Arg{...}
var gccRegName = [...]string{...}
var gnuOp = map[Op]string{...}
var intelOp = map[Op]string{...}
var intelReg = [...]string{...}
isCondJmp records the conditional jumps.
var isCondJmp = [*ast.BinaryExpr]bool{...}
isLoop records the loop operators.
var isLoop = [*ast.BinaryExpr]bool{...}
const maxOp = XTEST
memBytes records the size of the memory pointed at by a memory argument of the given form.
var memBytes = [...]int8{...}
var opNames = [...]string{...}
var pclmulqOps = []string{...}
var plan9Reg = [...]string{...}
var plan9Suffix = [*ast.BinaryExpr]bool{...}
var prefixNames = map[Prefix]string{...}
const regMax = TR7
var regNames = [...]string{...}
Set trace to true to cause the decoder to print the PC sequence of the executed instruction codes. This is typically only useful when you are running a test of a single input case.
const trace = false
const xArg1
const xArg3
const xArgAL
const xArgAX
const xArgCL
const xArgCR0dashCR7
const xArgCS
const xArgDR0dashDR7
const xArgDS
const xArgDX
const xArgEAX
const xArgEDX
const xArgES
const xArgFS
const xArgGS
const xArgImm16
const xArgImm16u
const xArgImm32
const xArgImm64
const xArgImm8
const xArgImm8u
const xArgM
const xArgM128
const xArgM1428byte
const xArgM16
const xArgM16and16
const xArgM16and32
const xArgM16and64
const xArgM16colon16
const xArgM16colon32
const xArgM16colon64
const xArgM16int
const xArgM256
const xArgM2byte
const xArgM32
const xArgM32and32
const xArgM32fp
const xArgM32int
const xArgM512byte
const xArgM64
const xArgM64fp
const xArgM64int
const xArgM8
const xArgM80bcd
const xArgM80dec
const xArgM80fp
const xArgM94108byte
const xArgMem
const xArgMm
const xArgMm1
const xArgMm2
const xArgMm2M64
const xArgMmM32
const xArgMmM64
const xArgMoffs16
const xArgMoffs32
const xArgMoffs64
const xArgMoffs8
const xArgPtr16colon16
const xArgPtr16colon32
const xArgR16
const xArgR16op
const xArgR32
const xArgR32M16
const xArgR32M8
const xArgR32op
const xArgR64
const xArgR64M16
const xArgR64op
const xArgR8
const xArgR8op
const xArgRAX
const xArgRDX
const xArgRM
const xArgRM16
const xArgRM32
const xArgRM64
const xArgRM8
const xArgReg
const xArgRegM16
const xArgRegM32
const xArgRegM8
const xArgRel16
const xArgRel32
const xArgRel8
const xArgRmf16
const xArgRmf32
const xArgRmf64
const xArgSS
const xArgST
const xArgSTi
const xArgSreg
const xArgTR0dashTR7
const xArgXMM0
const xArgXmm
const xArgXmm1
const xArgXmm2
const xArgXmm2M128
const xArgXmm2M16
const xArgXmm2M32
const xArgXmm2M64
const xArgXmmM128
const xArgXmmM32
const xArgXmmM64
const xArgYmm1
const xArgYmm2M256
const xCondAddrSize
const xCondByte
const xCondDataSize
const xCondIs64
const xCondIsMem
const xCondPrefix
const xCondSlashR
const xFail decodeOp = iota
const xJump
const xMatch
const xReadCb
const xReadCd
const xReadCm
const xReadCp
const xReadCw
const xReadIb
const xReadId
const xReadIo
const xReadIw
const xReadSlashR
const xSetOp
An Args holds the instruction arguments. If an instruction has fewer than 4 arguments, the final elements in the array are nil.
type Args [4]Arg
An Imm is an integer constant.
type Imm int64
An Op is an x86 opcode.
type Op uint32
A Prefix represents an Intel instruction prefix. The low 8 bits are the actual prefix byte encoding, and the top 8 bits contain distinguishing bits and metadata.
type Prefix uint16
Prefixes is an array of prefixes associated with a single instruction. The prefixes are listed in the same order as found in the instruction: each prefix byte corresponds to one slot in the array. The first zero in the array marks the end of the prefixes.
type Prefixes [14]Prefix
A Reg is a single register. The zero Reg value has no name but indicates “no register.”
type Reg uint8
A Rel is an offset relative to the current instruction pointer.
type Rel int32
type SymLookup func(uint64) (string, uint64)
type decodeOp uint16
An Arg is a single instruction argument, one of these types: Reg, Mem, Imm, Rel.
type Arg interface {
String() string
isArg()
}
An Inst is a single instruction.
type Inst struct {
Prefix Prefixes
Op Op
Opcode uint32
Args Args
Mode int
AddrSize int
DataSize int
MemBytes int
Len int
PCRel int
PCRelOff int
}
A Mem is a memory reference. The general form is Segment:[Base+Scale*Index+Disp].
type Mem struct {
Segment Reg
Base Reg
Scale uint8
Index Reg
Disp int64
}
Decode decodes the leading bytes in src as a single instruction. The mode arguments specifies the assumed processor mode: 16, 32, or 64 for 16-, 32-, and 64-bit execution modes.
func Decode(src []byte, mode int) (inst Inst, err error)
GNUSyntax returns the GNU assembler syntax for the instruction, as defined by GNU binutils. This general form is often called “AT&T syntax” as a reference to AT&T System V Unix.
func GNUSyntax(inst Inst, pc uint64, symname SymLookup) string
GoSyntax returns the Go assembler syntax for the instruction. The syntax was originally defined by Plan 9. The pc is the program counter of the instruction, used for expanding PC-relative addresses into absolute ones. The symname function queries the symbol table for the program being disassembled. Given a target address it returns the name and base address of the symbol containing the target, if any; otherwise it returns "", 0.
func GoSyntax(inst Inst, pc uint64, symname SymLookup) string
IntelSyntax returns the Intel assembler syntax for the instruction, as defined by Intel's XED tool.
func IntelSyntax(inst Inst, pc uint64, symname SymLookup) string
IsREX reports whether p is a REX prefix byte.
func (p Prefix) IsREX() bool
func (p Prefix) IsVEX() bool
func (i Imm) String() string
func (p Prefix) String() string
func (i Inst) String() string
func (r Rel) String() string
func (m Mem) String() string
func (r Reg) String() string
func (op Op) String() string
func argBytes(inst *Inst, arg Arg) int
baseRegForBits returns the base register for a given register size in bits.
func baseRegForBits(bits int) Reg
func byteSizeSuffix(b int) string
func countPrefix(inst *Inst, target Prefix) int
decode1 is the implementation of Decode but takes an extra gnuCompat flag to cause it to change its behavior to mimic bugs (or at least unique features) of GNU libopcodes as used by objdump. We don't believe that logic is the right thing to do in general, but when testing against libopcodes it simplifies the comparison if we adjust a few small pieces of logic. The affected logic is in the conditional branch for "mandatory" prefixes, case xCondPrefix.
func decode1(src []byte, mode int, gnuCompat bool) (Inst, error)
gnuArg returns the GNU syntax for the argument x from the instruction inst. If *usedPrefixes is false and x is a Mem, then the formatting includes any segment prefixes and sets *usedPrefixes to true.
func gnuArg(inst *Inst, pc uint64, symname SymLookup, x Arg, usedPrefixes *bool) string
instPrefix returns an Inst describing just one prefix byte. It is only used if there is a prefix followed by an unintelligible or invalid instruction byte sequence.
func instPrefix(b byte, mode int) (Inst, error)
func intelArg(inst *Inst, pc uint64, symname SymLookup, arg Arg) string
func (Reg) isArg()
func (Rel) isArg()
func (Imm) isArg()
func (Mem) isArg()
func isFloat(op Op) bool
func isFloatInt(op Op) bool
func isImm(a Arg) bool
func isMem(a Arg) bool
func isReg(a Arg) bool
func isSegReg(a Arg) bool
func isSegment(p Prefix) bool
func markLastImplicit(inst *Inst, prefix Prefix) bool
func memArgToSymbol(a Mem, pc uint64, instrLen int, symname SymLookup) (string, int64)
func plan9Arg(inst *Inst, pc uint64, symname func(uint64) (string, uint64), arg Arg) string
prefixToSegment returns the segment register corresponding to a particular segment prefix.
func prefixToSegment(p Prefix) Reg
func regBytes(a Arg) int
truncated reports a truncated instruction. For now we use instPrefix but perhaps later we will return a specific error here.
func truncated(src []byte, mode int) (Inst, error)
func unmarkImplicit(inst *Inst, prefix Prefix)
Generated with Arrow