]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
strip: Only sanity check symbols to not discarded sections for debug file.
authorMark Wielaard <mjw@redhat.com>
Sun, 4 Oct 2015 21:47:47 +0000 (23:47 +0200)
committerMark Wielaard <mjw@redhat.com>
Fri, 9 Oct 2015 09:22:00 +0000 (11:22 +0200)
We can only sanity check the symbols to discarded sections when creating a
debug file. Otherwise we won't keep track of debug_data. This can trigger
erroneously when there are relocation symbols in the symtab for a .debug
section but we are not putting those symbols in a separate .debug file.

Adjust run-strip-test.sh to always run in-place strip size check even
for ET_REL files. Before this fix the sanity check would trigger for
some ET_REL files because they contained such relocation symbols to
.debug sections (but debug_data would be NULL because -f wasn't used).

Signed-off-by: Mark Wielaard <mjw@redhat.com>
src/ChangeLog
src/strip.c
tests/run-strip-test.sh

index f577885635b991b1dc539454692c0d09fb82db0b..5e69d3a4ed9ecdde3d98e9bb4c079afe72ad694d 100644 (file)
@@ -1,3 +1,8 @@
+2015-10-04  Mark Wielaard  <mjw@redhat.com>
+
+       * strip.c (handle_elf): Only sanity check section symbols to not
+       kept discarded sections if we are creating a debug file.
+
 2015-10-07  Mark Wielaard  <mjw@redhat.com>
 
        * unstrip.c (MAX): Removed.
index 41169eda898c6a409b7b3a07f2da7b1c0c6d015d..6fdb3bf9a1fbb80586597752b3b37050b250f7c1 100644 (file)
@@ -1379,9 +1379,11 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname,
                            shdr_info[cnt].shdr.sh_info = destidx - 1;
                          }
                      }
-                   else if (debug_fname == NULL
-                            || shdr_info[cnt].debug_data == NULL)
-                     /* This is a section or group signature symbol
+                   else if (debug_fname != NULL
+                            && shdr_info[cnt].debug_data == NULL)
+                     /* The symbol points to a section that is discarded
+                        but isn't preserved in the debug file. Check that
+                        this is a section or group signature symbol
                         for a section which has been removed.  */
                      {
                        size_t sidx = (sym->st_shndx != SHN_XINDEX
index 2ebb5a91ad2896756c2a801545eff24eeede0383..43d27e533c2f9e062d6b741f658b211c6551f899 100755 (executable)
@@ -50,17 +50,11 @@ testrun ${abs_top_builddir}/src/elfcmp --hash-inexact $original testfile.unstrip
 }
 
 # Now strip in-place and make sure it is smaller.
-# Skip ET_REL files, they might have unexpected symbol table entries.
-is_ET_REL=0
-testrun ${abs_top_builddir}/src/readelf -h $original 2>&1 \
-  | fgrep 'REL (Relocatable file)' && is_ET_REL=1
-if test $is_ET_REL -eq 0; then
-  SIZE_original=$(stat -c%s $original)
-  testrun ${abs_top_builddir}/src/strip $original
-  SIZE_stripped=$(stat -c%s $original)
-  test $SIZE_stripped -lt $SIZE_original ||
-    { echo "*** failure in-place strip file not smaller $original"; status=1; }
-fi
+SIZE_original=$(stat -c%s $original)
+testrun ${abs_top_builddir}/src/strip $original
+SIZE_stripped=$(stat -c%s $original)
+test $SIZE_stripped -lt $SIZE_original ||
+  { echo "*** failure in-place strip file not smaller $original"; status=1; }
 
 tempfiles testfile.sections
 testrun ${abs_top_builddir}/src/readelf -S testfile.temp > testfile.sections || status=$?