recently i wanted to know the assembly of each functions in a program
this is how i did it.
$ gcc main.c // main.c source file
$ gdb a.exe // gdb a.out in linux
(gdb) disass main // note here main is a function
// similary it can be done for other functions
Here the first part stores the assembly output of the program in the same file name as Program but with a changed .s extension, you can open it as any normal text file.
The second part here compiles your program for actual usage and generates an executable for your Program with a specified file name.
The program.c used above is the name of your program and output is the name of the executable you want to generate.
I ran G++ from a DOS window on Win-XP, against a routine that contains an implicit cast
c:\gpp_code>g++ -g -O -Wa,-aslh horton_ex2_05.cpp >list.txt
horton_ex2_05.cpp: In function `int main()':
horton_ex2_05.cpp:92: warning: assignment to `int' from `double'
The output is asssembled generated code iterspersed with the original C++ code (the C++ code is shown as comments in the generated asm stream)
Use "-S" as an option. It displays the assembly output in the terminal.
recently i wanted to know the assembly of each functions in a program
this is how i did it.
Here is a solution for C using gcc :
Here the first part stores the assembly output of the program in the same file name as Program but with a changed .s extension, you can open it as any normal text file.
The second part here compiles your program for actual usage and generates an executable for your Program with a specified file name.
The program.c used above is the name of your program and output is the name of the executable you want to generate.
BTW It's my First post on StackOverFlow :-}
The following command line is from Christian Garbin's blog
I ran G++ from a DOS window on Win-XP, against a routine that contains an implicit cast
The output is asssembled generated code iterspersed with the original C++ code (the C++ code is shown as comments in the generated asm stream)