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

Nick Kledzik kledzik at apple.com
Wed Sep 4 16:53:44 PDT 2013


Author: kledzik
Date: Wed Sep  4 18:53:44 2013
New Revision: 190013

URL: http://llvm.org/viewvc/llvm-project?rev=190013&view=rev
Log:
Add names for mach-o permissions bits and use the symbol names in place of magic numbers

Modified:
    llvm/trunk/include/llvm/Support/MachO.h
    llvm/trunk/lib/MC/MachObjectWriter.cpp

Modified: llvm/trunk/include/llvm/Support/MachO.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MachO.h?rev=190013&r1=190012&r2=190013&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/MachO.h (original)
+++ llvm/trunk/include/llvm/Support/MachO.h Wed Sep  4 18:53:44 2013
@@ -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 {

Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MachObjectWriter.cpp?rev=190013&r1=190012&r2=190013&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MachObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/MachObjectWriter.cpp Wed Sep  4 18:53:44 2013
@@ -185,8 +185,10 @@ void MachObjectWriter::WriteSegmentLoadC
     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
 





More information about the llvm-commits mailing list