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)
50 } LibGoblin_SectionInfo;
53 /*=====================================================================*/
55 Ptr ptr_address; // Object Address
56 DWord dw_size; // Object Size (Address Range)
57 char *pstr_name; // Object Name (Param./Func./etc...)
58 //DWord dw_srcid; // SourceInfo struct ID
61 Word w_secid; // SectionInfo ItemIndex belong with this object.
62 } LibGoblin_AddressInfo ****OLD**** ;*/
65 /*=====================================================================*/
66 #define LIBGOBLIN_OBJINFO_INVALID 0x00
67 #define LIBGOBLIN_OBJINFO_VALID 0x01
69 #define OBJINFO_TYPE_NULL 0x00
70 #define OBJINFO_TYPE_MASTER 0x01
71 #define OBJINFO_TYPE_PROGHDR 0x02
72 #define OBJINFO_TYPE_SECTION 0x03
73 #define OBJINFO_TYPE_FUNCTION 0x04
74 #define OBJINFO_TYPE_OBJECT 0x05
75 #define OBJINFO_TYPE_COMMON 0x06
76 #define OBJINFO_TYPE_TLS 0x07
83 // Address & Memory-Range Info ----
85 Ptr ptr_addr; // Object Address
86 // [Section] sh_addr - Address in memory image.
87 // [Symbol ] st_value - Symbol value.
88 QWord qw_size; // Object Size (Address Range)
89 // [Symbol ] st_size - Size of associated object.
92 // Group(Parent-Child) Order Link ---
94 int i_parent_id; // Parent ObjectInfo
95 int i_child_topid; // Child Top ObjectInfo
97 int i_next_id; // Next
100 // Address Order Link ---
102 int i_next_id; // Next Address ObjectInfo
103 int i_prev_id; // Prev Address ObjectInfo
110 // [Section] sh_offset - Offset in file.
114 // ObjectInfo (DATA) ---
115 char *pstr_name; // Object Name (Param./Func./etc...)
116 // [Section] = sh_name - Section name (index into the section header string table).
117 // [Symbol ] = st_name - String table index of name.
121 DWord dw_hash_linkname;
127 DWord dw_type; // Entry type.
128 DWord dw_flags; // Access permission flags.
129 QWord qw_align; // Alignment in memory and file.
130 void *pv_proghdr; // Program Header Pointer
134 QWord qw_flag; // sh_flags - Section flags.
135 QWord qw_align; // sh_addralign - Alignment in bytes.
136 QWord qw_entsize; // sh_entsize - Size of each entry in section.
137 DWord dw_type; // sh_type - Section type.
138 DWord dw_link; // sh_link - Index of a related section.
139 DWord dw_info; // sh_info - Depends on section type.
144 Byte b_type; // st_info - Type and binding information.
145 Byte b_binding; // st_info - Type and binding information.
146 Byte b_visibility; // st_other - Reserved (not used).
147 Word w_secindex; // st_shndx - Section index of symbol.
154 int i_srcid; // SourceInfo struct ID
157 Word w_secid; // ==OLD== SectionInfo ItemIndex belong with this object.
159 } LibGoblin_ObjectInfo;
162 /*=====================================================================*/
166 } LibGoblin_AddressInfo;
168 /*=====================================================================*/
172 char str_filename[DRD64_MAX_PATH];
173 char str_localpath[DRD64_MAX_PATH];
174 char str_remotepath[DRD64_MAX_PATH];
178 /*=====================================================================*/
179 #define BINFILE_FLAGMASK_FILE (DWord)0x00000007
180 #define BINFILE_FLAG_FILE_MMAP (DWord)0x00000001
181 #define BINFILE_FLAG_FILE_EXTALLOC (DWord)0x00000002
182 #define BINFILE_FLAG_FILE_INTALLOC (DWord)0x00000004
184 #define BINFILE_FLAGMASK_RELTYPE (DWord)0x00000010
185 #define BINFILE_FLAG_RELTYPE_REL (DWord)0x00000000
186 #define BINFILE_FLAG_RELTYPE_RELA (DWord)0x00000010
192 /* Binary-File Info. */
196 // EXEC-program / shared lib. filename (without directry)
197 char str_filename[DRD64_MAX_PATH];
198 char str_localpath[DRD64_MAX_PATH]; // filepath in local machine path.(transported)
199 char str_remotepath[DRD64_MAX_PATH]; // filepath in remote machine path.(local machine is NULL)
201 // .dynamic Section - rpath (.so location path - converted real-path)
202 char str_rpath[DRD64_MAX_PATH];
203 // .dynamic Section - runpath (.so location path - converted real-path)
204 char str_runpath[DRD64_MAX_PATH];
206 LibFileType_FileType t_ftype;
208 /* Binary-File Memory Image Access Info. */
212 /* Binary-Format Depending Info. (ELF)*/
215 LibGoblin_SectionInfo t_section[LIBGOBLIN_SECTION_ID_MAX];
216 int i_secindex[LIBGOBLIN_SECTION_ID_MAX];
217 } LibGoblin_BinaryFile;
220 /*=====================================================================*/
221 #define LIBGOBLIN_BINFO_PHASE_INIT 0x00
222 #define LIBGOBLIN_BINFO_PHASE_ALLOCED 0x10
223 #define LIBGOBLIN_BINFO_PHASE_SETNAME 0x20
224 #define LIBGOBLIN_BINFO_PHASE_SETPROG 0x30
225 #define LIBGOBLIN_BINFO_PHASE_BINREAD 0x40
226 #define LIBGOBLIN_BINFO_PHASE_ELF1READ 0x51
227 #define LIBGOBLIN_BINFO_PHASE_ELF2READ 0x52
228 #define LIBGOBLIN_BINFO_PHASE_ANALYZED 0x50
230 #define LIBGOBLIN_BINFO_TYPE_NONE 0x00
231 #define LIBGOBLIN_BINFO_TYPE_ELF 0x01
232 #define LIBGOBLIN_BINFO_TYPE_ELF64 0x64
233 #define LIBGOBLIN_BINFO_TYPE_ELF32 0x32
236 ((LIBGOBLIN_BINFO_TYPE_ELF64==((n)->b_type)) ? 0x01 : 0x00)
238 ((LIBGOBLIN_BINFO_TYPE_ELF32==((n)->b_type)) ? 0x01 : 0x00)
239 #define IsBinfoType_Elf64(n) \
240 ((LIBGOBLIN_BINFO_TYPE_ELF64==((n)->b_type)) ? 0x01 : 0x00)
241 #define IsBinfoType_Elf32(n) \
242 ((LIBGOBLIN_BINFO_TYPE_ELF32==((n)->b_type)) ? 0x01 : 0x00)
244 #define LIBGOBLIN_BINFO_ENDIAN_NONE 0x00
245 #define LIBGOBLIN_BINFO_ENDIAN_LITTLE 0x01
246 #define LIBGOBLIN_BINFO_ENDIAN_BIG 0x02
248 #define LIBGOBLIN_BINFO_SECTION_TEXT 0x00
249 #define LIBGOBLIN_BINFO_SECTION_DATA 0x01
250 #define LIBGOBLIN_BINFO_SECTION_BSS 0x02
252 #define LIBGOBLIN_BINFO_MAXFILES 3 // Except FILE_LIBRARY
253 #define LIBGOBLIN_BINFO_FILE_EXEC 0
254 #define LIBGOBLIN_BINFO_FILE_CORE 1
255 #define LIBGOBLIN_BINFO_FILE_DEBUG 2
256 #define LIBGOBLIN_BINFO_FILE_LIBRARY -1
259 /* BinaryInfo Struct ID */
263 /* BinaryInfo Common Info. */
269 /* Debug-Format Depending Info. (DWarf) */
272 /* Address Table Info. */
274 LibGoblin_AddressInfo *p_addrinfo;
275 DWord dw_alloc_addrinfo;
276 DWord dw_max_addrinfo;
279 /* Exec. File Info. */
280 char str_filename[DRD64_MAX_PATH];
283 int i_binfile; // binaryFile ID
289 /* Binary-Format Depending Info. (ELF)*/
293 } LibGoblin_BinaryInfo;
296 /*=====================================================================*/
302 LibGoblin_BinaryInfo *p_binfo[LIBGOBLIN_BINFO_MAXFILES];
304 LibGoblin_SectionInfo t_section[LIBGOBLIN_SECTION_ID_MAX];
306 /* Address Table Info. */
307 //LibGoblin_AddressInfo *p_addrinfo;
308 //DWord dw_alloc_addrinfo;
309 //DWord dw_max_addrinfo;
311 // Object Table & Address Table ---
313 LibGoblin_ObjectInfo *p_objinfo;
314 int i_empty; // Empty ObjectInfo Chain Top-ID.
315 int i_alloced; // Alloced ObjectInfo
316 int i_used; // ObjectInfo Items
317 int i_topid; // Top-Ptr ObjectInfo
319 LibGoblin_AddressInfo *p_addrinfo;
325 } LibGoblin_ProgramInfo;
328 #endif /* DRD64_HEADER_LIBGOBLIN_TYPE*/
330 /* EOF of drd64_.h ----------------------------------- */