* script-sections.cc (Script_sections::create_segments): Use
authorIan Lance Taylor <ian@airs.com>
Tue, 15 Apr 2008 22:50:37 +0000 (22:50 +0000)
committerIan Lance Taylor <ian@airs.com>
Tue, 15 Apr 2008 22:50:37 +0000 (22:50 +0000)
header_size_adjustment even when there is enough room for the
headers.
* testsuite/script_test_4.sh: New file.
* testsuite/script_test_4.t: New file.
* testsuite/Makefile.am (check_SCRIPTS): Add script_test_4.sh.
(check_DATA): Add script_test_4.stdout.
(MOSTLYCLEANFILES): Likewise.
(script_test_4): New target.
(script_test_4.stdout): New target.
* testsuite/Makefile.in: Rebuild.

gold/ChangeLog
gold/Makefile.in
gold/script-sections.cc
gold/testsuite/Makefile.am
gold/testsuite/Makefile.in
gold/testsuite/script_test_4.sh [new file with mode: 0755]
gold/testsuite/script_test_4.t [new file with mode: 0644]

index c0675fb6fad7c78960edc97ac065071b68f1638f..0c6148e3a5ea3e4d186421862a44ecc279774da4 100644 (file)
@@ -1,5 +1,17 @@
 2008-04-15  Ian Lance Taylor  <iant@google.com>
 
+       * script-sections.cc (Script_sections::create_segments): Use
+       header_size_adjustment even when there is enough room for the
+       headers.
+       * testsuite/script_test_4.sh: New file.
+       * testsuite/script_test_4.t: New file.
+       * testsuite/Makefile.am (check_SCRIPTS): Add script_test_4.sh.
+       (check_DATA): Add script_test_4.stdout.
+       (MOSTLYCLEANFILES): Likewise.
+       (script_test_4): New target.
+       (script_test_4.stdout): New target.
+       * testsuite/Makefile.in: Rebuild.
+
        * sparc.cc: Add definitions for Output_data_plt_sparc class
        constants.
 
index 4ca446879a34d43563e897a596b697f31cf83d24..0170ab0791100f35f6f485ad140ea632af65c7a6 100644 (file)
@@ -54,11 +54,10 @@ DIST_COMMON = README $(am__configure_deps) $(srcdir)/../config.guess \
 subdir = .
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
-       $(top_srcdir)/../config/gettext-sister.m4 \
        $(top_srcdir)/../config/lead-dot.m4 \
-       $(top_srcdir)/../config/nls.m4 $(top_srcdir)/../config/po.m4 \
-       $(top_srcdir)/../config/proginstall.m4 \
        $(top_srcdir)/../config/progtest.m4 \
+       $(top_srcdir)/../config/po.m4 $(top_srcdir)/../config/nls.m4 \
+       $(top_srcdir)/../config/gettext-sister.m4 \
        $(top_srcdir)/../bfd/warning.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
        $(ACLOCAL_M4)
@@ -187,6 +186,7 @@ GCC_FALSE = @GCC_FALSE@
 GCC_TRUE = @GCC_TRUE@
 GENCAT = @GENCAT@
 GMSGFMT = @GMSGFMT@
+GREP = @GREP@
 HAVE_ZLIB_FALSE = @HAVE_ZLIB_FALSE@
 HAVE_ZLIB_TRUE = @HAVE_ZLIB_TRUE@
 INCINTL = @INCINTL@
@@ -243,10 +243,9 @@ WARN_CFLAGS = @WARN_CFLAGS@
 WARN_CXXFLAGS = @WARN_CXXFLAGS@
 XGETTEXT = @XGETTEXT@
 YACC = @YACC@
+YFLAGS = @YFLAGS@
 ac_ct_CC = @ac_ct_CC@
 ac_ct_CXX = @ac_ct_CXX@
-ac_ct_RANLIB = @ac_ct_RANLIB@
-ac_ct_STRIP = @ac_ct_STRIP@
 am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
 am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
 am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
@@ -263,23 +262,30 @@ build_cpu = @build_cpu@
 build_os = @build_os@
 build_vendor = @build_vendor@
 datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
 exec_prefix = @exec_prefix@
 host = @host@
 host_alias = @host_alias@
 host_cpu = @host_cpu@
 host_os = @host_os@
 host_vendor = @host_vendor@
+htmldir = @htmldir@
 includedir = @includedir@
 infodir = @infodir@
 install_sh = @install_sh@
 libdir = @libdir@
 libexecdir = @libexecdir@
+localedir = @localedir@
 localstatedir = @localstatedir@
 mandir = @mandir@
 mkdir_p = @mkdir_p@
 oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
+psdir = @psdir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 sysconfdir = @sysconfdir@
index f6b655083e6108aa4d1fb1acb312c4c5727fcb70..55db831ae7e647efd8a34e126e5a7112ae3b96cb 100644 (file)
@@ -2706,18 +2706,17 @@ Script_sections::create_segments(Layout* layout)
 
   size_t sizeof_headers = this->total_header_size(layout);
 
-  if ((first_seg->paddr() & (abi_pagesize - 1)) >= sizeof_headers)
-    {
-      first_seg->set_addresses(first_seg->vaddr() - sizeof_headers,
-                              first_seg->paddr() - sizeof_headers);
-      return first_seg;
-    }
-
   uint64_t vma = first_seg->vaddr();
   uint64_t lma = first_seg->paddr();
 
   uint64_t subtract = this->header_size_adjustment(lma, sizeof_headers);
 
+  if ((lma & (abi_pagesize - 1)) >= sizeof_headers)
+    {
+      first_seg->set_addresses(vma - subtract, lma - subtract);
+      return first_seg;
+    }
+
   // If there is no room to squeeze in the headers, then punt.  The
   // resulting executable probably won't run on GNU/Linux, but we
   // trust that the user knows what they are doing.
index 8859520c2097287bb3f343c7c054e0960f0fcfe7..2f950ccae585cb2a647fb855ac4c6466a7a3d0f0 100644 (file)
@@ -734,5 +734,13 @@ script_test_3: basic_test.o gcctestdir/ld script_test_3.t
 script_test_3.stdout: script_test_3
        $(TEST_READELF) -SlW script_test_3 > script_test_3.stdout
 
+check_SCRIPTS += script_test_4.sh
+check_DATA += script_test_4.stdout
+MOSTLYCLEANFILES += script_test_4.stdout
+script_test_4: basic_test.o gcctestdir/ld $(srcdir)/script_test_4.t
+       $(CXXLINK) -Bgcctestdir/ basic_test.o -T $(srcdir)/script_test_4.t
+script_test_4.stdout: script_test_4
+       $(TEST_READELF) -SlW script_test_4 > script_test_4.stdout
+
 endif GCC
 endif NATIVE_LINKER
index b46861f2de95498fbf6888ac4abce83ff1a6c41c..b4b5000133fc9492cfa077777a8ade90dc0a4ded 100644 (file)
@@ -178,7 +178,8 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_4.sh ver_test_5.sh \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_7.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
 
 # Create the data files that debug_msg.sh analyzes.
 
@@ -193,13 +194,15 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_4.syms ver_test_5.syms \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_7.syms \
 @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_3.stdout \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_4.stdout
 @GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_12 = debug_msg.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@ ver_matching_test.stdout \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_3.stdout
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_3.stdout \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_4.stdout
 
 # Test -o when emitting to a special file (such as something in /dev).
 @GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_13 = flagstest_o_specialfile
@@ -819,6 +822,7 @@ GCC_FALSE = @GCC_FALSE@
 GCC_TRUE = @GCC_TRUE@
 GENCAT = @GENCAT@
 GMSGFMT = @GMSGFMT@
+GREP = @GREP@
 HAVE_ZLIB_FALSE = @HAVE_ZLIB_FALSE@
 HAVE_ZLIB_TRUE = @HAVE_ZLIB_TRUE@
 INCINTL = @INCINTL@
@@ -875,10 +879,9 @@ WARN_CFLAGS = @WARN_CFLAGS@
 WARN_CXXFLAGS = @WARN_CXXFLAGS@
 XGETTEXT = @XGETTEXT@
 YACC = @YACC@
+YFLAGS = @YFLAGS@
 ac_ct_CC = @ac_ct_CC@
 ac_ct_CXX = @ac_ct_CXX@
-ac_ct_RANLIB = @ac_ct_RANLIB@
-ac_ct_STRIP = @ac_ct_STRIP@
 am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
 am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
 am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
@@ -895,23 +898,30 @@ build_cpu = @build_cpu@
 build_os = @build_os@
 build_vendor = @build_vendor@
 datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
 exec_prefix = @exec_prefix@
 host = @host@
 host_alias = @host_alias@
 host_cpu = @host_cpu@
 host_os = @host_os@
 host_vendor = @host_vendor@
+htmldir = @htmldir@
 includedir = @includedir@
 infodir = @infodir@
 install_sh = @install_sh@
 libdir = @libdir@
 libexecdir = @libexecdir@
+localedir = @localedir@
 localstatedir = @localstatedir@
 mandir = @mandir@
 mkdir_p = @mkdir_p@
 oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
+psdir = @psdir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 sysconfdir = @sysconfdir@
@@ -2030,6 +2040,10 @@ uninstall-am: uninstall-info-am
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ basic_test.o -T $(srcdir)/script_test_3.t
 @GCC_TRUE@@NATIVE_LINKER_TRUE@script_test_3.stdout: script_test_3
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -SlW script_test_3 > script_test_3.stdout
+@GCC_TRUE@@NATIVE_LINKER_TRUE@script_test_4: basic_test.o gcctestdir/ld $(srcdir)/script_test_4.t
+@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
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
diff --git a/gold/testsuite/script_test_4.sh b/gold/testsuite/script_test_4.sh
new file mode 100755 (executable)
index 0000000..e84c580
--- /dev/null
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+# script_test_4.sh -- test load segment
+
+# Copyright 2008 Free Software Foundation, Inc.
+# Written by Ian Lance Taylor <iant@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_4.t, which is a linker script which
+# starts the program at an unaligned address.
+
+check()
+{
+    if ! grep -q "$2" "$1"
+    then
+       echo "Did not find expected segment in $1:"
+       echo "   $2"
+       echo ""
+       echo "Actual output below:"
+       cat "$1"
+       exit 1
+    fi
+}
+
+check script_test_4.stdout "\\.interp[         ]*PROGBITS[     ]*10000400"
diff --git a/gold/testsuite/script_test_4.t b/gold/testsuite/script_test_4.t
new file mode 100644 (file)
index 0000000..47ae066
--- /dev/null
@@ -0,0 +1,40 @@
+/* script_test_4.t -- linker script test 4 for gold
+
+   Copyright 2008 Free Software Foundation, Inc.
+   Written by Ian Lance Taylor <iant@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
+{
+  . = 0x10000400;
+
+  /* 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) }
+}