0

I have written one kernel module, I want to generate assembly code i.e *.s file.

Till now I am able to generate .s file from object file by using objdump but it's not providing me proper assembly code. Can anyone please help me with this.

Sagar
  • 2,315
  • 7
  • 25
  • 34

1 Answers1

1

You have to use -S option for generating an assembly code, also I would suggest to disable any optimization with -O0 option (if you need it) , if you want to see optimized assmbly code, just add -S

More info about gcc options you may find here

Laser
  • 6,652
  • 8
  • 54
  • 85
  • 1
    Depends why you want to look at the asm. If you want to see whether the compiler did a good job, you should use `-O3` (actually, use exactly the same options that you use to build a `.o`, but with `-S` instead of `-c`). Looking at un-optimized asm output is rarely useful. See also [how to remove noise from gcc output](http://stackoverflow.com/questions/38552116/how-to-remove-noise-from-gcc-clang-assembly-output). I like `gcc -O3 -masm=intel -fverbose-asm -S -o- | less`. Although for kernel code, you probably need to avoid `-masm=intel` due to inline-asm assuming AT&T. – Peter Cordes Nov 25 '16 at 03:30