| ... | @@ -1929,7 +1929,19 @@ pub fn allocateAtom(self: *MachO, atom: *TextBlock, match: MatchingSection) !u64 | ... | @@ -1929,7 +1929,19 @@ pub fn allocateAtom(self: *MachO, atom: *TextBlock, match: MatchingSection) !u64 |
| 1929 | | 1929 | |
| 1930 | const expand_section = atom_placement == null or atom_placement.?.next == null; | 1930 | const expand_section = atom_placement == null or atom_placement.?.next == null; |
| 1931 | if (expand_section) { | 1931 | if (expand_section) { |
| 1932 | const max_size = seg.allocatedSize(vaddr - pagezero_vmsize); | 1932 | const sect_offset: u64 = blk: { |
| | 1933 | if (self.data_segment_cmd_index.? == match.seg) { |
| | 1934 | if (self.bss_section_index) |idx| { |
| | 1935 | if (idx == match.sect) break :blk self.bss_file_offset.?; |
| | 1936 | } |
| | 1937 | if (self.tlv_bss_section_index) |idx| { |
| | 1938 | if (idx == match.sect) break :blk self.tlv_bss_file_offset.?; |
| | 1939 | } |
| | 1940 | } |
| | 1941 | break :blk sect.offset; |
| | 1942 | }; |
| | 1943 | const file_offset = sect_offset + vaddr - sect.addr; |
| | 1944 | const max_size = seg.allocatedSize(file_offset); |
| 1933 | log.debug(" (atom size 0x{x}, max available size 0x{x})", .{ atom.size, max_size }); | 1945 | log.debug(" (atom size 0x{x}, max available size 0x{x})", .{ atom.size, max_size }); |
| 1934 | assert(atom.size <= max_size); // TODO must expand the section | 1946 | assert(atom.size <= max_size); // TODO must expand the section |
| 1935 | } | 1947 | } |