@@ -43,12 +43,18 @@ impl Mapping {
43
43
} )
44
44
}
45
45
46
- /// On Android, shared objects can be loaded directly from a
47
- /// ZIP archive. For example, an app may load a library from
48
- /// `/data/app/com.example/base.apk!/lib/x86_64/mylib.so`
46
+ /// On Android, shared objects can be loaded directly from a ZIP archive
47
+ /// (see: [`super::Library::zip_offset`]).
49
48
///
50
- /// `zip_offset` should be page-aligned; the dynamic linker
51
- /// requires this when it loads libraries.
49
+ /// If `zip_offset` is not None, we interpret the `path` as an
50
+ /// "embedded" library path, and the value of `zip_offset` tells us where
51
+ /// in the ZIP archive the library data starts.
52
+ ///
53
+ /// We expect `zip_offset` to be page-aligned because the dynamic linker
54
+ /// requires this. Otherwise, loading the embedded library will fail.
55
+ ///
56
+ /// If we fail to load an embedded library for any reason, we fallback to
57
+ /// interpreting the path as a literal file on disk (same as calling [`Self::new`]).
52
58
#[ cfg( target_os = "android" ) ]
53
59
pub fn new_android ( path : & Path , zip_offset : Option < u64 > ) -> Option < Mapping > {
54
60
fn map_embedded_library ( path : & Path , zip_offset : u64 ) -> Option < Mapping > {
@@ -75,6 +81,7 @@ impl Mapping {
75
81
}
76
82
77
83
// if ZIP offset is given, try mapping as a ZIP-embedded library
84
+ // otherwise, fallback to mapping as a literal filepath
78
85
if let Some ( zip_offset) = zip_offset {
79
86
map_embedded_library ( path, zip_offset) . or_else ( || Self :: new ( path) )
80
87
} else {
0 commit comments