1

I have this little C program in the file test.c :

int main(){

    int a = 10;
    a++;

}

I've compiled this program on both macOS ( x86_64 ) and Ubuntu. On macOS I've used "clang test.c -o test" and on Ubuntu I've used "gcc test.c -o test".

When I inspect the file in macOS with "otool -tV test" I get :

(__TEXT,__text) section
_main:
0000000100003fa0        pushq   %rbp
0000000100003fa1        movq    %rsp, %rbp
0000000100003fa4        movl    $0xa, -0x4(%rbp)
0000000100003fab        movl    -0x4(%rbp), %eax
0000000100003fae        addl    $0x1, %eax
0000000100003fb1        movl    %eax, -0x4(%rbp)
0000000100003fb4        xorl    %eax, %eax
0000000100003fb6        popq    %rbp
0000000100003fb7        retq

When I inspect the executable in Ubuntu with "objdump -dw test" I get :

0000000000001129 <main>:
    1129:   f3 0f 1e fa             endbr64 
    112d:   55                      push   %rbp
    112e:   48 89 e5                mov    %rsp,%rbp
    1131:   c7 45 fc 0a 00 00 00    movl   $0xa,-0x4(%rbp)
    1138:   83 45 fc 01             addl   $0x1,-0x4(%rbp)
    113c:   b8 00 00 00 00          mov    $0x0,%eax
    1141:   5d                      pop    %rbp
    1142:   c3                      ret  

Now, If you take for example the first push assembly instruction in objdump it is indicated as "push" but with otool it is "pushq".

My question :

Is there an option for objdump to explicitly display these size operands as otool does ?

alessio solari
  • 313
  • 1
  • 6
  • 1
    One-character is added to mnemonic that specifies the size of the instruction operands. `b = Byte (8–bit)`, `w = Word (16–bit)`, `l = Long (32–bit)`, `q = Quadword (64–bit)`. If there is no letter added, well, register used tells You the size. – Nassau Aug 21 '23 at 17:15
  • 1
    https://stackoverflow.com/questions/68630162/make-objdump-use-an-operand-size-suffix-like-l-on-every-mnemonic-even-when-its – Nassau Aug 21 '23 at 17:23

0 Answers0