| ... | @@ -262,11 +262,11 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void { | ... | @@ -262,11 +262,11 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void { |
| 262 | dysymtab.iundefsym = nlocals + nglobals; | 262 | dysymtab.iundefsym = nlocals + nglobals; |
| 263 | dysymtab.nundefsym = nundefs; | 263 | dysymtab.nundefsym = nundefs; |
| 264 | } | 264 | } |
| 265 | { | 265 | if (self.entry_addr) |addr| { |
| 266 | // update LC_MAIN with entry offset | 266 | // update LC_MAIN with entry offset |
| 267 | const text_segment = self.load_commands.items[self.text_segment_cmd_index.?].Segment; | 267 | const text_segment = self.load_commands.items[self.text_segment_cmd_index.?].Segment; |
| 268 | const main_cmd = &self.load_commands.items[self.main_cmd_index.?].EntryPoint; | 268 | const main_cmd = &self.load_commands.items[self.main_cmd_index.?].EntryPoint; |
| 269 | main_cmd.entryoff = self.entry_addr.? - text_segment.vmaddr; | 269 | main_cmd.entryoff = addr - text_segment.vmaddr; |
| 270 | } | 270 | } |
| 271 | { | 271 | { |
| 272 | var last_cmd_offset: usize = @sizeOf(macho.mach_header_64); | 272 | var last_cmd_offset: usize = @sizeOf(macho.mach_header_64); |
| ... | @@ -709,6 +709,7 @@ fn darwinArchString(arch: std.Target.Cpu.Arch) []const u8 { | ... | @@ -709,6 +709,7 @@ fn darwinArchString(arch: std.Target.Cpu.Arch) []const u8 { |
| 709 | pub fn deinit(self: *MachO) void { | 709 | pub fn deinit(self: *MachO) void { |
| 710 | self.offset_table.deinit(self.base.allocator); | 710 | self.offset_table.deinit(self.base.allocator); |
| 711 | self.string_table.deinit(self.base.allocator); | 711 | self.string_table.deinit(self.base.allocator); |
| | 712 | self.undef_symbols.deinit(self.base.allocator); |
| 712 | self.global_symbols.deinit(self.base.allocator); | 713 | self.global_symbols.deinit(self.base.allocator); |
| 713 | self.local_symbols.deinit(self.base.allocator); | 714 | self.local_symbols.deinit(self.base.allocator); |
| 714 | self.sections.deinit(self.base.allocator); | 715 | self.sections.deinit(self.base.allocator); |
| ... | @@ -813,7 +814,7 @@ pub fn updateDeclExports( | ... | @@ -813,7 +814,7 @@ pub fn updateDeclExports( |
| 813 | try module.failed_exports.ensureCapacity(module.gpa, module.failed_exports.items().len + 1); | 814 | try module.failed_exports.ensureCapacity(module.gpa, module.failed_exports.items().len + 1); |
| 814 | module.failed_exports.putAssumeCapacityNoClobber( | 815 | module.failed_exports.putAssumeCapacityNoClobber( |
| 815 | exp, | 816 | exp, |
| 816 | try Module.ErrorMsg.create(self.base.allocator, 0, "Unimplemented: ExportOptions.section", .{}), | 817 | try Compilation.ErrorMsg.create(self.base.allocator, 0, "Unimplemented: ExportOptions.section", .{}), |
| 817 | ); | 818 | ); |
| 818 | continue; | 819 | continue; |
| 819 | } | 820 | } |
| ... | @@ -831,7 +832,7 @@ pub fn updateDeclExports( | ... | @@ -831,7 +832,7 @@ pub fn updateDeclExports( |
| 831 | try module.failed_exports.ensureCapacity(module.gpa, module.failed_exports.items().len + 1); | 832 | try module.failed_exports.ensureCapacity(module.gpa, module.failed_exports.items().len + 1); |
| 832 | module.failed_exports.putAssumeCapacityNoClobber( | 833 | module.failed_exports.putAssumeCapacityNoClobber( |
| 833 | exp, | 834 | exp, |
| 834 | try Module.ErrorMsg.create(self.base.allocator, 0, "Unimplemented: GlobalLinkage.LinkOnce", .{}), | 835 | try Compilation.ErrorMsg.create(self.base.allocator, 0, "Unimplemented: GlobalLinkage.LinkOnce", .{}), |
| 835 | ); | 836 | ); |
| 836 | continue; | 837 | continue; |
| 837 | }, | 838 | }, |
| ... | @@ -1405,6 +1406,8 @@ fn writeAllUndefSymbols(self: *MachO) !void { | ... | @@ -1405,6 +1406,8 @@ fn writeAllUndefSymbols(self: *MachO) !void { |
| 1405 | } | 1406 | } |
| 1406 | | 1407 | |
| 1407 | fn writeExportTrie(self: *MachO) !void { | 1408 | fn writeExportTrie(self: *MachO) !void { |
| | 1409 | if (self.entry_addr == null) return; |
| | 1410 | |
| 1408 | // TODO implement mechanism for generating a prefix tree of the exported symbols | 1411 | // TODO implement mechanism for generating a prefix tree of the exported symbols |
| 1409 | // single branch export trie | 1412 | // single branch export trie |
| 1410 | var buf = [_]u8{0} ** 24; | 1413 | var buf = [_]u8{0} ** 24; |