* layout.cc (Layout::choose_output_section): Don't rename sections
authorCary Coutant <ccoutant@google.com>
Wed, 25 Feb 2009 19:05:21 +0000 (19:05 +0000)
committerCary Coutant <ccoutant@google.com>
Wed, 25 Feb 2009 19:05:21 +0000 (19:05 +0000)
when using a linker script that has a SECTIONS clause.
* Makefile.in: Regenerate.

* testsuite/Makefile.am (script_test_5.sh): New test case.
* testsuite/Makefile.in: Regenerate.
* testsuite/script_test_5.cc: New file.
* testsuite/script_test_5.sh: New file.
* testsuite/script_test_5.t: New file.

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

index f2d367f84fca41b41a7c12998ce069930e9a263c..8630e5016bd63455b76e57ddc5d1bf56c4655fad 100644 (file)
@@ -1,3 +1,15 @@
+2009-02-25  Cary Coutant  <ccoutant@google.com>
+
+       * layout.cc (Layout::choose_output_section): Don't rename sections
+       when using a linker script that has a SECTIONS clause.
+       * Makefile.in: Regenerate.
+
+       * testsuite/Makefile.am (script_test_5.sh): New test case.
+       * testsuite/Makefile.in: Regenerate.
+       * testsuite/script_test_5.cc: New file.
+       * testsuite/script_test_5.sh: New file.
+       * testsuite/script_test_5.t: New file.
+
 2009-02-13  Rafael Avila de Espindola  <espindola@google.com>
 
        * archive.cc (Archive::include_member): Update calls to add_symbols.
index a071bcf81c2346883313c8c0e3d3191846ce5362..20ad5b4f28f81ca5e24cd1334c8137bbd0672ec8 100644 (file)
@@ -79,15 +79,14 @@ am__objects_1 = archive.$(OBJEXT) binary.$(OBJEXT) common.$(OBJEXT) \
        cref.$(OBJEXT) defstd.$(OBJEXT) descriptors.$(OBJEXT) \
        dirsearch.$(OBJEXT) dynobj.$(OBJEXT) dwarf_reader.$(OBJEXT) \
        ehframe.$(OBJEXT) errors.$(OBJEXT) expression.$(OBJEXT) \
-       fileread.$(OBJEXT) gc.$(OBJEXT) \
-      gold.$(OBJEXT) gold-threads.$(OBJEXT) \
-       layout.$(OBJEXT) mapfile.$(OBJEXT) merge.$(OBJEXT) \
-       object.$(OBJEXT) options.$(OBJEXT) output.$(OBJEXT) \
-       parameters.$(OBJEXT) plugin.$(OBJEXT) readsyms.$(OBJEXT) \
-       reduced_debug_output.$(OBJEXT) reloc.$(OBJEXT) \
-       resolve.$(OBJEXT) script-sections.$(OBJEXT) script.$(OBJEXT) \
-       stringpool.$(OBJEXT) symtab.$(OBJEXT) target-select.$(OBJEXT) \
-       version.$(OBJEXT) workqueue.$(OBJEXT) \
+       fileread.$(OBJEXT) gc.$(OBJEXT) gold.$(OBJEXT) \
+       gold-threads.$(OBJEXT) layout.$(OBJEXT) mapfile.$(OBJEXT) \
+       merge.$(OBJEXT) object.$(OBJEXT) options.$(OBJEXT) \
+       output.$(OBJEXT) parameters.$(OBJEXT) plugin.$(OBJEXT) \
+       readsyms.$(OBJEXT) reduced_debug_output.$(OBJEXT) \
+       reloc.$(OBJEXT) resolve.$(OBJEXT) script-sections.$(OBJEXT) \
+       script.$(OBJEXT) stringpool.$(OBJEXT) symtab.$(OBJEXT) \
+       target-select.$(OBJEXT) version.$(OBJEXT) workqueue.$(OBJEXT) \
        workqueue-threads.$(OBJEXT)
 am__objects_2 =
 am__objects_3 = yyscript.$(OBJEXT)
@@ -549,6 +548,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/errors.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/expression.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fileread.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gc.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gold-threads.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gold.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/i386.Po@am__quote@
index 09775573c6d03837e4a664bf4e7dbada2df8c0ab..2bc14831a0190c07f9ddf1335318596e1f71c812 100644 (file)
@@ -426,7 +426,9 @@ Layout::choose_output_section(const Relobj* relobj, const char* name,
   // output section.
 
   size_t len = strlen(name);
-  if (is_input_section && !parameters->options().relocatable())
+  if (is_input_section
+      && !this->script_options_->saw_sections_clause()
+      && !parameters->options().relocatable())
     name = Layout::output_section_name(name, &len);
 
   Stringpool::Key name_key;
index c318718cd98376c924dd45f59e5c3eeacea9b4d1..46c661f05a8da20e8455185ac8e6ceae5ff2c0cd 100644 (file)
@@ -903,6 +903,14 @@ script_test_4: basic_test.o gcctestdir/ld $(srcdir)/script_test_4.t
 script_test_4.stdout: script_test_4
        $(TEST_READELF) -SlW script_test_4 > script_test_4.stdout
 
+check_SCRIPTS += script_test_5.sh
+check_DATA += script_test_5.stdout
+MOSTLYCLEANFILES += script_test_5.stdout
+script_test_5: script_test_5.o gcctestdir/ld $(srcdir)/script_test_5.t
+       $(CXXLINK) -Bgcctestdir/ script_test_5.o -T $(srcdir)/script_test_5.t
+script_test_5.stdout: script_test_5
+       $(TEST_READELF) -SW script_test_5 > script_test_5.stdout
+
 # Test --dynamic-list, --dynamic-list-data, --dynamic-list-cpp-new,
 # and --dynamic-list-cpp-typeinfo
 
index c1ad9c3ed8ee6fcd0acfe4bbeadeff979c3e549a..6703f6f66981ab08d65ba3f59f24f008c39e574a 100644 (file)
@@ -171,7 +171,8 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_7.sh ver_test_10.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 dynamic_list.sh
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_4.sh \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_5.sh dynamic_list.sh
 
 # Create the data files that debug_msg.sh analyzes.
 
@@ -188,6 +189,7 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_matching_test.stdout \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_3.stdout \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_4.stdout \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_5.stdout \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ dynamic_list.stdout
 @GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@am__append_8 = tls_test \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@       tls_pic_test \
@@ -234,6 +236,7 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_matching_test.stdout \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_3.stdout \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_4.stdout \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_5.stdout \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ dynamic_list.stdout
 
 # Test -o when emitting to a special file (such as something in /dev).
@@ -2467,6 +2470,10 @@ uninstall-am: uninstall-info-am
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ basic_test.o -T $(srcdir)/script_test_4.t
 @GCC_TRUE@@NATIVE_LINKER_TRUE@script_test_4.stdout: script_test_4
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -SlW script_test_4 > script_test_4.stdout
+@GCC_TRUE@@NATIVE_LINKER_TRUE@script_test_5: script_test_5.o gcctestdir/ld $(srcdir)/script_test_5.t
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ script_test_5.o -T $(srcdir)/script_test_5.t
+@GCC_TRUE@@NATIVE_LINKER_TRUE@script_test_5.stdout: script_test_5
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -SW script_test_5 > script_test_5.stdout
 @GCC_TRUE@@NATIVE_LINKER_TRUE@dynamic_list: basic_test.o gcctestdir/ld $(srcdir)/dynamic_list.t
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ basic_test.o \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@   -Wl,--dynamic-list $(srcdir)/dynamic_list.t \
diff --git a/gold/testsuite/script_test_5.cc b/gold/testsuite/script_test_5.cc
new file mode 100644 (file)
index 0000000..b5aec29
--- /dev/null
@@ -0,0 +1,45 @@
+// script_test_5.cc -- a test case for gold
+
+// Copyright 2009 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.
+
+// This program checks that the default renaming of ".text.xxx"
+// sections does not take place in the presence of a linker script
+// with a SECTIONS clause.
+
+bool
+t1() __attribute__ ((section (".text.foo")));
+
+bool
+t1()
+{
+  return 1;
+}
+
+// Main function.  Initialize variables and call test functions.
+
+int
+main()
+{
+  if (t1())
+    return 0;
+  else
+    return 1;
+}
diff --git a/gold/testsuite/script_test_5.sh b/gold/testsuite/script_test_5.sh
new file mode 100755 (executable)
index 0000000..9415483
--- /dev/null
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+# script_test_5.sh -- test linker script with uncovered sections
+
+# Copyright 2009 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.
+
+# This file goes with script_test_5.t, which is a linker script with
+# a SECTIONS clause that does not explicitly mention one of the input
+# sections in the test object file.  We check to make sure that the
+# correct output section is generated.
+
+check_count()
+{
+    if test "`grep -c "$2" "$1"`" != "$3"
+    then
+       echo "Did not find expected number ($3) of '$2' sections in $1"
+       echo ""
+       echo "Actual output below:"
+       cat "$1"
+       exit 1
+    fi
+}
+
+check_count script_test_5.stdout ".text " 1
+check_count script_test_5.stdout ".text.foo " 1
diff --git a/gold/testsuite/script_test_5.t b/gold/testsuite/script_test_5.t
new file mode 100644 (file)
index 0000000..b5e83aa
--- /dev/null
@@ -0,0 +1,40 @@
+/* script_test_5.t -- linker script test 5 for gold
+
+   Copyright 2009 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.  */
+
+/* We won't try to run this program, just ensure that it links
+   as expected.  */
+
+SECTIONS
+{
+  . = 0x10000000;
+
+  /* With luck this will be enough to get the program working.  */
+  .interp : { *(.interp) }
+  .text : { *(.text) }
+  . += 0x100000;
+  . = ALIGN(0x100);
+  .dynamic : { *(.dynamic) }
+  .data : { *(.data) }
+  . += 0x100000;
+  . = ALIGN(0x100);
+  .bss : { *(.bss) }
+}
This page took 0.036535 seconds and 4 git commands to generate.