This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
gold patch committed: Add -z text and -z textoff
- From: Ian Lance Taylor <iant at google dot com>
- To: binutils at sourceware dot org
- Date: Thu, 07 Jan 2010 10:17:50 -0800
- Subject: gold patch committed: Add -z text and -z textoff
I committed this patch to gold to add support for the -z text and -z
textoff options. I copied the Solaris ld behaviour as described on
the man page.
(The GNU linker does not currently implement these options.)
Ian
2010-01-07 Ian Lance Taylor <iant@google.com>
* options.h (class General_options): Add -z text and -z textoff.
* layout.cc (Layout::finish_dynamic_section): Implement -z text.
Index: layout.cc
===================================================================
RCS file: /cvs/src/src/gold/layout.cc,v
retrieving revision 1.158
diff -p -u -r1.158 layout.cc
--- layout.cc 7 Jan 2010 07:14:29 -0000 1.158
+++ layout.cc 7 Jan 2010 18:15:29 -0000
@@ -3353,8 +3353,10 @@ Layout::finish_dynamic_section(const Inp
odyn->add_constant(elfcpp::DT_TEXTREL, 0);
flags |= elfcpp::DF_TEXTREL;
- if (parameters->options().warn_shared_textrel()
- && parameters->options().shared())
+ if (parameters->options().text())
+ gold_error(_("read-only segment has dynamic relocations"));
+ else if (parameters->options().warn_shared_textrel()
+ && parameters->options().shared())
gold_warning(_("shared library text segment is not shareable"));
}
if (parameters->options().shared() && this->has_static_tls())
Index: options.h
===================================================================
RCS file: /cvs/src/src/gold/options.h,v
retrieving revision 1.134
diff -p -u -r1.134 options.h
--- options.h 7 Jan 2010 06:05:23 -0000 1.134
+++ options.h 7 Jan 2010 18:15:30 -0000
@@ -1052,6 +1052,12 @@ class General_options
DEFINE_bool(relro, options::DASH_Z, '\0', false,
N_("Where possible mark variables read-only after relocation"),
N_("Don't mark variables read-only after relocation"));
+ DEFINE_bool(text, options::DASH_Z, '\0', false,
+ N_("Do not permit relocations in read-only segments"),
+ NULL);
+ DEFINE_bool_alias(textoff, text, options::DASH_Z, '\0',
+ N_("Permit relocations in read-only segments (default)"),
+ NULL, true);
public:
typedef options::Dir_list Dir_list;