MCPcopy Create free account
hub / github.com/cinit/TMoe / ElfView

Class ElfView

app/src/main/cpp/utils/elfsym/ElfView.h:17–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15namespace elfsym {
16
17class ElfView {
18public:
19 using ElfInfo = struct {
20 const uint8_t *handle;
21 const void *ehdr;
22 const void *phdr;
23 const void *shdr;
24 const void *dyn;
25 uint32_t dyn_size;
26 const void *symtab;
27 uint32_t sym_size;
28 const void *relplt;
29 uint32_t relplt_size;
30 const void *reldyn;
31 bool use_rela;
32 uint32_t reldyn_size;
33 const void *gnu_hash;
34 uint32_t nbucket;
35 uint32_t nchain;
36 const uint32_t *bucket;
37 const uint32_t *chain;
38 const char *shstr;
39 const char *symstr;
40 };
41
42 static constexpr int ARCH_X86 = 3;
43 static constexpr int ARCH_X86_64 = 62;
44 static constexpr int ARCH_ARM = 40;
45 static constexpr int ARCH_AARCH64 = 183;
46private:
47 Rva mRva = {nullptr, 0};
48 int mPointerSize = 0;
49 int mArchitecture = 0;
50
51public:
52 void attachFileMemMapping(const Rva &rva);
53
54 [[nodiscard]] bool isValid() const noexcept {
55 return mPointerSize != 0;
56 }
57
58 inline void detach() {
59 mRva = {nullptr, 0};
60 mPointerSize = 0;
61 mArchitecture = 0;
62 }
63
64 [[nodiscard]] inline int getPointerSize() const noexcept {
65 return mPointerSize;
66 }
67
68 [[nodiscard]] inline int getArchitecture() const noexcept {
69 return mArchitecture;
70 }
71
72 [[nodiscard]] int getElfInfo(ElfInfo &info) const;
73
74 /**

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected