You can run objdump with an option -S(e.g., "objdump -Sd a.out"). It will display the source code mixed with the assembler code if the source files from which the code was compiled are available.
Alternatively, you can use the following method:
int main(void) {
int a = 0;
asm("#");
return a;
}
becomes
.file "a.c"
.text
.globl main
.type main, @function
main:
leal 4(%esp), %ecx
andl $-16, %esp
pushl -4(%ecx)
pushl %ebp
movl %esp, %ebp
pushl %ecx
subl $16, %esp
movl $0, -8(%ebp)
movl -8(%ebp), %eax
addl $16, %esp
popl %ecx
popl %ebp
leal -4(%ecx), %esp
ret
.size main, .-main
.ident "GCC: (GNU) 4.3.2"
.section .note.GNU-stack,"",@progbits
source
share