diff --git a/src/read/any.rs b/src/read/any.rs index 0b4cd8a0..715279be 100644 --- a/src/read/any.rs +++ b/src/read/any.rs @@ -2,6 +2,7 @@ use alloc::fmt; use alloc::vec::Vec; use core::marker::PhantomData; +#[allow(unused_imports)] // Unused for Wasm use crate::endian::{Endian, Endianness}; #[cfg(feature = "coff")] use crate::read::coff; diff --git a/src/write/mod.rs b/src/write/mod.rs index 1183cbd9..d181eb02 100644 --- a/src/write/mod.rs +++ b/src/write/mod.rs @@ -66,13 +66,15 @@ pub struct Object<'a> { standard_sections: HashMap, symbols: Vec, symbol_map: HashMap, SymbolId>, - stub_symbols: HashMap, comdats: Vec, /// File flags that are specific to each file format. pub flags: FileFlags, /// The symbol name mangling scheme. pub mangling: Mangling, + #[cfg(feature = "coff")] + stub_symbols: HashMap, /// Mach-O "_tlv_bootstrap" symbol. + #[cfg(feature = "macho")] tlv_bootstrap: Option, /// Mach-O CPU subtype. #[cfg(feature = "macho")] @@ -93,10 +95,12 @@ impl<'a> Object<'a> { standard_sections: HashMap::new(), symbols: Vec::new(), symbol_map: HashMap::new(), - stub_symbols: HashMap::new(), comdats: Vec::new(), flags: FileFlags::None, mangling: Mangling::default(format, architecture), + #[cfg(feature = "coff")] + stub_symbols: HashMap::new(), + #[cfg(feature = "macho")] tlv_bootstrap: None, #[cfg(feature = "macho")] macho_cpu_subtype: None, diff --git a/src/write/string.rs b/src/write/string.rs index 5d4e17b0..ee1f5174 100644 --- a/src/write/string.rs +++ b/src/write/string.rs @@ -30,6 +30,7 @@ impl<'a> StringTable<'a> { /// Return the id of the given string. /// /// Panics if the string is not in the string table. + #[allow(dead_code)] pub fn get_id(&self, string: &[u8]) -> StringId { let id = self.strings.get_index_of(string).unwrap(); StringId(id) @@ -38,6 +39,7 @@ impl<'a> StringTable<'a> { /// Return the string for the given id. /// /// Panics if the string is not in the string table. + #[allow(dead_code)] pub fn get_string(&self, id: StringId) -> &'a [u8] { self.strings.get_index(id.0).unwrap() } diff --git a/src/write/util.rs b/src/write/util.rs index b15814bd..56ed9947 100644 --- a/src/write/util.rs +++ b/src/write/util.rs @@ -167,6 +167,7 @@ impl<'a> BytesMut for &'a mut [u8] { /// Write an unsigned number using the LEB128 encoding to a buffer. /// /// Returns the number of bytes written. +#[allow(dead_code)] pub(crate) fn write_uleb128(buf: &mut Vec, mut val: u64) -> usize { let mut len = 0; loop { diff --git a/tests/read/elf.rs b/tests/read/elf.rs index 5ced5147..e42cd516 100644 --- a/tests/read/elf.rs +++ b/tests/read/elf.rs @@ -1,9 +1,9 @@ -use object::Object; -use std::path::Path; -use std::path::PathBuf; +#[cfg(feature = "std")] +use std::path::{Path, PathBuf}; #[cfg(feature = "std")] fn get_buildid(path: &Path) -> Result>, object::read::Error> { + use object::Object; let file = std::fs::File::open(path).unwrap(); let reader = object::read::ReadCache::new(file); let object = object::read::File::parse(&reader)?;