You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.4 KiB
44 lines
1.4 KiB
#include <llosymbol_loader/llosymbol_loader_map.hpp>
|
|
|
|
bool llo::s1::symbol_loader_map_t::load( llo::lloiff_t &iff )
|
|
{
|
|
std::ifstream map_file( symbols_path );
|
|
if ( !map_file.is_open() )
|
|
return false;
|
|
|
|
bool has_advanced = false;
|
|
std::string line, begin_symbols( " Address Publics by Value" );
|
|
|
|
// segment_idx:segment_offset symbol_name...
|
|
std::regex pattern( "([0-9a-fA-F]+):([0-9a-fA-F]+)\\s+([_A-Za-z0-9:?@$]+)" );
|
|
|
|
while ( std::getline( map_file, line ) )
|
|
{
|
|
// advance past header...
|
|
if ( !has_advanced )
|
|
{
|
|
if ( !line.substr( 0, begin_symbols.size() ).compare( begin_symbols ) )
|
|
has_advanced = true;
|
|
|
|
continue;
|
|
}
|
|
|
|
std::smatch m;
|
|
if ( !std::regex_search( line, m, pattern ) )
|
|
continue;
|
|
|
|
auto section_number = std::strtoull( m[ 0 ].str().c_str(), nullptr, 16 );
|
|
auto section_offset = std::strtoull( m[ 2 ].str().c_str(), nullptr, 16 );
|
|
auto symbol_name = m[ 3 ].str();
|
|
|
|
if ( !section_number )
|
|
continue;
|
|
|
|
// insert new opaque symbol into symbols list...
|
|
llo::disposition_t disposition( iff.name, iff.sections[ section_number - 1 ].section_name, section_offset );
|
|
auto new_opaque_symbol = llo::symbol::symbol_opaque_t::make( symbol_name, disposition );
|
|
iff.sections[ section_number - 1 ].symbols.push_back( new_opaque_symbol );
|
|
}
|
|
|
|
return true;
|
|
} |