Pass Module to UnwindContext
Once writing the LSDA, it will need access to the Module to get a reference to the personality function and to define a data object for the LSDA. Part of rust-lang/rustc_codegen_cranelift#1567
This commit is contained in:
parent
ab514c9596
commit
9495eb517e
2 changed files with 17 additions and 11 deletions
|
|
@ -1,7 +1,6 @@
|
|||
//! Unwind info generation (`.eh_frame`)
|
||||
|
||||
use cranelift_codegen::ir::Endianness;
|
||||
use cranelift_codegen::isa::TargetIsa;
|
||||
use cranelift_codegen::isa::unwind::UnwindInfo;
|
||||
use cranelift_object::ObjectProduct;
|
||||
use gimli::RunTimeEndian;
|
||||
|
|
@ -18,14 +17,14 @@ pub(crate) struct UnwindContext {
|
|||
}
|
||||
|
||||
impl UnwindContext {
|
||||
pub(crate) fn new(isa: &dyn TargetIsa, pic_eh_frame: bool) -> Self {
|
||||
let endian = match isa.endianness() {
|
||||
pub(crate) fn new(module: &mut dyn Module, pic_eh_frame: bool) -> Self {
|
||||
let endian = match module.isa().endianness() {
|
||||
Endianness::Little => RunTimeEndian::Little,
|
||||
Endianness::Big => RunTimeEndian::Big,
|
||||
};
|
||||
let mut frame_table = FrameTable::default();
|
||||
|
||||
let cie_id = if let Some(mut cie) = isa.create_systemv_cie() {
|
||||
let cie_id = if let Some(mut cie) = module.isa().create_systemv_cie() {
|
||||
if pic_eh_frame {
|
||||
cie.fde_address_encoding =
|
||||
gimli::DwEhPe(gimli::DW_EH_PE_pcrel.0 | gimli::DW_EH_PE_sdata4.0);
|
||||
|
|
@ -38,8 +37,15 @@ impl UnwindContext {
|
|||
UnwindContext { endian, frame_table, cie_id }
|
||||
}
|
||||
|
||||
pub(crate) fn add_function(&mut self, func_id: FuncId, context: &Context, isa: &dyn TargetIsa) {
|
||||
if let target_lexicon::OperatingSystem::MacOSX { .. } = isa.triple().operating_system {
|
||||
pub(crate) fn add_function(
|
||||
&mut self,
|
||||
module: &mut dyn Module,
|
||||
func_id: FuncId,
|
||||
context: &Context,
|
||||
) {
|
||||
if let target_lexicon::OperatingSystem::MacOSX { .. } =
|
||||
module.isa().triple().operating_system
|
||||
{
|
||||
// The object crate doesn't currently support DW_GNU_EH_PE_absptr, which macOS
|
||||
// requires for unwinding tables. In addition on arm64 it currently doesn't
|
||||
// support 32bit relocations as we currently use for the unwinding table.
|
||||
|
|
@ -48,7 +54,7 @@ impl UnwindContext {
|
|||
}
|
||||
|
||||
let unwind_info = if let Some(unwind_info) =
|
||||
context.compiled_code().unwrap().create_unwind_info(isa).unwrap()
|
||||
context.compiled_code().unwrap().create_unwind_info(module.isa()).unwrap()
|
||||
{
|
||||
unwind_info
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue