Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* dynamic loading/dumping out of binaries revisited
@ 1994-02-03 17:31 Sean Levy
  1994-02-03 18:48 ` Bennet Yee
  0 siblings, 1 reply; 2+ messages in thread
From: Sean Levy @ 1994-02-03 17:31 UTC (permalink / raw)


[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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1994-02-03 18:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1994-02-03 17:31 dynamic loading/dumping out of binaries revisited Sean Levy
1994-02-03 18:48 ` Bennet Yee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox