Changeset 977c3de in rtems-tools for linkers/rld-symbols.h


Ignore:
Timestamp:
Nov 17, 2012, 6:34:33 AM (7 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
4.10, 4.11, master
Children:
065ac15
Parents:
0b65a28
Message:

Refactor the ELF support to allow ELF write suppport.

The refactoring allows better reuse of the ELF support and cleans up
some hacks from the generic file and archive handling improving the
separation of the file handling from the file format, ie ELF. The
handling of ELF object files and ELF object files inside archives
is cleaner.

The refactor cleaned up the symbol handling where the symbols now
reside in the ELF file object and references are take in symbol
pointer containers and symbol table containers.

The main purpose of the refactor is to allow support for creating
and writing ELF files.

Also added an rtems-syms command where special symbol support
can be added.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • linkers/rld-symbols.h

    r0b65a28 r977c3de  
    11/*
    2  * Copyright (c) 2011, Chris Johns <chrisj@rtems.org> 
     2 * Copyright (c) 2011, Chris Johns <chrisj@rtems.org>
    33 *
    44 * Permission to use, copy, modify, and/or distribute this software for any
    55 * purpose with or without fee is hereby granted, provided that the above
    66 * copyright notice and this permission notice appear in all copies.
    7  * 
     7 *
    88 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
    99 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     
    5959       * Construct an exported symbol with a object file.
    6060       */
    61       symbol (const std::string&  name, 
    62               rld::files::object& object,
     61      symbol (const std::string&  name,
     62              files::object&      object,
    6363              const elf::elf_sym& esym);
    6464
     
    6767       */
    6868      symbol (const std::string& name, const elf::elf_sym& esym);
    69      
     69
    7070      /**
    7171       * Construct a linker symbol that is internally created.
     
    7373      symbol (const std::string&  name,
    7474              const elf::elf_addr value);
    75      
     75
    7676      /**
    7777       * Construct a linker symbol that is internally created.
    7878       */
    79       symbol (const char*        name,
    80               rld::elf::elf_addr value = 0);
    81      
     79      symbol (const char*   name,
     80              elf::elf_addr value = 0);
     81
    8282      /**
    8383       * The symbol's name.
     
    9696
    9797      /**
     98       * The symbol's type.
     99       */
     100      int type () const;
     101
     102      /**
     103       * The symbol's binding, ie local, weak, or global.
     104       */
     105      int binding () const;
     106
     107      /**
     108       * The synbol's section index.
     109       */
     110      int index () const;
     111
     112      /**
    98113       * The symbol's object file name.
    99114       */
    100       rld::files::object* object () const;
     115      files::object* object () const;
    101116
    102117      /**
     
    104119       * symbols.
    105120       */
    106       void set_object (rld::files::object& obj);
     121      void set_object (files::object& obj);
    107122
    108123      /**
    109124       * The ELF symbol.
    110125       */
    111       const ::GElf_Sym& esym () const;
     126      const elf::elf_sym& esym () const;
    112127
    113128      /**
     
    134149
    135150    private:
    136       std::string         name_;       //< The name of the symbol.
    137       std::string         demangled_;  //< If a C++ symbol the demangled name.
    138       rld::files::object* object_;     //< The object file containing the
    139                                        // symbol.
    140       ::GElf_Sym          esym_;       //< The ELF symbol.
    141       int                 references_; //< The number of times if it referenced.
     151
     152      std::string    name_;       //< The name of the symbol.
     153      std::string    demangled_;  //< If a C++ symbol the demangled name.
     154      files::object* object_;     //< The object file containing the symbol.
     155      elf::elf_sym   esym_;       //< The ELF symbol.
     156      int            references_; //< The number of times if it referenced.
    142157    };
    143158
    144159    /**
    145      * List of symbol references.
    146      */
    147     typedef std::list < symbol* > list;
    148 
    149     /**
    150      * A symbols table is a map container of symbols.
    151      */
    152     typedef std::map < std::string, symbol > table;
    153 
    154     /**
    155      * Given a list of symbols return how many are referenced.
    156      */
    157     size_t referenced (list& symbols);
     160     * Container of symbols. A bucket of symbols.
     161     */
     162    typedef std::list < symbol > bucket;
     163
     164    /**
     165     * References to symbols. Should always point to symbols held in a bucket.
     166     */
     167    typedef std::list < symbol* > pointers;
     168
     169    /**
     170     * A symbols table is a map container of symbols. Should always point to
     171     * symbols held in a bucket.
     172     */
     173    typedef std::map < std::string, symbol* > table;
     174
     175    /**
     176     * Load a table from a buckey.
     177     */
     178    void load (bucket& bucket_, table& table_);
     179
     180    /**
     181     * Given a container of symbols return how many are referenced.
     182     */
     183    size_t referenced (pointers& symbols);
    158184
    159185    /**
     
    167193 * Output stream operator.
    168194 */
    169 static inline std::ostream& operator<< (std::ostream& out, const rld::symbols::symbol& sym) {
     195static inline std::ostream& operator<< (std::ostream&               out,
     196                                        const rld::symbols::symbol& sym) {
    170197  sym.output (out);
    171198  return out;
Note: See TracChangeset for help on using the changeset viewer.