$ Verify = 'F$VERIFY (0)' $ IF F$TRNLNM ("Verify") .NES. "" THEN V = F$VERIFY (F$TRNLNM ("Verify")) $ ! $ ! P1 = Image file to be analyzed $ ! P2 = "" or "DEBUG". If "DEBUG", section flags summary is $ ! listed if an error is found $ ! $! $Initialization: $ SET NOON $ DELETE = "DELETE" $ Error = 0 $ Section_count = 0 $ Search_string_not_found = %X08D78053 $! $Get_P1: $ IF P1 .NES. "" THEN GOTO Continue $ READ/PROMPT="Image file to be analyzed: "/ERROR=End/END=End SYS$COMMAND P1 $ GOTO Get_P1 $! $Continue: $ P1 = F$PARSE (P1, ".Exe",,, "SYNTAX_ONLY") $ IF F$SEARCH (P1) .EQS. "" THEN GOTO Noimage $! $! $! If we are on an Alpha system, just run the native ANALYZE. If we are on $! a VAX, use the cross tool. $! $! $ IF F$GETSYI("CPU") .EQ. 128 $ THEN $ DEFINE/USER SYS$OUTPUT NL: $ DEFINE/USER SYS$ERROR NL: $ ANALYZE/IMAGE/HEADER 'P1'/OUT=Sys$Scratch:Check_sections.Anl $ IF F$SEARCH ("Sys$Scratch:Check_sections.Anl") .EQS. "" THEN GOTO Anl_file_not_found $ ELSE $ IF F$SEARCH ("EVMS$BUILD_TOOLS:Analyze.Com") .EQS. "" THEN GOTO End $ Message_settings = F$ENVIRONMENT ("MESSAGE") $ SET MESSAGE/NOFACILITY/NOSEVERITY/NOID/NOTEXT $ @EVMS$BUILD_TOOLS:Analyze.Com $ SET MESSAGE 'Message_settings $ DEFINE/USER SYS$OUTPUT NL: $ DEFINE/USER SYS$ERROR NL: $ ANALYZE/IMAGE/HEADER 'P1'/ALPHA/OUT=Sys$Scratch:Check_sections.Anl $ IF F$SEARCH ("Sys$Scratch:Check_sections.Anl") .EQS. "" THEN GOTO Anl_file_not_found $ ENDIF $! $! $! Determine if image is a VAX or Alpha image by checking symbol names - $! IHD$xxx = VAX, EIHD$xxx = Alpha $! $! $ SEARCH/NOOUTPUT Sys$Scratch:Check_sections.Anl EIHD$ $ IF $status .EQ. search_string_not_found $ THEN $ GOSUB Examine_VAX_image $ ELSE $ GOSUB Examine_Alpha_image $ ENDIF $ GOTO End $! $! $! Error messages: $! $Anl_file_not_found: $ WRITE SYS$OUTPUT "%CHECK_SECTIONS-E-NOANLFIL, Analysis file (Check_sections.Anl) was not found" $! $Noimage: $ WRITE SYS$OUTPUT "%CHECK_SECTIONS-E-NOIMAGE, No such file" $ Error = 2 $ GOTO End $! $Nosearch: $ WRITE SYS$OUTPUT "%CHECK_SECTIONS-E-BADIMAGE, Unable to find image section data in analysis file" $ Error = 2 $ GOTO End $! $Badformat: $ WRITE SYS$OUTPUT "%CHECK_SECTIONS-E-BADFORMAT, Bad analysis file - unable to parse" $ Error = 1 $! $End: $ IF Error .EQ. 0 .AND. Section_count .EQ. 0 $ THEN $ WRITE SYS$OUTPUT "%CHECK_SECTIONS-E-BADIMAGE, Unable to find image section data in analysis file" $ Error = 2 $ ENDIF $ CLOSE/NOLOG Tmp $ IF Error .AND. P2 .EQS. "DEBUG" THEN TYPE Sys$Scratch:Check_sections.Tmp $ IF Error .NE. 0 THEN WRITE SYS$OUTPUT "%CHECK_SECTIONS-I-SUMMARY, Errors found in image ''P1'" $ IF F$SEARCH ("Sys$Scratch:Check_sections.Anl") .NES. "" THEN DELETE Sys$Scratch:Check_sections.Anl;* $ IF F$SEARCH ("Sys$Scratch:Check_sections.Tmp") .NES. "" THEN DELETE Sys$Scratch:Check_sections.Tmp;* $ Verify = F$VERIFY (Verify) $ EXIT $! $! $! Subroutine definitions: $! $!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!$ $! !$ $! !$ $! SUBROUTINE Examine_Alpha_image !$ $! This subroutine examines an Alpha image to see if it is a loadable !$ $! Alpha/VMS execlet. !$ $! !$ $!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!$ $! $Examine_Alpha_image: $ WRITE SYS$OUTPUT "" $ WRITE SYS$OUTPUT "%CHECK_SECTIONS-I-EXAMFIL, Examining ''P1'" $! $! $! Search the analysis file for the items that constitute a loadable Alpha $! execlet. $! $ SEARCH Sys$Scratch:Check_sections.Anl/OUT=Sys$Scratch:Check_sections.Tmp - "image section descriptor ",- "EISD$V_WRT",- "EISD$V_GBL",- "EISD$V_INITALCOD",- "EISD$V_FIXUPVEC",- "EISD$V_RESIDENT" $ IF $status .EQ. Search_string_not_found $ THEN $ Error = 2 $ WRITE SYS$OUTPUT "%CHECK_SECTIONS-E-BADIMAGE, Unable to find image section data in analysis file" $ RETURN $ ENDIF $! $! $! Define the allowable image section descriptors. $! $ Section_type_00000 = "PAGEABLE/READONLY" $ Section_type_10000 = "GLOBAL/PAGEABLE/READONLY" $ Section_type_00001 = "NONPAGED/READONLY" $ Section_type_01000 = "PAGEABLE/READWRITE" $ Section_type_01001 = "NONPAGED/READWRITE" $ Section_type_01010 = "FIXUP VECTOR" $ Section_type_01100 = "INITIALIZATION" $ Sections = "" $ OPEN/READ/ERROR=Nosearch Tmp Sys$Scratch:Check_sections.Tmp $! $! $! The loop below is used to verify that only one type of image section $! descriptor defined above exists in the analysis file. $! $Loop: $ READ/END=End_Examine_Alpha_image/ERROR=Badformat Tmp Line1 $ IF F$LOCATE ("image section descriptor ", Line1) .EQ. F$LENGTH (Line1) THEN - GOTO Badformat $ IF Section_count .EQ. 7 $ THEN $ WRITE SYS$OUTPUT "%CHECK_SECTIONS-E-SIXALLOWED, Only six image sections allowed" $ Error = 1 $ ENDIF $ READ/ERROR=Badformat Tmp Line2 $ IF F$LOCATE ("EISD$V_GBL", Line2) .EQ. F$LENGTH (Line2) THEN GOTO Badformat $! $ READ/ERROR=Badformat Tmp Line3 $ IF F$LOCATE ("EISD$V_WRT", Line3) .EQ. F$LENGTH (Line3) THEN GOTO Badformat $! $ READ/ERROR=Badformat Tmp Line4 $ IF F$LOCATE ("EISD$V_INITALCOD", Line4) .EQ. F$LENGTH (Line4) THEN GOTO Badformat $! $ READ/ERROR=Badformat Tmp Line5 $ IF F$LOCATE ("EISD$V_FIXUPVEC", Line5) .EQ. F$LENGTH (Line5) THEN GOTO Badformat $! $ READ/ERROR=Badformat Tmp Line6 $ IF F$LOCATE ("EISD$V_RESIDENT", Line6) .EQ. F$LENGTH (Line6) THEN GOTO Badformat $! $! $! Create a bit pattern according to the attributes found in the image section $! descriptor. This bit pattern is used to determine if an image section $! descriptor of the same type already exists within the image being examined. $! $ Section_type = F$ELEMENT (2, " ", F$EDIT (Line2, "TRIM,COMPRESS")) + - F$ELEMENT (2, " ", F$EDIT (Line3, "TRIM,COMPRESS")) + - F$ELEMENT (2, " ", F$EDIT (Line4, "TRIM,COMPRESS")) + - F$ELEMENT (2, " ", F$EDIT (Line5, "TRIM,COMPRESS")) + - F$ELEMENT (2, " ", F$EDIT (Line6, "TRIM,COMPRESS")) $! $! $! Check if the global bit (EISD$V_GBL) is set on sections that are $! PAGEABLE/READWRITE. A loadable execlet can have as many of these types of $! image sections descriptors as it needs. $! $ IF Section_type .EQS. "10000" $ THEN $ GOTO Loop $ ELSE $ Section_count = Section_count + 1 $ ENDIF $! $! $! Check to see if there are more than one of any type of image section $! descriptor. $! $ IF F$LOCATE (Section_type, Sections) .NE. F$LENGTH (Sections) $ THEN $ WRITE SYS$OUTPUT "%CHECK_SECTIONS-E-TOOMANY, Too many """, Section_type_'Section_type',""" image sections found" $ Error = 1 $ ELSE $ IF F$TYPE (Section_type_'Section_type') .EQS. "" $ THEN $ WRITE SYS$OUTPUT "%CHECK_SECTIONS-E-BADSECTION, Illegal image section found" $ Error = 1 $ ELSE $ Sections = Sections + "," + Section_type $ ENDIF $ ENDIF $ GOTO Loop $! $End_Examine_Alpha_image: $ If Error .EQ. 0 $ THEN $ WRITE SYS$OUTPUT "%CHECK_SECTIONS-S-EXECLET, ''P1' is a loadable Alpha execlet" $ WRITE SYS$OUTPUT "" $ ENDIF $ RETURN $!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!$ $! !$ $! !$ $! SUBROUTINE Examine_VAX_image !$ $! This subroutine examines a VAX image to see if it is a loadable !$ $! VAX/VMS execlet. !$ $! !$ $!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!$ $! $Examine_VAX_image: $ WRITE SYS$OUTPUT "" $ WRITE SYS$OUTPUT "%CHECK_SECTIONS-I-EXAMFIL, Examining ''P1'" $! $! $! Search the analysis file for the items that constitute a loadable VAX $! execlet. $! $ SEARCH Sys$Scratch:Check_sections.Anl/OUT=Sys$Scratch:Check_sections.Tmp - "image section descriptor ",- "ISD$V_WRT",- "ISD$V_INITALCODE",- "ISD$V_FIXUPVEC",- "ISD$V_RESIDENT" $ IF $status .EQ. Search_string_not_found $ THEN $ Error = 2 $ WRITE SYS$OUTPUT "%CHECK_SECTIONS-E-BADIMAGE, Unable to find Image Section data in analysis file" $ RETURN $ ENDIF $! $! $! Define the allowable image section descriptors. $! $ Section_type_0000 = "PAGEABLE/READONLY" $ Section_type_0001 = "NONPAGED/READONLY" $ Section_type_1000 = "PAGEABLE/READWRITE" $ Section_type_1001 = "NONPAGED/READWRITE" $ Section_type_1010 = "FIXUP VECTOR" $ Section_type_1100 = "INITIALIZATION" $ Sections = "" $ OPEN/READ/ERROR=Nosearch Tmp Sys$Scratch:Check_sections.Tmp $! $! $! The loop below is used to verify that only one type of image section $! descriptor defined above exists in the analysis file. $! $Loop: $ READ/END=End_Examine_VAX_image/ERROR=Badformat Tmp Line1 $ IF F$LOCATE ("image section descriptor ", Line1) .EQ. F$LENGTH (Line1) - THEN GOTO Badformat $ Section_count = Section_count + 1 $ IF Section_count .EQ. 7 $ THEN $ WRITE SYS$OUTPUT "%CHECK_SECTIONS-E-SIXALLOWED, Only six image sections allowed" $ Error = 1 $ ENDIF $ READ/ERROR=Badformat Tmp Line2 $ IF F$LOCATE ("ISD$V_WRT", line2) .EQ. F$LENGTH (Line2) THEN GOTO Badformat $! $ READ/ERROR=Badformat Tmp Line3 $ IF F$LOCATE ("ISD$V_INITALCODE", line3) .EQ. F$LENGTH (Line3) THEN GOTO Badformat $! $ READ/ERROR=Badformat Tmp Line4 $ IF F$LOCATE ("ISD$V_FIXUPVEC", Line4) .EQ. F$LENGTH (Line4) THEN GOTO Badformat $! $ READ/ERROR=Badformat Tmp Line5 $ IF F$LOCATE ("ISD$V_RESIDENT", Line5) .EQ. F$LENGTH (Line5) THEN GOTO Badformat $! $! $! Create a bit pattern according to the attributes found in the image section $! descriptor. This bit pattern is used to determine if an image section $! descriptor of the same type already exists within the image being examined. $! $ Section_type = F$ELEMENT (2, " ", F$EDIT (Line2, "TRIM, COMPRESS")) + - F$ELEMENT (2, " ", F$EDIT (Line3, "TRIM,COMPRESS")) + - F$ELEMENT (2, " ", F$EDIT (Line4, "TRIM,COMPRESS")) + - F$ELEMENT (2, " ", F$EDIT (Line5, "TRIM,COMPRESS")) $! $! $! Check to see if there are more than one of any type of image section $! descriptor. $! $ IF F$LOCATE (Section_type, Sections) .NE. F$LENGTH (Sections) $ THEN $ WRITE SYS$OUTPUT "%CHECK_SECTIONS-E-TOOMANY, Too many """, Section_type_'Section_type',""" image sections found" $ Error = 1 $ ELSE $ IF F$TYPE (Section_type_'Section_type') .EQS. "" $ THEN $ WRITE SYS$OUTPUT "%CHECK_SECTIONS-E-BADSECTION, Illegal image section found" $ Error = 1 $ ELSE $ Sections = Sections + "," + Section_type $ ENDIF $ ENDIF $ GOTO Loop $! $End_Examine_VAX_image: $ IF Error .EQ. 0 $ THEN $ WRITE SYS$OUTPUT "%CHECK_SECTIONS-S-EXECLET, ''P1' is a loadable VAX execlet" $ WRITE SYS$OUTPUT "" $ ENDIF $ RETURN $ ! $ ! $ ! Check_sections.Com $ ! $ ! This procedure will analyze an image to check that it $ ! conforms to the requirements for an executive loadable image $ ! ("Execlet"). Such images are allowed at most one of each of $ ! the following types of image sections: $ ! $ ! Pageable/Readonly $ ! Nonpaged/Readonly $ ! Pageable/ReadWrite $ ! Nonpaged/ReadWrite $ ! Fixup Vector $ ! Initialization $ ! $ ! The output of ANALYZE/IMAGE is searched for the items of $ ! interest, and the search output is parsed to check for $ ! conformance. This command procedure can examine both Alpha $ ! and VAX images for conformance. The user does not need to do $ ! anything special in order to differentiate between Alpha and $ ! VAX images. This command procedure can make the proper $ ! distinction. $ ! $ ! X-4 RAB Richard A. Bishop 5-Nov-1992 $ ! Use SYS$SCRATCH for all temporary files $ ! $ ! X-3 CEG Clair Grant 19-Mar-1992 $ ! Add capability to be used on Alpha as well as VAX. $ ! $ ! X-2 NYK Nitin Y. Karkhanis 24-JUN-1991 $ ! Add capability to examine either Alpha or VAX image. $ ! $ ! X-1 RAB Richard A. Bishop 6-Jul-1990 $ ! Initial version