]> git.saurik.com Git - apple/ld64.git/blobdiff - src/ld/passes/objc.cpp
ld64-264.3.101.tar.gz
[apple/ld64.git] / src / ld / passes / objc.cpp
index ad4673cf564f94e764e7612c3adc5d67374cde13..c65ca2122282e5cc2abf7c5e82a99bd1a882ff0f 100644 (file)
@@ -755,6 +755,21 @@ bool OptimizeCategories<A>::hasProperties(ld::Internal& state, const std::vector
 }
 
 
+static const ld::Atom* fixClassAliases(const ld::Atom* classAtom)
+{
+       if ( (classAtom->size() != 0) || (classAtom->definition() == ld::Atom::definitionProxy) )
+               return classAtom;
+
+       for (ld::Fixup::iterator fit=classAtom->fixupsBegin(); fit != classAtom->fixupsEnd(); ++fit) {
+               if ( fit->kind == ld::Fixup::kindNoneFollowOn ) {
+                       assert(fit->offsetInAtom == 0);
+                       assert(fit->binding == ld::Fixup::bindingDirectlyBound);
+                       return fit->u.target;
+               }
+       }
+
+       return classAtom;
+}
 
 //
 // Helper for std::remove_if
@@ -841,7 +856,7 @@ void OptimizeCategories<A>::doit(const Options& opts, ld::Internal& state)
                                // ignore categories also in __objc_nlcatlist
                                if ( nlcatListAtoms.count(categoryAtom) != 0 )
                                        continue;
-                               const ld::Atom* categoryOnClassAtom = Category<A>::getClass(state, categoryAtom, hasAddend); 
+                               const ld::Atom* categoryOnClassAtom = fixClassAliases(Category<A>::getClass(state, categoryAtom, hasAddend));
                                assert(categoryOnClassAtom != NULL);
                                // only look at classes defined in this image
                                if ( categoryOnClassAtom->definition() != ld::Atom::definitionProxy ) {