This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[gold patch RFC] implement suppotr for -z origin
- From: "Chris Demetriou" <cgd at google dot com>
- To: binutils at sourceware dot org
- Cc: "Ian Lance Taylor" <iant at google dot com>
- Date: Thu, 11 Sep 2008 22:14:22 -0700
- Subject: [gold patch RFC] implement suppotr for -z origin
Got a request for -z origin support. This patch implements it.
Tested manually w/ -shared -z origin & -shared -z origin
--enable-new-dtags, comparing the readelf -d output w/ that from ld.
If you'd like me to implement a test case, let me know -- the
testsuite looked pretty thin on flags tests, I wasn't sure what was
desired there.
chris
---
2008-09-11 Chris Demetriou <cgd@google.com>
* options.h (origin): New -z option.
* layout.cc (Layout:finish_dynamic_section): If "-z origin"
is specified set DF_1_ORIGIN in DT_FLAGS_1, and if
--enable-new-dtags was also specified set DF_ORIGIN in DT_FLAGS.
Index: ChangeLog
===================================================================
RCS file: /cvs/src/src/gold/ChangeLog,v
retrieving revision 1.133
diff -u -u -p -r1.133 ChangeLog
--- ChangeLog 10 Sep 2008 17:56:02 -0000 1.133
+++ ChangeLog 12 Sep 2008 05:02:04 -0000
@@ -1,3 +1,10 @@
+2008-09-11 Chris Demetriou <cgd@google.com>
+
+ * options.h (origin): New -z option.
+ * layout.cc (Layout:finish_dynamic_section): If "-z origin"
+ is specified set DF_1_ORIGIN in DT_FLAGS_1, and if
+ --enable-new-dtags was also specified set DF_ORIGIN in DT_FLAGS.
+
2008-09-05 Cary Coutant <ccoutant@google.com>
* fileread.cc (File_read::make_view): Add check for attempt to map
Index: layout.cc
===================================================================
RCS file: /cvs/src/src/gold/layout.cc,v
retrieving revision 1.112
diff -u -u -p -r1.112 layout.cc
--- layout.cc 13 Aug 2008 07:37:46 -0000 1.112
+++ layout.cc 12 Sep 2008 05:02:04 -0000
@@ -2753,6 +2753,9 @@ Layout::finish_dynamic_section(const Inp
}
if (parameters->options().shared() && this->has_static_tls())
flags |= elfcpp::DF_STATIC_TLS;
+ if (parameters->options().origin()
+ && parameters->options().enable_new_dtags())
+ flags |= elfcpp::DF_ORIGIN;
odyn->add_constant(elfcpp::DT_FLAGS, flags);
flags = 0;
@@ -2774,6 +2777,8 @@ Layout::finish_dynamic_section(const Inp
flags &= ~(elfcpp::DF_1_INITFIRST
| elfcpp::DF_1_NODELETE
| elfcpp::DF_1_NOOPEN);
+ if (parameters->options().origin())
+ flags |= elfcpp::DF_1_ORIGIN;
if (flags)
odyn->add_constant(elfcpp::DT_FLAGS_1, flags);
}
Index: options.h
===================================================================
RCS file: /cvs/src/src/gold/options.h,v
retrieving revision 1.84
diff -u -u -p -r1.84 options.h
--- options.h 7 Aug 2008 17:02:11 -0000 1.84
+++ options.h 12 Sep 2008 05:02:04 -0000
@@ -837,6 +837,9 @@ 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(origin, options::DASH_Z, '\0', false,
+ N_("Mark DSO to indicate that needs immediate $ORIGIN "
+ "processing at runtime"), NULL);
public:
typedef options::Dir_list Dir_list;