lemieux@ireq.hydro.qc.ca (Lemieux) (06/18/91)
I have written an interpreter and I would like to dynamically link user-defined functions (external functions) to my program and execute them. I read the man page <ld(1)> but it's quite confusing for me. Is it possible to do such thing under SunOs 4.1.1 ? If it's possible, what steps do I have to follow ? Restrictions: ------------ - I want the users to compile and link their functions with all the necessary librairies (so they will be no unresolved external when I'll dynamically link them). - One object file must be built by external function. Thanks in advance. - Rick ----------------------------------------------------------------------------- Eric LEMIEUX | Internet: lemieux@ireq.hydro.qc.ca Institut de Recherche d'Hydro-Quebec | 1800 Montee Sainte-Julie | TEL: (514) 652-8139 Varennes, Quebec, Canada | FAX: (514) 652-8309 -----------------------------------------------------------------------------
simon@liasun2.epfl.ch (Simon Leinen) (06/18/91)
In article <7508@s3.ireq.hydro.qc.ca> lemieux@ireq.hydro.qc.ca (Lemieux) writes: [asks for the possibility of dynamically linking functions into a running program under SunOS 4.1.1] You should get Wilson Ho's Dld, the dynamic link/unlink editor. It currently runs on Vaxen, Suns (3 and 4), Sequent Symmetries and Atari STs and is rather easy to use. It can be found on prep.ai.mit.edu, anonymous FTP directory /pub/gnu: -rw-r--r-- 1 14910 wheel 161735 May 30 22:17 dld-3.2.3.tar.Z Have fun, -- Simon.
guy@auspex.auspex.com (Guy Harris) (06/21/91)
> [asks for the possibility of dynamically linking functions > into a running program under SunOS 4.1.1] > >You should get Wilson Ho's Dld, the dynamic link/unlink editor. He can also just use the routines described in the DLOPEN(3X) manual page if he's using SunOS 4.1[.x]; those routines are also in System V Release 4. > Restrictions: > ------------ > > - I want the users to compile and link their functions with all > the necessary librairies (so they will be no unresolved external > when I'll dynamically link them). If any of the libraries with which the user-defined module would be linked are shared libraries with which the interpreter was linked, that's not necessary; the dynamically-loaded code will get bound to the libraries in question when it's loaded. Otherwise, you'll have to link the dynamically-loaded code with the library (with the disadvantage that doing so will probably introduce non-position-independent code; that may mean that two processes using the same dynamically-loaded code won't share it all, if that matters, and may tickle some dynamic loader bugs). There's also a bug in the 4.1[.x] dynamic loader (which I'm told is absent from S5R4) such that it can't handle dynamically-loaded code if it has any BSS. A workaround is to: 1) open "/dev/zero"; 2) dup that file descriptor; 3) close the original file descriptor, leaving the dup'ed one open; as the first thing you do in "main()" (basically, the dynamic loader assumes "/dev/zero" is still open from when it was used to load the shared libraries; the above sequence re-opens it to what should be the same file descriptor number). A potential win of the "dlopen()" routines is portability; this doesn't matter for SunOS 4.1[.x], as "dld" is supported on all the platforms on which 4.1[.x] is supported, but may be a win for S5R4 - the dynamic loader has to be ported by the vendor, so you don't have to port it yourself to some new platform. (I.e., it should be in S5R4 for e.g. MIPS or the 88K; none of the platforms in the list of "dld" platforms have those chips.)