home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!mintaka.lcs.mit.edu!hal.gnu.ai.mit.edu!mycroft
- From: mycroft@hal.gnu.ai.mit.edu (Charles Hannum)
- Newsgroups: comp.unix.aix
- Subject: Re: Shared libraries sharing from main app?
- Message-ID: <1992Aug21.173329.1517@mintaka.lcs.mit.edu>
- Date: 21 Aug 92 17:33:29 GMT
- References: <1992Aug20.220555.25326@spss.com> <MARC.92Aug21090935@marc.watson.ibm.com>
- Sender: news@mintaka.lcs.mit.edu
- Organization: /etc/organization
- Lines: 146
-
-
- In article <MARC.92Aug21090935@marc.watson.ibm.com> marc@watson.ibm.com
- (Marc Auslander) writes:
- >
- > It is possible to build a shared library which imports a symbol from
- > the main (i.e. exec'd) program. However, the facility is clumsy,
-
- Agreed on that much.
-
- > because the shared library must contain the actual file name of the
- > exec'd program.
-
- Not true.
-
-
- Here's an example of how to make this junk work. Note that apparently
- some version of the automounter "fix" makes this not work. Don't ask
- me why; I don't know and I really don't want to.
-
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of shell archive."
- # Contents: Makefile feh.c feh.exp foo.c foo.exp foo.imp
- # Wrapped by mycroft@hal.gnu.ai.mit.edu on Fri Aug 21 13:27:02 1992
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'Makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Makefile'\"
- else
- echo shar: Extracting \"'Makefile'\" \(271 characters\)
- sed "s/^X//" >'Makefile' <<'END_OF_FILE'
- XCFLAGS = -g
- XLFLAGS = # -bnogc
- X
- Xall: feh
- X
- Xfoo.a: foo.o
- X rm -f foo.a shr.o
- X ld -o shr.o -bM\:SRE -bI\:foo.imp -bE\:foo.exp foo.o -lc
- X ar clq foo.a shr.o
- X rm -f shr.o
- X
- Xfeh: foo.a feh.o
- X cc -o feh feh.o -bE\:feh.exp -L. foo.a
- X
- Xclean:
- X rm -f feh feh.o foo.a shr.o foo.o core
- END_OF_FILE
- if test 271 -ne `wc -c <'Makefile'`; then
- echo shar: \"'Makefile'\" unpacked with wrong size!
- fi
- # end of 'Makefile'
- fi
- if test -f 'feh.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'feh.c'\"
- else
- echo shar: Extracting \"'feh.c'\" \(204 characters\)
- sed "s/^X//" >'feh.c' <<'END_OF_FILE'
- X#include <sys/types.h>
- X#include <sys/ldr.h>
- X
- Xextern void foo (void);
- X
- Xchar bar[] = "Crash and burn!";
- X
- Xint
- Xmain (int argc, char **argv, char **envp)
- X{
- X loadbind (0, main, foo);
- X puts (bar);
- X foo ();
- X}
- END_OF_FILE
- if test 204 -ne `wc -c <'feh.c'`; then
- echo shar: \"'feh.c'\" unpacked with wrong size!
- fi
- # end of 'feh.c'
- fi
- if test -f 'feh.exp' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'feh.exp'\"
- else
- echo shar: Extracting \"'feh.exp'\" \(4 characters\)
- sed "s/^X//" >'feh.exp' <<'END_OF_FILE'
- Xbar
- END_OF_FILE
- if test 4 -ne `wc -c <'feh.exp'`; then
- echo shar: \"'feh.exp'\" unpacked with wrong size!
- fi
- # end of 'feh.exp'
- fi
- if test -f 'foo.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'foo.c'\"
- else
- echo shar: Extracting \"'foo.c'\" \(120 characters\)
- sed "s/^X//" >'foo.c' <<'END_OF_FILE'
- X#include <stdio.h>
- X
- Xextern char bar[];
- X
- Xvoid
- Xfoo (void)
- X{
- X printf ("bar is at 0x%08lx\n", (long) bar);
- X puts (bar);
- X}
- END_OF_FILE
- if test 120 -ne `wc -c <'foo.c'`; then
- echo shar: \"'foo.c'\" unpacked with wrong size!
- fi
- # end of 'foo.c'
- fi
- if test -f 'foo.exp' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'foo.exp'\"
- else
- echo shar: Extracting \"'foo.exp'\" \(4 characters\)
- sed "s/^X//" >'foo.exp' <<'END_OF_FILE'
- Xfoo
- END_OF_FILE
- if test 4 -ne `wc -c <'foo.exp'`; then
- echo shar: \"'foo.exp'\" unpacked with wrong size!
- fi
- # end of 'foo.exp'
- fi
- if test -f 'foo.imp' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'foo.imp'\"
- else
- echo shar: Extracting \"'foo.imp'\" \(7 characters\)
- sed "s/^X//" >'foo.imp' <<'END_OF_FILE'
- X#!
- Xbar
- END_OF_FILE
- if test 7 -ne `wc -c <'foo.imp'`; then
- echo shar: \"'foo.imp'\" unpacked with wrong size!
- fi
- # end of 'foo.imp'
- fi
- echo shar: End of shell archive.
- exit 0
-
- --
- \ Charles Hannum, mycroft@ai.mit.edu
- /\ White heterosexual atheist male (WHAM) pride!
-