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 {...@@ -1142,7 +1142,8 @@ pub fn populateMissingMetadata(self: *MachO) !void {
1142 }1142 }
1143 if (self.text_segment_cmd_index == null) {1143 if (self.text_segment_cmd_index == null) {
1144 self.text_segment_cmd_index = @intCast(u16, self.load_commands.items.len);1144 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;
1146 try self.load_commands.append(self.base.allocator, .{1147 try self.load_commands.append(self.base.allocator, .{
1147 .Segment = .{1148 .Segment = .{
1148 .cmd = macho.LC_SEGMENT_64,1149 .cmd = macho.LC_SEGMENT_64,
...@@ -1152,8 +1153,8 @@ pub fn populateMissingMetadata(self: *MachO) !void {...@@ -1152,8 +1153,8 @@ pub fn populateMissingMetadata(self: *MachO) !void {
1152 .vmsize = 0,1153 .vmsize = 0,
1153 .fileoff = 0,1154 .fileoff = 0,
1154 .filesize = 0,1155 .filesize = 0,
1155 .maxprot = prot,1156 .maxprot = maxprot,
1156 .initprot = prot,1157 .initprot = initprot,
1157 .nsects = 0,1158 .nsects = 0,
1158 .flags = 0,1159 .flags = 0,
1159 },1160 },
...@@ -1194,7 +1195,8 @@ pub fn populateMissingMetadata(self: *MachO) !void {...@@ -1194,7 +1195,8 @@ pub fn populateMissingMetadata(self: *MachO) !void {
1194 if (self.data_segment_cmd_index == null) {1195 if (self.data_segment_cmd_index == null) {
1195 self.data_segment_cmd_index = @intCast(u16, self.load_commands.items.len);1196 self.data_segment_cmd_index = @intCast(u16, self.load_commands.items.len);
1196 const text_segment = &self.load_commands.items[self.text_segment_cmd_index.?].Segment;1197 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;
1198 try self.load_commands.append(self.base.allocator, .{1200 try self.load_commands.append(self.base.allocator, .{
1199 .Segment = .{1201 .Segment = .{
1200 .cmd = macho.LC_SEGMENT_64,1202 .cmd = macho.LC_SEGMENT_64,
...@@ -1204,8 +1206,8 @@ pub fn populateMissingMetadata(self: *MachO) !void {...@@ -1204,8 +1206,8 @@ pub fn populateMissingMetadata(self: *MachO) !void {
1204 .vmsize = 0,1206 .vmsize = 0,
1205 .fileoff = 0,1207 .fileoff = 0,
1206 .filesize = 0,1208 .filesize = 0,
1207 .maxprot = prot,1209 .maxprot = maxprot,
1208 .initprot = prot,1210 .initprot = initprot,
1209 .nsects = 0,1211 .nsects = 0,
1210 .flags = 0,1212 .flags = 0,
1211 },1213 },