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