This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gold patch committed: Consider weak/strong pairs for ODR violations


Currently gold only checks for C++ ODR violations when it sees two
weak definitions.  However, it's possible to have an ODR violation
between an inline function and a non-inline function, in which case we
will be combining one weak symbol and one strong symbol.  I committed
this patch to consider that sort of case as an ODR violation as well.

Ian


2010-01-10  Ian Lance Taylor  <iant@google.com>

	* resolve.cc (Symbol_table::resolve): Add symbols to the list of
	ODR candidates if only one is weak.


Index: resolve.cc
===================================================================
RCS file: /cvs/src/src/gold/resolve.cc,v
retrieving revision 1.51
diff -p -u -r1.51 resolve.cc
--- resolve.cc	9 Jan 2010 00:13:48 -0000	1.51
+++ resolve.cc	11 Jan 2010 05:42:37 -0000
@@ -342,13 +342,15 @@ Symbol_table::resolve(Sized_symbol<size>
   // 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.)
+  // 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
+      && (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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]