This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] gold: -Trodata-segment and fix -Ttext-segment for isolate_execinstr targets
- From: Roland McGrath <mcgrathr at google dot com>
- To: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Thu, 18 Jul 2013 16:56:39 -0700
- Subject: [PATCH] gold: -Trodata-segment and fix -Ttext-segment for isolate_execinstr targets
This patch does two things that could be separate changes, but they are
quite close together so I'm not bothering to send them separately.
Firstly, it fixes some of the assumptions that go along with using
-Ttext-segment so that it works when target->isolate_execinstr()
returns true.
Second, it adds -Trodata-segment with the same meaning it has to BFD ld.
This has no effect unless either --rosegment is also given, or
target->isolate_execinstr() returns true. I couldn't figure out where
to add option sanity checking that would complain if you passed
-Trodata-segment when it will be ignored, because it has to be done
someplace where the target has already been selected.
Before this, using -Ttext-segment for a NaCl target gets an assertion
failure. After this, it works (with or without -Trodata-segment).
OK for trunk and 2.23?
Thanks,
Roland
gold/
2013-07-18 Roland McGrath <mcgrathr@google.com>
* options.h (General_options): Add -Trodata-segment option.
* layout.cc (relaxation_loop_body): Honor -Trodata-segment option.
If target->isolate_execinstr(), don't expect executable segment to
come first.
--- a/gold/layout.cc
+++ b/gold/layout.cc
@@ -2424,8 +2424,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()
- && parameters->options().Ttext() % target->abi_pagesize() != 0)
+ if (target->isolate_execinstr()
+ ? (parameters->options().user_set_Trodata_segment()
+ && (parameters->options().Trodata_segment() % target->abi_pagesize()
+ != 0))
+ : (parameters->options().user_set_Ttext()
+ && parameters->options().Ttext() % target->abi_pagesize() != 0))
{
load_seg = NULL;
phdr_seg = NULL;
@@ -3411,10 +3415,18 @@ Layout::set_segment_offsets(const Target*
target, Output_segment* load_seg,
}
else if (parameters->options().user_set_Ttext()
&& (parameters->options().omagic()
- || ((*p)->flags() & elfcpp::PF_W) == 0))
+ || (target->isolate_execinstr()
+ ? ((*p)->flags() & elfcpp::PF_X) != 0
+ : ((*p)->flags() & elfcpp::PF_W) == 0)))
{
are_addresses_set = true;
}
+ else if (parameters->options().user_set_Trodata_segment()
+ && ((*p)->flags() & (elfcpp::PF_W | elfcpp::PF_X)) == 0)
+ {
+ addr = parameters->options().Trodata_segment();
+ are_addresses_set = true;
+ }
else if (parameters->options().user_set_Tdata()
&& ((*p)->flags() & elfcpp::PF_W) != 0
&& (!parameters->options().user_set_Tbss()
--- a/gold/options.h
+++ b/gold/options.h
@@ -1162,6 +1162,8 @@ class General_options
DEFINE_uint64_alias(Ttext_segment, Ttext, options::ONE_DASH, '\0',
N_("Set the address of the text segment"),
N_("ADDRESS"));
+ DEFINE_uint64(Trodata_segment, options::ONE_DASH, '\0', -1U,
+ N_("Set the address of the rodata segment"), N_("ADDRESS"));
DEFINE_bool(toc_optimize, options::TWO_DASHES, '\0', true,
N_("(PowerPC64 only) Optimize TOC code sequences"),