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 /*=====================================================================*/
48 QWord qw_abbrev_offset;
51 QWord qw_type_signature; // for DWARF4
52 QWord qw_type_offset; // for DWARF4
53 } LibGoblin_DWARF_Info_CUHeader;
56 /*=====================================================================*/
57 #define DWARF_ABBREV_MAXITEMS 30
64 DWord dw_attribute[ DWARF_ABBREV_MAXITEMS ];
65 DWord dw_format[ DWARF_ABBREV_MAXITEMS ];
69 /*=====================================================================*/
70 #define LIBGOBLIN_DWARF_INFO_TYPE_NONE 0x00
71 #define LIBGOBLIN_DWARF_INFO_TYPE_BYTE 0x01
72 #define LIBGOBLIN_DWARF_INFO_TYPE_WORD 0x02
73 #define LIBGOBLIN_DWARF_INFO_TYPE_DWORD 0x03
74 #define LIBGOBLIN_DWARF_INFO_TYPE_QWORD 0x04
75 #define LIBGOBLIN_DWARF_INFO_TYPE_INT64 0x05
76 #define LIBGOBLIN_DWARF_INFO_TYPE_POINTER 0x06
77 #define LIBGOBLIN_DWARF_INFO_TYPE_STRING 0x07
78 #define LIBGOBLIN_DWARF_INFO_TYPE_BLOCK 0x08
79 #define LIBGOBLIN_DWARF_INFO_TYPE_LINK 0x09
95 Byte *pb_data; // for BlockData
97 } LibGoblin_DWARF_DIEValue;
100 /*=====================================================================*/
103 LibGoblin_DWARF_DIEValue *p_val;
104 } LibGoblin_DWARF_Attribute;
107 /*=====================================================================*/
110 Byte *pb_data; // FileLocation (Offset)
120 } LibGoblin_SectionInfo;
123 /*=====================================================================*/
125 Ptr ptr_address; // Object Address
126 DWord dw_size; // Object Size (Address Range)
127 char *pstr_name; // Object Name (Param./Func./etc...)
128 //DWord dw_srcid; // SourceInfo struct ID
131 Word w_secid; // SectionInfo ItemIndex belong with this object.
132 } LibGoblin_AddressInfo ****OLD**** ;*/
135 /*=====================================================================*/
136 #define OBJINFO_STATUS_INVALID 0x00000000
137 #define OBJINFO_STATUS_VALID 0x00000001 // bit 0
138 #define OBJINFO_STATUS_DYNAMIC 0x00000002 // bit 1
139 #define OBJINFO_STATUS_RESOLV1 0x00000004 // bit 2 (Specified BinaryInfo & Index)
140 #define OBJINFO_STATUS_RESOLV2 0x00000008 // bit 3 (Loaded .so)
141 #define OBJINFO_STATUS_REL 0x00000100
143 #define OBJINFO_TYPE_NULL 0x00
144 #define OBJINFO_TYPE_PROGRAM 0x01
145 #define OBJINFO_TYPE_MASTER 0x02
146 #define OBJINFO_TYPE_PROGHDR 0x03
147 #define OBJINFO_TYPE_SECTION 0x04
148 #define OBJINFO_TYPE_FUNCTION 0x05
149 #define OBJINFO_TYPE_OBJECT 0x06
150 #define OBJINFO_TYPE_COMMON 0x07
151 #define OBJINFO_TYPE_TLS 0x08
152 #define OBJINFO_TYPE_REL 0x09
159 // Address & Memory-Range Info ----
161 Ptr ptr_addr; // Object Address
162 // [Section] sh_addr - Address in memory image.
163 // [Symbol ] st_value - Symbol value.
164 QWord qw_size; // Object Size (Address Range)
165 // [Symbol ] st_size - Size of associated object.
168 // Group(Parent-Child) Order Link ---
170 int i_parent_id; // Parent ObjectInfo
171 int i_child_topid; // Child Top ObjectInfo
173 int i_next_id; // Next
176 // Address Order Link ---
178 int i_next_id; // Next Address ObjectInfo
179 int i_prev_id; // Prev Address ObjectInfo
186 // [Section] sh_offset - Offset in file.
190 // ObjectInfo (DATA) ---
191 char *pstr_name; // Object Name (Param./Func./etc...)
192 // [Section] = sh_name - Section name (index into the section header string table).
193 // [Symbol ] = st_name - String table index of name.
204 DWord dw_type; // Entry type.
205 DWord dw_flags; // Access permission flags.
206 QWord qw_align; // Alignment in memory and file.
207 void *pv_proghdr; // Program Header Pointer
211 QWord qw_flag; // sh_flags - Section flags.
212 QWord qw_align; // sh_addralign - Alignment in bytes.
213 QWord qw_entsize; // sh_entsize - Size of each entry in section.
214 DWord dw_type; // sh_type - Section type.
215 DWord dw_link; // sh_link - Index of a related section.
216 DWord dw_info; // sh_info - Depends on section type.
221 Byte b_type; // st_info - Type and binding information.
222 Byte b_binding; // st_info - Type and binding information.
223 Byte b_visibility; // st_other - Reserved (not used).
224 Word w_secindex; // st_shndx - Section index of symbol.
241 int i_srcid; // SourceInfo struct ID
244 Word w_secid; // ==OLD== SectionInfo ItemIndex belong with this object.
246 } LibGoblin_ObjectInfo;
249 /*=====================================================================*/
253 } LibGoblin_AddressInfo;
255 /*=====================================================================*/
258 DWord dw_hash_filename;
259 DWord dw_hash_localpath;
260 char str_filename[DRD64_MAX_PATH];
261 char str_localpath[DRD64_MAX_PATH];
262 char str_srcpath[DRD64_MAX_PATH]; // for DW_AT_name
263 char str_buildpath[DRD64_MAX_PATH]; // for DW_AT_comp_dir (Optional)
268 DWARF_AbbrevEntry *p_abbrev;
274 /*=====================================================================*/
275 #define BINFILE_FLAGMASK_FILE (DWord)0x00000007
276 #define BINFILE_FLAG_FILE_MMAP (DWord)0x00000001
277 #define BINFILE_FLAG_FILE_EXTALLOC (DWord)0x00000002
278 #define BINFILE_FLAG_FILE_INTALLOC (DWord)0x00000004
280 #define BINFILE_FLAGMASK_RELTYPE (DWord)0x00000010
281 #define BINFILE_FLAG_RELTYPE_REL (DWord)0x00000000
282 #define BINFILE_FLAG_RELTYPE_RELA (DWord)0x00000010
284 #define BINFILE_STATUS_NOUSE 0x00
285 #define BINFILE_STATUS_CREATE 0x01
286 #define BINFILE_STATUS_FILEOPEN 0x02
287 #define BINFILE_STATUS_READSECTION 0x03
293 /* Binary-File Info. */
298 // EXEC-program / shared lib. filename (without directry)
299 char str_filename[DRD64_MAX_PATH];
300 char str_localpath[DRD64_MAX_PATH]; // filepath in local machine path.(transported)
301 char str_remotepath[DRD64_MAX_PATH]; // filepath in remote machine path.(local machine is NULL)
303 // .dynamic Section - rpath (.so location path - converted real-path)
304 char str_rpath[DRD64_MAX_PATH];
305 // .dynamic Section - runpath (.so location path - converted real-path)
306 char str_runpath[DRD64_MAX_PATH];
308 LibFileType_FileType t_ftype;
310 /* Binary-File Memory Image Access Info. */
315 LibGoblin_SrcFile *p_srcfile;
324 DWARF_AbbrevEntry *p_abbrev;
325 QWord qw_abbrev_unreadsz;
332 /* Binary-Format Depending Info. (ELF)*/
335 LibGoblin_SectionInfo t_section[LIBGOBLIN_SECTION_ID_MAX];
336 int i_secindex[LIBGOBLIN_SECTION_ID_MAX];
337 } LibGoblin_BinaryFile;
340 /*=====================================================================*/
341 #define LIBGOBLIN_BINFO_PHASE_INIT 0x00
342 #define LIBGOBLIN_BINFO_PHASE_ALLOCED 0x10
343 #define LIBGOBLIN_BINFO_PHASE_SETNAME 0x20
344 #define LIBGOBLIN_BINFO_PHASE_SETPROG 0x30
345 #define LIBGOBLIN_BINFO_PHASE_BINREAD 0x40
346 #define LIBGOBLIN_BINFO_PHASE_ELF1READ 0x51
347 #define LIBGOBLIN_BINFO_PHASE_ELF2READ 0x52
348 #define LIBGOBLIN_BINFO_PHASE_ANALYZED 0x50
350 #define LIBGOBLIN_BINFO_TYPE_NONE 0x00
351 #define LIBGOBLIN_BINFO_TYPE_ELF 0x01
352 #define LIBGOBLIN_BINFO_TYPE_ELF64 0x64
353 #define LIBGOBLIN_BINFO_TYPE_ELF32 0x32
356 ((LIBGOBLIN_BINFO_TYPE_ELF64==((n)->b_type)) ? 0x01 : 0x00)
358 ((LIBGOBLIN_BINFO_TYPE_ELF32==((n)->b_type)) ? 0x01 : 0x00)
359 #define IsBinfoType_Elf64(n) \
360 ((LIBGOBLIN_BINFO_TYPE_ELF64==((n)->b_type)) ? 0x01 : 0x00)
361 #define IsBinfoType_Elf32(n) \
362 ((LIBGOBLIN_BINFO_TYPE_ELF32==((n)->b_type)) ? 0x01 : 0x00)
364 #define LIBGOBLIN_BINFO_ENDIAN_NONE 0x00
365 #define LIBGOBLIN_BINFO_ENDIAN_LITTLE 0x01
366 #define LIBGOBLIN_BINFO_ENDIAN_BIG 0x02
368 #define LIBGOBLIN_BINFO_SECTION_TEXT 0x00
369 #define LIBGOBLIN_BINFO_SECTION_DATA 0x01
370 #define LIBGOBLIN_BINFO_SECTION_BSS 0x02
372 #define LIBGOBLIN_BINFO_MAXFILES 3 // Except FILE_LIBRARY
373 #define LIBGOBLIN_BINFO_FILE_EXEC 0
374 #define LIBGOBLIN_BINFO_FILE_CORE 1
375 #define LIBGOBLIN_BINFO_FILE_DEBUG 2
376 #define LIBGOBLIN_BINFO_FILE_LIBRARY -1
379 /* BinaryInfo Struct ID */
383 /* BinaryInfo Common Info. */
388 /* Debug-Format Depending Info. (DWarf) */
391 /* Address Table Info. */
393 LibGoblin_AddressInfo *p_addrinfo;
394 DWord dw_alloc_addrinfo;
395 DWord dw_max_addrinfo;
398 /* Exec. File Info. */
399 char str_filename[DRD64_MAX_PATH];
402 int i_binfile; // binaryFile ID
409 PtrValue ptr_loadbase;
411 LibGoblin_SectionInfo t_section[LIBGOBLIN_SECTION_ID_MAX];
413 /* Binary-Format Depending Info. (ELF)*/
418 LibGoblin_DWARF_DIEValue *p_infoval;
422 } LibGoblin_BinaryInfo;
425 /*=====================================================================*/
430 // Object Table & Address Table ---
432 LibGoblin_ObjectInfo *p_objinfo;
433 int i_empty; // Empty ObjectInfo Chain Top-ID.
434 int i_alloced; // Alloced ObjectInfo
435 int i_used; // ObjectInfo Items
436 int i_topid; // Top-Ptr ObjectInfo
438 LibGoblin_AddressInfo *p_addrinfo;
445 /* Address Table Info. */
446 //LibGoblin_AddressInfo *p_addrinfo;
447 //DWord dw_alloc_addrinfo;
448 //DWord dw_max_addrinfo;
451 } LibGoblin_ProgramInfo;
454 #endif /* DRD64_HEADER_LIBGOBLIN_TYPE*/
456 /* EOF of drd64_.h ----------------------------------- */