This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gold patch committed: Fix -Ttext


The -Ttext option was broken when used without a linker script.  It
would normally fail an assertion error.  This patch fixes it, and adds a
couple of test cases.  Committed to mainline.

Ian


2011-07-25  Ian Lance Taylor  <iant@google.com>

	* layout.cc (Layout::relaxation_loop_body): Only clear load_seg if
	the -Ttext option is not 0 modulo the page size.  If we clear
	load_seg, clear phdr_seg too.
	* testsuite/Makefile.am (check_PROGRAMS): Add flagstest_o_ttext_1.
	(flagstest_o_ttext_1): New target.
	(check_DATA): Add flagstest_o_ttext_2.
	(flagstest_o_ttext_2): New target.
	* testsuite/Makefile.in: Rebuild.


Index: layout.cc
===================================================================
RCS file: /cvs/src/src/gold/layout.cc,v
retrieving revision 1.216
diff -u -p -r1.216 layout.cc
--- layout.cc	14 Jul 2011 00:55:17 -0000	1.216
+++ layout.cc	25 Jul 2011 22:46:48 -0000
@@ -2095,8 +2095,12 @@ Layout::relaxation_loop_body(
   // If the user set the address of the text segment, that may not be
   // compatible with putting the segment headers and file headers into
   // that segment.
-  if (parameters->options().user_set_Ttext())
-    load_seg = NULL;
+  if (parameters->options().user_set_Ttext()
+      && parameters->options().Ttext() % target->common_pagesize() != 0)
+    {
+      load_seg = NULL;
+      phdr_seg = NULL;
+    }
 
   gold_assert(phdr_seg == NULL
 	      || load_seg != NULL
Index: testsuite/Makefile.am
===================================================================
RCS file: /cvs/src/src/gold/testsuite/Makefile.am,v
retrieving revision 1.177
diff -u -p -r1.177 Makefile.am
--- testsuite/Makefile.am	13 Jul 2011 22:47:07 -0000	1.177
+++ testsuite/Makefile.am	25 Jul 2011 22:46:49 -0000
@@ -1005,6 +1005,18 @@ flagstest_o_specialfile_and_compress_deb
 
 endif HAVE_ZLIB
 
+# Test -TText and -Tdata.
+check_PROGRAMS += flagstest_o_ttext_1
+flagstest_o_ttext_1: flagstest_debug.o gcctestdir/ld
+	$(CXXLINK) -Bgcctestdir/ -o $@ $< -Wl,-Ttext,0x400000 -Wl,-Tdata,0x800000
+
+# This version won't be runnable, because there is no way to put the
+# PT_PHDR segment at file offset 0.  We just make sure that we can
+# build it without error.
+check_DATA += flagstest_o_ttext_2
+flagstest_o_ttext_2: flagstest_debug.o gcctestdir/ld
+	$(CXXLINK) -Bgcctestdir/ -o $@ $< -Wl,-Ttext,0x400010 -Wl,-Tdata,0x800010
+
 # Test symbol versioning.
 check_PROGRAMS += ver_test
 ver_test_SOURCES = ver_test_main.cc

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]