1

For example:

$ gcc -O3 foobar.c -o foobar
$ grep 'foobar\.c' foobar
Binary file foobar matches

How can I exclude such unnecessary and revealing metadata from the output of gcc and other compilers? It appears regardless of whether the output is an assembly file, object file, or executable.

Matt
  • 21,026
  • 18
  • 63
  • 115

1 Answers1

3

man strip(1)

> strip -s a.out
Severin Pappadeux
  • 18,636
  • 3
  • 38
  • 64
  • Can an I `strip` an object file and still be able to link it after? I didn't really intend to strip actual function labels. – Matt Feb 07 '15 at 03:57
  • 1
    @Matt Yes, I believe so. `strip --strip-debug aaa.o` shall remove debug info but leave function labels intact. You might check symbols in .o using `nm` or `readelf` utility. Also for shared objects you might want to check `--strip-unneeded` option – Severin Pappadeux Feb 07 '15 at 04:07