Remove more dead relocation handling code (#3924)

Forgotten from #3905 I now realized.
This commit is contained in:
Alex Crichton
2022-03-14 12:29:45 -05:00
committed by GitHub
parent 44351cc4af
commit 884ca1f75b

View File

@@ -14,9 +14,8 @@
//! names have format "_trampoline_N", where N is `SignatureIndex`.
use crate::debug::{DwarfSection, DwarfSectionRelocTarget};
use crate::{CompiledFunction, Relocation, RelocationTarget};
use crate::{CompiledFunction, RelocationTarget};
use anyhow::Result;
use cranelift_codegen::binemit::Reloc;
use cranelift_codegen::isa::{
unwind::{systemv, UnwindInfo},
TargetIsa,
@@ -34,7 +33,6 @@ use object::{
};
use std::collections::HashMap;
use std::convert::TryFrom;
use std::mem;
use std::ops::Range;
use wasmtime_environ::obj;
use wasmtime_environ::{
@@ -105,12 +103,6 @@ pub struct ObjectBuilder<'a> {
/// `object`-crate identifier for the text section.
text_section: SectionId,
/// Relocations to be added once we've got all function symbols available to
/// us. The first entry is the relocation that we're applying, relative
/// within a function, and the second entry here is the offset of the
/// function that contains this relocation.
relocations: Vec<(&'a Relocation, u64)>,
/// In-progress text section that we're using cranelift's `MachBuffer` to
/// build to resolve relocations (calls) between functions.
pub text: Box<dyn TextSectionBuilder>,
@@ -171,7 +163,6 @@ impl<'a> ObjectBuilder<'a> {
windows_unwind_info: Vec::new(),
systemv_unwind_info_id: None,
systemv_unwind_info: Vec::new(),
relocations: Vec::new(),
text: isa
.text_section_builder((module.functions.len() - module.num_imported_funcs) as u32),
added_unwind_info: false,
@@ -374,35 +365,6 @@ impl<'a> ObjectBuilder<'a> {
}
pub fn finish(&mut self) -> Result<()> {
// Now that all function symbols are available register all final
// relocations between functions.
//
// FIXME(#3009) once the old backend is removed this loop should be
// deleted since there won't be any relocations here.
for (r, off) in mem::take(&mut self.relocations) {
let symbol = match r.reloc_target {
RelocationTarget::UserFunc(index) => self.func_symbols[index],
_ => unreachable!("should be handled in `append_func`"),
};
let (kind, encoding, size) = match r.reloc {
Reloc::X86CallPCRel4 => {
(RelocationKind::Relative, RelocationEncoding::X86Branch, 32)
}
other => unimplemented!("Unimplemented relocation {:?}", other),
};
self.obj.add_relocation(
self.text_section,
ObjectRelocation {
offset: off + u64::from(r.offset),
size,
kind,
encoding,
symbol,
addend: r.addend,
},
)?;
}
// Finish up the text section now that we're done adding functions.
let text = self.text.finish();
self.obj