OSDN Git Service

2018/10/10(Wed)
authorKoine Yuusuke(koinec) <koinec@users.osdn.me>
Wed, 10 Oct 2018 07:57:43 +0000 (16:57 +0900)
committerKoine Yuusuke(koinec) <koinec@users.osdn.me>
Wed, 10 Oct 2018 07:57:43 +0000 (16:57 +0900)
  * merge deprecate_LibraryFileList_struct branch

Squashed commit of the following:

commit e31f3deffef13d641b3a8cff60af19cb37104dfe
Author: Koine Yuusuke(koinec) <koinec@users.osdn.me>
Date:   Wed Oct 10 16:54:40 2018 +0900

    2018/10/10(Wed)
      * Deperecate LibGoblin_LibraryFileList struct

commit 00f5805230c04ed1a0950556a9bd543d8fcafdaf
Author: Koine Yuusuke(koinec) <koinec@users.osdn.me>
Date:   Sun Oct 7 19:39:42 2018 +0900

    2018/10/07(Sun)
      * WorkBackup on mobile

commit 06ccc7796dd5b95fc8e4b66006fe0819741e3c5e
Author: Koine Yuusuke(koinec) <koinec@users.osdn.me>
Date:   Tue Oct 2 22:52:22 2018 +0900

    2018/10/02(Tue) 22:50 on mobile
      * test

commit 80e6f9f4db3bfc7e8ec27393469a62b439cfc86c
Author: Koine Yuusuke(koinec) <koinec@users.osdn.me>
Date:   Tue Oct 2 21:57:31 2018 +0900

    2018/10/02(Tue) 21:57
      * WorkBackup: before push branch deprecate_LibraryFileList_struct to origin

commit c0188e2182240b1c43a9f07bcbe2e4b2a85c6bf3
Author: Koine Yuusuke(koinec) <koinec@users.osdn.me>
Date:   Tue Sep 25 22:31:32 2018 +0900

    2018/09/25(Tue)
      * move LibGoblin_BinaryInfo.str_rpath to LibGoblin_BinaryFile.str_rpath
      * move LibGoblin_BinaryInfo.str_filename to LibGoblin_BinaryFile.str_filename

25 files changed:
include/libfiletype.h
include/libgoblin.h
libbrownie/drd64_libbrownie_searchlib.c
libfiletype/drd64_libfiletype_main.c
libgoblin/Makefile
libgoblin/drd64_libgoblin_api.c [new file with mode: 0644]
libgoblin/drd64_libgoblin_binaryfile.c
libgoblin/drd64_libgoblin_binaryfile.h
libgoblin/drd64_libgoblin_binfo.c
libgoblin/drd64_libgoblin_binfo.h
libgoblin/drd64_libgoblin_debug_elf.c
libgoblin/drd64_libgoblin_debug_elf.h
libgoblin/drd64_libgoblin_elf_dynver.c
libgoblin/drd64_libgoblin_loadprog.c
libgoblin/drd64_libgoblin_loadprog.h
libgoblin/drd64_libgoblin_proginfo.c
libgoblin/drd64_libgoblin_proginfo.h
libgoblin/drd64_libgoblin_readbin.c
libgoblin/drd64_libgoblin_readbin.h
libgoblin/drd64_libgoblin_system.c [deleted file]
libgoblin/drd64_libgoblin_type.h
libgoblin/test_libgoblin.c
libgoblin/test_libgoblin_api.c [moved from libgoblin/test_libgoblin_system.c with 100% similarity]
libgoblin/test_libgoblin_loadprog.c
libgoblin/test_libgoblin_readbin.c

index 132dbb9..1f5ea84 100644 (file)
@@ -88,7 +88,7 @@ LIBFILETYPE_FUNC
 // libfiletype_main.c API ------------------------------------------
 LIBFILETYPE_FUNC
        int LibFileType_CheckFileType(
-                       LibFileType_FileType *p_filetype, char *pstr_filename, int i_argfd );
+                       LibFileType_FileType *p_filetype, const char *pstr_filename, int i_argfd );
 LIBFILETYPE_FUNC
        int LibFileType_CheckMemoryType(
                        LibFileType_FileType *p_filetype, Byte *pb_data, int i_size );
index a3ac5db..5949aa0 100644 (file)
@@ -41,15 +41,13 @@ Comment:
 #include"./drd64_defines.h"
 #include"./drd64_error.h"
 
-
 typedef struct {
-       int             i_start;
-       int             i_end;
-       char    str_libfilepath[DRD64_MAX_SOFILES][DRD64_MAX_PATH];
-       char    str_librealpath[DRD64_MAX_SOFILES][DRD64_MAX_PATH];
-       char    str_rpath[DRD64_MAX_SOFILES][DRD64_MAX_PATH];
-} LibGoblin_LibraryFileList;
-
+       char    str_remotepath[DRD64_MAX_PATH];
+       char    str_localpath[DRD64_MAX_PATH];
+       char    str_filename[DRD64_MAX_PATH];
+       char    str_rpath[DRD64_MAX_PATH];
+       int             i_bid;
+} LibGoblin_ObjectFilePath;
 
 #ifdef DRD64_HEADER_LIBGOBLIN_MAIN
        #define LIBGOBLIN_FUNC
@@ -58,14 +56,26 @@ typedef struct      {
 #endif
 
 
-#ifdef DRD64_SRC_LIBGOBLIN_SYSTEM
-       #define LIBGOBLIN_API_SYSTEM
+#ifdef DRD64_SRC_LIBGOBLIN_API
+       #define LIBGOBLIN_API
 #else
-       #define LIBGOBLIN_API_SYSTEM    extern
+       #define LIBGOBLIN_API   extern
 #endif
-LIBGOBLIN_API_SYSTEM
+LIBGOBLIN_API
+       int LibGoblin_GetUnresolv_ObjectFilePath( int i_pgid, LibGoblin_ObjectFilePath *p_objpath );
+LIBGOBLIN_API
+       int LibGoblin_SetPathAndLoad_ObjectFilePath( LibGoblin_ObjectFilePath *p_objpath );
+LIBGOBLIN_API
+       int LibGoblin_AllocBinInfo( int i_pgid, const char *pstr_filename );
+LIBGOBLIN_API
+       int LibGoblin_FreeBinInfo( int i_binfoid );
+LIBGOBLIN_API
+       int LibGoblin_AllocProgInfo( void );
+LIBGOBLIN_API
+       int LibGoblin_FreeProgInfo( int i_pgid );
+LIBGOBLIN_API
        int LibGoblin_Init( void );
-LIBGOBLIN_API_SYSTEM
+LIBGOBLIN_API
        int LibGoblin_Term( void );
 
 #ifdef DRD64_SRC_LIBGOBLIN_PROGINFO
@@ -73,12 +83,6 @@ LIBGOBLIN_API_SYSTEM
 #else
        #define LIBGOBLIN_API_PROGINFO  extern
 #endif
-LIBGOBLIN_API_PROGINFO
-       LibGoblin_LibraryFileList *LibGoblin_GetLibraryFileListArea( int i_pgid );
-LIBGOBLIN_API_PROGINFO
-       int LibGoblin_AllocProgInfo( void );
-LIBGOBLIN_API_PROGINFO
-       int LibGoblin_FreeProgInfo( int i_pgid );
 
 #ifdef DRD64_SRC_LIBGOBLIN_BINFO
        #define LIBGOBLIN_API_BINFO
@@ -87,10 +91,6 @@ LIBGOBLIN_API_PROGINFO
 #endif
 LIBGOBLIN_API_BINFO
        const char *LibGoblin_GetRPath_fromBinInfo( int i_bid, char *pstr_rpath );
-LIBGOBLIN_API_BINFO
-       int LibGoblin_AllocBinInfo( int i_pgid, const char *pstr_filename, const char *pstr_path );
-LIBGOBLIN_API_BINFO
-       int LibGoblin_FreeBinInfo( int i_binfoid );
 
 #ifdef DRD64_SRC_LIBGOBLIN_LOADPROG
        #define LIBGOBLIN_API_LOADPROG
@@ -98,11 +98,8 @@ LIBGOBLIN_API_BINFO
        #define LIBGOBLIN_API_LOADPROG  extern
 #endif
 LIBGOBLIN_API_LOADPROG
-       int LibGoblin_LoadProgram_Library( int i_pgid, LibGoblin_LibraryFileList *p_libflist );
-LIBGOBLIN_API_LOADPROG
        int LibGoblin_LoadProgram_Main(
-                       int i_pgid, const char *pstr_progpath, const char *pstr_realpath,
-                       LibGoblin_LibraryFileList *p_libflist );
+                       int i_pgid, const char *pstr_progpath, const char *pstr_realpath );
 
 
 
index 8b3fec5..5576d4b 100644 (file)
@@ -158,8 +158,6 @@ int
 
 goto_LibBrownie_GetLibraryPath_setting:
        strncpy( pstr_solibpath, pstr_nowpath, DRD64_MAX_PATH );
-       strncat( pstr_solibpath, "/", DRD64_MAX_PATH );
-       strncat( pstr_solibpath, pstr_solibname, DRD64_MAX_PATH );
 
        return 0x00;
 }
index 4e45d95..9db01da 100644 (file)
@@ -51,7 +51,7 @@ LIBFILETYPE_FUNC
 int
        LibFileType_CheckFileType(
                LibFileType_FileType    *p_filetype,
-               char    *pstr_filename,
+               const char      *pstr_filename,
                int             i_argfd )
 {
        struct  stat    t_stat;
index 455c05b..d360197 100644 (file)
@@ -47,7 +47,7 @@ LIB_HEADER = ../include/libfiletype.h
 FLAGS_DEBUG = -g -Wall
 
 TARGET = libgoblin.a
-OBJS = drd64_libgoblin_system.o \
+OBJS = drd64_libgoblin_api.o \
                drd64_libgoblin_proginfo.o \
                drd64_libgoblin_binfo.o \
                drd64_libgoblin_binaryfile.o \
@@ -104,7 +104,7 @@ TEST_FLAGS_LINKER = -L/usr/local/lib -lcunit -L.. -lfiletype -lbrownie
 TEST_TARGET = test_libgoblin
 TEST_HEADER = test_libgoblin.h
 TEST_OBJS = test_libgoblin.o \
-                       test_libgoblin_system.o \
+                       test_libgoblin_api.o \
                        test_libgoblin_proginfo.o \
                        test_libgoblin_binaryfile.o \
                        test_libgoblin_loadprog.o \
@@ -126,9 +126,9 @@ $(TARGET): $(OBJS) $(LIB_OBJS)
        ranlib $(TARGET)
        cp $(TARGET) ..
 
-drd64_libgoblin_system.o: drd64_libgoblin_system.c $(HEADER)
-       $(CC) -c -o drd64_libgoblin_system.o $(FLAGS_DEBUG) \
-                               drd64_libgoblin_system.c
+drd64_libgoblin_api.o: drd64_libgoblin_api.c $(HEADER)
+       $(CC) -c -o drd64_libgoblin_api.o $(FLAGS_DEBUG) \
+                               drd64_libgoblin_api.c
 drd64_libgoblin_proginfo.o: drd64_libgoblin_proginfo.c $(HEADER)
        $(CC) -c -o drd64_libgoblin_proginfo.o $(FLAGS_DEBUG) \
                                drd64_libgoblin_proginfo.c
@@ -208,10 +208,10 @@ test_libgoblin.o: test_libgoblin.c $(HEADER) $(TEST_HEADER)
        $(CC) -c -o test_libgoblin.o \
                        $(FLAGS_DEBUG) $(FLAGS_COMPILE) $(TEST_FLAGS_COMPILE) \
                        test_libgoblin.c
-test_libgoblin_system.o: test_libgoblin_system.c $(HEADER) $(TEST_HEADER)
-       $(CC) -c -o test_libgoblin_system.o \
+test_libgoblin_api.o: test_libgoblin_api.c $(HEADER) $(TEST_HEADER)
+       $(CC) -c -o test_libgoblin_api.o \
                        $(FLAGS_DEBUG) $(FLAGS_COMPILE) $(TEST_FLAGS_COMPILE) \
-                       test_libgoblin_system.c
+                       test_libgoblin_api.c
 test_libgoblin_binfo.o: test_libgoblin_binfo.c $(HEADER) $(TEST_HEADER)
        $(CC) -c -o test_libgoblin_binfo.o \
                        $(FLAGS_DEBUG) $(FLAGS_COMPILE) $(TEST_FLAGS_COMPILE) \
diff --git a/libgoblin/drd64_libgoblin_api.c b/libgoblin/drd64_libgoblin_api.c
new file mode 100644 (file)
index 0000000..feaf07c
--- /dev/null
@@ -0,0 +1,269 @@
+/*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_API
+#include"drd64_libgoblin.h"
+
+
+/***********************************************************************
+***********************************************************************/
+LIBGOBLIN_API
+int
+       LibGoblin_GetUnresolv_ObjectFilePath(
+               int             i_pgid,
+               LibGoblin_ObjectFilePath *p_objpath )
+{
+       int             i_result;
+       LibGoblin_ProgramInfo   *p_pginfo;
+       LibGoblin_BinaryInfo    *p_binfo;
+       LibGoblin_BinaryInfo    *p_binfo_parent;
+       LibGoblin_BinaryFile    *p_bfile;
+
+       if( NULL == p_objpath ) {
+               return -0x01;
+       }
+
+       p_pginfo        = LibGoblin_ProgInfo_GetProgInfo( i_pgid );
+       if( NULL == p_pginfo )  {
+               return -0x02;
+       }
+
+       p_binfo = p_pginfo->p_binfo[0];
+       while( NULL != p_binfo )        {
+               if( LIBGOBLIN_BINFO_PHASE_SETPROG > p_binfo->b_phase )
+                       { break; }
+               p_binfo = (LibGoblin_BinaryInfo *)p_binfo->pv_binfo_next;
+       }
+
+       i_result        = 0x00;
+       if( NULL != p_binfo )   {
+               memset( p_objpath, 0x00, sizeof( LibGoblin_ObjectFilePath ) );
+
+               p_objpath->i_bid        = p_binfo->i_id;
+
+               strncpy( p_objpath->str_filename, p_binfo->str_filename, DRD64_MAX_PATH );
+
+               if( -1 < p_binfo->i_parent_bid )        {
+                       p_binfo_parent  = LibGoblin_BinInfo_GetBinInfo( p_binfo->i_parent_bid );
+                       p_bfile = p_binfo_parent->p_binfile;
+                       if( NULL != p_bfile )
+                               { strncpy( p_objpath->str_rpath, p_bfile->str_rpath, DRD64_MAX_PATH ); }
+               }
+
+               i_result        = 0x01;
+       }
+
+       return i_result;
+}
+
+
+/***********************************************************************
+***********************************************************************/
+LIBGOBLIN_API
+int
+       LibGoblin_SetPathAndLoad_ObjectFilePath(
+               LibGoblin_ObjectFilePath        *p_objpath )
+{
+       int             i_result;
+       LibGoblin_BinaryInfo    *p_binfo;
+
+       p_binfo = LibGoblin_BinInfo_GetBinInfo( p_objpath->i_bid );
+       if( NULL == p_binfo )   {
+               return -0x01;
+       }
+
+       i_result        = strncmp( p_objpath->str_filename,
+                                               p_binfo->str_filename, DRD64_MAX_PATH );
+       if( 0x00 != i_result )  {
+               return -0x02;
+       }
+       
+       i_result        = LibGoblin_BinInfo_SetProgramPath(
+                                               p_binfo, p_objpath->str_remotepath,
+                                               p_objpath->str_localpath );
+       if( 0x00 != i_result )  {
+               return -0x03;
+       }
+
+       i_result        = LibGoblin_LoadProg_LoadBinaryInfo( p_binfo );
+       if( 0x00 != i_result )  {
+               return -0x04;
+       }
+
+       return 0x00;
+}
+
+
+/***********************************************************************
+***********************************************************************/
+LIBGOBLIN_API
+int
+       LibGoblin_AllocBinInfo(
+               int i_pgid,
+               const char *pstr_filename )
+{
+       LibGoblin_ProgramInfo   *p_pginfo       = NULL;
+       LibGoblin_BinaryInfo    *p_binfo        = NULL;
+
+       p_pginfo        = LibGoblin_ProgInfo_GetProgInfo( i_pgid );
+
+       p_binfo = LibGoblin_BinInfo_AllocBinInfo( p_pginfo, pstr_filename, -1 );
+       if( NULL == p_binfo )   {
+               return -0x01;
+       }
+
+       return p_binfo->i_id;
+}
+
+
+/***********************************************************************
+***********************************************************************/
+LIBGOBLIN_API
+int
+       LibGoblin_FreeBinInfo(
+               int i_binfoid )
+{
+       int             i_result;
+       LibGoblin_BinaryInfo    *p_binfo        = NULL;
+
+       p_binfo = LibGoblin_BinInfo_GetBinInfo( i_binfoid );
+       if( NULL == p_binfo )   {
+               return -0x01;
+       }
+
+       i_result        = LibGoblin_BinInfo_FreeBinInfo( p_binfo );
+       if( 0x00 != i_result )  {
+               return -0x02;
+       }
+
+       return i_result;
+}
+
+
+/***********************************************************************
+***********************************************************************/
+LIBGOBLIN_API_PROGINFO
+int
+       LibGoblin_AllocProgInfo(
+               void )
+{
+       LibGoblin_ProgramInfo   *p_pginfo       = NULL;
+       p_pginfo        = LibGoblin_ProgInfo_AllocProgInfo();
+       if( NULL == p_pginfo )  {
+               return -0x01;
+       }
+
+       return p_pginfo->i_id;
+}
+
+
+/***********************************************************************
+***********************************************************************/
+LIBGOBLIN_API_PROGINFO
+int
+       LibGoblin_FreeProgInfo(
+               int i_pgid )
+{
+       int             i_result;
+       LibGoblin_ProgramInfo   *p_pginfo;
+
+       p_pginfo        = LibGoblin_ProgInfo_GetProgInfo( i_pgid );
+       if( NULL == p_pginfo )  {
+               return -0x01;
+       }
+       assert( p_pginfo->i_id == i_pgid );
+
+       i_result        = LibGoblin_ProgInfo_FreeProgInfo( p_pginfo );
+       if( 0x00 != i_result )  {
+               return -0x02;
+       }
+
+       return 0x00;
+}
+
+
+/***********************************************************************
+***********************************************************************/
+LIBGOBLIN_API
+int
+       LibGoblin_Init(
+               void )
+{
+       int             i_err;
+       
+       i_err   = LibFileType_Init();
+       if( 0x00 != i_err )             { return i_err; }
+
+       i_err   = LibGoblin_ProgInfo_Init();
+       if( 0x00 != i_err )             { return i_err; }
+
+       i_err   = LibGoblin_BinInfo_Init();
+       if( 0x00 != i_err )             { return i_err; }
+
+       i_err   = LibGoblin_SymWork_Init();
+       if( 0x00 != i_err )             { return i_err; }
+
+       return 0x00;
+}
+
+
+/***********************************************************************
+***********************************************************************/
+LIBGOBLIN_API
+int
+       LibGoblin_Term(
+               void )
+{
+       int             i_err;
+
+       i_err   = LibGoblin_SymWork_Term();
+       if( 0x00 != i_err )             { return i_err; }
+
+       i_err   = LibGoblin_BinInfo_Term();
+       if( 0x00 != i_err )             { return i_err; }
+
+       i_err   = LibGoblin_ProgInfo_Term();
+       if( 0x00 != i_err )             { return i_err; }
+
+       i_err   = LibFileType_Term();
+       if( 0x00 != i_err )             { return i_err; }
+
+       return 0x00;
+}
+
+
+/* EOF of drd64_.c ----------------------------------- */
index 9edbb5e..3828559 100644 (file)
@@ -124,6 +124,79 @@ goto_BinaryFile_AllocBinaryFile_post:
 }
 
 
+/*----------------------------------------------------------------------
+----------------------------------------------------------------------*/
+LIBGOBLIN_BINARYFILE_EXTERN
+LibGoblin_BinaryFile   *
+       BinaryFile_SearchBinaryFile(
+                       char    *pstr_filename,
+                       char    *pstr_localpath,
+                       char    *pstr_remotepath )
+{
+       int             i_cnt;
+       int             i_result;
+       LibGoblin_BinaryFile    *p_bfile;
+
+       assert( NULL != pstr_filename);
+       assert( NULL != pstr_localpath );
+
+       for( i_cnt = 0; i_cnt < gi_max_binary_file; i_cnt++ )   {
+               p_bfile = BINFILE( i_cnt );
+
+               if( -0x01 == p_bfile->i_id )    { continue; }
+
+               i_result        = strncmp( pstr_filename, p_bfile->str_filename, DRD64_MAX_PATH );
+               if( 0x00 != i_result )  { continue; }
+
+               i_result        = strncmp( pstr_localpath, p_bfile->str_localpath, DRD64_MAX_PATH );
+               if( 0x00 != i_result )  { continue; }
+
+               if( NULL != pstr_remotepath )   {
+                       i_result        = strncmp( pstr_remotepath, p_bfile->str_remotepath, DRD64_MAX_PATH );
+                       if( 0x00 != i_result )  { continue; }
+               }
+
+               goto    goto_BinaryFile_SearchBinaryFile_post;
+       }
+
+       p_bfile = NULL;
+       
+goto_BinaryFile_SearchBinaryFile_post:
+       return p_bfile;
+}
+
+
+/*----------------------------------------------------------------------
+----------------------------------------------------------------------*/
+LIBGOBLIN_BINARYFILE_EXTERN
+LibGoblin_BinaryFile   *
+       BinaryFile_DispenseBinaryFile(
+                       LibGoblin_BinaryInfo    *p_binfo,
+                       char    *pstr_localpath,
+                       char    *pstr_remotepath )
+{
+       LibGoblin_BinaryFile    *p_bfile;
+
+       assert( NULL != p_binfo );
+
+       p_bfile = BinaryFile_SearchBinaryFile(
+                                       p_binfo->str_filename, pstr_localpath, pstr_remotepath );
+       if( NULL != p_bfile )   {
+               p_bfile->i_refcount++;
+       }
+       else    {
+               p_bfile = BinaryFile_AllocBinaryFile();
+       }
+
+       strncpy( p_bfile->str_filename, p_binfo->str_filename, DRD64_MAX_PATH );
+    strncpy( p_bfile->str_localpath, pstr_localpath, DRD64_MAX_PATH );
+    if( NULL != pstr_remotepath )   {
+        strncpy( p_bfile->str_remotepath, pstr_remotepath, DRD64_MAX_PATH );
+    }
+                               
+       return  p_bfile;
+}
+
 
 /*----------------------------------------------------------------------
 OK
@@ -139,14 +212,18 @@ int
 
        if( -0x01 == p_binfile->i_id )  { return 0x00; }
 
-       i_id    = p_binfile->i_id;
-       BinaryFile_ClearBinaryFile( p_binfile );
+       p_binfile->i_refcount--;
+
+       if( 0 == p_binfile->i_refcount )        {
+               i_id    = p_binfile->i_id;
+               BinaryFile_ClearBinaryFile( p_binfile );
 
-       if( gi_max_binary_file == (i_id + 1) )
-               { gi_max_binary_file--; }
+               if( gi_max_binary_file == (i_id + 1) )
+                       { gi_max_binary_file--; }
        
-       gi_now_binary_file--;
-       if( 0 == gi_now_binary_file )   { gi_max_binary_file = 0; }
+               gi_now_binary_file--;
+               if( 0 == gi_now_binary_file )   { gi_max_binary_file = 0; }
+       }
 
        return 0x00;
 }
index a27c757..5dece95 100644 (file)
@@ -64,14 +64,15 @@ int                                         gi_now_binary_file              = 0;
 
 LIBGOBLIN_BINARYFILE_EXTERN
        LibGoblin_BinaryFile *BinaryFile_GetBinaryFile( int i_libid );
-/*
-LIBGOBLIN_BINARYFILE_EXTERN
-       LibGoblin_BinaryInfo *LibGoblin_BinaryFile_AddBinaryInfo(
-                       LibGoblin_ProgramInfo *p_pginfo, const char *pstr_binname, int i_req_bid );
-*/
 LIBGOBLIN_BINARYFILE_EXTERN
        LibGoblin_BinaryFile *BinaryFile_AllocBinaryFile( void );
 LIBGOBLIN_BINARYFILE_EXTERN
+       LibGoblin_BinaryFile *BinaryFile_SearchBinaryFile(
+               char *pstr_filename, char *pstr_localpath, char *pstr_remotepath );
+LIBGOBLIN_BINARYFILE_EXTERN
+       LibGoblin_BinaryFile *BinaryFile_DispenseBinaryFile(
+               LibGoblin_BinaryInfo *p_binfo, char *pstr_localpath, char *pstr_remotepath );
+LIBGOBLIN_BINARYFILE_EXTERN
        int BinaryFile_FreeBinaryFile( LibGoblin_BinaryFile *p_libinfo );
 LIBGOBLIN_BINARYFILE_EXTERN
        int BinaryFile_Init( void );
index 6ac3cdc..ddb3f63 100644 (file)
@@ -61,15 +61,18 @@ const char *
                char    *pstr_rpath )
 {
        const char                              *pcstr_result;
+       LibGoblin_BinaryFile    *p_binfile;
 
        assert( NULL != p_binfo );
+       p_binfile       = p_binfo->p_binfile;
+       assert( NULL != p_binfile );
 
        if( NULL != pstr_rpath )        {
-               strncpy( pstr_rpath, p_binfo->str_rpath, DRD64_MAX_PATH );
+               strncpy( pstr_rpath, p_binfile->str_rpath, DRD64_MAX_PATH );
                pcstr_result    = (const char *)pstr_rpath;
        }
        else    {
-               pcstr_result    = (const char *)p_binfo->str_rpath;
+               pcstr_result    = (const char *)p_binfile->str_rpath;
        }
 
        return pcstr_result;
@@ -123,6 +126,73 @@ void
 ----------------------------------------------------------------------*/
 LIBGOBLIN_BINFO_EXTERN
 int
+       BinInfo_AppendChain(
+                       LibGoblin_BinaryInfo    *p_binfo_now )
+{
+       LibGoblin_BinaryInfo    *p_binfo_top;
+       LibGoblin_BinaryInfo    *p_binfo_end;
+
+       assert( NULL != p_binfo_now );
+
+       p_binfo_top     = p_binfo_now;
+       while( -1 < p_binfo_top->i_parent_bid )
+               { p_binfo_top   = BINFO( p_binfo_top->i_parent_bid ); }
+
+       if( p_binfo_now == p_binfo_top )
+               { return 0x00; }
+
+       p_binfo_end     = p_binfo_top;
+       while( ( NULL != p_binfo_end->pv_binfo_next )
+                               && ( p_binfo_end !=  p_binfo_now ) )    {
+               p_binfo_end     = (LibGoblin_BinaryInfo *)p_binfo_end->pv_binfo_next;
+       }
+
+       assert( NULL != p_binfo_end );
+
+       p_binfo_end->pv_binfo_next      = (void *)p_binfo_now;
+
+       return 0x00;
+}
+
+
+/*----------------------------------------------------------------------
+----------------------------------------------------------------------*/
+LIBGOBLIN_BINFO_EXTERN
+int
+       BinInfo_DeleteChain(
+                       LibGoblin_BinaryInfo    *p_binfo_del )
+{
+       LibGoblin_BinaryInfo    *p_binfo_top;
+       LibGoblin_BinaryInfo    *p_binfo_now;
+       LibGoblin_BinaryInfo    *p_binfo_before;
+
+       assert( NULL != p_binfo_del );
+
+       p_binfo_top     = p_binfo_del;
+       while( -1 < p_binfo_top->i_parent_bid )
+               { p_binfo_top   = BINFO( p_binfo_top->i_parent_bid ); }
+
+       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;
+       }
+
+       if( NULL != p_binfo_before )    {
+               p_binfo_before->pv_binfo_next   = (LibGoblin_BinaryInfo *)p_binfo_now->pv_binfo_next;
+       }
+       p_binfo_del->pv_binfo_next              = NULL;
+
+       return 0x00;
+}
+
+
+/*----------------------------------------------------------------------
+----------------------------------------------------------------------*/
+LIBGOBLIN_BINFO_EXTERN
+int
        LibGoblin_BinInfo_SetRPath(
                        LibGoblin_BinaryInfo    *p_binfo,
                        const char      *pstr_rpath )
@@ -131,15 +201,27 @@ int
        char            str_src[MAXPATHLEN];
        char            str_dest[MAXPATHLEN];
        char            *pstr_result;
+       char            *pstr_rbasepath;
+       LibGoblin_BinaryFile    *p_binfile;
 
        if( LIBGOBLIN_BINFO_PHASE_SETPROG > p_binfo->b_phase )  {
                return -0x01;
        }
 
+       p_binfile       = p_binfo->p_binfile;
+       assert( NULL != p_binfile );
+
        memset( str_src, 0x00, MAXPATHLEN );
 
-       i_len   = strnlen( p_binfo->str_path, DRD64_MAX_PATH );
-       strncpy( str_src, p_binfo->str_path, i_len + 1 ); 
+       // p_binfo->str_path is current path 
+       if( 0x00 != p_binfile->str_remotepath[0] )
+               { pstr_rbasepath        = p_binfile->str_remotepath; }
+       else
+               { pstr_rbasepath        = p_binfile->str_localpath; }
+
+
+       i_len   = strnlen( pstr_rbasepath, DRD64_MAX_PATH );
+       strncpy( str_src, pstr_rbasepath, i_len + 1 ); 
        str_src[ i_len ]        = '/';
        strncat( str_src, pstr_rpath, (MAXPATHLEN - i_len - 1) ); 
        
@@ -152,31 +234,7 @@ int
        if( DRD64_MAX_PATH <= i_len )   {
                return -0x03;
        }
-       strncpy( p_binfo->str_rpath, str_dest, DRD64_MAX_PATH );
-
-       return 0x00;
-}
-
-
-/*----------------------------------------------------------------------
-----------------------------------------------------------------------*/
-LIBGOBLIN_BINFO_EXTERN
-int
-       LibGoblin_BinInfo_SetProgramName(
-                       LibGoblin_BinaryInfo    *p_binfo,
-                       const char      *pstr_progname,
-                       int             i_req_bid )
-{
-       assert( NULL != p_binfo );
-
-       // Check BinaryInfo & BinaryFile struct status ---
-       if( LIBGOBLIN_BINFO_PHASE_ALLOCED < p_binfo->b_phase )  {
-               return -0x01;
-       }
-
-       strncpy( p_binfo->str_filename, pstr_progname, DRD64_MAX_PATH );
-       p_binfo->i_req_bid      = i_req_bid;
-       p_binfo->b_phase        = LIBGOBLIN_BINFO_PHASE_SETNAME;
+       strncpy( p_binfile->str_rpath, str_dest, DRD64_MAX_PATH );
 
        return 0x00;
 }
@@ -191,13 +249,14 @@ LIBGOBLIN_BINFO_EXTERN
 int
        LibGoblin_BinInfo_SetProgramPath(
                        LibGoblin_BinaryInfo    *p_binfo,
-                       const char      *pstr_progpath,
-                       const char      *pstr_realpath )
+                       const char      *pstr_remotepath,
+                       const char      *pstr_localpath )
 {
        int                     i_len;
-       char            str_temp[MAXPATHLEN];
+       char            str_local[MAXPATHLEN];
+       char            str_remote[MAXPATHLEN];
        char            *pstr_result;
-       char            *pstr_temp;
+       char            *pstr_remote;
        
        LibGoblin_BinaryFile    *p_bfile;
 
@@ -207,45 +266,37 @@ int
        if( LIBGOBLIN_BINFO_PHASE_SETPROG <= p_binfo->b_phase ) {
                return -0x01;
        }
-       if(( LIBGOBLIN_BINFO_PHASE_SETNAME == p_binfo->b_phase )
-                       && ( '\0' == p_binfo->str_filename[0] ))        {
-               return -0x02;
-       }
 
-       p_bfile = p_binfo->p_binfile;
-       if( '\0' != p_bfile->str_path[0] )      {
-               return -0x03;
+       // localpath convert to RelativePath to AbsolutePath ---
+       pstr_result     = realpath( pstr_localpath, str_local );
+       if( NULL == pstr_result )       {
+               return -0x04;
        }
+       i_len   = strnlen( str_local, DRD64_MAX_PATH );
+       if( '/' == str_local[ i_len ] ) { str_local[ i_len ] = '\0'; }
+
+       // remotepath convert to RelativePath to AbsolutePath ---
+       pstr_remote     = NULL;
+       if( NULL != pstr_remotepath )   {
+               if( '\0' != *pstr_remotepath )  {
+                       pstr_result     = realpath( pstr_remotepath, str_remote );
+                       if( NULL == pstr_result )       {
+                               return -0x05;
+                       }
+                       i_len   = strnlen( str_remote, DRD64_MAX_PATH );
+                       if( '/' == str_remote[ i_len ] )        { str_remote[ i_len ] = '\0'; }
 
-
-       if( pstr_progpath == pstr_realpath )
-               { strncpy( str_temp, pstr_progpath, DRD64_MAX_PATH ); }
-       else if( 0x00 == strncmp( pstr_progpath, pstr_realpath, DRD64_MAX_PATH ) )
-               { strncpy( str_temp, pstr_progpath, DRD64_MAX_PATH ); }
-       else    {
-               // Convert relative-filepath to absolute-filepath. 
-               pstr_result     = realpath( pstr_progpath, str_temp );
-               if( NULL == pstr_result )       {
-                       return -0x04;
+                       pstr_remote     = str_remote;
                }
        }
 
-       i_len   = strnlen( str_temp, MAXPATHLEN );
-       if( DRD64_MAX_PATH <= i_len )   {
-               return -0x05;
+       // Alloc BinaryFile struct & Set File Path ---
+       p_bfile = BinaryFile_DispenseBinaryFile( p_binfo, str_local, pstr_remote);
+       if( NULL == p_bfile )   {
+               return -0x06;
        }
-       
-       // Set Real-BinaryFile Path to LibGoblin_BinaryFile ---
-       strncpy( p_bfile->str_path, pstr_realpath, DRD64_MAX_PATH );
-
-       // Set ProgramFile Path to LibGoblin_BinaryInfo ---
-       for( pstr_temp = str_temp + i_len;
-                       ((pstr_temp != str_temp) && ('/' != *pstr_temp)); pstr_temp-- );
-       *pstr_temp      = '\0';
-
-       strncpy( p_binfo->str_filename, (pstr_temp + 1), DRD64_MAX_PATH );
-       strncpy( p_binfo->str_path, str_temp, DRD64_MAX_PATH );
 
+       p_binfo->p_binfile      = p_bfile;
        p_binfo->b_phase        = LIBGOBLIN_BINFO_PHASE_SETPROG;
 
        return 0x00;
@@ -258,14 +309,13 @@ LIBGOBLIN_BINFO_EXTERN
 LibGoblin_BinaryInfo *
        LibGoblin_BinInfo_AllocBinInfo(
                        LibGoblin_ProgramInfo   *p_pginfo,
-                       const char *pstr_filename, 
-                       const char *pstr_path )
+                       const char *pstr_filename,
+                       int     i_parent_bid )
 {
        int             i_cnt;
        int             i_id_now;
        LibGoblin_BinaryInfo *p_binfo_base;
        LibGoblin_BinaryInfo *p_binfo_now;
-       LibGoblin_BinaryFile *p_binfile;
        
        p_binfo_now     = NULL;
        i_id_now        = -1;
@@ -312,41 +362,18 @@ LibGoblin_BinaryInfo *
 
        assert( NULL != p_binfo_now );
 
-       p_binfile       = BinaryFile_AllocBinaryFile();
-       if( NULL == p_binfile ) {
-               return NULL;
-       }
-
        LibGoblin_BinInfo_ClearBinInfo( p_binfo_now );
        p_binfo_now->i_id               = i_id_now;
-       p_binfo_now->b_phase    = LIBGOBLIN_BINFO_PHASE_ALLOCED;
-       p_binfo_now->p_binfile  = p_binfile;
+       //p_binfo_now->b_phase  = LIBGOBLIN_BINFO_PHASE_ALLOCED;
        p_binfo_now->pv_pginfo  = (void *)p_pginfo;
+       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;
 
-       return p_binfo_now;
-}
-
-
-/***********************************************************************
-***********************************************************************/
-LIBGOBLIN_API_BINFO
-int
-       LibGoblin_AllocBinInfo(
-                       int     i_pgid,
-                       const char *pstr_filename, 
-                       const char *pstr_path )
-{
-       LibGoblin_ProgramInfo   *p_pginfo       = NULL;
-       LibGoblin_BinaryInfo    *p_binfo        = NULL;
-
-       p_pginfo        = LibGoblin_ProgInfo_GetProgInfo( i_pgid );
-
-       p_binfo = LibGoblin_BinInfo_AllocBinInfo( p_pginfo, pstr_filename, pstr_path );
-       if( NULL == p_binfo )   {
-               return -0x01;
-       }
+       BinInfo_AppendChain( p_binfo_now );
 
-       return p_binfo->i_id;
+       return p_binfo_now;
 }
 
 
@@ -367,13 +394,17 @@ int
                return -0x02;
        }
 
-       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_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;
+               }
+
+               BinaryFile_FreeBinaryFile( p_binfo->p_binfile );
+               p_binfo->p_binfile      = NULL;
        }
 
-       BinaryFile_FreeBinaryFile( p_binfo->p_binfile );
-       p_binfo->p_binfile      = NULL;
+       BinInfo_DeleteChain( p_binfo );
 
        i_binfoid       = p_binfo->i_id;
        LibGoblin_BinInfo_ClearBinInfo( p_binfo );
@@ -386,30 +417,6 @@ int
 }
 
 
-/***********************************************************************
-***********************************************************************/
-LIBGOBLIN_API_BINFO
-int
-       LibGoblin_FreeBinInfo(
-                       int     i_binfoid )
-{
-       int             i_result;
-       LibGoblin_BinaryInfo    *p_binfo        = NULL;
-
-       p_binfo = LibGoblin_BinInfo_GetBinInfo( i_binfoid );
-       if( NULL == p_binfo )   {
-               return -0x01;
-       }
-
-       i_result        = LibGoblin_BinInfo_FreeBinInfo( p_binfo );
-       if( 0x00 != i_result )  {
-               return -0x02;
-       }
-
-       return i_result;
-}
-
-
 /*----------------------------------------------------------------------
 ----------------------------------------------------------------------*/
 LIBGOBLIN_BINFO_EXTERN
index 256d4b2..59b8fe9 100644 (file)
@@ -71,14 +71,11 @@ LIBGOBLIN_BINFO_EXTERN
        int LibGoblin_BinInfo_SetRPath(
                        LibGoblin_BinaryInfo *p_binfo, const char *pstr_rpath );
 LIBGOBLIN_BINFO_EXTERN
-       int LibGoblin_BinInfo_SetProgramName(
-                       LibGoblin_BinaryInfo *p_binfo, const char *pstr_progname, int i_req_bid );
-LIBGOBLIN_BINFO_EXTERN
        int LibGoblin_BinInfo_SetProgramPath(
                        LibGoblin_BinaryInfo *p_binfo, const char *pstr_progpath, const char *pstr_realpath );
 LIBGOBLIN_BINFO_EXTERN
        LibGoblin_BinaryInfo *LibGoblin_BinInfo_AllocBinInfo(
-                       LibGoblin_ProgramInfo *p_pginfo, const char *pstr_filename, const char *pstr_path );
+                       LibGoblin_ProgramInfo *p_pginfo, const char *pstr_filename, int i_parent_bid );
 LIBGOBLIN_BINFO_EXTERN
        int LibGoblin_BinInfo_FreeBinInfo( LibGoblin_BinaryInfo *p_binfo );
 LIBGOBLIN_BINFO_EXTERN
index e6ac4d8..0a292d8 100644 (file)
@@ -42,36 +42,6 @@ Comment:
 ----------------------------------------------------------------------*/
 LIBGOBLIN_DEBUG_ELF_EXTERN
 int
-       LibGoblin_Debug_Elf_PrintLibFileList(
-                       LibGoblin_LibraryFileList       *p_libflist,
-                       Byte    b_level )
-{
-       int             i_cnt;
-
-       if( 0x00 < b_level )
-               { puts("[DEBUG] Load Library List -------------------------------------------"); }
-
-       for( i_cnt = p_libflist->i_start; i_cnt < p_libflist->i_end; i_cnt++ )  {
-               if( 0x00 < b_level )    {
-                       printf("  [%2d]: %s\t(%s)\n", i_cnt,
-                                       p_libflist->str_libfilepath[ i_cnt - p_libflist->i_start ],
-                                       p_libflist->str_librealpath[ i_cnt - p_libflist->i_start ] ); 
-               }
-       }
-
-       if( 0x00 < b_level )    {
-               puts("-----------------------------------------------------------------------");
-               puts("");
-       }
-
-       return 0x00;
-}
-
-
-/*----------------------------------------------------------------------
-----------------------------------------------------------------------*/
-LIBGOBLIN_DEBUG_ELF_EXTERN
-int
        LibGoblin_Debug_Elf_PrintSectionTable(
                        LibGoblin_BinaryInfo    *p_binfo,
                        Byte            b_level )
index 946cf4f..4d4577f 100644 (file)
@@ -46,9 +46,6 @@ Comment:
 #endif
 
 LIBGOBLIN_DEBUG_ELF_EXTERN
-       int LibGoblin_Debug_Elf_PrintLibFileList(
-            LibGoblin_LibraryFileList *p_libflist, Byte b_level );
-LIBGOBLIN_DEBUG_ELF_EXTERN
        int LibGoblin_Debug_Elf_PrintSectionTable(
                                LibGoblin_BinaryInfo *p_binfo, Byte b_level );
 
index 134084a..1ebc564 100644 (file)
@@ -83,7 +83,6 @@ int
        else
                { i_sz_elfdyn   = sizeof( Elf32_Dyn ); }
        
-               
        do      {
                if( IsBinfoType_Elf64( p_binfo ) )      {
                        p_dyn64 = (Elf64_Dyn *)pb_data;
@@ -101,14 +100,12 @@ int
 
                if( DT_NEEDED == qw_tag )       {
                        p_bintmp        = LibGoblin_ProgInfo_AddBinaryInfo(
-                                                               p_pginfo, ((char *)(pb_dynstr + qw_value)), NULL, p_binfo->i_id );
+                                                               p_pginfo, ((char *)(pb_dynstr + qw_value)), p_binfo->i_id );
                }
                else if( DT_RPATH == qw_tag )   {
                        LibGoblin_BinInfo_SetRPath( p_binfo, (const char *)(pb_dynstr + qw_value) );
                }
-               /*
-               else if( DT_SONAME == qw_tag )  { }
-               */
+               //else if( DT_SONAME == qw_tag )        { }
 
                pb_data += i_sz_elfdyn;
        }while( DT_NULL != qw_tag );
index 607f4d5..a13e2ac 100644 (file)
@@ -37,101 +37,35 @@ Comment:
 #define        DRD64_SRC_LIBGOBLIN_LOADPROG
 #include"drd64_libgoblin.h"
 
+
 /*----------------------------------------------------------------------
 ----------------------------------------------------------------------*/
 LIBGOBLIN_LOADPROG_EXTERN
 int
-       LibGoblin_LoadProg_LoadBinaryInfo_fromFileList(
-                       LibGoblin_ProgramInfo   *p_pginfo,
-                       LibGoblin_LibraryFileList       *p_libflist )
+       LibGoblin_LoadProg_LoadBinaryInfo(
+                       LibGoblin_BinaryInfo    *p_binfo )
 {
        int             i_result;
-       int             i_readed_bid;
-       int             i_now_bid;
-       int             i_max_bid;
-       int             i_idxflist;
-       LibGoblin_BinaryInfo    *p_binfo;
        LibGoblin_BinaryFile    *p_bfile;
 
-       assert( NULL != p_pginfo );
-       assert( NULL != p_libflist );
-
-       i_now_bid       = p_libflist->i_start;
-       i_max_bid       = p_libflist->i_end;
-       i_idxflist      = 0;
-
-       for( ; i_now_bid < i_max_bid; i_now_bid++, i_idxflist++ )       {
-               p_binfo = p_pginfo->p_binfo[ i_now_bid ];
-
-               i_result        = LibGoblin_BinInfo_SetProgramPath(
-                                                       p_binfo, p_libflist->str_libfilepath[i_idxflist],
-                                                       p_libflist->str_librealpath[i_idxflist] );
-               if( 0x00 != i_result )  {
-                       return -0x02;
-               }
-
-               i_result        = LibGoblin_ReadBinary_File( p_binfo, NULL );
-               if( 0x00 != i_result )  {
-                       return -0x03;
-               }
+       assert( NULL != p_binfo );
 
-               p_bfile = p_binfo->p_binfile;
-               if( 0x00 == (DRD64_LIBFILETYPE_SUB_ELF & p_bfile->t_ftype.w_subtype) )  {
-                       return -0x04;
-               }
-       
-               //i_result      = LibGoblin_Elf_ReadELF_Phase1( p_binfo, LIBGOBLIN_BINFO_FILE_EXEC );
-               i_result        = LibGoblin_Elf_ReadELF_Phase1( p_binfo );
-               if( 0x00 != i_result )  {
-                       return -0x05;
-               }
+       i_result        = LibGoblin_ReadBinary_File( p_binfo );
+       if( 0x00 != i_result )  {
+               return -0x03;
        }
 
-       memset( p_libflist, 0x00, sizeof( LibGoblin_LibraryFileList ) );
-
-       i_readed_bid    = i_max_bid;
-       i_now_bid               = i_max_bid;
-       i_max_bid               = LibGoblin_ProgInfo_GetBinaryInfos( p_pginfo );
-       for( ; i_now_bid < i_max_bid; i_now_bid++ )     {
-               p_binfo = p_pginfo->p_binfo[ i_now_bid ];
-               assert( NULL != p_binfo );
-
-               strncpy( p_libflist->str_libfilepath[ i_now_bid - i_readed_bid ],
-                                                               p_binfo->str_filename, DRD64_MAX_PATH );
-               LibGoblin_GetRPath_fromBinInfo(
-                               p_binfo->i_req_bid, p_libflist->str_rpath[ i_now_bid - i_readed_bid ] );
+       p_bfile = p_binfo->p_binfile;
+       if( 0x00 == (DRD64_LIBFILETYPE_SUB_ELF & p_bfile->t_ftype.w_subtype) )  {
+               return -0x04;
        }
-       
-       p_libflist->i_start     = i_readed_bid;
-       p_libflist->i_end       = i_max_bid;
 
-       return 0x00;
-}
-
-
-/***********************************************************************
-***********************************************************************/
-LIBGOBLIN_API_LOADPROG
-int
-       LibGoblin_LoadProgram_Library(
-                       int             i_pgid,
-                       LibGoblin_LibraryFileList       *p_libflist )
-{
-       int             i_result;
-       LibGoblin_ProgramInfo   *p_pginfo;
-
-       p_pginfo        = LibGoblin_ProgInfo_GetProgInfo( i_pgid );
-       if( NULL == p_pginfo )  {
-               return -0x01;
+       i_result        = LibGoblin_Elf_ReadELF_Phase1( p_binfo );
+       if( 0x00 != i_result )  {
+               return -0x05;
        }
 
-       if( NULL == p_libflist )        {
-               return -0x02;
-       }
-
-       i_result        = LibGoblin_LoadProg_LoadBinaryInfo_fromFileList( p_pginfo, p_libflist );
-
-       return i_result;
+       return 0x00;
 }
 
 
@@ -141,14 +75,14 @@ LIBGOBLIN_API_LOADPROG
 int
        LibGoblin_LoadProgram_Main(
                        int             i_pgid,
-                       const char      *pstr_progpath,
-                       const char      *pstr_realpath,
-                       LibGoblin_LibraryFileList       *p_libflist )
+                       const char      *pstr_remotefull,
+                       const char      *pstr_localfull )
 {
        int             i_result;
-       char    *pstr_temp;
-       char    *pstr_progfile;
-       char    *pstr_path;
+
+       char    str_filename[DRD64_MAX_PATH];
+       char    str_localpath[DRD64_MAX_PATH];
+       char    *pstr_remotepath;
        LibGoblin_ProgramInfo   *p_pginfo;
        LibGoblin_BinaryInfo    *p_binfo;
 
@@ -157,30 +91,27 @@ int
                return -0x01;
        }
 
-       if( NULL == p_libflist )        {
-               return -0x02;
-       }
-
-       strncpy( p_libflist->str_libfilepath[0], pstr_progpath, DRD64_MAX_PATH );
-       strncpy( p_libflist->str_librealpath[0], pstr_realpath, DRD64_MAX_PATH );
-       p_libflist->i_start     = 0;
-       p_libflist->i_end       = 1;
+       strncpy( str_filename, basename( pstr_localfull ), DRD64_MAX_PATH );
+       strncpy( str_localpath, dirname( pstr_localfull ), DRD64_MAX_PATH );
 
-       // XXX
-       pstr_temp       = alloca( DRD64_MAX_PATH + 1);
-       strncpy( pstr_temp, pstr_progpath, DRD64_MAX_PATH );
-       pstr_progfile   = basename( pstr_temp );
-
-       pstr_temp       = alloca( DRD64_MAX_PATH + 1);
-       strncpy( pstr_temp, pstr_progpath, DRD64_MAX_PATH );
-       pstr_path       = basename( pstr_temp );
+       pstr_remotepath = NULL;
+       if( NULL != pstr_remotefull )   {
+               pstr_remotepath = (char *)alloca( DRD64_MAX_PATH + 1 );
+               strncpy( pstr_remotepath, dirname( pstr_remotefull ), DRD64_MAX_PATH );
+       }
 
-       p_binfo = LibGoblin_ProgInfo_AddBinaryInfo( p_pginfo, pstr_progfile, pstr_path, 0 );
+       p_binfo = LibGoblin_ProgInfo_AddBinaryInfo( p_pginfo, str_filename,  -1 );
        if( NULL == p_binfo )   {
                return -0x01;
        }
 
-       i_result        = LibGoblin_LoadProg_LoadBinaryInfo_fromFileList( p_pginfo, p_libflist );
+       i_result        = LibGoblin_BinInfo_SetProgramPath(
+                                               p_binfo, pstr_remotepath, str_localpath );
+       if( 0x00 != i_result )  {
+               return -0x02;
+       }
+
+       i_result        = LibGoblin_LoadProg_LoadBinaryInfo( p_binfo );
 
        return i_result;
 }
index 60565f1..68388a2 100644 (file)
@@ -50,12 +50,8 @@ Comment:
 #endif
 
 LIBGOBLIN_LOADPROG_EXTERN
-       int LibGoblin_LoadProg_LoadBinaryInfo_fromFileList(
-                               LibGoblin_ProgramInfo *p_pginfo, LibGoblin_LibraryFileList *p_libflist );
-LIBGOBLIN_LOADPROG_EXTERN
-       int LibGoblin_LoadProg_LoadProgram_Main(
-                               LibGoblin_ProgramInfo *p_pginfo, const char *pstr_progpath,
-                               const char *pstr_realpath, LibGoblin_LibraryFileList *p_libflist );
+       int LibGoblin_LoadProg_LoadBinaryInfo(
+                               LibGoblin_BinaryInfo *p_binfo );
 
 
 #endif /* DRD64_HEADER_XXX */
index 3ff943d..62a04e9 100644 (file)
@@ -67,30 +67,6 @@ int
 }
 
 
-/***********************************************************************
-***********************************************************************/
-LIBGOBLIN_API_PROGINFO
-LibGoblin_LibraryFileList      *
-       LibGoblin_GetLibraryFileListArea(
-                       int     i_pgid )
-{
-       LibGoblin_ProgramInfo           *p_pginfo       = NULL;
-       LibGoblin_LibraryFileList       *p_libflist     = NULL;
-       
-       p_pginfo        = LibGoblin_ProgInfo_GetProgInfo( i_pgid );
-       if( NULL == p_pginfo )  {
-               return NULL;
-       }
-
-       p_libflist      = &(p_pginfo->t_libflist);
-       assert( NULL != p_libflist );
-
-       memset( p_libflist, 0x00, sizeof( LibGoblin_LibraryFileList ) );
-
-       return p_libflist;
-}
-
-
 /*----------------------------------------------------------------------
 ----------------------------------------------------------------------*/
 LIBGOBLIN_PROGINFO_EXTERN
@@ -98,12 +74,9 @@ LibGoblin_BinaryInfo *
        LibGoblin_ProgInfo_AddBinaryInfo(
                        LibGoblin_ProgramInfo   *p_pginfo,
                        const char      *pstr_binfilename,
-                       const char      *pstr_binpath,
                        int                     i_req_bid )
 {
        int             i_binfoid;
-       int             i_result;
-       int             i_cnt;
        LibGoblin_BinaryInfo    *p_binfo        = NULL;
 
        assert( NULL != p_pginfo );
@@ -113,16 +86,21 @@ LibGoblin_BinaryInfo *
                return NULL;
        }
 
+/*
        // Check Alloced Same-Library ---
        for( i_cnt = 0; i_cnt < p_pginfo->i_num_binfo; i_cnt++ )        {
-               if( !strncmp( (p_pginfo->p_binfo[ i_cnt ])->str_filename,
+               p_binfo = p_pginfo->p_binfo[ i_cnt ];
+               p_binfile       = p_binfo->p_binfile;
+
+               if( !strncmp( p_binfile->str_filename,
                                        pstr_binfilename, DRD64_MAX_PATH ) )    {
-                       return p_pginfo->p_binfo[ i_cnt ];
+                       return p_binfo;
                }
        }
+*/
 
        // Alloc BinaryInfo ---
-       p_binfo = LibGoblin_BinInfo_AllocBinInfo( p_pginfo, pstr_binfilename, pstr_binpath );
+       p_binfo = LibGoblin_BinInfo_AllocBinInfo( p_pginfo, pstr_binfilename, i_req_bid );
        if( NULL == p_binfo )   {
                return NULL;
        }
@@ -130,14 +108,6 @@ LibGoblin_BinaryInfo *
        p_pginfo->p_binfo[ i_binfoid ]  = p_binfo;
        p_pginfo->i_num_binfo++;
 
-       i_result        = LibGoblin_BinInfo_SetProgramName( p_binfo, pstr_binfilename, i_req_bid );
-       if( 0x00 != i_result )  {
-               LibGoblin_BinInfo_FreeBinInfo( p_binfo );
-               // XXX - error check!
-
-               return NULL;
-       }
-
        return p_binfo;
 }
 
@@ -207,24 +177,6 @@ goto_LibGoblin_ProgInfo_AllocProgInfo_post:
 }
 
 
-/***********************************************************************
-***********************************************************************/
-LIBGOBLIN_API_PROGINFO
-int
-       LibGoblin_AllocProgInfo(
-                       void )
-{
-       LibGoblin_ProgramInfo   *p_pginfo       = NULL;
-       
-       p_pginfo        = LibGoblin_ProgInfo_AllocProgInfo();
-       if( NULL == p_pginfo )  {
-               return -0x01;
-       }
-
-       return p_pginfo->i_id;
-}
-
-
 /*----------------------------------------------------------------------
 ----------------------------------------------------------------------*/
 LIBGOBLIN_PROGINFO_EXTERN
@@ -251,31 +203,6 @@ int
 }
 
 
-/***********************************************************************
-***********************************************************************/
-LIBGOBLIN_API_PROGINFO
-int
-       LibGoblin_FreeProgInfo(
-                       int     i_pgid )
-{
-       int             i_result;
-       LibGoblin_ProgramInfo   *p_pginfo;
-
-       p_pginfo        = LibGoblin_ProgInfo_GetProgInfo( i_pgid );
-       if( NULL == p_pginfo )  {
-               return -0x01;
-       }
-       assert( p_pginfo->i_id == i_pgid );
-
-       i_result        = LibGoblin_ProgInfo_FreeProgInfo( p_pginfo );
-       if( 0x00 != i_result )  {
-               return -0x02;
-       }
-       
-       return 0x00;
-}
-
-
 /*----------------------------------------------------------------------
 ----------------------------------------------------------------------*/
 LIBGOBLIN_PROGINFO_EXTERN
index fef969c..c9386fc 100644 (file)
@@ -68,7 +68,7 @@ LIBGOBLIN_PROGINFO_EXTERN
        int LibGoblin_ProgInfo_GetBinaryInfos( LibGoblin_ProgramInfo *p_pginfo );
 LIBGOBLIN_PROGINFO_EXTERN
        LibGoblin_BinaryInfo *LibGoblin_ProgInfo_AddBinaryInfo(
-                       LibGoblin_ProgramInfo *p_pginfo, const char *pstr_binfilename, const char *pstr_binpath, int i_req_bid );
+                       LibGoblin_ProgramInfo *p_pginfo, const char *pstr_binfilename, int i_req_bid );
 LIBGOBLIN_PROGINFO_EXTERN
        LibGoblin_ProgramInfo *LibGoblin_ProgInfo_AllocProgInfo( void );
 LIBGOBLIN_PROGINFO_EXTERN
index 0a4e73c..0cb1b55 100644 (file)
@@ -43,13 +43,14 @@ Comment:
 LIBGOBLIN_READBIN_EXTERN
 int
        LibGoblin_ReadBinary_File(
-                       LibGoblin_BinaryInfo    *p_binfo,
-                       const char      *pstr_filepath )
+                       LibGoblin_BinaryInfo    *p_binfo )
+                       //,const char   *pstr_filepath )
 {
        int             i_result        = 0x00;
        int             i_err;
        int             i_fd    = -0x01;
        const char      *pstr_binfile;
+       char    str_binfilepath[DRD64_MAX_PATH];
        Byte    *pb_head;
        LibFileType_FileType    t_ftype;
        LibGoblin_BinaryFile    *p_bfile;
@@ -58,12 +59,28 @@ int
        p_bfile = p_binfo->p_binfile;
        assert( NULL != p_bfile );
 
+       if ( LIBGOBLIN_BINFO_PHASE_SETPROG != p_binfo->b_phase )        {
+               return -0x01;
+       }
+               
+       strncpy( str_binfilepath, p_bfile->str_localpath, DRD64_MAX_PATH);
+       strcat( str_binfilepath, "/" );
+       strncat( str_binfilepath, p_bfile->str_filename, DRD64_MAX_PATH);
+       pstr_binfile    = p_bfile->str_localpath;
+       if( '\0' == pstr_binfile )      {
+               return -0x02;
+       }
+
+/*
        if( NULL == pstr_filepath )             {
                if ( LIBGOBLIN_BINFO_PHASE_SETPROG != p_binfo->b_phase )        {
                        return -0x01;
                }
                
-               pstr_binfile    = p_bfile->str_path;
+               strncpy( str_binfilepath, p_bfile->str_localpath, DRD64_MAX_PATH);
+               strcat( str_binfilepath, "/" );
+               strncat( str_binfilepath, p_bfile->str_filename, DRD64_MAX_PATH);
+               pstr_binfile    = p_bfile->str_localpath;
                if( '\0' == pstr_binfile )      {
                        return -0x02;
                }
@@ -73,18 +90,22 @@ int
                        return -0x03;
                }
                
-               pstr_binfile    = pstr_filepath;
+               // SetProgramPath ??!! 
+               //pstr_binfile  = pstr_filepath;
+               strncpy( str_binfilepath, pstr_filepath, DRD64_MAX_PATH);
+               return -0xff;
        }
+*/
 
        /* Open Test LM */
-       i_fd    = open( pstr_binfile, O_RDONLY );
+       i_fd    = open( str_binfilepath, O_RDONLY );
        if( -1 >= i_fd )        {
                i_result        = -0x10;
                goto    goto_LibGoblin_ReadBinary_File_post;
        }
 
        /* Get FileSize & FileType by LibFileType */
-       i_err   = LibFileType_CheckFileType( &t_ftype, pstr_binfile, i_fd );
+       i_err   = LibFileType_CheckFileType( &t_ftype, str_binfilepath, i_fd );
        if( 0x00 != i_err )     {
                close( i_fd );
                i_result        = -0x11;
@@ -109,8 +130,9 @@ int
        p_bfile->i_fd           = i_fd;
        p_bfile->dw_flag        = LIBGOBLIN_BINFO_FILE_MMAP;
        p_binfo->b_phase        = LIBGOBLIN_BINFO_PHASE_BINREAD;
-       if( NULL != pstr_filepath )
-               { strncpy( p_bfile->str_path, pstr_binfile, DRD64_MAX_PATH ); }
+       // XXX NO use??
+       //if( NULL != pstr_filepath )
+               //{ strncpy( p_bfile->str_localpath, pstr_binfile, DRD64_MAX_PATH ); }
 
        //i_result      = LibGoblin_AnalyzeBinary( p_binfo, i_filetype );
         
index 38e9832..6b05060 100644 (file)
@@ -47,7 +47,8 @@ Comment:
 
 LIBGOBLIN_READBIN_EXTERN
        int LibGoblin_ReadBinary_File(
-                               LibGoblin_BinaryInfo *p_binfo, const char *pstr_filepath );
+                               LibGoblin_BinaryInfo *p_binfo );
+                               //LibGoblin_BinaryInfo *p_binfo, const char *pstr_filepath );
 LIBGOBLIN_READBIN_EXTERN
        int LibGoblin_ReadBinary_Memory(
                                LibGoblin_BinaryInfo *p_binfo, Byte *pb_data, DWord dw_size );
diff --git a/libgoblin/drd64_libgoblin_system.c b/libgoblin/drd64_libgoblin_system.c
deleted file mode 100644 (file)
index 2a5ec06..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*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_SYSTEM
-#include"drd64_libgoblin.h"
-
-
-/*----------------------------------------------------------------------
-----------------------------------------------------------------------*/
-LIBGOBLIN_API_SYSTEM
-int
-       LibGoblin_Init(
-               void )
-{
-       int             i_err;
-       
-       i_err   = LibFileType_Init();
-       if( 0x00 != i_err )             { return i_err; }
-
-       i_err   = LibGoblin_ProgInfo_Init();
-       if( 0x00 != i_err )             { return i_err; }
-
-       i_err   = LibGoblin_BinInfo_Init();
-       if( 0x00 != i_err )             { return i_err; }
-
-       i_err   = LibGoblin_SymWork_Init();
-       if( 0x00 != i_err )             { return i_err; }
-
-       return 0x00;
-}
-
-
-/*----------------------------------------------------------------------
-----------------------------------------------------------------------*/
-LIBGOBLIN_API_SYSTEM
-int
-       LibGoblin_Term(
-               void )
-{
-       int             i_err;
-
-       i_err   = LibGoblin_SymWork_Term();
-       if( 0x00 != i_err )             { return i_err; }
-
-       i_err   = LibGoblin_BinInfo_Term();
-       if( 0x00 != i_err )             { return i_err; }
-
-       i_err   = LibGoblin_ProgInfo_Term();
-       if( 0x00 != i_err )             { return i_err; }
-
-       i_err   = LibFileType_Term();
-       if( 0x00 != i_err )             { return i_err; }
-
-       return 0x00;
-}
-
-
-/* EOF of drd64_.c ----------------------------------- */
index 945ee3b..04b8339 100644 (file)
@@ -91,17 +91,6 @@ typedef      struct  {
 
 
 /*=====================================================================*/
-/*
-typedef struct  {
-       int             i_id;
-       char    str_libfilepath[DRD64_MAX_PATH];
-       char    str_librealpath[DRD64_MAX_PATH];
-       char    str_rpath[DRD64_MAX_PATH];
-       void    *p_nextlib;
-} LibGoblin_LibraryInfo;
-*/
-
-/*=====================================================================*/
 typedef struct {
        int                     i_id;
        int                     i_refcount;
@@ -109,9 +98,16 @@ typedef struct      {
        /* Binary-File Info. */
        int                     i_fd;
        DWord           dw_flag;
+
+       // EXEC-program / shared lib. filename (without directry)
        char            str_filename[DRD64_MAX_PATH];
-       char            str_path[DRD64_MAX_PATH];
-       char            str_rpath[DRD64_MAX_PATH];              // .dyn Section rpath
+       //char          str_newpath[DRD64_MAX_PATH];    // nonuse
+       char            str_localpath[DRD64_MAX_PATH];  // filepath in local machine path.(transported)
+       char            str_remotepath[DRD64_MAX_PATH]; // filepath in remote machine path.(local machine is NULL)
+
+       // .dynamic Section - rpath (.so location path - converted real-path) 
+       char            str_rpath[DRD64_MAX_PATH];
+
        LibFileType_FileType    t_ftype;
 
        /* Binary-File Memory Image Access Info. */
@@ -131,6 +127,8 @@ typedef struct      {
 #define        LIBGOBLIN_BINFO_PHASE_SETNAME   0x20
 #define        LIBGOBLIN_BINFO_PHASE_SETPROG   0x30
 #define        LIBGOBLIN_BINFO_PHASE_BINREAD   0x40
+#define        LIBGOBLIN_BINFO_PHASE_ELF1READ  0x51
+#define        LIBGOBLIN_BINFO_PHASE_ELF2READ  0x52
 #define        LIBGOBLIN_BINFO_PHASE_ANALYZED  0x50
 
 #define        LIBGOBLIN_BINFO_MAXFILES                3
@@ -157,10 +155,8 @@ typedef struct     {
        DWord           dw_max_addrinfo;
 
        /* Exec. File Info. */
+       int                     i_parent_bid;
        char            str_filename[DRD64_MAX_PATH];
-       char            str_path[DRD64_MAX_PATH];
-       char            str_rpath[DRD64_MAX_PATH];              // .dynamic Section - rpath (.so location path)
-       int                     i_req_bid;
        
        LibGoblin_BinaryFile    *p_binfile;
 
@@ -170,7 +166,7 @@ typedef struct      {
        LibGoblin_SectionInfo   t_section[LIBGOBLIN_SECTION_ID_MAX];
        
        void            *pv_pginfo;
-       void            *pv_lib_binfile_next;   // NEW
+       void            *pv_binfo_next; // NEW
 
 }      LibGoblin_BinaryInfo;
 
@@ -187,10 +183,6 @@ typedef    struct  {
 
        int                                             i_opened_bid;
 
-
-       // Working Area
-       LibGoblin_LibraryFileList       t_libflist;
-
 }      LibGoblin_ProgramInfo;
 
 
index 63e35f1..2cc2d45 100644 (file)
@@ -53,8 +53,8 @@ int
        Test_LibGoblin_BinInfo();
        Test_LibGoblin_ProgInfo();
        Test_LibGoblin_BinaryFile();
-       Test_LibGoblin_ReadBinary();
        Test_LibGoblin_SymWork();
+       Test_LibGoblin_ReadBinary();
        Test_LibGoblin_LoadProg();
 
        CU_basic_run_tests();
index b8ad377..4c50410 100644 (file)
@@ -39,74 +39,50 @@ Comment:
 #include"test_libgoblin.h"
 
 
-/*--------------------------------------------------------------------*/
-int
-       Test_LibGoblin_LoadProg_ResolvLibraryFileList(
-                       LibGoblin_LibraryFileList       *p_libflist )
-{
-       int             i_cnt;
-       int             i_result;
-       int             i_items;
-       char    str_libname[DRD64_MAX_PATH];
-       char    *pstr_ldpath;
-       
-       i_items = p_libflist->i_end - p_libflist->i_start;
-
-       pstr_ldpath     = LibBrownie_GetLoadLibraryPath( LIBBROWNIE_LDHINTS_ELF64 );
-       if( NULL == pstr_ldpath )       { return -0x01; }
-
-       for( i_cnt = 0; i_cnt < i_items; i_cnt++ )      {
-               strncpy( str_libname, p_libflist->str_libfilepath[ i_cnt ], DRD64_MAX_PATH );
-
-               i_result        = LibBrownie_GetLibraryPath(
-                                                       p_libflist->str_libfilepath[ i_cnt ], str_libname,
-                                                       p_libflist->str_rpath[ i_cnt ], pstr_ldpath );
-               if( 0x00 != i_result )  { return -0x02; }
-
-               strncpy( p_libflist->str_librealpath[i_cnt],
-                                       p_libflist->str_libfilepath[i_cnt], DRD64_MAX_PATH );
-       }
-       
-       return 0x00;
-}
-
-
 /* LibGoblin_LoadProgram() API ****************************************/
 /*--------------------------------------------------------------------*/
 void Test_LibGoblin_LoadProg_API_LoadProgram_test00_001( void )
 {
        int             i_pgid;
        int             i_result;
+       char    *pstr_ldpath;
 
-       LibGoblin_LibraryFileList       *p_libflist;
+       LibGoblin_ObjectFilePath        t_objpath;
 
        i_result        = LibBrownie_Init();
        CU_ASSERT( 0x00 == i_result );
 
+       pstr_ldpath     = LibBrownie_GetLoadLibraryPath( LIBBROWNIE_LDHINTS_ELF64 );
+       if( NULL == pstr_ldpath )
+               { goto  goto_Test_LibGoblin_LoadProg_API_LoadProgram_test00_001_post; }
+
        i_result        = LibGoblin_Init();
        CU_ASSERT( 0x00 == i_result );
 
        i_pgid  = LibGoblin_AllocProgInfo();
        CU_ASSERT( 0x00 <= i_result );
 
-       p_libflist      = LibGoblin_GetLibraryFileListArea( i_pgid );
-       CU_ASSERT( NULL != p_libflist );
-
        i_result        = LibGoblin_LoadProgram_Main( i_pgid, "../testdata/dwarftest",
-                                                                                       "../testdata/dwarftest", p_libflist );
+                                                                                       "../testdata/dwarftest" );
        CU_ASSERT( 0x00 == i_result );
 
-       do      {
-               i_result        = Test_LibGoblin_LoadProg_ResolvLibraryFileList( p_libflist );
+
+       while( 0x00 < LibGoblin_GetUnresolv_ObjectFilePath( i_pgid, &t_objpath ) )      {
+               i_result        = LibBrownie_GetLibraryPath(
+                                                       t_objpath.str_localpath,
+                                                       t_objpath.str_filename, t_objpath.str_rpath, pstr_ldpath );
                CU_ASSERT( 0x00 == i_result );
+               if( 0x00 != i_result )
+                       { goto  goto_Test_LibGoblin_LoadProg_API_LoadProgram_test00_001_post; }
 
-               LibGoblin_Debug_Elf_PrintLibFileList( p_libflist, 0xff );
+               printf("  file= %s, rpath= %s\n      => localpath: %s\n", 
+                                       t_objpath.str_filename, t_objpath.str_rpath, t_objpath.str_localpath );
 
-               i_result        = LibGoblin_LoadProgram_Library( i_pgid, p_libflist );
+               i_result        = LibGoblin_SetPathAndLoad_ObjectFilePath( &t_objpath );
                CU_ASSERT( 0x00 == i_result );
-       }while( p_libflist->i_start < p_libflist->i_end );
-
-       LibBrownie_FreeLoadLibraryPath( LIBBROWNIE_LDHINTS_ELF64 );
+               if( 0x00 != i_result )
+                       { goto  goto_Test_LibGoblin_LoadProg_API_LoadProgram_test00_001_post; }
+       }
 
        i_result        = LibGoblin_FreeProgInfo( i_pgid );
        CU_ASSERT( 0x00 == i_result );
@@ -114,6 +90,9 @@ void Test_LibGoblin_LoadProg_API_LoadProgram_test00_001( void )
        i_result        = LibGoblin_Term();
        CU_ASSERT( 0x00 == i_result );
 
+       LibBrownie_FreeLoadLibraryPath( LIBBROWNIE_LDHINTS_ELF64 );
+
+goto_Test_LibGoblin_LoadProg_API_LoadProgram_test00_001_post:
        LibBrownie_Term();
 
        return;
index 271f650..8cd5871 100644 (file)
@@ -50,14 +50,16 @@ void Test_LibGoblin_ReadBinary_File_test00_001( void )
        i_result        = LibGoblin_Init();
        CU_ASSERT( 0x00 == i_result );
 
-       i_binfoid       = LibGoblin_AllocBinInfo( -1, "dwarftest", "../testdata/" );
+       i_binfoid       = LibGoblin_AllocBinInfo( -1, "dwarftest" );
        CU_ASSERT( 0x00 == i_binfoid );
 
        p_binfo = LibGoblin_BinInfo_GetBinInfo( i_binfoid );
        CU_ASSERT( NULL != p_binfo );
 
-       i_result        = LibGoblin_ReadBinary_File( p_binfo,
-                                               "../testdata/dwarftest" );
+       i_result        = LibGoblin_BinInfo_SetProgramPath( p_binfo, NULL, "../testdata" );
+       CU_ASSERT( 0x00 == i_result );
+
+       i_result        = LibGoblin_ReadBinary_File( p_binfo );
        CU_ASSERT( 0x00 == i_result );
 
        i_result        = LibGoblin_Debug_Elf_PrintSectionTable( p_binfo, 0xff );
@@ -89,16 +91,17 @@ void Test_LibGoblin_ReadBinary_File_test00_002( void )
        i_result        = LibGoblin_Init();
        CU_ASSERT( 0x00 == i_result );
 
-       i_binfoid       = LibGoblin_AllocBinInfo( -1, "dwarftest", "../testdata/" );
+       i_binfoid       = LibGoblin_AllocBinInfo( -1, "dwarftest" );
        CU_ASSERT( 0x00 == i_binfoid );
 
        p_binfo = LibGoblin_BinInfo_GetBinInfo( i_binfoid );
        CU_ASSERT( NULL != p_binfo );
 
        i_result        = LibGoblin_BinInfo_SetProgramPath( p_binfo,
-                                               "../testdata/dwarftest", "../testdata/dwarftest" );
+                                               "../testdata/", "../testdata/" );
+       CU_ASSERT( 0x00 == i_result );
 
-       i_result        = LibGoblin_ReadBinary_File( p_binfo, NULL );
+       i_result        = LibGoblin_ReadBinary_File( p_binfo );
        CU_ASSERT( 0x00 == i_result );
 
        i_result        = LibGoblin_ReadBinary_FreeBinary( p_binfo );
@@ -129,12 +132,15 @@ void Test_LibGoblin_ReadBinary_Memory_test00_001( void )
        i_result        = LibGoblin_Init();
        CU_ASSERT( 0x00 == i_result );
 
-       i_binfoid       = LibGoblin_AllocBinInfo( -1, "dwarftest", "../testdata/" );
+       i_binfoid       = LibGoblin_AllocBinInfo( -1, "dwarftest" );
        CU_ASSERT( 0x00 == i_binfoid );
 
        p_binfo = LibGoblin_BinInfo_GetBinInfo( i_binfoid );
        CU_ASSERT( NULL != p_binfo );
 
+       i_result        = LibGoblin_BinInfo_SetProgramPath( p_binfo, NULL, "../testdata" );
+       CU_ASSERT( 0x00 == i_result );
+
        i_fd    = open( "../testdata/dwarftest", O_RDONLY );
        CU_ASSERT( 0 <= i_fd );
 
@@ -183,7 +189,6 @@ int
                                                                 Test_LibGoblin_ReadBinary_File_test00_002 );
        CU_add_test( pt_goblin, "LibGoblin_ReadBinary_Memory_test00_001",
                                                                 Test_LibGoblin_ReadBinary_Memory_test00_001 );
-
        return 0x00;
 }