From 20d8e90f71783949c6c06a95b490fab4a4cd1f90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20M=C3=BCller?= Date: Wed, 19 Jul 2023 10:14:14 -0700 Subject: [PATCH] Factor out R typedef into dwarf::reader module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change moves the R typedef and associated functionality into the newly introduced dwarf::reader module. Signed-off-by: Daniel Müller --- src/dwarf/mod.rs | 1 + src/dwarf/parser.rs | 12 ++---------- src/dwarf/reader.rs | 10 ++++++++++ 3 files changed, 13 insertions(+), 10 deletions(-) create mode 100644 src/dwarf/reader.rs diff --git a/src/dwarf/mod.rs b/src/dwarf/mod.rs index 4614c43a..06286935 100644 --- a/src/dwarf/mod.rs +++ b/src/dwarf/mod.rs @@ -1,4 +1,5 @@ mod parser; +mod reader; mod resolver; pub(crate) use self::resolver::DwarfResolver; diff --git a/src/dwarf/parser.rs b/src/dwarf/parser.rs index 68b5997a..b30fbcfa 100644 --- a/src/dwarf/parser.rs +++ b/src/dwarf/parser.rs @@ -15,6 +15,8 @@ use gimli::SectionId; use gimli::Unit; use gimli::UnitSectionOffset; +use super::reader::R; + use crate::elf::ElfParser; use crate::inspect::SymType; use crate::log::warn; @@ -23,16 +25,6 @@ use crate::ErrorExt as _; use crate::Result; -#[cfg(target_endian = "little")] -type Endianess = gimli::LittleEndian; -#[cfg(target_endian = "big")] -type Endianess = gimli::BigEndian; - -/// The gimli reader type we currently use. Could be made generic if -/// need be, but we keep things simple while we can. -type R<'dat> = EndianSlice<'dat, Endianess>; - - fn format_offset(offset: UnitSectionOffset) -> String { match offset { UnitSectionOffset::DebugInfoOffset(o) => { diff --git a/src/dwarf/reader.rs b/src/dwarf/reader.rs new file mode 100644 index 00000000..94f2fe5e --- /dev/null +++ b/src/dwarf/reader.rs @@ -0,0 +1,10 @@ +use gimli::EndianSlice; + +#[cfg(target_endian = "little")] +type Endianess = gimli::LittleEndian; +#[cfg(target_endian = "big")] +type Endianess = gimli::BigEndian; + +/// The gimli reader type we currently use. Could be made generic if +/// need be, but we keep things simple while we can. +pub(crate) type R<'dat> = EndianSlice<'dat, Endianess>;