authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2020-11-13 22:20:07+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2020-11-26 11:50:09+01:00
logb3fdfe5ca055245e0184f09684329736fd020409
tree2780da4be48e88826224f2262fd7c974b0231fd4
parent7dd5ce25270ddd3a3ba3570e89654e305dbc2e76

stage2 MachO: clean up segment protection flags


1 files changed, 8 insertions(+), 6 deletions(-)

src/link/MachO.zig+8-6
......@@ -1142,7 +1142,8 @@ pub fn populateMissingMetadata(self: *MachO) !void {
11421142 }
11431143 if (self.text_segment_cmd_index == null) {
11441144 self.text_segment_cmd_index = @intCast(u16, self.load_commands.items.len);
1145 const prot = macho.VM_PROT_READ | macho.VM_PROT_EXECUTE;
1145 const maxprot = macho.VM_PROT_READ | macho.VM_PROT_WRITE | macho.VM_PROT_EXECUTE;
1146 const initprot = macho.VM_PROT_READ | macho.VM_PROT_EXECUTE;
11461147 try self.load_commands.append(self.base.allocator, .{
11471148 .Segment = .{
11481149 .cmd = macho.LC_SEGMENT_64,
......@@ -1152,8 +1153,8 @@ pub fn populateMissingMetadata(self: *MachO) !void {
11521153 .vmsize = 0,
11531154 .fileoff = 0,
11541155 .filesize = 0,
1155 .maxprot = prot,
1156 .initprot = prot,
1156 .maxprot = maxprot,
1157 .initprot = initprot,
11571158 .nsects = 0,
11581159 .flags = 0,
11591160 },
......@@ -1194,7 +1195,8 @@ pub fn populateMissingMetadata(self: *MachO) !void {
11941195 if (self.data_segment_cmd_index == null) {
11951196 self.data_segment_cmd_index = @intCast(u16, self.load_commands.items.len);
11961197 const text_segment = &self.load_commands.items[self.text_segment_cmd_index.?].Segment;
1197 const prot = macho.VM_PROT_READ | macho.VM_PROT_WRITE;
1198 const maxprot = macho.VM_PROT_READ | macho.VM_PROT_WRITE | macho.VM_PROT_EXECUTE;
1199 const initprot = macho.VM_PROT_READ | macho.VM_PROT_WRITE;
11981200 try self.load_commands.append(self.base.allocator, .{
11991201 .Segment = .{
12001202 .cmd = macho.LC_SEGMENT_64,
......@@ -1204,8 +1206,8 @@ pub fn populateMissingMetadata(self: *MachO) !void {
12041206 .vmsize = 0,
12051207 .fileoff = 0,
12061208 .filesize = 0,
1207 .maxprot = prot,
1208 .initprot = prot,
1209 .maxprot = maxprot,
1210 .initprot = initprot,
12091211 .nsects = 0,
12101212 .flags = 0,
12111213 },