2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
23 #include <sys/types.h>
24 #include <asm/ptrace.h>
30 #include "shared/telf.h"
46 struct ProgramTableHeader32 {
57 struct ProgramTableHeader64 {
81 typedef Elf32_Ehdr Ehdr;
82 typedef Elf32_Phdr Phdr;
83 typedef Elf32_Addr Addr;
84 typedef Elf32_Shdr Shdr;
85 typedef Elf32_Off Off;
86 typedef Elf32_Section Section;
87 typedef Elf32_Versym Versym;
88 typedef Elf32_Half Half;
89 typedef Elf32_Sword Sword;
90 typedef Elf32_Word Word;
91 typedef Elf32_Sxword Sxword;
92 typedef Elf32_Xword Xword;
93 typedef ProgramTableHeader32 ProgramTableHeader;
94 typedef Notefile32 Notefile;
95 typedef Elf32_auxv_t auxv_t;
96 typedef Elf32_Dyn Dyn;
97 typedef uint32_t uint;
98 static const char ELFCLASS = ELFCLASS32;
102 typedef Elf64_Ehdr Ehdr;
103 typedef Elf64_Phdr Phdr;
104 typedef Elf64_Addr Addr;
105 typedef Elf64_Shdr Shdr;
106 typedef Elf64_Off Off;
107 typedef Elf64_Section Section;
108 typedef Elf64_Versym Versym;
109 typedef Elf64_Half Half;
110 typedef Elf64_Sword Sword;
111 typedef Elf64_Word Word;
112 typedef Elf64_Sxword Sxword;
113 typedef Elf64_Xword Xword;
114 typedef ProgramTableHeader64 ProgramTableHeader;
115 typedef Notefile64 Notefile;
116 typedef Elf64_auxv_t auxv_t;
117 typedef Elf64_Dyn Dyn;
118 typedef uint64_t uint;
119 static const char ELFCLASS = ELFCLASS64;
124 const std::function<void()> m_start;
125 const std::function<void()> m_end;
127 Guardian(const std::function<void()> &start, const std::function<void()> &end)
128 : m_start(start), m_end(end) { m_start(); }
129 ~Guardian() { m_end(); }
132 bool fileExists(const std::string &path) {
134 return stat(path.c_str(), &buf) == 0;
137 #endif // HELPERS_HPP__