aboutsummaryrefslogtreecommitdiff
path: root/gold
diff options
context:
space:
mode:
authorCary Coutant <ccoutant@google.com>2009-02-25 19:05:21 +0000
committerCary Coutant <ccoutant@google.com>2009-02-25 19:05:21 +0000
commit401a9a73922f3b3ad7099859b7d3bc3c80397f3a (patch)
tree6a74503c6b496930ef074603db18cb9c9b5dbbd2 /gold
parent784788d2f758e76488ce5c12242fb97907d27b53 (diff)
downloadgdb-401a9a73922f3b3ad7099859b7d3bc3c80397f3a.zip
gdb-401a9a73922f3b3ad7099859b7d3bc3c80397f3a.tar.gz
gdb-401a9a73922f3b3ad7099859b7d3bc3c80397f3a.tar.bz2
* 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.
Diffstat (limited to 'gold')
-rw-r--r--gold/ChangeLog12
-rw-r--r--gold/Makefile.in18
-rw-r--r--gold/layout.cc4
-rw-r--r--gold/testsuite/Makefile.am8
-rw-r--r--gold/testsuite/Makefile.in9
-rw-r--r--gold/testsuite/script_test_5.cc45
-rwxr-xr-xgold/testsuite/script_test_5.sh43
-rw-r--r--gold/testsuite/script_test_5.t40
8 files changed, 168 insertions, 11 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog
index f2d367f..8630e50 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -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.
diff --git a/gold/Makefile.in b/gold/Makefile.in
index a071bcf..20ad5b4 100644
--- a/gold/Makefile.in
+++ b/gold/Makefile.in
@@ -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@
diff --git a/gold/layout.cc b/gold/layout.cc
index 0977557..2bc1483 100644
--- a/gold/layout.cc
+++ b/gold/layout.cc
@@ -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;
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am
index c318718..46c661f 100644
--- a/gold/testsuite/Makefile.am
+++ b/gold/testsuite/Makefile.am
@@ -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
diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in
index c1ad9c3..6703f6f 100644
--- a/gold/testsuite/Makefile.in
+++ b/gold/testsuite/Makefile.in
@@ -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
index 0000000..b5aec29
--- /dev/null
+++ b/gold/testsuite/script_test_5.cc
@@ -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
index 0000000..9415483
--- /dev/null
+++ b/gold/testsuite/script_test_5.sh
@@ -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
index 0000000..b5e83aa
--- /dev/null
+++ b/gold/testsuite/script_test_5.t
@@ -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) }
+}