top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

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

0 votes
1,024 views

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.

posted Jun 9, 2013 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

You can avoid generating "-debug" packages with: %define debug_package %{nil}

answer Jun 9, 2013 by anonymous
If %__debug_packageis not defined %__debug_install_post step will be
skipped and "find-debuginfo.sh" script will not be executed: that's the
script in charge of executing "strip -s" to remove all symbols, thanks
anyway for the advice.
Similar Questions
+2 votes

How can I prevent the laptop from sleeping when the lid is closed. I tried messing with the settings in gnome-power-preferences but that doesn't seem to prevent it when no one is logged in. Any suggestions?

0 votes

I am using CentOS 6.0 with Apache 2.2.15, and set up Apache with virtual host. The SSI works fine on the first VH, but ssi on the other virtual hosts does not work. I got the following message in the error log:

mod_include: Options +Includes (or IncludesNoExec) wasnt set, INCLUDES filter removed

Does anyone know how to resolve this problem?

0 votes

On CentOS5 I was used to create a simple spec file where at the end I'll declare files and directories I wan't to package:

%files
%dir /opt/myapp
%dir /opt/myapp/bin
%dir /opt/myapp/etc
/opt/myapp/bin/exec01
/opt/myapp/etc/myapp.conf

I'll copy the file in /usr/src/redhat/SPECS and run "rpmbuild -bb myapp.spec".

On CentOS6 rpm-build package no longer creates the /usr/src/redhat/... directory tree. I followed the CentOS6 Wiki instructions to setup my rpmbuild environment for a regular user.

When I try to build the package on CentOS6 I'm getting this error for every single file and directory:

File not found:

/home/myhome/rpmbuild/BUILDROOT/myapp-5.2-1el6.x86_64/opt/myapp/bin/exec01

I tried to override buildroot:

rpmbuild -bb --define="buildroot /" myapp.spec
 error: %{buildroot} can not be "/"

As a workaround I can manually create /home/myhome/rpmbuild/BUILDROOT/myapp-5.2-1el6.x86_64/ and copy all my file in there but that's a lot of extra work.

Is there a way to get the same functionality on CentOS6 where rpmbuild will collect the files from the main / directory and build the rpm package?

0 votes

I've found a number of articles on setting up a Linux / CUPS / Avahi server to allow airprinting, but they all seem to be quite old.

Two questions:
1) Does anyone have a link for a more recent article, hopefully specifically for Centos7.
2) I'm on a structured, VLAN network. Will I have to put a WIFI card into my Centos server to give it a presence on the WIFI before this will work?

...