Search notes:

gcc -Qn

By default, gcc writes the compiler version to an object file's .comment section:
$ echo 'void f() {}' | gcc     -xc -c -o f.obj -
$ readelf -p .comment f.obj

String dump of section '.comment':
  [     1]  GCC: (Debian 10.2.1-6) 10.2.1 20210110
With -Qn, such a section is not written.
$ echo 'void f() {}' | gcc -Qn -xc -c -o f.obj -
$ readelf -p .comment f.obj
readelf: Warning: Section '.comment' was not dumped because it does not exist!

Index