authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-10-19 21:35:51+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-10-22 07:59:23+02:00
log15f1e6a60c1b31a058e1a2f4638a1628b71d52a0
tree07fbf472b7ca4e5486ade18f3818665adf8b1745
parentc15e03ac7949205958b1eb66ddbba8dffd944bff

macho: fix silly error where we would incorrectly skip a valid binding


1 files changed, 8 insertions(+), 4 deletions(-)

src/link/MachO/zld.zig+8-4
......@@ -2144,6 +2144,8 @@ pub const Zld = struct {
21442144 const segment = self.getSegment(@intCast(u8, sect_id));
21452145 if (segment.maxprot & macho.PROT.WRITE == 0) continue;
21462146
2147 log.debug("{s},{s}", .{ header.segName(), header.sectName() });
2148
21472149 const cpu_arch = self.options.target.cpu.arch;
21482150 var atom_index = slice.items(.first_atom_index)[sect_id];
21492151
......@@ -2153,13 +2155,13 @@ pub const Zld = struct {
21532155
21542156 const should_rebase = blk: {
21552157 if (self.dyld_private_sym_index) |sym_index| {
2156 if (atom.sym_index == sym_index) break :blk false;
2158 if (atom.getFile() == null and atom.sym_index == sym_index) break :blk false;
21572159 }
21582160 break :blk !sym.undf();
21592161 };
21602162
21612163 if (should_rebase) {
2162 log.debug(" ATOM(%{d}, '{s}')", .{ atom.sym_index, self.getSymbolName(atom.getSymbolWithLoc()) });
2164 log.debug(" ATOM({d}, %{d}, '{s}')", .{ atom_index, atom.sym_index, self.getSymbolName(atom.getSymbolWithLoc()) });
21632165
21642166 const object = self.objects.items[atom.getFile().?];
21652167 const source_sym = object.getSourceSymbol(atom.sym_index).?;
......@@ -2273,15 +2275,17 @@ pub const Zld = struct {
22732275 const cpu_arch = self.options.target.cpu.arch;
22742276 var atom_index = slice.items(.first_atom_index)[sect_id];
22752277
2278 log.debug("{s},{s}", .{ header.segName(), header.sectName() });
2279
22762280 while (true) {
22772281 const atom = self.getAtom(atom_index);
22782282 const sym = self.getSymbol(atom.getSymbolWithLoc());
22792283
2280 log.debug(" ATOM(%{d}, '{s}')", .{ atom.sym_index, self.getSymbolName(atom.getSymbolWithLoc()) });
2284 log.debug(" ATOM({d}, %{d}, '{s}')", .{ atom_index, atom.sym_index, self.getSymbolName(atom.getSymbolWithLoc()) });
22812285
22822286 const should_bind = blk: {
22832287 if (self.dyld_private_sym_index) |sym_index| {
2284 if (atom.sym_index == sym_index) break :blk false;
2288 if (atom.getFile() == null and atom.sym_index == sym_index) break :blk false;
22852289 }
22862290 break :blk true;
22872291 };