pub enum Place {
Written,
ReadOnly,
RelocReadOnly {
local: bool,
},
Zero,
Merged,
Named(String),
}Expand description
Which section a variable goes in.
Worked out from what the variable is rather than named by it, except in the one case where the
program named it. A reader who wants to know why a variable is in .rodata should be able to
find the answer in the variable.
Variants§
Written
Written to, and its image is not all zeros. .data.
ReadOnly
Never written to, so it can go in a page the loader maps read only and every process
running the program can share. .rodata.
RelocReadOnly
Never written to by the program, but written once by the dynamic linker, because its image
holds the address of something and an address is not known until the image is loaded.
.data.rel.ro.
The section has to be writable for that one write and read only afterwards, which is what
the PT_GNU_RELRO segment is: the loader maps it, the relocations are applied, and then it
is turned read only before the program starts. Putting the variable in .rodata instead
means asking the linker to leave a relocation in a section that is never writable, and what
it does about that is give the whole image DT_TEXTREL, which gives up the protection the
section was for. Some hardened toolchains refuse the link outright.
Fields
local: boolWhether every address in the image is of something this file defines and does not export, which means the link can resolve them all and none can be interposed.
Those go in .data.rel.ro.local, which the linker puts in the first pages of the
segment, so the pages holding them are the ones the loader is done with soonest. It is
a hint about layout rather than a difference in what the section is.
Zero
All zeros, so the file says how big it is and carries none of it. .bss.
Merged
A tentative definition, which is not in a section at all: the linker is asked for that
much zeroed space and merges every definition of the name into one. .comm.
Named(String)
The section the program named, from __attribute__((section(...))).
Trait Implementations§
impl Eq for Place
impl StructuralPartialEq for Place
Auto Trait Implementations§
impl Freeze for Place
impl RefUnwindSafe for Place
impl Send for Place
impl Sync for Place
impl Unpin for Place
impl UnsafeUnpin for Place
impl UnwindSafe for Place
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.