From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f8c9b,b44dafcd55f370cb,start X-Google-Attributes: gidf8c9b,public X-Google-Thread: f72b0,b44dafcd55f370cb,start X-Google-Attributes: gidf72b0,public X-Google-Thread: fee84,b44dafcd55f370cb,start X-Google-Attributes: gidfee84,public X-Google-Thread: 150775,b44dafcd55f370cb,start X-Google-Attributes: gid150775,public X-Google-Thread: 1450f6,b44dafcd55f370cb,start X-Google-Attributes: gid1450f6,public X-Google-ArrivalTime: 1994-01-28 18:30:44 PST Xref: gmd.de comp.unix.osf.osf1:2067 comp.unix.misc:9286 comp.unix.questions:27756 Newsgroups: comp.unix.osf.osf1,comp.unix.misc,cmu.cs.unix.forum,cmu.comp.sys.dec.alpha,comp.unix.questions Path: gmd.de!newsserver.jvnc.net!netnews.upenn.edu!msuinfo!agate!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 woes (osf/1 1.3, but not only) Message-ID: Summary: Would like info/help on dynloading that works with image dumpout Keywords: dynamic loading, unexec 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, 27 Jan 1994 21:01:59 GMT Hi all, I am attempting to implement dynamic loading of shared objects plus an image dumpout facility for some software we have written (an object-oriented programming language, written in terms of a C-based object system we have developed locally). I develop mainly on Alphas running OSF/1 (V1.3), but I am attempting to make my solution as portable (or at least as #ifdef-able) as possible. Under OSF/1 1.3, I have both dumping out of an executable image from the running process and dynamic loading/linking of shared objects working, but the two interact catastrophically; dumped out executables don't contain code that was loaded at runtime. After many sessions in the debugger, pondering the dlopen(3), _rdl_new_interface(3), etc... man pages, looking at the SunOS => OSF/1 Porting Guide, and disassembling various bits of the system, I am still at a loss. It seems that what I want to do is have a segment somewhere above TEXT_START but before _edata into which the new object code gets loaded. I had been hoping to use the plain old data segment for this purpose, by way of modifications to malloc. I have modified GNU malloc to support the notion of multiple arenas, which can optionally be pointed at static arrays instead of the heap, and have implemented the rest of our object system in such a way that it can be told to allocate objects out of "pure" storage instead of heap (by switching arenas at the appropriate points). This has the desired effect of putting objects so allocated into the data segment, and thus gets them written out into dumped binaries. I had been hoping that dlopen and friends used calls to malloc to allocate whatever space was needed to hold loaded code, but this appears not to be the case; in fact, it also appears that they don't use sbrk, either. The _rdl_new_interface() man page and header file makes cryptic references to the sbrk interface implemented by some subcommands of _rdl_new_interface(), but I can't make heads nor tails of it. In fact, I don't really understand what mechanism is being used by the dynamic loader to bring the bits into memory; whatever it is results in addresses in the upper half of the universe (high 32 bits). I have played around with -taso a bit, but according to the memory map in the SunOS=>OSF/1 guide, it appears that that won't cut it either, because dynamically loaded code appears above the data segment. Since I have lots of other things to hack on, I'm about to punt. If anyone out there can offer advice or, better yet, sample code that will allow me to load code on the fly in such a way that I can dump out an image containing the code, please email me (snl+@CMU.EDU). Solutions that work on systems other than OSF/1 would be eagerly accepted. If there is interest, I'll summarize. Thanks in advance, -- Sean P.S. For folks on the GNU patrol, don't worry, I'm going to ship in my diffs to libmalloc as soon as I can figure this mess out, or figure out that it isn't figurable. -- S -- 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.