0

I am using otool to produce machine code from a gcc compiled C++ file:

otool -tvV one.o

That works well, and produces the assembly as output:

(__TEXT,__text) section
__Z14addByReferenceiRi:
0000000000000000    pushq   %rbp
0000000000000001    movq    %rsp, %rbp
0000000000000004    movl    %edi, -0x4(%rbp)
0000000000000007    movq    %rsi, -0x10(%rbp)
000000000000000b    movl    -0x4(%rbp), %edi
000000000000000e    movq    -0x10(%rbp), %rsi
0000000000000012    addl    __Z14addByReferenceiRi(%rsi), %edi ## addByReference(int, int&)
0000000000000014    movl    %edi, __Z14addByReferenceiRi(%rsi) ## addByReference(int, int&)
0000000000000016    popq    %rbp
0000000000000017    retq
0000000000000018    nopl    __Z14addByReferenceiRi(%rax,%rax) ## addByReference(int, int&)
_main:
0000000000000020    pushq   %rbp
0000000000000021    movq    %rsp, %rbp
0000000000000024    subq    $0x10, %rsp
0000000000000028    movl    $0x5, %edi
000000000000002d    leaq    -0x8(%rbp), %rsi
0000000000000031    movl    $__Z14addByReferenceiRi, -0x4(%rbp) ## addByReference(int, int&)
0000000000000038    movl    $__Z14addByReferenceiRi, -0x8(%rbp) ## addByReference(int, int&)
000000000000003f    callq   __Z14addByReferenceiRi
0000000000000044    leaq    0x17(%rip), %rdi ## literal pool for: "Answer: %d\n"
000000000000004b    movl    -0x8(%rbp), %esi
000000000000004e    movb    $0x0, %al
0000000000000050    callq   _printf
0000000000000055    xorl    %esi, %esi

The code isn't related to the question other than for recognizing which assembly language is being produced from the file.

I cannot find what assembly language this is actually producing, after looking thoroughly at multiple google search attempts. So, I don't have a way to easily look up what these assembly commands are actually doing.

What assembly language is this and/or where is a reference for the assembly commands being produced?

ICW
  • 4,875
  • 5
  • 27
  • 33
  • looks like GNU assembler syntax: https://en.wikipedia.org/wiki/GNU_Assembler – UnholySheep Sep 14 '19 at 21:51
  • and specifically x86-64 (also called amd64 and a few other names) – SoronelHaetir Sep 14 '19 at 22:00
  • It is GNU Assembler's AT&T Syntax. Unfortunately `otool` doesn't display Intel Syntax, although you could always use `gobjdump`. – Michael Petch Sep 14 '19 at 22:13
  • 1
    It's important to note that it's not really producing *any* "assembly language". I mean that in the sense that you aren't going to be able to take `otool`'s output and feed it back into an assembler successfully. It's a disassembly dump for diagnostic purposes. – Ken Thomases Sep 14 '19 at 22:30

0 Answers0