top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration
Print Preview

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

0 votes
69 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 Google+ Share Button LinkedIn Share Button Multiple Social 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?

+1 vote

I have a problem in that at first all my log files were dated 12-31-1969 and logrotate has:

# more /var/lib/logrotate.status
logrotate state -- version 2
"/var/log/yum.log" 1969-12-31-20:26:1
"/var/named/data/named.run" 1969-12-31-20:26:1
"/var/log/httpd/error_log" 2015-8-27-4:43:1
"/var/log/wtmp" 1969-12-31-20:26:1
"/var/log/chrony/*.log" 2015-8-19-22:0:0
"/var/log/spooler" 1969-12-31-20:26:1
"/var/log/btmp" 1969-12-31-20:26:1
"/var/log/maillog" 1969-12-31-20:26:1
"/var/log/wpa_supplicant.log" 2015-8-19-22:0:0
"/var/log/secure" 1969-12-31-20:26:1
"/var/log/ppp/connect-errors" 2015-8-19-22:0:0
"/var/log/messages" 1969-12-31-20:26:1
"/var/log/cron" 1969-12-31-20:26:1
"/var/log/httpd/access_log" 2015-8-27-4:43:1

How do I get this file rebuilt with the dates currently on the files listed?


Useful Links with Similar Problem
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...