Skip to content

Commit

Permalink
Make normalization APK exports conditional on 'apk' feature
Browse files Browse the repository at this point in the history
We use the 'apk' feature in the symbolization part of the crate to guard
inclusion of everything and anything APK related. However, for the
normalization APIs we only really exclude the actual implementation
(i.e., creation of APK meta entries). That seems to be a bit confusing.
Make sure to guard the APK meta data types of the normalization bits by
the 'apk' feature as well.

Signed-off-by: Daniel Müller <[email protected]>
  • Loading branch information
d-e-s-o committed Feb 26, 2025
1 parent 92d1b7b commit 6b4d772
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Unreleased
into account system KASLR state
- Added `kaslr_offset` member to `symbolize::Kernel`
- Moved symbolization and inspection sources into `source` sub-module
- Moved `normalize::Apk` behind existing `apk` feature
- Changed `inspect::SymInfo::size` to be an `Option`


Expand Down
6 changes: 6 additions & 0 deletions src/normalize/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use super::buildid::BuildId;
use super::Reason;


cfg_apk! {
/// Meta information about an APK.
///
/// This type is used in the [`UserMeta::Apk`] variant.
Expand Down Expand Up @@ -45,6 +46,7 @@ pub struct Apk {
#[doc(hidden)]
pub _non_exhaustive: (),
}
}


/// Meta information about an ELF file (executable, shared object, ...).
Expand Down Expand Up @@ -103,6 +105,8 @@ impl From<Unknown> for UserMeta<'_> {
#[non_exhaustive]
pub enum UserMeta<'src> {
/// The address belongs to an APK file.
#[cfg(feature = "apk")]
#[cfg_attr(docsrs, doc(cfg(feature = "apk")))]
Apk(Apk),
/// The address belongs to an ELF file.
Elf(Elf<'src>),
Expand All @@ -112,6 +116,8 @@ pub enum UserMeta<'src> {

impl<'src> UserMeta<'src> {
/// Retrieve the [`Apk`] of this enum, if this variant is active.
#[cfg(feature = "apk")]
#[cfg_attr(docsrs, doc(cfg(feature = "apk")))]
#[inline]
pub fn as_apk(&self) -> Option<&Apk> {
match self {
Expand Down
2 changes: 2 additions & 0 deletions src/normalize/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ use std::fmt::Formatter;
use std::fmt::Result as FmtResult;
use std::str;

cfg_apk! {
pub use meta::Apk;
}
pub use meta::Elf;
pub use meta::Unknown;
pub use meta::UserMeta;
Expand Down
1 change: 1 addition & 0 deletions src/normalize/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use crate::Error;
use crate::Result;

use super::buildid::BuildIdReader;
#[cfg(feature = "apk")]
use super::meta::Apk;
use super::meta::Elf;
use super::meta::Unknown;
Expand Down

0 comments on commit 6b4d772

Please sign in to comment.