aboutsummaryrefslogtreecommitdiff
path: root/gold/testsuite
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2012-08-14 08:31:57 +0000
committerNick Clifton <nickc@redhat.com>2012-08-14 08:31:57 +0000
commitb9b2ae8bbf911b7762fe41ecbb5dbc64a8e2b5a7 (patch)
tree53b5d6d4c8f3c498a9c9ebfb42d572a2553bfd4f /gold/testsuite
parent921b53228fa18e00beca6b19b3aa43c23903b900 (diff)
downloadgdb-b9b2ae8bbf911b7762fe41ecbb5dbc64a8e2b5a7.zip
gdb-b9b2ae8bbf911b7762fe41ecbb5dbc64a8e2b5a7.tar.gz
gdb-b9b2ae8bbf911b7762fe41ecbb5dbc64a8e2b5a7.tar.bz2
PR ld/14265
* script-sections.cc (Sections_element::output_section_name): Add keep return parameter. (Output_section_element::match_name): Add keep return parameter. Return the value of the keep_ member. * script-sections.h (class Output_section): Update output_section_name prototype. * layout.cc (Layout::keep_input_section): New public member function. (Layout::choose_output_section): Pass keep parameter to output_section_name. * layout.h (class Layout): Add keep_input_section. * object.cc (Sized_relobj_file::do_layout): Check for kept input sections. * testsuite/Makefile.am: Add a test. * testsuite/Makefile.in: Regenerate. * testsuite/pr14265.c: Source file for the test. * testsuite/pr14265.t: Linker script for the test. * testsuite/pr14265.sh: Shell script for the test. * ld-gc/gc.exp: Add a new test. * ld-gc/pr14265.c: Source file for the new test. * ld-gc/pr14265.t: Linker script for the new test. * ld-gc/pr14265.d: Expected symbol dump.
Diffstat (limited to 'gold/testsuite')
-rw-r--r--gold/testsuite/Makefile.am10
-rw-r--r--gold/testsuite/Makefile.in16
-rw-r--r--gold/testsuite/pr14265.c20
-rwxr-xr-xgold/testsuite/pr14265.sh40
-rw-r--r--gold/testsuite/pr14265.t23
5 files changed, 105 insertions, 4 deletions
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am
index b8b88e8..0e98e6a 100644
--- a/gold/testsuite/Makefile.am
+++ b/gold/testsuite/Makefile.am
@@ -164,6 +164,16 @@ gc_orphan_section_test:gc_orphan_section_test.o gcctestdir/ld
gc_orphan_section_test.stdout: gc_orphan_section_test
$(TEST_NM) gc_orphan_section_test > gc_orphan_section_test.stdout
+check_SCRIPTS += pr14265.sh
+check_DATA += pr14265.stdout
+MOSTLYCLEANFILES += pr14265
+pr14265.o: pr14265.c
+ $(COMPILE) -O0 -c -o $@ $<
+pr14265: pr14265.o
+ $(LINK) -Bgcctestdir/ -Wl,--gc-sections -T $(srcdir)/pr14265.t -o $@ $<
+pr14265.stdout: pr14265
+ $(TEST_NM) --format=bsd --numeric-sort $< > $@
+
check_SCRIPTS += icf_test.sh
check_DATA += icf_test.stdout
MOSTLYCLEANFILES += icf_test
diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in
index 4887827..a3a4506 100644
--- a/gold/testsuite/Makefile.in
+++ b/gold/testsuite/Makefile.in
@@ -76,7 +76,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_2 = incremental_test.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_comdat_test.sh gc_tls_test.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_orphan_section_test.sh \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_test.sh \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ pr14265.sh icf_test.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_keep_unique_test.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_test.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_so_test.sh \
@@ -104,7 +104,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_comdat_test.stdout \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_tls_test.stdout \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_orphan_section_test.stdout \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_test.stdout \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ pr14265.stdout icf_test.stdout \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_keep_unique_test.stdout \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_test_1.stdout \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_test_2.stdout \
@@ -118,8 +118,8 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_plt_shared.so debug_msg.err
@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_4 = incremental_test \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_comdat_test gc_tls_test \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_orphan_section_test icf_test \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_keep_unique_test \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_orphan_section_test pr14265 \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_test icf_keep_unique_test \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_test icf_safe_so_test \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ final_layout \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_virtual_function_folding_test \
@@ -3661,6 +3661,8 @@ gc_tls_test.sh.log: gc_tls_test.sh
@p='gc_tls_test.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
gc_orphan_section_test.sh.log: gc_orphan_section_test.sh
@p='gc_orphan_section_test.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+pr14265.sh.log: pr14265.sh
+ @p='pr14265.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
icf_test.sh.log: icf_test.sh
@p='icf_test.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
icf_keep_unique_test.sh.log: icf_keep_unique_test.sh
@@ -4272,6 +4274,12 @@ uninstall-am:
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -Wl,--gc-sections gc_orphan_section_test.o
@GCC_TRUE@@NATIVE_LINKER_TRUE@gc_orphan_section_test.stdout: gc_orphan_section_test
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_NM) gc_orphan_section_test > gc_orphan_section_test.stdout
+@GCC_TRUE@@NATIVE_LINKER_TRUE@pr14265.o: pr14265.c
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(COMPILE) -O0 -c -o $@ $<
+@GCC_TRUE@@NATIVE_LINKER_TRUE@pr14265: pr14265.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(LINK) -Bgcctestdir/ -Wl,--gc-sections -T $(srcdir)/pr14265.t -o $@ $<
+@GCC_TRUE@@NATIVE_LINKER_TRUE@pr14265.stdout: pr14265
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_NM) --format=bsd --numeric-sort $< > $@
@GCC_TRUE@@NATIVE_LINKER_TRUE@icf_test.o: icf_test.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -O0 -c -ffunction-sections -g -o $@ $<
@GCC_TRUE@@NATIVE_LINKER_TRUE@icf_test: icf_test.o gcctestdir/ld
diff --git a/gold/testsuite/pr14265.c b/gold/testsuite/pr14265.c
new file mode 100644
index 0000000..6bb8f9a
--- /dev/null
+++ b/gold/testsuite/pr14265.c
@@ -0,0 +1,20 @@
+int foo0 __attribute__((used,section(".foo0.0")));
+int foo1 __attribute__((used,section(".foo1.0")));
+int foo2 __attribute__((used,section(".foo2.0")));
+
+extern unsigned long __foo0_start;
+extern unsigned long __foo0_end;
+
+extern unsigned long __foo1_start;
+extern unsigned long __foo1_end;
+
+extern unsigned long __foo2_start;
+extern unsigned long __foo2_end;
+
+int
+main (void)
+{
+ return ((__foo0_end - __foo0_start) -
+ (__foo1_end - __foo1_start) -
+ (__foo2_end - __foo2_start));
+}
diff --git a/gold/testsuite/pr14265.sh b/gold/testsuite/pr14265.sh
new file mode 100755
index 0000000..4e477b2
--- /dev/null
+++ b/gold/testsuite/pr14265.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+
+# pr14265.sh -- test --gc-sections with KEEP
+
+# Copyright 2012 Free Software Foundation, Inc.
+# Written by Nick Clifton <nickc@redhat.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.
+
+
+check()
+{
+ if ! grep -q "$2" "$1"
+ then
+ echo "Garbage collection failed to KEEP :"
+ echo " $2"
+ exit 1
+ fi
+}
+
+check pr14265.stdout "foo1_start"
+check pr14265.stdout "foo1_end"
+check pr14265.stdout "foo2_start"
+check pr14265.stdout "foo2_end"
+
diff --git a/gold/testsuite/pr14265.t b/gold/testsuite/pr14265.t
new file mode 100644
index 0000000..eec56e7
--- /dev/null
+++ b/gold/testsuite/pr14265.t
@@ -0,0 +1,23 @@
+SECTIONS
+{
+ .text : { *(.text) }
+
+ __foo0_start = .;
+ .foo0 : { *(.foo0.*) }
+ __foo0_end = .;
+
+ __foo1_start = .;
+ .foo1 : { KEEP(*(.foo1.*)) }
+ __foo1_end = .;
+
+ .foo2 : {
+ __foo2_start = .;
+ KEEP(*(.foo2.*))
+ __foo2_end = .;
+ }
+}
+
+
+ASSERT (__foo1_start < __foo1_end, "foo1 not KEPT");
+ASSERT ((__foo1_end - __foo1_start) == (__foo2_end - __foo2_start),"foo2 not KEPT");
+