11//! Unwind info generation (`.eh_frame`)
22
33use cranelift_codegen:: ir:: Endianness ;
4- use cranelift_codegen:: isa:: TargetIsa ;
54use cranelift_codegen:: isa:: unwind:: UnwindInfo ;
65use cranelift_object:: ObjectProduct ;
76use gimli:: RunTimeEndian ;
@@ -18,14 +17,14 @@ pub(crate) struct UnwindContext {
1817}
1918
2019impl UnwindContext {
21- pub ( crate ) fn new ( isa : & dyn TargetIsa , pic_eh_frame : bool ) -> Self {
22- let endian = match isa. endianness ( ) {
20+ pub ( crate ) fn new ( module : & mut dyn Module , pic_eh_frame : bool ) -> Self {
21+ let endian = match module . isa ( ) . endianness ( ) {
2322 Endianness :: Little => RunTimeEndian :: Little ,
2423 Endianness :: Big => RunTimeEndian :: Big ,
2524 } ;
2625 let mut frame_table = FrameTable :: default ( ) ;
2726
28- let cie_id = if let Some ( mut cie) = isa. create_systemv_cie ( ) {
27+ let cie_id = if let Some ( mut cie) = module . isa ( ) . create_systemv_cie ( ) {
2928 if pic_eh_frame {
3029 cie. fde_address_encoding =
3130 gimli:: DwEhPe ( gimli:: DW_EH_PE_pcrel . 0 | gimli:: DW_EH_PE_sdata4 . 0 ) ;
@@ -38,8 +37,15 @@ impl UnwindContext {
3837 UnwindContext { endian, frame_table, cie_id }
3938 }
4039
41- pub ( crate ) fn add_function ( & mut self , func_id : FuncId , context : & Context , isa : & dyn TargetIsa ) {
42- if let target_lexicon:: OperatingSystem :: MacOSX { .. } = isa. triple ( ) . operating_system {
40+ pub ( crate ) fn add_function (
41+ & mut self ,
42+ module : & mut dyn Module ,
43+ func_id : FuncId ,
44+ context : & Context ,
45+ ) {
46+ if let target_lexicon:: OperatingSystem :: MacOSX { .. } =
47+ module. isa ( ) . triple ( ) . operating_system
48+ {
4349 // The object crate doesn't currently support DW_GNU_EH_PE_absptr, which macOS
4450 // requires for unwinding tables. In addition on arm64 it currently doesn't
4551 // support 32bit relocations as we currently use for the unwinding table.
@@ -48,7 +54,7 @@ impl UnwindContext {
4854 }
4955
5056 let unwind_info = if let Some ( unwind_info) =
51- context. compiled_code ( ) . unwrap ( ) . create_unwind_info ( isa) . unwrap ( )
57+ context. compiled_code ( ) . unwrap ( ) . create_unwind_info ( module . isa ( ) ) . unwrap ( )
5258 {
5359 unwind_info
5460 } else {
0 commit comments