Struct object::write::elf::AttributesWriter
source · pub struct AttributesWriter { /* private fields */ }
Expand description
A helper for writing an attributes section.
Attributes have a variable length encoding, so it is awkward to write them in a single pass. Instead, we build the entire attributes section data in memory, using placeholders for unknown lengths that are filled in later.
Implementations§
source§impl AttributesWriter
impl AttributesWriter
sourcepub fn new(endian: Endianness) -> Self
pub fn new(endian: Endianness) -> Self
Create a new AttributesWriter
for the given endianness.
sourcepub fn start_subsection(&mut self, vendor: &[u8])
pub fn start_subsection(&mut self, vendor: &[u8])
Start a new subsection with the given vendor name.
sourcepub fn end_subsection(&mut self)
pub fn end_subsection(&mut self)
End the subsection.
The subsection length is automatically calculated and written.
sourcepub fn start_subsubsection(&mut self, tag: u8)
pub fn start_subsubsection(&mut self, tag: u8)
Start a new sub-subsection with the given tag.
sourcepub fn write_subsubsection_index(&mut self, index: u32)
pub fn write_subsubsection_index(&mut self, index: u32)
Write a section or symbol index to the sub-subsection.
The user must also call this function to write the terminating 0 index.
sourcepub fn write_subsubsection_indices(&mut self, indices: &[u8])
pub fn write_subsubsection_indices(&mut self, indices: &[u8])
Write raw index data to the sub-subsection.
The terminating 0 index is automatically written.
sourcepub fn write_attribute_tag(&mut self, tag: u64)
pub fn write_attribute_tag(&mut self, tag: u64)
Write an attribute tag to the sub-subsection.
sourcepub fn write_attribute_integer(&mut self, value: u64)
pub fn write_attribute_integer(&mut self, value: u64)
Write an attribute integer value to the sub-subsection.
sourcepub fn write_attribute_string(&mut self, value: &[u8])
pub fn write_attribute_string(&mut self, value: &[u8])
Write an attribute string value to the sub-subsection.
The value must not include the null terminator.
sourcepub fn write_subsubsection_attributes(&mut self, attributes: &[u8])
pub fn write_subsubsection_attributes(&mut self, attributes: &[u8])
Write raw attribute data to the sub-subsection.
sourcepub fn end_subsubsection(&mut self)
pub fn end_subsubsection(&mut self)
End the sub-subsection.
The sub-subsection length is automatically calculated and written.