Skip to content

Instantly share code, notes, and snippets.

@simark
Created July 28, 2017 22:06
Show Gist options
  • Save simark/25e23c91a2332009982ca54fa9b2bc4d to your computer and use it in GitHub Desktop.
Save simark/25e23c91a2332009982ca54fa9b2bc4d to your computer and use it in GitHub Desktop.
.extern bar
.text
.globl foo
.type foo, @function
foo:
.cfi_startproc
xor %rsp, (%rsp)
// exp RA len const -8 plus dup deref xor
.cfi_escape 0x16, 0x10, 0x06, 0x09, 0xf8, 0x22, 0x12, 0x06, 0x27
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
movl %edi, -4(%rbp)
call bar
movl -4(%rbp), %eax
addl %eax, %eax
popq %rbp
.cfi_def_cfa 7, 8
xor %rsp, (%rsp)
ret
.cfi_endproc
#include <stdio.h>
int foo(int);
void bar(void)
{
printf("Hi!\n");
}
int main ()
{
return foo (4);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment