File tree 3 files changed +26
-1
lines changed
compiler/rustc_mir_transform/src
tests/run-make/panic-abort-eh_frame
3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ use rustc_middle::mir::{
9
9
} ;
10
10
use rustc_middle:: ty:: { Ty , TyCtxt , TypeAndMut } ;
11
11
use rustc_session:: Session ;
12
+ use rustc_target:: spec:: PanicStrategy ;
12
13
13
14
pub struct CheckAlignment ;
14
15
@@ -236,7 +237,11 @@ fn insert_alignment_check<'tcx>(
236
237
required : Operand :: Copy ( alignment) ,
237
238
found : Operand :: Copy ( addr) ,
238
239
} ) ,
239
- unwind : UnwindAction :: Terminate ,
240
+ unwind : if tcx. sess . panic_strategy ( ) == PanicStrategy :: Unwind {
241
+ UnwindAction :: Terminate
242
+ } else {
243
+ UnwindAction :: Unreachable
244
+ } ,
240
245
} ,
241
246
} ) ;
242
247
}
Original file line number Diff line number Diff line change
1
+ # only-linux
2
+ #
3
+ # This test ensures that `panic=abort` code (without `C-unwind`, that is) should not have any
4
+ # unwinding related `.eh_frame` sections emitted.
5
+
6
+ include ../tools.mk
7
+
8
+ all :
9
+ $(RUSTC ) foo.rs --crate-type=lib --emit=obj=$(TMPDIR ) /foo.o -Cpanic=abort
10
+ objdump --dwarf=frames $(TMPDIR ) /foo.o | $(CGREP ) -v ' DW_CFA'
Original file line number Diff line number Diff line change
1
+ #![ no_std]
2
+
3
+ #[ panic_handler]
4
+ fn handler ( _: & core:: panic:: PanicInfo < ' _ > ) -> ! {
5
+ loop { }
6
+ }
7
+
8
+ pub unsafe fn oops ( x : * const u32 ) -> u32 {
9
+ * x
10
+ }
You can’t perform that action at this time.
0 commit comments