Disasm returns the assembly instructions for the specified address range of a binary.
(file string, start, end uint64, intelSyntax bool)
| 257 | // Disasm returns the assembly instructions for the specified address range |
| 258 | // of a binary. |
| 259 | func (bu *Binutils) Disasm(file string, start, end uint64, intelSyntax bool) ([]plugin.Inst, error) { |
| 260 | b := bu.get() |
| 261 | if !b.objdumpFound { |
| 262 | return nil, errors.New("cannot disasm: no objdump tool available") |
| 263 | } |
| 264 | args := []string{"--disassemble", "--demangle", "--no-show-raw-insn", |
| 265 | "--line-numbers", fmt.Sprintf("--start-address=%#x", start), |
| 266 | fmt.Sprintf("--stop-address=%#x", end)} |
| 267 | |
| 268 | if intelSyntax { |
| 269 | if b.isLLVMObjdump { |
| 270 | args = append(args, "--x86-asm-syntax=intel") |
| 271 | } else { |
| 272 | args = append(args, "-M", "intel") |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | args = append(args, file) |
| 277 | cmd := exec.Command(b.objdump, args...) |
| 278 | out, err := cmd.Output() |
| 279 | if err != nil { |
| 280 | return nil, fmt.Errorf("%v: %v", cmd.Args, err) |
| 281 | } |
| 282 | |
| 283 | return disassemble(out) |
| 284 | } |
| 285 | |
| 286 | // Open satisfies the plugin.ObjTool interface. |
| 287 | func (bu *Binutils) Open(name string, start, limit, offset uint64, relocationSymbol string) (plugin.ObjFile, error) { |