mirror of
https://github.com/serge1/ELFIO.git
synced 2024-12-26 18:15:40 +00:00
Change order and meaning of address_translation structure
This commit is contained in:
parent
02dae4ee5e
commit
056846723a
@ -163,11 +163,11 @@ class endianess_convertor
|
||||
//------------------------------------------------------------------------------
|
||||
struct address_translation
|
||||
{
|
||||
address_translation( uint64_t start, uint64_t size, uint64_t map_to )
|
||||
: start( start ), size( size ), map_to( map_to ){};
|
||||
address_translation( uint64_t start, uint64_t size, uint64_t mapped_to )
|
||||
: start( start ), size( size ), mapped_to( mapped_to ){};
|
||||
std::streampos start;
|
||||
std::streampos size;
|
||||
std::streampos map_to;
|
||||
std::streampos mapped_to;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@ -182,7 +182,7 @@ class address_translator
|
||||
std::sort(
|
||||
addr_translations.begin(), addr_translations.end(),
|
||||
[]( address_translation& a, address_translation& b ) -> bool {
|
||||
return a.map_to < b.map_to;
|
||||
return a.start < b.start;
|
||||
} );
|
||||
}
|
||||
|
||||
@ -194,8 +194,8 @@ class address_translator
|
||||
}
|
||||
|
||||
for ( auto& t : addr_translations ) {
|
||||
if ( ( t.map_to <= value ) && ( ( value - t.map_to ) < t.size ) ) {
|
||||
return t.start - t.map_to + value;
|
||||
if ( ( t.start <= value ) && ( ( value - t.start ) < t.size ) ) {
|
||||
return value - t.start + t.mapped_to;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,8 +49,8 @@ void get_translation_ranges( std::ifstream& proc_maps,
|
||||
if ( match.size() == 9 && match[8].str() == file_name ) {
|
||||
unsigned long start = std::stoul( match[1].str(), 0, 16 );
|
||||
unsigned long end = std::stoul( match[2].str(), 0, 16 );
|
||||
unsigned long mapped = std::stoul( match[4].str(), 0, 16 );
|
||||
result.emplace_back( start, end - start, mapped );
|
||||
unsigned long actual = std::stoul( match[4].str(), 0, 16 );
|
||||
result.emplace_back( actual, end - start, start );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -433,9 +433,9 @@ BOOST_AUTO_TEST_CASE( address_translation_test )
|
||||
{
|
||||
std::vector<address_translation> ranges;
|
||||
|
||||
ranges.emplace_back( 500, 100, 0 );
|
||||
ranges.emplace_back( 1000, 1000, 500 );
|
||||
ranges.emplace_back( 3000, 1000, 2000 );
|
||||
ranges.emplace_back( 0, 100, 500 );
|
||||
ranges.emplace_back( 500, 1000, 1000 );
|
||||
ranges.emplace_back( 2000, 1000, 3000 );
|
||||
|
||||
address_translator tr;
|
||||
tr.set_address_translation( ranges );
|
||||
|
Loading…
Reference in New Issue
Block a user