| ... | ... | @@ -646,7 +646,7 @@ fn initRelocFromObject(rel: macho.relocation_info, context: RelocContext) !Reloc |
| 646 | 646 | .n_type = macho.N_SECT, |
| 647 | 647 | .n_sect = @intCast(u8, context.macho_file.section_ordinals.getIndex(match).? + 1), |
| 648 | 648 | .n_desc = 0, |
| 649 | | .n_value = sect.addr, |
| 649 | .n_value = 0, |
| 650 | 650 | }); |
| 651 | 651 | try context.object.sections_as_symbols.putNoClobber(context.allocator, sect_id, local_sym_index); |
| 652 | 652 | break :blk local_sym_index; |
| ... | ... | @@ -956,9 +956,9 @@ fn parseUnsigned( |
| 956 | 956 | mem.readIntLittle(i32, self.code.items[out.offset..][0..4]); |
| 957 | 957 | |
| 958 | 958 | if (rel.r_extern == 0) { |
| 959 | | assert(out.where == .local); |
| 960 | | const target_sym = context.macho_file.locals.items[out.where_index]; |
| 961 | | addend -= @intCast(i64, target_sym.n_value); |
| 959 | const source_seg = context.object.load_commands.items[context.object.segment_cmd_index.?].Segment; |
| 960 | const source_sect_base_addr = source_seg.sections.items[rel.r_symbolnum - 1].addr; |
| 961 | addend -= @intCast(i64, source_sect_base_addr); |
| 962 | 962 | } |
| 963 | 963 | |
| 964 | 964 | out.payload = .{ |
| ... | ... | @@ -1053,12 +1053,9 @@ fn parseSigned(self: TextBlock, rel: macho.relocation_info, out: *Relocation, co |
| 1053 | 1053 | var addend: i64 = mem.readIntLittle(i32, self.code.items[out.offset..][0..4]) + correction; |
| 1054 | 1054 | |
| 1055 | 1055 | if (rel.r_extern == 0) { |
| 1056 | | const source_sym = context.macho_file.locals.items[self.local_sym_index]; |
| 1057 | | const target_sym = switch (out.where) { |
| 1058 | | .local => context.macho_file.locals.items[out.where_index], |
| 1059 | | .undef => context.macho_file.undefs.items[out.where_index], |
| 1060 | | }; |
| 1061 | | addend = @intCast(i64, source_sym.n_value + out.offset + 4) + addend - @intCast(i64, target_sym.n_value); |
| 1056 | const source_seg = context.object.load_commands.items[context.object.segment_cmd_index.?].Segment; |
| 1057 | const source_sect_base_addr = source_seg.sections.items[rel.r_symbolnum - 1].addr; |
| 1058 | addend = @intCast(i64, out.offset) + addend - @intCast(i64, source_sect_base_addr) + 4 + correction; |
| 1062 | 1059 | } |
| 1063 | 1060 | |
| 1064 | 1061 | out.payload = .{ |