1 | /* |
---|
2 | This file is part of Libelfpp. |
---|
3 | |
---|
4 | Libelfpp is free software: you can redistribute it and/or modify |
---|
5 | it under the terms of the GNU Lesser General Public License as |
---|
6 | published by the Free Software Foundation, either version 3 of the |
---|
7 | License, or (at your option) any later version. |
---|
8 | |
---|
9 | Libelfpp is distributed in the hope that it will be useful, but |
---|
10 | WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
12 | General Public License for more details. |
---|
13 | |
---|
14 | You should have received a copy of the GNU Lesser General Public |
---|
15 | License along with Libelfpp. If not, see |
---|
16 | <http://www.gnu.org/licenses/>. |
---|
17 | |
---|
18 | Copyright (c) Alexandre Becoulet <alexandre.becoulet@free.fr> |
---|
19 | */ |
---|
20 | |
---|
21 | #ifndef ELFPP_SECTION_HXX_ |
---|
22 | #define ELFPP_SECTION_HXX_ |
---|
23 | |
---|
24 | #include <stdexcept> |
---|
25 | |
---|
26 | namespace elfpp |
---|
27 | { |
---|
28 | |
---|
29 | void section::set_name(const std::string &name) |
---|
30 | { |
---|
31 | name_ = name; |
---|
32 | } |
---|
33 | |
---|
34 | const std::string & section::get_name() const |
---|
35 | { |
---|
36 | return name_; |
---|
37 | } |
---|
38 | |
---|
39 | sh_type_e section::get_type() const |
---|
40 | { |
---|
41 | return type_; |
---|
42 | } |
---|
43 | |
---|
44 | void section::set_flags(sh_flags_e flags) |
---|
45 | { |
---|
46 | flags_ = flags; |
---|
47 | } |
---|
48 | |
---|
49 | sh_flags_e section::get_flags() const |
---|
50 | { |
---|
51 | return flags_; |
---|
52 | } |
---|
53 | |
---|
54 | void section::set_vaddr(uint64_t vaddr) |
---|
55 | { |
---|
56 | vaddr_ = vaddr; |
---|
57 | } |
---|
58 | |
---|
59 | uint64_t section::get_vaddr() const |
---|
60 | { |
---|
61 | return vaddr_; |
---|
62 | } |
---|
63 | |
---|
64 | size_t section::get_size() const |
---|
65 | { |
---|
66 | return size_; |
---|
67 | } |
---|
68 | |
---|
69 | void section::set_align(uint32_t align) |
---|
70 | { |
---|
71 | align_ = align; |
---|
72 | } |
---|
73 | |
---|
74 | uint32_t section::get_align() const |
---|
75 | { |
---|
76 | return align_; |
---|
77 | } |
---|
78 | |
---|
79 | void section::set_link(section *s) |
---|
80 | { |
---|
81 | link_ = s; |
---|
82 | s->back_info_ = this; |
---|
83 | } |
---|
84 | |
---|
85 | section * section::get_link() const |
---|
86 | { |
---|
87 | return link_; |
---|
88 | } |
---|
89 | |
---|
90 | section * section::get_back_link() const |
---|
91 | { |
---|
92 | return back_link_; |
---|
93 | } |
---|
94 | |
---|
95 | void section::set_info(section *s) |
---|
96 | { |
---|
97 | info_ = s; |
---|
98 | if (s) |
---|
99 | s->back_info_ = this; |
---|
100 | } |
---|
101 | |
---|
102 | section * section::get_info() const |
---|
103 | { |
---|
104 | return info_; |
---|
105 | } |
---|
106 | |
---|
107 | section * section::get_back_info() const |
---|
108 | { |
---|
109 | return back_info_; |
---|
110 | } |
---|
111 | |
---|
112 | void section::set_info_last(unsigned int last) |
---|
113 | { |
---|
114 | info_last_ = last; |
---|
115 | } |
---|
116 | |
---|
117 | unsigned int section::get_info_last() |
---|
118 | { |
---|
119 | return info_last_; |
---|
120 | } |
---|
121 | |
---|
122 | void section::set_entsize(uint32_t entsize) |
---|
123 | { |
---|
124 | entsize_ = entsize; |
---|
125 | } |
---|
126 | |
---|
127 | uint32_t section::get_entsize() const |
---|
128 | { |
---|
129 | return entsize_; |
---|
130 | } |
---|
131 | |
---|
132 | void section::set_content(void* a) |
---|
133 | { |
---|
134 | content_ = (uint8_t*) a; |
---|
135 | } |
---|
136 | |
---|
137 | uint8_t * section::get_content() const |
---|
138 | { |
---|
139 | return content_; |
---|
140 | } |
---|
141 | |
---|
142 | off_t section::get_file_offset() const |
---|
143 | { |
---|
144 | return offset_; |
---|
145 | } |
---|
146 | |
---|
147 | void section::set_file_offset(off_t a) |
---|
148 | { |
---|
149 | offset_ = a; |
---|
150 | } |
---|
151 | |
---|
152 | const sym_tab_map_t & section::get_symbol_table() const |
---|
153 | { |
---|
154 | return sym_tab_; |
---|
155 | } |
---|
156 | |
---|
157 | symbol & section::get_symbol(const std::string &name) |
---|
158 | { |
---|
159 | sym_tab_map_t::iterator i = sym_tab_.find(name); |
---|
160 | |
---|
161 | if (i == sym_tab_.end()) |
---|
162 | throw std::runtime_error("no such symbol name"); |
---|
163 | |
---|
164 | return *i->second; |
---|
165 | } |
---|
166 | |
---|
167 | object * section::get_object() const |
---|
168 | { |
---|
169 | return object_; |
---|
170 | } |
---|
171 | |
---|
172 | } |
---|
173 | |
---|
174 | #endif |
---|
175 | |
---|