| ... | ... | @@ -234,11 +234,24 @@ pub fn getDeclVAddr( |
| 234 | 234 | decl_index: InternPool.DeclIndex, |
| 235 | 235 | reloc_info: link.File.RelocInfo, |
| 236 | 236 | ) !u64 { |
| 237 | | _ = self; |
| 238 | | _ = macho_file; |
| 239 | | _ = decl_index; |
| 240 | | _ = reloc_info; |
| 241 | | @panic("TODO getDeclVAddr"); |
| 237 | const sym_index = try self.getOrCreateMetadataForDecl(macho_file, decl_index); |
| 238 | const sym = macho_file.getSymbol(sym_index); |
| 239 | const vaddr = sym.getAddress(.{}, macho_file); |
| 240 | const parent_atom = macho_file.getSymbol(reloc_info.parent_atom_index).getAtom(macho_file).?; |
| 241 | try parent_atom.addReloc(macho_file, .{ |
| 242 | .tag = .@"extern", |
| 243 | .offset = @intCast(reloc_info.offset), |
| 244 | .target = sym.nlist_idx, |
| 245 | .addend = reloc_info.addend, |
| 246 | .type = .unsigned, |
| 247 | .meta = .{ |
| 248 | .pcrel = false, |
| 249 | .has_subtractor = false, |
| 250 | .length = 3, |
| 251 | .symbolnum = @intCast(sym.nlist_idx), |
| 252 | }, |
| 253 | }); |
| 254 | return vaddr; |
| 242 | 255 | } |
| 243 | 256 | |
| 244 | 257 | pub fn getAnonDeclVAddr( |
| ... | ... | @@ -247,11 +260,24 @@ pub fn getAnonDeclVAddr( |
| 247 | 260 | decl_val: InternPool.Index, |
| 248 | 261 | reloc_info: link.File.RelocInfo, |
| 249 | 262 | ) !u64 { |
| 250 | | _ = self; |
| 251 | | _ = macho_file; |
| 252 | | _ = decl_val; |
| 253 | | _ = reloc_info; |
| 254 | | @panic("TODO getAnonDeclVAddr"); |
| 263 | const sym_index = self.anon_decls.get(decl_val).?.symbol_index; |
| 264 | const sym = macho_file.getSymbol(sym_index); |
| 265 | const vaddr = sym.getAddress(.{}, macho_file); |
| 266 | const parent_atom = macho_file.getSymbol(reloc_info.parent_atom_index).getAtom(macho_file).?; |
| 267 | try parent_atom.addReloc(macho_file, .{ |
| 268 | .tag = .@"extern", |
| 269 | .offset = @intCast(reloc_info.offset), |
| 270 | .target = sym.nlist_idx, |
| 271 | .addend = reloc_info.addend, |
| 272 | .type = .unsigned, |
| 273 | .meta = .{ |
| 274 | .pcrel = false, |
| 275 | .has_subtractor = false, |
| 276 | .length = 3, |
| 277 | .symbolnum = @intCast(sym.nlist_idx), |
| 278 | }, |
| 279 | }); |
| 280 | return vaddr; |
| 255 | 281 | } |
| 256 | 282 | |
| 257 | 283 | pub fn lowerAnonDecl( |