| ... | ... | @@ -144,9 +144,6 @@ objc_data_section_index: ?u16 = null, |
| 144 | 144 | rustc_section_index: ?u16 = null, |
| 145 | 145 | rustc_section_size: u64 = 0, |
| 146 | 146 | |
| 147 | | bss_file_offset: u32 = 0, |
| 148 | | tlv_bss_file_offset: u32 = 0, |
| 149 | | |
| 150 | 147 | locals: std.ArrayListUnmanaged(macho.nlist_64) = .{}, |
| 151 | 148 | globals: std.ArrayListUnmanaged(macho.nlist_64) = .{}, |
| 152 | 149 | undefs: std.ArrayListUnmanaged(macho.nlist_64) = .{}, |
| ... | ... | @@ -383,7 +380,8 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*MachO { |
| 383 | 380 | // Adhoc code signature is required when targeting aarch64-macos either directly or indirectly via the simulator |
| 384 | 381 | // ABI such as aarch64-ios-simulator, etc. |
| 385 | 382 | const requires_adhoc_codesig = cpu_arch == .aarch64 and (os_tag == .macos or abi == .simulator); |
| 386 | | const needs_prealloc = !(build_options.is_stage1 and options.use_stage1); |
| 383 | const use_stage1 = build_options.is_stage1 and options.use_stage1; |
| 384 | const needs_prealloc = !(use_stage1 or options.cache_mode == .whole); |
| 387 | 385 | |
| 388 | 386 | const self = try gpa.create(MachO); |
| 389 | 387 | errdefer gpa.destroy(self); |
| ... | ... | @@ -401,7 +399,6 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*MachO { |
| 401 | 399 | }; |
| 402 | 400 | |
| 403 | 401 | const use_llvm = build_options.have_llvm and options.use_llvm; |
| 404 | | const use_stage1 = build_options.is_stage1 and options.use_stage1; |
| 405 | 402 | if (use_llvm and !use_stage1) { |
| 406 | 403 | self.llvm_object = try LlvmObject.create(gpa, options); |
| 407 | 404 | } |
| ... | ... | @@ -2158,7 +2155,8 @@ fn writeAtoms(self: *MachO) !void { |
| 2158 | 2155 | const sect = seg.sections.items[match.sect]; |
| 2159 | 2156 | var atom: *Atom = entry.value_ptr.*; |
| 2160 | 2157 | |
| 2161 | | if (sect.flags == macho.S_ZEROFILL or sect.flags == macho.S_THREAD_LOCAL_ZEROFILL) continue; |
| 2158 | // TODO handle zerofill in stage2 |
| 2159 | // if (sect.flags == macho.S_ZEROFILL or sect.flags == macho.S_THREAD_LOCAL_ZEROFILL) continue; |
| 2162 | 2160 | |
| 2163 | 2161 | log.debug("writing atoms in {s},{s}", .{ sect.segName(), sect.sectName() }); |
| 2164 | 2162 | |
| ... | ... | @@ -4756,9 +4754,12 @@ fn allocateSegment(self: *MachO, index: u16, offset: u64) !void { |
| 4756 | 4754 | var start: u64 = offset; |
| 4757 | 4755 | for (seg.sections.items) |*sect, sect_id| { |
| 4758 | 4756 | const is_zerofill = sect.flags == macho.S_ZEROFILL or sect.flags == macho.S_THREAD_LOCAL_ZEROFILL; |
| 4757 | const use_stage1 = build_options.is_stage1 and self.base.options.use_stage1; |
| 4759 | 4758 | const alignment = try math.powi(u32, 2, sect.@"align"); |
| 4760 | 4759 | const start_aligned = mem.alignForwardGeneric(u64, start, alignment); |
| 4761 | | sect.offset = if (is_zerofill) 0 else @intCast(u32, seg.inner.fileoff + start_aligned); |
| 4760 | |
| 4761 | // TODO handle zerofill sections in stage2 |
| 4762 | sect.offset = if (is_zerofill and use_stage1) 0 else @intCast(u32, seg.inner.fileoff + start_aligned); |
| 4762 | 4763 | sect.addr = seg.inner.vmaddr + start_aligned; |
| 4763 | 4764 | |
| 4764 | 4765 | // Recalculate section size given the allocated start address |
| ... | ... | @@ -4786,7 +4787,7 @@ fn allocateSegment(self: *MachO, index: u16, offset: u64) !void { |
| 4786 | 4787 | |
| 4787 | 4788 | start = start_aligned + sect.size; |
| 4788 | 4789 | |
| 4789 | | if (!is_zerofill) { |
| 4790 | if (!(is_zerofill and use_stage1)) { |
| 4790 | 4791 | seg.inner.filesize = start; |
| 4791 | 4792 | } |
| 4792 | 4793 | seg.inner.vmsize = start; |
| ... | ... | @@ -4834,7 +4835,11 @@ fn initSection( |
| 4834 | 4835 | |
| 4835 | 4836 | sect.addr = seg.inner.vmaddr + off - seg.inner.fileoff; |
| 4836 | 4837 | |
| 4837 | | if (opts.flags != macho.S_ZEROFILL and opts.flags != macho.S_THREAD_LOCAL_ZEROFILL) { |
| 4838 | const is_zerofill = opts.flags == macho.S_ZEROFILL or opts.flags == macho.S_THREAD_LOCAL_ZEROFILL; |
| 4839 | const use_stage1 = build_options.is_stage1 and self.base.options.use_stage1; |
| 4840 | |
| 4841 | // TODO handle zerofill in stage2 |
| 4842 | if (!(is_zerofill and use_stage1)) { |
| 4838 | 4843 | sect.offset = @intCast(u32, off); |
| 4839 | 4844 | } |
| 4840 | 4845 | } |