示例#1
0
Elf_Half elfio::load_sections( std::istream &stream ) {
	Elf_Half  entry_size = header->get_section_entry_size();
	Elf_Half  num		= header->get_sections_num();
	Elf64_Off offset	 = header->get_sections_offset();
	for ( Elf_Half i = 0; i < num; ++i ) {
		section* sec = create_section();
		sec->load( stream, (std::streamoff)offset + i * entry_size );
		sec->set_index( i );
		// To mark that the section is not permitted to reassign address
		// during layout calculation
		sec->set_address( sec->get_address() );
	}
	Elf_Half shstrndx = get_section_name_str_index();
	if ( SHN_UNDEF != shstrndx ) {
		string_section_accessor str_reader( sections[shstrndx] );
		for ( Elf_Half i = 0; i < num; ++i ) {
			Elf_Word offset = sections[i]->get_name_string_offset();
			const char* p = str_reader.get_string( offset );
			if ( p != 0 ) {
				sections[i]->set_name( p );
			}
		}
	}
	return num;
}
示例#2
0
    bool
    generic_get_symbol( Elf_Xword index,
                        std::string& name, Elf64_Addr& value,
                        Elf_Xword& size,
                        unsigned char& bind, unsigned char& type,
                        Elf_Half& section_index,
                        unsigned char& other ) const
    {
        bool ret = false;

        if ( index < get_symbols_num() ) {
            const T* pSym = reinterpret_cast<const T*>(
                symbol_section->get_data() +
                    index * symbol_section->get_entry_size() );

            const endianess_convertor& convertor = elf_file.get_convertor();

            section* string_section = elf_file.sections[get_string_table_index()];
            string_section_accessor str_reader( string_section );
            const char* pStr = str_reader.get_string( convertor( pSym->st_name ) );
            if ( 0 != pStr ) {
                name = pStr;
            }
            value   = convertor( pSym->st_value );
            size    = convertor( pSym->st_size );
            bind    = ELF_ST_BIND( pSym->st_info );
            type    = ELF_ST_TYPE( pSym->st_info );
            section_index = convertor( pSym->st_shndx );
            other   = pSym->st_other;

            ret = true;
        }

        return ret;
    }
示例#3
0
void FMIndex::loadSGABWT(const std::string& filename)
{
    FMIndexBuilder builder(filename, m_smallSampleRate, m_largeSampleRate);

    size_t n = 0;

    // Load the compressed string from the file
    std::ifstream str_reader(builder.getStringFilename().c_str());
    n = builder.getNumStringBytes();
    m_string.resize(n);
    str_reader.read(reinterpret_cast<char*>(&m_string[0]), n);

    // Load the small markers from the file
    std::ifstream sm_reader(builder.getSmallMarkerFilename().c_str());
    n = builder.getNumSmallMarkers();
    m_smallMarkers.resize(n);
    sm_reader.read(reinterpret_cast<char*>(&m_smallMarkers[0]), sizeof(SmallMarker) * n);
    
    // Load the large markers from the file
    std::ifstream lm_reader(builder.getLargeMarkerFilename().c_str());
    n = builder.getNumLargeMarkers();
    m_largeMarkers.resize(n);
    lm_reader.read(reinterpret_cast<char*>(&m_largeMarkers[0]), sizeof(LargeMarker) * n);

    m_numStrings = builder.getNumStrings();
    m_numSymbols = builder.getNumSymbols();

    AlphaCount64 totals = builder.getSymbolCounts();
    assert(totals.get('$') + 
           totals.get('A') + 
           totals.get('C') + 
           totals.get('G') + 
           totals.get('T') == m_numSymbols);

    m_predCount.set('$', 0);
    m_predCount.set('A', totals.get('$')); 
    m_predCount.set('C', m_predCount.get('A') + totals.get('A'));
    m_predCount.set('G', m_predCount.get('C') + totals.get('C'));
    m_predCount.set('T', m_predCount.get('G') + totals.get('G'));
    assert(m_predCount.get('T') + totals.get('T') == m_numSymbols);

    m_decoder = builder.getDecoder();

    printInfo();
}