How to use chatr to change static library path in binary?


 
Thread Tools Search this Thread
Operating Systems HP-UX How to use chatr to change static library path in binary?
# 1  
Old 07-13-2012
How to use chatr to change static library path in binary?

I have solved this but now cannot recall the syntax. I want to strip or change the hard wired library paths on binaries I download from a repository. I do not have root and just want a personal install, but would rather not build every tool. I even posted the solution here once for others, but cannot find it.
Code:
$ bzip2 --help                                                                                                                        
/usr/lib/dld.sl: Can't open shared library: /usr/local/lib/libbz2.sl
/usr/lib/dld.sl: No such file or directory
Abort
$ whence bzip2
~/myroot/usr/local/bin/bzip2
$ find myroot -name libbz2.sl
myroot/usr/local/lib/libbz2.sl
$

---------- Post updated at 03:45 PM ---------- Previous update was at 02:53 PM ----------

I did something right, and now it works:
Code:
$ chatr +s enable -l /usr/local/lib/libbz2.sl myroot/usr/local/bin/bzip2
myroot/usr/local/bin/bzip2: 
   current values: 
         shared executable 
         shared library dynamic path search:
             SHLIB_PATH     enabled   second 
             embedded path  disabled  first  Not Defined
         shared library list:
             static    /usr/local/lib/libbz2.sl
             dynamic   /usr/lib/libc.2
         shared library binding:
             deferred 
         global hash table disabled
         plabel caching disabled
         global hash array size:1103
         global hash array nbuckets:3
         shared vtable support disabled
         explicit unloading enabled
         static branch prediction disabled
         executable from stack: D (default)
         kernel assisted branch prediction enabled
         lazy swap allocation disabled
         text segment locking disabled
         data segment locking disabled
         third quadrant private data space disabled
         fourth quadrant private data space disabled
         third quadrant global data space disabled
         data page size: D (default)
         instruction page size: D (default)
         nulptr references disabled
         shared library private mapping disabled
         shared library text merging disabled
   new values: 
         shared executable 
         shared library dynamic path search:
             SHLIB_PATH     enabled   second 
             embedded path  disabled  first  Not Defined
         shared library list:
             dynamic   /usr/local/lib/libbz2.sl
             dynamic   /usr/lib/libc.2
         shared library binding:
             deferred 
         global hash table disabled
         plabel caching disabled
         global hash array size:1103
         global hash array nbuckets:3
         shared vtable support disabled
         explicit unloading enabled
         static branch prediction disabled
         executable from stack: D (default)
         kernel assisted branch prediction enabled
         lazy swap allocation disabled
         text segment locking disabled
         data segment locking disabled
         third quadrant private data space disabled
         fourth quadrant private data space disabled
         third quadrant global data space disabled
         data page size: D (default)
         instruction page size: D (default)
         nulptr references disabled
         shared library private mapping disabled
         shared library text merging disabled
$ bzip2 --help
bzip2, a block-sorting file compressor.  Version 1.0.6, 6-Sept-2010.
   usage: bzip2 [flags and input files in any order]
   -h --help           print this message
   -d --decompress     force decompression
   -z --compress       force compression
   -k --keep           keep (don't delete) input files
   -f --force          overwrite existing output files
   -t --test           test compressed file integrity
   -c --stdout         output to standard out
   -q --quiet          suppress noncritical error messages
   -v --verbose        be verbose (a 2nd -v gives more)
   -L --license        display software version & license
   -V --version        display software version & license
   -s --small          use less memory (at most 2500k)
   -1 .. -9            set block size to 100k .. 900k
   --fast              alias for -1
   --best              alias for -9
   If invoked as `bzip2', default action is to compress.
              as `bunzip2',  default action is to decompress.
              as `bzcat', default action is to decompress to stdout.
   If no file names are given, bzip2 compresses or decompresses
   from standard input to standard output.  You can combine
   short flags, so `-v -4' means the same as -v4 or -4v, &c.
$ ldd -rsv local/bin/bzip2
  find library=/usr/lib/libc.2; required by local/bin/bzip2
    search path=/usr/lib:/usr/local/lob:/dhome1/n/nbkodln/local/lib  (SHLIB_PATH)
    trying path=/usr/lib/libc.2
        /usr/lib/libc.2 =>      /usr/lib/libc.2
  find library=/usr/lib/libdld.2; required by /usr/lib/libc.2
    search path=/usr/lib:/usr/local/lob:/dhome1/n/nbkodln/local/lib  (SHLIB_PATH)
    trying path=/usr/lib/libdld.2
        /usr/lib/libdld.2 =>    /usr/lib/libdld.2
  find library=/usr/lib/libc.2; required by implicit load
    search path=/usr/lib:/usr/local/lob:/dhome1/n/nbkodln/local/lib  (SHLIB_PATH)
    trying path=/usr/lib/libc.2
        /usr/lib/libc.2 =>      /usr/lib/libc.2
  find library=/usr/local/lib/libbz2.sl; required by local/bin/bzip2
    search path=/usr/lib:/usr/local/lob:/dhome1/n/nbkodln/local/lib  (SHLIB_PATH)
    trying path=/usr/lib/libbz2.0
    trying path=/usr/local/lob/libbz2.0
    trying path=/dhome1/n/nbkodln/local/lib/libbz2.0
    trying path=/usr/local/lib/libbz2.0  (absolute)
    search path=/usr/lib:/usr/local/lob:/dhome1/n/nbkodln/local/lib  (SHLIB_PATH)
    trying path=/usr/lib/libbz2.sl
    trying path=/usr/local/lob/libbz2.sl
    trying path=/dhome1/n/nbkodln/local/lib/libbz2.sl
        /usr/local/lib/libbz2.sl =>     /dhome1/n/nbkodln/local/lib/libbz2.sl
$

Word is that sometimes "+b disable" helps, if the files are not ELF.

This modifies your executbles in place, so it is a best practice to keep a copy of the original!
# 2  
Old 07-13-2012
# 3  
Old 07-13-2012
It is a cranky command, as I was getting errors about the missing library from chatr at first. Maybe just fat fingers and too much command recall! Thanks!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. IP Networking

Change source ip on static internet

Hi, Environment: Linux: Ubuntu 12.04 I am connected to internet using static ip. This means my internet provider Pacenet has assigned me static ip. Now, whenever I am trying to change source ip for tcp/ip (ip4) using iptables firewall, I am unable to access internet at all. Can anybody... (4 Replies)
Discussion started by: ashv
4 Replies

2. UNIX for Dummies Questions & Answers

Shared static library

Hello Please what does mean shared static library and LD-Preload? Thank you (3 Replies)
Discussion started by: chercheur857
3 Replies

3. Programming

Even the Static cURL Library Isn't Static

I'm writing a program which uses curl to be run on Linux PCs which will be used by a number of different users. I cannot make the users all install curl on their individual machines, so I have tried to link curl in statically, rather than using libcurl.so. I downloaded the source and created a... (8 Replies)
Discussion started by: BrandonShw
8 Replies

4. Shell Programming and Scripting

How to change Absolute path to Relative path

Hello, I have a doubt:- --------------------- Current script:- ################################################################################################ prefix=user@my-server: find . -depth -type d -name .git -printf '%h\0' | while read -d "" path ; do ( cd "$path" || exit $?... (4 Replies)
Discussion started by: sahil_jammu
4 Replies

5. Programming

Static and Shared Library in Makefile

I am having a devil of a time with a very simple make file. The program needs two shared and one static library. If I link the shared libraries only like below the mysql test app works ... (1 Reply)
Discussion started by: jadsys
1 Replies

6. Linux

Could static library include static library?

I have some static library(libxxx.a libyyy.a). And I want to generate my library(libzzz.a), libzzz.a will use libxxx.a and libyyy.a I wan't my application only use libzzz.a, (means libzzz.a had include libxxx.a, libyyy.a), how can I do that? Thank you. example: I have zzz.c. I do ... (4 Replies)
Discussion started by: freemagic
4 Replies

7. Programming

Adding a Static Library (libtimer.a) to the Makefile

Hi, The following is my Makefile, I wanted to add a staic library named libtimer.a. I'm using the following Makefile. Please let me know how to add this static library: Makefile:- It produces "usbserial" executable. Thanks, S (1 Reply)
Discussion started by: suryaemlinux
1 Replies

8. UNIX for Dummies Questions & Answers

Change static ip to dynamic ip

I had just install a solaris 10 server. I set the ip address to static during installation. I want to change it to dynamic but I don't know how. Expert here please help me! (5 Replies)
Discussion started by: jimmyysk
5 Replies

9. Shell Programming and Scripting

How to change a Makefile from building static library to shared library?

Hi: I have a library that it only offers Makefile for building static library. It built libxxx.a file. How do I in any way build a shared library? (either changin the Makefile or direct script or command to build shared library) Thanks. (1 Reply)
Discussion started by: cpthk
1 Replies

10. UNIX for Dummies Questions & Answers

where is unix-screen-binary path location

hi all, i wanna ask where is unix-screen-binary path location? i cannot find it in /usr/bin or /bin or using man command thx before (3 Replies)
Discussion started by: venven
3 Replies
Login or Register to Ask a Question