4 * (C) Copyright 1989-1995
12 * - errdmp: show s_id as string rather than array [NCPS]
13 * - relr: add support for 11 bit 8051 addressing
14 * 02-Apr-98 JLH: don't output empty hex records
23 * The module lkrloc.c contains the functions which
24 * perform the relocation calculations.
26 * lkrloc.c contains the following functions:
45 * lkrloc.c the local variable errmsg[].
49 /* Global which holds the upper 16 bits of the last 32 bit area adress
50 * output. Useful only for iHex mode.
52 int lastExtendedAddress=-1;
54 /* Static variable which holds the index of last processed area.
55 * Useful only for iHex mode.
57 static int lastAreaIndex = -1;
59 /*)Function VOID reloc(c)
63 * The function reloc() calls a particular relocation
64 * function determined by the process code.
70 * int lkerr error flag
73 * int fprintf() c_library
74 * VOID rele() lkrloc.c
75 * VOID relp() lkrloc.c
76 * VOID relr() lkrloc.c
77 * VOId relt() lkrloc.c
80 * Refer to the called relocation functions.
105 fprintf(stderr, "Undefined Relocation Operation\n");
113 /*)Function VOID relt()
115 * The function relt() evaluates a T line read by
116 * the linker. Each byte value read is saved in the
117 * rtval[] array, rtflg[] is set, and the number of
118 * evaluations is maintained in rtcnt.
122 * T xx xx nn nn nn nn nn ...
125 * In: "T n0 n1 n2 n3 ... nn"
127 * Out: 0 1 2 .. rtcnt
128 * +----+----+----+----+----+
129 * rtval | n0 | n1 | n2 | .. | nn |
130 * +----+----+----+----+----+
131 * rtflag| 1 | 1 | 1 | 1 | 1 |
132 * +----+----+----+----+----+
134 * The T line contains the assembled code output by the assem-
135 * bler with xx xx being the offset address from the current area
136 * base address and nn being the assembled instructions and data in
143 * int rtcnt number of values evaluated
144 * int rtflg[] array of evaluation flags
145 * int rtval[] array of evaluation values
148 * int eval() lkeval.c
152 * Linker input T line evaluated.
161 rtval[rtcnt] = eval();
168 /*)Function VOID relr()
170 * The function relr() evaluates a R line read by
171 * the linker. The R line data is combined with the
172 * previous T line data to perform the relocation of
173 * code and data bytes. The S19 / IHX output and
174 * translation of the LST files to RST files may be
179 * R 0 0 nn nn n1 n2 xx xx ...
181 * The R line provides the relocation information to the linker.
182 * The nn nn value is the current area index, i.e. which area the
183 * current values were assembled. Relocation information is en-
184 * coded in groups of 4 bytes:
186 * 1. n1 is the relocation mode and object format
187 * 1. bit 0 word(0x00)/byte(0x01)
188 * 2. bit 1 relocatable area(0x00)/symbol(0x02)
189 * 3. bit 2 normal(0x00)/PC relative(0x04) relocation
190 * 4. bit 3 1-byte(0x00)/2-byte(0x08) object format for
192 * 5. bit 4 signed(0x00)/unsigned(0x10) byte data
193 * 6. bit 5 normal(0x00)/page '0'(0x20) reference
194 * 7. bit 6 normal(0x00)/page 'nnn'(0x40) reference
196 * 2. n2 is a byte index into the corresponding (i.e. pre-
197 * ceeding) T line data (i.e. a pointer to the data to be
198 * updated by the relocation). The T line data may be
199 * 1-byte or 2-byte byte data format or 2-byte word
202 * 3. xx xx is the area/symbol index for the area/symbol be-
203 * ing referenced. the corresponding area/symbol is found
204 * in the header area/symbol lists.
206 * The groups of 4 bytes are repeated for each item requiring relo-
207 * cation in the preceeding T line.
210 * areax **a pointer to array of area pointers
211 * int aindex area index
212 * char *errmsg[] array of pointers to error strings
213 * int error error code
214 * int lkerr error flag
215 * int mode relocation mode
216 * adrr_t paga paging base area address
217 * Addr_T pags paging symbol address
218 * Addr_T pc relocated base address
219 * Addr_T r PCR relocation value
220 * Addr_T reli relocation initial value
221 * Addr_T relv relocation final value
222 * int rindex symbol / area index
223 * Addr_T rtbase base code address
224 * Addr_T rtofst rtval[] index offset
225 * int rtp index into T data
226 * sym **s pointer to array of symbol pointers
229 * head *hp pointer to the head structure
230 * rerr rerr linker error structure
231 * FILE *stderr standard error device
234 * Addr_T adb_b() lkrloc.c
235 * Addr_T adb_lo() lkrloc.c
236 * Addr_T adb_hi() lkrloc.c
237 * Addr_T adw_w() lkrloc.c
238 * Addr_T evword() lkrloc.c
239 * int eval() lkeval.c
240 * int fprintf() c_library
242 * int lkulist lklist.c
244 * VOID relerr() lkrloc.c
246 * int symval() lksym.c
249 * The R and T lines are combined to produce
250 * relocated code and data. Output S19 / IHX
251 * and relocated listing files may be produced.
258 register Addr_T reli, relv;
259 int aindex, rindex, rtp, error;
260 Addr_T r, rtbase, rtofst, paga, pags, pc;
265 * Get area and symbol lists
273 if (eval() != (R_WORD | R_AREA) || eval()) {
274 fprintf(stderr, "R input error\n");
282 if (aindex >= hp->h_narea) {
283 fprintf(stderr, "R area error\n");
291 rtbase = adw_w(0, 0);
297 pc = adw_w(a[aindex]->a_addr, 0);
300 printf("area %d base address: 0x%x size: 0x%x rtbase: 0x%x\n", aindex,
301 a[aindex]->a_addr, a[aindex]->a_size, rtbase);
304 * Do remaining relocations
310 if ((mode & R_ESCAPE_MASK) == R_ESCAPE_MASK)
312 mode = ((mode & ~R_ESCAPE_MASK) << 8) | eval();
313 /* printf("unescaping rmode\n"); */
320 * R_SYM or R_AREA references
323 if (rindex >= hp->h_nglob) {
324 fprintf(stderr, "R symbol error\n");
328 reli = symval(s[rindex]);
330 if (rindex >= hp->h_narea) {
331 fprintf(stderr, "R area error\n");
335 reli = a[rindex]->a_addr;
343 reli -= (pc + (rtp-rtofst) + 1);
345 reli -= (pc + (rtp-rtofst) + 2);
350 * R_PAG0 or R_PAG addressing
352 if (mode & (R_PAG0 | R_PAG)) {
353 paga = sdp.s_area->a_addr;
359 * R_BYTE or R_WORD operation
364 /* This is a three byte address, of which
365 * we will select one byte.
369 relv = adb_24_bit(reli, rtp);
371 else if (mode & R_HIB)
373 /* printf("24 bit address selecting hi byte.\n"); */
374 relv = adb_24_hi(reli, rtp);
376 else if (mode & R_MSB)
378 /* Note that in 24 bit mode, R_MSB
379 * is really the middle byte, not
380 * the most significant byte.
382 * This is ugly and I can only apologize
385 /* printf("24 bit address selecting middle byte.\n"); */
386 relv = adb_24_mid(reli, rtp);
390 /* printf("24 bit address selecting lo byte.\n"); */
391 relv = adb_24_lo(reli, rtp);
394 else if (mode & R_BYT2) {
395 /* This is a two byte address, of
396 * which we will select one byte.
399 relv = adb_bit(reli, rtp);
400 } else if (mode & R_MSB) {
401 relv = adb_hi(reli, rtp);
403 relv = adb_lo(reli, rtp);
406 relv = adb_b(reli, rtp);
408 } else if (IS_R_J11(mode)) {
409 /* JLH: 11 bit jump destination for 8051. Forms
410 / two byte instruction with op-code bits
412 / rtp points at 3 byte locus: first two
413 / will get the instructiion. third one
417 /* Calculate absolute destination
418 / relv must be on same 2K page as pc
420 relv = adw_w(reli, rtp);
422 if ((relv & ~0x7ff) != ((pc + rtp - rtofst) & ~0x7ff)) {
426 /* Merge MSB (byte 0) with op-code, ignoring
427 / top 5 bits of address. Then hide the op-code
429 rtval[rtp] = ((rtval[rtp] & 0x07)<<5) | rtval[rtp+2];
433 else if (IS_R_J19(mode)) {
434 /* 19 bit jump destination for DS80C390. Forms
435 / three byte instruction with op-code bits
437 / rtp points at 4 byte locus: first three
438 / will get the instructiion. fourth one
442 /* Calculate absolute destination
443 / relv must be on same 512K page as pc
445 relv = adw_24(reli, rtp);
447 if ((relv & ~0x7ffff) != ((pc + rtp - rtofst) & ~0x7ffff)) {
451 /* Merge MSB (byte 0) with op-code, ignoring
452 / top 5 bits of address. Then hide the op-code
454 rtval[rtp] = ((rtval[rtp] & 0x07)<<5) | rtval[rtp+3];
458 else if (IS_C24(mode))
461 relv = adw_24(reli, rtp);
465 /* 16 bit address. */
466 relv = adw_w(reli, rtp);
470 * R_BYTE with R_BYT2 offset adjust
479 * Unsigned Byte Checking
481 if (mode & R_USGN && mode & R_BYTE && relv & ~0xFF)
485 * PCR Relocation Error Checking
487 if (mode & R_PCR && mode & R_BYTE) {
489 if (r != (Addr_T) ~0x7F && r != 0)
494 * Page Relocation Error Checking
496 /* if (mode & R_PAG0 && (relv & ~0xFF || paga || pags))
498 if (mode & R_PAG && (relv & ~0xFF))
500 if ((mode & R_BIT) && (relv & ~0x87FF))
507 rerr.aindex = aindex;
509 rerr.rtbase = rtbase + rtp - rtofst - 1;
510 rerr.rindex = rindex;
511 rerr.rval = relv - reli;
512 relerr(errmsg[error-1]);
519 /* JLH: output only if data (beyond two byte address) */
520 if ((oflag == 1) && (rtcnt > 2)) {
521 int extendedAddress = (a[aindex]->a_addr >> 16) & 0xffff;
523 /* Boy, is this a hack: for ABS sections, the
524 * base address is stored as zero, and the T records
525 * indicate the offset from zero.
527 * Since T records can only indicate a 16 bit offset, this
528 * obviously creates a problem for ABS segments located
529 * above 64K (this is only meaningful in flat24 mode).
531 * However, the size of an ABS area is stored as
532 * base address + section size (I suspect this is a bug,
533 * but it's a handy one right now). So the upper 8 bits of
534 * the 24 bit address are stored in the size record.
537 * This is another reason why we can't have areas greater
538 * than 64K yet, even in flat24 mode.
540 // extendedAddress += ((a[aindex]->a_size) >> 16 & 0xffff);
541 // commented out by jr
543 if (lastAreaIndex != aindex) {
544 lastAreaIndex = aindex;
548 if (extendedAddress != lastExtendedAddress)
551 if (lastExtendedAddress!=-1) {
552 printf("output extended linear address record 0x%x 0x%x\n",
553 extendedAddress, lastExtendedAddress);
558 ihxEntendedLinearAddress(extendedAddress);
560 else if (extendedAddress)
562 /* Not allowed to generate extended address records,
563 * but one is called for here...
566 "warning: extended linear address encountered; "
567 "you probably want the -r flag.\n");
569 lastExtendedAddress = extendedAddress;
573 if ((oflag == 2) && (rtcnt > 2)) {
579 "Unsigned Byte error",
580 "Byte PCR relocation error",
581 "Page0 relocation error",
582 "Page Mode relocation error",
583 "Bit-addressable relocation error"
587 /*)Function VOID relp()
589 * The function relp() evaluates a P line read by
590 * the linker. The P line data is combined with the
591 * previous T line data to set the base page address
592 * and test the paging boundary and length.
596 * P 0 0 nn nn n1 n2 xx xx
598 * The P line provides the paging information to the linker as
599 * specified by a .setdp directive. The format of the relocation
600 * information is identical to that of the R line. The correspond-
601 * ing T line has the following information:
602 * T xx xx aa aa bb bb
604 * Where aa aa is the area reference number which specifies the
605 * selected page area and bb bb is the base address of the page.
606 * bb bb will require relocation processing if the 'n1 n2 xx xx' is
607 * specified in the P line. The linker will verify that the base
608 * address is on a 256 byte boundary and that the page length of an
609 * area defined with the PAG type is not larger than 256 bytes.
612 * areax **a pointer to array of area pointers
613 * int aindex area index
614 * int mode relocation mode
615 * Addr_T relv relocation value
616 * int rindex symbol / area index
617 * int rtp index into T data
618 * sym **s pointer to array of symbol pointers
621 * head *hp pointer to the head structure
622 * int lkerr error flag
623 * sdp sdp base page structure
624 * FILE *stderr standard error device
627 * Addr_T adw_w() lkrloc.c
628 * Addr_T evword() lkrloc.c
629 * int eval() lkeval.c
630 * int fprintf() c_library
632 * int symval() lksym.c
635 * The P and T lines are combined to set
636 * the base page address and report any
643 register int aindex, rindex;
650 * Get area and symbol lists
658 if (eval() != (R_WORD | R_AREA) || eval()) {
659 fprintf(stderr, "P input error\n");
667 if (aindex >= hp->h_narea) {
668 fprintf(stderr, "P area error\n");
674 * Do remaining relocations
682 * R_SYM or R_AREA references
685 if (rindex >= hp->h_nglob) {
686 fprintf(stderr, "P symbol error\n");
690 relv = symval(s[rindex]);
692 if (rindex >= hp->h_narea) {
693 fprintf(stderr, "P area error\n");
697 relv = a[rindex]->a_addr;
706 if (aindex >= hp->h_narea) {
707 fprintf(stderr, "P area error\n");
711 sdp.s_areax = a[aindex];
712 sdp.s_area = sdp.s_areax->a_bap;
713 sdp.s_addr = adw_w(0,4);
714 if (sdp.s_area->a_addr & 0xFF || sdp.s_addr & 0xFF)
715 relerp("Page Definition Boundary Error");
718 /*)Function VOID rele()
720 * The function rele() closes all open output files
721 * at the end of the linking process.
727 * int oflag output type flag
728 * int uflag relocation listing flag
732 * VOID lkulist() lklist.c
736 * All open output files are closed.
753 /*)Function Addr_T evword()
755 * The function evword() combines two byte values
756 * into a single word value.
759 * Addr_T v temporary evaluation variable
762 * hilo byte ordering parameter
765 * int eval() lkeval.c
768 * Relocation text line is scanned to combine
769 * two byte values into a single word value.
787 /*)Function Addr_T adb_b(v, i)
789 * int v value to add to byte
790 * int i rtval[] index
792 * The function adb_b() adds the value of v to
793 * the single byte value contained in rtval[i].
794 * The new value of rtval[i] is returned.
806 * The value of rtval[] is changed.
810 Addr_T adb_b(register Addr_T v, register int i)
812 return(rtval[i] += v);
815 /*)Function Addr_T adb_bit(v, i)
817 * int v value to add to byte
818 * int i rtval[] index
820 * The function adb_bit() converts the single
821 * byte address value contained in rtval[i] to bit-
822 * addressable space and adds the value of v to it.
823 * The new value of rtval[i] is returned.
826 * Addr_T j temporary evaluation variable
835 * The value of rtval[] is changed.
839 Addr_T adb_bit(register Addr_T v, register int i)
843 j = adb_lo(v, i) & 0xFF;
844 if ((j >= 0x20) && (j <= 0x2F)) {
846 } else if ((j < 0x80) || ((j & 0x07) != 0)) {
847 return(0x100);//error
851 j = rtval[i+1] = j + (rtval[i] & 0x07);
853 j = rtval[i] = j + (rtval[i+1] & 0x07);
858 /*)Function Addr_T adb_lo(v, i)
860 * int v value to add to byte
861 * int i rtval[] index
863 * The function adb_lo() adds the value of v to the
864 * double byte value contained in rtval[i] and rtval[i+1].
865 * The new value of rtval[i] / rtval[i+1] is returned.
866 * The MSB rtflg[] is cleared.
869 * Addr_T j temporary evaluation variable
872 * hilo byte ordering parameter
878 * The value of rtval[] is changed.
879 * The rtflg[] value corresponding to the
880 * MSB of the word value is cleared to reflect
881 * the fact that the LSB is the selected byte.
885 Addr_T adb_lo(Addr_T v, int i)
901 /*)Function Addr_T adb_hi(v, i)
903 * int v value to add to byte
904 * int i rtval[] index
906 * The function adb_hi() adds the value of v to the
907 * double byte value contained in rtval[i] and rtval[i+1].
908 * The new value of rtval[i] / rtval[i+1] is returned.
909 * The LSB rtflg[] is cleared.
912 * Addr_T j temporary evaluation variable
915 * hilo byte ordering parameter
921 * The value of rtval[] is changed.
922 * The rtflg[] value corresponding to the
923 * LSB of the word value is cleared to reflect
924 * the fact that the MSB is the selected byte.
928 Addr_T adb_hi(Addr_T v, int i)
944 /*)Function Addr_T adb_24_bit(v, i)
946 * int v value to add to byte
947 * int i rtval[] index
949 * The function adb_24_bit() converts the single
950 * byte address value contained in rtval[i] to bit-
951 * addressable space and adds the value of v to it.
952 * The new value of rtval[i] is returned.
955 * Addr_T j temporary evaluation variable
964 * The value of rtval[] is changed.
968 Addr_T adb_24_bit(register Addr_T v, register int i)
972 j = adb_24_lo(v, i) & 0xFF;
973 if ((j >= 0x20) && (j <= 0x2F)) {
975 } else if ((j < 0x80) || ((j & 0x07) != 0)) {
976 return(0x100);//error
980 j = rtval[i+2] = j + (rtval[i+1] & 0x07);
982 j = rtval[i] = j + (rtval[i+1] & 0x07);
987 /*)Function Addr_T adb_24_hi(v, i)
989 * int v value to add to byte
990 * int i rtval[] index
992 * The function adb_24_hi() adds the value of v to the
993 * 24 bit value contained in rtval[i] - rtval[i+2].
994 * The new value of rtval[i] / rtval[i+1] is returned.
995 * The LSB & middle byte rtflg[] is cleared.
998 * Addr_T j temporary evaluation variable
1001 * hilo byte ordering parameter
1007 * The value of rtval[] is changed.
1008 * The rtflg[] value corresponding to the
1009 * LSB & middle byte of the word value is cleared to
1010 * reflect the fact that the MSB is the selected byte.
1014 Addr_T adb_24_hi(Addr_T v, int i)
1020 /* Remove the lower two bytes. */
1034 /*)Function Addr_T adb_24_mid(v, i)
1036 * int v value to add to byte
1037 * int i rtval[] index
1039 * The function adb_24_mid() adds the value of v to the
1040 * 24 bit value contained in rtval[i] - rtval[i+2].
1041 * The new value of rtval[i] / rtval[i+1] is returned.
1042 * The LSB & MSB byte rtflg[] is cleared.
1045 * Addr_T j temporary evaluation variable
1048 * hilo byte ordering parameter
1054 * The value of rtval[] is changed.
1055 * The rtflg[] value corresponding to the
1056 * LSB & MSB of the 24 bit value is cleared to reflect
1057 * the fact that the middle byte is the selected byte.
1061 Addr_T adb_24_mid(Addr_T v, int i)
1067 /* remove the MSB & LSB. */
1074 /*)Function Addr_T adb_24_lo(v, i)
1076 * int v value to add to byte
1077 * int i rtval[] index
1079 * The function adb_24_lo() adds the value of v to the
1080 * 24 bit value contained in rtval[i] - rtval[i+2].
1081 * The new value of rtval[i] / rtval[i+1] is returned.
1082 * The MSB & middle byte rtflg[] is cleared.
1085 * Addr_T j temporary evaluation variable
1088 * hilo byte ordering parameter
1094 * The value of rtval[] is changed.
1095 * The rtflg[] value corresponding to the
1096 * MSB & middle byte of the word value is cleared to
1097 * reflect the fact that the LSB is the selected byte.
1101 Addr_T adb_24_lo(Addr_T v, int i)
1107 /* Remove the upper two bytes. */
1121 /*)Function Addr_T adw_w(v, i)
1123 * int v value to add to word
1124 * int i rtval[] index
1126 * The function adw_w() adds the value of v to the
1127 * word value contained in rtval[i] and rtval[i+1].
1128 * The new value of rtval[i] / rtval[i+1] is returned.
1131 * Addr_T j temporary evaluation variable
1134 * hilo byte ordering parameter
1140 * The word value of rtval[] is changed.
1144 Addr_T adw_w(register Addr_T v, register int i)
1149 j = v + (rtval[i] << 8) + (rtval[i+1] & 0xff);
1150 rtval[i] = (j >> 8) & 0xff;
1151 rtval[i+1] = j & 0xff;
1153 j = v + (rtval[i] & 0xff) + (rtval[i+1] << 8);
1154 rtval[i] = j & 0xff;
1155 rtval[i+1] = (j >> 8) & 0xff;
1160 /*)Function Addr_T adw_24(v, i)
1162 * int v value to add to word
1163 * int i rtval[] index
1165 * The function adw_w() adds the value of v to the
1166 * 24 bit value contained in rtval[i] - rtval[i+2].
1167 * The new value of rtval[i] - rtval[i+2] is returned.
1170 * Addr_T j temporary evaluation variable
1173 * hilo byte ordering parameter
1179 * The word value of rtval[] is changed.
1182 Addr_T adw_24(Addr_T v, int i)
1187 j = v + ((rtval[i] & 0xff) << 16)
1188 + ((rtval[i+1] & 0xff) << 8)
1189 + (rtval[i+2] & 0xff);
1190 rtval[i] = (j >> 16) & 0xff;
1191 rtval[i+1] = (j >> 8) & 0xff;
1192 rtval[i+2] = j & 0xff;
1194 j = v + (rtval[i] & 0xff)
1195 + ((rtval[i+1] & 0xff) << 8)
1196 + ((rtval[i+2] & 0xff) << 16);
1197 rtval[i] = j & 0xff;
1198 rtval[i+1] = (j >> 8) & 0xff;
1199 rtval[i+2] = (j >> 16) & 0xff;
1204 /*)Function Addr_T adw_lo(v, i)
1206 * int v value to add to byte
1207 * int i rtval[] index
1209 * The function adw_lo() adds the value of v to the
1210 * double byte value contained in rtval[i] and rtval[i+1].
1211 * The new value of rtval[i] / rtval[i+1] is returned.
1212 * The MSB rtval[] is zeroed.
1215 * Addr_T j temporary evaluation variable
1218 * hilo byte ordering parameter
1224 * The value of rtval[] is changed.
1225 * The MSB of the word value is cleared to reflect
1226 * the fact that the LSB is the selected byte.
1230 Addr_T adw_lo(Addr_T v, int i)
1246 /*)Function Addr_T adw_hi(v, i)
1248 * int v value to add to byte
1249 * int i rtval[] index
1251 * The function adw_hi() adds the value of v to the
1252 * double byte value contained in rtval[i] and rtval[i+1].
1253 * The new value of rtval[i] / rtval[i+1] is returned.
1254 * The MSB and LSB values are interchanged.
1255 * The MSB rtval[] is zeroed.
1258 * Addr_T j temporary evaluation variable
1261 * hilo byte ordering parameter
1267 * The value of rtval[] is changed.
1268 * The MSB and LSB values are interchanged and
1269 * then the MSB cleared.
1273 Addr_T adw_hi(Addr_T v, int i)
1279 * LSB = MSB, Clear MSB
1282 rtval[i+1] = rtval[i];
1285 rtval[i] = rtval[i+1];
1291 /*)Function VOID relerr(str)
1293 * char *str error string
1295 * The function relerr() outputs the error string to
1296 * stderr and to the map file (if it is open).
1302 * FILE *mfp handle for the map file
1305 * VOID errdmp() lkrloc.c
1308 * Error message inserted into map file.
1312 VOID relerr(char *str)
1314 errdmp(stderr, str);
1319 /*)Function VOID errdmp(fptr, str)
1321 * FILE *fptr output file handle
1322 * char *str error string
1324 * The function errdmp() outputs the error string str
1325 * to the device specified by fptr. Additional information
1326 * is output about the definition and referencing of
1327 * the symbol / area error.
1330 * int mode error mode
1331 * int aindex area index
1332 * int lkerr error flag
1333 * int rindex error index
1334 * sym **s pointer to array of symbol pointers
1335 * areax **a pointer to array of area pointers
1336 * areax *raxp error area extension pointer
1339 * sdp sdp base page structure
1342 * int fprintf() c_library
1343 * VOID prntval() lkrloc.c
1350 VOID errdmp(FILE *fptr, char *str)
1352 int mode, aindex, rindex;
1361 aindex = rerr.aindex;
1362 rindex = rerr.rindex;
1367 fprintf(fptr, "\n?ASlink-Warning-%s", str);
1371 * Print symbol if symbol based
1374 fprintf(fptr, " for symbol %s\n",
1375 &s[rindex]->s_id[0]);
1377 fprintf(fptr, "\n");
1384 " file module area offset\n");
1386 " Refby %-8.8s %-8.8s %-8.8s ",
1389 &a[aindex]->a_bap->a_id[0]);
1390 prntval(fptr, rerr.rtbase);
1396 raxp = s[rindex]->s_axp;
1401 " Defin %-8.8s %-8.8s %-8.8s ",
1402 raxp->a_bhp->h_lfile->f_idp,
1403 &raxp->a_bhp->m_id[0],
1404 &raxp->a_bap->a_id[0]);
1406 prntval(fptr, s[rindex]->s_addr);
1408 prntval(fptr, rerr.rval);
1412 /*)Function VOID prntval(fptr, v)
1414 * FILE *fptr output file handle
1415 * Addr_T v value to output
1417 * The function prntval() outputs the value v, in the
1418 * currently selected radix, to the device specified
1425 * int xflag current radix
1428 * int fprintf() c_library
1435 VOID prntval(FILE *fptr, Addr_T v)
1438 fprintf(fptr, "%04X\n", v);
1441 fprintf(fptr, "%06o\n", v);
1444 fprintf(fptr, "%05u\n", v);
1448 /*)Function VOID relerp(str)
1450 * char *str error string
1452 * The function relerp() outputs the paging error string to
1453 * stderr and to the map file (if it is open).
1459 * FILE *mfp handle for the map file
1462 * VOID erpdmp() lkrloc.c
1465 * Error message inserted into map file.
1469 VOID relerp(char *str)
1471 erpdmp(stderr, str);
1476 /*)Function VOID erpdmp(fptr, str)
1478 * FILE *fptr output file handle
1479 * char *str error string
1481 * The function erpdmp() outputs the error string str
1482 * to the device specified by fptr.
1485 * head *thp pointer to head structure
1488 * int lkerr error flag
1489 * sdp sdp base page structure
1492 * int fprintf() c_library
1493 * VOID prntval() lkrloc.c
1500 VOID erpdmp(FILE *fptr, char *str)
1502 register struct head *thp;
1504 thp = sdp.s_areax->a_bhp;
1509 fprintf(fptr, "\n?ASlink-Warning-%s\n", str);
1516 " file module pgarea pgoffset\n");
1518 " PgDef %-8.8s %-8.8s %-8.8s ",
1519 thp->h_lfile->f_idp,
1521 &sdp.s_area->a_id[0]);
1522 prntval(fptr, sdp.s_area->a_addr + sdp.s_addr);