298b69a
diff -rcp ../binutils-2.20.51.0.2-original/gold/object.cc gold/object.cc
298b69a
*** ../binutils-2.20.51.0.2-original/gold/object.cc	2010-05-04 17:27:33.000000000 +0100
298b69a
--- gold/object.cc	2010-05-04 17:31:43.000000000 +0100
298b69a
*************** Input_objects::add_object(Object* obj)
298b69a
*** 2134,2148 ****
298b69a
  void
298b69a
  Input_objects::check_dynamic_dependencies() const
298b69a
  {
298b69a
    for (Dynobj_list::const_iterator p = this->dynobj_list_.begin();
298b69a
         p != this->dynobj_list_.end();
298b69a
         ++p)
298b69a
      {
298b69a
        const Dynobj::Needed& needed((*p)->needed());
298b69a
        bool found_all = true;
298b69a
!       for (Dynobj::Needed::const_iterator pneeded = needed.begin();
298b69a
! 	   pneeded != needed.end();
298b69a
! 	   ++pneeded)
298b69a
  	{
298b69a
  	  if (this->sonames_.find(*pneeded) == this->sonames_.end())
298b69a
  	    {
298b69a
--- 2134,2148 ----
298b69a
  void
298b69a
  Input_objects::check_dynamic_dependencies() const
298b69a
  {
298b69a
+   bool issued_copy_dt_needed_error = false;
298b69a
    for (Dynobj_list::const_iterator p = this->dynobj_list_.begin();
298b69a
         p != this->dynobj_list_.end();
298b69a
         ++p)
298b69a
      {
298b69a
        const Dynobj::Needed& needed((*p)->needed());
298b69a
        bool found_all = true;
298b69a
!       Dynobj::Needed::const_iterator pneeded;
298b69a
!       for (pneeded = needed.begin(); pneeded != needed.end(); ++pneeded)
298b69a
  	{
298b69a
  	  if (this->sonames_.find(*pneeded) == this->sonames_.end())
298b69a
  	    {
298b69a
*************** Input_objects::check_dynamic_dependencie
298b69a
*** 2151,2156 ****
298b69a
--- 2151,2175 ----
298b69a
  	    }
298b69a
  	}
298b69a
        (*p)->set_has_unknown_needed_entries(!found_all);
298b69a
+ 
298b69a
+       // --copy-dt-needed-entries aka --add-needed is a GNU ld option
298b69a
+       // that gold does not support.  However, they cause no trouble
298b69a
+       // unless there is a DT_NEEDED entry that we don't know about;
298b69a
+       // warn only in that case.
298b69a
+       if (!found_all
298b69a
+ 	  && !issued_copy_dt_needed_error
298b69a
+ 	  && (parameters->options().copy_dt_needed_entries()
298b69a
+ 	      || parameters->options().add_needed()))
298b69a
+ 	{
298b69a
+ 	  const char* optname;
298b69a
+ 	  if (parameters->options().copy_dt_needed_entries())
298b69a
+ 	    optname = "--copy-dt-needed-entries";
298b69a
+ 	  else
298b69a
+ 	    optname = "--add-needed";
298b69a
+ 	  gold_error(_("%s is not supported but is required for %s in %s"),
298b69a
+ 		     optname, (*pneeded).c_str(), (*p)->name().c_str());
298b69a
+ 	  issued_copy_dt_needed_error = true;
298b69a
+ 	}
298b69a
      }
298b69a
  }
298b69a
  
298b69a
diff -rcp ../binutils-2.20.51.0.2-original/gold/options.h gold/options.h
298b69a
*** ../binutils-2.20.51.0.2-original/gold/options.h	2010-05-04 17:28:20.000000000 +0100
298b69a
--- gold/options.h	2010-05-04 17:29:43.000000000 +0100
298b69a
*************** class General_options
298b69a
*** 571,583 ****
298b69a
    // alphabetical order).  For both, lowercase sorts before uppercase.
298b69a
    // The -z options come last.
298b69a
  
298b69a
    DEFINE_bool(allow_shlib_undefined, options::TWO_DASHES, '\0', false,
298b69a
                N_("Allow unresolved references in shared libraries"),
298b69a
                N_("Do not allow unresolved references in shared libraries"));
298b69a
  
298b69a
    DEFINE_bool(as_needed, options::TWO_DASHES, '\0', false,
298b69a
!               N_("Only set DT_NEEDED for dynamic libs if used"),
298b69a
!               N_("Always DT_NEEDED for dynamic libs"));
298b69a
  
298b69a
    // This should really be an "enum", but it's too easy for folks to
298b69a
    // forget to update the list as they add new targets.  So we just
298b69a
--- 571,587 ----
298b69a
    // alphabetical order).  For both, lowercase sorts before uppercase.
298b69a
    // The -z options come last.
298b69a
  
298b69a
+   DEFINE_bool(add_needed, options::TWO_DASHES, '\0', false,
298b69a
+ 	      N_("Not supported"),
298b69a
+ 	      N_("Do not copy DT_NEEDED tags from shared libraries"));
298b69a
+ 
298b69a
    DEFINE_bool(allow_shlib_undefined, options::TWO_DASHES, '\0', false,
298b69a
                N_("Allow unresolved references in shared libraries"),
298b69a
                N_("Do not allow unresolved references in shared libraries"));
298b69a
  
298b69a
    DEFINE_bool(as_needed, options::TWO_DASHES, '\0', false,
298b69a
!               N_("Only set DT_NEEDED for shared libraries if used"),
298b69a
!               N_("Always DT_NEEDED for shared libraries"));
298b69a
  
298b69a
    // This should really be an "enum", but it's too easy for folks to
298b69a
    // forget to update the list as they add new targets.  So we just
298b69a
*************** class General_options
298b69a
*** 618,623 ****
298b69a
--- 622,631 ----
298b69a
                {"none"});
298b69a
  #endif
298b69a
  
298b69a
+   DEFINE_bool(copy_dt_needed_entries, options::TWO_DASHES, '\0', false,
298b69a
+ 	      N_("Not supported"),
298b69a
+ 	      N_("Do not copy DT_NEEDED tags from shared libraries"));
298b69a
+ 
298b69a
    DEFINE_bool(define_common, options::TWO_DASHES, 'd', false,
298b69a
                N_("Define common symbols"),
298b69a
                N_("Do not define common symbols"));