Search code examples
terminalgnuobjdump

Is there a way to format objdump output?


Examining some binary files with objdump (i'm on a mac, but installed binutils).

Is there a way to align the columns so there is no column overflow? Posted some example output below to illustrate the current state of things.

I don't want to send this to a text file and then auto edit everything. Is there a way to adjust the current terminal formatting.

objdump -D first | grep -A10 main:
_main:
100000f30:  55  pushq   %rbp
100000f31:  48 89 e5    movq    %rsp, %rbp
100000f34:  48 83 ec 20     subq    $32, %rsp
100000f38:  c7 45 fc 00 00 00 00    movl    $0, -4(%rbp)
100000f3f:  89 7d f8    movl    %edi, -8(%rbp)
100000f42:  48 89 75 f0     movq    %rsi, -16(%rbp)
100000f46:  c7 45 ec 00 00 00 00    movl    $0, -20(%rbp)
100000f4d:  83 7d ec 0a     cmpl    $10, -20(%rbp)
100000f51:  0f 8d 1f 00 00 00   jge 31 <_main+0x46>
100000f57:  48 8d 3d 40 00 00 00    leaq    64(%rip), %rdi

Solution

  • Use gobjdump to access the binutils installed on mac. That uses an autoformatted output