Skip to content

Commit d9531a0

Browse files
committed
Remove wrongly emitted .eh_frame in -Cpanic=abort
1 parent b2807b2 commit d9531a0

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

compiler/rustc_mir_transform/src/check_alignment.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use rustc_middle::mir::{
99
};
1010
use rustc_middle::ty::{Ty, TyCtxt, TypeAndMut};
1111
use rustc_session::Session;
12+
use rustc_target::spec::PanicStrategy;
1213

1314
pub 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 numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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'
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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+
}

0 commit comments

Comments
 (0)