diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2020-11-20 17:30:23 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2020-11-21 08:46:20 +0100 |
| commit | 5405d2e2ed019de7452677eacfc7de9562a8ea12 (patch) | |
| tree | 7b2f9f488a4b57ce9a40e4d16bc263c2f00d8e48 /pkg/ifuzz/x86/decode.go | |
| parent | 9bc78a846441516a33a7fd3b245380f463ba88ed (diff) | |
pkg/ifuzz: invert ifuzz and ifuzzimpl
ifuzzimpl imports the public interface package ifuzz
and prog package needs to import ifuzzimpl (implementation guts that
nobody outside of ifuzz should care about). This is not right.
Invert everything so that prog package only needs to import ifuzz
and ifuzz imports ifuzzimpl.
Diffstat (limited to 'pkg/ifuzz/x86/decode.go')
| -rw-r--r-- | pkg/ifuzz/x86/decode.go | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/pkg/ifuzz/x86/decode.go b/pkg/ifuzz/x86/decode.go index ca611ac69..e02a3a63f 100644 --- a/pkg/ifuzz/x86/decode.go +++ b/pkg/ifuzz/x86/decode.go @@ -5,26 +5,27 @@ package x86 import ( "fmt" - "github.com/google/syzkaller/pkg/ifuzz" + + "github.com/google/syzkaller/pkg/ifuzz/ifuzzimpl" ) // Decode decodes instruction length for the given mode. // It can have falsely decode incorrect instructions, // but should not fail to decode correct instructions. // nolint: gocyclo, nestif, gocognit, funlen -func (insnset *InsnSetX86) Decode(mode int, text []byte) (int, error) { +func (insnset *InsnSetX86) Decode(mode ifuzzimpl.Mode, text []byte) (int, error) { if len(text) == 0 { return 0, fmt.Errorf("zero-length instruction") } prefixes := prefixes32 var operSize, immSize, dispSize, addrSize int switch mode { - case ifuzz.ModeLong64: + case ifuzzimpl.ModeLong64: operSize, immSize, dispSize, addrSize = 4, 4, 4, 8 prefixes = prefixes64 - case ifuzz.ModeProt32: + case ifuzzimpl.ModeProt32: operSize, immSize, dispSize, addrSize = 4, 4, 4, 4 - case ifuzz.ModeProt16, ifuzz.ModeReal16: + case ifuzzimpl.ModeProt16, ifuzzimpl.ModeReal16: operSize, immSize, dispSize, addrSize = 2, 2, 2, 2 default: panic("bad mode") @@ -35,7 +36,7 @@ func (insnset *InsnSetX86) Decode(mode int, text []byte) (int, error) { if len(text) > 1 { // There are only 2 32-bit instructions that look like VEX-prefixed but are actually not: LDS, LES. // They always reference memory (mod!=3), but all VEX instructions have "mod=3" where LDS/LES would have mod. - if (text[0] == 0xc4 || text[0] == 0xc5) && (mode == ifuzz.ModeLong64 || text[1]&0xc0 == 0xc0) { + if (text[0] == 0xc4 || text[0] == 0xc5) && (mode == ifuzzimpl.ModeLong64 || text[1]&0xc0 == 0xc0) { vex = true } // There is only one instruction that looks like XOP-prefixed but is actually not: POP. @@ -207,7 +208,7 @@ nextInsn: return 0, fmt.Errorf("unknown instruction") } -var XedDecode func(mode int, text []byte) (int, error) +var XedDecode func(mode ifuzzimpl.Mode, text []byte) (int, error) var ( prefixes32 = map[byte]bool{ @@ -225,7 +226,7 @@ var ( } ) -func (insnset *InsnSetX86) DecodeExt(mode int, text []byte) (int, error) { +func (insnset *InsnSetX86) DecodeExt(mode ifuzzimpl.Mode, text []byte) (int, error) { if XedDecode != nil && text != nil && len(text) > 0 { return XedDecode(mode, text) } |
