| ... | @@ -1905,11 +1905,21 @@ pub fn allocateAtom(self: *MachO, atom: *TextBlock, match: MatchingSection) !u64 | ... | @@ -1905,11 +1905,21 @@ pub fn allocateAtom(self: *MachO, atom: *TextBlock, match: MatchingSection) !u64 |
| 1905 | const vaddr = outer: { | 1905 | const vaddr = outer: { |
| 1906 | if (!use_stage1) { | 1906 | if (!use_stage1) { |
| 1907 | const sym = &self.locals.items[atom.local_sym_index]; | 1907 | const sym = &self.locals.items[atom.local_sym_index]; |
| 1908 | const needs_padding = blk: { | 1908 | // Padding is not required for pointer-type sections and any synthetic sections such as |
| 1909 | // TODO is __text the only section that benefits from padding? | 1909 | // stubs or stub_helper. |
| 1910 | if (match.seg == self.text_segment_cmd_index.? and | 1910 | // TODO audit this. |
| 1911 | match.sect == self.text_section_index.?) break :blk true; | 1911 | const needs_padding = switch (commands.sectionType(sect.*)) { |
| 1912 | break :blk false; | 1912 | macho.S_SYMBOL_STUBS, |
| | 1913 | macho.S_NON_LAZY_SYMBOL_POINTERS, |
| | 1914 | macho.S_LAZY_SYMBOL_POINTERS, |
| | 1915 | macho.S_LITERAL_POINTERS, |
| | 1916 | macho.S_THREAD_LOCAL_VARIABLES, |
| | 1917 | => false, |
| | 1918 | else => blk: { |
| | 1919 | if (match.seg == self.text_segment_cmd_index.? and |
| | 1920 | match.sect == self.stub_helper_section_index.?) break :blk false; |
| | 1921 | break :blk true; |
| | 1922 | }, |
| 1913 | }; | 1923 | }; |
| 1914 | | 1924 | |
| 1915 | var atom_placement: ?*TextBlock = null; | 1925 | var atom_placement: ?*TextBlock = null; |