-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathBOOTOBJ.C
111 lines (93 loc) · 2.38 KB
/
BOOTOBJ.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/* @(#)bootobj.c 1.4 */
/*
* These routines are used to get and check the object file
* header of the program we want to boot into memory.
*
* ASSUMPTIONS:
*
* - The object file has been relocated to an absolute address.
*
* - This address does not conflict with the booter's program
* and data space.
*
* - The object file is COFF or Old Format (12/27/84 - Old Format Only Now)
*
* STILL TO BE DONE:
*
* - Handle non-contiguous segments.
*
* - COFF format files.
*
* - An initial start address in the header. Now it is zero.
*/
#include "portab.h"
#include "cdosboot.h"
/*
* THIS INFORMATION DEFINES THE OLD FORMAT OBJECT FILES.
*
* Old Format object files are produced by the CP/M-68K
* compilers.
*/
/*
* Two of_magic numbers exist for Old Format object files
* one for contiguous segments, one for non-contiguous.
*
* We don't muck with non-contiguous segments.
*/
#define MAGIC1 0x601a /* contiguous segments */
#define MAGIC2 0x601b /* non-contiguous segments */
/*
* Define the header structure where we get the object file
* layout for Old Format object files.
*/
typedef struct
{
WORD of_magic;
LONG of_tsize; /* all sizes in BYTES! */
LONG of_dsize;
LONG of_bsize;
LONG of_symsize;
LONG of_reserved; /* not used */
BYTE *of_tstart;
WORD of_relocinfo; /* if 0 - relocatable; */
} OF_OBJHD;
GetObjectFileInfo(p_objinfo,bp)
REG OBJINFO *p_objinfo;
BS *bp;
{
REG OF_OBJHD *of_objhd;
/*
* We must be at least able to read the header!
*/
if( (bp->numbytes = ReadPcdos(bp->buf)) < sizeof(OF_OBJHD) )
{
PutMsg("Can't read object file header.");
return ERROR;
}
of_objhd = (OF_OBJHD *)bp->buf; /* template over buffer */
bp->current = sizeof(OF_OBJHD);
if( of_objhd->of_magic != MAGIC1 )
{
PutMsg("Bad object file of_magic number.");
return ERROR;
}
if( of_objhd->of_relocinfo == 0 )
{
PutMsg("Object file is relocatable, must be absolute.");
return ERROR;
}
p_objinfo->textsize = of_objhd->of_tsize;
p_objinfo->datasize = of_objhd->of_dsize;
p_objinfo->bsssize = of_objhd->of_bsize;
p_objinfo->loadaddress = of_objhd->of_tstart;
/*
* We assume system starts execution at 0.
*/
p_objinfo->startaddress = (BYTE *)0L;
return OK;
}
f_tstart;
/*
* We assume system starts execution at 0.
*/
p_objinfo->startadd