2010-02-01 Doug Kwan <dougkwan@google.com>
[deliverable/binutils-gdb.git] / gold / resolve.cc
index d32b2b9712b0cfabc0d5c919a37e6486004a96ce..3c7c7a838246b39edc57523928f865d0c161b66f 100644 (file)
@@ -1,6 +1,6 @@
 // resolve.cc -- symbol resolution for gold
 
-// Copyright 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 // Written by Ian Lance Taylor <iant@google.com>.
 
 // This file is part of gold.
@@ -297,6 +297,38 @@ Symbol_table::resolve(Sized_symbol<size>* to,
         }
     }
 
+  // A new weak undefined reference, merging with an old weak
+  // reference, could be a One Definition Rule (ODR) violation --
+  // especially if the types or sizes of the references differ.  We'll
+  // store such pairs and look them up later to make sure they
+  // actually refer to the same lines of code.  We also check
+  // combinations of weak and strong, which might occur if one case is
+  // inline and the other is not.  (Note: not all ODR violations can
+  // be found this way, and not everything this finds is an ODR
+  // violation.  But it's helpful to warn about.)
+  bool to_is_ordinary;
+  if (parameters->options().detect_odr_violations()
+      && (sym.get_st_bind() == elfcpp::STB_WEAK
+         || to->binding() == elfcpp::STB_WEAK)
+      && orig_st_shndx != elfcpp::SHN_UNDEF
+      && to->shndx(&to_is_ordinary) != elfcpp::SHN_UNDEF
+      && to_is_ordinary
+      && sym.get_st_size() != 0    // Ignore weird 0-sized symbols.
+      && to->symsize() != 0
+      && (sym.get_st_type() != to->type()
+          || sym.get_st_size() != to->symsize())
+      // C does not have a concept of ODR, so we only need to do this
+      // on C++ symbols.  These have (mangled) names starting with _Z.
+      && to->name()[0] == '_' && to->name()[1] == 'Z')
+    {
+      Symbol_location fromloc
+          = { object, orig_st_shndx, sym.get_st_value() };
+      Symbol_location toloc = { to->object(), to->shndx(&to_is_ordinary),
+                               to->value() };
+      this->candidate_odr_violations_[to->name()].insert(fromloc);
+      this->candidate_odr_violations_[to->name()].insert(toloc);
+    }
+
   unsigned int frombits = symbol_to_bits(sym.get_st_bind(),
                                          object->is_dynamic(),
                                         st_shndx, is_ordinary,
@@ -337,36 +369,6 @@ Symbol_table::resolve(Sized_symbol<size>* to,
                                             _("multiple common of '%s'"),
                                             to, OBJECT, object);
     }
-
-  // A new weak undefined reference, merging with an old weak
-  // reference, could be a One Definition Rule (ODR) violation --
-  // especially if the types or sizes of the references differ.  We'll
-  // store such pairs and look them up later to make sure they
-  // actually refer to the same lines of code.  (Note: not all ODR
-  // violations can be found this way, and not everything this finds
-  // is an ODR violation.  But it's helpful to warn about.)
-  bool to_is_ordinary;
-  if (parameters->options().detect_odr_violations()
-      && sym.get_st_bind() == elfcpp::STB_WEAK
-      && to->binding() == elfcpp::STB_WEAK
-      && orig_st_shndx != elfcpp::SHN_UNDEF
-      && to->shndx(&to_is_ordinary) != elfcpp::SHN_UNDEF
-      && to_is_ordinary
-      && sym.get_st_size() != 0    // Ignore weird 0-sized symbols.
-      && to->symsize() != 0
-      && (sym.get_st_type() != to->type()
-          || sym.get_st_size() != to->symsize())
-      // C does not have a concept of ODR, so we only need to do this
-      // on C++ symbols.  These have (mangled) names starting with _Z.
-      && to->name()[0] == '_' && to->name()[1] == 'Z')
-    {
-      Symbol_location fromloc
-          = { object, orig_st_shndx, sym.get_st_value() };
-      Symbol_location toloc = { to->object(), to->shndx(&to_is_ordinary),
-                               to->value() };
-      this->candidate_odr_violations_[to->name()].insert(fromloc);
-      this->candidate_odr_violations_[to->name()].insert(toloc);
-    }
 }
 
 // Handle the core of symbol resolution.  This is called with the
@@ -440,9 +442,10 @@ Symbol_table::should_override(const Symbol* to, unsigned int frombits,
           || (object != NULL && object->just_symbols()))
         return false;
 
-      Symbol_table::report_resolve_problem(true,
-                                          _("multiple definition of '%s'"),
-                                          to, defined, object);
+      if (!parameters->options().muldefs())
+       Symbol_table::report_resolve_problem(true,
+                                            _("multiple definition of '%s'"),
+                                            to, defined, object);
       return false;
 
     case WEAK_DEF * 16 + DEF:
@@ -858,9 +861,8 @@ Symbol::override_base_with_special(const Symbol* from)
 
   // We shouldn't see these flags.  If we do, we need to handle them
   // somehow.
-  gold_assert(!from->is_target_special_ || this->is_target_special_);
   gold_assert(!from->is_forwarder_);
-  gold_assert(!from->has_plt_offset_);
+  gold_assert(!from->has_plt_offset());
   gold_assert(!from->has_warning_);
   gold_assert(!from->is_copied_from_dynobj_);
   gold_assert(!from->is_forced_local_);
This page took 0.026139 seconds and 4 git commands to generate.