]> git.saurik.com Git - apple/ld64.git/blobdiff - src/MachOWriterExecutable.hpp
ld64-85.2.1.tar.gz
[apple/ld64.git] / src / MachOWriterExecutable.hpp
index f983c6c2e80365e94c61207ad6489b19af977ca8..8667ae4e73a753302dbeb3549ee18dcfa65abf9c 100644 (file)
@@ -6550,6 +6550,8 @@ void Writer<A>::partitionIntoSections()
                                        currentSegmentInfo->fInitProtection = initprot;
                                        if ( initprot == 0 )
                                                currentSegmentInfo->fMaxProtection = 0;  // pagezero should have maxprot==initprot==0
+                                       else if ( fOptions.architecture() == CPU_TYPE_ARM )
+                                               currentSegmentInfo->fMaxProtection = currentSegmentInfo->fInitProtection; // iPhoneOS wants max==init
                                        else
                                                currentSegmentInfo->fMaxProtection = VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE;
                                        std::vector<Options::SegmentProtect>& customSegProtections = fOptions.customSegmentProtections();
@@ -6951,7 +6953,7 @@ void Writer<A>::adjustLoadCommandsAndPadding()
        }
        else if ( fOptions.makeEncryptable() ) {
                // want load commands to end on a page boundary, so __text starts on page boundary
-               paddingSize = 4096 - (totalSizeOfHeaderAndLoadCommands % 4096);
+               paddingSize = 4096 - ((totalSizeOfHeaderAndLoadCommands+fOptions.minimumHeaderPad()) % 4096) + fOptions.minimumHeaderPad();
                fEncryptionLoadCommand->setStartEncryptionOffset(totalSizeOfHeaderAndLoadCommands+paddingSize);
        }
        else {