• Aucun résultat trouvé

Relocatable File Format (.REL)

Dans le document RT–11 Volume and File Formats Manual (Page 88-93)

File Formats

2.8 Relocatable File Format (.REL)

To link a foreground job, use the Linker /R option or the keyboard monitor LINK command with the /FOREGROUND option. This causes the Linker to produce output in a linked, relocatable format, with a .REL file type. Note that system files are also stored in relocatable format. The only difference is that system files use a file type of .SYS instead of .REL.

Table 2–16: Information in Block 0 of a .REL Image Offset Contents

0 VIR in Radix–50 if the Linker /V option was used.

2 Virtual high limit if Linker /V option was used.

4 Job definition word ($JSX) bits. See Table 2–11 for bit definitions.

6 Reserved

Table 2–16 (Cont.): Information in Block 0 of a .REL Image Offset Contents

10 Reserved

12 Reserved

14 BPT trap PC(mapped monitors only) 16 BPT trap PSW (mapped monitors only) 20 IOT trap PC (mapped monitors only) 22 IOT trap PSW (mapped monitors only)

24 Reserved

26 Reserved

30 Reserved

32 Overlay definition word (SV.CVH) bits. See tables 2–12 and 2–13 for bit definitions.

34 Trap vector PC (TRAP) 36 Trap vector PSW (TRAP) 40 Program’s relative start address

42 Initial location of stack pointer (changed by /M option) 44 Job Status Word

46 USR swap address 50 Program’s high limit

52 Size of program’s root segment, in bytes.

54 Stack size, in bytes (changed by /R:n option).

56 Size of overlay region, in bytes (0 if not overlaid) 60 .REL file ID (REL in Radix–50)

62 Relative block number for start of relocation information 64 Address of overlay handler table for overlaid files

66 Address of start of window definition blocks (if /V used) 70–356 Reserved

360–377 Bitmap area

The object modules used to create a .REL file are linked as if they were a background .SAV image, with a base of 1000. This permits you to use .ASECT directives to store information in locations 0 through 777 in .REL files. All global references have been resolved. The Linker does not relocate the .REL file at link time; it merely includes relocation information to be used at FRUN time. The relocation information in the

file is used to determine which words in the program must be relocated when the job is installed in memory.

There are two types of .REL files to consider: those programs with overlay segments, and those without them.

2.8.1 .REL Files Without Overlays

A .REL file for a program without overlays appears as shown in Figure 2–39.

Figure 2–39: .REL File Without Overlays

Block Program Relocation information

0 text

Block 0 (relative to the start of the file) contains the information shown in Table 2–10.

Some of this information is used by the FRUN processor.

In the case of a program without overlays, the FRUN processor performs the following general steps to install a foreground job.

1. It reads block 0 of the file into an internal monitor buffer.

2. It obtains the amount of memory required for the job from location 528 of block 0 of the file, and allocates the space in memory by moving KMON and the USR down.

3. It reads the program text into the allocated space.

4. It reads the relocation information into an internal buffer.

5. It relocates the locations indicated in the relocation information area by adding or subtracting the relocation quantity. This quantity is the starting address the job occupies in memory, adjusted by the relocation base of the file. .REL files are linked with a base of 1000.

The relocation information consists of a list of addresses relative to the start of the user’s program. The monitor scans the list, and for each relative address computes an actual address. That address is then loaded with its original contents plus or minus the relocation constant. The relocation information is shown in Figure 2–40.

In Figure 2–40, bits 0 through 14 represent the relative address to relocate divided by 2. This implies that relocation is always done on a word boundary, which is indeed the case. Bit 15 indicates the type of relocation to perform—positive or negative.

The relocation constant (which is the load address of the program) is added to or subtracted from the indicated location depending on the sense of bit 15; 0 implies addition, while 1 implies subtraction. A full 16-bit word is the original contents. The

Figure 2–40: Root Relocation Information Format

15 14 0

Original contents

.

Relative word offset

Original contents

.

Relative word offset

. .

−2

value 177776, or –2, terminates the list of relocation information for a file without overlays.

2.8.2 .REL Files with Overlays

When you include overlays in a program, in addition to relocating the root segment, the FRUN processor must also relocate the overlay segments. Since overlays are not permanently memory resident but are read in from the file as needed, they require an additional operation. FRUN relocates each overlay segment and rewrites it into the file before the program begins execution. (Therefore, the volume containing the file must be write-enabled.) Thus, when the overlay is called into memory during program execution, it is correct. This process takes place each time you run an overlaid file with FRUN or SRUN. The relocation information for overlaid files contains both the list of addresses to be modified and the original contents of each location. This allows the file to be executed again after the first usage. It is necessary to preserve the original contents in case some change has occurred in the operating environment. Examples of these changes include using a different monitor version, running on a system with a different amount of memory, and having a different set of device handlers or system jobs resident in memory. Figure 2–41 shows a .REL file with overlays. Refer to Figure 2–40 and Figure 2–42 for more detail of the relocation information.

In the case of a .REL file with overlays, location 56 of block 0 of the .REL file contains the size in bytes of all the overlay regions. FRUN adds this size to the size of the program base segment (in location 52) to allocate space for the job.

Figure 2–41: .REL File with Overlays

Block 0 .REL Control Block Overlay handler and tables

Root relocation information

End of root relocation information Overlay segment 1 relocation information

End of overlay 1 relocation information

Overlay segment N relocation information Root

. . .

−1

Present if there is extra root information, such as relocation overlay handler information.

Segment

End of all relocation information text

. . .

−1 Overlay 1 data

−1 Overlay N data

−2

After FRUN relocates the program base (root) code, it reads each existing overlay into the program overlay region in memory, relocates it using the overlay relocation information, and then writes it back into the file.

The root relocation information section is terminated with a –1. This –1 is also an indication that an overlay segment relocation block follows.

The relocation is relative to the start of the program and is interpreted as if it were in a file without overlays (that is, bit 15 indicates the type of relocation, and the displacement is the true displacement divided by 2). Encountering –1 indicates that a new overlay region begins here; a –2 indicates the termination of all relocation information.

Figure 2–42: Overlay Segment Relocation Block

Overlay block number Start of overlay relative to start of file.

(Value is 0 if this is extra root information.) Size of overlay in words. (Value is 0 if this is extra root information.)

Overlay size

Relative word offset Text to relocate

. . .

. . . Relative word offset

Text to relocate

Relative word offset Text to relocate

Dans le document RT–11 Volume and File Formats Manual (Page 88-93)

Documents relatifs