title: jmp on x64 assembly
body: <p>The asm code below was generated using <code>gcc -O4 ..</code> on x64 osx which optimised it (please have a look at gcc manual for more information on <code>-O4</code>).</p>
  
  <pre><code>(gdb) disas main
  Dump of assembler code for function main:
     0x0000000100000f50 &lt;+0&gt;: push   rbp
     0x0000000100000f51 &lt;+1&gt;: mov    rbp,rsp
     0x0000000100000f54 &lt;+4&gt;: lea    rdi,[rip+0x2f]    # 0x100000f8a
     0x0000000100000f5b &lt;+11&gt;:    lea    rsi,[rip+0x2b]    # 0x100000f8d
     0x0000000100000f62 &lt;+18&gt;:    xor    eax,eax
     0x0000000100000f64 &lt;+20&gt;:    pop    rbp
     0x0000000100000f65 &lt;+21&gt;:    jmp    0x100000f6a
  </code></pre>
  
  <p>I am trying to understand the flow of the code at line main+21 and onwards. I tried the following but could not find out how to see the code at <code>0x100000f6a</code> (and onwards):</p>
  
  <pre><code>(gdb) disas 0x100000f6a
  No function contains specified address.
  (gdb) x/8 0x100000f6a
  0x100000f6a:    0x00a025ff  0x8d4c0000  0x0000911d  0xff534100
  0x100000f7a:    0x00008125  0x00689000  0xe9000000  0xffffffe6
  </code></pre>
  
  <p>So, as I understand, the code at main+21 makes a jump to address <code>0x100000f6a</code>. But, how do I see what's in <code>0x100000f6a</code> and beyond? I know that for this exercise that it's a <code>JMP</code> to <code>printf</code> function. I would like to see the entire function (if possible).</p>
  
  <p>Same code on x86 linux (yes <code>gcc -O4 ..</code> as well) gets relocated? correctly:</p>
  
  <pre><code>(gdb) disas main
  Dump of assembler code for function main:
    0x08048350 &lt;+0&gt;:  push   ebp
    0x08048351 &lt;+1&gt;:  mov    ebp,esp
    0x08048353 &lt;+3&gt;:  and    esp,0xfffffff0
    0x08048356 &lt;+6&gt;:  sub    esp,0x10
    0x08048359 &lt;+9&gt;:  mov    DWORD PTR [esp+0x8],0x8048500
    0x08048361 &lt;+17&gt;: mov    DWORD PTR [esp+0x4],0x8048506
    0x08048369 &lt;+25&gt;: mov    DWORD PTR [esp],0x1
    0x08048370 &lt;+32&gt;: call   0x8048340 &lt;__printf_chk@plt&gt;
    0x08048375 &lt;+37&gt;: leave
    0x08048376 &lt;+38&gt;: ret
  End of assembler dump.
  (gdb) x/32 0x8048340
  0x8048340 &lt;__printf_chk@plt&gt;:   -1610078721 275253252   -385875968  -64
  0x8048350 &lt;main&gt;:   -2082109099 -326897436  608487184   75825160
  0x8048360 &lt;main+16&gt;:    608487176   75826692    604292872   1
  0x8048370 &lt;main+32&gt;:    -13336  -1866216961 -1990267599 -253459487
  0x8048380 &lt;_start+8&gt;:   1750226000  134513824   75772008    1750487304
  0x8048390 &lt;_start+24&gt;:  134513488   -26648  -1869548289 -1869574000
  0x80483a0 &lt;__do_global_dtors_aux&gt;:  1407551829  -2147160957 77599805    1064632328
  0x80483b0 &lt;__do_global_dtors_aux+16&gt;:   77600929    -1625244920 -343865340  134520604
  </code></pre>