Fixed all of the invalid reads/uninitialised value errors in aesalon.
[aesalon.git] / monitor / src / elf / Section.h
blob4e6704a835bb491f93e5c48e1d679eb20aac066e
1 #ifndef AESALON_MONITOR_ELF_SECTION_H
2 #define AESALON_MONITOR_ELF_SECTION_H
4 #include <linux/elf.h>
6 #include <string>
8 #include "Types.h"
10 namespace ELF {
12 class Section {
13 private:
14 #if AESALON_PLATFORM == AESALON_PLATFORM_x86_64
15 typedef Elf64_Shdr section_t;
16 #elif AESALON_PLATFORM == AESALON_PLATFORM_x86
17 typedef Elf32_Shdr section_t;
18 #endif
20 int file_fd;
22 section_t data;
24 Block *content;
26 std::string name;
28 std::size_t get_content_size() const { return data.sh_size; }
29 public:
30 Section(int file_fd);
31 virtual ~Section();
33 void read_content();
34 Block *get_content() {
35 if(content == NULL) read_content();
36 return content;
39 std::string get_name() const { return name; }
40 void set_name(std::string new_name) { name = new_name; }
42 Word get_name_offset() const { return data.sh_name; }
43 Word get_data_offset() const { return data.sh_offset; }
45 Word get_virtual_address() const { return data.sh_addr; }
47 bool is_string_table() const { return data.sh_type == SHT_STRTAB; }
50 } // namespace ELF
52 #endif