Add text_section_builder method to TargetIsa
This commit is contained in:
@@ -49,7 +49,7 @@ use crate::flowgraph;
|
||||
use crate::ir::{self, Function};
|
||||
#[cfg(feature = "unwind")]
|
||||
use crate::isa::unwind::systemv::RegisterMappingError;
|
||||
use crate::machinst::{MachBackend, MachCompileResult, UnwindInfoKind};
|
||||
use crate::machinst::{MachBackend, MachCompileResult, TextSectionBuilder, UnwindInfoKind};
|
||||
use crate::settings;
|
||||
use crate::settings::SetResult;
|
||||
use crate::CodegenResult;
|
||||
@@ -263,6 +263,17 @@ pub trait TargetIsa: fmt::Display + Send + Sync {
|
||||
None
|
||||
}
|
||||
|
||||
/// Returns an object that can be used to build the text section of an
|
||||
/// executable.
|
||||
///
|
||||
/// This object will internally attempt to handle as many relocations as
|
||||
/// possible using relative calls/jumps/etc between functions.
|
||||
///
|
||||
/// The `num_labeled_funcs` argument here is the number of functions which
|
||||
/// will be "labeled" or might have calls between them, typically the number
|
||||
/// of defined functions in the object file.
|
||||
fn text_section_builder(&self, num_labeled_funcs: u32) -> Box<dyn TextSectionBuilder>;
|
||||
|
||||
/// Get the new-style MachBackend.
|
||||
fn get_mach_backend(&self) -> &dyn MachBackend;
|
||||
}
|
||||
|
||||
@@ -86,4 +86,8 @@ impl TargetIsa for TargetIsaAdapter {
|
||||
fn map_regalloc_reg_to_dwarf(&self, r: Reg) -> Result<u16, RegisterMappingError> {
|
||||
self.backend.map_reg_to_dwarf(r)
|
||||
}
|
||||
|
||||
fn text_section_builder(&self, num_labeled_funcs: u32) -> Box<dyn TextSectionBuilder> {
|
||||
self.backend.text_section_builder(num_labeled_funcs)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,7 +205,6 @@ impl<'a> ObjectBuilder<'a> {
|
||||
systemv_unwind_info: Vec::new(),
|
||||
relocations: Vec::new(),
|
||||
text: isa
|
||||
.get_mach_backend()
|
||||
.text_section_builder((module.functions.len() - module.num_imported_funcs) as u32),
|
||||
added_unwind_info: false,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user