| ... | @@ -63,17 +63,16 @@ pub const Reloc = struct { | ... | @@ -63,17 +63,16 @@ pub const Reloc = struct { |
| 63 | pub fn populateMissingMetadata(self: *DebugSymbols, allocator: Allocator) !void { | 63 | pub fn populateMissingMetadata(self: *DebugSymbols, allocator: Allocator) !void { |
| 64 | if (self.linkedit_segment_cmd_index == null) { | 64 | if (self.linkedit_segment_cmd_index == null) { |
| 65 | self.linkedit_segment_cmd_index = @intCast(u8, self.segments.items.len); | 65 | self.linkedit_segment_cmd_index = @intCast(u8, self.segments.items.len); |
| 66 | log.debug("found __LINKEDIT segment free space 0x{x} to 0x{x}", .{ | 66 | const fileoff = @intCast(u64, self.base.page_size); |
| 67 | self.base.page_size, | 67 | const needed_size = @intCast(u64, self.base.page_size) * 2; |
| 68 | self.base.page_size * 2, | 68 | log.debug("found __LINKEDIT segment free space 0x{x} to 0x{x}", .{ fileoff, needed_size }); |
| 69 | }); | | |
| 70 | // TODO this needs reworking | 69 | // TODO this needs reworking |
| 71 | try self.segments.append(allocator, .{ | 70 | try self.segments.append(allocator, .{ |
| 72 | .segname = makeStaticString("__LINKEDIT"), | 71 | .segname = makeStaticString("__LINKEDIT"), |
| 73 | .vmaddr = self.base.page_size, | 72 | .vmaddr = fileoff, |
| 74 | .vmsize = self.base.page_size, | 73 | .vmsize = needed_size, |
| 75 | .fileoff = self.base.page_size, | 74 | .fileoff = fileoff, |
| 76 | .filesize = self.base.page_size, | 75 | .filesize = needed_size, |
| 77 | .maxprot = macho.PROT.READ, | 76 | .maxprot = macho.PROT.READ, |
| 78 | .initprot = macho.PROT.READ, | 77 | .initprot = macho.PROT.READ, |
| 79 | .cmdsize = @sizeOf(macho.segment_command_64), | 78 | .cmdsize = @sizeOf(macho.segment_command_64), |
| ... | @@ -284,6 +283,7 @@ pub fn flushModule(self: *DebugSymbols, allocator: Allocator, options: link.Opti | ... | @@ -284,6 +283,7 @@ pub fn flushModule(self: *DebugSymbols, allocator: Allocator, options: link.Opti |
| 284 | const lc_writer = lc_buffer.writer(); | 283 | const lc_writer = lc_buffer.writer(); |
| 285 | var ncmds: u32 = 0; | 284 | var ncmds: u32 = 0; |
| 286 | | 285 | |
| | 286 | self.updateDwarfSegment(); |
| 287 | try self.writeLinkeditSegmentData(&ncmds, lc_writer); | 287 | try self.writeLinkeditSegmentData(&ncmds, lc_writer); |
| 288 | self.updateDwarfSegment(); | 288 | self.updateDwarfSegment(); |
| 289 | | 289 | |