OSDN Git Service

2018/11/02(Fri) 21:34
authorKoine Yuusuke(koinec) <koinec@users.osdn.me>
Fri, 2 Nov 2018 12:33:28 +0000 (21:33 +0900)
committerKoine Yuusuke(koinec) <koinec@users.osdn.me>
Fri, 2 Nov 2018 12:33:28 +0000 (21:33 +0900)
  * merget reconstruct_AddressInfo_phase1 branch
Squashed commit of the following:

commit d66577480fbb0302daaf27d2fb92706e90bb6fb4
Author: Koine Yuusuke(koinec) <koinec@users.osdn.me>
Date:   Fri Nov 2 21:32:08 2018 +0900

    2018/11/2(Fri) 21:32
      * WorkBackup

commit e951b65198c4e4483d1f9542aaaf91a79db0e523
Author: Koine Yuusuke(koinec) <koinec@users.osdn.me>
Date:   Fri Oct 19 21:08:55 2018 +0900

    2018/10/19(Fri) 21:09
      * WorkBackup

24 files changed:
libgoblin/Makefile
libgoblin/drd64_libgoblin.h
libgoblin/drd64_libgoblin_addrinfo.c
libgoblin/drd64_libgoblin_addrinfo.h
libgoblin/drd64_libgoblin_api.c
libgoblin/drd64_libgoblin_binfo.c
libgoblin/drd64_libgoblin_binfo.h
libgoblin/drd64_libgoblin_checkbin.c
libgoblin/drd64_libgoblin_debug_addrinfo.c
libgoblin/drd64_libgoblin_debug_elf.c
libgoblin/drd64_libgoblin_elf.c
libgoblin/drd64_libgoblin_elf64.c
libgoblin/drd64_libgoblin_elf64.h
libgoblin/drd64_libgoblin_elf_dynver.c
libgoblin/drd64_libgoblin_elf_symtab.c [new file with mode: 0644]
libgoblin/drd64_libgoblin_elf_symtab.h [new file with mode: 0644]
libgoblin/drd64_libgoblin_loadprog.c
libgoblin/drd64_libgoblin_proginfo.c
libgoblin/drd64_libgoblin_readbin.c
libgoblin/drd64_libgoblin_section.c
libgoblin/drd64_libgoblin_section.h
libgoblin/drd64_libgoblin_type.h
libgoblin/test_libgoblin_binfo.c
libgoblin/test_libgoblin_readbin.c

index ef07dca..7fb166f 100644 (file)
@@ -56,10 +56,10 @@ OBJS = drd64_libgoblin_api.o \
                drd64_libgoblin_loadprog.o \
                drd64_libgoblin_symwork.o \
                drd64_libgoblin_objinfo.o \
-               drd64_libgoblin_addrinfo.o \
                drd64_libgoblin_section.o \
                drd64_libgoblin_elf.o \
                drd64_libgoblin_elf_dynver.o \
+               drd64_libgoblin_elf_symtab.o \
                drd64_libgoblin_elf64.o \
                drd64_libgoblin_elf32.o \
                drd64_libgoblin_dwarf.o \
@@ -68,8 +68,7 @@ OBJS = drd64_libgoblin_api.o \
                drd64_libgoblin_dwarf_line.o \
                drd64_libgoblin_dwarf_common.o \
                drd64_libgoblin_debug_elf.o \
-               drd64_libgoblin_debug_symwork.o \
-               drd64_libgoblin_debug_addrinfo.o
+               drd64_libgoblin_debug_symwork.o
 HEADER = drd64_libgoblin.h \
                drd64_libgoblin_section_defs.h \
                drd64_libgoblin_type.h \
@@ -81,10 +80,10 @@ HEADER = drd64_libgoblin.h \
                drd64_libgoblin_loadprog.h \
                drd64_libgoblin_symwork.h \
                drd64_libgoblin_objinfo.h \
-               drd64_libgoblin_addrinfo.h \
                drd64_libgoblin_section.h \
                drd64_libgoblin_elf.h \
                drd64_libgoblin_elf_dynver.h \
+               drd64_libgoblin_elf_symtab.h \
                drd64_libgoblin_elf64.h \
                drd64_libgoblin_elf32.h \
                drd64_libgoblin_dwarf.h \
@@ -95,7 +94,7 @@ HEADER = drd64_libgoblin.h \
                drd64_libgoblin_dwarf_str.h \
                drd64_libgoblin_debug_elf.h \
                drd64_libgoblin_debug_symwork.h \
-               drd64_libgoblin_debug_addrinfo.h \
+               drd64_libgoblin_addrinfo.h \
                $(USER_HEADER) $(SUPER_HEADER) $(LIB_HEADER) 
 LIBRARY = ../libfiletype.a
 
@@ -153,9 +152,6 @@ drd64_libgoblin_symwork.o: drd64_libgoblin_symwork.c $(HEADER)
 drd64_libgoblin_objinfo.o: drd64_libgoblin_objinfo.c $(HEADER)
        $(CC) -c -o drd64_libgoblin_objinfo.o $(FLAGS_DEBUG) \
                                drd64_libgoblin_objinfo.c
-drd64_libgoblin_addrinfo.o: drd64_libgoblin_addrinfo.c $(HEADER)
-       $(CC) -c -o drd64_libgoblin_addrinfo.o $(FLAGS_DEBUG) \
-                               drd64_libgoblin_addrinfo.c
 drd64_libgoblin_section.o: drd64_libgoblin_section.c $(HEADER)
        $(CC) -c -o drd64_libgoblin_section.o $(FLAGS_DEBUG) \
                                drd64_libgoblin_section.c
@@ -166,6 +162,9 @@ drd64_libgoblin_elf.o: drd64_libgoblin_elf.c $(HEADER)
 drd64_libgoblin_elf_dynver.o: drd64_libgoblin_elf_dynver.c $(HEADER)
        $(CC) -c -o drd64_libgoblin_elf_dynver.o $(FLAGS_DEBUG) \
                                drd64_libgoblin_elf_dynver.c
+drd64_libgoblin_elf_symtab.o: drd64_libgoblin_elf_symtab.c $(HEADER)
+       $(CC) -c -o drd64_libgoblin_elf_symtab.o $(FLAGS_DEBUG) \
+                               drd64_libgoblin_elf_symtab.c
 drd64_libgoblin_elf64.o: drd64_libgoblin_elf64.c $(HEADER)
        $(CC) -c -o drd64_libgoblin_elf64.o $(FLAGS_DEBUG) \
                                drd64_libgoblin_elf64.c
@@ -197,9 +196,6 @@ drd64_libgoblin_debug_elf.o: drd64_libgoblin_debug_elf.c $(HEADER)
 drd64_libgoblin_debug_symwork.o: drd64_libgoblin_debug_symwork.c $(HEADER)
        $(CC) -c -o drd64_libgoblin_debug_symwork.o $(FLAGS_DEBUG) \
                                drd64_libgoblin_debug_symwork.c
-drd64_libgoblin_debug_addrinfo.o: drd64_libgoblin_debug_addrinfo.c $(HEADER)
-       $(CC) -c -o drd64_libgoblin_debug_addrinfo.o $(FLAGS_DEBUG) \
-                               drd64_libgoblin_debug_addrinfo.c
 
 #$(TEST_TARGET): elftest.c ../include/libgoblin.h $(TARGET)
 #      $(CC) -g -o $(TEST_TARGET) elftest.c $(TARGET)
index 09b1ac7..e15b6bc 100644 (file)
@@ -79,9 +79,9 @@ Comment:
 #include"drd64_libgoblin_symwork.h"
 #include"drd64_libgoblin_section.h"
 #include"drd64_libgoblin_objinfo.h"
-#include"drd64_libgoblin_addrinfo.h"
 #include"drd64_libgoblin_elf.h"
 #include"drd64_libgoblin_elf_dynver.h"
+#include"drd64_libgoblin_elf_symtab.h"
 #include"drd64_libgoblin_elf64.h"
 #include"drd64_libgoblin_elf32.h"
 #include"drd64_libgoblin_dwarf_common.h"
index 0f7e170..365fedd 100644 (file)
@@ -40,210 +40,14 @@ Comment:
 
 /*----------------------------------------------------------------------
 ----------------------------------------------------------------------*/
-int
-       AddrInfo_Set_Symtab(
-                       LibGoblin_BinaryInfo    *p_binfo,
-                       LibGoblin_AddressInfo   *p_addr,
-                       LibGoblin_SymbolWorkInfo        *p_syminfo )
-{
-       
-       Byte            *pb_strtab;
-       Elf32_Sym       *p_sym32;
-       Elf64_Sym       *p_sym64;
-       LibGoblin_SectionInfo   *p_secinfo;
-
-       assert( NULL != p_binfo );
-       assert( NULL != p_addr );
-       assert( NULL != p_syminfo );
-
-       p_secinfo       = LibGoblin_Section_GetSectionInfo( p_binfo, LIBGOBLIN_SECTION_ID_STRTAB );
-       if( NULL == p_secinfo )         {
-               return -0x01;
-       }
-       pb_strtab       = p_secinfo->pb_data;
-       assert( NULL != pb_strtab );
-
-       if( isElf64( p_binfo ) )        {
-               p_sym64 = (Elf64_Sym *)p_syminfo->pb_symbol;
-
-               p_addr->ptr_address     = p_syminfo->ptr_address;
-               p_addr->dw_size         = (DWord)p_sym64->st_size;
-               // p_addr->dw_srcid     is update when reading DWARF data.
-               // p_addr->dw_next is update when finalizing ELF/DWARF reading phase.
-               p_addr->b_elf_flags     = p_sym64->st_info;
-               p_addr->w_secid         = LibGoblin_Section_GetSectionID_fromSectionNumber_inElf(
-                                                               p_binfo, p_sym64->st_shndx );
-               if( STT_SECTION == (p_addr->b_elf_flags & 0x0f) )
-                       { p_addr->pstr_name     = LibGoblin_Section_GetSectionName( p_binfo, p_addr->w_secid ); }
-               else
-                       { p_addr->pstr_name     = (char *)(pb_strtab + p_sym64->st_name); }
-       }
-       else if( isElf32( p_binfo ) )   {
-               p_sym32 = (Elf32_Sym *)p_syminfo->pb_symbol;
-
-               p_addr->ptr_address     = p_syminfo->ptr_address;
-               p_addr->dw_size         = (DWord)p_sym32->st_size;
-               // p_addr->dw_srcid     is update when reading DWARF data.
-               // p_addr->dw_next is update when finalizing ELF/DWARF reading phase.
-               p_addr->b_elf_flags     = p_sym32->st_info;
-               p_addr->w_secid         = LibGoblin_Section_GetSectionID_fromSectionNumber_inElf(
-                                                               p_binfo, p_sym32->st_shndx );
-               if( STT_SECTION == (p_addr->b_elf_flags & 0x0f) )
-                       { p_addr->pstr_name     = LibGoblin_Section_GetSectionName( p_binfo, p_addr->w_secid ); }
-               else
-                       { p_addr->pstr_name     = (char *)(pb_strtab + p_sym32->st_name); }
-       }
-       else    { return -0x02; }
-
-       p_syminfo->dw_type              = LIBGOBLIN_SYMWORKINFO_TYPE_ADDRTBL;
-       p_syminfo->pb_symbol    = (Byte *)p_addr;
-       
-       return 0x00;
-}
 
 
 /*----------------------------------------------------------------------
 ----------------------------------------------------------------------*/
-int
-       AddrInfo_Move_AddrInfo(
-                       LibGoblin_BinaryInfo    *p_binfo,
-                       LibGoblin_AddressInfo   *p_addr,
-                       LibGoblin_SymbolWorkInfo        *p_syminfo )
-{
-       LibGoblin_AddressInfo   *p_srcaddr;
-
-       assert( NULL != p_binfo );
-       assert( NULL != p_addr );
-       assert( NULL != p_syminfo );
-
-       p_srcaddr       = (LibGoblin_AddressInfo *)p_syminfo->pb_symbol;
-       assert( NULL != p_srcaddr );
-
-       if( p_addr == p_srcaddr )       { return 0x00; }
-
-       memcpy( p_addr, p_srcaddr, sizeof( LibGoblin_AddressInfo ) );
-
-       p_syminfo->pb_symbol    = (Byte *)p_addr;
-
-       memset( p_srcaddr, 0x00, sizeof( LibGoblin_AddressInfo ) );
-
-       return 0x00;
-}
 
 
 /*----------------------------------------------------------------------
 ----------------------------------------------------------------------*/
-LIBGOBLIN_ADDRINFO_EXTERN
-int
-       AddrInfo_SyncSymbolWorkTable(
-               LibGoblin_BinaryInfo            *p_binfo, 
-               LibGoblin_SymbolWorkTable       *p_symworktbl )
-{
-       int             i_result;
-       DWord   dw_cnt;
-       DWord   dw_reallocs;
-       LibGoblin_AddressInfo           *p_addr;
-       LibGoblin_SymbolWorkInfo        *p_syminfo;
-
-       assert( NULL != p_binfo );
-       assert( NULL != p_symworktbl );
-
-       if( 0 == p_symworktbl->dw_max_symwork )         {
-               return -0x01;
-       }
-
-       // Check & Expand AddrInfo Table Items ---
-       if( p_symworktbl->dw_max_symwork > p_binfo->dw_alloc_addrinfo ) {
-               dw_reallocs     = LIBGOBLIN_CalcAddrInfoAllocs( p_symworktbl->dw_max_symwork );
-               assert( dw_reallocs > p_binfo->dw_alloc_addrinfo );
-
-               p_addr  = (LibGoblin_AddressInfo *)realloc( p_binfo->p_addrinfo, dw_reallocs );
-               if( NULL != p_addr )    {
-                       return -0x02;
-               }
-               memset( (p_addr + p_binfo->dw_alloc_addrinfo), 0x00,
-                               ((dw_reallocs - p_binfo->dw_alloc_addrinfo) * sizeof(LibGoblin_AddressInfo) ));
-
-               p_binfo->p_addrinfo                     = p_addr;
-               p_binfo->dw_alloc_addrinfo      = dw_reallocs;
-       }
-
-       p_addr          = p_binfo->p_addrinfo + (p_symworktbl->dw_max_symwork - 1);
-       p_syminfo       = p_symworktbl->p_symwork + (p_symworktbl->dw_max_symwork - 1);
-       for( dw_cnt = p_symworktbl->dw_max_symwork; dw_cnt > 0; dw_cnt--, p_syminfo--, p_addr-- )       {
-               if( LIBGOBLIN_SYMWORKINFO_TYPE_SYMTAB == GET_SYMWORKINFO_TYPE(p_syminfo->dw_type) )     {
-                       i_result        = AddrInfo_Set_Symtab( p_binfo, p_addr, p_syminfo );
-               }
-               else if( LIBGOBLIN_SYMWORKINFO_TYPE_DWARF
-                                               == GET_SYMWORKINFO_TYPE(p_syminfo->dw_type) )   {
-
-               }
-               else if( LIBGOBLIN_SYMWORKINFO_TYPE_ADDRTBL
-                                               == GET_SYMWORKINFO_TYPE(p_syminfo->dw_type) )   {
-                       i_result        = AddrInfo_Move_AddrInfo( p_binfo, p_addr, p_syminfo );
-               }
-       }
-
-       p_binfo->dw_max_addrinfo        = p_symworktbl->dw_max_symwork;
-
-       return 0x00;
-}
-
-
-/*----------------------------------------------------------------------
-----------------------------------------------------------------------*/
-LIBGOBLIN_ADDRINFO_EXTERN
-int
-       AddrInfo_AllocAddrInfo(
-                       LibGoblin_BinaryInfo    *p_binfo,
-                       DWord   dw_initsymbols )
-{
-       DWord   dw_allocs;
-       LibGoblin_AddressInfo   *p_addr;
-
-       assert( NULL != p_binfo );
-
-       if( NULL != p_binfo->p_addrinfo )       {
-               return 0x01;
-       }
-       
-       dw_allocs       = LIBGOBLIN_CalcAddrInfoAllocs( dw_initsymbols );
-       p_addr  = (LibGoblin_AddressInfo *)malloc(
-                                                               dw_allocs * sizeof( LibGoblin_AddressInfo ) );
-       if( NULL == p_addr )    {
-               return -0x02;
-       }
-       memset( p_addr, 0x00, dw_allocs * sizeof( LibGoblin_AddressInfo ) );
-       
-       p_binfo->p_addrinfo                     = p_addr;
-       p_binfo->dw_alloc_addrinfo      = dw_allocs;
-       p_binfo->dw_max_addrinfo        = 0;
-
-       return 0x00;
-}
-
-
-/*----------------------------------------------------------------------
-----------------------------------------------------------------------*/
-LIBGOBLIN_ADDRINFO_EXTERN
-int
-       AddrInfo_FreeAddrInfo(
-                       LibGoblin_BinaryInfo    *p_binfo )
-{
-       assert( NULL != p_binfo );
-
-       if( NULL == p_binfo->p_addrinfo )       {
-               return 0x00;
-       }
-
-       free( p_binfo->p_addrinfo );
-       p_binfo->p_addrinfo     = NULL;
-
-       p_binfo->dw_alloc_addrinfo      = 0;
-       p_binfo->dw_max_addrinfo        = 0;
-
-       return 0x00;
-}
 
 
 /* EOF of drd64_.c ----------------------------------- */
index f1fd63e..78ba648 100644 (file)
@@ -49,17 +49,6 @@ Comment:
        #define LIBGOBLIN_ADDRINFO_INTERNALFUNC
 #endif
 
-#define        LIBGOBLIN_ADDRINFO_ALLOC_UNITS  256
-
-#define        LIBGOBLIN_CalcAddrInfoAllocs(m) ((((m) / LIBGOBLIN_ADDRINFO_ALLOC_UNITS) + 2) * LIBGOBLIN_ADDRINFO_ALLOC_UNITS)
-
-LIBGOBLIN_ADDRINFO_EXTERN
-       int AddrInfo_SyncSymbolWorkTable(
-                               LibGoblin_BinaryInfo *p_binfo, LibGoblin_SymbolWorkTable *p_symworktbl );
-LIBGOBLIN_ADDRINFO_EXTERN
-       int AddrInfo_AllocAddrInfo( LibGoblin_BinaryInfo *p_binfo, DWord dw_initsymbols );
-LIBGOBLIN_ADDRINFO_EXTERN
-       int AddrInfo_FreeAddrInfo( LibGoblin_BinaryInfo *p_binfo );
 
 
 #endif /* DRD64_HEADER_XXX */
index 8f39503..f73f8ba 100644 (file)
@@ -89,7 +89,7 @@ int
        while( NULL != p_binfo )        {
                if( LIBGOBLIN_BINFO_PHASE_SETPROG > p_binfo->b_phase )
                        { break; }
-               p_binfo = (LibGoblin_BinaryInfo *)p_binfo->pv_binfo_next;
+               p_binfo = BinaryInfo_GetBinInfo( p_binfo->i_binfo_next );
        }
 
        i_result        = 0x00;
@@ -102,7 +102,7 @@ int
 
                if( -1 < p_binfo->i_parent_bid )        {
                        p_binfo_parent  = BinaryInfo_GetBinInfo( p_binfo->i_parent_bid );
-                       p_bfile = p_binfo_parent->p_binfile;
+                       p_bfile = BinaryFile_GetBinaryFile( p_binfo_parent->i_binfile );
                        if( NULL != p_bfile )
                                { strncpy( p_objpath->str_rpath, p_bfile->str_rpath, DRD64_MAX_PATH ); }
                }
index 8a77757..b95d4e9 100644 (file)
@@ -64,7 +64,7 @@ const char *
        LibGoblin_BinaryFile    *p_binfile;
 
        assert( NULL != p_binfo );
-       p_binfile       = p_binfo->p_binfile;
+       p_binfile       = BinaryFile_GetBinaryFile( p_binfo->i_binfile );
        assert( NULL != p_binfile );
 
        if( NULL != pstr_rpath )        {
@@ -111,12 +111,15 @@ void
 
        memset( p_binfo, 0x00, sizeof( LibGoblin_BinaryInfo ) );
 
-       //XXX
-       p_binfo->i_id   = -0x01;
-
+/*
        if( NULL != p_binfo->p_binfile )        {
                p_binfo->p_binfile->i_fd        = -0x01;
        }
+*/
+
+       p_binfo->i_id                   = -0x01;
+       p_binfo->i_binfo_next   = -0x01;
+       p_binfo->i_binfile              = -0x01;
 
        return;
 }
@@ -134,6 +137,7 @@ int
 
        assert( NULL != p_binfo_now );
 
+       // Search Parent BinaryInfo ---
        p_binfo_top     = p_binfo_now;
        while( -1 < p_binfo_top->i_parent_bid )
                { p_binfo_top   = BINFO( p_binfo_top->i_parent_bid ); }
@@ -141,15 +145,16 @@ int
        if( p_binfo_now == p_binfo_top )
                { return 0x00; }
 
+       // Search & Get ChainEnd BinaryInfo ---
        p_binfo_end     = p_binfo_top;
-       while( ( NULL != p_binfo_end->pv_binfo_next )
+       while( ( -1 != p_binfo_end->i_binfo_next )
                                && ( p_binfo_end !=  p_binfo_now ) )    {
-               p_binfo_end     = (LibGoblin_BinaryInfo *)p_binfo_end->pv_binfo_next;
+               p_binfo_end     = BINFO( p_binfo_end->i_binfo_next);
        }
 
        assert( NULL != p_binfo_end );
 
-       p_binfo_end->pv_binfo_next      = (void *)p_binfo_now;
+       p_binfo_end->i_binfo_next       = BINFOID(p_binfo_now);
 
        return 0x00;
 }
@@ -165,25 +170,29 @@ int
        LibGoblin_BinaryInfo    *p_binfo_top;
        LibGoblin_BinaryInfo    *p_binfo_now;
        LibGoblin_BinaryInfo    *p_binfo_before;
+       LibGoblin_BinaryInfo    *p_binfo_next;
 
        assert( NULL != p_binfo_del );
 
+       // Search Parent BinaryInfo ---
        p_binfo_top     = p_binfo_del;
        while( -1 < p_binfo_top->i_parent_bid )
                { p_binfo_top   = BINFO( p_binfo_top->i_parent_bid ); }
 
+       // Search & Get ChainEnd & ChainEnd-1 BinaryInfo ---
        p_binfo_before  = NULL;
        p_binfo_now             = p_binfo_top;
        while( p_binfo_now !=  p_binfo_del )    {
                assert( NULL != p_binfo_now );
                p_binfo_before  = p_binfo_now;
-               p_binfo_now             = (LibGoblin_BinaryInfo *)p_binfo_now->pv_binfo_next;
+               p_binfo_now             = BINFO(p_binfo_now->i_binfo_next);
        }
 
        if( NULL != p_binfo_before )    {
-               p_binfo_before->pv_binfo_next   = (LibGoblin_BinaryInfo *)p_binfo_now->pv_binfo_next;
+               p_binfo_next    = BINFO(p_binfo_now->i_binfo_next);
+               p_binfo_before->i_binfo_next    = BINFOID(p_binfo_next);
        }
-       p_binfo_del->pv_binfo_next              = NULL;
+       p_binfo_del->i_binfo_next               = -1;
 
        return 0x00;
 }
@@ -208,7 +217,7 @@ int
                return -0x01;
        }
 
-       p_binfile       = p_binfo->p_binfile;
+       p_binfile       = BinaryFile_GetBinaryFile( p_binfo->i_binfile );
        assert( NULL != p_binfile );
 
        memset( str_src, 0x00, MAXPATHLEN );
@@ -296,7 +305,7 @@ int
                return -0x06;
        }
 
-       p_binfo->p_binfile      = p_bfile;
+       p_binfo->i_binfile      = p_bfile->i_id;
        p_binfo->b_phase        = LIBGOBLIN_BINFO_PHASE_SETPROG;
 
        return 0x00;
@@ -369,7 +378,6 @@ LibGoblin_BinaryInfo *
        p_binfo_now->i_parent_bid       = i_parent_bid;
        strncpy( p_binfo_now->str_filename, pstr_filename, DRD64_MAX_PATH );
        p_binfo_now->b_phase    = LIBGOBLIN_BINFO_PHASE_SETNAME;
-       p_binfo_now->pv_binfo_next      = NULL;
 
        BinInfo_AppendChain( p_binfo_now );
 
@@ -386,22 +394,21 @@ int
 {
        int             i_binfoid;      
        int             i_result;
+       LibGoblin_BinaryFile    *p_binfile;
 
        if( NULL == p_binfo )   { return 0x01; }
 
-       i_result        = AddrInfo_FreeAddrInfo( p_binfo );
-       if( 0x00 != i_result )  {
-               return -0x02;
-       }
+       if( -0x01 != p_binfo->i_binfile )       {
+               p_binfile       = BinaryFile_GetBinaryFile( p_binfo->i_binfile );
+               assert( NULL != p_binfile );
 
-       if( NULL != p_binfo->p_binfile )        {
-               if( NULL == p_binfo->p_binfile->p_elf ) {
-                       free( p_binfo->p_binfile->p_elf );
-                       p_binfo->p_binfile->p_elf       = NULL;
+               if( NULL == p_binfile->p_elf )  {
+                       free( p_binfile->p_elf );
+                       p_binfile->p_elf        = NULL;
                }
 
-               BinaryFile_FreeBinaryFile( p_binfo->p_binfile );
-               p_binfo->p_binfile      = NULL;
+               BinaryFile_FreeBinaryFile( p_binfile );
+               p_binfo->i_binfile      = -0x01;
        }
 
        BinInfo_DeleteChain( p_binfo );
index 8eb25b1..1b149fb 100644 (file)
@@ -62,6 +62,7 @@ int                                           gi_now_binary_info              = 0;
 #endif
 
 #define        BINFO(n)        ((LibGoblin_BinaryInfo *)(gp_binary_info + (n)))
+#define        BINFOID(n)      ((n)->i_id)
 
 LIBGOBLIN_BINFO_EXTERN
        LibGoblin_BinaryInfo *BinaryInfo_GetBinInfo( int i_bid );
index a66ded5..a4cb05e 100644 (file)
@@ -44,9 +44,11 @@ int
                        LibGoblin_BinaryInfo    *p_binfo )
 {
        Byte    *pb_data;
+       LibGoblin_BinaryFile    *p_binfile;
 
        assert( NULL != p_binfo );
-       pb_data = p_binfo->p_binfile->pb_binary;
+       p_binfile       = BinaryFile_GetBinaryFile( p_binfo->i_binfile );
+       pb_data = p_binfile->pb_binary;
        assert( NULL != pb_data );
 
        /* Analyze ELF Ident Header from Bits ---*/
index 1a054e7..aa5c68b 100644 (file)
@@ -50,8 +50,10 @@ int
        Word                                    w_type;
        DWord                                   dw_cnt;
        LibGoblin_AddressInfo   *p_addr;
+       LibGoblin_ProgramInfo   *p_pginfo;
 
        assert( NULL != p_binfo );
+       p_pginfo        = (LibGoblin_ProgramInfo *)p_binfo->pv_pginfo;
 
        if( 0x00 < b_level )
                { puts("[DEBUG] Address Info. Table -------------------------------------------"); }
@@ -102,7 +104,7 @@ int
                        else if( SHN_UNDEF  == p_addr->w_secid )        { printf("(UNDEF)"); }
                        else if( LIBGOBLIN_SECTION_ID_MAX > p_addr->w_secid )   {
                                printf("(%s)",
-                                       LibGoblin_Section_GetSectionName( p_binfo, p_addr->w_secid ));
+                                       LibGoblin_Section_GetSectionName( p_pginfo, p_addr->w_secid ));
                        }
                        else    { printf("(NO SHNDX)%d", p_addr->w_secid); }
                        // dw_next
index 0a292d8..6a2ddf1 100644 (file)
@@ -50,14 +50,17 @@ int
        void                                    *p_shdr;
        Ptr                                             ptr_start;
        LibGoblin_SectionInfo   *p_secinfo;
+       LibGoblin_ProgramInfo   *p_pginfo;
        Elf64_Shdr                              *p_shdr64;
        Elf32_Shdr                              *p_shdr32;
 
+       p_pginfo        = (LibGoblin_ProgramInfo *)p_binfo->pv_pginfo;
+
        if( 0x00 < b_level )
                { puts("[DEBUG] Section Table -----------------------------------------------"); }
 
        for( b_cnt = 0; b_cnt < LIBGOBLIN_SECTION_ID_MAX; b_cnt++ )             {
-               p_secinfo       = LibGoblin_Section_GetSectionInfo( p_binfo, b_cnt );
+               p_secinfo       = LibGoblin_Section_GetSectionInfo( p_pginfo, b_cnt );
                assert( NULL != p_secinfo );
                p_shdr          = (void *)p_secinfo->pb_sechdr;
 
index 636b327..98276e7 100644 (file)
@@ -72,7 +72,7 @@ Byte *
        LibGoblin_SectionInfo   *p_sectbl;
 
        assert( NULL != p_binfo );
-       p_bfile = p_binfo->p_binfile;
+       p_bfile = BinaryFile_GetBinaryFile( p_binfo->i_binfile );
 
        pb_data         = NULL;
        *qw_secsize     = 0;
@@ -80,7 +80,7 @@ Byte *
 
        if( LIBGOBLIN_SECTION_ID_DEFAULT_MAX <= b_secid )       { return NULL; }
 
-       p_sectbl        = &(p_binfo->t_section[b_secid]);
+       p_sectbl        = &(p_bfile->t_section[b_secid]);
        if( NULL != p_sectbl->pb_sechdr )       {
                pb_data         = p_sectbl->pb_data;
                *qw_secsize     = p_sectbl->qw_size;
@@ -140,29 +140,21 @@ int
        LibGoblin_SymbolWorkTable       t_symwork;
 
        assert( NULL != p_binfo );
-       p_bfile = p_binfo->p_binfile;
+       p_bfile = BinaryFile_GetBinaryFile( p_binfo->i_binfile );
        pb_data = p_bfile->pb_binary;
        assert( NULL != pb_data );
 
        /* Create Symbol-Table ------------------*/
+
        i_result        = LibGoblin_Section_ReadSymtabSection_toWorkTable(
                                                                        p_binfo, &t_symwork );
        if( 0x00 != i_result )  {
                return i_result;
        }
 
-       i_result        = AddrInfo_AllocAddrInfo( p_binfo, t_symwork.dw_max_symwork );
-       if( 0x00 != i_result )  {
-               return i_result;
-       }
 
        LibGoblin_Debug_SymWork_PrintWorkTable( &t_symwork, 0x02 );
 
-       i_result        = AddrInfo_SyncSymbolWorkTable( p_binfo, &t_symwork );
-       if( 0x00 != i_result )  {
-               return i_result;
-       }
-
 
        /* Analyze Dwarf-Debug Info. */
 /*
index c96eaa0..1cb26b2 100644 (file)
@@ -45,7 +45,6 @@ int
                LibGoblin_BinaryInfo    *p_binfo )
 {
        int                     i_cnt;
-       int                     i_globid;
        int                     i_secnum;
        int                     i_index;
        int                     i_user_section;
@@ -56,10 +55,10 @@ int
        Elf64_Shdr      *p_secstrhdr;
        LibGoblin_BinaryFile    *p_bfile;
        LibGoblin_SectionInfo   *p_sectbl;
-       LibGoblin_SectionInfo   *p_globsec;
+       LibGoblin_ProgramInfo   *p_pginfo;
 
        assert( NULL != p_binfo );
-       p_bfile = p_binfo->p_binfile;
+       p_bfile = BinaryFile_GetBinaryFile( p_binfo->i_binfile );
        pb_data = p_bfile->pb_binary;
        assert( NULL != pb_data );
 
@@ -90,9 +89,7 @@ int
                                p_sectbl->pb_data               = (Byte *)(pb_data + p_sechdr->sh_offset);
                                p_sectbl->pstr_secname  = pstr_secname;
                                p_sectbl->qw_size               = p_sechdr->sh_size;
-                               // i_fid member set the value of the Section-ID in ELF file 
-                               //   on BinaryFile struct inner SectionTable
-                               p_sectbl->i_fid                 = i_cnt;
+                               p_sectbl->i_fid                 = p_binfo->i_filetype;
                                break;
                        }
                }
@@ -104,9 +101,7 @@ int
                        p_sectbl->pb_data               = (Byte *)(pb_data + p_sechdr->sh_offset);
                        p_sectbl->pstr_secname  = pstr_secname;
                        p_sectbl->qw_size               = p_sechdr->sh_size;
-                       // i_fid member set the value of the Section-ID in ELF file 
-                       //   on BinaryFile struct inner SectionTable
-                       p_sectbl->i_fid                 = i_cnt;
+                       p_sectbl->i_fid                 = p_binfo->i_filetype;
                                
                        i_user_section++;
                }
@@ -114,43 +109,11 @@ int
        }
 
        /* Update Global SectionTable ---*/
-       for( i_cnt = 0; i_cnt < LIBGOBLIN_SECTION_ID_DEFAULT_MAX; i_cnt++ )     {
-               p_globsec       = &(p_binfo->t_section[i_cnt]);
-               p_sectbl        = &(p_bfile->t_section[i_cnt]);
-
-               if( NULL == p_globsec->pb_sechdr )      {
-                       p_globsec->pb_sechdr    = p_sectbl->pb_sechdr;
-                       p_globsec->pb_data              = p_sectbl->pb_data;
-                       p_globsec->pstr_secname = p_sectbl->pstr_secname;
-                       p_globsec->qw_size              = p_sectbl->qw_size;
-                       p_globsec->i_fid                = 0;    // XXX: i_analyzefid;
-               }
-
+       if( NULL != p_binfo->pv_pginfo )        {
+               p_pginfo        = (LibGoblin_ProgramInfo *)p_binfo->pv_pginfo;
+               Section_UpdateSectionInfo_inProgInfo( p_pginfo, p_binfo );
        }
-       
-       for( i_cnt = LIBGOBLIN_SECTION_ID_DEFAULT_MAX;
-                                               i_cnt < LIBGOBLIN_SECTION_ID_MAX; i_cnt++ )             {
-
-               p_sectbl        = &(p_bfile->t_section[i_cnt]);
-               if( NULL == p_sectbl->pb_sechdr )       { break; }
-
-               for( i_globid = LIBGOBLIN_SECTION_ID_DEFAULT_MAX;
-                                               i_globid < LIBGOBLIN_SECTION_ID_MAX; i_globid++ )               {
-                       
-                       p_globsec       = &(p_binfo->t_section[i_globid]);
-                       if( NULL == p_globsec->pb_sechdr )      { break; }
 
-                       if( !strncmp( p_globsec->pstr_secname,
-                                                               p_sectbl->pstr_secname, 20 ))   { break; }
-               }
-
-               p_globsec->pb_sechdr    = p_sectbl->pb_sechdr;
-               p_globsec->pb_data              = p_sectbl->pb_data;
-               p_globsec->pstr_secname = p_sectbl->pstr_secname;
-               p_globsec->qw_size              = p_sectbl->qw_size;
-               p_globsec->i_fid                = 0;    // XXX: i_analyzefid;
-       }
-       
        return 0x00;
 }
 
@@ -163,11 +126,13 @@ int
        LibGoblin_Elf64_Analyze(
                LibGoblin_BinaryInfo    *p_binfo )
 {
-       Byte    *pb_data;
+       //Byte  *pb_data;
+       //LibGoblin_BinaryFile  *p_binfile;
 
        assert( NULL != p_binfo );
-       pb_data = p_binfo->p_binfile->pb_binary;
-       assert( NULL != pb_data );
+       //p_binfile     = BinaryFile_GetBinaryFile( p_binfo->i_binfile );
+       //pb_data               = p_binfile->pb_binary;
+       //assert( NULL != pb_data );
 
        /* Read & Analyze Section Header */
        LibGoblin_Elf64_SetSectionInfo( p_binfo );
index fe88ce2..de88aaa 100644 (file)
@@ -45,7 +45,8 @@ Comment:
        #define LIBGOBLIN_ELF64_EXTERN  extern
 #endif
 
-
+LIBGOBLIN_ELF64_EXTERN
+       int LibGoblin_Elf64_SetSectionInfo( LibGoblin_BinaryInfo *p_binfo );
 LIBGOBLIN_ELF64_EXTERN
        int LibGoblin_Elf64_Analyze( LibGoblin_BinaryInfo *p_binfo );
 
index 5f6bac4..ba39c54 100644 (file)
@@ -60,7 +60,7 @@ int
        LibGoblin_ProgramInfo   *p_pginfo;
 
        assert( NULL != p_binfo );
-       p_bfile = p_binfo->p_binfile;
+       p_bfile         = BinaryFile_GetBinaryFile( p_binfo->i_binfile );
        p_pginfo        = (LibGoblin_ProgramInfo *)p_binfo->pv_pginfo;
 
        // Read & Check SectionInfo ---
diff --git a/libgoblin/drd64_libgoblin_elf_symtab.c b/libgoblin/drd64_libgoblin_elf_symtab.c
new file mode 100644 (file)
index 0000000..bd61e10
--- /dev/null
@@ -0,0 +1,124 @@
+/*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
+
+                         D r . D e a m o n  6 4
+                        for INTEL64(R), AMD64(R)
+       
+   Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+    this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+
+DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
+
+/* File Info -----------------------------------------------------------
+File: drd64_.c
+Function: 
+Comment: 
+----------------------------------------------------------------------*/
+
+#define        DRD64_SRC_LIBGOBLIN_ELF_SYMTAB
+#include"drd64_libgoblin.h"
+
+
+/*----------------------------------------------------------------------
+----------------------------------------------------------------------*/
+LIBGOBLIN_ELF_SYMTAB_EXTERN
+int
+       Elf_Symtab_ReadSymtabSection(
+                       LibGoblin_ProgramInfo   *p_pginfo )
+{
+/*
+       Byte            *pb_symtab;
+       int                     i_result        = 0x00;
+       DWord           dw_symbols;
+       DWord           dw_cnt;
+       Elf32_Shdr      *p_shdr32;
+       Elf64_Shdr      *p_shdr64;
+       Elf32_Sym       *p_sym32        = NULL;
+       Elf64_Sym       *p_sym64        = NULL;
+       LibGoblin_SectionInfo   *p_secinfo;
+       
+       assert( NULL != p_binfo );
+
+       // Check BinaryInfo & Get SymbolEntires
+       p_secinfo       = LibGoblin_Section_GetSectionInfo_fid(
+                                               p_binfo, LIBGOBLIN_SECTION_ID_SYMTAB );
+       if( NULL == p_secinfo ) {
+               return -0x01;
+       }
+
+       if( IsBinfoType_Elf64( p_binfo ) )      {
+               p_shdr64        = (Elf64_Shdr *)(p_secinfo->pb_sechdr);
+               if( 0 == p_shdr64->sh_entsize ) {
+                       return -0x02;
+               }
+               dw_symbols      = (DWord)p_shdr64->sh_size / (DWord)p_shdr64->sh_entsize;
+               pb_symtab       = p_secinfo->pb_data;
+       }
+       else    {
+               p_shdr32        = (Elf32_Shdr *)(p_secinfo->pb_sechdr);
+               if( 0 == p_shdr32->sh_entsize ) {
+                       return -0x02;
+               }
+               dw_symbols      = (DWord)p_shdr32->sh_size / (DWord)p_shdr32->sh_entsize;
+               pb_symtab       = p_secinfo->pb_data;
+       }
+
+       // Create & Alloc SymbolWorkTable
+    i_result   = LibGoblin_SymWork_AllocSymbolWorkTable( p_symwork, dw_symbols );
+       if( 0x00 != i_result )  {
+               return -0x03;
+       }
+
+       // Read SymbolSection to SymbolWorkTable
+       if( IsBinfoType_Elf64( p_binfo ) )      {
+               p_sym64 = (Elf64_Sym *)pb_symtab;
+
+               for( dw_cnt = 0; ((dw_cnt < dw_symbols) && (0x00 == i_result)); dw_cnt++, p_sym64++ )   {
+                       i_result        = LibGoblin_SymWork_AddSymbolWorkInfo(
+                                                               p_binfo, p_symwork, (Ptr)p_sym64->st_value, (Byte *)p_sym64,
+                                                               LIBGOBLIN_SYMWORKINFO_TYPE_SYMTAB );
+               }
+       }
+       else    {
+               p_sym32= (Elf32_Sym *)pb_symtab;
+
+               for( dw_cnt = 0; ((dw_cnt < dw_symbols) && (0x00 == i_result)); dw_cnt++, p_sym32++ )   {
+                        i_result       = LibGoblin_SymWork_AddSymbolWorkInfo(
+                                                               p_binfo, p_symwork, (Ptr)p_sym32->st_value, (Byte *)p_sym32,
+                                                               LIBGOBLIN_SYMWORKINFO_TYPE_SYMTAB );
+               }
+       }
+       if( 0x00 != i_result )  {
+               return -0x04;
+       }
+
+       // Sort WorkTable
+//     LibGoblin_SymWork_SortSymbolWorkTable( p_symwork );
+*/
+       return 0x00;
+}
+
+
+
+/* EOF of drd64_.c ----------------------------------- */
+
+
diff --git a/libgoblin/drd64_libgoblin_elf_symtab.h b/libgoblin/drd64_libgoblin_elf_symtab.h
new file mode 100644 (file)
index 0000000..d64a6ea
--- /dev/null
@@ -0,0 +1,60 @@
+/*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
+
+                         D r . D e a m o n  6 4
+                        for INTEL64(R), AMD64(R)
+       
+   Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+    this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+
+DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
+
+/* File Info -----------------------------------------------------------
+File: drd64_.h
+Function: Header 
+Comment: 
+----------------------------------------------------------------------*/
+
+#ifndef DRD64_HEADER_LIBGOBLIN_ELF_SYMTAB
+#define DRD64_HEADER_LIBGOBLIN_ELF_SYMTAB
+
+#include"drd64_libgoblin.h"
+
+#ifdef DRD64_SRC_LIBGOBLIN_ELF_SYMTAB
+       #define LIBGOBLIN_ELF_SYMTAB_EXTERN
+#else
+       #define LIBGOBLIN_ELF_SYMTAB_EXTERN     extern
+#endif
+
+
+#ifdef DRD64_SRC_LIBGOBLIN_ELF_SYMTAB
+#endif
+
+
+LIBGOBLIN_ELF_SYMTAB_EXTERN
+       int Elf_Symtab_ReadSymtabSection(
+                       LibGoblin_ProgramInfo   *p_pginfo );
+
+
+#endif /* DRD64_HEADER_LIBGOBLIN_BINFO */
+
+/* EOF of drd64_.h ----------------------------------- */
index ad2199c..9e2d4e2 100644 (file)
@@ -55,7 +55,7 @@ int
                return -0x03;
        }
 
-       p_bfile = p_binfo->p_binfile;
+       p_bfile = BinaryFile_GetBinaryFile( p_binfo->i_binfile );
        if( 0x00 == (DRD64_LIBFILETYPE_SUB_ELF & p_bfile->t_ftype.w_subtype) )  {
                return -0x04;
        }
index 74b2d18..1ecaf3b 100644 (file)
@@ -86,8 +86,13 @@ LibGoblin_BinaryInfo *
                return NULL;
        }
 
-       if( -1 == i_req_bid )
-               { p_pginfo->p_binfo[LIBGOBLIN_BINFO_FILE_EXEC]  = p_binfo; }
+       if( -1 == i_req_bid )   {
+               p_binfo->i_filetype     = LIBGOBLIN_BINFO_FILE_EXEC;
+               p_pginfo->p_binfo[LIBGOBLIN_BINFO_FILE_EXEC]    = p_binfo;
+       }
+       else    {
+               p_binfo->i_filetype     = LIBGOBLIN_BINFO_FILE_LIBRARY;
+       }
        p_pginfo->i_num_binfo++;
 
        return p_binfo;
index 0cfeb44..9c9259b 100644 (file)
@@ -55,7 +55,7 @@ int
        LibGoblin_BinaryFile    *p_bfile;
 
        assert( NULL != p_binfo );
-       p_bfile = p_binfo->p_binfile;
+       p_bfile = BinaryFile_GetBinaryFile( p_binfo->i_binfile );
        assert( NULL != p_bfile );
 
        if ( LIBGOBLIN_BINFO_PHASE_SETPROG != p_binfo->b_phase )        {
@@ -129,7 +129,7 @@ int
                return -0x01;
        }
 
-       p_bfile = p_binfo->p_binfile;
+       p_bfile = BinaryFile_GetBinaryFile( p_binfo->i_binfile );
        assert( NULL != p_bfile );
 
        memcpy( (void *)&(p_bfile->t_ftype), (void *)&t_ftype, sizeof( LibFileType_FileType ));
@@ -159,7 +159,7 @@ int
        }
 
        for( i_cnt = 0; i_cnt < LIBGOBLIN_BINFO_MAXFILES; i_cnt++ )     {
-               p_bfile = p_binfo->p_binfile;
+               p_bfile = BinaryFile_GetBinaryFile( p_binfo->i_binfile );
 
                if( -0x01 == p_bfile->i_fd )    { continue; }
 
index 654ff1a..804f155 100644 (file)
@@ -43,14 +43,14 @@ Comment:
 LIBGOBLIN_SECTION_EXTERN
 char *
        LibGoblin_Section_GetSectionName(
-                       LibGoblin_BinaryInfo    *p_binfo,
+                       LibGoblin_ProgramInfo   *p_pginfo,
                        Byte    b_secid )
 {
        LibGoblin_SectionInfo   *p_secinfo;
 
        if( LIBGOBLIN_SECTION_ID_MAX <= b_secid )       { return NULL; }
 
-       p_secinfo       = &(p_binfo->t_section[b_secid]);
+       p_secinfo       = &(p_pginfo->t_section[b_secid]);
 
        return p_secinfo->pstr_secname;
 }
@@ -61,14 +61,14 @@ char *
 LIBGOBLIN_SECTION_EXTERN
 LibGoblin_SectionInfo *
        LibGoblin_Section_GetSectionInfo(
-                       LibGoblin_BinaryInfo    *p_binfo,
+                       LibGoblin_ProgramInfo   *p_pginfo,
                        Byte    b_secid )
 {
        LibGoblin_SectionInfo   *p_secinfo;
 
        if( LIBGOBLIN_SECTION_ID_MAX <= b_secid )       { return NULL; }
 
-       p_secinfo       = &(p_binfo->t_section[b_secid]);
+       p_secinfo       = &(p_pginfo->t_section[b_secid]);
 
        return p_secinfo;
 }
@@ -86,7 +86,7 @@ LibGoblin_SectionInfo *
        LibGoblin_SectionInfo   *p_secinfo;
 
        assert( NULL != p_binfo );
-       p_bfile = p_binfo->p_binfile;
+       p_bfile = BinaryFile_GetBinaryFile( p_binfo->i_binfile );
 
        if( LIBGOBLIN_SECTION_ID_MAX <= b_secid )       { return NULL; }
 
@@ -116,7 +116,7 @@ Word
                return w_secnumber;
        }
 
-       p_bfile = p_binfo->p_binfile;
+       p_bfile = BinaryFile_GetBinaryFile( p_binfo->i_binfile );
        
        for( b_secid = 0; b_secid < LIBGOBLIN_SECTION_ID_MAX; b_secid++ )       {
                p_secinfo       = &(p_bfile->t_section[ b_secid ]);
@@ -213,7 +213,63 @@ int
 }
 
 
+/*----------------------------------------------------------------------
+----------------------------------------------------------------------*/
+int
+       Section_UpdateSectionInfo_inProgInfo(
+               LibGoblin_ProgramInfo   *p_pginfo,
+               LibGoblin_BinaryInfo    *p_binfo )
+{
+       int                     i_cnt;
+       int                     i_globid;
+       LibGoblin_BinaryFile    *p_bfile;
+       LibGoblin_SectionInfo   *p_sectbl;
+       LibGoblin_SectionInfo   *p_globsec;
 
-/* EOF of drd64_.c ----------------------------------- */
+       assert( NULL != p_pginfo );
+       assert( NULL != p_binfo );
+       p_bfile = BinaryFile_GetBinaryFile( p_binfo->i_binfile );
+
+       // Update Global SectionTable ---
+       for( i_cnt = 0; i_cnt < LIBGOBLIN_SECTION_ID_DEFAULT_MAX; i_cnt++ )     {
+               p_globsec       = &(p_pginfo->t_section[i_cnt]);
+               p_sectbl        = &(p_bfile->t_section[i_cnt]);
+
+               if( NULL == p_globsec->pb_sechdr )      {
+                       p_globsec->pb_sechdr    = p_sectbl->pb_sechdr;
+                       p_globsec->pb_data              = p_sectbl->pb_data;
+                       p_globsec->pstr_secname = p_sectbl->pstr_secname;
+                       p_globsec->qw_size              = p_sectbl->qw_size;
+                       p_globsec->i_fid                = p_sectbl->i_fid;
+               }
 
+       }
+       
+       for( i_cnt = LIBGOBLIN_SECTION_ID_DEFAULT_MAX;
+                                               i_cnt < LIBGOBLIN_SECTION_ID_MAX; i_cnt++ )             {
 
+               p_sectbl        = &(p_bfile->t_section[i_cnt]);
+               if( NULL == p_sectbl->pb_sechdr )       { break; }
+
+               for( i_globid = LIBGOBLIN_SECTION_ID_DEFAULT_MAX;
+                                               i_globid < LIBGOBLIN_SECTION_ID_MAX; i_globid++ )               {
+                       
+                       p_globsec       = &(p_pginfo->t_section[i_globid]);
+                       if( NULL == p_globsec->pb_sechdr )      { break; }
+
+                       if( !strncmp( p_globsec->pstr_secname,
+                                                               p_sectbl->pstr_secname, 20 ))   { break; }
+               }
+
+               p_globsec->pb_sechdr    = p_sectbl->pb_sechdr;
+               p_globsec->pb_data              = p_sectbl->pb_data;
+               p_globsec->pstr_secname = p_sectbl->pstr_secname;
+               p_globsec->qw_size              = p_sectbl->qw_size;
+               p_globsec->i_fid                = p_sectbl->i_fid;
+       }
+       
+       return 0x00;
+}
+
+
+/* EOF of drd64_.c ----------------------------------- */
index d4a370d..c619ef0 100644 (file)
@@ -91,13 +91,10 @@ Comment:
 
 
 LIBGOBLIN_SECTION_EXTERN
-       char *LibGoblin_Section_GetSectionName( LibGoblin_BinaryInfo *p_binfo, Byte b_secid );
-LIBGOBLIN_SECTION_EXTERN
-       LibGoblin_SectionInfo *LibGoblin_Section_GetSectionInfo_fid(
-                       LibGoblin_BinaryInfo *p_binfo, Byte b_secid );
+       char *LibGoblin_Section_GetSectionName( LibGoblin_ProgramInfo *p_pginfo, Byte b_secid );
 LIBGOBLIN_SECTION_EXTERN
        LibGoblin_SectionInfo *LibGoblin_Section_GetSectionInfo(
-                       LibGoblin_BinaryInfo *p_binfo, Byte b_secid );
+                       LibGoblin_ProgramInfo *p_pginfo, Byte b_secid );
 LIBGOBLIN_SECTION_EXTERN
        LibGoblin_SectionInfo *LibGoblin_Section_GetSectionInfo_fid(
                        LibGoblin_BinaryInfo *p_binfo, Byte b_secid );
@@ -108,7 +105,9 @@ LIBGOBLIN_SECTION_EXTERN
        int LibGoblin_Section_ReadSymtabSection_toWorkTable(
                        LibGoblin_BinaryInfo *p_binfo,
                        LibGoblin_SymbolWorkTable *p_symwork );
-
+LIBGOBLIN_SECTION_EXTERN
+       int Section_UpdateSectionInfo_inProgInfo(
+                       LibGoblin_ProgramInfo *p_pginfo, LibGoblin_BinaryInfo *p_binfo );
 
 #endif /* DRD64_HEADER_LIBGOBLIN_BINFO */
 
index cef2454..c714d6c 100644 (file)
@@ -155,10 +155,11 @@ typedef struct    {
 #define        LIBGOBLIN_BINFO_FILE_EXTALLOC   (DWord)0x02
 #define        LIBGOBLIN_BINFO_FILE_INTALLOC   (DWord)0x04
 
-#define        LIBGOBLIN_BINFO_MAXFILES                3
+#define        LIBGOBLIN_BINFO_MAXFILES                3       // Except FILE_LIBRARY
 #define        LIBGOBLIN_BINFO_FILE_EXEC               0
 #define        LIBGOBLIN_BINFO_FILE_CORE               1
 #define        LIBGOBLIN_BINFO_FILE_DEBUG              2
+#define        LIBGOBLIN_BINFO_FILE_LIBRARY    -1
 
 typedef struct {
        /* BinaryInfo Struct ID */
@@ -169,28 +170,31 @@ typedef struct    {
        Byte            b_type;
        Byte            b_endian;
        Byte            b_bits;
+       int                     i_filetype;
 
        /* Debug-Format Depending Info. (DWarf) */
        void            *p_debug;
 
        /* Address Table Info. */
+/*
        LibGoblin_AddressInfo   *p_addrinfo;
        DWord           dw_alloc_addrinfo;
        DWord           dw_max_addrinfo;
+*/
 
        /* Exec. File Info. */
        int                     i_parent_bid;
        char            str_filename[DRD64_MAX_PATH];
        
-       LibGoblin_BinaryFile    *p_binfile;
+       int                     i_binfile;              // binaryFile ID
 
        /* Binary-Format Depending Info. (ELF)*/
        //void          *p_format;
 
-       LibGoblin_SectionInfo   t_section[LIBGOBLIN_SECTION_ID_MAX];
+       //LibGoblin_SectionInfo t_section[LIBGOBLIN_SECTION_ID_MAX];
        
        void            *pv_pginfo;
-       void            *pv_binfo_next; // NEW
+       int                     i_binfo_next;
 
 }      LibGoblin_BinaryInfo;
 
@@ -203,6 +207,8 @@ typedef     struct  {
        int                                             i_num_binfo;
        LibGoblin_BinaryInfo    *p_binfo[LIBGOBLIN_BINFO_MAXFILES];
 
+       LibGoblin_SectionInfo   t_section[LIBGOBLIN_SECTION_ID_MAX];
+
        /* Address Table Info. */
        //LibGoblin_AddressInfo *p_addrinfo;
        //DWord         dw_alloc_addrinfo;
index aa41cf4..7a673a3 100644 (file)
@@ -104,6 +104,8 @@ void Test_BinaryInfo_AllocFree_test00_002( void )
                p_binfo = BinaryInfo_AllocBinInfo( p_pginfo, str_fname, i_parent_bid );
                CU_ASSERT( NULL != p_binfo );
                CU_ASSERT( i_cnt == p_binfo->i_id );
+
+               //printf("  debug: %p (%02d)\n", p_binfo, p_binfo->i_id );
        }
 
        for( i_cnt = (8 * 8); i_cnt > 0; i_cnt-- )      {
index 087f4a2..7238d08 100644 (file)
@@ -62,15 +62,9 @@ void Test_ReadBinary_File_test00_001( void )
        i_result        = ReadBinary_File( p_binfo );
        CU_ASSERT( 0x00 == i_result );
 
-       i_result        = LibGoblin_Debug_Elf_PrintSectionTable( p_binfo, 0xff );
-       CU_ASSERT( 0x00 == i_result );
-
-       i_result        = LibGoblin_Debug_AddrInfo_PrintAddrTable( p_binfo, 0xff );
-       CU_ASSERT( 0x00 <= i_result );
-
        i_result        = ReadBinary_FreeBinary( p_binfo );
        CU_ASSERT( 0x00 == i_result );
-       
+
        i_result        = LibGoblin_FreeBinInfo( i_binfoid );
        CU_ASSERT( 0x00 == i_result );
 
@@ -189,6 +183,7 @@ int
                                                                 Test_ReadBinary_File_test00_002 );
        CU_add_test( pt_goblin, "ReadBinary_Memory_test00_001",
                                                                 Test_ReadBinary_Memory_test00_001 );
+
        return 0x00;
 }