[comp.sys.atari.st.tech] Alignment problems with Pexec

kilian@seas.gwu.edu (Jens Kilian) (01/10/91)

  While implementing a Prolog system on the ST, I came across the following
problem:

  I'd like the program to be able to pre-load the Prolog code of the compiler
and library and to 'dump' itself to a new executable file. When starting the
new file, the Prolog code will be present in memory, greatly speeding up the
startup process.  [For those not familiar with such a technique, this is
exactly what GNU Emacs does, at least on a UNIX system].
  On the ST, this is a bit complicated since programs can't assume that they
will always be loaded to the same address (I already figured out how to
generate relocation information for the new executable file, so that's not
my problem). In particular (as I understand it), TOS only guarantees that
a program will be loaded on an EVEN address.
  THAT'S my problem.
  In the program I'm writing, the least significant 2-3 bits of a pointer
are used as type tags. To make this work with the relocation scheme
implemented by the TOS function Pexec(), the dumped executable program
must be loaded to an address that is congruent (modulo 8) to the original
load address (speaking C: (old_adress - new_address) % 8 == 0 ), which simply
can't be done under the normal TOS.

  Does anybody know a solution for this problem ? It is not simply a matter
of putting a program in the AUTO folder that intercepts all Malloc() requests
and forces 8-byte alignment, since Pexec() predictably doesn't call Malloc()
(it calls some internal TOS routine which can't be trapped). I don't feel
like rewriting Pexec() either. The program is intended for public use, so
fixing the ROMS or using a modified RAM TOS won't help.

  [In case someone is interested in the program, a pre-release version is
   available from comp.binaries.atari.st]


			Thanks for any comments

				Jens Kilian


--
Internet: kilian@seas.gwu.edu		SnailMail: 4715 MacArthur Blvd.
UUCP: ...uunet!seas.gwu.edu!kilian		   Washington, DC 20007
"Sie hawwe-mer so e bekannt Physionomie, ich mahn, ich misst Ihne kenne.
 Sinn-Se net, um Vergebung, der Herr Assesser Ranft ?"