Best Syzkaller code snippet using main.addImm
gen.go
Source:gen.go
...268 case v == "lock_prefix":269 insn.Prefix = append(insn.Prefix, 0xF0)270 // Immediates.271 case v == "UIMM8()", v == "SIMM8()":272 addImm(insn, 1)273 case v == "UIMM16()":274 addImm(insn, 2)275 case v == "UIMM32()":276 addImm(insn, 4)277 case v == "SIMMz()":278 addImm(insn, -1)279 case v == "UIMMv()":280 addImm(insn, -3)281 case v == "UIMM8_1()":282 addImm(insn, 1)283 case v == "BRDISP8()":284 addImm(insn, 1)285 case v == "BRDISP32()":286 addImm(insn, 4)287 case v == "BRDISPz()":288 addImm(insn, -1)289 case v == "MEMDISPv()":290 addImm(insn, -2)291 // VOP/VEX292 case v == "XOPV":293 insn.Vex = 0x8f294 insn.Mode &^= 1 << ifuzz.ModeReal16295 case v == "EVV":296 insn.Vex = 0xc4297 case v == "VV1":298 insn.Vex = 0xc4299 case v == "VMAP0":300 insn.VexMap = 0301 case v == "V0F":302 insn.VexMap = 1303 case v == "V0F38":304 insn.VexMap = 2305 case v == "V0F3A":306 insn.VexMap = 3307 case v == "XMAP8":308 insn.VexMap = 8309 case v == "XMAP9":310 insn.VexMap = 9311 case v == "XMAPA":312 insn.VexMap = 10313 case v == "VNP":314 insn.VexP = 0315 case v == "V66":316 insn.VexP = 1317 case v == "VF2":318 insn.VexP = 3319 case v == "VF3":320 insn.VexP = 2321 case v == "VL128", v == "VL=0":322 insn.VexL = -1323 case v == "VL256", v == "VL=1":324 insn.VexL = 1325 case v == "NOVSR":326 insn.VexNoR = true327 case v == "NOEVSR":328 insn.VexNoR = true329 // VEXDEST3=0b1 VEXDEST210=0b111 VEXDEST4=0b0330 case v == "SE_IMM8()":331 addImm(insn, 1)332 // Modes333 case v == "mode64":334 insn.Mode &= 1 << ifuzz.ModeLong64335 case v == "not64":336 insn.Mode &^= 1 << ifuzz.ModeLong64337 case v == "mode32":338 insn.Mode &= 1 << ifuzz.ModeProt32339 case v == "mode16":340 insn.Mode &= 1<<ifuzz.ModeProt16 | 1<<ifuzz.ModeReal16341 case v == "eamode64",342 v == "eamode32",343 v == "eamode16",344 v == "eanot16":345 case v == "no_refining_prefix":346 insn.NoRepPrefix = true347 insn.No66Prefix = true348 case v == "no66_prefix", v == "eosz32", v == "eosz64":349 insn.No66Prefix = true350 case v == "eosz16", v == "eosznot64", v == "REP!=3":351 // TODO(dvyukov): this may have some effect on REP/66 prefixes,352 // but this wasn't checked. These are just added here to unbreak build.353 case v == "f2_refining_prefix", v == "refining_f2", v == "repne", v == "REP=2":354 insn.Prefix = append(insn.Prefix, 0xF2)355 insn.NoRepPrefix = true356 case v == "f3_refining_prefix", v == "refining_f3", v == "repe", v == "REP=3":357 insn.Prefix = append(insn.Prefix, 0xF3)358 insn.NoRepPrefix = true359 case v == "norep", v == "not_refining", v == "REP=0":360 insn.NoRepPrefix = true361 case v == "osz_refining_prefix":362 insn.Prefix = append(insn.Prefix, 0x66)363 insn.NoRepPrefix = true364 case v == "rexw_prefix", v == "W1":365 insn.Rexw = 1366 case v == "norexw_prefix", v == "W0":367 insn.Rexw = -1368 case v == "MPXMODE=1",369 v == "MPXMODE=0",370 v == "TZCNT=1",371 v == "TZCNT=0",372 v == "LZCNT=1",373 v == "LZCNT=0",374 v == "CR_WIDTH()",375 v == "DF64()",376 v == "IMMUNE_REXW()",377 v == "FORCE64()",378 v == "EOSZ=1",379 v == "EOSZ!=1",380 v == "EOSZ=2",381 v == "EOSZ!=2",382 v == "EOSZ=3",383 v == "EOSZ!=3",384 v == "BRANCH_HINT()",385 v == "P4=1",386 v == "P4=0",387 v == "rexb_prefix",388 v == "norexb_prefix",389 v == "IMMUNE66()",390 v == "REFINING66()",391 v == "IGNORE66()",392 v == "IMMUNE66_LOOP64()",393 v == "OVERRIDE_SEG0()",394 v == "OVERRIDE_SEG1()",395 v == "REMOVE_SEGMENT()",396 v == "ONE()",397 v == "nolock_prefix",398 v == "MODRM()",399 v == "VMODRM_XMM()",400 v == "VMODRM_YMM()",401 v == "BCRC=0",402 v == "BCRC=1",403 v == "ESIZE_8_BITS()",404 v == "ESIZE_16_BITS()",405 v == "ESIZE_32_BITS()",406 v == "ESIZE_64_BITS()",407 v == "ESIZE_128_BITS()",408 v == "NELEM_GPR_WRITER_STORE()",409 v == "NELEM_GPR_WRITER_STORE_BYTE()",410 v == "NELEM_GPR_WRITER_STORE_WORD()",411 v == "NELEM_GPR_WRITER_LDOP_Q()",412 v == "NELEM_GPR_WRITER_LDOP_D()",413 v == "NELEM_GPR_READER()",414 v == "NELEM_GPR_READER_BYTE()",415 v == "NELEM_GPR_READER_WORD()",416 v == "NELEM_GSCAT()",417 v == "NELEM_HALF()",418 v == "NELEM_FULL()",419 v == "NELEM_FULLMEM()",420 v == "NELEM_QUARTERMEM()",421 v == "NELEM_EIGHTHMEM()",422 v == "NELEM_HALFMEM()",423 v == "NELEM_MEM128()",424 v == "NELEM_SCALAR()",425 v == "NELEM_TUPLE1()",426 v == "NELEM_TUPLE2()",427 v == "NELEM_TUPLE4()",428 v == "NELEM_TUPLE8()",429 v == "NELEM_TUPLE1_4X()",430 v == "NELEM_TUPLE1_BYTE()",431 v == "NELEM_TUPLE1_WORD()",432 v == "NELEM_MOVDDUP()",433 v == "UISA_VMODRM_XMM()",434 v == "UISA_VMODRM_YMM()",435 v == "UISA_VMODRM_ZMM()",436 v == "MASK=0",437 v == "FIX_ROUND_LEN128()",438 v == "FIX_ROUND_LEN512()",439 v == "AVX512_ROUND()",440 v == "ZEROING=0",441 v == "SAE()",442 v == "VL512", // VL=2443 v == "not_refining_f3",444 v == "EVEXRR_ONE",445 v == "CET=0",446 v == "CET=1",447 v == "WBNOINVD=0",448 v == "WBNOINVD=1",449 v == "CLDEMOTE=0",450 v == "CLDEMOTE=1",451 strings.HasPrefix(v, "MODEP5="):452 default:453 return errSkip(fmt.Sprintf("unknown pattern %v", v))454 }455 }456 if insn.Modrm {457 switch insn.Mod {458 case -3, -1, 0, 1, 2, 3:459 default:460 return fmt.Errorf("bad MOD value: %v", insn.Mod)461 }462 if insn.Reg < -1 || insn.Reg > 7 {463 return fmt.Errorf("bad REG value: %v", insn.Mod)464 }465 if insn.Rm < -1 || insn.Rm > 7 {466 return fmt.Errorf("bad RM value: %v", insn.Mod)467 }468 }469 if insn.Imm != 0 && len(insn.Suffix) != 0 {470 return fmt.Errorf("both immediate and suffix opcode")471 }472 if insn.Mode == 0 {473 return errSkip("no modes for instruction")474 }475 return nil476}477func parseOperands(insn *ifuzz.Insn, vals []string) error {478 for _, v := range vals {479 switch v {480 case "REG0=SEG():r", "REG1=SEG():r", "REG0=SEG():w":481 if insn.Reg != -1 {482 return fmt.Errorf("REG=SEG() operand, but fixed reg")483 }484 insn.Reg = -6485 case "REG0=CR_R():w", "REG1=CR_R():r":486 if insn.Reg != -1 {487 return fmt.Errorf("REG=CR_R() operand, but fixed reg")488 }489 insn.Reg = -8490 insn.NoSibDisp = true491 case "REG0=DR_R():w", "REG1=DR_R():r":492 insn.NoSibDisp = true493 case "MEM0:r:mem16", "MEM0:w:mem16", "MEM0:r:mem16int", "MEM0:w:mem16int":494 insn.Mem16 = true495 case "MEM0:r:mem32real", "MEM0:r:mem32int", "MEM0:w:mem32real", "MEM0:w:mem32int":496 insn.Mem32 = true497 }498 }499 return nil500}501func parseModrm(v string) (int8, error) {502 if len(v) < 4 || len(v) > 7 || v[0] != '[' || v[len(v)-1] != ']' {503 return 0, fmt.Errorf("malformed")504 }505 if v == "[mm]" || v == "[rrr]" || v == "[nnn]" {506 return -1, nil507 }508 if !strings.HasPrefix(v, "[0b") {509 return 0, fmt.Errorf("malformed")510 }511 var vv int8512 for i := 3; i < len(v)-1; i++ {513 if v[i] != '0' && v[i] != '1' {514 return 0, fmt.Errorf("malformed")515 }516 vv *= 2517 if v[i] == '1' {518 vv++519 }520 }521 return vv, nil522}523func addImm(insn *ifuzz.Insn, imm int8) {524 if insn.Imm == 0 {525 insn.Imm = imm526 return527 }528 if insn.Imm2 == 0 {529 insn.Imm2 = imm530 return531 }532 panic("too many immediates")533}534func failf(msg string, args ...interface{}) {535 fmt.Fprintf(os.Stderr, msg+"\n", args...)536 os.Exit(1)537}...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!