From bee2d247bd2178bd5d8cfade4e22a517c4e056ef Mon Sep 17 00:00:00 2001 From: Christopher Cole Date: Thu, 8 Jun 2023 13:51:21 -0700 Subject: [PATCH] Turn on #![deny(missing_debug_implementations)] This helps ensure we're deriving Debug, as it's generally always helpful. This helps avoid issues like #33 --- src/compression.rs | 2 ++ src/dynamic.rs | 2 ++ src/elf_bytes.rs | 3 ++- src/elf_stream.rs | 2 ++ src/file.rs | 2 ++ src/gnu_symver.rs | 2 ++ src/lib.rs | 2 ++ src/relocation.rs | 4 ++++ src/section.rs | 2 ++ src/segment.rs | 2 ++ src/symbol.rs | 2 ++ 11 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/compression.rs b/src/compression.rs index 0ce49ec..1e11fdb 100644 --- a/src/compression.rs +++ b/src/compression.rs @@ -12,6 +12,7 @@ use crate::parse::{ParseAt, ParseError}; /// C-style 32-bit ELF Compression Header definition /// /// These C-style definitions are for users who want to implement their own ELF manipulation logic. +#[derive(Debug)] #[repr(C)] pub struct Elf32_Chdr { pub ch_type: u32, @@ -22,6 +23,7 @@ pub struct Elf32_Chdr { /// C-style 64-bit ELF Compression Header definition /// /// These C-style definitions are for users who want to implement their own ELF manipulation logic. +#[derive(Debug)] #[repr(C)] pub struct Elf64_Chdr { pub ch_type: u32, diff --git a/src/dynamic.rs b/src/dynamic.rs index 64f46d2..af88f46 100644 --- a/src/dynamic.rs +++ b/src/dynamic.rs @@ -8,6 +8,7 @@ pub type DynamicTable<'data, E> = ParsingTable<'data, E, Dyn>; /// C-style 32-bit ELF Dynamic section entry definition /// /// These C-style definitions are for users who want to implement their own ELF manipulation logic. +#[derive(Debug)] #[repr(C)] pub struct Elf32_Dyn { pub d_tag: i32, @@ -18,6 +19,7 @@ pub struct Elf32_Dyn { /// C-style 64-bit ELF Dynamic section entry definition /// /// These C-style definitions are for users who want to implement their own ELF manipulation logic. +#[derive(Debug)] #[repr(C)] pub struct Elf64_Dyn { pub d_tag: i64, diff --git a/src/elf_bytes.rs b/src/elf_bytes.rs index 3fac040..f37c221 100644 --- a/src/elf_bytes.rs +++ b/src/elf_bytes.rs @@ -61,6 +61,7 @@ use crate::symbol::{Symbol, SymbolTable}; /// .collect(); /// println!("There are {} PT_LOAD segments", all_load_phdrs.len()); /// ``` +#[derive(Debug)] pub struct ElfBytes<'data, E: EndianParse> { pub ehdr: FileHeader, data: &'data [u8], @@ -142,7 +143,7 @@ fn find_phdrs<'data, E: EndianParse>( } /// This struct collects the common sections found in ELF objects -#[derive(Default)] +#[derive(Debug, Default)] pub struct CommonElfData<'data, E: EndianParse> { /// .symtab section pub symtab: Option>, diff --git a/src/elf_stream.rs b/src/elf_stream.rs index 8539e87..b236fb8 100644 --- a/src/elf_stream.rs +++ b/src/elf_stream.rs @@ -23,6 +23,7 @@ use crate::file::FileHeader; /// This type encapsulates the stream-oriented interface for parsing ELF objects from /// a `Read + Seek`. +#[derive(Debug)] pub struct ElfStream { pub ehdr: FileHeader, shdrs: Vec, @@ -670,6 +671,7 @@ impl ElfStream { } } +#[derive(Debug)] struct CachingReader { reader: R, stream_len: u64, diff --git a/src/file.rs b/src/file.rs index b5ff448..bf4137d 100644 --- a/src/file.rs +++ b/src/file.rs @@ -13,6 +13,7 @@ pub enum Class { /// C-style 32-bit ELF File Header definition /// /// These C-style definitions are for users who want to implement their own ELF manipulation logic. +#[derive(Debug)] #[repr(C)] pub struct Elf32_Ehdr { pub e_ident: [u8; abi::EI_NIDENT], @@ -34,6 +35,7 @@ pub struct Elf32_Ehdr { /// C-style 64-bit ELF File Header definition /// /// These C-style definitions are for users who want to implement their own ELF manipulation logic. +#[derive(Debug)] #[repr(C)] pub struct Elf64_Ehdr { pub e_ident: [u8; abi::EI_NIDENT], diff --git a/src/gnu_symver.rs b/src/gnu_symver.rs index 895ece9..5576376 100644 --- a/src/gnu_symver.rs +++ b/src/gnu_symver.rs @@ -14,6 +14,7 @@ pub struct SymbolRequirement<'data> { pub hidden: bool, } +#[derive(Debug)] pub struct SymbolDefinition<'data, E: EndianParse> { pub hash: u32, pub flags: u16, @@ -44,6 +45,7 @@ impl<'data, E: EndianParse> Iterator for SymbolNamesIterator<'data, E> { } } +#[derive(Debug)] pub struct SymbolVersionTable<'data, E: EndianParse> { version_ids: VersionIndexTable<'data, E>, diff --git a/src/lib.rs b/src/lib.rs index ea10f16..1bf5616 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -128,6 +128,8 @@ #![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(all(feature = "nightly", not(feature = "std")), feature(error_in_core))] +#![deny(missing_debug_implementations)] + pub mod abi; pub mod compression; diff --git a/src/relocation.rs b/src/relocation.rs index 5d8e485..bbec4a0 100644 --- a/src/relocation.rs +++ b/src/relocation.rs @@ -9,6 +9,7 @@ pub type RelaIterator<'data, E> = ParsingIterator<'data, E, Rela>; /// C-style 32-bit ELF Relocation definition /// /// These C-style definitions are for users who want to implement their own ELF manipulation logic. +#[derive(Debug)] #[repr(C)] pub struct Elf32_Rel { pub r_offset: u32, @@ -18,6 +19,7 @@ pub struct Elf32_Rel { /// C-style 64-bit ELF Relocation definition /// /// These C-style definitions are for users who want to implement their own ELF manipulation logic. +#[derive(Debug)] #[repr(C)] pub struct Elf64_Rel { pub r_offset: u64, @@ -72,6 +74,7 @@ impl ParseAt for Rel { /// C-style 32-bit ELF Relocation (with addend) definition /// /// These C-style definitions are for users who want to implement their own ELF manipulation logic. +#[derive(Debug)] #[repr(C)] pub struct Elf32_Rela { pub r_offset: u32, @@ -82,6 +85,7 @@ pub struct Elf32_Rela { /// C-style 64-bit ELF Relocation (with addend) definition /// /// These C-style definitions are for users who want to implement their own ELF manipulation logic. +#[derive(Debug)] #[repr(C)] pub struct Elf64_Rela { pub r_offset: u64, diff --git a/src/section.rs b/src/section.rs index c54a17a..a973051 100644 --- a/src/section.rs +++ b/src/section.rs @@ -8,6 +8,7 @@ pub type SectionHeaderTable<'data, E> = ParsingTable<'data, E, SectionHeader>; /// C-style 32-bit ELF Section Header definition /// /// These C-style definitions are for users who want to implement their own ELF manipulation logic. +#[derive(Debug)] #[repr(C)] pub struct Elf32_Shdr { pub sh_name: u32, @@ -25,6 +26,7 @@ pub struct Elf32_Shdr { /// C-style 64-bit ELF Section Header definition /// /// These C-style definitions are for users who want to implement their own ELF manipulation logic. +#[derive(Debug)] #[repr(C)] pub struct Elf64_Shdr { pub sh_name: u32, diff --git a/src/segment.rs b/src/segment.rs index abb2b29..5f148f0 100644 --- a/src/segment.rs +++ b/src/segment.rs @@ -8,6 +8,7 @@ pub type SegmentTable<'data, E> = ParsingTable<'data, E, ProgramHeader>; /// C-style 32-bit ELF Program Segment Header definition /// /// These C-style definitions are for users who want to implement their own ELF manipulation logic. +#[derive(Debug)] #[repr(C)] pub struct Elf32_Phdr { pub p_type: u32, @@ -23,6 +24,7 @@ pub struct Elf32_Phdr { /// C-style 64-bit ELF Program Segment Header definition /// /// These C-style definitions are for users who want to implement their own ELF manipulation logic. +#[derive(Debug)] #[repr(C)] pub struct Elf64_Phdr { pub p_type: u32, diff --git a/src/symbol.rs b/src/symbol.rs index 65deee2..90a12b4 100644 --- a/src/symbol.rs +++ b/src/symbol.rs @@ -9,6 +9,7 @@ pub type SymbolTable<'data, E> = ParsingTable<'data, E, Symbol>; /// C-style 32-bit ELF Symbol definition /// /// These C-style definitions are for users who want to implement their own ELF manipulation logic. +#[derive(Debug)] #[repr(C)] pub struct Elf32_Sym { pub st_name: u32, @@ -22,6 +23,7 @@ pub struct Elf32_Sym { /// C-style 64-bit ELF Symbol definition /// /// These C-style definitions are for users who want to implement their own ELF manipulation logic. +#[derive(Debug)] #[repr(C)] pub struct Elf64_Sym { pub st_name: u32,