Clear SHF_COMPRESSED flag bit from input to output

For relocatable link, we should clear the SHF_COMPRESSED flag bit from
input group section.

	PR gold/18689
	* layout.cc (Layout::layout): Clear the SHF_COMPRESSED flag bit
	from input group section for relocatable link.
	* testsuite/Makefile.am (check_SCRIPTS): Add pr18689.sh.
	(check_DATA): Add pr18689.stdout.
	(MOSTLYCLEANFILES): Add pr18689a.o pr18689b.o.
	(pr18689.stdout): New rule.
	(pr18689a.o): Likewise.
	(pr18689b.o): Likewise.
	(pr18689.o): Likewise.
	* testsuite/pr18689.c: New file.
	* testsuite/pr18689.sh: Likewise.
	* testsuite/Makefile.in: Regenerated.
This commit is contained in:
H.J. Lu 2015-07-20 10:14:26 -07:00
parent a3b5281eb9
commit f54f5e31ce
6 changed files with 88 additions and 7 deletions

View File

@ -1,3 +1,19 @@
2015-07-20 H.J. Lu <hongjiu.lu@intel.com>
PR gold/18689
* layout.cc (Layout::layout): Clear the SHF_COMPRESSED flag bit
from input group section for relocatable link.
* testsuite/Makefile.am (check_SCRIPTS): Add pr18689.sh.
(check_DATA): Add pr18689.stdout.
(MOSTLYCLEANFILES): Add pr18689a.o pr18689b.o.
(pr18689.stdout): New rule.
(pr18689a.o): Likewise.
(pr18689b.o): Likewise.
(pr18689.o): Likewise.
* testsuite/pr18689.c: New file.
* testsuite/pr18689.sh: Likewise.
* testsuite/Makefile.in: Regenerated.
2015-07-20 Yiran Wang <yiran@google.com> 2015-07-20 Yiran Wang <yiran@google.com>
Cary Coutant <ccoutant@gmail.com> Cary Coutant <ccoutant@gmail.com>

View File

@ -1160,8 +1160,12 @@ Layout::layout(Sized_relobj_file<size, big_endian>* object, unsigned int shndx,
if (parameters->options().relocatable() if (parameters->options().relocatable()
&& (shdr.get_sh_flags() & elfcpp::SHF_GROUP) != 0) && (shdr.get_sh_flags() & elfcpp::SHF_GROUP) != 0)
{ {
// Some flags in the input section should not be automatically
// copied to the output section.
elfcpp::Elf_Xword flags = (shdr.get_sh_flags()
& ~ elfcpp::SHF_COMPRESSED);
name = this->namepool_.add(name, true, NULL); name = this->namepool_.add(name, true, NULL);
os = this->make_output_section(name, sh_type, shdr.get_sh_flags(), os = this->make_output_section(name, sh_type, flags,
ORDER_INVALID, false); ORDER_INVALID, false);
} }
else else

View File

@ -1424,6 +1424,22 @@ flagstest_o_specialfile_and_compress_debug_sections: flagstest_debug.o \
chmod a+x $@ chmod a+x $@
test -s $@ test -s $@
check_SCRIPTS += pr18689.sh
check_DATA += pr18689.stdout
MOSTLYCLEANFILES += pr18689a.o pr18689b.o
pr18689.stdout: pr18689b.o
$(TEST_READELF) -SW $< > $@
pr18689a.o: pr18689.o ../ld-new
../ld-new -r -o $@ $<
pr18689b.o: pr18689a.o ../ld-new
../ld-new -r -o $@ $<
pr18689.o: pr18689.c gcctestdir/as
$(COMPILE) -Bgcctestdir/ -ggdb3 -g -Wa,--compress-debug-sections=zlib-gabi -c -w -o $@ $(srcdir)/pr18689.c
# Test -TText and -Tdata. # Test -TText and -Tdata.
check_PROGRAMS += flagstest_o_ttext_1 check_PROGRAMS += flagstest_o_ttext_1
flagstest_o_ttext_1: flagstest_debug.o gcctestdir/ld flagstest_o_ttext_1: flagstest_debug.o gcctestdir/ld

View File

@ -280,8 +280,8 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ debug_msg_cdebug_gabi.err \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ debug_msg_cdebug_gabi.err \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ debug_msg_so.err \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ debug_msg_so.err \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ debug_msg_ndebug.err \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ debug_msg_ndebug.err \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ undef_symbol.err \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ undef_symbol.err pr18689a.o \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_o_ttext_2 \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ pr18689b.o flagstest_o_ttext_2 \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_11.a protected_3.err \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_11.a protected_3.err \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ justsyms_lib binary.txt \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ justsyms_lib binary.txt \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_matching_test.stdout \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_matching_test.stdout \
@ -323,10 +323,11 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
# and --dynamic-list-cpp-typeinfo # and --dynamic-list-cpp-typeinfo
@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_35 = debug_msg.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_35 = debug_msg.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ missing_key_func.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ missing_key_func.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ undef_symbol.sh ver_test_1.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ undef_symbol.sh pr18689.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_2.sh ver_test_4.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_1.sh ver_test_2.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_5.sh ver_test_7.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_4.sh ver_test_5.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_10.sh relro_test.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_7.sh ver_test_10.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ relro_test.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_matching_test.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_matching_test.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_3.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_3.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_4.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_4.sh \
@ -365,6 +366,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_compress_debug_sections_gabi.stdout \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_compress_debug_sections_gabi.stdout \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_compress_debug_sections_gabi.cmp \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_compress_debug_sections_gabi.cmp \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_compress_debug_sections_gabi.check \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_compress_debug_sections_gabi.check \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ pr18689.stdout \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_o_ttext_2 \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_o_ttext_2 \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_1.syms ver_test_2.syms \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_1.syms ver_test_2.syms \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_4.syms ver_test_5.syms \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_4.syms ver_test_5.syms \
@ -4414,6 +4416,8 @@ missing_key_func.sh.log: missing_key_func.sh
@p='missing_key_func.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) @p='missing_key_func.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
undef_symbol.sh.log: undef_symbol.sh undef_symbol.sh.log: undef_symbol.sh
@p='undef_symbol.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) @p='undef_symbol.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
pr18689.sh.log: pr18689.sh
@p='pr18689.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
ver_test_1.sh.log: ver_test_1.sh ver_test_1.sh.log: ver_test_1.sh
@p='ver_test_1.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) @p='ver_test_1.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
ver_test_2.sh.log: ver_test_2.sh ver_test_2.sh.log: ver_test_2.sh
@ -5675,6 +5679,18 @@ uninstall-am:
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -o /dev/stdout $< -Wl,--compress-debug-sections=zlib 2>&1 | cat > $@ @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -o /dev/stdout $< -Wl,--compress-debug-sections=zlib 2>&1 | cat > $@
@GCC_TRUE@@NATIVE_LINKER_TRUE@ chmod a+x $@ @GCC_TRUE@@NATIVE_LINKER_TRUE@ chmod a+x $@
@GCC_TRUE@@NATIVE_LINKER_TRUE@ test -s $@ @GCC_TRUE@@NATIVE_LINKER_TRUE@ test -s $@
@GCC_TRUE@@NATIVE_LINKER_TRUE@pr18689.stdout: pr18689b.o
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -SW $< > $@
@GCC_TRUE@@NATIVE_LINKER_TRUE@pr18689a.o: pr18689.o ../ld-new
@GCC_TRUE@@NATIVE_LINKER_TRUE@ ../ld-new -r -o $@ $<
@GCC_TRUE@@NATIVE_LINKER_TRUE@pr18689b.o: pr18689a.o ../ld-new
@GCC_TRUE@@NATIVE_LINKER_TRUE@ ../ld-new -r -o $@ $<
@GCC_TRUE@@NATIVE_LINKER_TRUE@pr18689.o: pr18689.c gcctestdir/as
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(COMPILE) -Bgcctestdir/ -ggdb3 -g -Wa,--compress-debug-sections=zlib-gabi -c -w -o $@ $(srcdir)/pr18689.c
@GCC_TRUE@@NATIVE_LINKER_TRUE@flagstest_o_ttext_1: flagstest_debug.o gcctestdir/ld @GCC_TRUE@@NATIVE_LINKER_TRUE@flagstest_o_ttext_1: flagstest_debug.o gcctestdir/ld
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -o $@ $< -Wl,-Ttext,0x400000 -Wl,-Tdata,0x800000 @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -o $@ $< -Wl,-Ttext,0x400000 -Wl,-Tdata,0x800000
@GCC_TRUE@@NATIVE_LINKER_TRUE@flagstest_o_ttext_2: flagstest_debug.o gcctestdir/ld @GCC_TRUE@@NATIVE_LINKER_TRUE@flagstest_o_ttext_2: flagstest_debug.o gcctestdir/ld

1
gold/testsuite/pr18689.c Normal file
View File

@ -0,0 +1 @@
/* Dummy file. */

28
gold/testsuite/pr18689.sh Executable file
View File

@ -0,0 +1,28 @@
#!/bin/sh
# pr18689.sh -- a test case for compressed .debug_macro sections.
# Copyright (C) 2015 Free Software Foundation, Inc.
# 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.
set -e
egrep -q "..debug_macro[ ]+*" pr18689.stdout
exit 0