Add names for mach-o permissions bits and use the symbol names in place of magic numbers

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190013 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Nick Kledzik 2013-09-04 23:53:44 +00:00
parent 5afaf5d1c1
commit a38c27be0f
2 changed files with 13 additions and 2 deletions

View File

@ -417,6 +417,15 @@ namespace llvm {
X86_64_RELOC_TLV = 9
};
// Values for segment_command.initprot.
// From <mach/vm_prot.h>
enum {
VM_PROT_READ = 0x1,
VM_PROT_WRITE = 0x2,
VM_PROT_EXECUTE = 0x4
};
// Structs from <mach-o/loader.h>
struct mach_header {

View File

@ -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