Using Overlays


The Meridian compiler can produce separate OBJ files which can be linked using overlays. We have been trying this and to this point have had good success. One project which took 11 Megabytes as separate EXE's took 1.2 Megabytes as overlays. An example follows showing how this is done:

This example shows how to overlay the code from a library using the Meridian compiler and a separate linker (RTLINK Plus). As an example we will compile a library called testlib, a main program called test, and then overlay the code from testlib. This is done in a directory called C:\AA. This is accomplished using a batch file shown below:

        * Note - the numbers down the left side are line numbers used as a reference in later descriptions of this file.
        1 ada fESs K testlib.ads
        2 if errorlevel 1 goto errs
        3 ada fESs K testlib.adb
        4 if errorlevel 1 goto errs
        5 ada fESs K test.ada
        6 if errorlevel 1 goto errs
        7
        8 goto done
        9
        10 :errs
        11 echo **** ERRORS OCCURRED ****
        12 goto out
        13
        14 :done
        15 echo Compilation completed without error
        16
        17 copy c:\aa\ada.aux\btestlib.obj c:\aa\ada.aux\btestlib.sav
        18 del c:\aa\ada.aux\btestlib.obj
        19
        20 bamp o mytest.obj r test
        21 rem bamp o mytest.obj g r test
        22
        23 copy c:\aa\ada.aux\btestlib.sav btestlib.obj
        24
        25 SET RTLINKCMD=NODEFLIB SYNTAX FREEFORMAT
        26 C:\RTLINK\RTLINK @test.LNK
        27
        28 :out
      
Lines 1 .. 6 perform the compilation

Lines 10 .. 12 are used if errors occurred in compilation

Lines 14 .. 26 are used in the event of a successful compilation. The OBJ file containing the code to be overlayed must be renamed to keep the bamp linker from pulling it into the relinkable OBJ file for the main program.

This is done in lines 17 and 18. Line 20 creates an OBJ file for the main program called mytest.obj containing all the code except for that in the testlib library. If you want to perform an optimization to remove all unused code then you could use line 21 instead of 20. After creating the main OBJ the testlib code is renamed to the original OBJ name (Line 23).

Line 25 sets an environment variable used by RTLINK Plus. Line 26 calls RTLINK Plus and passes the name of the linker response file to use. The linker response file is shown below: * Note - any line starting with an # is a comment line. # SPECIFY THE NAME OF THE FINAL .EXE FILE.
OUTPUT TEST.EXE # IF THE FOLLOWING LINE IS UNCOMMENTED THEN DEBUG INFO WILL BE LINKED IN.
#CODEVIEW # IF THE FOLLOWING LINE IS UNCOMMENTED THEN THE LINKER WILL SHOW STATUS.
#SILENT # CREATE A SWAP FILE ON A RAM DRIVE TO SPEED THE LINKING.
WORKFILE D:\SWAP DOSSEG # OVERLAY CODE NOT THE DATA.
OVERLAY CODE # USE TEST.OBJ.
FILE TEST VERBOSE 2 WARNING 3 MAP=TEST.MAP STACK 30000. # SPECIFY THE AREA TO OVERLAY
BEGINAREA
SECTION TESTLIB FILE C:\AA\BTESTLIB
ENDAREA Other linkers can probably be used to perform the same function as described above. We are not endorsing RTLINK Plus as the tools to use, just describing the method and tools used by the Sage-ST TM developers to do overlays. Go Back To Sage-ST TABLE OF CONTENTS


warren.merrill@inl.gov , ftp://sage.inel.gov
Copyright © 1989-2006. Battelle Energy Alliance