Best Syzkaller code snippet using x86.generateArg
encode.go
Source:encode.go
...185 if !insn.NoSibDisp {186 if addrSize == 2 {187 if mod == 1 {188 // disp8189 code = append(code, generateArg(cfg, r, 1)...)190 } else if mod == 2 || mod == 0 && rm == 6 {191 // disp16192 code = append(code, generateArg(cfg, r, 2)...)193 }194 } else {195 var sibbase byte196 if mod != 3 && rm == 4 {197 // SIB198 scale := byte(r.Intn(4))199 index := byte(r.Intn(8))200 sibbase = byte(r.Intn(8))201 if insn.Avx2Gather {202 rrrr := reg | (1-vexR)<<3203 for {204 iiii := index | (1-vexX)<<3205 if iiii != vvvv^0xf && iiii != rrrr {206 break207 }208 index = (index + 1) & 7209 }210 }211 sib := scale<<6 | index<<3 | sibbase212 code = append(code, sib)213 }214 if mod == 1 {215 // disp8216 code = append(code, generateArg(cfg, r, 1)...)217 } else if mod == 2 || mod == 0 && rm == 5 || mod == 0 && sibbase == 5 {218 // disp16/32219 code = append(code, generateArg(cfg, r, dispSize)...)220 }221 }222 }223 }224 addImm := func(imm int) {225 if imm == -1 {226 imm = immSize227 } else if imm == -2 {228 imm = addrSize229 } else if imm == -3 {230 imm = operSize231 }232 if imm != 0 {233 code = append(code, generateArg(cfg, r, imm)...)234 }235 }236 addImm(int(insn.Imm))237 addImm(int(insn.Imm2))238 code = append(code, insn.Suffix...)239 return code240}...
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!!