[Vm-dev] what about image reading?

Tobias Pape Das.Linux at gmx.de
Thu Jan 13 17:20:28 UTC 2011


Am 2011-01-13 um 17:52 schrieb David T. Lewis:
> 
> On Thu, Jan 13, 2011 at 05:26:34PM +0100, Tobias Pape wrote:
>> […]
>> In a previous discussion, the method
>> Interpreter>>readImageFromFile: f HeapSize: desiredHeapSize StartingAt: imageOffset
>> was mentioned that can read the image format using the given offset.
>> However, neither in the Smalltalk code nor in the generated C code I was able
>> to find any uses of this. 
>> 
>> SqueakVMMaker/src ??? grep -iR readImageFromFileHeapSizeStartingAt *
>> vm/interp.c:sqInt readImageFromFileHeapSizeStartingAt(sqImageFile  f, usqInt desiredHeapSize, squeakFileOffsetType  imageOffset);
>> vm/interp.c:sqInt readImageFromFileHeapSizeStartingAt(sqImageFile  f, usqInt desiredHeapSize, squeakFileOffsetType  imageOffset) {
>> 
>> Is this by design? Did I miss something?
>> […]
> 
> The purpose of this feature is to support "shebang" processing:
>  http://en.wikipedia.org/wiki/Shebang_(Unix)
> 
> The idea is to offset the start of the image by 512 bytes into
> the image file, and put the hash-bang line at the beginning
> of the file. The hash-bang line invokes the VM, and the VM
> reads the file containing the image at offset 512. The VM
> first tries to read the image starting at offset 0, which
> fails because it sees the hash-bang instead of the image
> format word. It then skips ahead 512 bytes, tries again, and
> presto the image starts up.
> 
> The end result is that an image file can be turned into an
> executable file that runs itself.


The _purpose_ of the 512byte skip was clear to me.
I was just puzzled that there is no reference to the indicated method whatsoever.
Can you give me a hint, where that is used?

So Long,
	-Tobias


More information about the Vm-dev mailing list