authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-09-02 00:44:33+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-09-02 00:44:33+02:00
log4741c04254790fedcebdce7d13b27c6ba31ac412
treeaebe8fc5e99b50e84b0d104c1558c6ea4e829232
parent9dbad2d1888aae19f0411cc6de27171abc4e96f5

macho: better spec for sections which don't require padding


1 files changed, 15 insertions(+), 5 deletions(-)

src/link/MachO.zig+15-5
......@@ -1905,11 +1905,21 @@ pub fn allocateAtom(self: *MachO, atom: *TextBlock, match: MatchingSection) !u64
19051905 const vaddr = outer: {
19061906 if (!use_stage1) {
19071907 const sym = &self.locals.items[atom.local_sym_index];
1908 const needs_padding = blk: {
1909 // TODO is __text the only section that benefits from padding?
1910 if (match.seg == self.text_segment_cmd_index.? and
1911 match.sect == self.text_section_index.?) break :blk true;
1912 break :blk false;
1908 // Padding is not required for pointer-type sections and any synthetic sections such as
1909 // stubs or stub_helper.
1910 // TODO audit this.
1911 const needs_padding = switch (commands.sectionType(sect.*)) {
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 },
19131923 };
19141924
19151925 var atom_placement: ?*TextBlock = null;