fix: dont interpret padding as instructions
a.out padds the text section with 0-bytes, which where interpreted as 0x00 0x00 instruction and occasionally as a single 0x00 byte. Add logic to ignore single 0x00 bytes and to remove dangling 0x00 0x00 instructions at the end of the instruction vec, so only the 'actual' instructions are presented in the end. Also adjust visibility of methods, so only the truncated instructions will ever be presented. Of course, this could remove an actual `0x00 0x00` instruction from the end, but they would not have any effect on execution anyway.
This commit is contained in:
@@ -33,14 +33,11 @@ impl Aout {
|
||||
|
||||
let text_start = hdr.hdrlen as usize;
|
||||
let text_end = text_start + hdr.text as usize;
|
||||
let data_start = text_end + 1;
|
||||
let data_start = text_end;
|
||||
let data_end = data_start + hdr.data as usize;
|
||||
|
||||
dbg!(&hdr);
|
||||
|
||||
let text_section = &buf[text_start..text_end];
|
||||
// let data_section = &buf[data_start..data_end];
|
||||
let data_section = [];
|
||||
let data_section = &buf[data_start..data_end];
|
||||
|
||||
Aout {
|
||||
header: hdr,
|
||||
|
||||
Reference in New Issue
Block a user