Re: Trying to strip a library automatically

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Hi Orion,

Glad objdump helped -- the second approach I meant to write objcopy, which actually strips the symbols.

Regarding how the symbols might show up in the library automatically, here's how it might happen.  When I took a look at one of the build.log files from koji at the following link:

https://kojipkgs.fedoraproject.org//packages/Lmod/8.7.25/2.fc38/data/logs/x86_64/build.log

I see your CFLAGS variable contains the -g flag, which forces debug symbols to be included.  For example, for the tcl2lua it has it as part of the build (which contains the -g flag):

make[1]: Entering directory '/builddir/build/BUILD/Lmod-8.7.25/pkgs/tcl2lua'
gcc -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64  -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer  -DLUA_COMPAT_MODULE -fPIC -I/usr/include -I/usr/include/   -c -o tcl2lua.o tcl2lua.c

The way this seems to happen could be as follows:

1) I took a look at the source code from here:

https://kojipkgs.fedoraproject.org//packages/Lmod/8.7.25/2.fc38/src/Lmod-8.7.25-2.fc38.src.rpm

When I looked at the Makefile for tcl2lua under Lmod-8.7.25/pkgs/tcl2lua, it inherits it from a previous file:

override CFLAGS   := $(CFLAGS) -DLUA_COMPAT_MODULE -fPIC $(LUA_INC) $(TCL_INCLUDE)

2) When I traverse the inheritance, it seems to come from the configure script Lmod-8.7.25/configure:

I see a bunch of CFLAGS="-g there.  

If I then look at the build.log it seems to be run at the beginning of the build:

+ ./configure --build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu --program-prefix= --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/libexec --localstatedir=/var --runstatedir=/run --sharedstatedir=/var/lib --mandir=/usr/share/man --infodir=/usr/share/info --prefix=/usr/share PS=/usr/bin/ps
configure: WARNING: unrecognized options: --disable-dependency-tracking

I then looked at the Lmod.spec file, and I see this, which confirms it:

%build
%if 0%{?rhel} && 0%{?rhel} <= 6
%configure --prefix=%{_datadir} PS=/bin/ps
%else
%configure --prefix=%{_datadir} PS=/usr/bin/ps
%endif
%make_build

So debug symbols seem to get triggered through the configure script.  

Hope it helps,
Paul

On Fri, Jun 2, 2023 at 7:42 PM Orion Poplawski <orion@xxxxxxxx> wrote:
On 6/1/23 23:00, Paul Grosu wrote:
> Hi Orion,
>
> There are two ways to remove the debugging symbols:
>
> 1) strip --strip-debug your_library.so
>
> 2) objcopy --strip-debug your_library.so
>
> Below is an example of both approaches:
>
> 1) Method using strip:
>
> paul$ objdump --syms libfoo.so | grep debug
> 0000000000000000 l    d  .debug_aranges 0000000000000000             
>   .debug_aranges
> 0000000000000000 l    d  .debug_info    0000000000000000             
>   .debug_info
> 0000000000000000 l    d  .debug_abbrev  0000000000000000             
>   .debug_abbrev
> 0000000000000000 l    d  .debug_line    0000000000000000             
>   .debug_line
> 0000000000000000 l    d  .debug_str     0000000000000000             
>   .debug_str
> paul$ strip --strip-debug libfoo.so
> paul$ objdump --syms libfoo.so | grep debug
> paul$
>
> 2) Method using objdump:
>
> paul$ objdump --syms libfoo.so | grep debug
> 0000000000000000 l    d  .debug_aranges 0000000000000000             
>   .debug_aranges
> 0000000000000000 l    d  .debug_info    0000000000000000             
>   .debug_info
> 0000000000000000 l    d  .debug_abbrev  0000000000000000             
>   .debug_abbrev
> 0000000000000000 l    d  .debug_line    0000000000000000             
>   .debug_line
> 0000000000000000 l    d  .debug_str     0000000000000000             
>   .debug_str
> paul$ objcopy --strip-debug libfoo.so
> paul$ objdump --syms libfoo.so | grep debug
> paul$
>
> Are there other symbols you are looking to strip?
>
> Hope it helps,
> Paul

So I'm afraid my subject isn't the best - I'm really wondering why the
library isn't being stripped automatically and debug info collected by
RPM as I would expect.

But your answer pointed me towards using objdump --syms to verify that
the debug info has been removed, not the output of "file".  Thanks!

>
> On Fri, Jun 2, 2023 at 12:11 AM Orion Poplawski <orion@xxxxxxxx
> <mailto:orion@xxxxxxxx>> wrote:
>
>     I'm trying to resolve this packaging issue with Lmod:
>
>     https://artifacts.dev.testing-farm.io/4d7bee41-8d21-42fb-8c57-e5ffbf58119f/ <https://artifacts.dev.testing-farm.io/4d7bee41-8d21-42fb-8c57-e5ffbf58119f/>
>
>     debuginfo
>     BAD /usr/share/lmod/8.7.25/lib/tcl2lua.so in Lmod-8.7.25-2.fc38 on i686
>     contains debugging symbols
>
>     I've dealt with a couple of issues here:
>
>     https://src.fedoraproject.org/rpms/Lmod/pull-request/2
>     <https://src.fedoraproject.org/rpms/Lmod/pull-request/2>
>
>     but despite all of my attempts the library does not appear to get
>     stripped.
>
>     In fact:
>
>     ]$ strip -g
>     /home/orion/BUILDROOT/Lmod-8.7.25-3.fc39.x86_64/usr/lib64/lmod/tcl2lua.so.1.0.1
>
>     $ file
>     /home/orion/BUILDROOT/Lmod-8.7.25-3.fc39.x86_64/usr/lib64/lmod/tcl2lua.so.1.0.1
>     /home/orion/BUILDROOT/Lmod-8.7.25-3.fc39.x86_64/usr/lib64/lmod/tcl2lua.so.1.0.1:
>     ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically
>     linked, BuildID[sha1]=aa1ea44979190d0cf530d350f8151ffafeab0f36, not
>     stripped
>
>     ?
>
>
>     --
>     Orion Poplawski
>     he/him/his  - surely the least important thing about me
>     IT Systems Manager                         720-772-5637
>     NWRA, Boulder/CoRA Office             FAX: 303-415-9702
>     3380 Mitchell Lane orion@xxxxxxxx <mailto:orion@xxxxxxxx>
>     Boulder, CO 80301 https://www.nwra.com/ <https://www.nwra.com/>
>     _______________________________________________
>     devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx
>     <mailto:devel@xxxxxxxxxxxxxxxxxxxxxxx>
>     To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx
>     <mailto:devel-leave@xxxxxxxxxxxxxxxxxxxxxxx>
>     Fedora Code of Conduct:
>     https://docs.fedoraproject.org/en-US/project/code-of-conduct/
>     <https://docs.fedoraproject.org/en-US/project/code-of-conduct/>
>     List Guidelines:
>     https://fedoraproject.org/wiki/Mailing_list_guidelines
>     <https://fedoraproject.org/wiki/Mailing_list_guidelines>
>     List Archives:
>     https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx <https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx>
>     Do not reply to spam, report it:
>     https://pagure.io/fedora-infrastructure/new_issue
>     <https://pagure.io/fedora-infrastructure/new_issue>
>
>
> _______________________________________________
> devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx
> To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx
> Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
> List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
> List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx
> Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue

--
Orion Poplawski
he/him/his  - surely the least important thing about me
IT Systems Manager                         720-772-5637
NWRA, Boulder/CoRA Office             FAX: 303-415-9702
3380 Mitchell Lane                       orion@xxxxxxxx
Boulder, CO 80301                 https://www.nwra.com/

_______________________________________________
devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue
_______________________________________________
devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Users]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]

  Powered by Linux