Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In 64-bit mode you cannot push and pop 32-bit values; you need <code>pushq</code> and <code>popq</code>.</p> <p>Also, you will not get a proper exit this way. On 32-bit x86, you would need to set <code>%eax</code> to 1 to select the <code>exit()</code> system call, <em>and</em> set <code>%ebx</code> to the exit code you actually wish. On 64-bit x86 (that's what you are using), conventions are different: the system call number for <code>exit()</code> is 60, not 1; the first system call parameter goes in <code>%rdi</code>, not <code>%rbx</code>; the system-call invocation opcode is not <code>int $0x80</code> but the special, x86-64-only opcode <code>syscall</code>.</p> <p>Which leads to:</p> <pre><code>.section .data .section .text .globl _start _start: pushq $60 popq %rax pushq $1 popq %rdi syscall </code></pre> <p>(each <code>push</code>/<code>pop</code> sequence can be replaced with a simple <code>mov</code> (like <code>mov $60, %eax</code>) of course; I suppose that you are trying to explicitly test <code>push</code> and <code>pop</code>, optimize for code-size, or avoid <code>0</code> bytes in the machine code (for an exploit payload))</p> <hr> <p>Related: </p> <ul> <li><a href="https://stackoverflow.com/questions/2535989/what-are-the-calling-conventions-for-unix-linux-system-calls-on-x86-64">What are the calling conventions for UNIX &amp; Linux system calls on i386 and x86-64</a></li> <li><a href="https://stackoverflow.com/questions/46087730/what-happens-if-you-use-the-32-bit-int-0x80-linux-abi-in-64-bit-code">What happens if you use the 32-bit int 0x80 Linux ABI in 64-bit code?</a></li> </ul>
 

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