aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gold/ChangeLog11
-rw-r--r--gold/incremental.cc4
-rw-r--r--gold/testsuite/Makefile.am11
-rw-r--r--gold/testsuite/Makefile.in56
-rw-r--r--gold/testsuite/incr_comdat_test_1.cc68
-rw-r--r--gold/testsuite/incr_comdat_test_2_v1.cc44
-rw-r--r--gold/testsuite/incr_comdat_test_2_v2.cc44
-rw-r--r--gold/testsuite/incr_comdat_test_2_v3.cc44
8 files changed, 268 insertions, 14 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog
index 82da380..d3d8719 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,14 @@
+2011-09-13 Cary Coutant <ccoutant@google.com>
+
+ * incremental.cc (Sized_relobj_incr::do_layout): Call
+ report_comdat_group for kept comdat sections.
+ * testsuite/Makefile.am (incremental_comdat_test_1): New test.
+ * testsuite/Makefile.in: Regenerate.
+ * testsuite/incr_comdat_test_1.cc: New source file.
+ * testsuite/incr_comdat_test_2_v1.cc: New source file.
+ * testsuite/incr_comdat_test_2_v2.cc: New source file.
+ * testsuite/incr_comdat_test_2_v3.cc: New source file.
+
2011-09-13 Ian Lance Taylor <iant@google.com>
* object.cc (Sized_relobj_file::do_layout): Remove unused local
diff --git a/gold/incremental.cc b/gold/incremental.cc
index e3b48a4..4c4483d 100644
--- a/gold/incremental.cc
+++ b/gold/incremental.cc
@@ -2008,7 +2008,9 @@ Sized_relobj_incr<size, big_endian>::do_layout(
this->error(_("COMDAT group has no signature"));
bool keep = layout->find_or_add_kept_section(signature, this, i, true,
true, NULL);
- if (!keep)
+ if (keep)
+ incremental_inputs->report_comdat_group(this, signature);
+ else
this->error(_("COMDAT group %s included twice in incremental link"),
signature);
}
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am
index ca07f87..194fc4f 100644
--- a/gold/testsuite/Makefile.am
+++ b/gold/testsuite/Makefile.am
@@ -2024,6 +2024,17 @@ incremental_common_test_1: common_test_1_v1.o common_test_1_v2.o gcctestdir/ld
cp -f common_test_1_v2.o common_test_1_tmp.o
$(CXXLINK) -Wl,--incremental-update -Bgcctestdir/ common_test_1_tmp.o
+check_PROGRAMS += incremental_comdat_test_1
+incremental_comdat_test_1: incr_comdat_test_1.o incr_comdat_test_2_v1.o incr_comdat_test_2_v2.o incr_comdat_test_2_v3.o gcctestdir/ld
+ cp -f incr_comdat_test_2_v1.o incr_comdat_test_1_tmp.o
+ $(CXXLINK) -Wl,--incremental-full,--incremental-patch=100 -Bgcctestdir/ incr_comdat_test_1.o incr_comdat_test_1_tmp.o
+ @sleep 1
+ cp -f incr_comdat_test_2_v2.o incr_comdat_test_1_tmp.o
+ $(CXXLINK) -Wl,--incremental-update -Bgcctestdir/ incr_comdat_test_1.o incr_comdat_test_1_tmp.o
+ @sleep 1
+ cp -f incr_comdat_test_2_v3.o incr_comdat_test_1_tmp.o
+ $(CXXLINK) -Wl,--incremental-update -Bgcctestdir/ incr_comdat_test_1.o incr_comdat_test_1_tmp.o
+
endif DEFAULT_TARGET_X86_64
endif GCC
diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in
index f0339fd..09d7375 100644
--- a/gold/testsuite/Makefile.in
+++ b/gold/testsuite/Makefile.in
@@ -472,7 +472,8 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_test_5 \
@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_test_6 \
@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_copy_test \
-@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_common_test_1
+@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_common_test_1 \
+@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_comdat_test_1
@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_55 = two_file_test_tmp_2.o \
@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_test_tmp_3.o \
@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_test_4.base \
@@ -749,7 +750,8 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS)
@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_test_5$(EXEEXT) \
@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_test_6$(EXEEXT) \
@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_copy_test$(EXEEXT) \
-@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_common_test_1$(EXEEXT)
+@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_common_test_1$(EXEEXT) \
+@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_comdat_test_1$(EXEEXT)
basic_pic_test_SOURCES = basic_pic_test.c
basic_pic_test_OBJECTS = basic_pic_test.$(OBJEXT)
basic_pic_test_LDADD = $(LDADD)
@@ -1083,6 +1085,13 @@ ifuncmain7static_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
ifuncvar_OBJECTS = $(am_ifuncvar_OBJECTS)
ifuncvar_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(ifuncvar_LDFLAGS) \
$(LDFLAGS) -o $@
+incremental_comdat_test_1_SOURCES = incremental_comdat_test_1.c
+incremental_comdat_test_1_OBJECTS = \
+ incremental_comdat_test_1.$(OBJEXT)
+incremental_comdat_test_1_LDADD = $(LDADD)
+incremental_comdat_test_1_DEPENDENCIES = libgoldtest.a ../libgold.a \
+ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
incremental_common_test_1_SOURCES = incremental_common_test_1.c
incremental_common_test_1_OBJECTS = \
incremental_common_test_1.$(OBJEXT)
@@ -1635,17 +1644,17 @@ SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c basic_pie_test.c \
ifuncmain6pie.c $(ifuncmain7_SOURCES) ifuncmain7pic.c \
ifuncmain7picstatic.c ifuncmain7pie.c \
$(ifuncmain7static_SOURCES) $(ifuncvar_SOURCES) \
- incremental_common_test_1.c incremental_copy_test.c \
- incremental_test_2.c incremental_test_3.c incremental_test_4.c \
- incremental_test_5.c incremental_test_6.c $(initpri1_SOURCES) \
- $(initpri2_SOURCES) $(initpri3a_SOURCES) $(initpri3b_SOURCES) \
- $(justsyms_SOURCES) $(justsyms_exec_SOURCES) $(large_SOURCES) \
- local_labels_test.c many_sections_r_test.c \
- $(many_sections_test_SOURCES) $(object_unittest_SOURCES) \
- permission_test.c plugin_test_1.c plugin_test_2.c \
- plugin_test_3.c plugin_test_4.c plugin_test_5.c \
- plugin_test_6.c plugin_test_7.c plugin_test_8.c \
- $(protected_1_SOURCES) $(protected_2_SOURCES) \
+ incremental_comdat_test_1.c incremental_common_test_1.c \
+ incremental_copy_test.c incremental_test_2.c \
+ incremental_test_3.c incremental_test_4.c incremental_test_5.c \
+ incremental_test_6.c $(initpri1_SOURCES) $(initpri2_SOURCES) \
+ $(initpri3a_SOURCES) $(initpri3b_SOURCES) $(justsyms_SOURCES) \
+ $(justsyms_exec_SOURCES) $(large_SOURCES) local_labels_test.c \
+ many_sections_r_test.c $(many_sections_test_SOURCES) \
+ $(object_unittest_SOURCES) permission_test.c plugin_test_1.c \
+ plugin_test_2.c plugin_test_3.c plugin_test_4.c \
+ plugin_test_5.c plugin_test_6.c plugin_test_7.c \
+ plugin_test_8.c $(protected_1_SOURCES) $(protected_2_SOURCES) \
$(relro_now_test_SOURCES) $(relro_script_test_SOURCES) \
$(relro_strip_test_SOURCES) $(relro_test_SOURCES) \
$(script_test_1_SOURCES) $(script_test_2_SOURCES) \
@@ -2770,6 +2779,15 @@ ifuncmain7static$(EXEEXT): $(ifuncmain7static_OBJECTS) $(ifuncmain7static_DEPEND
ifuncvar$(EXEEXT): $(ifuncvar_OBJECTS) $(ifuncvar_DEPENDENCIES)
@rm -f ifuncvar$(EXEEXT)
$(ifuncvar_LINK) $(ifuncvar_OBJECTS) $(ifuncvar_LDADD) $(LIBS)
+@DEFAULT_TARGET_X86_64_FALSE@incremental_comdat_test_1$(EXEEXT): $(incremental_comdat_test_1_OBJECTS) $(incremental_comdat_test_1_DEPENDENCIES)
+@DEFAULT_TARGET_X86_64_FALSE@ @rm -f incremental_comdat_test_1$(EXEEXT)
+@DEFAULT_TARGET_X86_64_FALSE@ $(LINK) $(incremental_comdat_test_1_OBJECTS) $(incremental_comdat_test_1_LDADD) $(LIBS)
+@GCC_FALSE@incremental_comdat_test_1$(EXEEXT): $(incremental_comdat_test_1_OBJECTS) $(incremental_comdat_test_1_DEPENDENCIES)
+@GCC_FALSE@ @rm -f incremental_comdat_test_1$(EXEEXT)
+@GCC_FALSE@ $(LINK) $(incremental_comdat_test_1_OBJECTS) $(incremental_comdat_test_1_LDADD) $(LIBS)
+@NATIVE_LINKER_FALSE@incremental_comdat_test_1$(EXEEXT): $(incremental_comdat_test_1_OBJECTS) $(incremental_comdat_test_1_DEPENDENCIES)
+@NATIVE_LINKER_FALSE@ @rm -f incremental_comdat_test_1$(EXEEXT)
+@NATIVE_LINKER_FALSE@ $(LINK) $(incremental_comdat_test_1_OBJECTS) $(incremental_comdat_test_1_LDADD) $(LIBS)
@DEFAULT_TARGET_X86_64_FALSE@incremental_common_test_1$(EXEEXT): $(incremental_common_test_1_OBJECTS) $(incremental_common_test_1_DEPENDENCIES)
@DEFAULT_TARGET_X86_64_FALSE@ @rm -f incremental_common_test_1$(EXEEXT)
@DEFAULT_TARGET_X86_64_FALSE@ $(LINK) $(incremental_common_test_1_OBJECTS) $(incremental_common_test_1_LDADD) $(LIBS)
@@ -3220,6 +3238,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifuncmain7picstatic.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifuncmain7pie.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifuncvar3.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/incremental_comdat_test_1.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/incremental_common_test_1.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/incremental_copy_test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/incremental_test_2.Po@am__quote@
@@ -3934,6 +3953,8 @@ incremental_copy_test.log: incremental_copy_test$(EXEEXT)
@p='incremental_copy_test$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
incremental_common_test_1.log: incremental_common_test_1$(EXEEXT)
@p='incremental_common_test_1$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+incremental_comdat_test_1.log: incremental_comdat_test_1$(EXEEXT)
+ @p='incremental_comdat_test_1$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
.test.log:
@p='$<'; $(am__check_pre) $(TEST_LOG_COMPILE) "$$tst" $(am__check_post)
@am__EXEEXT_TRUE@.test$(EXEEXT).log:
@@ -4984,6 +5005,15 @@ uninstall-am:
@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ @sleep 1
@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ cp -f common_test_1_v2.o common_test_1_tmp.o
@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Wl,--incremental-update -Bgcctestdir/ common_test_1_tmp.o
+@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@incremental_comdat_test_1: incr_comdat_test_1.o incr_comdat_test_2_v1.o incr_comdat_test_2_v2.o incr_comdat_test_2_v3.o gcctestdir/ld
+@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ cp -f incr_comdat_test_2_v1.o incr_comdat_test_1_tmp.o
+@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Wl,--incremental-full,--incremental-patch=100 -Bgcctestdir/ incr_comdat_test_1.o incr_comdat_test_1_tmp.o
+@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ @sleep 1
+@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ cp -f incr_comdat_test_2_v2.o incr_comdat_test_1_tmp.o
+@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Wl,--incremental-update -Bgcctestdir/ incr_comdat_test_1.o incr_comdat_test_1_tmp.o
+@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ @sleep 1
+@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ cp -f incr_comdat_test_2_v3.o incr_comdat_test_1_tmp.o
+@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Wl,--incremental-update -Bgcctestdir/ incr_comdat_test_1.o incr_comdat_test_1_tmp.o
@NATIVE_OR_CROSS_LINKER_TRUE@script_test_10.o: script_test_10.s
@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_AS) -o $@ $<
@NATIVE_OR_CROSS_LINKER_TRUE@script_test_10: $(srcdir)/script_test_10.t script_test_10.o gcctestdir/ld
diff --git a/gold/testsuite/incr_comdat_test_1.cc b/gold/testsuite/incr_comdat_test_1.cc
new file mode 100644
index 0000000..7a232c2
--- /dev/null
+++ b/gold/testsuite/incr_comdat_test_1.cc
@@ -0,0 +1,68 @@
+// incr_comdat_test_1.cc -- test incremental update with comdat sections
+
+// Copyright 2011 Free Software Foundation, Inc.
+// Written by Cary Coutant <ccoutant@google.com>.
+
+// This file is part of gold.
+
+// This program 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; either version 3 of the License, or
+// (at your option) any later version.
+
+// This program 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 this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+// MA 02110-1301, USA.
+
+#include <cstdio>
+
+template <class T>
+T GetMax(T a, T b)
+{
+ return a > b ? a : b;
+}
+
+extern int foo();
+
+int bar()
+{
+ return GetMax<int>(4, 5);
+}
+
+class A
+{
+ public:
+ int sum(int k)
+ {
+ static int total = 0;
+ total += k;
+ return total;
+ }
+};
+
+#define CHECK_EQ(var, expected) \
+ do \
+ { \
+ if ((var) != (expected)) \
+ { \
+ printf(#var ": expected %d, found %d\n", expected, var); \
+ return 1; \
+ } \
+ } \
+ while (0)
+
+int main()
+{
+ A a;
+ CHECK_EQ(bar(), 5);
+ CHECK_EQ(foo(), 11);
+ CHECK_EQ(a.sum(55), 11 + 55);
+ CHECK_EQ(a.sum(66), 11 + 55 + 66);
+ return 0;
+}
diff --git a/gold/testsuite/incr_comdat_test_2_v1.cc b/gold/testsuite/incr_comdat_test_2_v1.cc
new file mode 100644
index 0000000..f7d6a8c
--- /dev/null
+++ b/gold/testsuite/incr_comdat_test_2_v1.cc
@@ -0,0 +1,44 @@
+// incr_comdat_test_2.cc -- test incremental update with comdat sections
+
+// Copyright 2011 Free Software Foundation, Inc.
+// Written by Cary Coutant <ccoutant@google.com>.
+
+// This file is part of gold.
+
+// This program 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; either version 3 of the License, or
+// (at your option) any later version.
+
+// This program 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 this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+// MA 02110-1301, USA.
+
+template <class T>
+T GetMax(T a, T b)
+{
+ return a > b ? a : b;
+}
+
+class A
+{
+ public:
+ int sum(int k)
+ {
+ static int total = 0;
+ total += k;
+ return total;
+ }
+};
+
+int foo()
+{
+ A a;
+ return GetMax<int>(10, a.sum(8));
+}
diff --git a/gold/testsuite/incr_comdat_test_2_v2.cc b/gold/testsuite/incr_comdat_test_2_v2.cc
new file mode 100644
index 0000000..fca7fda
--- /dev/null
+++ b/gold/testsuite/incr_comdat_test_2_v2.cc
@@ -0,0 +1,44 @@
+// incr_comdat_test_2.cc -- test incremental update with comdat sections
+
+// Copyright 2011 Free Software Foundation, Inc.
+// Written by Cary Coutant <ccoutant@google.com>.
+
+// This file is part of gold.
+
+// This program 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; either version 3 of the License, or
+// (at your option) any later version.
+
+// This program 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 this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+// MA 02110-1301, USA.
+
+template <class T>
+T GetMax(T a, T b)
+{
+ return a > b ? a : b;
+}
+
+class A
+{
+ public:
+ int sum(int k)
+ {
+ static int total = 0;
+ total += k;
+ return total;
+ }
+};
+
+int foo()
+{
+ A a;
+ return GetMax<int>(10, a.sum(9));
+}
diff --git a/gold/testsuite/incr_comdat_test_2_v3.cc b/gold/testsuite/incr_comdat_test_2_v3.cc
new file mode 100644
index 0000000..cbb83c1
--- /dev/null
+++ b/gold/testsuite/incr_comdat_test_2_v3.cc
@@ -0,0 +1,44 @@
+// incr_comdat_test_2.cc -- test incremental update with comdat sections
+
+// Copyright 2011 Free Software Foundation, Inc.
+// Written by Cary Coutant <ccoutant@google.com>.
+
+// This file is part of gold.
+
+// This program 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; either version 3 of the License, or
+// (at your option) any later version.
+
+// This program 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 this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+// MA 02110-1301, USA.
+
+template <class T>
+T GetMax(T a, T b)
+{
+ return a > b ? a : b;
+}
+
+class A
+{
+ public:
+ int sum(int k)
+ {
+ static int total = 0;
+ total += k;
+ return total;
+ }
+};
+
+int foo()
+{
+ A a;
+ return GetMax<int>(10, a.sum(11));
+}