gnu-misc-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C/C++ statements and assembly mixed listing


From: Miles Bader
Subject: Re: C/C++ statements and assembly mixed listing
Date: Sun, 12 Mar 2006 09:06:39 +0900

"Allan" <address@hidden> writes:
> As everyone knows, gcc -S file.c will generate file.s. Is it possible
> to generate a file which has C statements followed by their assemblies.

You can do it using "objdump":

   $ objdump --help
   Usage: objdump <option(s)> <file(s)>
     ...
     -d, --disassemble        Display assembler contents of executable sections
     -D, --disassemble-all    Display assembler contents of all sections
     -S, --source             Intermix source code with disassembly

This relies on debugging info, so you should make sure your compile
commands are using the -g option.  The output is somewhat confused if
higher optimization levels were used, but that's pretty much unavoidable
for this sort of mixed listing....

-Miles
-- 
My spirit felt washed.  With blood.  [Eli Shin, on "The Passion of the Christ"]


reply via email to

[Prev in Thread] Current Thread [Next in Thread]