Open GoldsteinE opened 2 months ago
Yes, this is indeed unsound and should be made zero-sized.
LINKME_START is also unsound if the array ends up being empty.
Yes, this is indeed unsound and should be made zero-sized.
Are zero-sized extern statics portable? I’m unsure because C/++ doesn’t have ZSTs, so I don’t know if LLVM portably supports it.
Yes they are. LLVM supports them just fine.
Currently linkme generates an extern static of
Element
type for the “stop section” symbol:https://github.com/dtolnay/linkme/blob/0e5e28bd673014b2b8d0a7337eab9489f74d2624/impl/src/declaration.rs#L139-L143
As pointed out in https://github.com/rust-lang/rust/issues/46188#issuecomment-2295924689, statics are considered always-dereferenceable, so it’s probably unsound. As the stop static is never actually read from, I think it could be made zero-sized to remove the unsoundness?