From: Vivek Das Mohapatra Date: Mon, 14 Dec 2020 17:25:55 +0000 (+0000) Subject: Implement and document -z unique / -z nounique handling in gold X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8a87b2791181eb7fc1533ffaeb95df8d87d41493;p=binutils-gdb.git Implement and document -z unique / -z nounique handling in gold * layout.cc (Layout::finish_dynamic_section): Set DF_GNU_1_UNIQUE. * options.h (class General_options): Handle -z unique, -z nounique. --- diff --git a/gold/ChangeLog b/gold/ChangeLog index 533736b9559..d1c0ca713ee 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,9 @@ +2020-12-15 Vivek Das Mohapatra + + 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-13 Cary Coutant PR gold/23539 diff --git a/gold/layout.cc b/gold/layout.cc index dc88a9d8ae6..44664e2943e 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 51d3614e6b6..111453b95ee 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);