If you have a particular line of C code in mind to examine in the machine output, how would you locate it in objdump output. Here is an example
if (cond)
foo;
bar();
and I want to see if bar was inlined as I'd like. Or would you use some alternative tool instead of objdump?
You can start objdump using the -S
option (like "objdump -Sd a.out"
). It will display the sourcecode intermixxed with the assembler code, if the source-files the code was compiled from are available.
Alternatively, you can use the following way:
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)
#APP
# 3 "a.c" 1
#
# 0 "" 2
#NO_APP
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