MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / from_mach_reloc

Method from_mach_reloc

cranelift/module/src/module.rs:40–67  ·  view source on GitHub ↗

Converts a `FinalizedMachReloc` produced from a `Function` into a `ModuleReloc`.

(
        mach_reloc: &FinalizedMachReloc,
        func: &Function,
        func_id: FuncId,
    )

Source from the content-addressed store, hash-verified

38impl 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.

Callers

nothing calls this directly

Calls 4

LibCallEnum · 0.85
KnownSymbolEnum · 0.85
FunctionOffsetClass · 0.85
user_named_funcsMethod · 0.80

Tested by

no test coverage detected