executable = exe + data

Sam Steingold sds@gnu.org
Fri Dec 30 05:07:00 GMT 2005

CLISP consists of a run time (a normal executable lisp.exe, 2.5M)
and a memory image (a binary data file lispinit.mem 2MB-10GB).
It is normally invoked as "lisp.exe -M lispinit.mem", i.e., the
application consists of two files instead of a single executable which
is generally not considered desirable by the users, one of whom
suggested the following:
copy /y /b lisp.exe + marker.txt + lispinit.mem myapp.exe
where marker.txt contains some marker test.
so lisp.exe, when invoked without -M, will look at its own executable
file and search for the marker text and use whatever it finds after that
as the memory image (i.e., the -M file).

This should work, but I would rather not search the executable for the
marker text (for performance reasons - I do not want to increase the
start-up time), I would prefer to know where the executable ends right

Is it possible?

simply put, it it possible to write something like this:

int main () {
  size_t my_length;
  <some magic>
  printf("exe size=%lld\n",my_length);
  return 0;

so that when it is compiled, my_length contains the length of the
executable file as it was created by the compiler.
$ ./myprog.exe
exe size=1234567
$ copy /y /b myprog.exe + myprog.exe myprog2.exe
$ ./myprog2.exe
exe size=1234567
-- and not 2469134

one of the main requirements is portability.
(nothing woe32-specific or cygwin-specific &c)

the only idea I have had so far is this:

   char string[]="this is a buffer into which I will be writing my stuff";
   size_t my_length = atol(string);

and then have a post-processor edit lisp.exe and replace the contents of
string with the actual lisp.exe file length (I need the long initial
junk there so that the post-processor will be able to find where it is to
write the length).

any suggestions?


PS. I understand that this is not cygwin-specific, so I would appreciate
    a pointer to the proper forum to ask this question.

Sam Steingold (http://www.podval.org/~sds) running w2k
http://www.honestreporting.com http://www.openvotingconsortium.org/
http://www.iris.org.il http://www.camera.org http://www.memri.org/
MS: Brain off-line, please wait.

Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

More information about the Cygwin mailing list