Created attachment 544932 [details]
A sample archive library
Description of problem:
The eu-strip program dies with a segmentation fault when given an archive library. Ordinary strip does not.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Grab the attached libgcov.a.
2. eu-strip libgcov.a
SEGV. libgcov.a is now a broken ELF object file.
It should work and leave an archive library.
Program received signal SIGSEGV, Segmentation fault.
0x00000034850044e3 in elf_end (elf=0x60d220) at elf_end.c:119
119 while (child->next != elf)
#0 0x00000034850044e3 in elf_end (elf=0x60d220) at elf_end.c:119
#1 0x0000000000402bf5 in handle_elf (fd=7, elf=<optimized out>, prefix=<optimized out>, mode=4294958400, tvp=0x0) at strip.c:1806
#2 0x0000000000405d54 in handle_ar (fd=7, elf=0x60c030, prefix=<optimized out>, fname=0x7fffffffe54c "libgcov.a", tvp=0x0) at strip.c:1881
#3 0x000000000040611d in process_file (fname=0x7fffffffe54c "libgcov.a") at strip.c:365
#4 0x00000000004021e3 in main (argc=2, argv=0x7fffffffe178) at strip.c:197
(gdb) i lo
child = 0x0
parent = 0x60c030
__PRETTY_FUNCTION__ = "elf_end"
This happens for all archives, not only archives from non-native architectures. The following is on x86_64:
$ gcc -x c /dev/null -c -o null.o
$ ar cru null.a null.o
$ eu-strip null.a
The apparent reason is that elf_clone doesn't add the cloned elf among parent's children. After doing that, it doesn't segv, but the archive is broken anyway. I'm looking further.
See also https://fedorahosted.org/pipermail/elfutils-devel/2009-August/000567.html and https://fedorahosted.org/pipermail/elfutils-devel/2011-November/002162.html
Yes, I was just about to post about the same. Something was at the back of my mind about strip and archives.
Fedora 16 changed to end-of-life (EOL) status on 2013-02-12. Fedora 16 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.
If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version.
Thank you for reporting this bug and we are sorry it could not be fixed.
This seems to be a long standing problem not yet resolved.
Note the list archive of the messages from comment #2 have moved:
This bug appears to have been reported against 'rawhide' during the Fedora 19 development cycle.
Changing version to '19'.
(As we did not run this process for some time, it could affect also pre-Fedora 19 development
cycle bugs. We are very sorry. It will help us with cleanup during Fedora 19 End Of Life. Thank you.)
More information and reason for this action is here:
This will still crash eu-strip with current elfutils git.
I pushed a patch to make eu-strip just print an error when trying to strip an archive. That obviously isn't very helpful, but it is better than crashing or (silently) corrupting archives.
We should rework eu-strip as outlined by Roland in: