Converts a `FinalizedMachReloc` produced from a `Function` into a `ModuleReloc`.
(
mach_reloc: &FinalizedMachReloc,
func: &Function,
func_id: FuncId,
)
| 38 | impl ModuleReloc { |
| 39 | /// Converts a `FinalizedMachReloc` produced from a `Function` into a `ModuleReloc`. |
| 40 | pub fn from_mach_reloc( |
| 41 | mach_reloc: &FinalizedMachReloc, |
| 42 | func: &Function, |
| 43 | func_id: FuncId, |
| 44 | ) -> Self { |
| 45 | let name = match mach_reloc.target { |
| 46 | FinalizedRelocTarget::ExternalName(ExternalName::User(reff)) => { |
| 47 | let name = &func.params.user_named_funcs()[reff]; |
| 48 | ModuleRelocTarget::user(name.namespace, name.index) |
| 49 | } |
| 50 | FinalizedRelocTarget::ExternalName(ExternalName::TestCase(_)) => unimplemented!(), |
| 51 | FinalizedRelocTarget::ExternalName(ExternalName::LibCall(libcall)) => { |
| 52 | ModuleRelocTarget::LibCall(libcall) |
| 53 | } |
| 54 | FinalizedRelocTarget::ExternalName(ExternalName::KnownSymbol(ks)) => { |
| 55 | ModuleRelocTarget::KnownSymbol(ks) |
| 56 | } |
| 57 | FinalizedRelocTarget::Func(offset) => { |
| 58 | ModuleRelocTarget::FunctionOffset(func_id, offset) |
| 59 | } |
| 60 | }; |
| 61 | Self { |
| 62 | offset: mach_reloc.offset, |
| 63 | kind: mach_reloc.kind, |
| 64 | name, |
| 65 | addend: mach_reloc.addend, |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | /// A function identifier for use in the `Module` interface. |
nothing calls this directly
no test coverage detected