1
1
//! Unwind info generation (`.eh_frame`)
2
2
3
3
use cranelift_codegen:: ir:: Endianness ;
4
- use cranelift_codegen:: isa:: TargetIsa ;
5
4
use cranelift_codegen:: isa:: unwind:: UnwindInfo ;
6
5
use cranelift_object:: ObjectProduct ;
7
6
use gimli:: RunTimeEndian ;
@@ -18,14 +17,14 @@ pub(crate) struct UnwindContext {
18
17
}
19
18
20
19
impl 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 ( ) {
23
22
Endianness :: Little => RunTimeEndian :: Little ,
24
23
Endianness :: Big => RunTimeEndian :: Big ,
25
24
} ;
26
25
let mut frame_table = FrameTable :: default ( ) ;
27
26
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 ( ) {
29
28
if pic_eh_frame {
30
29
cie. fde_address_encoding =
31
30
gimli:: DwEhPe ( gimli:: DW_EH_PE_pcrel . 0 | gimli:: DW_EH_PE_sdata4 . 0 ) ;
@@ -38,8 +37,15 @@ impl UnwindContext {
38
37
UnwindContext { endian, frame_table, cie_id }
39
38
}
40
39
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
+ {
43
49
// The object crate doesn't currently support DW_GNU_EH_PE_absptr, which macOS
44
50
// requires for unwinding tables. In addition on arm64 it currently doesn't
45
51
// support 32bit relocations as we currently use for the unwinding table.
@@ -48,7 +54,7 @@ impl UnwindContext {
48
54
}
49
55
50
56
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 ( )
52
58
{
53
59
unwind_info
54
60
} else {
0 commit comments