+2010-05-19 Rafael Espindola <espindola@google.com>
+
+ * script-sections.cc (Output_section_definition::allocate_to_segment):
+ Update the phdrs_list even when the output section is NULL.
+ * testsuite/Makefile.am: Add test.
+ * testsuite/Makefile.in: Regenerate.
+ * testsuite/script_test_9.cc: New.
+ * testsuite/script_test_9.sh: New.
+ * testsuite/script_test_9.t: New.
+
2010-05-19 Doug Kwan <dougkwan@google.com>
* arm.cc (Arm_input_section::original_size): New method.
Output_section_definition::allocate_to_segment(String_list** phdrs_list,
bool* orphan)
{
+ // Update phdrs_list even if we don't have an output section. It
+ // might be used by the following sections.
+ if (this->phdrs_ != NULL)
+ *phdrs_list = this->phdrs_;
+
if (this->output_section_ == NULL)
return NULL;
if ((this->output_section_->flags() & elfcpp::SHF_ALLOC) == 0)
return NULL;
*orphan = false;
- if (this->phdrs_ != NULL)
- *phdrs_list = this->phdrs_;
return this->output_section_;
}
script_test_8.stdout: script_test_8
$(TEST_READELF) -SlW script_test_8 > script_test_8.stdout
+
+check_SCRIPTS += script_test_9.sh
+check_DATA += script_test_9.stdout
+script_test_9.o: script_test_9.cc
+ $(CXXCOMPILE) -O0 -c -o $@ $<
+script_test_9: gcctestdir/ld $(srcdir)/script_test_9.t script_test_9.o
+ $(CXXLINK) -Bgcctestdir/ script_test_9.o -T $(srcdir)/script_test_9.t
+script_test_9.stdout: script_test_9
+ $(TEST_READELF) -lW script_test_9 > script_test_9.stdout
+
+
# Test --dynamic-list, --dynamic-list-data, --dynamic-list-cpp-new,
# and --dynamic-list-cpp-typeinfo
@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_5.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_6.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_7.sh \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_8.sh dynamic_list.sh
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_8.sh \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_9.sh dynamic_list.sh
# Create the data files that debug_msg.sh analyzes.
@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_6.stdout \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_7.stdout \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_8.stdout \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_9.stdout \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ dynamic_list.stdout
@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_3 = incremental_test \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_comdat_test gc_tls_test \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ -Wl,-Ttext=0x20001000 -Wl,-Tdata=0x20200000 -Wl,-Tbss=0x20400000
@GCC_TRUE@@NATIVE_LINKER_TRUE@script_test_8.stdout: script_test_8
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -SlW script_test_8 > script_test_8.stdout
+@GCC_TRUE@@NATIVE_LINKER_TRUE@script_test_9.o: script_test_9.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -O0 -c -o $@ $<
+@GCC_TRUE@@NATIVE_LINKER_TRUE@script_test_9: gcctestdir/ld $(srcdir)/script_test_9.t script_test_9.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ script_test_9.o -T $(srcdir)/script_test_9.t
+@GCC_TRUE@@NATIVE_LINKER_TRUE@script_test_9.stdout: script_test_9
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -lW script_test_9 > script_test_9.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 \
--- /dev/null
+// script_test_9.cc -- a test case for gold
+
+// Copyright 2010 Free Software Foundation, Inc.
+// Written by Rafael Avila de Espindola <espindola@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.
+
+int main() {
+ return 0;
+}
--- /dev/null
+#!/bin/sh
+
+# script_test_9.sh -- Check that the script_test_9.t script has placed
+# .init and .text in the same segment.
+
+# Copyright 2010 Free Software Foundation, Inc.
+# Written by Rafael Avila de Espindola <espindola@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.
+
+check()
+{
+ if ! grep -q "$2" "$1"
+ then
+ echo "Did not find expected section in $1:"
+ echo " $2"
+ echo ""
+ echo "Actual output below:"
+ cat "$1"
+ exit 1
+ fi
+}
+
+check script_test_9.stdout "LOAD .*R E "
+check script_test_9.stdout "LOAD .*RW "
+check script_test_9.stdout "00 .*\.text .init"
+check script_test_9.stdout "01 .*\.data "
--- /dev/null
+PHDRS
+{
+ text PT_LOAD FLAGS(5);
+ data PT_LOAD FLAGS(6);
+}
+
+SECTIONS
+{
+ .init :
+ {
+ } :text
+ .text :
+ {
+ }
+ .data :
+ {
+ } :data
+}