From 07feaf2cb00322d025073eb8ec22189ada5e4180 Mon Sep 17 00:00:00 2001 From: Apple Date: Mon, 14 Mar 2011 21:59:03 +0000 Subject: [PATCH] ld64-97.17.tar.gz --- ChangeLog | 23 ++++++++++++ src/ld/LTOReader.hpp | 2 +- src/ld/MachOReaderDylib.hpp | 2 +- src/ld/Options.cpp | 3 ++ src/ld/ld.cpp | 71 +------------------------------------ 5 files changed, 29 insertions(+), 72 deletions(-) diff --git a/ChangeLog b/ChangeLog index 38543bc..ebd5628 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,27 @@ +----- Tagged ld64-97.17 + +2010-09-07 Nick Kledzik + + ld mis-handling std::tr1::anonymous symbols + Remove support for ordering gcc-4.0 compiled anonymous namespace symbols + +2010-09-07 Nick Kledzik + + RedGarnet's linker does not honor $ld$hide for umbrella libraries + +----- Tagged ld64-97.16 + +2010-08-10 Nick Kledzik + + add -demangle noop to ld64-97 + +----- Tagged ld64-97.15 + +2010-08-10 Nick Kledzik + + linker crash when using LTO in lto::Atom::getSymbolTableInclusion() + ----- Tagged ld64-97.14 2010-04-20 Nick Kledzik diff --git a/src/ld/LTOReader.hpp b/src/ld/LTOReader.hpp index 9d00b00..2e560cc 100644 --- a/src/ld/LTOReader.hpp +++ b/src/ld/LTOReader.hpp @@ -145,7 +145,7 @@ public: Scope getScope() const { return (fRealAtom ? fRealAtom->getScope() : fScope); } DefinitionKind getDefinitionKind() const { return (fRealAtom ? fRealAtom->getDefinitionKind() : fKind); } SymbolTableInclusion getSymbolTableInclusion() const - { return fRealAtom->getSymbolTableInclusion(); } + { return (fRealAtom ? fRealAtom->getSymbolTableInclusion() : ObjectFile::Atom::kSymbolTableIn); } bool dontDeadStrip() const { return false; } bool isZeroFill() const { return (fRealAtom ? fRealAtom->isZeroFill() : false); } bool isThumb() const { return false; } diff --git a/src/ld/MachOReaderDylib.hpp b/src/ld/MachOReaderDylib.hpp index 1d8f89b..5a6c553 100644 --- a/src/ld/MachOReaderDylib.hpp +++ b/src/ld/MachOReaderDylib.hpp @@ -832,7 +832,7 @@ void Reader::processIndirectLibraries(DylibHander* handler) ObjectFile::Reader* child = handler->findDylib(it->path, this->getPath()); if ( isPublicLocation(child->getInstallPath()) ) { // promote this child to be automatically added as a direct dependent if this already is - if ( this->explicitlyLinked() || this->implicitlyLinked() ) { + if ( (this->explicitlyLinked() || this->implicitlyLinked()) && (strcmp(it->path,child->getInstallPath()) == 0) ) { //fprintf(stderr, "processIndirectLibraries() implicitly linking %s\n", child->getInstallPath()); ((Reader*)child)->setImplicitlyLinked(); } diff --git a/src/ld/Options.cpp b/src/ld/Options.cpp index 01ce10f..492d140 100644 --- a/src/ld/Options.cpp +++ b/src/ld/Options.cpp @@ -2520,6 +2520,9 @@ void Options::parse(int argc, const char* argv[]) else warning("ignoring unrecognized argument (%s) to -objc_abi_version", version); } + else if ( strcmp(arg, "-demangle") == 0 ) { + // add -demangle noop to ld64-97 + } else { throwf("unknown option: %s", arg); } diff --git a/src/ld/ld.cpp b/src/ld/ld.cpp index 48e1e88..115240e 100644 --- a/src/ld/ld.cpp +++ b/src/ld/ld.cpp @@ -2025,32 +2025,6 @@ static bool matchesObjectFile(ObjectFile::Atom* atom, const char* objectFileLeaf } -static bool usesAnonymousNamespace(const char* symbol) -{ - return ( (strncmp(symbol, "__Z", 3) == 0) && (strstr(symbol, "_GLOBAL__N_") != NULL) ); -} - - -// -// convert: -// __ZN20_GLOBAL__N__Z5main2v3barEv => _ZN-3barEv -// __ZN37_GLOBAL__N_main.cxx_00000000_493A01A33barEv => _ZN-3barEv -// -static void canonicalizeAnonymousName(const char* inSymbol, char outSymbol[]) -{ - const char* globPtr = strstr(inSymbol, "_GLOBAL__N_"); - while ( isdigit(*(--globPtr)) ) - ; // loop - char* endptr; - unsigned long length = strtoul(globPtr+1, &endptr, 10); - const char* globEndPtr = endptr + length; - int startLen = globPtr-inSymbol+1; - memcpy(outSymbol, inSymbol, startLen); - outSymbol[startLen] = '-'; - strcpy(&outSymbol[startLen+1], globEndPtr); -} - - ObjectFile::Atom* Linker::findAtom(const Options::OrderedSymbol& orderedSymbol) { ObjectFile::Atom* atom = fGlobalSymbolTable.find(orderedSymbol.symbolName); @@ -2061,7 +2035,6 @@ ObjectFile::Atom* Linker::findAtom(const Options::OrderedSymbol& orderedSymbol) else { // slow case. The requested symbol is not in symbol table, so might be static function static SymbolTable::Mapper hashTableOfTranslationUnitScopedSymbols; - static SymbolTable::Mapper hashTableOfSymbolsWithAnonymousNamespace; static bool built = false; // build a hash_map the first time if ( !built ) { @@ -2069,18 +2042,7 @@ ObjectFile::Atom* Linker::findAtom(const Options::OrderedSymbol& orderedSymbol) atom = *it; const char* name = atom->getName(); if ( name != NULL) { - if ( usesAnonymousNamespace(name) ) { - // symbol that uses anonymous namespace - char canonicalName[strlen(name)+2]; - canonicalizeAnonymousName(name, canonicalName); - const char* hashName = strdup(canonicalName); - SymbolTable::Mapper::iterator pos = hashTableOfSymbolsWithAnonymousNamespace.find(hashName); - if ( pos == hashTableOfSymbolsWithAnonymousNamespace.end() ) - hashTableOfSymbolsWithAnonymousNamespace[hashName] = atom; - else - hashTableOfSymbolsWithAnonymousNamespace[hashName] = NULL; // collision, denote with NULL - } - else if ( atom->getScope() == ObjectFile::Atom::scopeTranslationUnit ) { + if ( atom->getScope() == ObjectFile::Atom::scopeTranslationUnit ) { // static function or data SymbolTable::Mapper::iterator pos = hashTableOfTranslationUnitScopedSymbols.find(name); if ( pos == hashTableOfTranslationUnitScopedSymbols.end() ) @@ -2119,37 +2081,6 @@ ObjectFile::Atom* Linker::findAtom(const Options::OrderedSymbol& orderedSymbol) } } - // look for name in hashTableOfSymbolsWithAnonymousNamespace - if ( usesAnonymousNamespace(orderedSymbol.symbolName) ) { - // symbol that uses anonymous namespace - char canonicalName[strlen(orderedSymbol.symbolName)+2]; - canonicalizeAnonymousName(orderedSymbol.symbolName, canonicalName); - SymbolTable::Mapper::iterator pos = hashTableOfSymbolsWithAnonymousNamespace.find(canonicalName); - if ( pos != hashTableOfSymbolsWithAnonymousNamespace.end() ) { - if ( (pos->second != NULL) && matchesObjectFile(pos->second, orderedSymbol.objectFileName) ) { - //fprintf(stderr, "found %s in anonymous namespace hash table\n", canonicalName); - return pos->second; - } - if ( pos->second == NULL ) - // name is in hash table, but atom is NULL, so that means there are duplicates, so we use super slow way - for (std::vector::iterator it=fAllAtoms.begin(); it != fAllAtoms.end(); it++) { - atom = *it; - const char* name = atom->getName(); - if ( (name != NULL) && usesAnonymousNamespace(name) ) { - char canonicalAtomName[strlen(name)+2]; - canonicalizeAnonymousName(name, canonicalAtomName); - if ( strcmp(canonicalAtomName, canonicalName) == 0 ) { - if ( matchesObjectFile(atom, orderedSymbol.objectFileName) ) { - if ( fOptions.printOrderFileStatistics() ) - warning("%s specified in order_file but it exists in multiple .o files. " - "Prefix symbol with .o filename in order_file to disambiguate", orderedSymbol.symbolName); - return atom; - } - } - } - } - } - } } return NULL; } -- 2.45.2