File tree Expand file tree Collapse file tree 3 files changed +26
-1
lines changed
compiler/rustc_mir_transform/src
tests/run-make/panic-abort-eh_frame Expand file tree Collapse file tree 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::{
99} ;
1010use rustc_middle:: ty:: { Ty , TyCtxt , TypeAndMut } ;
1111use rustc_session:: Session ;
12+ use rustc_target:: spec:: PanicStrategy ;
1213
1314pub struct CheckAlignment ;
1415
@@ -236,7 +237,11 @@ fn insert_alignment_check<'tcx>(
236237 required : Operand :: Copy ( alignment) ,
237238 found : Operand :: Copy ( addr) ,
238239 } ) ,
239- unwind : UnwindAction :: Terminate ,
240+ unwind : if tcx. sess . panic_strategy ( ) == PanicStrategy :: Unwind {
241+ UnwindAction :: Terminate
242+ } else {
243+ UnwindAction :: Unreachable
244+ } ,
240245 } ,
241246 } ) ;
242247}
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