home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.aix
- Path: sparky!uunet!newsgate.watson.ibm.com!yktnews!admin!minnie!gerth
- From: gerth@watson.ibm.com (John Gerth)
- Subject: Re: Changing LIBPATH in an Executable
- Summary: Try reprocessing with -L
- Sender: news@watson.ibm.com (NNTP News Poster)
- Message-ID: <1992Jul22.014432.24045@watson.ibm.com>
- Date: Wed, 22 Jul 1992 01:44:32 GMT
- Disclaimer: This posting represents the poster's views, not necessarily those of IBM
- References: <QeP7NVr0Bwxa8l5shq@transarc.com>
- Nntp-Posting-Host: minnie.watson.ibm.com
- Organization: IBM T.J. Watson Research Center
- Keywords: LIBPATH ld reprocessing
- Lines: 36
-
- You should be able to do this with the existing facilities for
- 'cc' (or 'ld'). The libpath stored in a binary is determined
- at link time as the concatenation of any -L flags -- and
- /lib:/usr/lib.
-
- To alter the path of an existing binary, you can reprocess it
- adding -L flags. For example:
- cc -o fred fred.c
- Yields fred with a path of /lib:/usr/lib
- Reprocessing it with:
- cc -o fred -L /usr/local/lib fred
- or
- ld -o fred -lc -L/usr/local/lib fred
- Yields fred with a path of /usr/local/lib:/lib:/usr/lib
-
- Two caveats must be added to the preceding (these are just the
- way it is, I do not know why). First if LIBPATH is not null
- when 'cc' or 'ld' is issued *and* no -L flags are specified, then the
- the value of LIBPATH is stored with the executable (overriding
- the /lib:/usr/lib provided by default). However if *any* -L flag
- is found, LIBPATH is ignored and the normal behavior is restored.
- Second, versions of 'ld' at least as new as AIX 3.1.5 had a bug
- which caused them to erase the input binaries to reprocessing.
- For example, suppose I wanted to have a profiled version of fred:
- cc -o fred fred.c
- followed by
- cc -p -o fredp fred
- would erase fred! This bug is fixed at least at the AIX 3.2.1 level.
-
- I apologize for making reprocessing sound complicated. For simple
- things like changing the stored libpath or replacing only a couple
- of functions is a big binary, it is usually easy and quite fast.
-
-
- --
- John Gerth gerth@watson.ibm.com (914) 784-7639
-