Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

objdump from inside emacs

Assuming I have my working folder as ~/X/ and the binaries after compiling are in ~/X/bin/ I usually first get the objdump like so:

objdump -D ~/X/bin/bin1 > bin1.list

then emacs bin1.list&

How is it possible to assign a function in .emacs to open a temporary buffer in Emacs and execute objdump -D in on the binary in it directly?

like image 248
SFbay007 Avatar asked May 13 '26 03:05

SFbay007


1 Answers

Sure, by default the command M-! (shell-command) outputs shell output to a default output buffer.

M-! objdump -D /bin/ls

If you want to change the name of the output buffer, you can invoke shell-command through some elisp:

(shell-command "objdump -D /bin/ls" "ls.dump")

or

C-x C-w (write-file) - to write the shell output buffer to a file

Edit:

Example which grabs file at point if available, or prompts the user

(defun my-objdump-file (&optional file)
  (interactive)
  (unless file 
    (setq file (expand-file-name (or (thing-at-point 'filename)
                     (read-file-name "File: ")))))
  (when file
    (shell-command (concat "objdump -D "
               file)
           "*Objdump Output*")))
like image 176
assem Avatar answered May 16 '26 10:05

assem



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!