removing library path


 
Thread Tools Search this Thread
Operating Systems HP-UX removing library path
# 1  
Old 11-13-2007
removing library path

Hi Everyone

I have written an installer dependant on several shared libraries. I am attempting to strip the full path from these dependant libraries using the chatr command via a script file but am having no success. Running ldd on the intaller exe fails with the following error. Cant open shared library: error followed by the original full library path.

The chatr command I am using is below

chatr +s enable +b disable -l <librarypath1> -l <librarypath2> <installer_exe>

Is this the correct approach to stripping paths from libraries and if so where am I going wrong.

Thanks
Ed
# 2  
Old 11-13-2007
My approach has been to build the shared libraries using the ld option +cdp to change the recorded library name to strip the prefixed path.
# 3  
Old 11-13-2007
Semi-answer from non-HP expert

According to the man page, "+b disable" is not allowed for "ELF" binaries. If you type ...
Code:
file <program name>

You might see something like ...
Code:
... ELF 32-bit executable

Then this is the problem. Also, I'm not sure what you're trying to do can really be done here. The chatr command is documented to say that it tells the OS to ignore the embedded paths. It sounds like you want to remove these paths, as a way of hiding software development details. I think that has to be done at linking time.
# 4  
Old 11-14-2007
Here is a script I use to prefix a link command which I use to strip the leading paths.

I do this by executing the build command and looking at the resulting binary and it's dynamic references then rebuilding the binary.

There are a couple of required variables for this to work, mainly SHLB_REF_STRONG is a PATH like list of directories that should be stripped, these are then matched against the referenced library, if it matches a -Wl,+cdp argument is added to the build line.

Then the binary is rebuilt.

Code:
#!/bin/sh
# author: porter@www.unix.com
# this is provided as is with no claim to be fit for any purpose
# do not remove this header

ORIGINAL_CMD=$@

if test "$LD" = ""
then
	LD=ld
fi

is_member()
{
	is_member_1=$1
	shift
	for is_member_i in $@
	do
		if test "$is_member_i" = "$is_member_1"
		then
			return 0
		fi
	done
	return 1
}

is_ld()
{
	for is_ld_i in $@
	do
		case "$is_ld_i" in
		$LD )
			return 0
			;;
		$CC )
			return 1;
			;;
		$CXX )
			return 1;
			;;
		* )
			;;
		esac
	done
	return 1
}

# echo $ORIGINAL_CMD=$ORIGINAL_CMD

SEARCH_PATHS="`echo $SHLB_REF_STRONG $SHLB_REF_WEAK | sed y/:/\\ /`"
STRIP_PATHS=

# echo SEARCH_PATHS=$SEARCH_PATHS

$ORIGINAL_CMD

RC=$?

if test "$RC" != "0"
then
	exit $RC
fi

PREV_FLAG=
OUTPUT_FILE=

for d in $ORIGINAL_CMD
do
	case "$d" in
	-o )
		PREV_FLAG=$d
		;;
	* )
		case "$PREV_FLAG" in
		-o )
			OUTPUT_FILE="$d"
			;;
		* )
			;;
		esac
		PREV_FLAG=
		;;
	esac
done

# echo OUTPUT_FILE=$OUTPUT_FILE

if test -f "$OUTPUT_FILE"
then
	for d in `chatr "$OUTPUT_FILE" | grep dynamic`
	do
		if test -f "$d"
		then
# echo POSSIBLE $d
			e=`dirname $d`
			if is_member $e $SEARCH_PATHS
			then
				STRIP_PATHS="$STRIP_PATHS $d"
			fi			
		fi
	done
else
	exit 0
fi

# echo STRIP_PATHS=$STRIP_PATHS

if test "$STRIP_PATHS" = ""
then
	exit 0
fi

rm $OUTPUT_FILE

NEW_CMD="$ORIGINAL_CMD"

for d in $STRIP_PATHS
do
	e=`basename $d`
	if is_ld $ORIGINAL_CMD
	then
		NEW_CMD="$NEW_CMD +cdp $d:$e"
	else
		NEW_CMD="$NEW_CMD -Wl,+cdp,$d:$e"
	fi
done

#echo CC=$CC
#echo CXX=$CXX
#echo LD=$LD
#echo NEW_CMD=$NEW_CMD

$NEW_CMD

RC=$?

# echo NEW_CMD returned $RC

if test "$RC" != "0"
then
	echo NEW_CMD returned $RC
	exit $RC
fi

# chatr $OUTPUT_FILE

# exit 1

# 5  
Old 11-19-2007
Hi Guys

Thanks for the suggestions however as usual my problem was in missing the obvious. It appears that the chatr command was doing its jobs perfectly in stripping the library path, run in a script straight after linking as below

chatr +s enable +b disable -l <librarypath1> -l <librarypath2> <installer_exe>

Unfortunately the second library path I had given it didn't exist and so the command failed with a nice verbal error message which I gobbled up in my script using a grep.

Fixed this and the chatr output on my problem exe changes form this...

HP-C8000 37% chatr install
install:
shared executable
shared library dynamic path search:
SHLIB_PATH disabled second
embedded path disabled first Not Defined
shared library list:
static /sources/my_lib.so
...

...to this ...

HP-C8000 45% chatr install
install:
shared executable
shared library dynamic path search:
SHLIB_PATH enabled first
embedded path disabled second Not Defined
shared library list:
dynamic /sources/mylib.so
...

Thanks again for the help

Ed
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

AIX full path to socket library

Can somebody help me too identify full path to socket library on AIX? Cannot find anything Thanks for contribution (2 Replies)
Discussion started by: digioleg54
2 Replies

2. Programming

Library/header path for ./configure

Hello, I am always confused about adding library path for ./configure when compiling software under Linux Debian based OS. For example the README of the software tells --with-boost=PATH specify directory for the boost header files --with-mpi=PATH specify prefix directory for... (4 Replies)
Discussion started by: yifangt
4 Replies

3. Programming

Boost library path for cmake & make

I was compiling a downloaded open source pkg. Following the install instruction, I did $ mkdir build; cd build; cmake ../; make but got error message:make: *** No rule to make target 'usr/lib64/lib64/libboost_graph-mt.so.5'. needed by ../bin.gam-create. stop make: *** Error 2 make: *** Error... (1 Reply)
Discussion started by: yifangt
1 Replies

4. Programming

C++ library path

Hello, How to set up the path for downloaded C/C++ libraries (or, header files) so that they can be included like system headers (stdio.h or iostream)? The libraries/headers are from a package containing different folders each has different sets of headers and put in... (1 Reply)
Discussion started by: yifangt
1 Replies

5. UNIX for Advanced & Expert Users

Can't find path for shared library: libintl.sl

Hello, Any inputs about this one? /usr/lib/dld.sl: Can't find path for shared library: libintl.sl /usr/lib/dld.sl: No such file or directory : Core file for 32-bit PA-RISC application : /tmp/usr/local/bin/git saved to /etc/core.git. ABORT instruction (core dumped) bash-4.0# echo... (3 Replies)
Discussion started by: SystemAddict
3 Replies

6. Shell Programming and Scripting

Library on Remote machine or $PATH is not working..

I don't know how to put this. However here is the problem. While executing command remotely on a Unix machine i get an error /usr/lib/hpux32/dld.so: Unable to find library 'libxerces-c.sl.21'. However when i execute the command on the remote machine locally. it works fine. Also i have... (2 Replies)
Discussion started by: suraj.sheikh
2 Replies

7. Shell Programming and Scripting

unix Library path variables.

Library path variables. I need to know the library rnvironment variable in linux. Ie, I install zlib directory in the custom path /usr/local/mylib and give --enable-zlib in the ffmpeg install, ffmpeg should check for the zlib libraries in the path /usr/local/mylib. Currently it checks /usr/lib... (5 Replies)
Discussion started by: anilcliff
5 Replies

8. UNIX for Advanced & Expert Users

library path in linux

Is there something which is an alternative to the variable LD_LIBRARY_PATH? The behaviour of this variable is that the path specified here will be checked before checking usual paths. But I want to have some folders checked for shared libraries after the usual paths. i.e usual paths have to... (3 Replies)
Discussion started by: bbala
3 Replies

9. Shell Programming and Scripting

Setting path for a stand alone library in home directory

Hi all, This is probably a basic question. I had installed a stand-alone library called szip in my home directory, as I don't have the necessary root permission. I tried to set an environment for both include and lib files in my .cshrc script as setenv /home/szip/lib setenv... (3 Replies)
Discussion started by: alamcheril
3 Replies

10. UNIX for Dummies Questions & Answers

library path

How do you get an application to use an alternate library? Dave:confused: (2 Replies)
Discussion started by: nucca
2 Replies
Login or Register to Ask a Question