fix annotation linking
This commit is contained in:
parent
eece6178f9
commit
832f6b7711
2 changed files with 20 additions and 0 deletions
|
|
@ -2328,6 +2328,24 @@ impl DexWriter {
|
|||
}
|
||||
}
|
||||
|
||||
/// Link the offsets of annotations_directory_item in class_def_items.
|
||||
///
|
||||
/// # Warning
|
||||
///
|
||||
/// Linking can only occur once all sections are entirelly generated.
|
||||
fn link_annotation_directories(&mut self) {
|
||||
debug!("Link the annotations_directory_item entries in class_def_items");
|
||||
for class_def in self.class_defs_list.iter_mut() {
|
||||
// prelink value is set to offset in the section + 1 (to distinguish with 0)
|
||||
if class_def.annotations_off != 0 {
|
||||
class_def.annotations_off += self
|
||||
.section_manager
|
||||
.get_offset(Section::AnnotationsDirectoryItem)
|
||||
- 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Link the offsets of static_values_off in class_def_items.
|
||||
///
|
||||
/// # Warning
|
||||
|
|
@ -2464,6 +2482,7 @@ impl DexWriter {
|
|||
self.link_call_site_ids();
|
||||
self.link_type_list_occurences()?;
|
||||
self.link_class_data_occurences();
|
||||
self.link_annotation_directories();
|
||||
self.link_static_values();
|
||||
self.link_debug_info();
|
||||
self.link_annotations();
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use crate::{
|
|||
use log::{error, info, warn};
|
||||
use std::io::{Cursor, Seek, SeekFrom};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct DexFileReader<'a> {
|
||||
data: &'a [u8],
|
||||
header: HeaderItem,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue