Skip to content
Snippets Groups Projects
Commit 3385408d authored by Martin Bickel's avatar Martin Bickel Committed by Serge Lamikhov-Center
Browse files

Rephrase condition of is_sect_in_seg() to make it more intuitive

parent fe78d06e
No related branches found
No related tags found
No related merge requests found
...@@ -426,11 +426,11 @@ class elfio ...@@ -426,11 +426,11 @@ class elfio
//! It doesn't matter if the addresses are memory addresses, or file offsets, //! It doesn't matter if the addresses are memory addresses, or file offsets,
//! they just need to be in the same address space //! they just need to be in the same address space
bool is_sect_in_seg ( Elf64_Off sect_begin, Elf_Xword sect_size, Elf64_Off seg_begin, Elf64_Off seg_end ) { bool is_sect_in_seg ( Elf64_Off sect_begin, Elf_Xword sect_size, Elf64_Off seg_begin, Elf64_Off seg_end ) {
if ( sect_size > 0 ) { return seg_begin <= sect_begin
return seg_begin <= sect_begin && sect_begin + sect_size <= seg_end; && sect_begin + sect_size <= seg_end
} else { && sect_begin < seg_end; // this is important criteria when sect_size == 0
return seg_begin <= sect_begin && sect_begin < seg_end; // Example: seg_begin=10, seg_end=12 (-> covering the bytes 10 and 11)
} // sect_begin=12, sect_size=0 -> shall return false!
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment