#[repr(C)]pub struct SectionHeader {
pub name: [u8; 8],
pub virtual_size: u32,
pub virtual_address: u32,
pub size_of_raw_data: u32,
pub pointer_to_raw_data: u32,
pub pointer_to_relocations: u32,
pub pointer_to_line_numbers: u32,
pub number_of_relocations: u16,
pub number_of_line_numbers: u16,
pub characteristics: u32,
}
Expand description
Contains information such as name, size, characteristics and location of a section in the binary
Fields§
§name: [u8; 8]
An 8-byte, null-padded UTF-8 encoded string. If the string is exactly 8 characters long, there is no terminating null. For longer names, this field contains a slash (/) that is followed by an ASCII representation of a decimal number that is an offset into the string table. Executable images do not use a string table and do not support section names longer than 8 characters. Long names in object files are truncated if they are emitted to an executable file.
virtual_size: u32
The total size of the section when loaded into memory.
If this value is greater than size_of_raw_data
, the section is zero-padded.
This field is valid only for executable images and should be set to zero for object files.
virtual_address: u32
For executable images, the address of the first byte of the section relative to the image base when the section is loaded into memory. For object files, this field is the address of the first byte before relocation is applied; for simplicity, compilers should set this to zero. Otherwise, it is an arbitrary value that is subtracted from offsets during relocation.
size_of_raw_data: u32
The size of the section (for object files) or the size of the initialized data on disk (for image files).
For executable images, this must be a multiple of file_alignment
from the optional header.
If this is less than virtual_size
, the remainder of the section is zero-filled.
Because the size_of_raw_data
field is rounded but the virtual_size
field is not, it is possible for size_of_raw_data
to be greater than virtual_size
as well.
When a section contains only uninitialized data, this field should be zero.
pointer_to_raw_data: u32
The file pointer to the first page of the section within the COFF file.
For executable images, this must be a multiple of file_alignment
from the optional header.
For object files, the value should be aligned on a 4-byte boundary for best performance.
When a section contains only uninitialized data, this field should be zero.
pointer_to_relocations: u32
The file pointer to the beginning of relocation entries for the section. This is set to zero for executable images or if there are no relocations.
pointer_to_line_numbers: u32
The file pointer to the beginning of line-number entries for the section. This is set to zero if there are no COFF line numbers. This value should be zero for an image because COFF debugging information is deprecated.
number_of_relocations: u16
The number of relocation entries for the section. This is set to zero for executable images.
number_of_line_numbers: u16
The number of line-number entries for the section. This value should be zero for an image because COFF debugging information is deprecated.
characteristics: u32
The flags that describe the characteristics of the section.
Implementations§
Source§impl SectionHeader
impl SectionHeader
Sourcepub fn get_name(&self) -> Option<String>
pub fn get_name(&self) -> Option<String>
Get the name of a section as a string. Note that this string may contain null characters.
Sourcepub fn get_characteristics(&self) -> Option<SectionFlags>
pub fn get_characteristics(&self) -> Option<SectionFlags>
Returns the Section Characteristics as bitflags
Trait Implementations§
Source§impl Clone for SectionHeader
impl Clone for SectionHeader
Source§fn clone(&self) -> SectionHeader
fn clone(&self) -> SectionHeader
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Default for SectionHeader
impl Default for SectionHeader
Source§fn default() -> SectionHeader
fn default() -> SectionHeader
Source§impl Display for SectionHeader
impl Display for SectionHeader
impl Copy for SectionHeader
impl Pod for SectionHeader
Auto Trait Implementations§
impl Freeze for SectionHeader
impl RefUnwindSafe for SectionHeader
impl Send for SectionHeader
impl Sync for SectionHeader
impl Unpin for SectionHeader
impl UnwindSafe for SectionHeader
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> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
type Bits = T
Self
must have the same layout as the specified Bits
except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern
.Source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self
.