Skip to content

Commit 1e5f452

Browse files
committed
Fix panic=unwind for JIT
1 parent 06bee44 commit 1e5f452

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
@@ -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(
@@ -75,26 +96,7 @@ impl UnwindContext {
7596

7697
module.define_data(personality_ref, &personality_ref_data).unwrap();
7798

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

0 commit comments

Comments
 (0)