Index: lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp =================================================================== --- lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp +++ lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp @@ -1631,6 +1631,17 @@ normFile.pageSize = context.pageSize(); normFile.rpaths = context.rpaths(); util.addDependentDylibs(atomFile, normFile); + if (context.outputMachOType() == MH_DYLIB) { + // If we're not re-exporting any dylib set MH_NO_REEXPORTED_DYLIBS + normFile.flags = normFile.flags | MH_NO_REEXPORTED_DYLIBS; + for (DependentDylib § : normFile.dependentDylibs) { + if (sect.kind == llvm::MachO::LC_REEXPORT_DYLIB) { + normFile.flags = normFile.flags &~ MH_NO_REEXPORTED_DYLIBS; + break; + } + } + } + util.copySegmentInfo(normFile); util.copySectionInfo(normFile); util.assignAddressesToSections(normFile);