paludis  Version 2.6.0
elf_symbol_section.hh
1 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
2 
3 /*
4  * Copyright (c) 2007 Tiziano Müller
5  * Copyright (c) 2007 David Leverton
6  *
7  * This file is part of the Paludis package manager. Paludis is free software;
8  * you can redistribute it and/or modify it under the terms of the GNU General
9  * Public License version 2, as published by the Free Software Foundation.
10  *
11  * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14  * details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
18  * Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 
21 #ifndef PALUDIS_GUARD_PALUDIS_UTIL_ELF_SYMBOL_SECTION_HH
22 #define PALUDIS_GUARD_PALUDIS_UTIL_ELF_SYMBOL_SECTION_HH 1
23 
24 #include <paludis/util/elf_sections.hh>
25 #include <paludis/util/pimp.hh>
26 #include <paludis/util/wrapped_forward_iterator-fwd.hh>
27 
28 #include <iosfwd>
29 
30 namespace paludis
31 {
32  namespace littlelf_internals
33  {
34  template <typename ElfType_> class SymbolStringResolvingVisitor;
35  }
36 
37  template <typename ElfType_>
38  class Symbol
39  {
41 
42  private:
43  typename ElfType_::Symbol _my_symbol;
44  std::string _symbol_name;
45  std::string _binding, _visibility;
46 
47  protected:
48  void resolve_symbol(std::string symbol_name)
49  {
50  _symbol_name = symbol_name;
51  }
52 
53  typename ElfType_::Word get_symbol_index() const
54  {
55  return _my_symbol.st_name;
56  }
57 
58  public:
59  Symbol(const typename ElfType_::Symbol &);
60  ~Symbol();
61 
62  std::string name() const
63  {
64  return _symbol_name;
65  }
66 
67  std::string binding() const
68  {
69  return _binding;
70  }
71 
72  std::string visibility() const
73  {
74  return _visibility;
75  }
76  };
77 
78  template <typename ElfType_>
80 
81  template <typename ElfType_>
82  class SymbolSection :
83  public Section<ElfType_>,
84  public paludis::ImplementAcceptMethods<Section<ElfType_>, SymbolSection<ElfType_> >
85  {
86  private:
88  std::string _type;
89 
90  public:
91  SymbolSection(typename ElfType_::Word, const typename ElfType_::SectionHeader &, std::istream &, bool);
92  virtual ~SymbolSection();
93 
94  virtual std::string get_type() const
95  {
96  return _type;
97  }
98 
99  void resolve_symbols(Section<ElfType_> &);
100 
101  typedef SymbolSectionSymbolIteratorTag<ElfType_> SymbolIteratorTag;
103  SymbolIterator symbol_begin() const;
104  SymbolIterator symbol_end() const;
105  };
106 }
107 
108 #endif
Definition: pimp.hh:51
Definition: about_metadata-fwd.hh:23
Definition: visitor-fwd.hh:52
Definition: elf_sections.hh:32
Definition: elf_symbol_section.hh:38
Definition: wrapped_forward_iterator-fwd.hh:26
Definition: elf_symbol_section.hh:79
Definition: elf_sections.hh:35