Exemplo n.º 1
0
void
BinMapOutput::OutputSymbols(const Section* sect)
{
    for (Object::const_symbol_iterator sym = m_object.symbols_begin(),
         end = m_object.symbols_end(); sym != end; ++sym)
    {
        const std::string& name = sym->getName();
        const Expr* equ;
        Location loc;

        if (sect == 0 && (equ = sym->getEqu()))
        {
            std::auto_ptr<Expr> realequ(equ->clone());
            realequ->Simplify(m_diags);
            BinSimplify(*realequ);
            realequ->Simplify(m_diags);
            OutputIntNum(realequ->getIntNum());
            m_os << "  " << name << '\n';
        }
        else if (sym->getLabel(&loc) && loc.bc->getContainer() == sect)
        {
            // Real address
            OutputIntNum(sect->getLMA() + loc.getOffset());
            m_os << "  ";

            // Virtual address
            OutputIntNum(sect->getVMA() + loc.getOffset());

            // Name
            m_os << "  " << name << '\n';
        }
    }
}
Exemplo n.º 2
0
static unsigned long
CountSymbols(const Object& object, const Section* sect)
{
    unsigned long count = 0;

    for (Object::const_symbol_iterator sym = object.symbols_begin(),
         end = object.symbols_end(); sym != end; ++sym)
    {
        Location loc;
        // TODO: autodetect wider size
        if ((sect == 0 && sym->getEqu()) ||
            (sym->getLabel(&loc) && loc.bc->getContainer() == sect))
            count++;
    }

    return count;
}