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 /*=====================================================================*/
42 #define DWARF_ABBREV_MAXITEMS 30
49 DWord dw_attribute[ DWARF_ABBREV_MAXITEMS ];
50 DWord dw_format[ DWARF_ABBREV_MAXITEMS ];
54 /*=====================================================================*/
55 #define LIBGOBLIN_DWARF_INFO_TYPE_NONE 0x00
56 #define LIBGOBLIN_DWARF_INFO_TYPE_BYTE 0x01
57 #define LIBGOBLIN_DWARF_INFO_TYPE_WORD 0x02
58 #define LIBGOBLIN_DWARF_INFO_TYPE_DWORD 0x03
59 #define LIBGOBLIN_DWARF_INFO_TYPE_QWORD 0x04
60 #define LIBGOBLIN_DWARF_INFO_TYPE_INT64 0x05
61 #define LIBGOBLIN_DWARF_INFO_TYPE_POINTER 0x06
62 #define LIBGOBLIN_DWARF_INFO_TYPE_STRING 0x07
63 #define LIBGOBLIN_DWARF_INFO_TYPE_BLOCK 0x08
64 #define LIBGOBLIN_DWARF_INFO_TYPE_LINK 0x09
80 Byte *pb_data; // for BlockData
82 } LibGoblin_DWARF_DIEValue;
85 /*=====================================================================*/
88 LibGoblin_DWARF_DIEValue *p_val;
89 } LibGoblin_DWARF_Attribute;
92 /*=====================================================================*/
95 Byte *pb_data; // FileLocation (Offset)
105 } LibGoblin_SectionInfo;
108 /*=====================================================================*/
110 Ptr ptr_address; // Object Address
111 DWord dw_size; // Object Size (Address Range)
112 char *pstr_name; // Object Name (Param./Func./etc...)
113 //DWord dw_srcid; // SourceInfo struct ID
116 Word w_secid; // SectionInfo ItemIndex belong with this object.
117 } LibGoblin_AddressInfo ****OLD**** ;*/
120 /*=====================================================================*/
121 #define OBJINFO_STATUS_INVALID 0x00000000
122 #define OBJINFO_STATUS_VALID 0x00000001 // bit 0
123 #define OBJINFO_STATUS_DYNAMIC 0x00000002 // bit 1
124 #define OBJINFO_STATUS_RESOLV1 0x00000004 // bit 2 (Specified BinaryInfo & Index)
125 #define OBJINFO_STATUS_RESOLV2 0x00000008 // bit 3 (Loaded .so)
126 #define OBJINFO_STATUS_REL 0x00000100
128 #define OBJINFO_TYPE_NULL 0x00
129 #define OBJINFO_TYPE_PROGRAM 0x01
130 #define OBJINFO_TYPE_MASTER 0x02
131 #define OBJINFO_TYPE_PROGHDR 0x03
132 #define OBJINFO_TYPE_SECTION 0x04
133 #define OBJINFO_TYPE_FUNCTION 0x05
134 #define OBJINFO_TYPE_OBJECT 0x06
135 #define OBJINFO_TYPE_COMMON 0x07
136 #define OBJINFO_TYPE_TLS 0x08
137 #define OBJINFO_TYPE_REL 0x09
144 // Address & Memory-Range Info ----
146 Ptr ptr_addr; // Object Address
147 // [Section] sh_addr - Address in memory image.
148 // [Symbol ] st_value - Symbol value.
149 QWord qw_size; // Object Size (Address Range)
150 // [Symbol ] st_size - Size of associated object.
153 // Group(Parent-Child) Order Link ---
155 int i_parent_id; // Parent ObjectInfo
156 int i_child_topid; // Child Top ObjectInfo
158 int i_next_id; // Next
161 // Address Order Link ---
163 int i_next_id; // Next Address ObjectInfo
164 int i_prev_id; // Prev Address ObjectInfo
171 // [Section] sh_offset - Offset in file.
175 // ObjectInfo (DATA) ---
176 char *pstr_name; // Object Name (Param./Func./etc...)
177 // [Section] = sh_name - Section name (index into the section header string table).
178 // [Symbol ] = st_name - String table index of name.
189 DWord dw_type; // Entry type.
190 DWord dw_flags; // Access permission flags.
191 QWord qw_align; // Alignment in memory and file.
192 void *pv_proghdr; // Program Header Pointer
196 QWord qw_flag; // sh_flags - Section flags.
197 QWord qw_align; // sh_addralign - Alignment in bytes.
198 QWord qw_entsize; // sh_entsize - Size of each entry in section.
199 DWord dw_type; // sh_type - Section type.
200 DWord dw_link; // sh_link - Index of a related section.
201 DWord dw_info; // sh_info - Depends on section type.
206 Byte b_type; // st_info - Type and binding information.
207 Byte b_binding; // st_info - Type and binding information.
208 Byte b_visibility; // st_other - Reserved (not used).
209 Word w_secindex; // st_shndx - Section index of symbol.
226 int i_srcid; // SourceInfo struct ID
229 Word w_secid; // ==OLD== SectionInfo ItemIndex belong with this object.
231 } LibGoblin_ObjectInfo;
234 /*=====================================================================*/
238 } LibGoblin_AddressInfo;
240 /*=====================================================================*/
243 DWord dw_hash_filename;
244 DWord dw_hash_localpath;
245 char str_filename[DRD64_MAX_PATH];
246 char str_localpath[DRD64_MAX_PATH];
247 char str_srcpath[DRD64_MAX_PATH]; // for DW_AT_name
248 char str_buildpath[DRD64_MAX_PATH]; // for DW_AT_comp_dir (Optional)
253 DWARF_AbbrevEntry *p_abbrev;
259 /*=====================================================================*/
260 #define BINFILE_FLAGMASK_FILE (DWord)0x00000007
261 #define BINFILE_FLAG_FILE_MMAP (DWord)0x00000001
262 #define BINFILE_FLAG_FILE_EXTALLOC (DWord)0x00000002
263 #define BINFILE_FLAG_FILE_INTALLOC (DWord)0x00000004
265 #define BINFILE_FLAGMASK_RELTYPE (DWord)0x00000010
266 #define BINFILE_FLAG_RELTYPE_REL (DWord)0x00000000
267 #define BINFILE_FLAG_RELTYPE_RELA (DWord)0x00000010
269 #define BINFILE_STATUS_NOUSE 0x00
270 #define BINFILE_STATUS_CREATE 0x01
271 #define BINFILE_STATUS_FILEOPEN 0x02
272 #define BINFILE_STATUS_READSECTION 0x03
278 /* Binary-File Info. */
283 // EXEC-program / shared lib. filename (without directry)
284 char str_filename[DRD64_MAX_PATH];
285 char str_localpath[DRD64_MAX_PATH]; // filepath in local machine path.(transported)
286 char str_remotepath[DRD64_MAX_PATH]; // filepath in remote machine path.(local machine is NULL)
288 // .dynamic Section - rpath (.so location path - converted real-path)
289 char str_rpath[DRD64_MAX_PATH];
290 // .dynamic Section - runpath (.so location path - converted real-path)
291 char str_runpath[DRD64_MAX_PATH];
293 LibFileType_FileType t_ftype;
295 /* Binary-File Memory Image Access Info. */
300 LibGoblin_SrcFile *p_srcfile;
309 DWARF_AbbrevEntry *p_abbrev;
310 QWord qw_abbrev_unreadsz;
317 /* Binary-Format Depending Info. (ELF)*/
320 LibGoblin_SectionInfo t_section[LIBGOBLIN_SECTION_ID_MAX];
321 int i_secindex[LIBGOBLIN_SECTION_ID_MAX];
322 } LibGoblin_BinaryFile;
325 /*=====================================================================*/
326 #define LIBGOBLIN_BINFO_PHASE_INIT 0x00
327 #define LIBGOBLIN_BINFO_PHASE_ALLOCED 0x10
328 #define LIBGOBLIN_BINFO_PHASE_SETNAME 0x20
329 #define LIBGOBLIN_BINFO_PHASE_SETPROG 0x30
330 #define LIBGOBLIN_BINFO_PHASE_BINREAD 0x40
331 #define LIBGOBLIN_BINFO_PHASE_ELF1READ 0x51
332 #define LIBGOBLIN_BINFO_PHASE_ELF2READ 0x52
333 #define LIBGOBLIN_BINFO_PHASE_ANALYZED 0x50
335 #define LIBGOBLIN_BINFO_TYPE_NONE 0x00
336 #define LIBGOBLIN_BINFO_TYPE_ELF 0x01
337 #define LIBGOBLIN_BINFO_TYPE_ELF64 0x64
338 #define LIBGOBLIN_BINFO_TYPE_ELF32 0x32
341 ((LIBGOBLIN_BINFO_TYPE_ELF64==((n)->b_type)) ? 0x01 : 0x00)
343 ((LIBGOBLIN_BINFO_TYPE_ELF32==((n)->b_type)) ? 0x01 : 0x00)
344 #define IsBinfoType_Elf64(n) \
345 ((LIBGOBLIN_BINFO_TYPE_ELF64==((n)->b_type)) ? 0x01 : 0x00)
346 #define IsBinfoType_Elf32(n) \
347 ((LIBGOBLIN_BINFO_TYPE_ELF32==((n)->b_type)) ? 0x01 : 0x00)
349 #define LIBGOBLIN_BINFO_ENDIAN_NONE 0x00
350 #define LIBGOBLIN_BINFO_ENDIAN_LITTLE 0x01
351 #define LIBGOBLIN_BINFO_ENDIAN_BIG 0x02
353 #define LIBGOBLIN_BINFO_SECTION_TEXT 0x00
354 #define LIBGOBLIN_BINFO_SECTION_DATA 0x01
355 #define LIBGOBLIN_BINFO_SECTION_BSS 0x02
357 #define LIBGOBLIN_BINFO_MAXFILES 3 // Except FILE_LIBRARY
358 #define LIBGOBLIN_BINFO_FILE_EXEC 0
359 #define LIBGOBLIN_BINFO_FILE_CORE 1
360 #define LIBGOBLIN_BINFO_FILE_DEBUG 2
361 #define LIBGOBLIN_BINFO_FILE_LIBRARY -1
364 /* BinaryInfo Struct ID */
368 /* BinaryInfo Common Info. */
373 /* Debug-Format Depending Info. (DWarf) */
376 /* Address Table Info. */
378 LibGoblin_AddressInfo *p_addrinfo;
379 DWord dw_alloc_addrinfo;
380 DWord dw_max_addrinfo;
383 /* Exec. File Info. */
384 char str_filename[DRD64_MAX_PATH];
387 int i_binfile; // binaryFile ID
394 PtrValue ptr_loadbase;
396 LibGoblin_SectionInfo t_section[LIBGOBLIN_SECTION_ID_MAX];
398 /* Binary-Format Depending Info. (ELF)*/
403 LibGoblin_DWARF_DIEValue *p_infoval;
407 } LibGoblin_BinaryInfo;
410 /*=====================================================================*/
415 // Object Table & Address Table ---
417 LibGoblin_ObjectInfo *p_objinfo;
418 int i_empty; // Empty ObjectInfo Chain Top-ID.
419 int i_alloced; // Alloced ObjectInfo
420 int i_used; // ObjectInfo Items
421 int i_topid; // Top-Ptr ObjectInfo
423 LibGoblin_AddressInfo *p_addrinfo;
430 /* Address Table Info. */
431 //LibGoblin_AddressInfo *p_addrinfo;
432 //DWord dw_alloc_addrinfo;
433 //DWord dw_max_addrinfo;
436 } LibGoblin_ProgramInfo;
439 #endif /* DRD64_HEADER_LIBGOBLIN_TYPE*/
441 /* EOF of drd64_.h ----------------------------------- */