From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f8c9b,9af96ed078e3da0a,start X-Google-Attributes: gidf8c9b,public X-Google-Thread: 150775,9af96ed078e3da0a,start X-Google-Attributes: gid150775,public X-Google-Thread: fee84,9af96ed078e3da0a,start X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 1994-02-03 09:31:17 PST Xref: gmd.de comp.unix.osf.osf1:2135 comp.unix.questions:28093 Newsgroups: comp.unix.osf.osf1,comp.unix.questions,cmu.cs.unix.forum Path: gmd.de!xlink.net!rz.uni-karlsruhe.de!news.uni-stuttgart.de!news.belwue.de!news.dfn.de!news.dfn.de!zib-berlin.de!zrz.TU-Berlin.DE!netmbx.de!Germany.EU.net!EU.net!howland.reston.ans.net!europa.eng.gtefsd.com!fs7.ece.cmu.edu!honeydew.srv.cs.cmu.edu!eiger.edrc.cmu.edu!snl From: snl@paneer.ndim.edrc.cmu.edu (Sean Levy) Subject: dynamic loading/dumping out of binaries revisited Message-ID: Summary: getting dynamic loading and unexec to work together under osf/1 Keywords: osf/1, dynamic loading, unexec, portability Sender: news@cs.cmu.edu (Usenet News System) Nntp-Posting-Host: paneer.ndim.edrc.cmu.edu Reply-To: snl+@cmu.edu Organization: n-dim Group, Engineering Design Research Center, CMU Date: Thu, 3 Feb 1994 17:31:17 GMT [Preamble: I appologize if this gets posted twice, but our news system here appears to be screwing up w.r.t. outgoing articles. I had posted previous re: getting dynamic loading and dumping out of a binary from a running process to work together. The specific context is OSF/1 1.3 on DEC Alphas, but I'm looking for a more generic soln. ] I've received several responses to my original query, most of which were of the "if you figure it out, let me know" variety, with a couple helpful suggestions thrown in for good measure. The consensus is that OSF/1 dlopen() is using mmap() to bring the code in to some chunk of VM high up in the address space, which sounds about right. I consider this a dirty trick, but can see why it is being done that way. I've been told that SunOS does it this way as well; anyone know about others? It seems to me that, at least for systems that use COFF, if I could get the starting virtual address and length of each chunk of VM containing dynamically loaded code, I could cons up some extra sections in the header of the dumped out binary which brought those chunks in at exec time, and then append them to the file (just have to get the file offsets right in the section headers). Does this sound right? I haven't taken a serious look at things besides COFF, but it sounds to me like this would be a reasonable thing to expect to be able to do. If so, then all I need to do is figure out how to get that information. I've been informed that there are ways of doing this under HP-UX and SunOS (but not Solaris?). It *looks* to me from examination of the loader(5) man page and various system header files that, under OSF/1, the _rld_new_interface() routine is what I'd need to use, but the information I have available to me is sketchy at best. If anyone out there in OSF/1-land can point me in the right direction (code samples would be cool), I'd appreciate it. It occured to me, lying in bed one night, that I might be able to do slightly better than this as well; if I knew the names of all the dynloaded files (which I can arrange to do), I might even be able to merge in the symtabs from dynloaded objects into the symtab of the dumped out binary, making debugging of dumped images somewhat less painful. Comments? {ASIDE As a language/environment implementor, I think it'd be just really nifty neato keen if there were a generic library with a reasonably clean interface that provided: * malloc with pure-storage hooks (I've done this already) * dynamic loading * binary image dump-out * some simple symbol table munging routines in a system-independent manner. In effect, I'm already doing this, in pieces, for various OSes/hardware. Surely, I'm not the only one; it seems to me like most folks who implement a programming language/environment of any size with some interactive/interpreted component at least think about these issues at some point. I know about BFD and DLD, but they have problems. BFD doesn't deal with the output side of things at all, and is rather large. DLD also doesn't deal with the output side of things, and only supports a limited number of platforms (It does appear to use malloc() to hold code, however, which is a plus in my context). It sure looks like most Unixish OSes available nowadays provide some facilities for doing some of these things. Since I hate kluging things together, I'd really rather spend a little more effort and produce something generically useful. If there are others out there who feel the same and who have built parts of these sorts of things already, or who know how and/or have ideas on how the interface should look, perhaps we should pool our efforts. This is the list of platforms that our system currently runs on, for which I'm attempting to get all of this working properly, and the current state of my efforts: HW OS Dynload? Dumpout? Works together? ------- ------- -------------- --------------- ---------------- Alpha OSF/1 y y n Sparc SunOS y y n Pmax Ultrix n y Pmax CMUMach n y NeXT NS 3.1 n n i[34]86 CMUmach n n The Hot Port List (in decreasing order of priority): Snake HP-UX Mac MacOS (does any of this make sense on the Mac?) RS6k AIX (had it working for 3.1.5 :-( ). I know nothing about the Amiga, Windows or NT. Any thoughts, comments, code, offers to pool effort would be greatfully appreciated. The system we've built is free (not sure which copyright model we're going to use, but it will be freely available), as are all of the subsystems of it (like the one I'm discussing here). } TIA, -- Sean -- prototype (n) - Sean Levy, n-dim Group, EDRC, CMU | +1 412 268- | something you intend to snl+@CMU.EDU (MIME,ATK) | 5222(vox) | throw away, but somehow snl@DAMRAK.SLIP.CS.CMU.EDU (NeXT) | 5229(fax) | never do.