I am trying to view the assembly for my simple C application. So, I have tried to produce assembly from binary by using objdump
and it produces about 4.3MB sized file with 103228 lines of assembly code. Then, I have tried to do so by providing -S
& -save-temps
flags to the gcc
.
I have used the following three commands:
1. arm-linux-gnueabi-objdump -d hello_simple > hello_simple.dump
2. arm-linux-gnueabi-gcc -save-temps -static hello_simple.c -o hello_simple -lm
3. arm-linux-gnueabi-gcc -S -static hello_simple.c -o hello_simple.asm -lm
In case of 2 & 3, exactly same results are produced, i.e., 65 lines of assembly code. I understand objdump
produces some extra details too.
But, why is there a huge difference?
EDIT1: I have used the following command to build that binary:
arm-linux-gnueabi-gcc -static hello_simple.c -o hello_simple -lm
EDIT2: Though, -static
and -lm
flags may look here unnecessary but, I have to execute this binary on simulator after compile time additions of some assembly components, making them a must.
So, which assembly code should I consider as the most relevant during my analysis of execution traces? (I know it's another question but it would be handy to cover it in the same answer.)
-static
linkage for your program, it will also containlibc
and other libraries linked into executable. Those will be dumped withobjdump
as well. – Alex Skalozub-static -lm
have no effect on command 3. They obviously do make a difference for the other commands, since those do produce binaries. – Peter Cordes