diff --git a/include/llvm/Support/MachO.h b/include/llvm/Support/MachO.h index 9d401c8d366..59998ada020 100644 --- a/include/llvm/Support/MachO.h +++ b/include/llvm/Support/MachO.h @@ -417,6 +417,15 @@ namespace llvm { X86_64_RELOC_TLV = 9 }; + // Values for segment_command.initprot. + // From + enum { + VM_PROT_READ = 0x1, + VM_PROT_WRITE = 0x2, + VM_PROT_EXECUTE = 0x4 + }; + + // Structs from struct mach_header { diff --git a/lib/MC/MachObjectWriter.cpp b/lib/MC/MachObjectWriter.cpp index d0bfc65cb27..3531ab2247d 100644 --- a/lib/MC/MachObjectWriter.cpp +++ b/lib/MC/MachObjectWriter.cpp @@ -185,8 +185,10 @@ void MachObjectWriter::WriteSegmentLoadCommand(unsigned NumSections, Write32(SectionDataStartOffset); // file offset Write32(SectionDataSize); // file size } - Write32(0x7); // maxprot - Write32(0x7); // initprot + // maxprot + Write32(MachO::VM_PROT_READ | MachO::VM_PROT_WRITE | MachO::VM_PROT_EXECUTE); + // initprot + Write32(MachO::VM_PROT_READ | MachO::VM_PROT_WRITE | MachO::VM_PROT_EXECUTE); Write32(NumSections); Write32(0); // flags