Struct test_assembler::Section [−][src]
pub struct Section {
pub endian: Endian,
// some fields omitted
}
Expand description
A section is a sequence of bytes, constructed by appending bytes to the end.
Sections have a convenient and flexible set of member functions for appending data in various formats: big-endian and little-endian signed and unsigned values of different sizes, and raw blocks of bytes.
There are methods for appending each of u8
, u16
, u32
, and u64
in each of big, little, or the Section
’s default endianness.
The method names are {D,L,B}{8,16,32,64} for each variant, so
D16
writes a u16
in the Section
’s default endianness, and
L64
writes a u64
in little-endian byte order.
Each of these methods also accepts a Label
to write
non-constant values.
See the module-level documentation for examples.
Fields
endian: Endian
The current endianness of the writer.
This sets the behavior of the D
Implementations
Construct a Section
with endian
endianness.
Return a Label
that will resolve to the final size of the section.
This label is undefined until get_contents
is called.
Get the contents of this section as a slice of bytes.
Consumes the section. If there were still undefined labels,
return None
.
Return a label representing the start of the section.
It is up to the user whether this label represents the section’s
position in an object file, the section’s address in memory, or
what have you; some applications may need both, in which case
this simple-minded interface won’t be enough. This class only
provides a single start label, for use with the here
and mark
methods.
A label representing the point at which the next appended item will appear in the section, relative to start
.
Set the value of start
to value
.
Append data
to the end of this section, and return this section.
Append section
’s contents to the end of this section.
Any Label
s that were appended to section
will not be
resolved until this section is finalized.
Return this section.
Append count
copies of byte
to the end of this section.
Return this section.
Jump to the next location aligned on an alignment
-byte boundary, relative to the start of the section.
Fill the gap with zeroes. alignment
must be a power of two.
Return this section.
Append byte
with the Section’s default endianness.
byte
may be a Label
or a u8
.
Return this section.
Append byte
as little-endian (identical to D8
).
Return this section.
Append byte
as big-endian (identical to D8
).
Return this section.
Append word
with the Section’s default endianness.
word
may be a Label
or a u16
.
Return this section.
Append word
as little-endian.
word
may be a Label
or a u16
.
Return this section.
Append word
as big-endian.
word
may be a Label
or a u16
.
Return this section.
Append dword
with the Section’s default endianness.
dword
may be a Label
or a u32
.
Return this section.
Append dword
as little-endian.
dword
may be a Label
or a u32
.
Return this section.
Append dword
as big-endian.
dword
may be a Label
or a u32
.
Return this section.
Append qword
with the Section’s default endianness.
qword
may be a Label
or a u32
.
Return this section.
Append qword
as little-endian.
qword
may be a Label
or a u32
.
Return this section.
Append qword
as big-endian.
qword
may be a Label
or a u32
.
Return this section.