aboutsummaryrefslogtreecommitdiff
path: root/src/clients/reconcilio/littlelf/elf_relocation_section.hh
blob: bcf19ccc29124a379492aac56f2cc9ac65ca5ec9 (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
85
86
87
88
89
90
91
92
93
94
95
96
97
#ifndef ELFRELOCATIONSECTION_HH_
#define ELFRELOCATIONSECTION_HH_

#include "elf_sections.hh"

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

#include <iosfwd>

template <typename ElfType_>
class RelocationEntry
{
    private:
        typename ElfType_::Relocation _my_relocation;

    public:
        RelocationEntry(const typename ElfType_::Relocation &);
        ~RelocationEntry();

        typename ElfType_::RelocationOffset get_offset() const
        {
            return _my_relocation.r_offset;
        }

        typename ElfType_::RelocationInfo get_info() const
        {
            return _my_relocation.r_info;
        }
};

template <typename ElfType_>
class RelocationAEntry
{
    private:
        typename ElfType_::RelocationA _my_relocation;

    public:
        RelocationAEntry(const typename ElfType_::RelocationA &);
        ~RelocationAEntry();

        typename ElfType_::RelocationOffset get_offset() const
        {
            return _my_relocation.r_offset;
        }

        typename ElfType_::RelocationInfo get_info() const
        {
            return _my_relocation.r_info;
        }

        typename ElfType_::RelocationAddend get_addend() const
        {
            return _my_relocation.r_addend;
        }
};

template <typename ElfType_>
struct Relocation
{
    typedef typename ElfType_::Relocation Type;
    typedef RelocationEntry<ElfType_> Entry;
    const static std::string type_name;
};

template <typename ElfType_>
struct RelocationA
{
    typedef typename ElfType_::RelocationA Type;
    typedef RelocationAEntry<ElfType_> Entry;
    const static std::string type_name;
};

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

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

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

        struct RelocationIteratorTag;
        typedef paludis::WrappedForwardIterator<RelocationIteratorTag, const typename Relocation_::Entry> RelocationIterator;
        RelocationIterator relocation_begin() const;
        RelocationIterator relocation_end() const;
};

#endif /*ELFRELOCATIONSECTION_HH_*/