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.
124 DWord dw_type; // Entry type.
125 DWord dw_flags; // Access permission flags.
126 QWord qw_align; // Alignment in memory and file.
127 void *pv_proghdr; // Program Header Pointer
131 QWord qw_flag; // sh_flags - Section flags.
132 QWord qw_align; // sh_addralign - Alignment in bytes.
133 QWord qw_entsize; // sh_entsize - Size of each entry in section.
134 DWord dw_type; // sh_type - Section type.
135 DWord dw_link; // sh_link - Index of a related section.
136 DWord dw_info; // sh_info - Depends on section type.
141 Byte b_type; // st_info - Type and binding information.
142 Byte b_binding; // st_info - Type and binding information.
143 Byte b_visibility; // st_other - Reserved (not used).
144 Word w_secindex; // st_shndx - Section index of symbol.
151 int i_srcid; // SourceInfo struct ID
154 Word w_secid; // ==OLD== SectionInfo ItemIndex belong with this object.
156 } LibGoblin_ObjectInfo;
159 /*=====================================================================*/
163 } LibGoblin_AddressInfo;
165 /*=====================================================================*/
169 char str_filename[DRD64_MAX_PATH];
170 char str_localpath[DRD64_MAX_PATH];
171 char str_remotepath[DRD64_MAX_PATH];
175 /*=====================================================================*/
176 #define BINFILE_FLAGMASK_FILE (DWord)0x00000007
177 #define BINFILE_FLAG_FILE_MMAP (DWord)0x00000001
178 #define BINFILE_FLAG_FILE_EXTALLOC (DWord)0x00000002
179 #define BINFILE_FLAG_FILE_INTALLOC (DWord)0x00000004
181 #define BINFILE_FLAGMASK_RELTYPE (DWord)0x00000010
182 #define BINFILE_FLAG_RELTYPE_REL (DWord)0x00000000
183 #define BINFILE_FLAG_RELTYPE_RELA (DWord)0x00000010
189 /* Binary-File Info. */
193 // EXEC-program / shared lib. filename (without directry)
194 char str_filename[DRD64_MAX_PATH];
195 char str_localpath[DRD64_MAX_PATH]; // filepath in local machine path.(transported)
196 char str_remotepath[DRD64_MAX_PATH]; // filepath in remote machine path.(local machine is NULL)
198 // .dynamic Section - rpath (.so location path - converted real-path)
199 char str_rpath[DRD64_MAX_PATH];
200 // .dynamic Section - runpath (.so location path - converted real-path)
201 char str_runpath[DRD64_MAX_PATH];
203 LibFileType_FileType t_ftype;
205 /* Binary-File Memory Image Access Info. */
209 /* Binary-Format Depending Info. (ELF)*/
212 LibGoblin_SectionInfo t_section[LIBGOBLIN_SECTION_ID_MAX];
213 int i_secindex[LIBGOBLIN_SECTION_ID_MAX];
214 } LibGoblin_BinaryFile;
217 /*=====================================================================*/
218 #define LIBGOBLIN_BINFO_PHASE_INIT 0x00
219 #define LIBGOBLIN_BINFO_PHASE_ALLOCED 0x10
220 #define LIBGOBLIN_BINFO_PHASE_SETNAME 0x20
221 #define LIBGOBLIN_BINFO_PHASE_SETPROG 0x30
222 #define LIBGOBLIN_BINFO_PHASE_BINREAD 0x40
223 #define LIBGOBLIN_BINFO_PHASE_ELF1READ 0x51
224 #define LIBGOBLIN_BINFO_PHASE_ELF2READ 0x52
225 #define LIBGOBLIN_BINFO_PHASE_ANALYZED 0x50
227 #define LIBGOBLIN_BINFO_TYPE_NONE 0x00
228 #define LIBGOBLIN_BINFO_TYPE_ELF 0x01
229 #define LIBGOBLIN_BINFO_TYPE_ELF64 0x64
230 #define LIBGOBLIN_BINFO_TYPE_ELF32 0x32
233 ((LIBGOBLIN_BINFO_TYPE_ELF64==((n)->b_type)) ? 0x01 : 0x00)
235 ((LIBGOBLIN_BINFO_TYPE_ELF32==((n)->b_type)) ? 0x01 : 0x00)
236 #define IsBinfoType_Elf64(n) \
237 ((LIBGOBLIN_BINFO_TYPE_ELF64==((n)->b_type)) ? 0x01 : 0x00)
238 #define IsBinfoType_Elf32(n) \
239 ((LIBGOBLIN_BINFO_TYPE_ELF32==((n)->b_type)) ? 0x01 : 0x00)
241 #define LIBGOBLIN_BINFO_ENDIAN_NONE 0x00
242 #define LIBGOBLIN_BINFO_ENDIAN_LITTLE 0x01
243 #define LIBGOBLIN_BINFO_ENDIAN_BIG 0x02
245 #define LIBGOBLIN_BINFO_SECTION_TEXT 0x00
246 #define LIBGOBLIN_BINFO_SECTION_DATA 0x01
247 #define LIBGOBLIN_BINFO_SECTION_BSS 0x02
249 #define LIBGOBLIN_BINFO_MAXFILES 3 // Except FILE_LIBRARY
250 #define LIBGOBLIN_BINFO_FILE_EXEC 0
251 #define LIBGOBLIN_BINFO_FILE_CORE 1
252 #define LIBGOBLIN_BINFO_FILE_DEBUG 2
253 #define LIBGOBLIN_BINFO_FILE_LIBRARY -1
256 /* BinaryInfo Struct ID */
260 /* BinaryInfo Common Info. */
266 /* Debug-Format Depending Info. (DWarf) */
269 /* Address Table Info. */
271 LibGoblin_AddressInfo *p_addrinfo;
272 DWord dw_alloc_addrinfo;
273 DWord dw_max_addrinfo;
276 /* Exec. File Info. */
278 char str_filename[DRD64_MAX_PATH];
280 int i_binfile; // binaryFile ID
282 /* Binary-Format Depending Info. (ELF)*/
288 } LibGoblin_BinaryInfo;
291 /*=====================================================================*/
297 LibGoblin_BinaryInfo *p_binfo[LIBGOBLIN_BINFO_MAXFILES];
299 LibGoblin_SectionInfo t_section[LIBGOBLIN_SECTION_ID_MAX];
301 /* Address Table Info. */
302 //LibGoblin_AddressInfo *p_addrinfo;
303 //DWord dw_alloc_addrinfo;
304 //DWord dw_max_addrinfo;
306 // Object Table & Address Table ---
308 LibGoblin_ObjectInfo *p_objinfo;
309 int i_empty; // Empty ObjectInfo Chain Top-ID.
310 int i_alloced; // Alloced ObjectInfo
311 int i_used; // ObjectInfo Items
312 int i_topid; // Top-Ptr ObjectInfo
314 LibGoblin_AddressInfo *p_addrinfo;
320 } LibGoblin_ProgramInfo;
323 #endif /* DRD64_HEADER_LIBGOBLIN_TYPE*/
325 /* EOF of drd64_.h ----------------------------------- */