2

I'm using gcc -save-temps to generate assembly and I added -fverbose-asm but that option does NOT generate what I want; it's some weird debug-ish comments.

To get the assembly + inline source, I'm doing gcc -g followed by objdump -S.

Since -save-temps generates the assembly anyway, is there a way to configure it to output the inline source that objdump -S produces?

Bob
  • 4,576
  • 7
  • 39
  • 107
  • 1
    Try `gcc -S` as indicated in the man page. Note that there is no option to get output similar to `objdump -S`, perhaps you can request that feature. – fuz Sep 15 '17 at 19:46
  • Are you just trying to save a step and simplify here, or are you hoping to be able to get `gcc -fverbose-asm -S` output mixed with source? Note that you can get a very similar effect from the Godbolt compiler explorer's colour highlighting of source + asm lines. For example, https://godbolt.org/g/SQDMJq. Related https://stackoverflow.com/questions/38552116/how-to-remove-noise-from-gcc-clang-assembly-output – Peter Cordes Sep 15 '17 at 23:54
  • I used `-S -fverbose-asm` but it wasn't the same as `objump-S`. I guess it'll have to be two steps. – Bob Sep 17 '17 at 22:17
  • @fuz sounds like that's the answer. Please put it as the answer. – Bob Sep 17 '17 at 22:18

1 Answers1

4

The GNU C compiler (gcc) produces assembly output if you specify the option -S during compilation. Note that this output is not like the output of objdump -S in the source code is not interspersed with the assembly. To get such output, there is currently no way around creating an object file and then disassembling it. Consider filing a bug report if you would like to have such a feature.

fuz
  • 88,405
  • 25
  • 200
  • 352