]>
git.proxmox.com Git - rustc.git/blob - vendor/gimli/src/read/lists.rs
1 use crate::common
::{Encoding, Format}
;
2 use crate::read
::{Error, Reader, Result}
;
4 #[derive(Debug, Clone, Copy)]
5 pub(crate) struct ListsHeader
{
7 offset_entry_count
: u32,
10 impl Default
for ListsHeader
{
11 fn default() -> Self {
14 format
: Format
::Dwarf32
,
18 offset_entry_count
: 0,
24 /// Return the serialized size of the table header.
28 // initial_length + version + address_size + segment_selector_size + offset_entry_count
29 ListsHeader
::size_for_encoding(self.encoding
)
32 /// Return the serialized size of the table header.
34 pub(crate) fn size_for_encoding(encoding
: Encoding
) -> u8 {
35 // initial_length + version + address_size + segment_selector_size + offset_entry_count
36 encoding
.format
.initial_length_size() + 2 + 1 + 1 + 4
40 // TODO: add an iterator over headers in the appropriate sections section
42 fn parse_header
<R
: Reader
>(input
: &mut R
) -> Result
<ListsHeader
> {
43 let (length
, format
) = input
.read_initial_length()?
;
44 input
.truncate(length
)?
;
46 let version
= input
.read_u16()?
;
48 return Err(Error
::UnknownVersion(u64::from(version
)));
51 let address_size
= input
.read_u8()?
;
52 let segment_selector_size
= input
.read_u8()?
;
53 if segment_selector_size
!= 0 {
54 return Err(Error
::UnsupportedSegmentSize
);
56 let offset_entry_count
= input
.read_u32()?
;
58 let encoding
= Encoding
{