ELFSectionBits.h revision 58611fc8193e7386698178f167a2e0cbdd6a4f6f
1#ifndef ELF_SECTION_BITS_H
2#define ELF_SECTION_BITS_H
3
4#include "ELFTypes.h"
5#include "ELFSection.h"
6
7#include <llvm/ADT/OwningPtr.h>
8
9template <unsigned Bitwidth>
10class ELFSectionBits : public ELFSection<Bitwidth> {
11protected:
12  ELFSectionHeader<Bitwidth> const *section_header;
13  unsigned char *buf;
14  size_t buf_size;
15
16protected:
17  ELFSectionBits() : buf(NULL), buf_size(0) { }
18
19  ~ELFSectionBits();
20
21public:
22  template <typename Archiver, typename ConcreteELFSectionBits>
23  static ConcreteELFSectionBits *
24  read(Archiver &AR,
25       ELFSectionHeader<Bitwidth> const *sh,
26       ConcreteELFSectionBits *concrete);
27
28  virtual void print() const {}
29
30  unsigned char &operator[](size_t index) {
31    return buf[index];
32  }
33
34  unsigned char const &operator[](size_t index) const {
35    return buf[index];
36  }
37
38  size_t size() const {
39    return buf_size;
40  }
41
42  unsigned char const *memory_protect() const;
43
44};
45
46#include "impl/ELFSectionBits.hxx"
47
48#endif // ELF_SECTION_BITS_H
49