| ... | ... | @@ -127,7 +127,6 @@ tlv_bss_section_index: ?u16 = null, |
| 127 | 127 | la_symbol_ptr_section_index: ?u16 = null, |
| 128 | 128 | data_section_index: ?u16 = null, |
| 129 | 129 | bss_section_index: ?u16 = null, |
| 130 | | common_section_index: ?u16 = null, |
| 131 | 130 | |
| 132 | 131 | objc_const_section_index: ?u16 = null, |
| 133 | 132 | objc_selrefs_section_index: ?u16 = null, |
| ... | ... | @@ -1222,31 +1221,17 @@ pub fn getMatchingSection(self: *MachO, sect: macho.section_64) !?MatchingSectio |
| 1222 | 1221 | }; |
| 1223 | 1222 | }, |
| 1224 | 1223 | macho.S_ZEROFILL => { |
| 1225 | | if (mem.eql(u8, sectname, "__common")) { |
| 1226 | | if (self.common_section_index == null) { |
| 1227 | | self.common_section_index = @intCast(u16, data_seg.sections.items.len); |
| 1228 | | try data_seg.addSection(self.base.allocator, "__common", .{ |
| 1229 | | .flags = macho.S_ZEROFILL, |
| 1230 | | }); |
| 1231 | | } |
| 1232 | | |
| 1233 | | break :blk .{ |
| 1234 | | .seg = self.data_segment_cmd_index.?, |
| 1235 | | .sect = self.common_section_index.?, |
| 1236 | | }; |
| 1237 | | } else { |
| 1238 | | if (self.bss_section_index == null) { |
| 1239 | | self.bss_section_index = @intCast(u16, data_seg.sections.items.len); |
| 1240 | | try data_seg.addSection(self.base.allocator, "__bss", .{ |
| 1241 | | .flags = macho.S_ZEROFILL, |
| 1242 | | }); |
| 1243 | | } |
| 1244 | | |
| 1245 | | break :blk .{ |
| 1246 | | .seg = self.data_segment_cmd_index.?, |
| 1247 | | .sect = self.bss_section_index.?, |
| 1248 | | }; |
| 1224 | if (self.bss_section_index == null) { |
| 1225 | self.bss_section_index = @intCast(u16, data_seg.sections.items.len); |
| 1226 | try data_seg.addSection(self.base.allocator, "__bss", .{ |
| 1227 | .flags = macho.S_ZEROFILL, |
| 1228 | }); |
| 1249 | 1229 | } |
| 1230 | |
| 1231 | break :blk .{ |
| 1232 | .seg = self.data_segment_cmd_index.?, |
| 1233 | .sect = self.bss_section_index.?, |
| 1234 | }; |
| 1250 | 1235 | }, |
| 1251 | 1236 | macho.S_THREAD_LOCAL_VARIABLES => { |
| 1252 | 1237 | if (self.tlv_section_index == null) { |
| ... | ... | @@ -1598,7 +1583,6 @@ fn sortSections(self: *MachO) !void { |
| 1598 | 1583 | &self.tlv_data_section_index, |
| 1599 | 1584 | &self.tlv_bss_section_index, |
| 1600 | 1585 | &self.bss_section_index, |
| 1601 | | &self.common_section_index, |
| 1602 | 1586 | }; |
| 1603 | 1587 | for (indices) |maybe_index| { |
| 1604 | 1588 | const new_index: u16 = if (maybe_index.*) |index| blk: { |
| ... | ... | @@ -2578,16 +2562,16 @@ fn resolveSymbols(self: *MachO) !void { |
| 2578 | 2562 | while (tentatives.popOrNull()) |entry| { |
| 2579 | 2563 | const sym = &self.globals.items[entry.key]; |
| 2580 | 2564 | const match: MatchingSection = blk: { |
| 2581 | | if (self.common_section_index == null) { |
| 2565 | if (self.bss_section_index == null) { |
| 2582 | 2566 | const data_seg = &self.load_commands.items[self.data_segment_cmd_index.?].Segment; |
| 2583 | | self.common_section_index = @intCast(u16, data_seg.sections.items.len); |
| 2584 | | try data_seg.addSection(self.base.allocator, "__common", .{ |
| 2567 | self.bss_section_index = @intCast(u16, data_seg.sections.items.len); |
| 2568 | try data_seg.addSection(self.base.allocator, "__bss", .{ |
| 2585 | 2569 | .flags = macho.S_ZEROFILL, |
| 2586 | 2570 | }); |
| 2587 | 2571 | } |
| 2588 | 2572 | break :blk .{ |
| 2589 | 2573 | .seg = self.data_segment_cmd_index.?, |
| 2590 | | .sect = self.common_section_index.?, |
| 2574 | .sect = self.bss_section_index.?, |
| 2591 | 2575 | }; |
| 2592 | 2576 | }; |
| 2593 | 2577 | _ = try self.section_ordinals.getOrPut(self.base.allocator, match); |
| ... | ... | @@ -2890,23 +2874,17 @@ fn addLoadDylibLCs(self: *MachO) !void { |
| 2890 | 2874 | fn flushZld(self: *MachO) !void { |
| 2891 | 2875 | try self.writeTextBlocks(); |
| 2892 | 2876 | |
| 2893 | | if (self.common_section_index) |index| { |
| 2894 | | const seg = &self.load_commands.items[self.data_segment_cmd_index.?].Segment; |
| 2895 | | const sect = &seg.sections.items[index]; |
| 2896 | | sect.offset = 0; |
| 2897 | | } |
| 2898 | | |
| 2899 | | if (self.bss_section_index) |index| { |
| 2900 | | const seg = &self.load_commands.items[self.data_segment_cmd_index.?].Segment; |
| 2901 | | const sect = &seg.sections.items[index]; |
| 2902 | | sect.offset = 0; |
| 2903 | | } |
| 2904 | | |
| 2905 | | if (self.tlv_bss_section_index) |index| { |
| 2906 | | const seg = &self.load_commands.items[self.data_segment_cmd_index.?].Segment; |
| 2907 | | const sect = &seg.sections.items[index]; |
| 2908 | | sect.offset = 0; |
| 2909 | | } |
| 2877 | // if (self.bss_section_index) |index| { |
| 2878 | // const seg = &self.load_commands.items[self.data_segment_cmd_index.?].Segment; |
| 2879 | // const sect = &seg.sections.items[index]; |
| 2880 | // sect.offset = 0; |
| 2881 | // } |
| 2882 | |
| 2883 | // if (self.tlv_bss_section_index) |index| { |
| 2884 | // const seg = &self.load_commands.items[self.data_segment_cmd_index.?].Segment; |
| 2885 | // const sect = &seg.sections.items[index]; |
| 2886 | // sect.offset = 0; |
| 2887 | // } |
| 2910 | 2888 | |
| 2911 | 2889 | try self.setEntryPoint(); |
| 2912 | 2890 | try self.writeRebaseInfoTableZld(); |