-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What about: distributed slices (linkme) #545
Comments
I'm dubious that we actually want this rule that you can't jump statics with the same pointer. For statics with specific link flags, the addresses are public and possibly chosen to line up with something else, and so I think it should be possible to access these allocations using no-provenance pointers (transmuted integers, or at least integers passed through some |
The most straightforward resolution would probably be to extend the "same A more direct encoding of behavior would be to say that all Additionally, the intermittent discussion of the compiler exposing a similar feature has usually assumed that the compiler doing this kind of aliasing of (Whether the language should expose such a feature, how it should work, and complications from dynamic linking are not relevant here.) Footnotes
|
Orthogonal to what was discussed above,
That's just one static pointing to another, isn't it? I don't see the problem with that. I am using the LLVM definition of "derived from". |
I don't think we have an issue tracking this yet. linkme implements distributed slices with linker shenanigans such that it's possible to write
#[distributed_slice] pub static ITEMS: [Item];
and use that slice to access any number of#[distributed_slice(ITEMS)] static ITEM: Item = /* … */;
safely.This is implemented by expanding to, very roughly (omitting non-linux support, item type validation, and guards against name clashes):
Unfortunately, as currently written, I think this should be considered unsound (a case of deliberate UB):
Originally posted by @RalfJung in rust-lang/reference#1657 (comment)
Namely, because the static
ITEM
is accessible through bothITEM
and the sliceITEMS
. Writing this in a sound manner (the static item is only accessible through a single static name) may be possible, but isn't particularly nice and introduces additional indirection, very roughly:…however, on Windows, the situation is even more squirrelly, because
__START
/__STOP
aren'textern static
, because Windows doesn't have magic symbols for the boundary of link sections like unixes do. Instead,[Item; 0]
statics are created in the right place utilizing section ordering.The text was updated successfully, but these errors were encountered: