Continued ripping up the source.
[aesalon.git] / monitor / src / elf / Section.h
blob67ba75dd912f8d42a06a88012c0fda5672d9cba5
1 #ifndef AESALON_MONITOR_ELF_SECTION_H
2 #define AESALON_MONITOR_ELF_SECTION_H
4 #include <linux/elf.h>
6 #include "Types.h"
8 #include "misc/SmartPointer.h"
10 namespace Aesalon {
11 namespace Monitor {
12 namespace ELF {
14 class Section {
15 private:
16 #if AESALON_PLATFORM == AESALON_PLATFORM_x86_64
17 typedef Elf64_Shdr section_t;
18 #elif AESALON_PLATFORM == AESALON_PLATFORM_x86
19 typedef Elf32_Shdr section_t;
20 #endif
22 int file_fd;
24 section_t data;
26 Misc::SmartPointer<Block> content;
28 std::string name;
30 std::size_t get_content_size() const { return data.sh_size; }
31 public:
32 Section(int file_fd);
33 virtual ~Section() {}
35 void read_content();
36 Misc::SmartPointer<Block> get_content() {
37 if(!content.is_valid()) read_content();
38 return content;
41 std::string get_name() const { return name; }
42 void set_name(std::string new_name) { name = new_name; }
44 Word get_name_offset() const { return data.sh_name; }
45 Word get_data_offset() const { return data.sh_offset; }
47 Word get_virtual_address() const { return data.sh_addr; }
49 bool is_string_table() const { return data.sh_type == SHT_STRTAB; }
52 } // namespace ELF
53 } // namespace Monitor
54 } // namespace Aesalon
56 #endif