Last change
on this file since 792 was
163,
checked in by karaoui, 13 years ago
|
changing mover to memo
changing soft.bin to soft.elf
...
|
File size:
1.7 KB
|
Line | |
---|
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 | #include <iostream> |
---|
22 | #include <cstdlib> |
---|
23 | #include <cstring> |
---|
24 | |
---|
25 | #include <dpp/foreach> |
---|
26 | |
---|
27 | #include <elfpp/symbol> |
---|
28 | #include <elfpp/section> |
---|
29 | #include <elfpp/reloc> |
---|
30 | |
---|
31 | namespace elfpp |
---|
32 | { |
---|
33 | |
---|
34 | symbol::symbol(const std::string &name) |
---|
35 | : name_(name), |
---|
36 | value_(0), |
---|
37 | size_(0), |
---|
38 | info_(0), |
---|
39 | other_(0), |
---|
40 | section_(0), |
---|
41 | sec_ndx_(0), |
---|
42 | reloc_tab_(), |
---|
43 | content_(0) |
---|
44 | { |
---|
45 | } |
---|
46 | |
---|
47 | symbol::~symbol() |
---|
48 | { |
---|
49 | if (content_) |
---|
50 | std::free(content_); |
---|
51 | |
---|
52 | FOREACH2(s, reloc_tab_) |
---|
53 | delete &*s; |
---|
54 | FOREACH(s, reloc_mod_) |
---|
55 | delete &*s; |
---|
56 | } |
---|
57 | |
---|
58 | void symbol::set_section(section &sec) |
---|
59 | { |
---|
60 | section_ = &sec; |
---|
61 | } |
---|
62 | |
---|
63 | void symbol::set_content(uint8_t *data) |
---|
64 | { |
---|
65 | content_ = (uint8_t*)std::realloc(content_, size_); |
---|
66 | std::memcpy(content_, data, size_); |
---|
67 | } |
---|
68 | |
---|
69 | std::ostream & operator<<(std::ostream &o, const symbol &s) |
---|
70 | { |
---|
71 | o << "[" << s.name_ << " val:" << s.value_ << " size:" << s.size_ << "]"; |
---|
72 | return o; |
---|
73 | }; |
---|
74 | |
---|
75 | } |
---|
76 | |
---|
Note: See
TracBrowser
for help on using the repository browser.