$OpenBSD$

Logic for -z wxneeded and -z nowxneeded options
Allow -shared -pie and -static -pie
.openbsd.wxneeded support

Index: gold/options.cc
--- gold/options.cc.orig
+++ gold/options.cc
@@ -1011,6 +1011,7 @@ General_options::General_options()
   : bsymbolic_(BSYMBOLIC_NONE),
     printed_version_(false),
     execstack_status_(EXECSTACK_FROM_INPUT),
+    wxneeded_status_(WXNEEDED_FROM_INPUT),
     icf_status_(ICF_NONE),
     static_(false),
     do_demangle_(false),
@@ -1154,6 +1155,13 @@ General_options::finalize()
   else if (this->noexecstack())
     this->set_execstack_status(EXECSTACK_NO);
 
+  // wxneeded_status_ is a three-state variable; update it based on
+  // -z [no]wxneeded.
+  if (this->wxneeded())
+    this->set_wxneeded_status(WXNEEDED_YES);
+  else if (this->nowxneeded())
+    this->set_wxneeded_status(WXNEEDED_NO);
+
   // icf_status_ is a three-state variable; update it based on the
   // value of this->icf().
   if (strcmp(this->icf(), "none") == 0)
@@ -1358,6 +1366,7 @@ General_options::finalize()
   // Now that we've normalized the options, check for contradictory ones.
   if (this->shared() && this->is_static())
     gold_fatal(_("-shared and -static are incompatible"));
+#if 0
   if (this->shared() && this->pie())
     gold_fatal(_("-shared and -pie are incompatible"));
   if (this->pie() && this->is_static())
@@ -1367,6 +1376,7 @@ General_options::finalize()
     gold_fatal(_("-shared and -r are incompatible"));
   if (this->pie() && this->relocatable())
     gold_fatal(_("-pie and -r are incompatible"));
+#endif
 
   if (!this->shared())
     {
