Elfedit: handling the case where we move the same section we're adding
Dependencies
- [2]
ZV57M4VNDebugging - [*]
AR2X3TLAInitial commit: introducing elfedit - [*]
5PJAXSZ7Elfedit: correct reallocation of dynstr/dynamic
Change contents
- edit in elfedit/src/lib.rs at line 1225[2.3518][5.13332]
// Since we may be trying to update this// very section + segment (example: if the// interpreter is the first section),// update the `programs` array.programs[pi].0 = new_offset; - edit in elfedit/src/lib.rs at line 1261[5.14215][5.14215]
let old_offset = sec.offset(id) as usize; - edit in elfedit/src/lib.rs at line 1265[5.14351][5.14351]
// Update the corresponding segment, which may have been// moved just above (hence the resetting of programs[..]// above).for (o, _, ty, _, p) in &programs {if *o == old_offset && *ty != Pht::LOAD {let mut p = self.program_mut(*p as usize);p.set_offset(id, new_offset);p.set_filesz(id, new.len());p.set_memsz(id, new.len());p.set_vaddr(id, last_vaddr as usize);}}