home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ogicse!das-news.harvard.edu!cantaloupe.srv.cs.cmu.edu!crabapple.srv.cs.cmu.edu!andrew.cmu.edu!<UNAUTHENTICATED>+
- From: Barry_Wolman@transarc.com
- Newsgroups: comp.unix.aix
- Subject: Changing LIBPATH in an Executable
- Message-ID: <QeP7NVr0Bwxa8l5shq@transarc.com>
- Date: 21 Jul 92 12:41:05 GMT
- Article-I.D.: transarc.QeP7NVr0Bwxa8l5shq
- Organization: Carnegie Mellon, Pittsburgh, PA
- Lines: 44
-
- I'd like to be able to change the LIBPATH stored in an executable. I
- realize I can use
- setenv LIBPATH ...
- to specify a LIBPATH that overrides the LIBPATH stored in an
- executable. Doing this presents a problem if one is dealing with
- multiple executables having different LIBPATH requirements.
-
- I tried writing a simple utility that did the following (I've glossed
- over some details):
-
- 1. Find the loader section header
-
- 2. Read and parse the import triples (path, base, and archive)
- specified by the loader section header
-
- 3. Replace the path component (LIBPATH) of the first import triple
- with the string specifying the new LIBPATH
-
- 4. Write the new import table at the end of the executable
-
- 5. Update the loader section header to reference the new import table
- (updated values for l_islen and l_impoff)
-
- 6. Rewrite the updated loader section header
-
- This partially works. When I used "dump -H" to display the import
- list for the modified file, it shows the new LIBPATH and the other
- information is unchanged. But, when I try to execute the resulting
- object module, I get
-
- perf[barry] hello
- Could not load program hello
- hello is not executable or not in correct XCOFF format
- Error was: Exec format error
-
- So, it appears that AIX may be making assumptions about the structure
- of the object module not reflected in the documentation. Does anyone
- know what else I need to change to get this utility to work? Even
- better, if such a utility already exists, where can I find it?
- I'll be glad to donate mine if I can finish it, but I'd rather just
- use an existing program.
-
- Thanks,
- Barry Wolman
-