aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gold/ChangeLog12
-rw-r--r--gold/Makefile.in16
-rw-r--r--gold/script-sections.cc13
-rw-r--r--gold/testsuite/Makefile.am8
-rw-r--r--gold/testsuite/Makefile.in24
-rwxr-xr-xgold/testsuite/script_test_4.sh41
-rw-r--r--gold/testsuite/script_test_4.t40
7 files changed, 137 insertions, 17 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog
index c0675fb..0c6148e 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -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.
diff --git a/gold/Makefile.in b/gold/Makefile.in
index 4ca4468..0170ab0 100644
--- a/gold/Makefile.in
+++ b/gold/Makefile.in
@@ -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@
diff --git a/gold/script-sections.cc b/gold/script-sections.cc
index f6b6550..55db831 100644
--- a/gold/script-sections.cc
+++ b/gold/script-sections.cc
@@ -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.
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am
index 8859520..2f950cc 100644
--- a/gold/testsuite/Makefile.am
+++ b/gold/testsuite/Makefile.am
@@ -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
diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in
index b46861f..b4b5000 100644
--- a/gold/testsuite/Makefile.in
+++ b/gold/testsuite/Makefile.in
@@ -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
index 0000000..e84c580
--- /dev/null
+++ b/gold/testsuite/script_test_4.sh
@@ -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
index 0000000..47ae066
--- /dev/null
+++ b/gold/testsuite/script_test_4.t
@@ -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) }
+}