How to use objdump method of backend Package

Best Syzkaller code snippet using backend.objdump

dwarf.go

Source:dwarf.go Github

copy

Full Screen

...91 }92 var data []byte93 var coverPoints [2][]uint6494 if target.Arch != targets.AMD64 && target.Arch != targets.ARM64 {95 coverPoints, err = objdump(target, module)96 } else if module.Name == "" {97 data, err = fn.readTextData(module)98 if err != nil {99 errc <- err100 return101 }102 coverPoints, err = readCoverPoints(target, info, data)103 } else {104 coverPoints, err = fn.readModuleCoverPoints(target, module, info)105 }106 allCoverPoints[0] = append(allCoverPoints[0], coverPoints[0]...)107 allCoverPoints[1] = append(allCoverPoints[1], coverPoints[1]...)108 if err == nil && module.Name == "" && len(coverPoints[0]) == 0 {109 err = fmt.Errorf("%v doesn't contain coverage callbacks (set CONFIG_KCOV=y on linux)", module.Path)110 }111 errc <- err112 }()113 ranges, units, err := fn.readTextRanges(module)114 if err != nil {115 return nil, err116 }117 if err := <-errc; err != nil {118 return nil, err119 }120 allRanges = append(allRanges, ranges...)121 allUnits = append(allUnits, units...)122 }123 sort.Slice(allSymbols, func(i, j int) bool {124 return allSymbols[i].Start < allSymbols[j].Start125 })126 sort.Slice(allRanges, func(i, j int) bool {127 return allRanges[i].start < allRanges[j].start128 })129 for k := range allCoverPoints {130 sort.Slice(allCoverPoints[k], func(i, j int) bool {131 return allCoverPoints[k][i] < allCoverPoints[k][j]132 })133 }134 allSymbols = buildSymbols(allSymbols, allRanges, allCoverPoints)135 nunit := 0136 for _, unit := range allUnits {137 if len(unit.PCs) == 0 {138 continue // drop the unit139 }140 // TODO: objDir won't work for out-of-tree modules.141 unit.Name, unit.Path = cleanPath(unit.Name, objDir, srcDir, buildDir)142 allUnits[nunit] = unit143 nunit++144 }145 allUnits = allUnits[:nunit]146 if len(allSymbols) == 0 || len(allUnits) == 0 {147 return nil, fmt.Errorf("failed to parse DWARF (set CONFIG_DEBUG_INFO=y on linux)")148 }149 if target.OS == targets.FreeBSD {150 // On FreeBSD .text address in ELF is 0, but .text is actually mapped at 0xffffffff.151 pcBase = ^uint64(0)152 }153 impl := &Impl{154 Units: allUnits,155 Symbols: allSymbols,156 Symbolize: func(pcs map[*Module][]uint64) ([]Frame, error) {157 return symbolize(target, objDir, srcDir, buildDir, pcs)158 },159 RestorePC: func(pc uint32) uint64 {160 return PreviousInstructionPC(target, RestorePC(pc, uint32(pcBase>>32)))161 },162 }163 return impl, nil164}165func buildSymbols(symbols []*Symbol, ranges []pcRange, coverPoints [2][]uint64) []*Symbol {166 // Assign coverage point PCs to symbols.167 // Both symbols and coverage points are sorted, so we do it one pass over both.168 selectPCs := func(u *ObjectUnit, typ int) *[]uint64 {169 return [2]*[]uint64{&u.PCs, &u.CMPs}[typ]170 }171 for pcType := range coverPoints {172 pcs := coverPoints[pcType]173 var curSymbol *Symbol174 firstSymbolPC, symbolIdx := -1, 0175 for i := 0; i < len(pcs); i++ {176 pc := pcs[i]177 for ; symbolIdx < len(symbols) && pc >= symbols[symbolIdx].End; symbolIdx++ {178 }179 var symb *Symbol180 if symbolIdx < len(symbols) && pc >= symbols[symbolIdx].Start && pc < symbols[symbolIdx].End {181 symb = symbols[symbolIdx]182 }183 if curSymbol != nil && curSymbol != symb {184 *selectPCs(&curSymbol.ObjectUnit, pcType) = pcs[firstSymbolPC:i]185 firstSymbolPC = -1186 }187 curSymbol = symb188 if symb != nil && firstSymbolPC == -1 {189 firstSymbolPC = i190 }191 }192 if curSymbol != nil {193 *selectPCs(&curSymbol.ObjectUnit, pcType) = pcs[firstSymbolPC:]194 }195 }196 // Assign compile units to symbols based on unit pc ranges.197 // Do it one pass as both are sorted.198 nsymbol := 0199 rangeIndex := 0200 for _, s := range symbols {201 for ; rangeIndex < len(ranges) && ranges[rangeIndex].end <= s.Start; rangeIndex++ {202 }203 if rangeIndex == len(ranges) || s.Start < ranges[rangeIndex].start || len(s.PCs) == 0 {204 continue // drop the symbol205 }206 unit := ranges[rangeIndex].unit207 s.Unit = unit208 symbols[nsymbol] = s209 nsymbol++210 }211 symbols = symbols[:nsymbol]212 for pcType := range coverPoints {213 for _, s := range symbols {214 symbPCs := selectPCs(&s.ObjectUnit, pcType)215 unitPCs := selectPCs(&s.Unit.ObjectUnit, pcType)216 pos := len(*unitPCs)217 *unitPCs = append(*unitPCs, *symbPCs...)218 *symbPCs = (*unitPCs)[pos:]219 }220 }221 return symbols222}223type symbolInfo struct {224 textAddr uint64225 tracePC uint64226 traceCmp map[uint64]bool227 tracePCIdx map[int]bool228 traceCmpIdx map[int]bool229}230type pcRange struct {231 start uint64232 end uint64233 unit *CompileUnit234}235type pcFixFn = (func([2]uint64) ([2]uint64, bool))236func readTextRanges(debugInfo *dwarf.Data, module *Module, pcFix pcFixFn) (237 []pcRange, []*CompileUnit, error) {238 var ranges []pcRange239 var units []*CompileUnit240 for r := debugInfo.Reader(); ; {241 ent, err := r.Next()242 if err != nil {243 return nil, nil, err244 }245 if ent == nil {246 break247 }248 if ent.Tag != dwarf.TagCompileUnit {249 return nil, nil, fmt.Errorf("found unexpected tag %v on top level", ent.Tag)250 }251 attrName := ent.Val(dwarf.AttrName)252 if attrName == nil {253 continue254 }255 unit := &CompileUnit{256 ObjectUnit: ObjectUnit{257 Name: attrName.(string),258 },259 Module: module,260 }261 units = append(units, unit)262 ranges1, err := debugInfo.Ranges(ent)263 if err != nil {264 return nil, nil, err265 }266 var filtered bool267 for _, r := range ranges1 {268 if pcFix != nil {269 r, filtered = pcFix(r)270 if filtered {271 continue272 }273 }274 ranges = append(ranges, pcRange{r[0] + module.Addr, r[1] + module.Addr, unit})275 }276 r.SkipChildren()277 }278 return ranges, units, nil279}280func symbolizeModule(target *targets.Target, objDir, srcDir, buildDir string,281 mod *Module, pcs []uint64) ([]Frame, error) {282 procs := runtime.GOMAXPROCS(0) / 2283 if need := len(pcs) / 1000; procs > need {284 procs = need285 }286 const (287 minProcs = 1288 maxProcs = 4289 )290 // addr2line on a beefy vmlinux takes up to 1.6GB of RAM, so don't create too many of them.291 if procs > maxProcs {292 procs = maxProcs293 }294 if procs < minProcs {295 procs = minProcs296 }297 type symbolizerResult struct {298 frames []symbolizer.Frame299 err error300 }301 symbolizerC := make(chan symbolizerResult, procs)302 pcchan := make(chan []uint64, procs)303 for p := 0; p < procs; p++ {304 go func() {305 symb := symbolizer.NewSymbolizer(target)306 defer symb.Close()307 var res symbolizerResult308 for pcs := range pcchan {309 for i, pc := range pcs {310 pcs[i] = pc - mod.Addr311 }312 frames, err := symb.SymbolizeArray(mod.Path, pcs)313 if err != nil {314 res.err = fmt.Errorf("failed to symbolize: %v", err)315 }316 res.frames = append(res.frames, frames...)317 }318 symbolizerC <- res319 }()320 }321 for i := 0; i < len(pcs); {322 end := i + 100323 if end > len(pcs) {324 end = len(pcs)325 }326 pcchan <- pcs[i:end]327 i = end328 }329 close(pcchan)330 var err0 error331 var frames []Frame332 for p := 0; p < procs; p++ {333 res := <-symbolizerC334 if res.err != nil {335 err0 = res.err336 }337 for _, frame := range res.frames {338 name, path := cleanPath(frame.File, objDir, srcDir, buildDir)339 frames = append(frames, Frame{340 Module: mod,341 PC: frame.PC + mod.Addr,342 Name: name,343 Path: path,344 Range: Range{345 StartLine: frame.Line,346 StartCol: 0,347 EndLine: frame.Line,348 EndCol: LineEnd,349 },350 })351 }352 }353 if err0 != nil {354 return nil, err0355 }356 return frames, nil357}358func symbolize(target *targets.Target, objDir, srcDir, buildDir string,359 pcs map[*Module][]uint64) ([]Frame, error) {360 var frames []Frame361 for mod, pcs1 := range pcs {362 frames1, err := symbolizeModule(target, objDir, srcDir, buildDir, mod, pcs1)363 if err != nil {364 return nil, err365 }366 frames = append(frames, frames1...)367 }368 return frames, nil369}370// readCoverPoints finds all coverage points (calls of __sanitizer_cov_trace_*) in the object file.371// Currently it is [amd64|arm64]-specific: looks for opcode and correct offset.372// Running objdump on the whole object file is too slow.373func readCoverPoints(target *targets.Target, info *symbolInfo, data []byte) ([2][]uint64, error) {374 var pcs [2][]uint64375 if info.tracePC == 0 {376 return pcs, fmt.Errorf("no __sanitizer_cov_trace_pc symbol in the object file")377 }378 // Loop that's checking each instruction for the current architectures call379 // opcode. When found, it compares the call target address with those of the380 // __sanitizer_cov_trace_* functions we previously collected. When found,381 // we collect the pc as a coverage point.382 arch := arches[target.Arch]383 for i, opcode := range data {384 if opcode != arch.opcodes[0] && opcode != arch.opcodes[1] {385 continue386 }387 i -= arch.opcodeOffset388 if i < 0 || i+arch.callLen > len(data) {389 continue390 }391 pc := info.textAddr + uint64(i)392 target := arch.target(&arch, data[i:], pc, opcode)393 if target == info.tracePC {394 pcs[0] = append(pcs[0], pc)395 } else if info.traceCmp[target] {396 pcs[1] = append(pcs[1], pc)397 }398 }399 return pcs, nil400}401func cleanPath(path, objDir, srcDir, buildDir string) (string, string) {402 filename := ""403 switch {404 case strings.HasPrefix(path, objDir):405 // Assume the file was built there.406 path = strings.TrimPrefix(path, objDir)407 filename = filepath.Join(objDir, path)408 case strings.HasPrefix(path, buildDir):409 // Assume the file was moved from buildDir to srcDir.410 path = strings.TrimPrefix(path, buildDir)411 filename = filepath.Join(srcDir, path)412 default:413 // Assume this is relative path.414 filename = filepath.Join(srcDir, path)415 }416 return strings.TrimLeft(filepath.Clean(path), "/\\"), filename417}418// objdump is an old, slow way of finding coverage points.419// amd64 uses faster option of parsing binary directly (readCoverPoints).420// TODO: use the faster approach for all other arches and drop this.421func objdump(target *targets.Target, mod *Module) ([2][]uint64, error) {422 var pcs [2][]uint64423 cmd := osutil.Command(target.Objdump, "-d", "--no-show-raw-insn", mod.Path)424 stdout, err := cmd.StdoutPipe()425 if err != nil {426 return pcs, err427 }428 defer stdout.Close()429 stderr, err := cmd.StderrPipe()430 if err != nil {431 return pcs, err432 }433 defer stderr.Close()434 if err := cmd.Start(); err != nil {435 return pcs, fmt.Errorf("failed to run objdump on %v: %v", mod.Path, err)436 }437 defer func() {438 cmd.Process.Kill()439 cmd.Wait()440 }()441 s := bufio.NewScanner(stdout)442 callInsns, traceFuncs := archCallInsn(target)443 for s.Scan() {444 if pc := parseLine(callInsns, traceFuncs, s.Bytes()); pc != 0 {445 pcs[0] = append(pcs[0], pc+mod.Addr)446 }447 }448 stderrOut, _ := ioutil.ReadAll(stderr)449 if err := cmd.Wait(); err != nil {450 return pcs, fmt.Errorf("failed to run objdump on %v: %v\n%s", mod.Path, err, stderrOut)451 }452 if err := s.Err(); err != nil {453 return pcs, fmt.Errorf("failed to run objdump on %v: %v\n%s", mod.Path, err, stderrOut)454 }455 return pcs, nil456}457func parseLine(callInsns, traceFuncs [][]byte, ln []byte) uint64 {458 pos := -1459 for _, callInsn := range callInsns {460 if pos = bytes.Index(ln, callInsn); pos != -1 {461 break462 }463 }464 if pos == -1 {465 return 0466 }467 hasCall := false...

Full Screen

Full Screen

elf.go

Source:elf.go Github

copy

Full Screen

...43 }44 if target.Arch == targets.AMD64 {45 coverPoints, err = readCoverPoints(file, tracePC, traceCmp)46 } else {47 coverPoints, err = objdump(target, kernelObject)48 }49 errc <- err50 }()51 ranges, units, err := readTextRanges(file)52 if err != nil {53 return nil, err54 }55 if err := <-errc; err != nil {56 return nil, err57 }58 if len(coverPoints[0]) == 0 {59 return nil, fmt.Errorf("%v doesn't contain coverage callbacks (set CONFIG_KCOV=y)", kernelObject)60 }61 symbols = buildSymbols(symbols, ranges, coverPoints)62 nunit := 063 for _, unit := range units {64 if len(unit.PCs) == 0 {65 continue // drop the unit66 }67 unit.Name, unit.Path = cleanPath(unit.Name, objDir, srcDir, buildDir)68 units[nunit] = unit69 nunit++70 }71 units = units[:nunit]72 if len(symbols) == 0 || len(units) == 0 {73 return nil, fmt.Errorf("failed to parse DWARF (set CONFIG_DEBUG_INFO=y?)")74 }75 impl := &Impl{76 Units: units,77 Symbols: symbols,78 Symbolize: func(pcs []uint64) ([]Frame, error) {79 return symbolize(target, objDir, srcDir, buildDir, kernelObject, pcs)80 },81 RestorePC: func(pc uint32) uint64 {82 return PreviousInstructionPC(target, RestorePC(pc, uint32(textAddr>>32)))83 },84 }85 return impl, nil86}87type pcRange struct {88 start uint6489 end uint6490 unit *CompileUnit91}92func buildSymbols(symbols []*Symbol, ranges []pcRange, coverPoints [2][]uint64) []*Symbol {93 // Assign coverage point PCs to symbols.94 // Both symbols and coverage points are sorted, so we do it one pass over both.95 selectPCs := func(u *ObjectUnit, typ int) *[]uint64 {96 return [2]*[]uint64{&u.PCs, &u.CMPs}[typ]97 }98 for pcType := range coverPoints {99 pcs := coverPoints[pcType]100 var curSymbol *Symbol101 firstSymbolPC, symbolIdx := -1, 0102 for i := 0; i < len(pcs); i++ {103 pc := pcs[i]104 for ; symbolIdx < len(symbols) && pc >= symbols[symbolIdx].End; symbolIdx++ {105 }106 var symb *Symbol107 if symbolIdx < len(symbols) && pc >= symbols[symbolIdx].Start && pc < symbols[symbolIdx].End {108 symb = symbols[symbolIdx]109 }110 if curSymbol != nil && curSymbol != symb {111 *selectPCs(&curSymbol.ObjectUnit, pcType) = pcs[firstSymbolPC:i]112 firstSymbolPC = -1113 }114 curSymbol = symb115 if symb != nil && firstSymbolPC == -1 {116 firstSymbolPC = i117 }118 }119 if curSymbol != nil {120 *selectPCs(&curSymbol.ObjectUnit, pcType) = pcs[firstSymbolPC:]121 }122 }123 // Assign compile units to symbols based on unit pc ranges.124 // Do it one pass as both are sorted.125 nsymbol := 0126 rangeIndex := 0127 for _, s := range symbols {128 for ; rangeIndex < len(ranges) && ranges[rangeIndex].end <= s.Start; rangeIndex++ {129 }130 if rangeIndex == len(ranges) || s.Start < ranges[rangeIndex].start || len(s.PCs) == 0 {131 continue // drop the symbol132 }133 unit := ranges[rangeIndex].unit134 s.Unit = unit135 symbols[nsymbol] = s136 nsymbol++137 }138 symbols = symbols[:nsymbol]139 for pcType := range coverPoints {140 for _, s := range symbols {141 symbPCs := selectPCs(&s.ObjectUnit, pcType)142 unitPCs := selectPCs(&s.Unit.ObjectUnit, pcType)143 pos := len(*unitPCs)144 *unitPCs = append(*unitPCs, *symbPCs...)145 *symbPCs = (*unitPCs)[pos:]146 }147 }148 return symbols149}150func readSymbols(file *elf.File) ([]*Symbol, uint64, uint64, map[uint64]bool, error) {151 text := file.Section(".text")152 if text == nil {153 return nil, 0, 0, nil, fmt.Errorf("no .text section in the object file")154 }155 allSymbols, err := file.Symbols()156 if err != nil {157 return nil, 0, 0, nil, fmt.Errorf("failed to read ELF symbols: %v", err)158 }159 traceCmp := make(map[uint64]bool)160 var tracePC uint64161 var symbols []*Symbol162 for _, symb := range allSymbols {163 if symb.Value < text.Addr || symb.Value+symb.Size > text.Addr+text.Size {164 continue165 }166 symbols = append(symbols, &Symbol{167 ObjectUnit: ObjectUnit{168 Name: symb.Name,169 },170 Start: symb.Value,171 End: symb.Value + symb.Size,172 })173 if strings.HasPrefix(symb.Name, "__sanitizer_cov_trace_") {174 if symb.Name == "__sanitizer_cov_trace_pc" {175 tracePC = symb.Value176 } else {177 traceCmp[symb.Value] = true178 }179 }180 }181 if tracePC == 0 {182 return nil, 0, 0, nil, fmt.Errorf("no __sanitizer_cov_trace_pc symbol in the object file")183 }184 sort.Slice(symbols, func(i, j int) bool {185 return symbols[i].Start < symbols[j].Start186 })187 return symbols, text.Addr, tracePC, traceCmp, nil188}189func readTextRanges(file *elf.File) ([]pcRange, []*CompileUnit, error) {190 text := file.Section(".text")191 if text == nil {192 return nil, nil, fmt.Errorf("no .text section in the object file")193 }194 kaslr := file.Section(".rela.text") != nil195 debugInfo, err := file.DWARF()196 if err != nil {197 return nil, nil, fmt.Errorf("failed to parse DWARF: %v (set CONFIG_DEBUG_INFO=y?)", err)198 }199 var ranges []pcRange200 var units []*CompileUnit201 for r := debugInfo.Reader(); ; {202 ent, err := r.Next()203 if err != nil {204 return nil, nil, err205 }206 if ent == nil {207 break208 }209 if ent.Tag != dwarf.TagCompileUnit {210 return nil, nil, fmt.Errorf("found unexpected tag %v on top level", ent.Tag)211 }212 attrName := ent.Val(dwarf.AttrName)213 if attrName == nil {214 continue215 }216 unit := &CompileUnit{217 ObjectUnit: ObjectUnit{218 Name: attrName.(string),219 },220 }221 units = append(units, unit)222 ranges1, err := debugInfo.Ranges(ent)223 if err != nil {224 return nil, nil, err225 }226 for _, r := range ranges1 {227 if r[0] >= r[1] || r[0] < text.Addr || r[1] > text.Addr+text.Size {228 if kaslr {229 // Linux kernel binaries with CONFIG_RANDOMIZE_BASE=y are strange.230 // .text starts at 0xffffffff81000000 and symbols point there as well,231 // but PC ranges point to addresses around 0.232 // So try to add text offset and retry the check.233 // It's unclear if we also need some offset on top of text.Addr,234 // it gives approximately correct addresses, but not necessary precisely235 // correct addresses.236 r[0] += text.Addr237 r[1] += text.Addr238 if r[0] >= r[1] || r[0] < text.Addr || r[1] > text.Addr+text.Size {239 continue240 }241 }242 }243 ranges = append(ranges, pcRange{r[0], r[1], unit})244 }245 r.SkipChildren()246 }247 sort.Slice(ranges, func(i, j int) bool {248 return ranges[i].start < ranges[j].start249 })250 return ranges, units, nil251}252func symbolize(target *targets.Target, objDir, srcDir, buildDir, obj string, pcs []uint64) ([]Frame, error) {253 procs := runtime.GOMAXPROCS(0) / 2254 if need := len(pcs) / 1000; procs > need {255 procs = need256 }257 const (258 minProcs = 1259 maxProcs = 4260 )261 // addr2line on a beefy vmlinux takes up to 1.6GB of RAM, so don't create too many of them.262 if procs > maxProcs {263 procs = maxProcs264 }265 if procs < minProcs {266 procs = minProcs267 }268 type symbolizerResult struct {269 frames []symbolizer.Frame270 err error271 }272 symbolizerC := make(chan symbolizerResult, procs)273 pcchan := make(chan []uint64, procs)274 for p := 0; p < procs; p++ {275 go func() {276 symb := symbolizer.NewSymbolizer(target)277 defer symb.Close()278 var res symbolizerResult279 for pcs := range pcchan {280 frames, err := symb.SymbolizeArray(obj, pcs)281 if err != nil {282 res.err = fmt.Errorf("failed to symbolize: %v", err)283 }284 res.frames = append(res.frames, frames...)285 }286 symbolizerC <- res287 }()288 }289 for i := 0; i < len(pcs); {290 end := i + 100291 if end > len(pcs) {292 end = len(pcs)293 }294 pcchan <- pcs[i:end]295 i = end296 }297 close(pcchan)298 var err0 error299 var frames []Frame300 for p := 0; p < procs; p++ {301 res := <-symbolizerC302 if res.err != nil {303 err0 = res.err304 }305 for _, frame := range res.frames {306 name, path := cleanPath(frame.File, objDir, srcDir, buildDir)307 frames = append(frames, Frame{308 PC: frame.PC,309 Name: name,310 Path: path,311 Range: Range{312 StartLine: frame.Line,313 StartCol: 0,314 EndLine: frame.Line,315 EndCol: LineEnd,316 },317 })318 }319 }320 if err0 != nil {321 return nil, err0322 }323 return frames, nil324}325// readCoverPoints finds all coverage points (calls of __sanitizer_cov_trace_pc) in the object file.326// Currently it is amd64-specific: looks for e8 opcode and correct offset.327// Running objdump on the whole object file is too slow.328func readCoverPoints(file *elf.File, tracePC uint64, traceCmp map[uint64]bool) ([2][]uint64, error) {329 var pcs [2][]uint64330 text := file.Section(".text")331 if text == nil {332 return pcs, fmt.Errorf("no .text section in the object file")333 }334 data, err := text.Data()335 if err != nil {336 return pcs, fmt.Errorf("failed to read .text: %v", err)337 }338 const callLen = 5339 end := len(data) - callLen + 1340 for i := 0; i < end; i++ {341 pos := bytes.IndexByte(data[i:end], 0xe8)342 if pos == -1 {343 break344 }345 pos += i346 i = pos347 off := uint64(int64(int32(binary.LittleEndian.Uint32(data[pos+1:]))))348 pc := text.Addr + uint64(pos)349 target := pc + off + callLen350 if target == tracePC {351 pcs[0] = append(pcs[0], pc)352 } else if traceCmp[target] {353 pcs[1] = append(pcs[1], pc)354 }355 }356 return pcs, nil357}358// objdump is an old, slow way of finding coverage points.359// amd64 uses faster option of parsing binary directly (readCoverPoints).360// TODO: use the faster approach for all other arches and drop this.361func objdump(target *targets.Target, obj string) ([2][]uint64, error) {362 var pcs [2][]uint64363 cmd := osutil.Command(target.Objdump, "-d", "--no-show-raw-insn", obj)364 stdout, err := cmd.StdoutPipe()365 if err != nil {366 return pcs, err367 }368 defer stdout.Close()369 stderr, err := cmd.StderrPipe()370 if err != nil {371 return pcs, err372 }373 defer stderr.Close()374 if err := cmd.Start(); err != nil {375 return pcs, fmt.Errorf("failed to run objdump on %v: %v", obj, err)376 }377 defer func() {378 cmd.Process.Kill()379 cmd.Wait()380 }()381 s := bufio.NewScanner(stdout)382 callInsns, traceFuncs := archCallInsn(target)383 for s.Scan() {384 if pc := parseLine(callInsns, traceFuncs, s.Bytes()); pc != 0 {385 pcs[0] = append(pcs[0], pc)386 }387 }388 stderrOut, _ := ioutil.ReadAll(stderr)389 if err := cmd.Wait(); err != nil {390 return pcs, fmt.Errorf("failed to run objdump on %v: %v\n%s", obj, err, stderrOut)391 }392 if err := s.Err(); err != nil {393 return pcs, fmt.Errorf("failed to run objdump on %v: %v\n%s", obj, err, stderrOut)394 }395 return pcs, nil396}397func parseLine(callInsns, traceFuncs [][]byte, ln []byte) uint64 {398 pos := -1399 for _, callInsn := range callInsns {400 if pos = bytes.Index(ln, callInsn); pos != -1 {401 break402 }403 }404 if pos == -1 {405 return 0406 }407 hasCall := false...

Full Screen

Full Screen

objdump

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 out, err := exec.Command("objdump", "-d", "1").Output()4 if err != nil {5 fmt.Printf("%s", err)6 }7 fmt.Printf("%s", out)8}9import (10func main() {11 out, err := exec.Command("objdump", "-d", "2").Output()12 if err != nil {13 fmt.Printf("%s", err)14 }15 fmt.Printf("%s", out)16}17import (18func main() {19 out, err := exec.Command("objdump", "-d", "3").Output()20 if err != nil {21 fmt.Printf("%s", err)22 }23 fmt.Printf("%s", out)24}25import (26func main() {27 out, err := exec.Command("objdump", "-d", "4").Output()28 if err != nil {29 fmt.Printf("%s", err)30 }31 fmt.Printf("%s", out)32}33import (34func main() {35 out, err := exec.Command("objdump", "-d", "5").Output()36 if err != nil {37 fmt.Printf("%s", err)38 }39 fmt.Printf("%s", out)40}41import (42func main() {43 out, err := exec.Command("objdump", "-d", "6").Output()44 if err != nil {45 fmt.Printf("%s", err)46 }47 fmt.Printf("%s", out)48}49import (

Full Screen

Full Screen

objdump

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 cmd := exec.Command("objdump", "-d", "-M", "intel", "-j", ".text", "hello")4 out, err := cmd.Output()5 if err != nil {6 fmt.Println(err)7 os.Exit(1)8 }9 fmt.Println(string(out))10}11import (12func main() {13 cmd := exec.Command("objdump", "-d", "-M", "intel", "-j", ".text", "hello")14 out, err := cmd.Output()15 if err != nil {16 fmt.Println(err)17 os.Exit(1)18 }19 fmt.Println(string(out))20}21import (22func main() {23 cmd := exec.Command("objdump", "-d", "-M", "intel", "-j", ".text", "hello")24 out, err := cmd.Output()25 if err != nil {26 fmt.Println(err)27 os.Exit(1)28 }29 fmt.Println(string(out))30}31import (32func main() {33 cmd := exec.Command("objdump", "-d", "-M", "intel", "-j", ".text", "hello")34 out, err := cmd.Output()35 if err != nil {36 fmt.Println(err)37 os.Exit(1)38 }39 fmt.Println(string(out))40}41import (42func main() {43 cmd := exec.Command("objdump", "-d", "-M", "intel", "-j", ".text", "hello")44 out, err := cmd.Output()45 if err != nil {

Full Screen

Full Screen

objdump

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Hello World")4}5TEXT main.main(SB) /home/ashish/Downloads/2.go6 2.go:9 0x1040e09 483b6110 CMPQ 0x10(CX), SP7 2.go:9 0x1040e13 48896c2420 MOVQ BP, 0x20(SP)8 2.go:9 0x1040e18 488d6c2420 LEAQ 0x20(SP), BP9 2.go:10 0x1040e1d 488d05b4c8ff LEAQ go.string."Hello World"(SB), AX10 2.go:10 0x1040e24 4889442408 MOVQ AX, 0x8(SP)11 2.go:10 0x1040e29 488d05e5c8ff LEAQ go.string."%s" + 0(SB), AX12 2.go:10 0x1040e30 4889442410 MOVQ AX, 0x10(SP)13 2.go:10 0x1040e35 488d7c2410 LEAQ 0x10(SP), DI14 2.go:10 0x1040e3a e8d3fdffff CALL fmt.Printf(SB)

Full Screen

Full Screen

objdump

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 if len(os.Args) < 2 {4 fmt.Println("Usage: 2.exe <file>")5 }6 cmd := exec.Command("objdump", "-d", os.Args[1])7 cmd.Run()8}9import (10func main() {11 if len(os.Args) < 2 {12 fmt.Println("Usage: 3.exe <file>")13 }14 cmd := exec.Command("objdump", "-d", os.Args[1])15 cmd.Run()16}17import (18func main() {19 if len(os.Args) < 2 {20 fmt.Println("Usage: 4.exe <file>")21 }22 cmd := exec.Command("objdump", "-d", os.Args[1])23 cmd.Run()24}25import (26func main() {27 if len(os.Args) < 2 {28 fmt.Println("Usage: 5.exe <file>")29 }30 cmd := exec.Command("objdump", "-d", os.Args[1])31 cmd.Run()32}33import (34func main()

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful