Skip to content

Commit 61fa77e

Browse files
committed
Fix panic=unwind for JIT
1 parent 379b09f commit 61fa77e

File tree

3 files changed

+49
-30
lines changed

3 files changed

+49
-30
lines changed

example/mini_core.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,10 +521,27 @@ fn panic_cannot_unwind() -> ! {
521521
}
522522

523523
#[lang = "eh_personality"]
524-
fn eh_personality() -> ! {
524+
// FIXME personality signature depends on target
525+
fn eh_personality(
526+
_version: i32,
527+
_actions: i32,
528+
_exception_class: u64,
529+
_exception_object: *mut (),
530+
_context: *mut (),
531+
) -> i32 {
525532
loop {}
526533
}
527534

535+
#[lang = "panic_in_cleanup"]
536+
fn panic_in_cleanup() -> ! {
537+
loop {}
538+
}
539+
540+
#[link(name = "gcc_s")]
541+
extern "C" {
542+
fn _Unwind_Resume(exc: *mut ()) -> !;
543+
}
544+
528545
#[lang = "drop_in_place"]
529546
#[allow(unconditional_recursion)]
530547
pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {

scripts/test_rustc_tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,5 +184,5 @@ index 073116933bd..c3e4578204d 100644
184184
EOF
185185

186186
echo "[TEST] rustc test suite"
187-
COMPILETEST_FORCE_STAGE0=1 ./x.py test --stage 0 --test-args=--no-capture tests/{codegen-units,run-make,ui,incremental}
187+
COMPILETEST_FORCE_STAGE0=1 ./x.py test --stage 0 tests/{codegen-units,ui,incremental}
188188
popd

src/debuginfo/unwind.rs

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

3131
let cie_id = if let Some(mut cie) = module.isa().create_systemv_cie() {
32-
if pic_eh_frame {
33-
cie.fde_address_encoding =
34-
gimli::DwEhPe(gimli::DW_EH_PE_pcrel.0 | gimli::DW_EH_PE_sdata4.0);
35-
cie.lsda_encoding =
36-
Some(gimli::DwEhPe(gimli::DW_EH_PE_pcrel.0 | gimli::DW_EH_PE_sdata4.0));
32+
let ptr_encoding = if pic_eh_frame {
33+
gimli::DwEhPe(gimli::DW_EH_PE_pcrel.0 | gimli::DW_EH_PE_sdata4.0)
3734
} else {
38-
cie.fde_address_encoding = gimli::DW_EH_PE_absptr;
39-
cie.lsda_encoding = Some(gimli::DW_EH_PE_absptr);
40-
}
35+
gimli::DW_EH_PE_absptr
36+
};
37+
let code_ptr_encoding = if pic_eh_frame {
38+
if module.isa().triple().architecture == target_lexicon::Architecture::X86_64 {
39+
gimli::DwEhPe(
40+
gimli::DW_EH_PE_indirect.0
41+
| gimli::DW_EH_PE_pcrel.0
42+
| gimli::DW_EH_PE_sdata4.0,
43+
)
44+
} else if let target_lexicon::Architecture::Aarch64(_) =
45+
module.isa().triple().architecture
46+
{
47+
gimli::DwEhPe(
48+
gimli::DW_EH_PE_indirect.0
49+
| gimli::DW_EH_PE_pcrel.0
50+
| gimli::DW_EH_PE_sdata8.0,
51+
)
52+
} else {
53+
todo!()
54+
}
55+
} else {
56+
gimli::DwEhPe(gimli::DW_EH_PE_indirect.0 | gimli::DW_EH_PE_absptr.0)
57+
};
58+
59+
cie.fde_address_encoding = ptr_encoding;
60+
cie.lsda_encoding = Some(ptr_encoding);
61+
4162
// FIXME use eh_personality lang item instead
4263
let personality = module
4364
.declare_function(
@@ -72,26 +93,7 @@ impl UnwindContext {
7293

7394
module.define_data(personality_ref, &personality_ref_data).unwrap();
7495

75-
cie.personality = Some((
76-
if module.isa().triple().architecture == target_lexicon::Architecture::X86_64 {
77-
gimli::DwEhPe(
78-
gimli::DW_EH_PE_indirect.0
79-
| gimli::DW_EH_PE_pcrel.0
80-
| gimli::DW_EH_PE_sdata4.0,
81-
)
82-
} else if let target_lexicon::Architecture::Aarch64(_) =
83-
module.isa().triple().architecture
84-
{
85-
gimli::DwEhPe(
86-
gimli::DW_EH_PE_indirect.0
87-
| gimli::DW_EH_PE_pcrel.0
88-
| gimli::DW_EH_PE_sdata8.0,
89-
)
90-
} else {
91-
todo!()
92-
},
93-
address_for_data(personality_ref),
94-
));
96+
cie.personality = Some((code_ptr_encoding, address_for_data(personality_ref)));
9597
Some(frame_table.add_cie(cie))
9698
} else {
9799
None

0 commit comments

Comments
 (0)