This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] gold: Add --rosegment-gap option
- From: Roland McGrath <mcgrathr at google dot com>
- To: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Cc: Derek Schuff <dschuff at google dot com>
- Date: Fri, 10 May 2013 13:10:40 -0700
- Subject: [PATCH] gold: Add --rosegment-gap option
On targets that set Target.rosegment_gap there are situations in which
the user needs to override that setting.
OK for trunk and 2.23?
Thanks,
Roland
gold/
2013-05-10 Roland McGrath <mcgrathr@google.com>
* options.h (General_options): Add --rosegment-gap option.
* options.cc (finalize): --rosegment-gap implies --rosegment.
* layout.cc (set_segment_offsets): Let user option override
target->rosegment_gap().
--- a/gold/layout.cc
+++ b/gold/layout.cc
@@ -3455,9 +3455,13 @@ Layout::set_segment_offsets(const Target*
target, Output_segment* load_seg,
// headers, so its offset will have to be exactly zero.
gold_assert(orig_off == 0);
+ uint64_t gap = target->rosegment_gap();
+ if (parameters->options().user_set_rosegment_gap())
+ gap = parameters->options().rosegment_gap();
+
// If the target wants a fixed minimum distance from the
// text segment to the read-only segment, move up now.
- uint64_t min_addr = start_addr + target->rosegment_gap();
+ uint64_t min_addr = start_addr + gap;
if (addr < min_addr)
addr = min_addr;
--- a/gold/options.cc
+++ b/gold/options.cc
@@ -1,6 +1,7 @@
// options.c -- handle command line options for gold
-// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2013
+// Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// This file is part of gold.
@@ -1272,6 +1273,10 @@ General_options::finalize()
}
}
+ // --rosegment-gap implies --rosegment.
+ if (this->user_set_rosegment_gap())
+ this->set_rosegment(true);
+
// FIXME: we can/should be doing a lot more sanity checking here.
}
--- a/gold/options.h
+++ b/gold/options.h
@@ -1,6 +1,7 @@
// options.h -- handle command line options for gold -*- C++ -*-
-// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2013
+// Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// This file is part of gold.
@@ -926,6 +927,10 @@ class General_options
N_(" Put read-only non-executable sections in their own segment"),
NULL);
+ DEFINE_uint64(rosegment_gap, options::TWO_DASHES, '\0', -1U,
+ N_("Set offset between executable and read-only segments"),
+ N_("OFFSET"));
+
DEFINE_string(m, options::EXACTLY_ONE_DASH, 'm', "",
N_("Set GNU linker emulation; obsolete"), N_("EMULATION"));