Skip to content

Commit 14ab911

Browse files
committed
Fix panic=unwind for JIT
1 parent e654c54 commit 14ab911

File tree

1 file changed

+30
-28
lines changed

1 file changed

+30
-28
lines changed

src/debuginfo/unwind.rs

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,36 @@ impl UnwindContext {
3232
let mut frame_table = FrameTable::default();
3333

3434
let cie_id = if let Some(mut cie) = module.isa().create_systemv_cie() {
35-
if pic_eh_frame {
36-
cie.fde_address_encoding =
37-
gimli::DwEhPe(gimli::DW_EH_PE_pcrel.0 | gimli::DW_EH_PE_sdata4.0);
38-
cie.lsda_encoding =
39-
Some(gimli::DwEhPe(gimli::DW_EH_PE_pcrel.0 | gimli::DW_EH_PE_sdata4.0));
35+
let ptr_encoding = if pic_eh_frame {
36+
gimli::DwEhPe(gimli::DW_EH_PE_pcrel.0 | gimli::DW_EH_PE_sdata4.0)
4037
} else {
41-
cie.fde_address_encoding = gimli::DW_EH_PE_absptr;
42-
cie.lsda_encoding = Some(gimli::DW_EH_PE_absptr);
43-
}
38+
gimli::DW_EH_PE_absptr
39+
};
40+
let code_ptr_encoding = if pic_eh_frame {
41+
if module.isa().triple().architecture == target_lexicon::Architecture::X86_64 {
42+
gimli::DwEhPe(
43+
gimli::DW_EH_PE_indirect.0
44+
| gimli::DW_EH_PE_pcrel.0
45+
| gimli::DW_EH_PE_sdata4.0,
46+
)
47+
} else if let target_lexicon::Architecture::Aarch64(_) =
48+
module.isa().triple().architecture
49+
{
50+
gimli::DwEhPe(
51+
gimli::DW_EH_PE_indirect.0
52+
| gimli::DW_EH_PE_pcrel.0
53+
| gimli::DW_EH_PE_sdata8.0,
54+
)
55+
} else {
56+
todo!()
57+
}
58+
} else {
59+
gimli::DwEhPe(gimli::DW_EH_PE_indirect.0 | gimli::DW_EH_PE_absptr.0)
60+
};
61+
62+
cie.fde_address_encoding = ptr_encoding;
63+
cie.lsda_encoding = Some(ptr_encoding);
64+
4465
// FIXME use eh_personality lang item instead
4566
let personality = module
4667
.declare_function(
@@ -77,26 +98,7 @@ impl UnwindContext {
7798

7899
module.define_data(personality_ref, &personality_ref_data).unwrap();
79100

80-
cie.personality = Some((
81-
if module.isa().triple().architecture == target_lexicon::Architecture::X86_64 {
82-
gimli::DwEhPe(
83-
gimli::DW_EH_PE_indirect.0
84-
| gimli::DW_EH_PE_pcrel.0
85-
| gimli::DW_EH_PE_sdata4.0,
86-
)
87-
} else if let target_lexicon::Architecture::Aarch64(_) =
88-
module.isa().triple().architecture
89-
{
90-
gimli::DwEhPe(
91-
gimli::DW_EH_PE_indirect.0
92-
| gimli::DW_EH_PE_pcrel.0
93-
| gimli::DW_EH_PE_sdata8.0,
94-
)
95-
} else {
96-
todo!()
97-
},
98-
address_for_data(personality_ref),
99-
));
101+
cie.personality = Some((code_ptr_encoding, address_for_data(personality_ref)));
100102
Some(frame_table.add_cie(cie))
101103
} else {
102104
None

0 commit comments

Comments
 (0)