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]);
329 } else if ((IS_R_J11(mode) || IS_R_J19(mode)) && (rindex == 0xFFFF)) {
330 /* absolute acall/ajmp address */
333 if (rindex >= hp->h_narea) {
334 fprintf(stderr, "R area error\n");
338 reli = a[rindex]->a_addr;
346 reli -= (pc + (rtp-rtofst) + 1);
348 reli -= (pc + (rtp-rtofst) + 2);
353 * R_PAG0 or R_PAG addressing
355 if (mode & (R_PAG0 | R_PAG)) {
356 paga = sdp.s_area->a_addr;
362 * R_BYTE or R_WORD operation
367 /* This is a three byte address, of which
368 * we will select one byte.
372 relv = adb_24_bit(reli, rtp);
374 else if (mode & R_HIB)
376 /* printf("24 bit address selecting hi byte.\n"); */
377 relv = adb_24_hi(reli, rtp);
379 else if (mode & R_MSB)
381 /* Note that in 24 bit mode, R_MSB
382 * is really the middle byte, not
383 * the most significant byte.
385 * This is ugly and I can only apologize
388 /* printf("24 bit address selecting middle byte.\n"); */
389 relv = adb_24_mid(reli, rtp);
393 /* printf("24 bit address selecting lo byte.\n"); */
394 relv = adb_24_lo(reli, rtp);
397 else if (mode & R_BYT2) {
398 /* This is a two byte address, of
399 * which we will select one byte.
402 relv = adb_bit(reli, rtp);
403 } else if (mode & R_MSB) {
404 relv = adb_hi(reli, rtp);
406 relv = adb_lo(reli, rtp);
409 relv = adb_b(reli, rtp);
411 } else if (IS_R_J11(mode)) {
412 /* JLH: 11 bit jump destination for 8051. Forms
413 / two byte instruction with op-code bits
415 / rtp points at 3 byte locus: first two
416 / will get the instructiion. third one
420 /* Calculate absolute destination
421 / relv must be on same 2K page as pc
423 relv = adw_w(reli, rtp);
425 if ((relv & ~0x7ff) != ((pc + rtp - rtofst) & ~0x7ff)) {
429 /* Merge MSB (byte 0) with op-code, ignoring
430 / top 5 bits of address. Then hide the op-code
432 rtval[rtp] = ((rtval[rtp] & 0x07)<<5) | rtval[rtp+2];
436 else if (IS_R_J19(mode)) {
437 /* 19 bit jump destination for DS80C390. Forms
438 / three byte instruction with op-code bits
440 / rtp points at 4 byte locus: first three
441 / will get the instructiion. fourth one
445 /* Calculate absolute destination
446 / relv must be on same 512K page as pc
448 relv = adw_24(reli, rtp);
450 if ((relv & ~0x7ffff) != ((pc + rtp - rtofst) & ~0x7ffff)) {
454 /* Merge MSB (byte 0) with op-code, ignoring
455 / top 5 bits of address. Then hide the op-code
457 rtval[rtp] = ((rtval[rtp] & 0x07)<<5) | rtval[rtp+3];
461 else if (IS_C24(mode))
464 relv = adw_24(reli, rtp);
468 /* 16 bit address. */
469 relv = adw_w(reli, rtp);
473 * R_BYTE with R_BYT2 offset adjust
482 * Unsigned Byte Checking
484 if (mode & R_USGN && mode & R_BYTE && relv & ~0xFF)
488 * PCR Relocation Error Checking
490 if (mode & R_PCR && mode & R_BYTE) {
492 if (r != (Addr_T) ~0x7F && r != 0)
497 * Page Relocation Error Checking
499 /* if (mode & R_PAG0 && (relv & ~0xFF || paga || pags))
501 if (mode & R_PAG && (relv & ~0xFF))
503 if ((mode & R_BIT) && (relv & ~0x87FF))
510 rerr.aindex = aindex;
512 rerr.rtbase = rtbase + rtp - rtofst - 1;
513 rerr.rindex = rindex;
514 rerr.rval = relv - reli;
515 relerr(errmsg[error-1]);
522 /* JLH: output only if data (beyond two byte address) */
523 if ((oflag == 1) && (rtcnt > 2)) {
524 int extendedAddress = (a[aindex]->a_addr >> 16) & 0xffff;
526 /* Boy, is this a hack: for ABS sections, the
527 * base address is stored as zero, and the T records
528 * indicate the offset from zero.
530 * Since T records can only indicate a 16 bit offset, this
531 * obviously creates a problem for ABS segments located
532 * above 64K (this is only meaningful in flat24 mode).
534 * However, the size of an ABS area is stored as
535 * base address + section size (I suspect this is a bug,
536 * but it's a handy one right now). So the upper 8 bits of
537 * the 24 bit address are stored in the size record.
540 * This is another reason why we can't have areas greater
541 * than 64K yet, even in flat24 mode.
543 // extendedAddress += ((a[aindex]->a_size) >> 16 & 0xffff);
544 // commented out by jr
546 if (lastAreaIndex != aindex) {
547 lastAreaIndex = aindex;
551 if (extendedAddress != lastExtendedAddress)
554 if (lastExtendedAddress!=-1) {
555 printf("output extended linear address record 0x%x 0x%x\n",
556 extendedAddress, lastExtendedAddress);
561 ihxExtendedLinearAddress(extendedAddress);
563 else if (extendedAddress)
565 /* Not allowed to generate extended address records,
566 * but one is called for here...
569 "warning: extended linear address encountered; "
570 "you probably want the -r flag.\n");
572 lastExtendedAddress = extendedAddress;
576 if ((oflag == 2) && (rtcnt > 2)) {
582 "Unsigned Byte error",
583 "Byte PCR relocation error",
584 "Page0 relocation error",
585 "Page Mode relocation error",
586 "Bit-addressable relocation error"
590 /*)Function VOID relp()
592 * The function relp() evaluates a P line read by
593 * the linker. The P line data is combined with the
594 * previous T line data to set the base page address
595 * and test the paging boundary and length.
599 * P 0 0 nn nn n1 n2 xx xx
601 * The P line provides the paging information to the linker as
602 * specified by a .setdp directive. The format of the relocation
603 * information is identical to that of the R line. The correspond-
604 * ing T line has the following information:
605 * T xx xx aa aa bb bb
607 * Where aa aa is the area reference number which specifies the
608 * selected page area and bb bb is the base address of the page.
609 * bb bb will require relocation processing if the 'n1 n2 xx xx' is
610 * specified in the P line. The linker will verify that the base
611 * address is on a 256 byte boundary and that the page length of an
612 * area defined with the PAG type is not larger than 256 bytes.
615 * areax **a pointer to array of area pointers
616 * int aindex area index
617 * int mode relocation mode
618 * Addr_T relv relocation value
619 * int rindex symbol / area index
620 * int rtp index into T data
621 * sym **s pointer to array of symbol pointers
624 * head *hp pointer to the head structure
625 * int lkerr error flag
626 * sdp sdp base page structure
627 * FILE *stderr standard error device
630 * Addr_T adw_w() lkrloc.c
631 * Addr_T evword() lkrloc.c
632 * int eval() lkeval.c
633 * int fprintf() c_library
635 * int symval() lksym.c
638 * The P and T lines are combined to set
639 * the base page address and report any
646 register int aindex, rindex;
653 * Get area and symbol lists
661 if (eval() != (R_WORD | R_AREA) || eval()) {
662 fprintf(stderr, "P input error\n");
670 if (aindex >= hp->h_narea) {
671 fprintf(stderr, "P area error\n");
677 * Do remaining relocations
685 * R_SYM or R_AREA references
688 if (rindex >= hp->h_nglob) {
689 fprintf(stderr, "P symbol error\n");
693 relv = symval(s[rindex]);
695 if (rindex >= hp->h_narea) {
696 fprintf(stderr, "P area error\n");
700 relv = a[rindex]->a_addr;
709 if (aindex >= hp->h_narea) {
710 fprintf(stderr, "P area error\n");
714 sdp.s_areax = a[aindex];
715 sdp.s_area = sdp.s_areax->a_bap;
716 sdp.s_addr = adw_w(0,4);
717 if (sdp.s_area->a_addr & 0xFF || sdp.s_addr & 0xFF)
718 relerp("Page Definition Boundary Error");
721 /*)Function VOID rele()
723 * The function rele() closes all open output files
724 * at the end of the linking process.
730 * int oflag output type flag
731 * int uflag relocation listing flag
735 * VOID lkulist() lklist.c
739 * All open output files are closed.
756 /*)Function Addr_T evword()
758 * The function evword() combines two byte values
759 * into a single word value.
762 * Addr_T v temporary evaluation variable
765 * hilo byte ordering parameter
768 * int eval() lkeval.c
771 * Relocation text line is scanned to combine
772 * two byte values into a single word value.
790 /*)Function Addr_T adb_b(v, i)
792 * int v value to add to byte
793 * int i rtval[] index
795 * The function adb_b() adds the value of v to
796 * the single byte value contained in rtval[i].
797 * The new value of rtval[i] is returned.
809 * The value of rtval[] is changed.
813 Addr_T adb_b(register Addr_T v, register int i)
815 return(rtval[i] += v);
818 /*)Function Addr_T adb_bit(v, i)
820 * int v value to add to byte
821 * int i rtval[] index
823 * The function adb_bit() converts the single
824 * byte address value contained in rtval[i] to bit-
825 * addressable space and adds the value of v to it.
826 * The new value of rtval[i] is returned.
829 * Addr_T j temporary evaluation variable
838 * The value of rtval[] is changed.
842 Addr_T adb_bit(register Addr_T v, register int i)
846 j = adb_lo(v, i) & 0xFF;
847 if ((j >= 0x20) && (j <= 0x2F)) {
849 } else if ((j < 0x80) || ((j & 0x07) != 0)) {
850 return(0x100);//error
854 j = rtval[i+1] = j + (rtval[i] & 0x07);
856 j = rtval[i] = j + (rtval[i+1] & 0x07);
861 /*)Function Addr_T adb_lo(v, i)
863 * int v value to add to byte
864 * int i rtval[] index
866 * The function adb_lo() adds the value of v to the
867 * double byte value contained in rtval[i] and rtval[i+1].
868 * The new value of rtval[i] / rtval[i+1] is returned.
869 * The MSB rtflg[] is cleared.
872 * Addr_T j temporary evaluation variable
875 * hilo byte ordering parameter
881 * The value of rtval[] is changed.
882 * The rtflg[] value corresponding to the
883 * MSB of the word value is cleared to reflect
884 * the fact that the LSB is the selected byte.
888 Addr_T adb_lo(Addr_T v, int i)
904 /*)Function Addr_T adb_hi(v, i)
906 * int v value to add to byte
907 * int i rtval[] index
909 * The function adb_hi() adds the value of v to the
910 * double byte value contained in rtval[i] and rtval[i+1].
911 * The new value of rtval[i] / rtval[i+1] is returned.
912 * The LSB rtflg[] is cleared.
915 * Addr_T j temporary evaluation variable
918 * hilo byte ordering parameter
924 * The value of rtval[] is changed.
925 * The rtflg[] value corresponding to the
926 * LSB of the word value is cleared to reflect
927 * the fact that the MSB is the selected byte.
931 Addr_T adb_hi(Addr_T v, int i)
947 /*)Function Addr_T adb_24_bit(v, i)
949 * int v value to add to byte
950 * int i rtval[] index
952 * The function adb_24_bit() converts the single
953 * byte address value contained in rtval[i] to bit-
954 * addressable space and adds the value of v to it.
955 * The new value of rtval[i] is returned.
958 * Addr_T j temporary evaluation variable
967 * The value of rtval[] is changed.
971 Addr_T adb_24_bit(register Addr_T v, register int i)
975 j = adb_24_lo(v, i) & 0xFF;
976 if ((j >= 0x20) && (j <= 0x2F)) {
978 } else if ((j < 0x80) || ((j & 0x07) != 0)) {
979 return(0x100);//error
983 j = rtval[i+2] = j + (rtval[i+1] & 0x07);
985 j = rtval[i] = j + (rtval[i+1] & 0x07);
990 /*)Function Addr_T adb_24_hi(v, i)
992 * int v value to add to byte
993 * int i rtval[] index
995 * The function adb_24_hi() adds the value of v to the
996 * 24 bit value contained in rtval[i] - rtval[i+2].
997 * The new value of rtval[i] / rtval[i+1] is returned.
998 * The LSB & middle byte rtflg[] is cleared.
1001 * Addr_T j temporary evaluation variable
1004 * hilo byte ordering parameter
1010 * The value of rtval[] is changed.
1011 * The rtflg[] value corresponding to the
1012 * LSB & middle byte of the word value is cleared to
1013 * reflect the fact that the MSB is the selected byte.
1017 Addr_T adb_24_hi(Addr_T v, int i)
1023 /* Remove the lower two bytes. */
1037 /*)Function Addr_T adb_24_mid(v, i)
1039 * int v value to add to byte
1040 * int i rtval[] index
1042 * The function adb_24_mid() adds the value of v to the
1043 * 24 bit value contained in rtval[i] - rtval[i+2].
1044 * The new value of rtval[i] / rtval[i+1] is returned.
1045 * The LSB & MSB byte rtflg[] is cleared.
1048 * Addr_T j temporary evaluation variable
1051 * hilo byte ordering parameter
1057 * The value of rtval[] is changed.
1058 * The rtflg[] value corresponding to the
1059 * LSB & MSB of the 24 bit value is cleared to reflect
1060 * the fact that the middle byte is the selected byte.
1064 Addr_T adb_24_mid(Addr_T v, int i)
1070 /* remove the MSB & LSB. */
1077 /*)Function Addr_T adb_24_lo(v, i)
1079 * int v value to add to byte
1080 * int i rtval[] index
1082 * The function adb_24_lo() adds the value of v to the
1083 * 24 bit value contained in rtval[i] - rtval[i+2].
1084 * The new value of rtval[i] / rtval[i+1] is returned.
1085 * The MSB & middle byte rtflg[] is cleared.
1088 * Addr_T j temporary evaluation variable
1091 * hilo byte ordering parameter
1097 * The value of rtval[] is changed.
1098 * The rtflg[] value corresponding to the
1099 * MSB & middle byte of the word value is cleared to
1100 * reflect the fact that the LSB is the selected byte.
1104 Addr_T adb_24_lo(Addr_T v, int i)
1110 /* Remove the upper two bytes. */
1124 /*)Function Addr_T adw_w(v, i)
1126 * int v value to add to word
1127 * int i rtval[] index
1129 * The function adw_w() adds the value of v to the
1130 * word value contained in rtval[i] and rtval[i+1].
1131 * The new value of rtval[i] / rtval[i+1] is returned.
1134 * Addr_T j temporary evaluation variable
1137 * hilo byte ordering parameter
1143 * The word value of rtval[] is changed.
1147 Addr_T adw_w(register Addr_T v, register int i)
1152 j = v + (rtval[i] << 8) + (rtval[i+1] & 0xff);
1153 rtval[i] = (j >> 8) & 0xff;
1154 rtval[i+1] = j & 0xff;
1156 j = v + (rtval[i] & 0xff) + (rtval[i+1] << 8);
1157 rtval[i] = j & 0xff;
1158 rtval[i+1] = (j >> 8) & 0xff;
1163 /*)Function Addr_T adw_24(v, i)
1165 * int v value to add to word
1166 * int i rtval[] index
1168 * The function adw_w() adds the value of v to the
1169 * 24 bit value contained in rtval[i] - rtval[i+2].
1170 * The new value of rtval[i] - rtval[i+2] is returned.
1173 * Addr_T j temporary evaluation variable
1176 * hilo byte ordering parameter
1182 * The word value of rtval[] is changed.
1185 Addr_T adw_24(Addr_T v, int i)
1190 j = v + ((rtval[i] & 0xff) << 16)
1191 + ((rtval[i+1] & 0xff) << 8)
1192 + (rtval[i+2] & 0xff);
1193 rtval[i] = (j >> 16) & 0xff;
1194 rtval[i+1] = (j >> 8) & 0xff;
1195 rtval[i+2] = j & 0xff;
1197 j = v + (rtval[i] & 0xff)
1198 + ((rtval[i+1] & 0xff) << 8)
1199 + ((rtval[i+2] & 0xff) << 16);
1200 rtval[i] = j & 0xff;
1201 rtval[i+1] = (j >> 8) & 0xff;
1202 rtval[i+2] = (j >> 16) & 0xff;
1207 /*)Function Addr_T adw_lo(v, i)
1209 * int v value to add to byte
1210 * int i rtval[] index
1212 * The function adw_lo() adds the value of v to the
1213 * double byte value contained in rtval[i] and rtval[i+1].
1214 * The new value of rtval[i] / rtval[i+1] is returned.
1215 * The MSB rtval[] is zeroed.
1218 * Addr_T j temporary evaluation variable
1221 * hilo byte ordering parameter
1227 * The value of rtval[] is changed.
1228 * The MSB of the word value is cleared to reflect
1229 * the fact that the LSB is the selected byte.
1233 Addr_T adw_lo(Addr_T v, int i)
1249 /*)Function Addr_T adw_hi(v, i)
1251 * int v value to add to byte
1252 * int i rtval[] index
1254 * The function adw_hi() adds the value of v to the
1255 * double byte value contained in rtval[i] and rtval[i+1].
1256 * The new value of rtval[i] / rtval[i+1] is returned.
1257 * The MSB and LSB values are interchanged.
1258 * The MSB rtval[] is zeroed.
1261 * Addr_T j temporary evaluation variable
1264 * hilo byte ordering parameter
1270 * The value of rtval[] is changed.
1271 * The MSB and LSB values are interchanged and
1272 * then the MSB cleared.
1276 Addr_T adw_hi(Addr_T v, int i)
1282 * LSB = MSB, Clear MSB
1285 rtval[i+1] = rtval[i];
1288 rtval[i] = rtval[i+1];
1294 /*)Function VOID relerr(str)
1296 * char *str error string
1298 * The function relerr() outputs the error string to
1299 * stderr and to the map file (if it is open).
1305 * FILE *mfp handle for the map file
1308 * VOID errdmp() lkrloc.c
1311 * Error message inserted into map file.
1315 VOID relerr(char *str)
1317 errdmp(stderr, str);
1322 /*)Function VOID errdmp(fptr, str)
1324 * FILE *fptr output file handle
1325 * char *str error string
1327 * The function errdmp() outputs the error string str
1328 * to the device specified by fptr. Additional information
1329 * is output about the definition and referencing of
1330 * the symbol / area error.
1333 * int mode error mode
1334 * int aindex area index
1335 * int lkerr error flag
1336 * int rindex error index
1337 * sym **s pointer to array of symbol pointers
1338 * areax **a pointer to array of area pointers
1339 * areax *raxp error area extension pointer
1342 * sdp sdp base page structure
1345 * int fprintf() c_library
1346 * VOID prntval() lkrloc.c
1353 VOID errdmp(FILE *fptr, char *str)
1355 int mode, aindex, rindex;
1364 aindex = rerr.aindex;
1365 rindex = rerr.rindex;
1370 fprintf(fptr, "\n?ASlink-Warning-%s", str);
1374 * Print symbol if symbol based
1377 fprintf(fptr, " for symbol %s\n",
1378 &s[rindex]->s_id[0]);
1380 fprintf(fptr, "\n");
1387 " file module area offset\n");
1389 " Refby %-8.8s %-8.8s %-8.8s ",
1392 &a[aindex]->a_bap->a_id[0]);
1393 prntval(fptr, rerr.rtbase);
1399 raxp = s[rindex]->s_axp;
1404 " Defin %-8.8s %-8.8s %-8.8s ",
1405 raxp->a_bhp->h_lfile->f_idp,
1406 &raxp->a_bhp->m_id[0],
1407 &raxp->a_bap->a_id[0]);
1409 prntval(fptr, s[rindex]->s_addr);
1411 prntval(fptr, rerr.rval);
1415 /*)Function VOID prntval(fptr, v)
1417 * FILE *fptr output file handle
1418 * Addr_T v value to output
1420 * The function prntval() outputs the value v, in the
1421 * currently selected radix, to the device specified
1428 * int xflag current radix
1431 * int fprintf() c_library
1438 VOID prntval(FILE *fptr, Addr_T v)
1441 fprintf(fptr, "%04X\n", v);
1444 fprintf(fptr, "%06o\n", v);
1447 fprintf(fptr, "%05u\n", v);
1451 /*)Function VOID relerp(str)
1453 * char *str error string
1455 * The function relerp() outputs the paging error string to
1456 * stderr and to the map file (if it is open).
1462 * FILE *mfp handle for the map file
1465 * VOID erpdmp() lkrloc.c
1468 * Error message inserted into map file.
1472 VOID relerp(char *str)
1474 erpdmp(stderr, str);
1479 /*)Function VOID erpdmp(fptr, str)
1481 * FILE *fptr output file handle
1482 * char *str error string
1484 * The function erpdmp() outputs the error string str
1485 * to the device specified by fptr.
1488 * head *thp pointer to head structure
1491 * int lkerr error flag
1492 * sdp sdp base page structure
1495 * int fprintf() c_library
1496 * VOID prntval() lkrloc.c
1503 VOID erpdmp(FILE *fptr, char *str)
1505 register struct head *thp;
1507 thp = sdp.s_areax->a_bhp;
1512 fprintf(fptr, "\n?ASlink-Warning-%s\n", str);
1519 " file module pgarea pgoffset\n");
1521 " PgDef %-8.8s %-8.8s %-8.8s ",
1522 thp->h_lfile->f_idp,
1524 &sdp.s_area->a_id[0]);
1525 prntval(fptr, sdp.s_area->a_addr + sdp.s_addr);