[RFC][PATCH v6 6/6] Implement and document -z unique / -z nounique handling in gold
Vivek Das Mohapatra
vivek@collabora.com
Mon Dec 14 17:25:55 GMT 2020
---
gold/ChangeLog | 6 ++++++
gold/layout.cc | 6 ++++++
gold/options.h | 3 +++
3 files changed, 15 insertions(+)
diff --git a/gold/ChangeLog b/gold/ChangeLog
index e152e1ed69..4a08e35efc 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,9 @@
+2020-12-09 Vivek Das Mohapatra <vivek@collabora.com>
+
+ Implement -z unique / -z nounique options.
+ * layout.cc (Layout::finish_dynamic_section): Set DF_GNU_1_UNIQUE.
+ * options.h (class General_options): Handle -z unique, -z nounique.
+
2020-12-07 Alan Modra <amodra@gmail.com>
* plugin.cc (Plugin_recorder::init): Replace strncpy with memcpy.
diff --git a/gold/layout.cc b/gold/layout.cc
index 8563f11099..5cbef4d566 100644
--- a/gold/layout.cc
+++ b/gold/layout.cc
@@ -5371,6 +5371,12 @@ Layout::finish_dynamic_section(const Input_objects* input_objects,
flags |= elfcpp::DF_1_PIE;
if (flags != 0)
odyn->add_constant(elfcpp::DT_FLAGS_1, flags);
+
+ flags = 0;
+ if (parameters->options().unique())
+ flags |= elfcpp::DF_GNU_1_UNIQUE;
+ if (flags != 0)
+ odyn->add_constant(elfcpp::DT_GNU_FLAGS_1, flags);
}
// Set the size of the _DYNAMIC symbol table to be the size of the
diff --git a/gold/options.h b/gold/options.h
index 51d3614e6b..5a487106d5 100644
--- a/gold/options.h
+++ b/gold/options.h
@@ -1469,6 +1469,9 @@ class General_options
DEFINE_bool(interpose, options::DASH_Z, '\0', false,
N_("Mark object to interpose all DSOs but executable"),
NULL);
+ DEFINE_bool(unique, options::DASH_Z, '\0', false,
+ N_("Mark DSO to be loaded at most once, and only in the main namespace"),
+ N_("Do not mark the DSO as one to be loaded only in the main namespace"));
DEFINE_bool_alias(lazy, now, options::DASH_Z, '\0',
N_("Mark object for lazy runtime binding"),
NULL, true);
--
2.20.1
More information about the Binutils
mailing list