Commit bcd16b2708

Jakub Konka <kubkon@jakubkonka.com>
2023-01-19 14:06:47
macho: fix ordering issue with lazy bind pointers
1 parent b2febd1
Changed files (1)
src
src/link/MachO.zig
@@ -3421,11 +3421,11 @@ fn populateLazyBindOffsetsInStubHelper(self: *MachO, lazy_bind: LazyBind) !void
     const header = section.header;
     var atom = section.last_atom.?;
 
-    var index: usize = lazy_bind.offsets.items.len;
-    while (index > 0) : (index -= 1) {
+    var index: usize = 0;
+    while (index < lazy_bind.offsets.items.len) : (index += 1) {
         const sym = atom.getSymbol(self);
         const file_offset = header.offset + sym.n_value - header.addr + stub_offset;
-        const bind_offset = lazy_bind.offsets.items[index - 1];
+        const bind_offset = lazy_bind.offsets.items[index];
 
         log.debug("writing lazy bind offset 0x{x} in stub helper at 0x{x}", .{ bind_offset, file_offset });