mirror of
https://github.com/allankoechke/rust.git
synced 2026-12-02 01:40:02 +00:00
panic_unwind: Use global_asm! for IMGREL relocations Rust consteval cannot construct 32-bit values that contain the offset between two symbols, but this is required for panic_unwind on some architectures because unwinding on Windows SEH uses image-base-relative pointers for the panic information (which makes them fit in 32-bit rather than 64-bit). Currently, this is worked around by initializing these globals on panic with atomic stores. This works, but is undefined behavior as the panic runtime reads the values with non-atomic loads, which leads to a data race. Instead, utilize `global_asm!` to create the globals with `@IMGREL` relocations so that the linker constructs the relative pointers for us at link or load time. For context: [#t-compiler > relative pointers in windows SEH panic_unwind @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/relative.20pointers.20in.20windows.20SEH.20panic_unwind/near/613200087) AI assistance was involved with writing the assembly code.