]> git.saurik.com Git - apple/ld64.git/blobdiff - src/ld/SymbolTable.cpp
ld64-128.2.tar.gz
[apple/ld64.git] / src / ld / SymbolTable.cpp
index 2716ccfb66e798fc0c5267cbc288ce41cadf8fab..66ff3588955c46a45743abf88cc503183ac7b4f7 100644 (file)
@@ -179,22 +179,32 @@ bool SymbolTable::addByName(const ld::Atom& newAtom, bool ignoreDuplicates)
                                                        }
                                                        else {
                                                                // existing not-weak, new is not-weak
-                                                               if ( ignoreDuplicates ) {
+                                                               if ( newAtom.section().type() == ld::Section::typeMachHeader ) {
+                                                                       warning("ignoring override of built-in symbol %s from %s", newAtom.name(), existingAtom->file()->path());
+                                                                       useNew = true;
+                                                               } 
+                                                               else if ( existingAtom->section().type() == ld::Section::typeMachHeader ) {
+                                                                       warning("ignoring override of built-in symbol %s from %s", newAtom.name(), newAtom.file()->path());
                                                                        useNew = false;
-                                                                       static bool fullWarning = false;
-                                                                       if ( ! fullWarning ) {
-                                                                               warning("-dead_strip with lazy loaded static (library) archives "
-                                                                                               "has resulted in a duplicate symbol.  You can change your "
-                                                                                               "source code to rename symbols to avoid the collision.  "
-                                                                                               "This will be an error in a future linker.");
-                                                                               fullWarning = true;
-                                                                       }
-                                                                       warning("duplicate symbol %s originally in %s now lazily loaded from %s",
-                                                                                       SymbolTable::demangle(name), existingAtom->file()->path(), newAtom.file()->path());
-                                                               }
+                                                               } 
                                                                else {
-                                                                       throwf("duplicate symbol %s in %s and %s", 
-                                                                                       SymbolTable::demangle(name), newAtom.file()->path(), existingAtom->file()->path());
+                                                                       if ( ignoreDuplicates ) {
+                                                                               useNew = false;
+                                                                               static bool fullWarning = false;
+                                                                               if ( ! fullWarning ) {
+                                                                                       warning("-dead_strip with lazy loaded static (library) archives "
+                                                                                                       "has resulted in a duplicate symbol.  You can change your "
+                                                                                                       "source code to rename symbols to avoid the collision.  "
+                                                                                                       "This will be an error in a future linker.");
+                                                                                       fullWarning = true;
+                                                                               }
+                                                                               warning("duplicate symbol %s originally in %s now lazily loaded from %s",
+                                                                                               SymbolTable::demangle(name), existingAtom->file()->path(), newAtom.file()->path());
+                                                                       }
+                                                                       else {
+                                                                               throwf("duplicate symbol %s in %s and %s", 
+                                                                                               SymbolTable::demangle(name), newAtom.file()->path(), existingAtom->file()->path());
+                                                                       }
                                                                }
                                                        }
                                                }
@@ -222,17 +232,27 @@ bool SymbolTable::addByName(const ld::Atom& newAtom, bool ignoreDuplicates)
                                switch ( newAtom.definition() ) {
                                        case ld::Atom::definitionRegular:
                                                // replace existing tentative atom with regular one
-                                               checkVisibilityMismatch = true;
-                                               if ( newAtom.size() < existingAtom->size() ) {
-                                                       warning("for symbol %s tentative definition of size %llu from %s is "
-                                                                                       "being replaced by a real definition of size %llu from %s",
-                                                                                       newAtom.name(), existingAtom->size(), existingAtom->file()->path(),
-                                                                                       newAtom.size(), newAtom.file()->path());
+                                               if ( newAtom.section().type() == ld::Section::typeMachHeader ) {
+                                                       // silently replace tentative __dso_handle with real linker created symbol
+                                                       useNew = true;
+                                               }
+                                               else if ( existingAtom->section().type() == ld::Section::typeMachHeader ) {
+                                                       // silently replace tentative __dso_handle with real linker created symbol
+                                                       useNew = false;
                                                }
-                                               if ( newAtom.section().type() == ld::Section::typeCode ) {
-                                                       warning("for symbol %s tentative (data) defintion from %s is "
-                                                                       "being replaced by code from %s", newAtom.name(), existingAtom->file()->path(),
-                                                                       newAtom.file()->path());
+                                               else {
+                                                       checkVisibilityMismatch = true;
+                                                       if ( newAtom.size() < existingAtom->size() ) {
+                                                               warning("for symbol %s tentative definition of size %llu from %s is "
+                                                                                               "being replaced by a real definition of size %llu from %s",
+                                                                                               newAtom.name(), existingAtom->size(), existingAtom->file()->path(),
+                                                                                               newAtom.size(), newAtom.file()->path());
+                                                       }
+                                                       if ( newAtom.section().type() == ld::Section::typeCode ) {
+                                                               warning("for symbol %s tentative (data) defintion from %s is "
+                                                                               "being replaced by code from %s", newAtom.name(), existingAtom->file()->path(),
+                                                                               newAtom.file()->path());
+                                                       }
                                                }
                                                break;
                                        case ld::Atom::definitionTentative: