Fix earlier ChangeLog entry to give Igor credit, add testcases.

2016-12-01  Cary Coutant  <ccoutant@gmail.com>
	    Igor Kudrin  <ikudrin@accesssoftek.com>

	PR gold/20717
	* script-sections.cc (Script_sections): Set *keep to false when
	no match.

2016-12-11  Igor Kudrin  <ikudrin@accesssoftek.com>

	PR gold/20717
	* testsuite/Makefile.am (pr20717): New test.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/pr20717.c: New test source file.
	* testsuite/pr20717.sh: New test script.
	* testsuite/pr20717.t: New test linker script.
This commit is contained in:
Igor Kudrin 2016-12-11 20:31:09 -08:00 committed by Cary Coutant
parent 5d9f66cb84
commit cc90de4973
7 changed files with 81 additions and 6 deletions

View File

@ -1,3 +1,12 @@
2016-12-11 Igor Kudrin <ikudrin@accesssoftek.com>
PR gold/20717
* testsuite/Makefile.am (pr20717): New test.
* testsuite/Makefile.in: Regenerate.
* testsuite/pr20717.c: New test source file.
* testsuite/pr20717.sh: New test script.
* testsuite/pr20717.t: New test linker script.
2016-12-11 Cary Coutant <ccoutant@gmail.com>
PR gold/16711
@ -80,6 +89,7 @@
* testsuite/file_in_many_sections_test.sh: New script.
2016-12-01 Cary Coutant <ccoutant@gmail.com>
Igor Kudrin <ikudrin@accesssoftek.com>
PR gold/20717
* script-sections.cc (Script_sections): Set *keep to false when

View File

@ -87,8 +87,8 @@ subdir = .
DIST_COMMON = NEWS README ChangeLog $(srcdir)/Makefile.in \
$(srcdir)/Makefile.am $(top_srcdir)/configure \
$(am__configure_deps) $(srcdir)/config.in \
$(srcdir)/../mkinstalldirs $(top_srcdir)/po/Make-in ffsll.c \
pread.c mremap.c ftruncate.c yyscript.h yyscript.c \
$(srcdir)/../mkinstalldirs $(top_srcdir)/po/Make-in mremap.c \
ffsll.c ftruncate.c pread.c yyscript.h yyscript.c \
$(srcdir)/../depcomp $(srcdir)/../ylwrap
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \

View File

@ -220,6 +220,16 @@ pr14265: pr14265.o
pr14265.stdout: pr14265
$(TEST_NM) --format=bsd --numeric-sort $< > $@
check_SCRIPTS += pr20717.sh
check_DATA += pr20717.stdout
MOSTLYCLEANFILES += pr20717
pr20717.o: pr20717.c
$(COMPILE) -O0 -ffunction-sections -c -o $@ $<
pr20717: pr20717.o gcctestdir/ld $(srcdir)/pr20717.t
$(LINK) -Bgcctestdir/ -Wl,--gc-sections -Wl,-T,$(srcdir)/pr20717.t -o $@ $<
pr20717.stdout: pr20717
$(TEST_NM) $< > $@
check_SCRIPTS += gc_dynamic_list_test.sh
check_DATA += gc_dynamic_list_test.stdout
MOSTLYCLEANFILES += gc_dynamic_list_test

View File

@ -77,7 +77,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@ pr14265.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ pr14265.sh pr20717.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_dynamic_list_test.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_test.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_keep_unique_test.sh \
@ -96,7 +96,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@ pr14265.stdout \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ pr14265.stdout pr20717.stdout \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_dynamic_list_test.stdout \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_test.map \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_keep_unique_test.stdout \
@ -121,8 +121,8 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_test.cmdline \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_comdat_test gc_tls_test \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_orphan_section_test pr14265 \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_dynamic_list_test icf_test \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_test.map \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ pr20717 gc_dynamic_list_test \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_test icf_test.map \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_keep_unique_test \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_test icf_safe_test.map \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_so_test \
@ -5027,6 +5027,8 @@ 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)
pr20717.sh.log: pr20717.sh
@p='pr20717.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
gc_dynamic_list_test.sh.log: gc_dynamic_list_test.sh
@p='gc_dynamic_list_test.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
icf_test.sh.log: icf_test.sh
@ -5802,6 +5804,12 @@ uninstall-am:
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(LINK) -Bgcctestdir/ -Wl,--gc-sections -Wl,-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@pr20717.o: pr20717.c
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(COMPILE) -O0 -ffunction-sections -c -o $@ $<
@GCC_TRUE@@NATIVE_LINKER_TRUE@pr20717: pr20717.o gcctestdir/ld $(srcdir)/pr20717.t
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(LINK) -Bgcctestdir/ -Wl,--gc-sections -Wl,-T,$(srcdir)/pr20717.t -o $@ $<
@GCC_TRUE@@NATIVE_LINKER_TRUE@pr20717.stdout: pr20717
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_NM) $< > $@
@GCC_TRUE@@NATIVE_LINKER_TRUE@gc_dynamic_list_test.o: gc_dynamic_list_test.c
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(COMPILE) -c -ffunction-sections -o $@ $<
@GCC_TRUE@@NATIVE_LINKER_TRUE@gc_dynamic_list_test: gc_dynamic_list_test.o gcctestdir/ld $(srcdir)/gc_dynamic_list_test.t

3
gold/testsuite/pr20717.c Normal file
View File

@ -0,0 +1,3 @@
void unused(void);
void unused(void) {}
int main(void) {return 0;}

40
gold/testsuite/pr20717.sh Executable file
View File

@ -0,0 +1,40 @@
#!/bin/sh
# pr20717.sh -- test --gc-sections for an unused orphan section
# when the last section in the linker script has a KEEP statement.
# Copyright (C) 2016 Free Software Foundation, Inc.
# Written by Igor Kudrin <ikudrin@accesssoftek.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()
{
file=$1
pattern=$2
if grep -q "$pattern" "$file"
then
echo "Garbage collection failed to collect :"
echo " $pattern"
exit 1
fi
}
check pr20717.stdout "unused"

4
gold/testsuite/pr20717.t Normal file
View File

@ -0,0 +1,4 @@
SECTIONS
{
.dummy : { KEEP (*(.dummy)) }
}