[Info-vax] Non-portable code

Marc Van Dyck marc.vandyck at brutele.be
Wed Jan 6 17:36:29 EST 2010


Marc Van Dyck formulated the question :
> G'd evening to all...
>
> I have a program on my systems, that was written in the VAX ages,
> and that I use to display which version of layered products, tools, etc,
> are installed. It simply extracts from the image headers the version
> info that has been put there by the linker, with the IDENT clause of
> the link options file.
>
> Here is an extract of the code that does it (Pascal) :
>
> RESET ( f ) ;
> buffer := f^ ;
> CLOSE ( f ) ;
>
> addr := IADDRESS (buffer) +
>         buffer[EIHD$L_IMGIDOFF+1]::$UBYTE +
>         EIHI$T_IMGID ;
> image_id.LENGTH := 0 ;
>
> LIB$MOVC3 ( word_integer_length := 1 ,
>             source := %IMMED addr ,
>             destination := image_id.LENGTH ) ;
> addr := addr + 1 ;
> STR$COPY_R ( destination_string := image_id.BODY ,
>              word_integer_source_length := image_id.LENGTH ,
>              source_string_address := %IMMED addr ) ;
>
> (Assuming that f is an executable image file and image_id the place for
> the info that I want to obtain)
>
> EIHD$L_IMGIDOFF and EIHI$T_IMGID are declared as [EXTERNAL,VALUE]
> variables and resolved at link time by inserting a .STB file (don't
> remember which one, I'm at home here) in the link options file.
>
> This works perfectly well on VAX and Alpha. On Itanium, it compiles
> but either gives false results, or even ACCVIOes (I suppose that it
> happens when what I read in buffer[EIHD$L_IMGIDOFF+1] is absurdly high).
>
> So, a few questions :
>
> For Integrity images, is the method I used above still valid - but with
> wrong offsets - or am I completely screwed up ? If positive, what are
> the offsets that I should use ? If not, how should I do ? Is it
> documented somewhere ?
>
> If the offsets EIHD$L_IMGIDOFF and EIHI$T_IMGID are wrong on Integrity,
> why is it possible that the program compiled and linked with no problem
> at all ? I would have expected that those either have the correct value,
> or do not exist at all, in which case the link would have failed. Where
> am I wrong ?
>
> If I need to have code differences between the VAX/AXP and the I64
> version, do I need to have two separate source files, or does Pascal
> provide some way of conditional compiling ?
>
> Many thanks in advance for your help. This is the first time I
> encouter code which is not source-compatible between the 3 VMS
> hardware architectures...

OK gentlemen, thank you very much to all for your help. We have been
able to transform the C code that John Reagan posted here into a
function that my Pascal program can call. It works very well,
so my problem is solved.

-- 
Marc Van Dyck





More information about the Info-vax mailing list