This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Guile Startup Time Suggestion


karlheg@inetarena.com (Karl M. Hegbloom) writes:
> >>>>> "John" == John Tobey <jtobey@channel1.com> writes:
> 
>     >> On several platforms, unexec and dynamic loading cannot live
>     >> together.
> 
>     John> Why not?  If you mean that pointers need to be relocated and
>     John> there's no telling what's a pointer and what isn't, I
>     John> suggest we try harder.
> 
>     John> I'm glad you made the claim it can't be done, 'cause now I'm
>     John> gonna try and prove that it __can__.
> 
>  Why can `XEmacs' and `emacs' do it then?  They are dynamicly
>  linked... to a pile of shared object libraries.

This confused me too when I first heard it claimed, "unexec and shared
libs don't mix".  I think he means that you can't create a dynamic
library from a heap image, an assertion which I still dispute.

> ldd =xemacs
> 	libXaw.so.6 => /usr/X11R6/lib/neXtaw/libXaw.so.6 (0x40012000)
> 	libcompface.so.1 => /usr/lib/libcompface.so.1 (0x40068000)
[etc.]

We (or at least I) want to see something like:

ldd emacs
	libemacs.so.1 => /usr/lib/libemacs.so.1 (0x40012000)
...

where the emacs executable is tiny.  I've found three main
difficulties in creating unexec'ed libs, all of which I think I can
work around (at least on Linux/ix86/Glibc2).

One is that the shared library data segments are in mmapped regions,
which are separated from the heap used by malloc.

Two, shared libraries must be (or at least ought to be) relocatable,
so there has to be a way to find all the pointers in
application-specific data structures.

Three, we'll want to be able to free or realloc pointers that were
returned by malloc and realloc, which will mean they have to be
individually malloc'ed when the dumped library is loaded, and special
code will have to relocate all pointers that point to within malloc'ed
blocks.

(Emacs is not a good first choice of programs to try this on, since it
stores flags in the high bits of pointers, which are used on Linux to
separate malloc'ed from mmapped memory.  I haven't looked at Guile
closely enough to know if it will be any easier.)

-John