authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-04-20 18:28:18+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-04-21 22:44:28+02:00
log9a181f367d51acc653379c173b7661f9c69e5ad4
tree5428336841bd12295486d350902fc3a6ea181df3
parenta596e48d8fa2ca6ae267dbb49458fe107c89b953

macho: mark relocs dirty by target when updating GOT/stubs


1 files changed, 3 insertions(+), 0 deletions(-)

src/link/MachO.zig+3
...@@ -1801,6 +1801,7 @@ fn addGotEntry(self: *MachO, target: SymbolWithLoc) !void {...@@ -1801,6 +1801,7 @@ fn addGotEntry(self: *MachO, target: SymbolWithLoc) !void {
1801 const got_index = try self.got_table.allocateEntry(self.base.allocator, target);1801 const got_index = try self.got_table.allocateEntry(self.base.allocator, target);
1802 try self.writeOffsetTableEntry(got_index);1802 try self.writeOffsetTableEntry(got_index);
1803 self.got_table_count_dirty = true;1803 self.got_table_count_dirty = true;
1804 self.markRelocsDirtyByTarget(target);
1804}1805}
18051806
1806fn addStubEntry(self: *MachO, target: SymbolWithLoc) !void {1807fn addStubEntry(self: *MachO, target: SymbolWithLoc) !void {
...@@ -1808,6 +1809,7 @@ fn addStubEntry(self: *MachO, target: SymbolWithLoc) !void {...@@ -1808,6 +1809,7 @@ fn addStubEntry(self: *MachO, target: SymbolWithLoc) !void {
1808 const stub_index = try self.stub_table.allocateEntry(self.base.allocator, target);1809 const stub_index = try self.stub_table.allocateEntry(self.base.allocator, target);
1809 try self.writeStubTableEntry(stub_index);1810 try self.writeStubTableEntry(stub_index);
1810 self.stub_table_count_dirty = true;1811 self.stub_table_count_dirty = true;
1812 self.markRelocsDirtyByTarget(target);
1811}1813}
18121814
1813pub fn updateFunc(self: *MachO, module: *Module, func: *Module.Fn, air: Air, liveness: Liveness) !void {1815pub fn updateFunc(self: *MachO, module: *Module, func: *Module.Fn, air: Air, liveness: Liveness) !void {
...@@ -2294,6 +2296,7 @@ fn updateDeclCode(self: *MachO, decl_index: Module.Decl.Index, code: []u8) !u64...@@ -2294,6 +2296,7 @@ fn updateDeclCode(self: *MachO, decl_index: Module.Decl.Index, code: []u8) !u64
2294 log.debug(" (updating GOT entry)", .{});2296 log.debug(" (updating GOT entry)", .{});
2295 const got_atom_index = self.got_table.lookup.get(.{ .sym_index = sym_index }).?;2297 const got_atom_index = self.got_table.lookup.get(.{ .sym_index = sym_index }).?;
2296 try self.writeOffsetTableEntry(got_atom_index);2298 try self.writeOffsetTableEntry(got_atom_index);
2299 self.markRelocsDirtyByTarget(.{ .sym_index = sym_index });
2297 }2300 }
2298 } else if (code_len < atom.size) {2301 } else if (code_len < atom.size) {
2299 self.shrinkAtom(atom_index, code_len);2302 self.shrinkAtom(atom_index, code_len);