X-Git-Url: https://git.saurik.com/apple/ld64.git/blobdiff_plain/599556ff3dd31aab68bb9685f1ed7fc4867803e7..fb9a160cc46cd88a41dda5ab61012c5572e56f33:/src/ld/passes/objc.cpp diff --git a/src/ld/passes/objc.cpp b/src/ld/passes/objc.cpp index 2bbf54a..ad4673c 100644 --- a/src/ld/passes/objc.cpp +++ b/src/ld/passes/objc.cpp @@ -805,7 +805,7 @@ void OptimizeCategories::doit(const Options& opts, ld::Internal& state) std::set nlcatListAtoms; for (std::vector::iterator sit=state.sections.begin(); sit != state.sections.end(); ++sit) { ld::Internal::FinalSection* sect = *sit; - if ( (strcmp(sect->sectionName(), "__objc_nlcatlist") == 0) && (strcmp(sect->segmentName(), "__DATA") == 0) ) { + if ( (strcmp(sect->sectionName(), "__objc_nlcatlist") == 0) && (strncmp(sect->segmentName(), "__DATA", 6) == 0) ) { for (std::vector::iterator ait=sect->atoms.begin(); ait != sect->atoms.end(); ++ait) { const ld::Atom* categoryListElementAtom = *ait; for (unsigned int offset=0; offset < categoryListElementAtom->size(); offset += sizeof(pint_t)) { @@ -865,7 +865,7 @@ void OptimizeCategories::doit(const Options& opts, ld::Internal& state) } } // record method list section - if ( (strcmp(sect->sectionName(), "__objc_const") == 0) && (strcmp(sect->segmentName(), "__DATA") == 0) ) + if ( (strcmp(sect->sectionName(), "__objc_const") == 0) && (strncmp(sect->segmentName(), "__DATA", 6) == 0) ) methodListSection = sect; } @@ -885,9 +885,11 @@ void OptimizeCategories::doit(const Options& opts, ld::Internal& state) const ld::Atom* newClassRO = Class::setInstanceMethodList(state, classAtom, newInstanceMethodListAtom, deadAtoms); // add new method list to final sections methodListSection->atoms.push_back(newInstanceMethodListAtom); + state.atomToSection[newInstanceMethodListAtom] = methodListSection; if ( newClassRO != NULL ) { assert(strcmp(newClassRO->section().sectionName(), "__objc_const") == 0); methodListSection->atoms.push_back(newClassRO); + state.atomToSection[newClassRO] = methodListSection; } } // if any category adds class methods, generate new merged method list, and replace @@ -897,9 +899,11 @@ void OptimizeCategories::doit(const Options& opts, ld::Internal& state) const ld::Atom* newClassRO = Class::setClassMethodList(state, classAtom, newClassMethodListAtom, deadAtoms); // add new method list to final sections methodListSection->atoms.push_back(newClassMethodListAtom); + state.atomToSection[newClassMethodListAtom] = methodListSection; if ( newClassRO != NULL ) { assert(strcmp(newClassRO->section().sectionName(), "__objc_const") == 0); methodListSection->atoms.push_back(newClassRO); + state.atomToSection[newClassRO] = methodListSection; } } // if any category adds protocols, generate new merged protocol list, and replace @@ -910,13 +914,16 @@ void OptimizeCategories::doit(const Options& opts, ld::Internal& state) const ld::Atom* newMetaClassRO = Class::setClassProtocolList(state, classAtom, newProtocolListAtom, deadAtoms); // add new protocol list to final sections methodListSection->atoms.push_back(newProtocolListAtom); + state.atomToSection[newProtocolListAtom] = methodListSection; if ( newClassRO != NULL ) { assert(strcmp(newClassRO->section().sectionName(), "__objc_const") == 0); methodListSection->atoms.push_back(newClassRO); + state.atomToSection[newClassRO] = methodListSection; } if ( newMetaClassRO != NULL ) { assert(strcmp(newMetaClassRO->section().sectionName(), "__objc_const") == 0); methodListSection->atoms.push_back(newMetaClassRO); + state.atomToSection[newMetaClassRO] = methodListSection; } } // if any category adds properties, generate new merged property list, and replace @@ -926,9 +933,11 @@ void OptimizeCategories::doit(const Options& opts, ld::Internal& state) const ld::Atom* newClassRO = Class::setInstancePropertyList(state, classAtom, newPropertyListAtom, deadAtoms); // add new property list to final sections methodListSection->atoms.push_back(newPropertyListAtom); + state.atomToSection[newPropertyListAtom] = methodListSection; if ( newClassRO != NULL ) { assert(strcmp(newClassRO->section().sectionName(), "__objc_const") == 0); methodListSection->atoms.push_back(newClassRO); + state.atomToSection[newClassRO] = methodListSection; } }