pub struct Section {
pub header: SectionHeader,
pub entry_header: EntryHeader,
/* private fields */
}
Expand description
Represents a section in a sub-image.
This struct encapsulates a section within the image, consisting of the following components:
header
: The metadata and configuration for the section (represented bySectionHeader
).entry_header
: The header that defines the entry point and loading address of the section (represented byEntryHeader
).data
: AVec<u8>
containing the raw data for the section, which can be processed or manipulated as needed.
§Default Values:
- The
header
andentry_header
are initialized with their default values. - The
data
is an empty vector by default.
Fields§
§header: SectionHeader
The metadata and configuration for the section.
entry_header: EntryHeader
The header that defines the entry point and loading address of the section.
Implementations§
Source§impl Section
impl Section
Sourcepub fn new_with_size(capacity: usize) -> Section
pub fn new_with_size(capacity: usize) -> Section
Creates a new Section
with a specified data capacity.
This static method allows you to create a new Section
with a predefined data capacity.
The data
field will be initialized as a vector of zeroed bytes with the given size.
§Parameters:
capacity
: The size (in bytes) to which thedata
vector should be initialized.
§Returns:
A new Section
instance with the specified capacity
for its data
field.
§Example:
let section = Section::new_with_size(1024);
Sourcepub fn build_aligned_length(&self) -> u32
pub fn build_aligned_length(&self) -> u32
Computes the aligned length of the section data, ensuring it is padded to a 0x20-byte boundary.
This function calculates the total length of the section (including the EntryHeader
and the
section’s data) and ensures that the result is aligned to a 0x20-byte boundary.
§Returns:
u32
: The aligned length of the section, including theEntryHeader
and section data.
Sourcepub fn build_aligned_size(&self) -> u32
pub fn build_aligned_size(&self) -> u32
Computes the aligned size of the section, including the SectionHeader
, EntryHeader
, and section data.
§Returns:
u32
: The aligned size of the section, including headers and data.