| ... | @@ -129,25 +129,37 @@ fn markLive( | ... | @@ -129,25 +129,37 @@ fn markLive( |
| 129 | const relocs = Atom.getAtomRelocs(zld, atom_index); | 129 | const relocs = Atom.getAtomRelocs(zld, atom_index); |
| 130 | const reverse_lookup = reverse_lookups[atom.getFile().?]; | 130 | const reverse_lookup = reverse_lookups[atom.getFile().?]; |
| 131 | for (relocs) |rel| { | 131 | for (relocs) |rel| { |
| 132 | switch (cpu_arch) { | 132 | const target = switch (cpu_arch) { |
| 133 | .aarch64 => { | 133 | .aarch64 => blk: { |
| 134 | const rel_type = @intToEnum(macho.reloc_type_arm64, rel.r_type); | 134 | const rel_type = @intToEnum(macho.reloc_type_arm64, rel.r_type); |
| 135 | switch (rel_type) { | 135 | switch (rel_type) { |
| 136 | .ARM64_RELOC_ADDEND, .ARM64_RELOC_SUBTRACTOR => continue, | 136 | .ARM64_RELOC_ADDEND => continue, |
| 137 | else => {}, | 137 | .ARM64_RELOC_SUBTRACTOR => { |
| | 138 | const sym_index = reverse_lookup[rel.r_symbolnum]; |
| | 139 | break :blk SymbolWithLoc{ |
| | 140 | .sym_index = sym_index, |
| | 141 | .file = atom.file, |
| | 142 | }; |
| | 143 | }, |
| | 144 | else => break :blk try Atom.parseRelocTarget(zld, atom_index, rel, reverse_lookup), |
| 138 | } | 145 | } |
| 139 | }, | 146 | }, |
| 140 | .x86_64 => { | 147 | .x86_64 => blk: { |
| 141 | const rel_type = @intToEnum(macho.reloc_type_x86_64, rel.r_type); | 148 | const rel_type = @intToEnum(macho.reloc_type_x86_64, rel.r_type); |
| 142 | switch (rel_type) { | 149 | switch (rel_type) { |
| 143 | .X86_64_RELOC_SUBTRACTOR => continue, | 150 | .X86_64_RELOC_SUBTRACTOR => { |
| 144 | else => {}, | 151 | const sym_index = reverse_lookup[rel.r_symbolnum]; |
| | 152 | break :blk SymbolWithLoc{ |
| | 153 | .sym_index = sym_index, |
| | 154 | .file = atom.file, |
| | 155 | }; |
| | 156 | }, |
| | 157 | else => break :blk try Atom.parseRelocTarget(zld, atom_index, rel, reverse_lookup), |
| 145 | } | 158 | } |
| 146 | }, | 159 | }, |
| 147 | else => unreachable, | 160 | else => unreachable, |
| 148 | } | 161 | }; |
| 149 | | 162 | |
| 150 | const target = try Atom.parseRelocTarget(zld, atom_index, rel, reverse_lookup); | | |
| 151 | const target_sym = zld.getSymbol(target); | 163 | const target_sym = zld.getSymbol(target); |
| 152 | if (target_sym.undf()) continue; | 164 | if (target_sym.undf()) continue; |
| 153 | if (target.getFile() == null) { | 165 | if (target.getFile() == null) { |