if( -1 < p_binfo->i_parent_bid ) {
p_binfo_parent = BinaryInfo_GetBinInfo( p_binfo->i_parent_bid );
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 ); }
+ if( NULL != p_bfile ) {
+ strncpy( p_objpath->str_rpath, p_bfile->str_rpath, DRD64_MAX_PATH );
+ strncpy( p_objpath->str_runpath, p_bfile->str_runpath, DRD64_MAX_PATH );
+ }
}
i_result = 0x01;
/*----------------------------------------------------------------------
+----------------------------------------------------------------------*/
+LIBGOBLIN_BINFO_EXTERN
+int
+ BinaryInfo_SetRunPath(
+ LibGoblin_BinaryInfo *p_binfo,
+ const char *pstr_runpath )
+{
+ int i_len;
+ 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 = BinaryFile_GetBinaryFile( p_binfo->i_binfile );
+ assert( NULL != p_binfile );
+
+ memset( str_src, 0x00, MAXPATHLEN );
+
+ // 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_runpath, (MAXPATHLEN - i_len - 1) );
+
+ pstr_result = realpath( str_src, str_dest );
+ if( NULL == pstr_result ) {
+ return -0x02;
+ }
+
+ i_len = strnlen( str_dest, MAXPATHLEN );
+ if( DRD64_MAX_PATH <= i_len ) {
+ return -0x03;
+ }
+ strncpy( p_binfile->str_runpath, str_dest, DRD64_MAX_PATH );
+
+ return 0x00;
+}
+
+
+/*----------------------------------------------------------------------
pstr_progpath: Absolute & Relative Path in this-machine program.
Absolute Path ONLY in remote-machine program.
* pstr_progpath != pstr_realpath is remote-machine program.
LibGoblin_BinaryInfo *p_binfo )
{
int i_binfoid;
- int i_result;
LibGoblin_BinaryFile *p_binfile;
if( NULL == p_binfo ) { return 0x01; }
int BinaryInfo_SetRPath(
LibGoblin_BinaryInfo *p_binfo, const char *pstr_rpath );
LIBGOBLIN_BINFO_EXTERN
+ int BinaryInfo_SetRunPath(
+ LibGoblin_BinaryInfo *p_binfo, const char *pstr_runpath );
+LIBGOBLIN_BINFO_EXTERN
int BinaryInfo_SetProgramPath(
LibGoblin_BinaryInfo *p_binfo, const char *pstr_progpath, const char *pstr_realpath );
LIBGOBLIN_BINFO_EXTERN
else if( DT_RPATH == qw_tag ) {
BinaryInfo_SetRPath( p_binfo, (const char *)(pb_dynstr + qw_value) );
}
+ else if( DT_RUNPATH == qw_tag ) {
+ BinaryInfo_SetRunPath( p_binfo, (const char *)(pb_dynstr + qw_value) );
+ }
//else if( DT_SONAME == qw_tag ) { }
pb_data += i_sz_elfdyn;
// .dynamic Section - rpath (.so location path - converted real-path)
char str_rpath[DRD64_MAX_PATH];
+ // .dynamic Section - runpath (.so location path - converted real-path)
+ char str_runpath[DRD64_MAX_PATH];
LibFileType_FileType t_ftype;
int i_pgid;
int i_result;
char *pstr_ldpath;
+ char *pstr_env_ldlibpath;
LibGoblin_ObjectFilePath t_objpath;
if( NULL == pstr_ldpath )
{ goto goto_Test_LibGoblin_LoadProg_API_LoadProgram_test00_001_post; }
+ pstr_env_ldlibpath = getenv("LD_LIBRARY_PATH");
+
i_result = LibGoblin_Init();
CU_ASSERT( 0x00 == i_result );
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 )
+ t_objpath.str_filename,
+ t_objpath.str_rpath,
+ t_objpath.str_runpath,
+ pstr_env_ldlibpath,
+ pstr_ldpath );
+
+ CU_ASSERT( 0x00 < i_result );
+ if( 0x00 >= i_result )
{ goto goto_Test_LibGoblin_LoadProg_API_LoadProgram_test00_001_post; }
- printf(" file= %s, rpath= %s\n => localpath: %s\n",
- t_objpath.str_filename, t_objpath.str_rpath, t_objpath.str_localpath );
+ printf(" file= %s, DT_RPATH= %s, DT_RUNPATH=%s\n => localpath: %s\n",
+ t_objpath.str_filename, t_objpath.str_rpath,
+ t_objpath.str_runpath, t_objpath.str_localpath );
i_result = LibGoblin_SetPathAndLoad_ObjectFilePath( &t_objpath );
CU_ASSERT( 0x00 == i_result );