home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / aix / 8044 < prev    next >
Encoding:
Text File  |  1992-07-21  |  2.1 KB  |  52 lines

  1. Newsgroups: comp.unix.aix
  2. Path: sparky!uunet!newsgate.watson.ibm.com!yktnews!admin!minnie!gerth
  3. From: gerth@watson.ibm.com (John Gerth)
  4. Subject: Re: Changing LIBPATH in an Executable
  5. Summary: Try reprocessing with -L  
  6. Sender: news@watson.ibm.com (NNTP News Poster)
  7. Message-ID: <1992Jul22.014432.24045@watson.ibm.com>
  8. Date: Wed, 22 Jul 1992 01:44:32 GMT
  9. Disclaimer: This posting represents the poster's views, not necessarily those of IBM
  10. References: <QeP7NVr0Bwxa8l5shq@transarc.com>
  11. Nntp-Posting-Host: minnie.watson.ibm.com
  12. Organization: IBM T.J. Watson Research Center
  13. Keywords: LIBPATH ld reprocessing
  14. Lines: 36
  15.  
  16. You should be able to do this with the existing facilities for
  17. 'cc' (or 'ld').  The libpath stored in a binary is determined
  18. at link time as the concatenation of any -L flags -- and
  19. /lib:/usr/lib.   
  20.  
  21. To alter the path of an existing binary, you can reprocess it
  22. adding -L flags.  For example:
  23.     cc -o fred fred.c
  24. Yields fred with a path of /lib:/usr/lib
  25. Reprocessing it with:
  26.     cc -o fred -L /usr/local/lib fred
  27. or
  28.     ld -o fred -lc -L/usr/local/lib fred
  29. Yields fred with a path of /usr/local/lib:/lib:/usr/lib
  30.  
  31. Two caveats must be added to the preceding (these are just the
  32. way it is, I do not know why).  First if LIBPATH is not null
  33. when 'cc' or 'ld' is issued *and* no -L flags are specified, then the
  34. the value of LIBPATH is stored with the executable (overriding
  35. the /lib:/usr/lib provided by default).  However if *any* -L flag
  36. is found, LIBPATH is ignored and the normal behavior is restored.
  37. Second, versions of 'ld' at least as new as AIX 3.1.5 had a bug
  38. which caused them to erase the input binaries to reprocessing.
  39. For example, suppose I wanted to have a profiled version of fred:
  40.      cc -o fred fred.c
  41. followed by
  42.      cc -p -o fredp fred
  43. would erase fred!  This bug is fixed at least at the AIX 3.2.1 level.
  44.  
  45. I apologize for making reprocessing sound complicated.  For simple
  46. things like changing the stored libpath or replacing only a couple
  47. of functions is a big binary, it is usually easy and quite fast.
  48.  
  49.  
  50. -- 
  51. John Gerth     gerth@watson.ibm.com        (914) 784-7639
  52.