home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / unix / sys5 / r4 / 824 < prev    next >
Encoding:
Text File  |  1992-12-14  |  2.1 KB  |  67 lines

  1. Path: sparky!uunet!munnari.oz.au!uniwa!DIALix!zeus!zeus!not-for-mail
  2. From: peter@zeus.DIALix.oz.au (Peter Wemm)
  3. Newsgroups: comp.unix.sys5.r4
  4. Subject: Re: Incremental loading of objects into a running process under SVR4???
  5. Date: 14 Dec 1992 18:11:38 +0800
  6. Organization: Karam Pty. Ltd., Perth, Western Australia.
  7. Lines: 53
  8. Message-ID: <1ghmkqINNcp0@zeus.dialix.oz.au>
  9. References: <9515227@MVB.SAIC.COM>
  10. NNTP-Posting-Host: zeus.dialix.oz.au
  11. Keywords: SVR4 ELF executables, incremental loading
  12. X-Newsreader: NN version 6.4.19 #73
  13.  
  14. jcp@logjam.trg.saic.com (John C. Peterson) writes:
  15.  
  16. >   I'm trying to port xlispstat to (Dell) SVR4. It has a facility where
  17. >the user can issue a command at runtime that will incrementally load the
  18. >specified C/Fortran .o object file and then execute it.
  19.  
  20. >   I'm still pretty new to SVR4, so my real question is if incremental
  21. >loading is possible, or some other mechanism for loading an object into
  22. >an already running process exists?
  23.  
  24. >Thanks in Advance,
  25.  
  26. >  John
  27.  
  28. SVR4 has dynamic linking built in.  It is quite easy to
  29. do something like this.
  30.  
  31. See the man pages for dlopen, dlsym, dlclose.
  32.  
  33. You can use the -G flag to generate a shared object.
  34.  
  35. ld -G -o libx.so libx1.o libx2.o libx3.o
  36.  
  37. #include <dlfcn.h>
  38.  
  39. main()
  40. {
  41.   void *handle;
  42.   int i, *iptr;
  43.   int (*fptr)(int);
  44.  
  45.   /* open the needed object */
  46.   handle = dlopen("/usr/mydir/libx.so", RTLD_LAZY);
  47.  
  48.   /* find address of function and data objects */
  49.   fptr = (int (*)(int))dlsym(handle, "some_function");
  50.  
  51.   iptr = (int *)dlsym(handle, "int_object");
  52.  
  53.   /* invoke function, passing value of integer as a parameter */
  54.  
  55.   i = (*fptr)(*iptr);
  56. }
  57.  
  58. >-- 
  59. >John C. Peterson  KD6EKQ        | (+1) 619-546-6539 | Disclaimer: The opinions
  60. >Science Application Intl. Corp. |  jcp@trg.saic.com | expressed are mine alone,
  61. >10260 Campus Point Dr. MS-C6    |                   | and do not reflect those
  62. >San Diego, CA 92121             |                   | of SAIC.
  63. -- 
  64. Peter Wemm : peter@zeus.dialix.oz.au   If it's broke, fix it (The MS-DOS way)
  65. Work phone: +61-9-479-1855    If it aint broke, don't touch it (The Unix way)
  66. Fax: +61-9-479-1134   If we can't fix it, it ain't broke (Maintainer's Motto)
  67.