home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!munnari.oz.au!uniwa!DIALix!zeus!zeus!not-for-mail
- From: peter@zeus.DIALix.oz.au (Peter Wemm)
- Newsgroups: comp.unix.sys5.r4
- Subject: Re: Incremental loading of objects into a running process under SVR4???
- Date: 14 Dec 1992 18:11:38 +0800
- Organization: Karam Pty. Ltd., Perth, Western Australia.
- Lines: 53
- Message-ID: <1ghmkqINNcp0@zeus.dialix.oz.au>
- References: <9515227@MVB.SAIC.COM>
- NNTP-Posting-Host: zeus.dialix.oz.au
- Keywords: SVR4 ELF executables, incremental loading
- X-Newsreader: NN version 6.4.19 #73
-
- jcp@logjam.trg.saic.com (John C. Peterson) writes:
-
- > I'm trying to port xlispstat to (Dell) SVR4. It has a facility where
- >the user can issue a command at runtime that will incrementally load the
- >specified C/Fortran .o object file and then execute it.
-
- > I'm still pretty new to SVR4, so my real question is if incremental
- >loading is possible, or some other mechanism for loading an object into
- >an already running process exists?
-
- >Thanks in Advance,
-
- > John
-
- SVR4 has dynamic linking built in. It is quite easy to
- do something like this.
-
- See the man pages for dlopen, dlsym, dlclose.
-
- You can use the -G flag to generate a shared object.
-
- ld -G -o libx.so libx1.o libx2.o libx3.o
-
- #include <dlfcn.h>
-
- main()
- {
- void *handle;
- int i, *iptr;
- int (*fptr)(int);
-
- /* open the needed object */
- handle = dlopen("/usr/mydir/libx.so", RTLD_LAZY);
-
- /* find address of function and data objects */
- fptr = (int (*)(int))dlsym(handle, "some_function");
-
- iptr = (int *)dlsym(handle, "int_object");
-
- /* invoke function, passing value of integer as a parameter */
-
- i = (*fptr)(*iptr);
- }
-
- >--
- >John C. Peterson KD6EKQ | (+1) 619-546-6539 | Disclaimer: The opinions
- >Science Application Intl. Corp. | jcp@trg.saic.com | expressed are mine alone,
- >10260 Campus Point Dr. MS-C6 | | and do not reflect those
- >San Diego, CA 92121 | | of SAIC.
- --
- Peter Wemm : peter@zeus.dialix.oz.au If it's broke, fix it (The MS-DOS way)
- Work phone: +61-9-479-1855 If it aint broke, don't touch it (The Unix way)
- Fax: +61-9-479-1134 If we can't fix it, it ain't broke (Maintainer's Motto)
-