Clear SHF_COMPRESSED flag bit from input to output
authorH.J. Lu <hjl.tools@gmail.com>
Mon, 20 Jul 2015 17:14:26 +0000 (10:14 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Mon, 20 Jul 2015 17:14:35 +0000 (10:14 -0700)
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.

gold/ChangeLog
gold/layout.cc
gold/testsuite/Makefile.am
gold/testsuite/Makefile.in
gold/testsuite/pr18689.c [new file with mode: 0644]
gold/testsuite/pr18689.sh [new file with mode: 0755]

index de73b7de65c6c93b250f667851a215aed3c83564..596c1d7a942a8fcc734dd7b1cef4f4b10e6a93cd 100644 (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>
        Cary Coutant  <ccoutant@gmail.com>
 
index 142fd900d29a2dcf395f8223e6e2e32fe63dbf5b..b454c101b71ddf1cabc965719c6174374e4e3fa8 100644 (file)
@@ -1160,8 +1160,12 @@ Layout::layout(Sized_relobj_file<size, big_endian>* object, unsigned int shndx,
   if (parameters->options().relocatable()
       && (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);
-      os = this->make_output_section(name, sh_type, shdr.get_sh_flags(),
+      os = this->make_output_section(name, sh_type, flags,
                                     ORDER_INVALID, false);
     }
   else
index cf56c32f3ae7ab1e9f11965f93ce85c3aba81894..4b0027397e578d34dae35357aaa2470d069f422b 100644 (file)
@@ -1424,6 +1424,22 @@ flagstest_o_specialfile_and_compress_debug_sections: flagstest_debug.o \
        chmod a+x $@
        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.
 check_PROGRAMS += flagstest_o_ttext_1
 flagstest_o_ttext_1: flagstest_debug.o gcctestdir/ld
index fc1063952ffe60761832f2bd0029eca936c7ffb2..720558bacc19f354bc74d51d5424389bdc0448bb 100644 (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_so.err \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ debug_msg_ndebug.err \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ undef_symbol.err \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_o_ttext_2 \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ undef_symbol.err pr18689a.o \
+@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@ justsyms_lib binary.txt \
 @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
 @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@ undef_symbol.sh ver_test_1.sh \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_2.sh ver_test_4.sh \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_5.sh ver_test_7.sh \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_10.sh relro_test.sh \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ undef_symbol.sh pr18689.sh \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_1.sh ver_test_2.sh \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_4.sh ver_test_5.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@ script_test_3.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.cmp \
 @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@ ver_test_1.syms ver_test_2.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)
 undef_symbol.sh.log: undef_symbol.sh
        @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
        @p='ver_test_1.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
 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@ chmod a+x $@
 @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@ $(CXXLINK) -Bgcctestdir/ -o $@ $< -Wl,-Ttext,0x400000 -Wl,-Tdata,0x800000
 @GCC_TRUE@@NATIVE_LINKER_TRUE@flagstest_o_ttext_2: flagstest_debug.o gcctestdir/ld
diff --git a/gold/testsuite/pr18689.c b/gold/testsuite/pr18689.c
new file mode 100644 (file)
index 0000000..9d841c9
--- /dev/null
@@ -0,0 +1 @@
+/* Dummy file.  */
diff --git a/gold/testsuite/pr18689.sh b/gold/testsuite/pr18689.sh
new file mode 100755 (executable)
index 0000000..822ed11
--- /dev/null
@@ -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
This page took 0.045294 seconds and 4 git commands to generate.