mirror of
https://github.com/serge1/ELFIO.git
synced 2025-03-15 16:21:02 +00:00
Fixed section to segment mapping for 0-length sections
This commit is contained in:
parent
6dad943222
commit
6c19078803
@ -419,6 +419,18 @@ class elfio
|
||||
return num;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//! Checks whether the addresses of the section entirely fall within the given segment.
|
||||
//! It doesn't matter if the addresses are memory addresses, or file offsets,
|
||||
//! 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 ) {
|
||||
if ( sect_size > 0 ) {
|
||||
return seg_begin <= sect_begin && sect_begin + sect_size <= seg_end;
|
||||
} else {
|
||||
return seg_begin <= sect_begin && sect_begin < seg_end;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool load_segments( std::istream& stream )
|
||||
{
|
||||
@ -454,12 +466,8 @@ class elfio
|
||||
// SHF_ALLOC sections are matched based on the virtual address
|
||||
// otherwise the file offset is matched
|
||||
if( psec->get_flags() & SHF_ALLOC
|
||||
? (segVBaseAddr <= psec->get_address()
|
||||
&& psec->get_address() + psec->get_size()
|
||||
<= segVEndAddr)
|
||||
: (segBaseOffset <= psec->get_offset()
|
||||
&& psec->get_offset() + psec->get_size()
|
||||
<= segEndOffset)) {
|
||||
? is_sect_in_seg( psec->get_address(), psec->get_size(), segVBaseAddr, segVEndAddr )
|
||||
: is_sect_in_seg( psec->get_offset(), psec->get_size(), segBaseOffset, segEndOffset )) {
|
||||
seg->add_section_index( psec->get_index(),
|
||||
psec->get_addr_align() );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user