Exemplo n.º 1
0
/** Adds the newly constructed symbol to the specified ELF Symbol Table. */
void
SgAsmElfSymbol::ctor(SgAsmElfSymbolSection *symtab)
{
    ROSE_ASSERT(symtab!=NULL);
    SgAsmElfStringSection *strsec = dynamic_cast<SgAsmElfStringSection*>(symtab->get_linked_section());
    ROSE_ASSERT(strsec!=NULL);
    
    set_name(new SgAsmStoredString(strsec->get_strtab(), 0));

    ROSE_ASSERT(symtab->get_symbols()!=NULL);
    symtab->get_symbols()->get_symbols().push_back(this);
    ROSE_ASSERT(symtab->get_symbols()->get_symbols().size()>0);
    set_parent(symtab->get_symbols());

    set_st_info(0);
    set_st_res1(0);
    set_st_shndx(0);
    set_st_size(0);
}
Exemplo n.º 2
0
    void visit(SgNode *astNode) {
        SgAsmElfSymbolSection *symsec = isSgAsmElfSymbolSection(astNode);
        if (symsec) {
            printf("Scanning symbols in [%d] \"%s\"\n", symsec->get_id(), symsec->get_name()->get_string(true).c_str());
            const SgAsmElfSymbolPtrList &symbols = symsec->get_symbols()->get_symbols();
            for (SgAsmElfSymbolPtrList::const_iterator i=symbols.begin(); i!=symbols.end(); ++i) {
                std::string name = (*i)->get_name()->get_string();
                if (name.substr(0, 5)=="PMPI_") {
                    printf("  %s\n", name.c_str());
                    name[0] = 'X';
                    (*i)->get_name()->set_string(name);
                }
            }

#if 0
            /* Case 3a: repack the string table to make free space contiguous in hope of being able to allocate space for the
             * new string without having to extend the string table. This works by removing storage for all the strings in the
             * table. When the string table is unparsed all its strings are reallocated in one coordinated operation. */
            SgAsmElfStringSection *strsec = dynamic_cast<SgAsmElfStringSection*>(symsec->get_linked_section());
            ROSE_ASSERT(strsec!=NULL);
            strsec->get_strtab()->free_all_strings(true); /*true means free even the unreferenced parts of the table*/
#endif
        }
    }