Solved

DOS Overlay file (.ovl) in C++ and DOS relocation table

Posted on 1998-03-21
1
864 Views
Last Modified: 2008-02-01
Hi all,
1)
    I would like to create .ovl files for my C/C++ programs like .ovr's in PASCAL because I would like to seperate the main code with the subcode such as the setup program. Do you know how to do?

2)
Also, i'm checking out the usage of the relocation table in dos header and i'm not quite sure why the first relocation table item (offset) contains 01 00 and segment contains 00 00, my program actually starts at 200h, and the second relocation item is also set to 8c 00 00 00. does it mean that thesecond segment starts at 00 8c (offset) with a displacement of 8c hex from the start of the file?
here is a dump of my program:
4D 5A 5E 00 88 00 38 00 20 00 C8 05 FF FF 8D 14
00 20 00 00 00 00 00 00 3E 00 00 00 01 00 FB 30
6A 72 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00
00 00 8C 00 00 00 7A 01 00 00 29 5D 00 00 30 5D
00 00 37 5D 00 00 3E 5D 00 00 5D 5D 00 00 6F 5D
00 00 8F 5D 00 00 A2 5D 00 00 BE 5D 00 00 C5 5D
00 00 CE 5D 00 00 FA 5D 00 00 09 5E 00 00 35 5E
00 00 3C 5E 00 00 43 5E 00 00 5E 5E 00 00 7D 5E
00 00 8D 5E 00 00 A2 94 00 00 A4 99 00 00 C1 99
00 00 40 00 37 0D 5B 00 37 0D 75 00 37 0D 7C 00
37 0D F7 00 3F 0D 0B 01 3F 0D 16 01 3F 0D B0 00
51 0D BB 00 51 0D 4F 01 51 0D 5D 01 51 0D C0 00
6E 0D C8 00 6E 0D D7 00 6E 0D E4 00 6E 0D 1C 02
6E 0D 5F 09 6E 0D 1B A6 00 00 20 A6 00 00 3D A6
00 00 42 A6 00 00 51 A6 00 00 89 A6 00 00 53 AB
00 00 60 AB 00 00 65 AB 00 00 AF AB 00 00 F6 AB
00 00 EA AC 00 00 77 B5 00 00 2A B7 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
B8 6B 0F 8E D8 FA 8E D0 BC 20 72 FB FC 8C 06 AE
15 E8 E3 06 BF B4 15 B9 07 02 33 C0 1E 07 F3 AB
1E BA 79 01 0E 1F B8 23 25 CD 21 FC 1F BB 00 00
E8 88 06 8E 06 AE 15 26 8A 1E 80 00 32 FF 26 C6




0
Comment
Question by:whluk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 16

Accepted Solution

by:
imladris earned 100 total points
ID: 1257788
Creating overlays is mostly a matter of getting a hold of an overlay linker. I have used RTLINK from PocketSoft. I believe the Microsoft linker also does simple overlays though.
Given that, it is mostly a matter of specifying to the linker which objects to put in overlays. This is usually done by something simple like enclosing groups of obj files in parenthesis.

As for the questions in the second part:

When you say your program starts at 200, I assume you mean it starts at offset 200 in the file. However, relocation items are taken to be offsets from the start of the program. A linker would normally load the program portion of the file into memory, then take each relocation item and do the fixup.
Relocation items are formatted just like any adress in an intel processor: offset:segment (backwards). So the first one (01 00 00 00) refers to address 0:01 (i.e. the second byte of the program), the second item (8c 00 00 00) refers to 0:8c (i.e. 8c bytes from the start of the program).
A relocation item is a fixup specification. So there are two bytes at each of the addresses specified that refer to segments. These need to be "relocated". This is done by adding theprograms actual starting segment to the one that is there. A program is compiled with the assumption it will be loaded at 0:0 (simply for convenience, you have to assume something). Assume it is actually loaded at 4e00:0. Now suppose there is a far call in the program to segment 200. The relocation item points to it, the loader reads the 200, adds 4e00, and writes it back.

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C++ vs C compilers 13 164
Handling string inputs in C/Linux 23 195
C Language combined operators 28 124
List out all word 7 338
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question