Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c039ee8

Browse files
committedJul 22, 2024
library: vary unsafety in bootstrapping for SEH
1 parent 5c2e274 commit c039ee8

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed
 

‎panic_unwind/src/seh.rs

+6
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,10 @@ mod imp {
157157
// going to be cross-lang LTOed anyway. However, using expose is shorter and
158158
// requires less unsafe.
159159
let addr: usize = ptr.expose_provenance();
160+
#[cfg(bootstrap)]
160161
let image_base = unsafe { addr_of!(__ImageBase) }.addr();
162+
#[cfg(not(bootstrap))]
163+
let image_base = addr_of!(__ImageBase).addr();
161164
let offset: usize = addr - image_base;
162165
Self(offset as u32)
163166
}
@@ -250,7 +253,10 @@ extern "C" {
250253
// This is fine since the MSVC runtime uses string comparison on the type name
251254
// to match TypeDescriptors rather than pointer equality.
252255
static mut TYPE_DESCRIPTOR: _TypeDescriptor = _TypeDescriptor {
256+
#[cfg(bootstrap)]
253257
pVFTable: unsafe { addr_of!(TYPE_INFO_VTABLE) } as *const _,
258+
#[cfg(not(bootstrap))]
259+
pVFTable: addr_of!(TYPE_INFO_VTABLE) as *const _,
254260
spare: core::ptr::null_mut(),
255261
name: TYPE_NAME,
256262
};

0 commit comments

Comments
 (0)
Failed to load comments.