aboutsummaryrefslogtreecommitdiff
path: root/src/clients/reconcilio/littlelf/elf_symbol_section.hh
blob: 3f7d4fc33a31049529dc81c3fbe322dbe59f4bad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef ELFSYMBOLSECTION_HH_
#define ELFSYMBOLSECTION_HH_

#include "elf_sections.hh"

#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/wrapped_forward_iterator-fwd.hh>

#include <iosfwd>

namespace littlelf_internals
{
    template <typename ElfType_> class SymbolStringResolvingVisitor;
}

template <typename ElfType_>
class Symbol
{
    friend class littlelf_internals::SymbolStringResolvingVisitor<ElfType_>;

    private:
        typename ElfType_::Symbol _my_symbol;
        std::string _symbol_name;
        std::string _binding, _visibility;

    protected:
        void resolve_symbol(std::string symbol_name)
        {
            _symbol_name = symbol_name;
        }

        typename ElfType_::Word get_symbol_index() const
        {
            return _my_symbol.st_name;
        }

    public:
        Symbol(const typename ElfType_::Symbol &);
        ~Symbol();

        std::string name() const
        {
            return _symbol_name;
        }

        std::string binding() const
        {
            return _binding;
        }

        std::string visibility() const
        {
            return _visibility;
        }
};

template <typename ElfType_>
class SymbolSection :
    public Section<ElfType_>,
    public paludis::AcceptInterfaceVisitsThis<SectionVisitorTypes<ElfType_> , SymbolSection<ElfType_> >,
    private paludis::PrivateImplementationPattern<SymbolSection<ElfType_> >
{
    using paludis::PrivateImplementationPattern<SymbolSection>::_imp;

    private:
        std::string _type;

    public:
        SymbolSection(const typename ElfType_::SectionHeader &, std::istream &, bool);
        virtual ~SymbolSection();

        virtual std::string get_type() const
        {
            return _type;
        }

        void resolve_symbols(Section<ElfType_> &);

        typedef paludis::WrappedForwardIterator<enum SymbolIteratorTag { }, const Symbol<ElfType_ > > SymbolIterator;
        SymbolIterator symbol_begin() const;
        SymbolIterator symbol_end() const;
};

#endif /*ELFSYMBOLSECTION_HH_*/