* gold patch committed: Fix -Ttext
@ 2011-07-26 1:47 Ian Lance Taylor
0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2011-07-26 1:47 UTC (permalink / raw)
To: binutils
[-- Attachment #1: Type: text/plain, Size: 622 bytes --]
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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-patch, Size: 1822 bytes --]
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-07-25 22:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-26 1:47 gold patch committed: Fix -Ttext Ian Lance Taylor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).