| ... | @@ -2149,13 +2149,12 @@ fn writeRebaseInfoTable(self: *Zld) !void { | ... | @@ -2149,13 +2149,12 @@ fn writeRebaseInfoTable(self: *Zld) !void { |
| 2149 | const sect = seg.sections.items[idx]; | 2149 | const sect = seg.sections.items[idx]; |
| 2150 | const base_offset = sect.addr - seg.inner.vmaddr; | 2150 | const base_offset = sect.addr - seg.inner.vmaddr; |
| 2151 | const segment_id = @intCast(u16, self.data_const_segment_cmd_index.?); | 2151 | const segment_id = @intCast(u16, self.data_const_segment_cmd_index.?); |
| 2152 | const index_offset = @intCast(u32, self.got_entries.items().len); | | |
| 2153 | | 2152 | |
| 2154 | try pointers.ensureCapacity(pointers.items.len + self.got_entries.items().len); | | |
| 2155 | for (self.got_entries.items()) |entry| { | 2153 | for (self.got_entries.items()) |entry| { |
| 2156 | const index = index_offset + entry.value.index; | 2154 | if (entry.value.tag == .import) continue; |
| 2157 | pointers.appendAssumeCapacity(.{ | 2155 | |
| 2158 | .offset = base_offset + index * @sizeOf(u64), | 2156 | try pointers.append(.{ |
| | 2157 | .offset = base_offset + entry.value.index * @sizeOf(u64), |
| 2159 | .segment_id = segment_id, | 2158 | .segment_id = segment_id, |
| 2160 | }); | 2159 | }); |
| 2161 | } | 2160 | } |
| ... | @@ -2242,15 +2241,16 @@ fn writeBindInfoTable(self: *Zld) !void { | ... | @@ -2242,15 +2241,16 @@ fn writeBindInfoTable(self: *Zld) !void { |
| 2242 | const base_offset = sect.addr - seg.inner.vmaddr; | 2241 | const base_offset = sect.addr - seg.inner.vmaddr; |
| 2243 | const segment_id = @intCast(u16, self.data_const_segment_cmd_index.?); | 2242 | const segment_id = @intCast(u16, self.data_const_segment_cmd_index.?); |
| 2244 | | 2243 | |
| 2245 | try pointers.ensureCapacity(pointers.items.len + self.got_entries.items().len); | | |
| 2246 | for (self.got_entries.items()) |entry| { | 2244 | for (self.got_entries.items()) |entry| { |
| | 2245 | if (entry.value.tag == .local) continue; |
| | 2246 | |
| 2247 | const dylib_ordinal = dylib_ordinal: { | 2247 | const dylib_ordinal = dylib_ordinal: { |
| 2248 | const sym = self.symtab.get(entry.key) orelse continue; // local indirection | 2248 | const sym = self.symtab.get(entry.key) orelse continue; // local indirection |
| 2249 | if (sym.tag != .Import) continue; // local indirection | 2249 | if (sym.tag != .Import) continue; // local indirection |
| 2250 | break :dylib_ordinal sym.file.? + 1; | 2250 | break :dylib_ordinal sym.file.? + 1; |
| 2251 | }; | 2251 | }; |
| 2252 | | 2252 | |
| 2253 | pointers.appendAssumeCapacity(.{ | 2253 | try pointers.append(.{ |
| 2254 | .offset = base_offset + entry.value.index * @sizeOf(u64), | 2254 | .offset = base_offset + entry.value.index * @sizeOf(u64), |
| 2255 | .segment_id = segment_id, | 2255 | .segment_id = segment_id, |
| 2256 | .dylib_ordinal = dylib_ordinal, | 2256 | .dylib_ordinal = dylib_ordinal, |