[CentOS] Force to strip all symbols from ELFs when using rpmbuild on CentOS

Sun Jun 9 20:03:40 UTC 2013
Santi Saez <santi at woop.es>

Hello.

What's the proper way to remove *all symbols* from ELF binaries when 
building packages with rpmbuild on CentOS? Seems that an out of the box 
rpmbuild install only discards debugging symbols (strip -g).

That's the default configuration for %__os_install_post on CentOS, the 
step in charge on stripping binaries:

     $ rpmbuild --showrc
     (..)
     -14: __os_install_post
         %{_rpmconfigdir}/brp-compress
         %{_rpmconfigdir}/brp-strip
         %{_rpmconfigdir}/brp-strip-static-archive
         %{_rpmconfigdir}/brp-strip-comment-note

ELF binaries are stripped with /usr/lib/rpm/brp-strip, this script 
explicitly calls to /usr/bin/strip with "-g" flag and discards only 
debugging symbols.

Seems that the people usually installs "redhat-rpm-config" package to 
achieve this. Indeed it builds RPMs with all symbols removed, but it 
also installs some helper scripts and macros that change other 
behaviors, for example SRPMs are signed with SHA-256.

When "redhat-rpm-config" package is installed, %__os_install_post 
variable is modified and find-debuginfo.sh is executed, this script will 
remove all symbols, but it will *also* build "-debug" packages, and 
that's not what I'm looking for.

For the moment, I have have added another script to %__os_install_post 
step that removes all symbols using "strip --strip-all", but I wonder if 
this is the most straightforward method, thanks.

Santi Saez