source: soft/giet_vm/memo/include/libelfpp/elfpp/elfpp_symbol.hh @ 264

Last change on this file since 264 was 163, checked in by karaoui, 12 years ago

changing mover to memo
changing soft.bin to soft.elf
...

File size: 4.2 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#ifndef ELFPP_SYMBOL_HH_
22#define ELFPP_SYMBOL_HH_
23
24#include "elfpp.hh"
25#include "elfpp_bits.hh"
26
27#include <stdint.h>
28#include <string>
29#include <map>
30
31#include <dpp/linked_list>
32
33namespace elfpp
34{
35
36  class reloc;
37  class section;
38
39  class symbol;
40  std::ostream & operator<<(std::ostream &o, const symbol &v);
41
42  /**
43      @short ELF symbol class
44      @header elfpp/symbol
45   */
46  class symbol
47  {
48    template <typename, int> friend class elfn_access;
49    friend std::ostream & operator<<(std::ostream &o, const symbol &v);
50    friend class reloc;
51
52  public:
53    /** @this creates a new symbol with given name */
54    symbol(const std::string &name);
55
56    ~symbol();
57
58    /** @this gets symbol name */
59    inline const std::string & get_name() const;
60
61    /** @this sets symbol section */
62    void set_section(section &sec);
63    /** @this gets symbol section */
64    inline section * get_section() const;
65    /** @this sets integer section index, must be used for special ndx values */
66    inline void set_section_ndx(unsigned int ndx);
67    /** @this gets integer section index */
68    inline unsigned int get_section_ndx() const;
69
70    /** @this gets symbol info field
71        @see get_type @see get_bind @see #ELF_ST_TYPE @see #ELF_ST_BIND */
72    inline uint8_t get_info() const;
73    /** @this sets symbol info field
74        @see set_type @see set_bind @see #ELF_ST_TYPE @see #ELF_ST_BIND */
75    inline void set_info(uint8_t st_info);
76
77    /** @this gets symbol type decoded from info field
78        @see get_info */
79    inline st_info_type_e get_type() const;
80    /** @this sets symbol type in info field
81        @see set_info */
82    inline void set_type(st_info_type_e type);
83
84    /** @this gets symbol bind decoded from info field
85        @see get_info */
86    inline st_info_bind_e get_bind() const;
87    /** @this sets symbol bind in info field
88        @see set_info */
89    inline void set_bind(st_info_bind_e bind);
90
91    /** @this gets symbol "other" field */
92    inline uint8_t get_other() const;
93    /** @this sets symbol "other" field */
94    inline void set_other(uint8_t st_other);
95
96    /** @this gets symbol value field */
97    inline uint64_t get_value() const;
98    /** @this sets symbol value field */
99    inline void set_value(uint64_t val);
100
101    /** @this gets symbol size in bytes */
102    inline size_t get_size() const;
103    /** @this sets symbol size in bytes */
104    inline void set_size(size_t size);
105
106    /** @multiple @this gets relocations associated with this symbol */
107    inline const reloc_table_t & get_reloc_table() const;
108
109    /** @multiple @this gets relocations which are mangling this symbol */
110    inline const reloc_modlist_t & get_mangling_relocs() const;
111
112    /** @this allocates a symbol content buffer of symbol size and fill with
113        data from given pointer. no symbol content buffer is allocated
114        by default unless load_symbol_data() has been called on elf
115        object. section is updated with symbol content at symbol value
116        offset when elf file is written. */
117    void set_content(uint8_t *data);
118
119    /** @this gets symbol content buffer */
120    inline uint8_t * get_content() const;
121
122  private:
123    /** start of flags present in elf symbol entry */
124    std::string                 name_;
125    uint64_t                    value_;
126    size_t                      size_;
127    uint8_t                     info_;
128    uint8_t                     other_;
129    section                     *section_;
130    unsigned int                sec_ndx_;
131    /** end of flags present in elf symbol entry */
132
133    unsigned int                index_;
134
135    reloc_table_t               reloc_tab_;
136    reloc_modlist_t             reloc_mod_;
137    uint8_t                     *content_;
138  };
139
140}
141
142#endif
143
Note: See TracBrowser for help on using the repository browser.