<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">--- src/ld/OutputFile.cpp
+++ src/ld/OutputFile.cpp
@@ -4461,14 +4461,18 @@ void OutputFile::addClassicRelocs(ld::Internal&amp; state, ld::Internal::FinalSectio
 		assert(minusTarget-&gt;definition() != ld::Atom::definitionProxy);
 		assert(target != NULL);
 		assert(target-&gt;definition() != ld::Atom::definitionProxy);
-		// make sure target is not global and weak
-		if ( (target-&gt;scope() == ld::Atom::scopeGlobal) &amp;&amp; (target-&gt;combine() == ld::Atom::combineByName)
-				&amp;&amp; (atom-&gt;section().type() != ld::Section::typeCFI)
-				&amp;&amp; (atom-&gt;section().type() != ld::Section::typeDtraceDOF)
-				&amp;&amp; (atom-&gt;section().type() != ld::Section::typeUnwindInfo) 
-				&amp;&amp; (minusTarget != target) ) {
-			// ok for __eh_frame and __uwind_info to use pointer diffs to global weak symbols
-			throwf("bad codegen, pointer diff in %s to global weak symbol %s", atom-&gt;name(), target-&gt;name());
+		// check if target of pointer-diff is global and weak
+		if ( (target-&gt;scope() == ld::Atom::scopeGlobal) &amp;&amp; (target-&gt;combine() == ld::Atom::combineByName) &amp;&amp; (target-&gt;definition() == ld::Atom::definitionRegular) ) {
+			if ( (atom-&gt;section().type() == ld::Section::typeCFI)
+				|| (atom-&gt;section().type() == ld::Section::typeDtraceDOF)
+				|| (atom-&gt;section().type() == ld::Section::typeUnwindInfo) ) {
+				// ok for __eh_frame and __uwind_info to use pointer diffs to global weak symbols
+				return;
+			}
+			// Have direct reference to weak-global.  This should be an indrect reference
+			warning("direct access in %s to global weak symbol %s means the weak symbol cannot be overriden at runtime. "
+					"This was likely caused by different translation units being compiled with different visiblity settings.",
+					 atom-&gt;name(), target-&gt;name());
 		}
 		return;
 	}
-- 
2.10.1

</pre></body></html>