home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!noc.near.net!bertha!ibm3.hyperdesk.com!adennie
- From: adennie@ibm3.hyperdesk.com (Andy Dennie)
- Newsgroups: comp.unix.aix
- Subject: problem load()-ing shared object
- Message-ID: <609@bertha.HyperDesk.com>
- Date: 21 Dec 92 22:41:04 GMT
- Sender: usenet@bertha.HyperDesk.com
- Reply-To: andy_d@hyperdesk.com
- Followup-To: comp.unix.aix
- Organization: HyperDesk Corporation, Westboro, MA
- Lines: 61
-
- I've been playing around with shared objects on AIX 3.2, and although I
- can successfully load and execute a simple function in a shared object,
- I'm stumped on the following problem: how do you load a shared object
- that contains references to globals defined in the program doing the
- loading? Below is a simple test case that illustrates the problem.
-
- Any help would be greatly appreciated!
-
- foo2.c contains:
- ----------------------------------------------------------------------
- #include <errno.h>
- #include <stdio.h>
- #include <sys/ldr.h>
-
- char global_string[] = "hello, world\n"; /* here's the global */
-
- main() {
- int (*pfunc)() = load("bar.so", 0, (char*)NULL);
-
- if (pfunc == 0) {
- printf("load failed, errno=%d\n", errno);
- }
- }
- ----------------------------------------------------------------------
-
-
- bar2.c contains:
- ----------------------------------------------------------------------
- extern char *global_string;
-
- void bar () {
- printf("%s", global_string);
- }
- ----------------------------------------------------------------------
-
- bar2.exp contains:
- ------------------
- bar
- ------------------
-
- bar2.imp contains:
- ------------------
- global_string
- ------------------
-
- % make foo2 bar2.so
- xlc -o foo2 -D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE foo2.c
- xlc -o bar2.so -bM:SRE -bE:bar2.exp -bI:bar2.imp -e _nostart bar2.c
- % foo2
- load failed, errno=8
-
-
- BTW, $LIBPATH contains the current directory, where bar2.so resides. I
- think I'm probably doing something wrong with bar2.imp. I've tried
- adding
-
- #!/pathname/of/foo
-
- to the beginning of it, but that didn't help. I also tried creating a
- foo2.exp file and linking foo2 with the -bE:foo2.exp switch (same
- results). Any ideas?
-