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

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

};