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 {...@@ -2144,6 +2144,8 @@ pub const Zld = struct {
2144 const segment = self.getSegment(@intCast(u8, sect_id));2144 const segment = self.getSegment(@intCast(u8, sect_id));
2145 if (segment.maxprot & macho.PROT.WRITE == 0) continue;2145 if (segment.maxprot & macho.PROT.WRITE == 0) continue;
21462146
2147 log.debug("{s},{s}", .{ header.segName(), header.sectName() });
2148
2147 const cpu_arch = self.options.target.cpu.arch;2149 const cpu_arch = self.options.target.cpu.arch;
2148 var atom_index = slice.items(.first_atom_index)[sect_id];2150 var atom_index = slice.items(.first_atom_index)[sect_id];
21492151
...@@ -2153,13 +2155,13 @@ pub const Zld = struct {...@@ -2153,13 +2155,13 @@ pub const Zld = struct {
21532155
2154 const should_rebase = blk: {2156 const should_rebase = blk: {
2155 if (self.dyld_private_sym_index) |sym_index| {2157 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;
2157 }2159 }
2158 break :blk !sym.undf();2160 break :blk !sym.undf();
2159 };2161 };
21602162
2161 if (should_rebase) {2163 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
2164 const object = self.objects.items[atom.getFile().?];2166 const object = self.objects.items[atom.getFile().?];
2165 const source_sym = object.getSourceSymbol(atom.sym_index).?;2167 const source_sym = object.getSourceSymbol(atom.sym_index).?;
...@@ -2273,15 +2275,17 @@ pub const Zld = struct {...@@ -2273,15 +2275,17 @@ pub const Zld = struct {
2273 const cpu_arch = self.options.target.cpu.arch;2275 const cpu_arch = self.options.target.cpu.arch;
2274 var atom_index = slice.items(.first_atom_index)[sect_id];2276 var atom_index = slice.items(.first_atom_index)[sect_id];
22752277
2278 log.debug("{s},{s}", .{ header.segName(), header.sectName() });
2279
2276 while (true) {2280 while (true) {
2277 const atom = self.getAtom(atom_index);2281 const atom = self.getAtom(atom_index);
2278 const sym = self.getSymbol(atom.getSymbolWithLoc());2282 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
2282 const should_bind = blk: {2286 const should_bind = blk: {
2283 if (self.dyld_private_sym_index) |sym_index| {2287 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;
2285 }2289 }
2286 break :blk true;2290 break :blk true;
2287 };2291 };