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

Method finish

cranelift/object/src/unwind.rs:89–134  ·  view source on GitHub ↗

Serialize all collected FDEs into an `.eh_frame` section on `object`. Returns without writing anything if no FDE was ever added (e.g. when the user enabled unwind info on a target that does not produce System V frames). The pointer-width unwrap is safe because [`ObjectBuilder`] has already rejected unknown architectures during construction. [`ObjectBuilder`]: crate::ObjectBuilder

(self, object: &mut Object<'static>, isa: &dyn TargetIsa)

Source from the content-addressed store, hash-verified

87 ///
88 /// [`ObjectBuilder`]: crate::ObjectBuilder
89 pub(crate) fn finish(self, object: &mut Object<'static>, isa: &dyn TargetIsa) -> Result<()> {
90 let UnwindBuilder {
91 section,
92 frame_table,
93 cie_id,
94 symbols,
95 } = self;
96 if cie_id.is_none() {
97 return Ok(());
98 }
99 let mut eh_frame = EhFrame(section);
100 frame_table
101 .write_eh_frame(&mut eh_frame)
102 .map_err(|err| anyhow!("failed to write .eh_frame: {err}"))?;
103 let EhFrame(EhFrameSection {
104 writer,
105 relocations,
106 }) = eh_frame;
107
108 let section_id = object.section_id(StandardSection::EhFrame);
109 let alignment = u64::from(isa.triple().pointer_width().unwrap().bytes());
110 object.append_section_data(section_id, &writer.into_vec(), alignment);
111
112 let format = object.format();
113 for reloc in relocations {
114 let symbol_id = match reloc.target {
115 RelocationTarget::Symbol(index) => symbols[index],
116 // gimli's writer only emits section-relative relocations for
117 // DWARF debug sections, never for `.eh_frame`. Skip defensively.
118 RelocationTarget::Section(_) => continue,
119 };
120 let flags = translate_eh_pe(reloc.eh_pe, reloc.size, format)?;
121 object
122 .add_relocation(
123 section_id,
124 ObjectRelocation {
125 offset: reloc.offset as u64,
126 symbol: symbol_id,
127 addend: reloc.addend,
128 flags,
129 },
130 )
131 .map_err(|err| anyhow!("failed to record .eh_frame relocation: {err}"))?;
132 }
133 Ok(())
134 }
135}
136
137struct EhFrameSection {

Callers 15

build_host_isaFunction · 0.45
compile_testfileFunction · 0.45
build_filecheckerFunction · 0.45
with_host_isaMethod · 0.45
memcmpFunction · 0.45
small_memcmp_helperFunction · 0.45
parse_cmdline_targetMethod · 0.45
parse_target_specsMethod · 0.45
parse_sets_and_tripleFunction · 0.45
run_func_passesMethod · 0.45
set_isa_flagsMethod · 0.45

Calls 10

OkFunction · 0.85
fromFunction · 0.85
translate_eh_peFunction · 0.85
is_noneMethod · 0.45
bytesMethod · 0.45
unwrapMethod · 0.45
pointer_widthMethod · 0.45
tripleMethod · 0.45
into_vecMethod · 0.45
formatMethod · 0.45

Tested by 15

build_host_isaFunction · 0.36
compile_testfileFunction · 0.36
build_filecheckerFunction · 0.36
memcmpFunction · 0.36
isaFunction · 0.36
testFunction · 0.36
libcall_functionFunction · 0.36