library: vary unsafety in bootstrapping for SEH · model-checking/verify-rust-std@c039ee8 (original) (raw)

Original file line number Diff line number Diff line change
@@ -157,7 +157,10 @@ mod imp {
157 157 // going to be cross-lang LTOed anyway. However, using expose is shorter and
158 158 // requires less unsafe.
159 159 let addr: usize = ptr.expose_provenance();
160 +#[cfg(bootstrap)]
160 161 let image_base = unsafe { addr_of!(__ImageBase) }.addr();
162 +#[cfg(not(bootstrap))]
163 +let image_base = addr_of!(__ImageBase).addr();
161 164 let offset: usize = addr - image_base;
162 165 Self(offset as u32)
163 166 }
@@ -250,7 +253,10 @@ extern "C" {
250 253 // This is fine since the MSVC runtime uses string comparison on the type name
251 254 // to match TypeDescriptors rather than pointer equality.
252 255 static mut TYPE_DESCRIPTOR: _TypeDescriptor = _TypeDescriptor {
256 +#[cfg(bootstrap)]
253 257 pVFTable: unsafe { addr_of!(TYPE_INFO_VTABLE) } as *const _,
258 +#[cfg(not(bootstrap))]
259 +pVFTable: addr_of!(TYPE_INFO_VTABLE) as *const _,
254 260 spare: core::ptr::null_mut(),
255 261 name: TYPE_NAME,
256 262 };