Skip to content

Instantly share code, notes, and snippets.

@RichardBarrell
Created July 9, 2014 00:35
Show Gist options
  • Save RichardBarrell/9510198f1f8dcd466da9 to your computer and use it in GitHub Desktop.
Save RichardBarrell/9510198f1f8dcd466da9 to your computer and use it in GitHub Desktop.
Does calling a function defined like "foo()" differ from calling a function defined like "foo(void)"?
#include <stdio.h>
int foo(FOO_ARGS);
int main(int argc, char **argv) {
printf("%d!\n", foo());
return 0;
}
.file "main.c"
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
.string "%d!\n"
.section .text.startup,"ax",@progbits
.globl main
.type main, @function
main:
.LFB0:
.cfi_startproc
pushq %rax
.cfi_def_cfa_offset 16
xorl %eax, %eax
call foo
movl $.LC0, %edi
movl %eax, %esi
xorl %eax, %eax
call printf
xorl %eax, %eax
popq %rdx
.cfi_def_cfa_offset 8
ret
.cfi_endproc
.LFE0:
.size main, .-main
.ident "GCC: (GNU) 4.8.3 20140624 (Red Hat 4.8.3-1)"
.section .note.GNU-stack,"",@progbits
.file "main.c"
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
.string "%d!\n"
.section .text.startup,"ax",@progbits
.globl main
.type main, @function
main:
.LFB0:
.cfi_startproc
pushq %rax
.cfi_def_cfa_offset 16
call foo
movl $.LC0, %edi
movl %eax, %esi
xorl %eax, %eax
call printf
xorl %eax, %eax
popq %rdx
.cfi_def_cfa_offset 8
ret
.cfi_endproc
.LFE0:
.size main, .-main
.ident "GCC: (GNU) 4.8.3 20140624 (Red Hat 4.8.3-1)"
.section .note.GNU-stack,"",@progbits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment