summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ChangeLog7
-rw-r--r--src/strip.c32
-rw-r--r--tests/ChangeLog8
-rw-r--r--tests/Makefile.am6
-rwxr-xr-xtests/run-strip-groups.sh63
-rw-r--r--tests/testfile58.bz2bin0 -> 1680 bytes
6 files changed, 109 insertions, 7 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 5f164e0d..154b38e2 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
+2011-05-18 Mark Wielaard <mjw@redhat.com>
+
+ * strip.c (handle_elf): Make sure all sections of a removed group
+ section are removed too. Don't discard SHT_GROUP sections, copy
+ section table before it gets modified. Section group signature
+ symbols don't have to be retained.
+
2011-05-16 Jakub Jelinek <jakub@redhat.com>
* readelf.c (print_ops): Handle DW_OP_GNU_const_type,
diff --git a/src/strip.c b/src/strip.c
index 99374eb3..8c3c57de 100644
--- a/src/strip.c
+++ b/src/strip.c
@@ -726,6 +726,22 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname,
|| shdr_info[cnt].shdr.sh_type == SHT_RELA)
&& shdr_info[shdr_info[cnt].shdr.sh_info].idx != 0)
shdr_info[cnt].idx = 1;
+
+ /* If a group section is marked as being removed make
+ sure all the sections it contains are being removed, too. */
+ if (shdr_info[cnt].shdr.sh_type == SHT_GROUP)
+ {
+ Elf32_Word *grpref;
+ grpref = (Elf32_Word *) shdr_info[cnt].data->d_buf;
+ for (size_t in = 1;
+ in < shdr_info[cnt].data->d_size / sizeof (Elf32_Word);
+ ++in)
+ if (shdr_info[grpref[in]].idx != 0)
+ {
+ shdr_info[cnt].idx = 1;
+ break;
+ }
+ }
}
if (shdr_info[cnt].idx == 1)
@@ -883,6 +899,7 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname,
bool discard_section = (shdr_info[cnt].idx > 0
&& shdr_info[cnt].debug_data == NULL
&& shdr_info[cnt].shdr.sh_type != SHT_NOTE
+ && shdr_info[cnt].shdr.sh_type != SHT_GROUP
&& cnt != ehdr->e_shstrndx);
/* Set the section header in the new file. */
@@ -912,7 +929,8 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname,
*debugdata = *shdr_info[cnt].data;
if (discard_section)
debugdata->d_buf = NULL;
- else if (shdr_info[cnt].debug_data != NULL)
+ else if (shdr_info[cnt].debug_data != NULL
+ || shdr_info[cnt].shdr.sh_type == SHT_GROUP)
{
/* Copy the original data before it gets modified. */
shdr_info[cnt].debug_data = debugdata;
@@ -1261,9 +1279,15 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname,
}
else if (debug_fname == NULL
|| shdr_info[cnt].debug_data == NULL)
- /* This is a section symbol for a section which has
- been removed. */
- assert (GELF_ST_TYPE (sym->st_info) == STT_SECTION);
+ /* This is a section or group signature symbol
+ for a section which has been removed. */
+ {
+ size_t sidx = (sym->st_shndx != SHN_XINDEX
+ ? sym->st_shndx : xshndx);
+ assert (GELF_ST_TYPE (sym->st_info) == STT_SECTION
+ || (shdr_info[sidx].shdr.sh_type == SHT_GROUP
+ && shdr_info[sidx].shdr.sh_info == inner));
+ }
}
if (destidx != inner)
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 674fe969..2599b0ca 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,11 @@
+2011-05-18 Mark Wielaard <mjw@redhat.com>
+
+ * run-strip-groups.sh: New test.
+ * testfile58.bz2: New test file.
+ * Makefile.am (EXTRA_DIST): Add testfile58.bz2.
+ (TESTS): Add run-strip-groups.sh.
+ (EXTRA_DIST): Likewise.
+
2011-03-28 Marek Polacek <mpolacek@redhat.com>
* alldts.c: New file.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 35f55e3c..16a47e2e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -70,7 +70,7 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \
newscn run-strip-test.sh run-strip-test2.sh \
run-strip-test3.sh run-strip-test4.sh run-strip-test5.sh \
run-strip-test6.sh run-strip-test7.sh run-strip-test8.sh \
- run-unstrip-test.sh run-unstrip-test2.sh \
+ run-strip-groups.sh run-unstrip-test.sh run-unstrip-test2.sh \
run-ecp-test.sh run-ecp-test2.sh run-alldts.sh \
run-elflint-test.sh run-elflint-self.sh run-ranlib-test.sh \
run-ranlib-test2.sh run-ranlib-test3.sh run-ranlib-test4.sh \
@@ -110,7 +110,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
testfile13.bz2 run-strip-test3.sh run-allfcts.sh \
run-line2addr.sh run-elflint-test.sh testfile14.bz2 \
run-strip-test4.sh run-strip-test5.sh run-strip-test6.sh \
- run-strip-test7.sh run-strip-test8.sh \
+ run-strip-test7.sh run-strip-test8.sh run-strip-groups.sh \
run-unstrip-test.sh run-unstrip-test2.sh \
run-elflint-self.sh run-ranlib-test.sh run-ranlib-test2.sh \
run-ranlib-test3.sh run-ranlib-test4.sh \
@@ -158,7 +158,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
testfile55-32.bz2 testfile55-32.debug.bz2 \
testfile55-32.prelink.bz2 testfile55-64.bz2 \
testfile55-64.debug.bz2 testfile55-64.prelink.bz2 \
- testfile56.bz2 testfile57.bz2
+ testfile56.bz2 testfile57.bz2 testfile58.bz2
installed_TESTS_ENVIRONMENT = libdir=$(DESTDIR)$(libdir) \
bindir=$(DESTDIR)$(bindir) \
diff --git a/tests/run-strip-groups.sh b/tests/run-strip-groups.sh
new file mode 100755
index 00000000..3434a61e
--- /dev/null
+++ b/tests/run-strip-groups.sh
@@ -0,0 +1,63 @@
+#! /bin/sh
+# Copyright (C) 2011 Red Hat, Inc.
+# This file is part of Red Hat elfutils.
+#
+# Red Hat elfutils is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by the
+# Free Software Foundation; version 2 of the License.
+#
+# Red Hat elfutils is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with Red Hat elfutils; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
+#
+# Red Hat elfutils is an included package of the Open Invention Network.
+# An included package of the Open Invention Network is a package for which
+# Open Invention Network licensees cross-license their patents. No patent
+# license is granted, either expressly or impliedly, by designation as an
+# included package. Should you wish to participate in the Open Invention
+# Network licensing program, please visit www.openinventionnetwork.com
+# <http://www.openinventionnetwork.com>.
+#
+# g++ -gdwarf-4 -c testfile58.cxx
+# class ct
+# {
+# private:
+# int i;
+#
+# public:
+# void foo ()
+# {
+# i = 1;
+# }
+#
+# int bar ()
+# {
+# return i;
+# }
+# };
+#
+# int baz ()
+# {
+# class ct c;
+# c.foo ();
+# return c.bar ();
+# }
+
+. $srcdir/test-subr.sh
+
+infile=testfile58
+outfile=$infile.stripped
+dbgfile=$infile.debug
+
+testfiles $infile
+tempfiles $outfile $dbgfile
+
+testrun ../src/strip -o $outfile -f $dbgfile $infile
+testrun ../src/elflint -q $infile
+testrun ../src/elflint -q $outfile
+testrun ../src/elflint -q -d $dbgfile
diff --git a/tests/testfile58.bz2 b/tests/testfile58.bz2
new file mode 100644
index 00000000..839efd92
--- /dev/null
+++ b/tests/testfile58.bz2
Binary files differ