Shebang the image (was: [Vm-dev] (fwd) Re: 6502)
Jecel Assumpcao Jr
jecel at merlintec.com
Thu Apr 23 13:14:58 UTC 2009
David T. Lewis wrote:
> This already works, and has been available for many years on Squeak. I have
> a dim recollection that Lex Spoon may have been responsible for adding this.
> In any case if you prepend a 512 byte gob of anything to the beginning
> of any image file (added prior to the actual image header), then the image
> will still load (the gob of bytes is skipped). If that gob of bytes happens
> to start with the string "#!/usr/bin/squeak" and if you set the image file as
> executable, then you can just execute the image directly, the /usr/bin/squeak
> program will be invoked, and it will load the image file and start Squeak.
This is done by looking for the version number both at offset 0 and at
offset 512 in the file, right? And advantage of having such a generous
space to add extra stuff is that something similar to the Unix trick
could also be done for Windows - the first page could be a valid .exe
file with a tiny program that would load the VM from the end of the file
and the image starting at byte 512.
Self also leaves a similar amount of free space at the start of each
image and in addition to the #! command line it also included the
setting of some environment variables in the following lines, so the
image was its own .ini file as well.
More information about the Vm-dev