Commit cb745c84 authored by Artem Pyanykh's avatar Artem Pyanykh Committed by Marge Bot

Add missing levels to SegmentProt enum

parent 3cdcc0b5
...@@ -62,9 +62,24 @@ typedef ...@@ -62,9 +62,24 @@ typedef
} }
SectionAlloc; SectionAlloc;
/* Indicates a desired memory protection for pages within a segment. Defined as
* enum since it's more explicit and look nicer in a debugger.
*
* Can be used directly as a substitution for a combination of PROT_X flags on
* POSIX systems.
*/
typedef enum { typedef enum {
#if RTS_LINKER_USE_MMAP
SEGMENT_PROT_RO = PROT_READ,
SEGMENT_PROT_RX = PROT_READ | PROT_EXEC,
SEGMENT_PROT_RWO = PROT_READ | PROT_WRITE,
SEGMENT_PROT_RWX = PROT_READ | PROT_WRITE | PROT_EXEC
#else
SEGMENT_PROT_RO,
SEGMENT_PROT_RX, SEGMENT_PROT_RX,
SEGMENT_PROT_RW SEGMENT_PROT_RWO,
SEGMENT_PROT_RWX
#endif
} SegmentProt; } SegmentProt;
/* /*
......
...@@ -1141,9 +1141,9 @@ ocBuildSegments_MachO(ObjectCode *oc) ...@@ -1141,9 +1141,9 @@ ocBuildSegments_MachO(ObjectCode *oc)
initSegment(rwSegment, initSegment(rwSegment,
curMem, curMem,
roundUpToPage(size_rwSegment), roundUpToPage(size_rwSegment),
SEGMENT_PROT_RW, SEGMENT_PROT_RWO,
n_rwSections); n_rwSections);
IF_DEBUG(linker, debugBelch("ocBuildSegments_MachO: init segment %d (RW) at %p size %zu\n", IF_DEBUG(linker, debugBelch("ocBuildSegments_MachO: init segment %d (RWO) at %p size %zu\n",
curSegment, rwSegment->start, rwSegment->size)); curSegment, rwSegment->start, rwSegment->size));
curMem = (char *)curMem + rwSegment->size; curMem = (char *)curMem + rwSegment->size;
curSegment++; curSegment++;
...@@ -1155,7 +1155,7 @@ ocBuildSegments_MachO(ObjectCode *oc) ...@@ -1155,7 +1155,7 @@ ocBuildSegments_MachO(ObjectCode *oc)
initSegment(gbZerofillSegment, initSegment(gbZerofillSegment,
curMem, curMem,
roundUpToPage(size_gbZerofillSegment), roundUpToPage(size_gbZerofillSegment),
SEGMENT_PROT_RW, SEGMENT_PROT_RWO,
n_gbZerofills); n_gbZerofills);
IF_DEBUG(linker, debugBelch("ocBuildSegments_MachO: init segment %d (GB_ZEROFILL) at %p size %zu\n", IF_DEBUG(linker, debugBelch("ocBuildSegments_MachO: init segment %d (GB_ZEROFILL) at %p size %zu\n",
curSegment, gbZerofillSegment->start, gbZerofillSegment->size)); curSegment, gbZerofillSegment->start, gbZerofillSegment->size));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment