Skip to content

Commit

Permalink
Fix unused items when building with feature combinations (gimli-rs#637)
Browse files Browse the repository at this point in the history
  • Loading branch information
philipc authored Feb 26, 2024
1 parent 20aaf08 commit be15366
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/read/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 6 additions & 2 deletions src/write/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,15 @@ pub struct Object<'a> {
standard_sections: HashMap<StandardSection, SectionId>,
symbols: Vec<Symbol>,
symbol_map: HashMap<Vec<u8>, SymbolId>,
stub_symbols: HashMap<SymbolId, SymbolId>,
comdats: Vec<Comdat>,
/// 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<SymbolId, SymbolId>,
/// Mach-O "_tlv_bootstrap" symbol.
#[cfg(feature = "macho")]
tlv_bootstrap: Option<SymbolId>,
/// Mach-O CPU subtype.
#[cfg(feature = "macho")]
Expand All @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/write/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
}
Expand Down
1 change: 1 addition & 0 deletions src/write/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8>, mut val: u64) -> usize {
let mut len = 0;
loop {
Expand Down
6 changes: 3 additions & 3 deletions tests/read/elf.rs
Original file line number Diff line number Diff line change
@@ -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<Option<Vec<u8>>, 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)?;
Expand Down

0 comments on commit be15366

Please sign in to comment.