-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathReloc.c
More file actions
85 lines (74 loc) · 2.77 KB
/
Reloc.c
File metadata and controls
85 lines (74 loc) · 2.77 KB
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
/*
* LSI-11 Linker
* îÁÓÔÒÏÊËÁ ÚÁÇÒÕÚÏÞÎÏÇÏ ÍÏÄÕÌÑ
*/
#include <SysStrings>
#include "LinkerDefs"
#define INTSIZE 2 /* òÁÚÍÅÒ "ÓÌÏ×Á" × ÔÅÒÍÉÎÁÈ ÆÏÒÍÁÔÁ ÆÁÊÌÁ.
* úÁÍÅÔÉÍ, ÞÔÏ ÎÁ ÎÅÇÏ ÚÁÛÉÔÁ ÓÅËÃÉÑ OutWget */
void Reloc( mp )
Module *mp;
{
char *relbuff; /* âÕÆÅÒ Ó ÉÎÆÏÒÍÁÃÉÅÊ Ï ÐÅÒÅÍÅÝÅÎÉÉ ..*/
int relblen; /* .. É ÅÇÏ ÁËÔÕÁÌØÎÁÑ ÄÌÉÎÁ */
int relindex; /* éÎÄÅËÓ × ÂÕÆÅÒÅ */
unsigned int x, modbase, modleng;
unsigned outseek; /* áÄÒÅÓ ÔÅÌÁ ÍÏÄÕÌÑ × ÆÁÊÌÅ */
unsigned rword;
int datum,datum0;
Symbol *sp;
outseek = mp->Mseek; /* áÄÒÅÓ × ÆÁÊÌÅ */
modbase = mp->Mldbase; /* áÄÒÅÓ × ÐÁÍÑÔÉ ËÏÎËÁÔÅÎÁÃÉÉ ÓÅÇÍÅÎÔÏ×*/
modleng = mp->Mtextsize + mp->Mdatasize;
ModSeek( modleng ); /* îÁ ÔÁÂÌÉÃÕ ÐÅÒÅÍÅÝÅÎÉÊ */
relindex = relblen = 0; /* éÍÉÔÉÒÕÅÍ ÉÓÞÅÒÐÁÎÉÅ ÂÕÆÅÒÁ */
for( x = 0; x < modleng; x += INTSIZE ){
if( relindex >= relblen ){ /* âÕÆÅÒ ÉÓÞÅÒÐÁÎ */
ModRead( &relbuff, &relblen );
/** if( relblen > ÏÓÔÁÔÏË_ÍÏÄÕÌÑ ) relblen = ??; **/
relindex = 0;
}
rword = (relbuff[ relindex++ ] & 0xFF);
rword += (relbuff[ relindex++ ] << 8);
if( rword == RABS ) continue; /* âÁÎÁÌØÎÏ, ÎÏ ÜÆÆËÔÉ×ÎÏ */
/* úÄÅÓØ ÕËÁÚÁÔÅÌØ ×/× ÓÔÏÉÔ */
datum0 = datum = OutWGet( outseek + x );
switch( rword & REF_TO ){
case RTEXT:
case RDATA:
datum += modbase; /* óÅÇÍÅÎÔÙ ÓÌÉÔÙ ×ÍÅÓÔÅ */
break;
case RBSS:
/* ðÒÉ×ÏÄÉÍ Ë ÓÍÅÝÅÎÉÀ × bss É ÚÁÔÅÍ Ë ÐÏÌÎÏÍÕ ÁÄÒÅÓÕ */
datum = datum0 - modleng + Tabss() + mp->Mbssoff;
break;
case REXT:
/* ðÏÉÓË ÓÉÍ×ÏÌÁ ÐÏ ÅÇÏ ÉÎÄÅËÓÕ ÄÌÑ ÌÏËÁÌØÎÏÊ ÔÁÂÌÉÃÙ */
sp = LookES( SYMNUM( rword ), mp );
if( sp == NULL ) Error(8); /* îÁ×ÅÒÎÏÅ, ÂÙÌ ÌÏËÁÌØÎÙÊ */
if( LOCATION( sp->Stype ) == UNDEF ){
char diagstr[ SNLENG+1 ];
MVS( sp->Sname, SNLENG, diagstr );
diagstr[ SNLENG ] = '\0';
Diagnose( 2, diagstr ); /* óÓÙÌËÁ ÎÁ ÎÅÏÐÒÅÄÅÌÅÎÎÙÊ */
}else{
datum += sp->Sval;
if( LOCATION( sp->Stype ) == BSS ){
datum += Tabss();
}
}
break;
case RABS:
break; /* movb $'*,ConsDBR */
default:
Error(1);
}
if( rword & RPCBIT ) datum -= modbase;
if( datum0 != datum ){
char outbuff[ INTSIZE ];
outbuff[0] = (char)datum;
outbuff[1] = (char)(datum>>8);
OutWrite( outbuff, INTSIZE );
}
} /*loop*/
}