OSDN Git Service

2019/02/11(Mon) 13:11
authorKoine Yuusuke(koinec) <koinec@users.osdn.me>
Mon, 11 Feb 2019 04:11:38 +0000 (13:11 +0900)
committerKoine Yuusuke(koinec) <koinec@users.osdn.me>
Mon, 11 Feb 2019 04:11:38 +0000 (13:11 +0900)
 (LibGoblin)
  * WorkBackup

libgoblin/drd64_libgoblin_debug_objinfo.c

index b53061d..6ccc10e 100644 (file)
@@ -81,23 +81,147 @@ static char        gstr_type[256][8]       = {
 /*====================================================================*/
 /*--------------------------------------------------------------------*/
 void
+       Debug_ObjectInfo_Print_Section(
+                       LibGoblin_ObjectInfo    *p_obj,
+                       char    *pstr_space,
+                       Byte    b_level )
+{
+       char    str_type[32];
+       char    str_flag[256];
+       DWord   qw_flag;
+
+       printf(" %s\t\t[OBJINFO] Addr.Link(%3d <-> %3d)  File{ Offset=%8p, Size=%8ld, FID=%d }\n",
+                               pstr_space, 
+                               p_obj->addrlink.i_prev_id, p_obj->addrlink.i_next_id,
+                               p_obj->file.pv_offset, p_obj->file.qw_size, p_obj->file.i_fid );
+
+
+       switch( p_obj->info.section.dw_type )   {
+               /* 0 - inactive */
+               case SHT_NULL:
+                       strncpy( str_type, "NULL", 31 );
+                       break;
+               /* 1 - program defined information */
+               case SHT_PROGBITS:
+                       strncpy( str_type, "PROGBITS", 31 );
+                       break;
+               /* 2 - symbol table section */
+               case SHT_SYMTAB:
+                       strncpy( str_type, "SYMTAB", 31 );
+                       break;
+               /* 3 - string table section */
+               case SHT_STRTAB:
+                       strncpy( str_type, "STRTAB", 31 );
+                       break;
+               /* 4 - relocation section with addends */
+               case SHT_RELA:
+                       strncpy( str_type, "RELA", 31 );
+                       break;
+               /* 5 - symbol hash table section */
+               case SHT_HASH:
+                       strncpy( str_type, "HASH", 31 );
+                       break;
+               /* 6 - dynamic section */
+               case SHT_DYNAMIC:
+                       strncpy( str_type, "DYNAMIC", 31 );
+                       break;
+               /* 7 - note section */
+               case SHT_NOTE:
+                       strncpy( str_type, "NOTE", 31 );
+                       break;
+               /* 8 - no space section */
+               case SHT_NOBITS:
+                       strncpy( str_type, "NOBITS", 31 );
+                       break;
+               /* 9 - relocation section - no addends */
+               case SHT_REL:
+                       strncpy( str_type, "REL", 31 );
+                       break;
+               /* 10 - reserved - purpose unknown */
+               case SHT_SHLIB:
+                       strncpy( str_type, "SHLIB", 31 );
+                       break;
+               /* 11 - dynamic symbol table section */
+               case SHT_DYNSYM:
+                       strncpy( str_type, "DYNSYM", 31 );
+                       break;
+               /* 14 - Initialization function pointers. */
+               case  SHT_INIT_ARRAY:
+                       strncpy( str_type, "INIT_ARRAY", 31 );
+                       break;
+               /* 15 - Termination function pointers. */
+               case SHT_FINI_ARRAY:
+                       strncpy( str_type, "FINI_ARRAY", 31 );
+                       break;
+               /* 16 - Pre-initialization function ptrs. */
+               case SHT_PREINIT_ARRAY:
+                       strncpy( str_type, "PREINIT_ARRAY", 31 );
+                       break;
+               /* 17 - Section group. */
+               case SHT_GROUP:
+                       strncpy( str_type, "GROUP", 31 );
+                       break;
+               /* 18 - Section indexes (see SHN_XINDEX). */
+               case  SHT_SYMTAB_SHNDX:
+                       strncpy( str_type, "SYMTAB_SHNDX", 31 );
+                       break;
+
+               default:
+                       snprintf( str_type, 31, "(%8x)", p_obj->info.section.dw_type );
+                       break;
+       }
+       
+       qw_flag = p_obj->info.section.qw_flag;
+       str_flag[0]     = '\0';
+       /* SHF_WRITE 0x1:       Section contains writable data. */
+       if( SHF_WRITE & qw_flag )       { strcat( str_flag, "Write " ); }
+       /* SHF_ALLOC 0x2: Section occupies memory. */
+       if( SHF_ALLOC & qw_flag )       { strcat( str_flag, "Alloc " ); }
+       /* SHF_EXECINSTR 0x4: Section contains instructions. */
+       if( SHF_EXECINSTR & qw_flag )   { strcat( str_flag, "Exec " ); }
+       /* SHF_MERGE 0x10: Section may be merged. */
+       if( SHF_MERGE & qw_flag )       { strcat( str_flag, "Merged " ); }
+       /* SHF_STRINGS 0x20: Section contains strings. */
+       if( SHF_STRINGS & qw_flag )     { strcat( str_flag, "Strings " ); }
+       /* SHF_INFO_LINK 0x40: sh_info holds section index. */
+       if( SHF_INFO_LINK & qw_flag )   { strcat( str_flag, "InfoLink " ); }
+       /* SHF_LINK_ORDER 0x80: Special ordering requirements. */
+       if( SHF_LINK_ORDER & qw_flag )  { strcat( str_flag, "LinkOrder " ); }
+       /* SHF_OS_NONCONFORMING 0x100: OS-specific processing required. */
+       if( SHF_OS_NONCONFORMING & qw_flag )    { strcat( str_flag, "OSspecific " ); }
+       /* SHF_GROUP 0x200: Member of section group. */
+       if( SHF_GROUP & qw_flag )       { strcat( str_flag, "Group " ); }
+       /* SHF_TLS 0x400: Section contains TLS data. */
+       if( SHF_TLS & qw_flag ) { strcat( str_flag, "TLS " ); }
+       /* SHF_COMPRESSED 0x800: Section contains compressed data. */
+       if( SHF_COMPRESSED & qw_flag )  { strcat( str_flag, "Compressed " ); }
+
+       printf(" %s\t\t[SECTION] Type: %s, Align= %ld, Flag[ %s]\n",
+                               pstr_space, str_type, p_obj->info.section.qw_align, str_flag );
+       printf(" %s\t\t[SECTION] EntSize= %ld, Link(Related Section)= %d, Info(Depends Section Type)= %xh\n",
+                               pstr_space, p_obj->info.section.qw_entsize,
+                               p_obj->info.section.dw_link, p_obj->info.section.dw_info );
+
+       printf(" %s\n", pstr_space );
+
+       return;
+}
+
+/*--------------------------------------------------------------------*/
+void
        Debug_ObjectInfo_Print_ProgramHeader(
                        LibGoblin_ObjectInfo    *p_obj,
                        char    *pstr_space,
                        Byte    b_level )
 {
-       //char  str_group[4];
        char    str_type[32];
        char    str_flag[8];
        DWord   dw_flag;
-/*
-       str_group[0] = ' ';
-       str_group[1] = ' ';
-       str_group[2] = ' ';
-       str_group[3] = '\0';
-       if( NO_OBJINFO != p_obj->grplink.i_child_topid )
-               { str_group[1] = '|'; }
-*/             
+
+       printf(" %s\t\t[OBJINFO] Addr.Link(%3d <-> %3d)  File{ Offset=%8p, Size=%8ld, FID=%d }\n",
+                               pstr_space, 
+                               p_obj->addrlink.i_prev_id, p_obj->addrlink.i_next_id,
+                               p_obj->file.pv_offset, p_obj->file.qw_size, p_obj->file.i_fid );
 
        switch( p_obj->info.proghdr.dw_type )   {
                case PT_NULL:
@@ -137,7 +261,7 @@ void
                                        ((PF_MASKOS & dw_flag) ? 'O': ' '),
                                        ((PF_MASKPROC & dw_flag) ? 'P': ' ') );
 
-       printf(" %s\t\t[%5s] Type: %s, align= %d\n",
+       printf(" %s\t\t[PROGHDR] Flag[%5s] Type: %s, align= %d\n",
                                pstr_space, str_flag, str_type, p_obj->info.proghdr.qw_align );
        printf(" %s\n", pstr_space );
 
@@ -188,6 +312,7 @@ void
                        break;
 
                case OBJINFO_TYPE_SECTION:
+                       Debug_ObjectInfo_Print_Section( p_obj, pstr_space, b_level );
                        break;
 
                default: