From cdf889a53de7c08173c762fca0335821dc5b8c83 Mon Sep 17 00:00:00 2001 From: Alan Li <61896187+lebr0nli@users.noreply.github.com> Date: Thu, 27 Jul 2023 00:38:45 +0800 Subject: [PATCH] Add `--dwarf-start=0` option to remove the file path in the output (#205) * Add `--dwarf-start=0` option to remove the file path in output --- lib/one_gadget/fetchers/objdump.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/one_gadget/fetchers/objdump.rb b/lib/one_gadget/fetchers/objdump.rb index 5bd4308c..753823bb 100644 --- a/lib/one_gadget/fetchers/objdump.rb +++ b/lib/one_gadget/fetchers/objdump.rb @@ -31,7 +31,10 @@ def extra_options=(options) # @param [Integer] stop The end address. # @return [String] The CLI command to be executed. def command(start: nil, stop: nil) - cmd = [bin, '--no-show-raw-insn', '-w', '-d', *@options, @file] + # --dwarf-start=0 is to make sure `suppress_bfd_header` is true to eliminate the file path in the output, see + # issue #204 for more details. + # Note: We might need to update this when the objdump act differently in the future. + cmd = [bin, '--dwarf-start=0', '--no-show-raw-insn', '-w', '-d', *@options, @file] cmd.push('--start-address', start) if start cmd.push('--stop-address', stop) if stop ::Shellwords.join(cmd)