Changeset fdb1fe6 in rtems-tools for rtemstoolkit/rld-symbols.cpp


Ignore:
Timestamp:
Oct 30, 2014, 6:55:18 AM (5 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
4.10, 4.11, master
Children:
2015c85
Parents:
aac2949
Message:

linkers: Add base image symbol to ELF object file generation.

This change adds support to the rtems-syms code to generate a suitable
ELF object you can link to the base image kernel in the embed mode or
you can load with the run-time load mode.

The change fixes a bug in the framework where local ELF symbols
were being placed in the external symbol table. The external
symbol table has been removed and a global, weak and local set
of tables is now provided as this is more aligned with the ELF
format.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • rtemstoolkit/rld-symbols.cpp

    raac2949 rfdb1fe6  
    133133    }
    134134
     135    bool
     136    symbol::is_local () const
     137    {
     138      return binding () == STB_LOCAL;
     139    }
     140
     141    bool
     142    symbol::is_weak () const
     143    {
     144      return binding () == STB_WEAK;
     145    }
     146
     147    bool
     148    symbol::is_global () const
     149    {
     150      return binding () == STB_GLOBAL;
     151    }
     152
    135153    int
    136154    symbol::type () const
     
    276294
    277295    void
    278     table::add_external (symbol& sym)
    279     {
    280       _externals[sym.name ()] = &sym;
     296    table::add_global (symbol& sym)
     297    {
     298      globals_[sym.name ()] = &sym;
    281299    }
    282300
     
    284302    table::add_weak (symbol& sym)
    285303    {
    286       _weaks[sym.name ()] = &sym;
     304      weaks_[sym.name ()] = &sym;
     305    }
     306
     307    void
     308    table::add_local (symbol& sym)
     309    {
     310      locals_[sym.name ()] = &sym;
    287311    }
    288312
    289313    symbol*
    290     table::find_external (const std::string& name)
    291     {
    292       symtab::iterator sti = _externals.find (name);
    293       if (sti == _externals.end ())
     314    table::find_global (const std::string& name)
     315    {
     316      symtab::iterator sti = globals_.find (name);
     317      if (sti == globals_.end ())
    294318        return 0;
    295319      return (*sti).second;
     
    299323    table::find_weak (const std::string& name)
    300324    {
    301       symtab::iterator sti = _weaks.find (name);
    302       if (sti == _weaks.end ())
     325      symtab::iterator sti = weaks_.find (name);
     326      if (sti == weaks_.end ())
    303327        return 0;
    304328      return (*sti).second;
    305329    }
    306330
     331    symbol*
     332    table::find_local (const std::string& name)
     333    {
     334      symtab::iterator sti = locals_.find (name);
     335      if (sti == locals_.end ())
     336        return 0;
     337      return (*sti).second;
     338    }
     339
    307340    size_t
    308341    table::size () const
    309342    {
    310       return _externals.size () + _weaks.size ();
     343      return globals_.size () + weaks_.size () + locals_.size ();
    311344    }
    312345
    313346    const symtab&
    314     table::externals () const
    315     {
    316       return _externals;
     347    table::globals () const
     348    {
     349      return globals_;
    317350    }
    318351
     
    320353    table::weaks () const
    321354    {
    322       return _weaks;
     355      return weaks_;
     356    }
     357
     358    const symtab&
     359    table::locals () const
     360    {
     361      return locals_;
    323362    }
    324363
     
    330369           ++sbi)
    331370      {
    332         table_.add_external (*sbi);
     371        table_.add_global (*sbi);
    333372      }
    334373    }
     
    365404    output (std::ostream& out, const table& symbols)
    366405    {
    367       out << "Externals:" << std::endl;
    368       output (out, symbols.externals ());
     406      out << "Globals:" << std::endl;
     407      output (out, symbols.globals ());
    369408      out << "Weaks:" << std::endl;
    370409      output (out, symbols.weaks ());
     410      out << "Locals:" << std::endl;
     411      output (out, symbols.locals ());
    371412    }
    372413
Note: See TracChangeset for help on using the changeset viewer.