static char gstr_type[256][9] = {
"NULL",
+ "PROGRAM",
"MASTER",
"PROGHDR",
"SECTION",
"COMMON",
"TLS",
"REL",
- "", "", "", "", "", "", "",
+ "", "", "", "", "", "",
"", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "",
return;
}
-
+/*--------------------------------------------------------------------*/
+void
+ Debug_ObjectInfo_Print_ProgramFile(
+ LibGoblin_ObjectInfo *p_obj,
+ char *pstr_space,
+ Byte b_level )
+{
+ printf(" %s\t\t[OBJINFO] Addr.Link(%3d <-> %3d)\n",
+ pstr_space, p_obj->addrlink.i_prev_id, p_obj->addrlink.i_next_id );
+
+ printf(" %s\t\t[PROGRAM] BinaryInfo ID= %d\n",
+ pstr_space, p_obj->info.program.i_binfo_id );
+
+ return;
+}
+
+
/*====================================================================*/
/*--------------------------------------------------------------------*/
void
else { strcat( pstr_space, " " ); }
switch( p_obj->b_type ) {
+ case OBJINFO_TYPE_PROGRAM:
+ Debug_ObjectInfo_Print_ProgramFile( p_obj, pstr_space, b_level );
+ break;
+
case OBJINFO_TYPE_PROGHDR:
Debug_ObjectInfo_Print_ProgramHeader( p_obj, pstr_space, b_level );
break;
return i_result;
}
- //Debug_ObjectInfo_Print_AllGroupLink( p_pginfo, 0xff );
+ Debug_ObjectInfo_Print_AllGroupLink( p_pginfo, 0xff );
/* Analyze Dwarf-Debug Info. */
int i_phdrnum;
int i_phdrsize;
Byte *pb_data;
+ PtrValue ptr_start;
+ PtrValue ptr_end;
Elf64_Ehdr *p_elfhdr;
Elf64_Phdr *p_proghdr;
LibGoblin_BinaryFile *p_bfile;
p_bfile = BinaryFile_GetBinaryFile( p_binfo->i_binfile );
pb_data = p_bfile->pb_binary;
assert( NULL != pb_data );
-
+
p_elfhdr = (Elf64_Ehdr *)pb_data;
- p_proghdr = (Elf64_Phdr *)(pb_data + p_elfhdr->e_phoff);
i_phdrnum = p_elfhdr->e_phnum;
i_phdrsize = p_elfhdr->e_phentsize;
+
+ // Regist Program ObjectInfo *************************
+ p_proghdr = (Elf64_Phdr *)(pb_data + p_elfhdr->e_phoff);
+ ptr_start = 0xffffffffffffffff;
+ ptr_end = 0x0000000000000000;
for( i_cnt = 0; i_cnt < i_phdrnum; i_cnt++ ) {
+ if( ptr_start > p_proghdr->p_vaddr )
+ { ptr_start = (PtrValue)p_proghdr->p_vaddr; }
+ if( ptr_end < (p_proghdr->p_vaddr + p_proghdr->p_memsz) )
+ { ptr_end = (p_proghdr->p_vaddr + p_proghdr->p_memsz); }
+
+ // for Next-Loop proc.
+ p_proghdr = (Elf64_Phdr *)(pb_data + p_elfhdr->e_phoff + ((i_cnt + 1) * i_phdrsize));
+ }
+
+ p_objinfo = ObjectInfo_InsetObject(
+ p_pginfo, ptr_start, (ptr_end - ptr_start), NULL, 0x00 );
+ if( NULL == p_objinfo ) {
+ return -0x01;
+ }
+
+ p_objinfo->b_type = OBJINFO_TYPE_PROGRAM;
+ p_objinfo->pstr_name = p_binfo->str_filename;
+ p_objinfo->info.program.i_binfo_id = p_binfo->i_id;
+
+ // Regist ProgramHeader to ObjectInfo *****************
+ p_proghdr = (Elf64_Phdr *)(pb_data + p_elfhdr->e_phoff);
+
+ for( i_cnt = 0; i_cnt < i_phdrnum; i_cnt++ ) {
+
// Inset ObjectInfo ---
// p_vaddr - Virtual address in memory image.
// p_memsz - Size of contents in memory.
p_objinfo = ObjectInfo_InsetObject(
- p_pginfo, p_proghdr->p_vaddr, p_proghdr->p_memsz, NULL, 0x00 );
+ p_pginfo, p_proghdr->p_vaddr, p_proghdr->p_memsz, NULL, 0x01 );
if( NULL == p_objinfo ) {
- return -0x01;
+ return -0x02;
}
// Set ProgramHdr Value to ObjectInfo ---
#define OBJINFO_STATUS_REL 0x00000100
#define OBJINFO_TYPE_NULL 0x00
-#define OBJINFO_TYPE_MASTER 0x01
-#define OBJINFO_TYPE_PROGHDR 0x02
-#define OBJINFO_TYPE_SECTION 0x03
-#define OBJINFO_TYPE_FUNCTION 0x04
-#define OBJINFO_TYPE_OBJECT 0x05
-#define OBJINFO_TYPE_COMMON 0x06
-#define OBJINFO_TYPE_TLS 0x07
-#define OBJINFO_TYPE_REL 0x08
+#define OBJINFO_TYPE_PROGRAM 0x01
+#define OBJINFO_TYPE_MASTER 0x02
+#define OBJINFO_TYPE_PROGHDR 0x03
+#define OBJINFO_TYPE_SECTION 0x04
+#define OBJINFO_TYPE_FUNCTION 0x05
+#define OBJINFO_TYPE_OBJECT 0x06
+#define OBJINFO_TYPE_COMMON 0x07
+#define OBJINFO_TYPE_TLS 0x08
+#define OBJINFO_TYPE_REL 0x09
typedef struct {
int i_id;
Byte b_data[128];
struct {
+ int i_binfo_id;
+ } program;
+
+ struct {
DWord dw_type; // Entry type.
DWord dw_flags; // Access permission flags.
QWord qw_align; // Alignment in memory and file.
int i_binfo_parent;
int i_binfo_next;
+ PtrValue ptr_loadbase;
+
/* Binary-Format Depending Info. (ELF)*/
//void *p_format;