OSDN Git Service

2019/02/23(Sat) 9:37
authorKoine Yuusuke(koinec) <koinec@users.osdn.me>
Sat, 23 Feb 2019 00:36:48 +0000 (09:36 +0900)
committerKoine Yuusuke(koinec) <koinec@users.osdn.me>
Sat, 23 Feb 2019 00:36:48 +0000 (09:36 +0900)
 (libGoblin)
  * WorkBackup

libgoblin/drd64_libgoblin_elf.c
libgoblin/drd64_libgoblin_elf_dynsym.c

index b33cc15..52f40ff 100644 (file)
@@ -170,6 +170,12 @@ int
                return i_result;
        }
 
+       /* Read DynamicSymbolTable to ObjectInfo --------------*/
+       i_result        = ELF64_DynSym_ReadSection( p_binfo );
+       if( 0x00 != i_result )  {
+               return i_result;
+       }
+
        Debug_ObjectInfo_Print_AllGroupLink( p_pginfo, 0xff );
 
        /* Create Symbol-Table ------------------*/
index 3bf6e65..40c938d 100644 (file)
@@ -37,6 +37,11 @@ Comment:
 #define        DRD64_SRC_LIBGOBLIN_ELF_DYNSYM
 #include"drd64_libgoblin.h"
 
+typedef struct {
+       Byte    *pb_verneed;
+       int             i_binfo_id;
+} DynSym_LibInfo;
+
 
 /*----------------------------------------------------------------------
 ----------------------------------------------------------------------*/
@@ -45,6 +50,69 @@ int
        ELF64_DynSym_ReadSection(
                        LibGoblin_BinaryInfo    *p_binfo )
 {
+       Byte    *pb_gnuver_r;
+       Byte    *pb_dynstr;
+       DWord   dw_cnt;
+       DWord   dw_symbols;
+       Elf64_Shdr      *p_shdr;
+       Elf64_Verneed   *p_verneed;
+       LibGoblin_SectionInfo   *psec_gnuver_r;
+       LibGoblin_SectionInfo   *psec_dynsym;
+       LibGoblin_SectionInfo   *psec_dynstr;
+
+
+       // Check exist .dynsym section ---
+       psec_dynsym     = LibGoblin_Section_GetSectionInfo_fid(
+                                                       p_binfo, LIBGOBLIN_SECTION_ID_DYNSYM );
+       if( NULL == psec_dynsym )       {
+               return 0x00;
+       }
+       p_shdr  = (Elf64_Shdr *)(psec_dynsym->pb_sechdr);
+       assert( NULL != p_shdr );
+
+       dw_symbols      = (DWord)p_shdr->sh_size / (DWord)p_shdr->sh_entsize;
+       
+       psec_dynstr     = LibGoblin_Section_GetSectionInfo_fid(
+                                                       p_binfo, LIBGOBLIN_SECTION_ID_DYNSTR );
+       if( NULL == psec_dynstr )       {
+               return 0x00;
+       }
+       pb_dynstr       = psec_dynstr->pb_data;
+
+       // Read .gnu.version_r for Temp-Data
+       //   Read Pass1 - Check max vna_other value.
+       psec_gnuver_r   = LibGoblin_Section_GetSectionInfo_fid(
+                                                       p_binfo, LIBGOBLIN_SECTION_ID_GNU_VERSION_R );
+       if( NULL == psec_gnuver_r )
+               { goto  goto_ELF64_DynSym_ReadSection_phase2; }
+       pb_gnuver_r     = psec_gnuver_r->pb_data;
+
+       p_verneed       = (Elf64_Verneed *)pb_gnuver_r;
+       
+       printf("  [Verneed] vn_version= %d, vn_cnt= %d, vn_file= %s\n",
+                               p_verneed->vn_version, p_verneed->vn_cnt, (pb_dynstr + p_verneed->vn_file) );
+       printf("  [Verneed] vn_aux= %d, vn_next= %d\n\n",
+                               p_verneed->vn_aux, p_verneed->vn_next );
+
+       p_verneed       = (Elf64_Verneed *)(pb_gnuver_r + p_verneed->vn_next);
+       printf("  [Verneed] vn_version= %d, vn_cnt= %d, vn_file= %s\n",
+                               p_verneed->vn_version, p_verneed->vn_cnt, (pb_dynstr + p_verneed->vn_file) );
+       printf("  [Verneed] vn_aux= %d, vn_next= %d\n\n",
+                               p_verneed->vn_aux, p_verneed->vn_next );
+
+
+/*
+       for( dw_cnt = 0; dw_cnt < dw_symbols; dw_cnt++ )        {
+
+       }
+*/
+       
+       //   Read Pass2 - Read Data for Temp-Data
+
+       // Read .dymsym & .gnu.version for ObjectInfo
+
+goto_ELF64_DynSym_ReadSection_phase2:
+
 /*
        Byte            *pb_symtab;
        Byte            *pb_strtab;