Skip to content

Commit

Permalink
Fix section inclusion calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
kjackiewicz authored and romainthomas committed Apr 2, 2022
1 parent ebe4990 commit 2671daa
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/ELF/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,18 +609,16 @@ ok_error_t Parser::parse_overlay() {
}

bool Parser::check_section_in_segment(const Section& section, const Segment& segment) {
const uint64_t sec_end = section.virtual_address() + section.size();
if (section.virtual_address() > 0) {
const uint64_t seg_vend = segment.virtual_address() + segment.virtual_size();
return segment.virtual_address() <= section.virtual_address() &&
sec_end <= seg_vend;
section.virtual_address() + section.size() <= seg_vend;
}

if (section.file_offset() > 0) {
const uint64_t seg_end = segment.file_offset() + segment.physical_size();
return segment.file_offset() <= section.file_offset() &&
sec_end < seg_end;

section.file_offset() + section.size() <= seg_end;
}
return false;
}
Expand Down

0 comments on commit 2671daa

Please sign in to comment.