Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The following answer applies to x86 64bit assembler.</p> <p>Short answer: x86 does not have %s as some kind of assembler instruction, that is pure c and even java nowadays aswell. </p> <p>Long answer:</p> <ul> <li><p>Compile your program with symbols (non stripped): <code>gcc -g yourprogram.c</code></p></li> <li><p>Dump the assembly with intermixed c-code: <code>objdump -S yourProgram.o</code></p></li> </ul> <p>The following text shows how <code>strcpy</code> and <code>printf</code> is shown in assembly. I have also added how you should read the assembly:</p> <pre><code>strcpy(buf, argv[1]); 4005eb: 48 8b 85 60 ff ff ff mov -0xa0(%rbp),%rax Move argv[0] to %rax register 4005f2: 48 83 c0 08 add $0x8,%rax Add 8 to %rax which means we now store argv[1] 4005f6: 48 8b 10 mov (%rax),%rdx Copy argv[1] to the destination register %rdx 4005f9: 48 8d 85 70 ff ff ff lea -0x90(%rbp),%rax Move buf to %rax 400600: 48 89 d6 mov %rdx,%rsi Move argv[1] to %esi which is the source register implicitly used by string funcs 400603: 48 89 c7 mov %rax,%rdi Move buf to destination register 400606: e8 85 fe ff ff callq 400490 &lt;strcpy@plt&gt; Call strcpy which uses %rsi and %rdi Now we have argv[1] in buf, right!? printf("%s\n", buf); 40060b: 48 8d 85 70 ff ff ff lea -0x90(%rbp),%rax The first line loads what you have at the base pointer -0x90 to the %rax register which means that it loads the address of buf into rax as buf is on the stack. 400612: 48 89 c7 mov %rax,%rdi Just mov it to the %rdi register. 400615: e8 86 fe ff ff callq 4004a0 &lt;puts@plt&gt; Call the puts function with buf </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload