+2017-06-06 Mark Wielaard <mark@klomp.org>
+
+ * strip.c (handle_elf): Assume e_shstrndx section can be removed.
+
2017-04-20 Ulf Hermann <ulf.hermann@qt.io>
* readelf.c: Include strings.h.
in the sh_link or sh_info element it cannot be removed either
*/
for (cnt = 1; cnt < shnum; ++cnt)
- /* Check whether the section can be removed. */
+ /* Check whether the section can be removed. Since we will create
+ a new .shstrtab assume it will be removed too. */
if (remove_shdrs ? !(shdr_info[cnt].shdr.sh_flags & SHF_ALLOC)
- : ebl_section_strip_p (ebl, ehdr, &shdr_info[cnt].shdr,
- shdr_info[cnt].name, remove_comment,
- remove_debug))
+ : (ebl_section_strip_p (ebl, ehdr, &shdr_info[cnt].shdr,
+ shdr_info[cnt].name, remove_comment,
+ remove_debug)
+ || cnt == ehdr->e_shstrndx))
{
/* For now assume this section will be removed. */
shdr_info[cnt].idx = 0;
}
/* Test whether we are doing anything at all. */
- if (cnt == idx)
- /* Nope, all removable sections are already gone. */
+ if (cnt == idx
+ || (cnt == idx + 1 && shdr_info[ehdr->e_shstrndx].idx == 0))
+ /* Nope, all removable sections are already gone. Or the only section
+ we would remove is the .shstrtab section which we will add again. */
goto fail_close;
/* Create the reference to the file with the debug info. */
+2017-06-06 Mark Wielaard <mark@klomp.org>
+
+ * run-strip-test.sh: Test strip -g doesn't introduce extra .shstrtab.
+
2017-05-30 Mark Wielaard <mark@klomp.org>
* run-backtrace-fp-core-ppc64le.sh: New test.
testrun ${abs_top_builddir}/src/elfcmp --hash-inexact $original testfile.unstrip
}
+# test strip -g
+testrun ${abs_top_builddir}/src/strip -g -o testfile.temp $original
+
+# Buggy eu-strip created multiple .shstrtab sections
+shstrtab_SECS=$(testrun ${abs_top_builddir}/src/readelf -S testfile.temp | grep '.shstrtab' | wc --lines)
+test $shstrtab_SECS -eq 1 ||
+ { echo "*** failure not just one '.shstrtab' testfile.temp ($shstrtab_SECS)"; status=1; }
+
# Now strip in-place and make sure it is smaller.
SIZE_original=$(stat -c%s $original)
testrun ${abs_top_builddir}/src/strip $original