1 /*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
4 for INTEL64(R), AMD64(R)
6 Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are met:
11 1. Redistributions of source code must retain the above copyright notice,
12 this list of conditions and the following disclaimer.
13 2. Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in the
15 documentation and/or other materials provided with the distribution.
17 THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY
18 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE
21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
27 OF THE POSSIBILITY OF SUCH DAMAGE.
29 DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
31 /* File Info -----------------------------------------------------------
35 ----------------------------------------------------------------------*/
37 #ifndef DRD64_HEADER_LIBGOBLIN_TYPE
38 #define DRD64_HEADER_LIBGOBLIN_TYPE
41 /*=====================================================================*/
44 Byte *pb_data; // FileLocation (Offset)
49 } LibGoblin_SectionInfo;
52 /*=====================================================================*/
54 Ptr ptr_address; // Object Address
55 DWord dw_size; // Object Size (Address Range)
56 char *pstr_name; // Object Name (Param./Func./etc...)
57 //DWord dw_srcid; // SourceInfo struct ID
60 Word w_secid; // SectionInfo ItemIndex belong with this object.
61 } LibGoblin_AddressInfo ****OLD**** ;*/
64 /*=====================================================================*/
65 #define LIBGOBLIN_OBJINFO_INVALID 0x00
66 #define LIBGOBLIN_OBJINFO_VALID 0x01
68 #define OBJINFO_TYPE_NULL 0x00
69 #define OBJINFO_TYPE_MASTER 0x01
70 #define OBJINFO_TYPE_PROGHDR 0x02
71 #define OBJINFO_TYPE_SECTION 0x03
78 // Address & Memory-Range Info ----
80 Ptr ptr_addr; // Object Address
81 QWord qw_size; // Object Size (Address Range)
84 // Group(Parent-Child) Order Link ---
86 int i_parent_id; // Parent ObjectInfo
87 int i_child_topid; // Child Top ObjectInfo
89 int i_next_id; // Next
92 // Address Order Link ---
94 int i_next_id; // Next Address ObjectInfo
95 int i_prev_id; // Prev Address ObjectInfo
102 // [Section] sh_offset - Offset in file.
106 // ObjectInfo (DATA) ---
107 char *pstr_name; // Object Name (Param./Func./etc...)
108 // [Section] = sh_name - Section name (index into the section header string table).
114 DWord dw_type; // Entry type.
115 DWord dw_flags; // Access permission flags.
116 QWord qw_align; // Alignment in memory and file.
117 void *pv_proghdr; // Program Header Pointer
121 QWord qw_flag; // sh_flags - Section flags.
122 QWord qw_align; // sh_addralign - Alignment in bytes.
123 QWord qw_entsize; // sh_entsize - Size of each entry in section.
124 DWord dw_type; // sh_type - Section type.
125 DWord dw_link; // sh_link - Index of a related section.
126 DWord dw_info; // sh_info - Depends on section type.
128 // sh_addr - Address in memory image.
134 //DWord dw_srcid; // SourceInfo struct ID
136 Word w_secid; // SectionInfo ItemIndex belong with this object.
138 } LibGoblin_ObjectInfo;
141 /*=====================================================================*/
145 } LibGoblin_AddressInfo;
147 /*=====================================================================*/
150 char str_filename[DRD64_MAX_PATH];
151 char str_localpath[DRD64_MAX_PATH];
152 } LibGoblin_SourceInfo;
155 /*=====================================================================*/
160 /* Binary-File Info. */
164 // EXEC-program / shared lib. filename (without directry)
165 char str_filename[DRD64_MAX_PATH];
166 char str_localpath[DRD64_MAX_PATH]; // filepath in local machine path.(transported)
167 char str_remotepath[DRD64_MAX_PATH]; // filepath in remote machine path.(local machine is NULL)
169 // .dynamic Section - rpath (.so location path - converted real-path)
170 char str_rpath[DRD64_MAX_PATH];
171 // .dynamic Section - runpath (.so location path - converted real-path)
172 char str_runpath[DRD64_MAX_PATH];
174 LibFileType_FileType t_ftype;
176 /* Binary-File Memory Image Access Info. */
180 /* Binary-Format Depending Info. (ELF)*/
183 LibGoblin_SectionInfo t_section[LIBGOBLIN_SECTION_ID_MAX];
184 } LibGoblin_BinaryFile;
187 /*=====================================================================*/
188 #define LIBGOBLIN_BINFO_PHASE_INIT 0x00
189 #define LIBGOBLIN_BINFO_PHASE_ALLOCED 0x10
190 #define LIBGOBLIN_BINFO_PHASE_SETNAME 0x20
191 #define LIBGOBLIN_BINFO_PHASE_SETPROG 0x30
192 #define LIBGOBLIN_BINFO_PHASE_BINREAD 0x40
193 #define LIBGOBLIN_BINFO_PHASE_ELF1READ 0x51
194 #define LIBGOBLIN_BINFO_PHASE_ELF2READ 0x52
195 #define LIBGOBLIN_BINFO_PHASE_ANALYZED 0x50
197 #define LIBGOBLIN_BINFO_TYPE_NONE 0x00
198 #define LIBGOBLIN_BINFO_TYPE_ELF 0x01
199 #define LIBGOBLIN_BINFO_TYPE_ELF64 0x64
200 #define LIBGOBLIN_BINFO_TYPE_ELF32 0x32
203 ((LIBGOBLIN_BINFO_TYPE_ELF64==((n)->b_type)) ? 0x01 : 0x00)
205 ((LIBGOBLIN_BINFO_TYPE_ELF32==((n)->b_type)) ? 0x01 : 0x00)
206 #define IsBinfoType_Elf64(n) \
207 ((LIBGOBLIN_BINFO_TYPE_ELF64==((n)->b_type)) ? 0x01 : 0x00)
208 #define IsBinfoType_Elf32(n) \
209 ((LIBGOBLIN_BINFO_TYPE_ELF32==((n)->b_type)) ? 0x01 : 0x00)
211 #define LIBGOBLIN_BINFO_ENDIAN_NONE 0x00
212 #define LIBGOBLIN_BINFO_ENDIAN_LITTLE 0x01
213 #define LIBGOBLIN_BINFO_ENDIAN_BIG 0x02
215 #define LIBGOBLIN_BINFO_SECTION_TEXT 0x00
216 #define LIBGOBLIN_BINFO_SECTION_DATA 0x01
217 #define LIBGOBLIN_BINFO_SECTION_BSS 0x02
219 #define LIBGOBLIN_BINFO_FILE_MMAP (DWord)0x01
220 #define LIBGOBLIN_BINFO_FILE_EXTALLOC (DWord)0x02
221 #define LIBGOBLIN_BINFO_FILE_INTALLOC (DWord)0x04
223 #define LIBGOBLIN_BINFO_MAXFILES 3 // Except FILE_LIBRARY
224 #define LIBGOBLIN_BINFO_FILE_EXEC 0
225 #define LIBGOBLIN_BINFO_FILE_CORE 1
226 #define LIBGOBLIN_BINFO_FILE_DEBUG 2
227 #define LIBGOBLIN_BINFO_FILE_LIBRARY -1
230 /* BinaryInfo Struct ID */
234 /* BinaryInfo Common Info. */
240 /* Debug-Format Depending Info. (DWarf) */
243 /* Address Table Info. */
245 LibGoblin_AddressInfo *p_addrinfo;
246 DWord dw_alloc_addrinfo;
247 DWord dw_max_addrinfo;
250 /* Exec. File Info. */
252 char str_filename[DRD64_MAX_PATH];
254 int i_binfile; // binaryFile ID
256 /* Binary-Format Depending Info. (ELF)*/
262 } LibGoblin_BinaryInfo;
265 /*=====================================================================*/
266 #define LIBGOBLIN_PROGINFO_FLAG_REL 0x00000000
267 #define LIBGOBLIN_PROGINFO_FLAG_RELA 0x00000001
274 LibGoblin_BinaryInfo *p_binfo[LIBGOBLIN_BINFO_MAXFILES];
276 LibGoblin_SectionInfo t_section[LIBGOBLIN_SECTION_ID_MAX];
278 /* Address Table Info. */
279 //LibGoblin_AddressInfo *p_addrinfo;
280 //DWord dw_alloc_addrinfo;
281 //DWord dw_max_addrinfo;
283 // Object Table & Address Table ---
285 LibGoblin_ObjectInfo *p_objinfo;
286 int i_empty; // Empty ObjectInfo Chain Top-ID.
287 int i_alloced; // Alloced ObjectInfo
288 int i_used; // ObjectInfo Items
289 int i_topid; // Top-Ptr ObjectInfo
291 LibGoblin_AddressInfo *p_addrinfo;
297 } LibGoblin_ProgramInfo;
300 #endif /* DRD64_HEADER_LIBGOBLIN_TYPE*/
302 /* EOF of drd64_.h ----------------------------------- */