source: trunk/src/binutils/bfd/vms-tir.c@ 106

Last change on this file since 106 was 10, checked in by bird, 22 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 53.5 KB
Line 
1/* vms-tir.c -- BFD back-end for VAX (openVMS/VAX) and
2 EVAX (openVMS/Alpha) files.
3 Copyright 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
4
5 TIR record handling functions
6 ETIR record handling functions
7
8 go and read the openVMS linker manual (esp. appendix B)
9 if you don't know what's going on here :-)
10
11 Written by Klaus K"ampf (kkaempf@rmi.de)
12
13This program is free software; you can redistribute it and/or modify
14it under the terms of the GNU General Public License as published by
15the Free Software Foundation; either version 2 of the License, or
16(at your option) any later version.
17
18This program is distributed in the hope that it will be useful,
19but WITHOUT ANY WARRANTY; without even the implied warranty of
20MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21GNU General Public License for more details.
22
23You should have received a copy of the GNU General Public License
24along with this program; if not, write to the Free Software
25Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
26
27/* The following type abbreviations are used:
28
29 cs counted string (ascii string with length byte)
30 by byte (1 byte)
31 sh short (2 byte, 16 bit)
32 lw longword (4 byte, 32 bit)
33 qw quadword (8 byte, 64 bit)
34 da data stream */
35
36#include <ctype.h>
37
38#include "bfd.h"
39#include "sysdep.h"
40#include "bfdlink.h"
41#include "libbfd.h"
42
43#include "vms.h"
44
45static void image_set_ptr PARAMS ((bfd *abfd, int psect, uquad offset));
46static void image_inc_ptr PARAMS ((bfd *abfd, uquad offset));
47static void image_dump PARAMS ((bfd *abfd, unsigned char *ptr, int size, int offset));
48static void image_write_b PARAMS ((bfd *abfd, unsigned int value));
49static void image_write_w PARAMS ((bfd *abfd, unsigned int value));
50static void image_write_l PARAMS ((bfd *abfd, unsigned long value));
51static void image_write_q PARAMS ((bfd *abfd, uquad value));
52
53/*-----------------------------------------------------------------------------*/
54
55static int
56check_section (abfd, size)
57 bfd *abfd;
58 int size;
59{
60 int offset;
61
62 offset = PRIV(image_ptr) - PRIV(image_section)->contents;
63 if ((bfd_size_type) (offset + size) > PRIV(image_section)->_raw_size)
64 {
65 PRIV(image_section)->contents = bfd_realloc (PRIV(image_section)->contents, offset + size);
66 if (PRIV(image_section)->contents == 0)
67 {
68 (*_bfd_error_handler) (_("No Mem !"));
69 return -1;
70 }
71 PRIV(image_section)->_raw_size = offset + size;
72 PRIV(image_ptr) = PRIV(image_section)->contents + offset;
73 }
74
75 return 0;
76}
77
78/* routines to fill sections contents during tir/etir read */
79
80/* Initialize image buffer pointer to be filled */
81
82static void
83image_set_ptr (abfd, psect, offset)
84 bfd *abfd;
85 int psect;
86 uquad offset;
87{
88#if VMS_DEBUG
89 _bfd_vms_debug (4, "image_set_ptr (%d=%s, %d)\n",
90 psect, PRIV(sections)[psect]->name, offset);
91#endif
92
93 PRIV(image_ptr) = PRIV(sections)[psect]->contents + offset;
94 PRIV(image_section) = PRIV(sections)[psect];
95 return;
96}
97
98/* Increment image buffer pointer by offset */
99
100static void
101image_inc_ptr (abfd, offset)
102 bfd *abfd;
103 uquad offset;
104{
105#if VMS_DEBUG
106 _bfd_vms_debug (4, "image_inc_ptr (%d)\n", offset);
107#endif
108
109 PRIV(image_ptr) += offset;
110
111 return;
112}
113
114/* Dump multiple bytes to section image */
115
116static void
117image_dump (abfd, ptr, size, offset)
118 bfd *abfd;
119 unsigned char *ptr;
120 int size;
121 int offset ATTRIBUTE_UNUSED;
122{
123#if VMS_DEBUG
124 _bfd_vms_debug (8, "image_dump from (%p, %d) to (%p)\n", ptr, size, PRIV(image_ptr));
125 _bfd_hexdump (9, ptr, size, offset);
126#endif
127
128 if (PRIV(is_vax) && check_section (abfd, size))
129 return;
130
131 while (size-- > 0)
132 *PRIV(image_ptr)++ = *ptr++;
133 return;
134}
135
136/* Write byte to section image */
137
138static void
139image_write_b (abfd, value)
140 bfd *abfd;
141 unsigned int value;
142{
143#if VMS_DEBUG
144 _bfd_vms_debug (6, "image_write_b(%02x)\n", (int)value);
145#endif
146
147 if (PRIV(is_vax) && check_section (abfd, 1))
148 return;
149
150 *PRIV(image_ptr)++ = (value & 0xff);
151 return;
152}
153
154/* Write 2-byte word to image */
155
156static void
157image_write_w (abfd, value)
158 bfd *abfd;
159 unsigned int value;
160{
161#if VMS_DEBUG
162 _bfd_vms_debug (6, "image_write_w(%04x)\n", (int)value);
163#endif
164
165 if (PRIV(is_vax) && check_section (abfd, 2))
166 return;
167
168 bfd_putl16 (value, PRIV(image_ptr));
169 PRIV(image_ptr) += 2;
170
171 return;
172}
173
174/* Write 4-byte long to image */
175
176static void
177image_write_l (abfd, value)
178 bfd *abfd;
179 unsigned long value;
180{
181#if VMS_DEBUG
182 _bfd_vms_debug (6, "image_write_l (%08lx)\n", value);
183#endif
184
185 if (PRIV(is_vax) && check_section (abfd, 4))
186 return;
187
188 bfd_putl32 (value, PRIV(image_ptr));
189 PRIV(image_ptr) += 4;
190
191 return;
192}
193
194/* Write 8-byte quad to image */
195
196static void
197image_write_q (abfd, value)
198 bfd *abfd;
199 uquad value;
200{
201#if VMS_DEBUG
202 _bfd_vms_debug (6, "image_write_q (%016lx)\n", value);
203#endif
204
205 if (PRIV(is_vax) && check_section (abfd, 8))
206 return;
207
208 bfd_putl64 (value, PRIV(image_ptr));
209 PRIV(image_ptr) += 8;
210
211 return;
212}
213
214
215
216#define HIGHBIT(op) ((op & 0x80000000L) == 0x80000000L)
217
218/* etir_sta
219
220 vms stack commands
221
222 handle sta_xxx commands in etir section
223 ptr points to data area in record
224
225 see table B-8 of the openVMS linker manual */
226
227static boolean
228etir_sta (abfd, cmd, ptr)
229 bfd *abfd;
230 int cmd;
231 unsigned char *ptr;
232{
233
234#if VMS_DEBUG
235 _bfd_vms_debug (5, "etir_sta %d/%x\n", cmd, cmd);
236 _bfd_hexdump (8, ptr, 16, (int)ptr);
237#endif
238
239 switch (cmd)
240 {
241 /* stack */
242
243 /* stack global
244 arg: cs symbol name
245
246 stack 32 bit value of symbol (high bits set to 0) */
247
248 case ETIR_S_C_STA_GBL:
249 {
250 char *name;
251 vms_symbol_entry *entry;
252
253 name = _bfd_vms_save_counted_string (ptr);
254 entry = (vms_symbol_entry *)
255 bfd_hash_lookup (PRIV(vms_symbol_table), name, false, false);
256 if (entry == (vms_symbol_entry *)NULL)
257 {
258#if VMS_DEBUG
259 _bfd_vms_debug (3, "ETIR_S_C_STA_GBL: no symbol \"%s\"\n", name);
260#endif
261 _bfd_vms_push (abfd, (uquad)0, -1);
262 }
263 else
264 {
265 _bfd_vms_push (abfd, (uquad) (entry->symbol->value), -1);
266 }
267 }
268 break;
269
270 /* stack longword
271 arg: lw value
272
273 stack 32 bit value, sign extend to 64 bit */
274
275 case ETIR_S_C_STA_LW:
276 _bfd_vms_push (abfd, (uquad)bfd_getl32 (ptr), -1);
277 break;
278
279 /* stack global
280 arg: qw value
281
282 stack 64 bit value of symbol */
283
284 case ETIR_S_C_STA_QW:
285 _bfd_vms_push (abfd, (uquad)bfd_getl64(ptr), -1);
286 break;
287
288 /* stack psect base plus quadword offset
289 arg: lw section index
290 qw signed quadword offset (low 32 bits)
291
292 stack qw argument and section index
293 (see ETIR_S_C_STO_OFF, ETIR_S_C_CTL_SETRB) */
294
295 case ETIR_S_C_STA_PQ:
296 {
297 uquad dummy;
298 unsigned int psect;
299
300 psect = bfd_getl32 (ptr);
301 if (psect >= PRIV(section_count))
302 {
303 (*_bfd_error_handler) (_("Bad section index in ETIR_S_C_STA_PQ"));
304 bfd_set_error (bfd_error_bad_value);
305 return false;
306 }
307 dummy = bfd_getl64 (ptr+4);
308 _bfd_vms_push (abfd, dummy, psect);
309 }
310 break;
311
312 /* all not supported */
313
314 case ETIR_S_C_STA_LI:
315 case ETIR_S_C_STA_MOD:
316 case ETIR_S_C_STA_CKARG:
317
318 (*_bfd_error_handler) (_("Unsupported STA cmd %d"), cmd);
319 return false;
320 break;
321
322 default:
323 (*_bfd_error_handler) (_("Reserved STA cmd %d"), cmd);
324 return false;
325 break;
326 }
327#if VMS_DEBUG
328 _bfd_vms_debug (5, "etir_sta true\n");
329#endif
330 return true;
331}
332
333/*
334 etir_sto
335
336 vms store commands
337
338 handle sto_xxx commands in etir section
339 ptr points to data area in record
340
341 see table B-9 of the openVMS linker manual */
342
343static boolean
344etir_sto (abfd, cmd, ptr)
345 bfd *abfd;
346 int cmd;
347 unsigned char *ptr;
348{
349 uquad dummy;
350 int psect;
351
352#if VMS_DEBUG
353 _bfd_vms_debug (5, "etir_sto %d/%x\n", cmd, cmd);
354 _bfd_hexdump (8, ptr, 16, (int)ptr);
355#endif
356
357 switch (cmd)
358 {
359
360 /* store byte: pop stack, write byte
361 arg: - */
362
363 case ETIR_S_C_STO_B:
364 dummy = _bfd_vms_pop (abfd, &psect);
365#if 0
366 if (is_share) /* FIXME */
367 (*_bfd_error_handler) ("ETIR_S_C_STO_B: byte fixups not supported");
368#endif
369 image_write_b (abfd, dummy & 0xff); /* FIXME: check top bits */
370 break;
371
372 /* store word: pop stack, write word
373 arg: - */
374
375 case ETIR_S_C_STO_W:
376 dummy = _bfd_vms_pop (abfd, &psect);
377#if 0
378 if (is_share) /* FIXME */
379 (*_bfd_error_handler) ("ETIR_S_C_STO_B: word fixups not supported");
380#endif
381 image_write_w (abfd, dummy & 0xffff); /* FIXME: check top bits */
382 break;
383
384 /* store longword: pop stack, write longword
385 arg: - */
386
387 case ETIR_S_C_STO_LW:
388 dummy = _bfd_vms_pop (abfd, &psect);
389 dummy += (PRIV(sections)[psect])->vma;
390 image_write_l (abfd, dummy & 0xffffffff);/* FIXME: check top bits */
391 break;
392
393 /* store quadword: pop stack, write quadword
394 arg: - */
395
396 case ETIR_S_C_STO_QW:
397 dummy = _bfd_vms_pop (abfd, &psect);
398 dummy += (PRIV(sections)[psect])->vma;
399 image_write_q (abfd, dummy); /* FIXME: check top bits */
400 break;
401
402 /* store immediate repeated: pop stack for repeat count
403 arg: lw byte count
404 da data */
405
406 case ETIR_S_C_STO_IMMR:
407 {
408 unsigned long size;
409
410 size = bfd_getl32 (ptr);
411 dummy = (unsigned long)_bfd_vms_pop (abfd, NULL);
412 while (dummy-- > 0L)
413 image_dump (abfd, ptr+4, size, 0);
414 }
415 break;
416
417 /* store global: write symbol value
418 arg: cs global symbol name */
419
420 case ETIR_S_C_STO_GBL:
421 {
422 vms_symbol_entry *entry;
423 char *name;
424
425 name = _bfd_vms_save_counted_string (ptr);
426 entry = (vms_symbol_entry *)bfd_hash_lookup (PRIV(vms_symbol_table), name, false, false);
427 if (entry == (vms_symbol_entry *)NULL)
428 {
429 (*_bfd_error_handler) (_("ETIR_S_C_STO_GBL: no symbol \"%s\""),
430 name);
431 return false;
432 }
433 else
434 image_write_q (abfd, (uquad) (entry->symbol->value)); /* FIXME, reloc */
435 }
436 break;
437
438 /* store code address: write address of entry point
439 arg: cs global symbol name (procedure) */
440
441 case ETIR_S_C_STO_CA:
442 {
443 vms_symbol_entry *entry;
444 char *name;
445
446 name = _bfd_vms_save_counted_string (ptr);
447 entry = (vms_symbol_entry *) bfd_hash_lookup (PRIV(vms_symbol_table), name, false, false);
448 if (entry == (vms_symbol_entry *)NULL)
449 {
450 (*_bfd_error_handler) (_("ETIR_S_C_STO_CA: no symbol \"%s\""),
451 name);
452 return false;
453 }
454 else
455 image_write_q (abfd, (uquad) (entry->symbol->value)); /* FIXME, reloc */
456 }
457 break;
458
459 /* not supported */
460
461 case ETIR_S_C_STO_RB:
462 case ETIR_S_C_STO_AB:
463 (*_bfd_error_handler) (_("ETIR_S_C_STO_RB/AB: Not supported"));
464 break;
465
466 /* store offset to psect: pop stack, add low 32 bits to base of psect
467 arg: - */
468
469 case ETIR_S_C_STO_OFF:
470 {
471 uquad q;
472 int psect;
473
474 q = _bfd_vms_pop (abfd, &psect);
475 q += (PRIV(sections)[psect])->vma;
476 image_write_q (abfd, q);
477 }
478 break;
479
480 /* store immediate
481 arg: lw count of bytes
482 da data */
483
484 case ETIR_S_C_STO_IMM:
485 {
486 int size;
487
488 size = bfd_getl32 (ptr);
489 image_dump (abfd, ptr+4, size, 0);
490 }
491 break;
492
493 /* this code is 'reserved to digital' according to the openVMS linker manual,
494 however it is generated by the DEC C compiler and defined in the include file.
495 FIXME, since the following is just a guess
496 store global longword: store 32bit value of symbol
497 arg: cs symbol name */
498
499 case ETIR_S_C_STO_GBL_LW:
500 {
501 vms_symbol_entry *entry;
502 char *name;
503
504 name = _bfd_vms_save_counted_string (ptr);
505 entry = (vms_symbol_entry *)bfd_hash_lookup (PRIV(vms_symbol_table), name, false, false);
506 if (entry == (vms_symbol_entry *)NULL)
507 {
508#if VMS_DEBUG
509 _bfd_vms_debug (3, "ETIR_S_C_STO_GBL_LW: no symbol \"%s\"\n", name);
510#endif
511 image_write_l (abfd, (unsigned long)0); /* FIXME, reloc */
512 }
513 else
514 image_write_l (abfd, (unsigned long) (entry->symbol->value)); /* FIXME, reloc */
515 }
516 break;
517
518 /* not supported */
519
520 case ETIR_S_C_STO_LP_PSB:
521 (*_bfd_error_handler) (_("ETIR_S_C_STO_LP_PSB: Not supported"));
522 break;
523
524 /* */
525
526 case ETIR_S_C_STO_HINT_GBL:
527 (*_bfd_error_handler) (_("ETIR_S_C_STO_HINT_GBL: not implemented"));
528 break;
529
530 /* */
531
532 case ETIR_S_C_STO_HINT_PS:
533 (*_bfd_error_handler) (_("ETIR_S_C_STO_HINT_PS: not implemented"));
534 break;
535
536 default:
537 (*_bfd_error_handler) (_("Reserved STO cmd %d"), cmd);
538 break;
539 }
540
541 return true;
542}
543
544/* stack operator commands
545 all 32 bit signed arithmetic
546 all word just like a stack calculator
547 arguments are popped from stack, results are pushed on stack
548
549 see table B-10 of the openVMS linker manual */
550
551static boolean
552etir_opr (abfd, cmd, ptr)
553 bfd *abfd;
554 int cmd;
555 unsigned char *ptr ATTRIBUTE_UNUSED;
556{
557 long op1, op2;
558
559#if VMS_DEBUG
560 _bfd_vms_debug (5, "etir_opr %d/%x\n", cmd, cmd);
561 _bfd_hexdump (8, ptr, 16, (int)ptr);
562#endif
563
564 switch (cmd)
565 {
566 /* operation */
567
568 /* no-op */
569
570 case ETIR_S_C_OPR_NOP:
571 break;
572
573 /* add */
574
575 case ETIR_S_C_OPR_ADD:
576 op1 = (long)_bfd_vms_pop (abfd, NULL);
577 op2 = (long)_bfd_vms_pop (abfd, NULL);
578 _bfd_vms_push (abfd, (uquad) (op1 + op2), -1);
579 break;
580
581 /* subtract */
582
583 case ETIR_S_C_OPR_SUB:
584 op1 = (long)_bfd_vms_pop (abfd, NULL);
585 op2 = (long)_bfd_vms_pop (abfd, NULL);
586 _bfd_vms_push (abfd, (uquad) (op2 - op1), -1);
587 break;
588
589 /* multiply */
590
591 case ETIR_S_C_OPR_MUL:
592 op1 = (long)_bfd_vms_pop (abfd, NULL);
593 op2 = (long)_bfd_vms_pop (abfd, NULL);
594 _bfd_vms_push (abfd, (uquad) (op1 * op2), -1);
595 break;
596
597 /* divide */
598
599 case ETIR_S_C_OPR_DIV:
600 op1 = (long)_bfd_vms_pop (abfd, NULL);
601 op2 = (long)_bfd_vms_pop (abfd, NULL);
602 if (op2 == 0)
603 _bfd_vms_push (abfd, (uquad)0L, -1);
604 else
605 _bfd_vms_push (abfd, (uquad) (op2 / op1), -1);
606 break;
607
608 /* logical and */
609
610 case ETIR_S_C_OPR_AND:
611 op1 = (long)_bfd_vms_pop (abfd, NULL);
612 op2 = (long)_bfd_vms_pop (abfd, NULL);
613 _bfd_vms_push (abfd, (uquad) (op1 & op2), -1);
614 break;
615
616 /* logical inclusive or */
617
618 case ETIR_S_C_OPR_IOR:
619 op1 = (long)_bfd_vms_pop (abfd, NULL);
620 op2 = (long)_bfd_vms_pop (abfd, NULL);
621 _bfd_vms_push (abfd, (uquad) (op1 | op2), -1);
622 break;
623
624 /* logical exclusive or */
625
626 case ETIR_S_C_OPR_EOR:
627 op1 = (long)_bfd_vms_pop (abfd, NULL);
628 op2 = (long)_bfd_vms_pop (abfd, NULL);
629 _bfd_vms_push (abfd, (uquad) (op1 ^ op2), -1);
630 break;
631
632 /* negate */
633
634 case ETIR_S_C_OPR_NEG:
635 op1 = (long)_bfd_vms_pop (abfd, NULL);
636 _bfd_vms_push (abfd, (uquad) (-op1), -1);
637 break;
638
639 /* complement */
640
641 case ETIR_S_C_OPR_COM:
642 op1 = (long)_bfd_vms_pop (abfd, NULL);
643 _bfd_vms_push (abfd, (uquad) (op1 ^ -1L), -1);
644 break;
645
646 /* insert field */
647
648 case ETIR_S_C_OPR_INSV:
649 (void)_bfd_vms_pop (abfd, NULL);
650 (*_bfd_error_handler) (_("ETIR_S_C_OPR_INSV: Not supported"));
651 break;
652
653 /* arithmetic shift */
654
655 case ETIR_S_C_OPR_ASH:
656 op1 = (long)_bfd_vms_pop (abfd, NULL);
657 op2 = (long)_bfd_vms_pop (abfd, NULL);
658 if (op2 < 0) /* shift right */
659 op1 >>= -op2;
660 else /* shift left */
661 op1 <<= op2;
662 _bfd_vms_push (abfd, (uquad)op1, -1);
663 break;
664
665 /* unsigned shift */
666
667 case ETIR_S_C_OPR_USH:
668 (*_bfd_error_handler) (_("ETIR_S_C_OPR_USH: Not supported"));
669 break;
670
671 /* rotate */
672
673 case ETIR_S_C_OPR_ROT:
674 (*_bfd_error_handler) (_("ETIR_S_C_OPR_ROT: Not supported"));
675 break;
676
677 /* select */
678
679 case ETIR_S_C_OPR_SEL:
680 if ((long)_bfd_vms_pop (abfd, NULL) & 0x01L)
681 (void)_bfd_vms_pop (abfd, NULL);
682 else
683 {
684 op1 = (long)_bfd_vms_pop (abfd, NULL);
685 (void)_bfd_vms_pop (abfd, NULL);
686 _bfd_vms_push (abfd, (uquad)op1, -1);
687 }
688 break;
689
690 /* redefine symbol to current location */
691
692 case ETIR_S_C_OPR_REDEF:
693 (*_bfd_error_handler) (_("ETIR_S_C_OPR_REDEF: Not supported"));
694 break;
695
696 /* define a literal */
697
698 case ETIR_S_C_OPR_DFLIT:
699 (*_bfd_error_handler) (_("ETIR_S_C_OPR_DFLIT: Not supported"));
700 break;
701
702 default:
703 (*_bfd_error_handler) (_("Reserved OPR cmd %d"), cmd);
704 break;
705 }
706
707 return true;
708}
709
710/* control commands
711
712 see table B-11 of the openVMS linker manual */
713
714static boolean
715etir_ctl (abfd, cmd, ptr)
716 bfd *abfd;
717 int cmd;
718 unsigned char *ptr;
719{
720 uquad dummy;
721 int psect;
722
723#if VMS_DEBUG
724 _bfd_vms_debug (5, "etir_ctl %d/%x\n", cmd, cmd);
725 _bfd_hexdump (8, ptr, 16, (int)ptr);
726#endif
727
728 switch (cmd)
729 {
730 /* set relocation base: pop stack, set image location counter
731 arg: - */
732
733 case ETIR_S_C_CTL_SETRB:
734 dummy = _bfd_vms_pop (abfd, &psect);
735 image_set_ptr (abfd, psect, dummy);
736 break;
737
738 /* augment relocation base: increment image location counter by offset
739 arg: lw offset value */
740
741 case ETIR_S_C_CTL_AUGRB:
742 dummy = bfd_getl32 (ptr);
743 image_inc_ptr (abfd, dummy);
744 break;
745
746 /* define location: pop index, save location counter under index
747 arg: - */
748
749 case ETIR_S_C_CTL_DFLOC:
750 dummy = _bfd_vms_pop (abfd, NULL);
751 /* FIXME */
752 break;
753
754 /* set location: pop index, restore location counter from index
755 arg: - */
756
757 case ETIR_S_C_CTL_STLOC:
758 dummy = _bfd_vms_pop (abfd, &psect);
759 /* FIXME */
760 break;
761
762 /* stack defined location: pop index, push location counter from index
763 arg: - */
764
765 case ETIR_S_C_CTL_STKDL:
766 dummy = _bfd_vms_pop (abfd, &psect);
767 /* FIXME */
768 break;
769
770 default:
771 (*_bfd_error_handler) (_("Reserved CTL cmd %d"), cmd);
772 break;
773 }
774 return true;
775}
776
777/* store conditional commands
778
779 see table B-12 and B-13 of the openVMS linker manual */
780
781static boolean
782etir_stc (abfd, cmd, ptr)
783 bfd *abfd;
784 int cmd;
785 unsigned char *ptr ATTRIBUTE_UNUSED;
786{
787
788#if VMS_DEBUG
789 _bfd_vms_debug (5, "etir_stc %d/%x\n", cmd, cmd);
790 _bfd_hexdump (8, ptr, 16, (int)ptr);
791#endif
792
793 switch (cmd)
794 {
795 /* 200 Store-conditional Linkage Pair
796 arg: */
797
798 case ETIR_S_C_STC_LP:
799 (*_bfd_error_handler) (_("ETIR_S_C_STC_LP: not supported"));
800 break;
801
802 /* 201 Store-conditional Linkage Pair with Procedure Signature
803 arg: lw linkage index
804 cs procedure name
805 by signature length
806 da signature */
807
808 case ETIR_S_C_STC_LP_PSB:
809 image_inc_ptr (abfd, 16); /* skip entry,procval */
810 break;
811
812 /* 202 Store-conditional Address at global address
813 arg: lw linkage index
814 cs global name */
815
816 case ETIR_S_C_STC_GBL:
817 (*_bfd_error_handler) (_("ETIR_S_C_STC_GBL: not supported"));
818 break;
819
820 /* 203 Store-conditional Code Address at global address
821 arg: lw linkage index
822 cs procedure name */
823
824 case ETIR_S_C_STC_GCA:
825 (*_bfd_error_handler) (_("ETIR_S_C_STC_GCA: not supported"));
826 break;
827
828 /* 204 Store-conditional Address at psect + offset
829 arg: lw linkage index
830 lw psect index
831 qw offset */
832
833 case ETIR_S_C_STC_PS:
834 (*_bfd_error_handler) (_("ETIR_S_C_STC_PS: not supported"));
835 break;
836
837 /* 205 Store-conditional NOP at address of global
838 arg: */
839
840 case ETIR_S_C_STC_NOP_GBL:
841
842 /* 206 Store-conditional NOP at pect + offset
843 arg: */
844
845 case ETIR_S_C_STC_NOP_PS:
846
847 /* 207 Store-conditional BSR at global address
848 arg: */
849
850 case ETIR_S_C_STC_BSR_GBL:
851
852 /* 208 Store-conditional BSR at pect + offset
853 arg: */
854
855 case ETIR_S_C_STC_BSR_PS:
856
857 /* 209 Store-conditional LDA at global address
858 arg: */
859
860 case ETIR_S_C_STC_LDA_GBL:
861
862 /* 210 Store-conditional LDA at psect + offset
863 arg: */
864
865 case ETIR_S_C_STC_LDA_PS:
866
867 /* 211 Store-conditional BSR or Hint at global address
868 arg: */
869
870 case ETIR_S_C_STC_BOH_GBL:
871
872 /* 212 Store-conditional BSR or Hint at pect + offset
873 arg: */
874
875 case ETIR_S_C_STC_BOH_PS:
876
877 /* 213 Store-conditional NOP,BSR or HINT at global address
878 arg: */
879
880 case ETIR_S_C_STC_NBH_GBL:
881
882 /* 214 Store-conditional NOP,BSR or HINT at psect + offset
883 arg: */
884
885 case ETIR_S_C_STC_NBH_PS:
886/* FIXME (*_bfd_error_handler) ("ETIR_S_C_STC_xx: (%d) not supported", cmd); */
887 break;
888
889 default:
890#if VMS_DEBUG
891 _bfd_vms_debug (3, "Reserved STC cmd %d", cmd);
892#endif
893 break;
894 }
895 return true;
896}
897
898static asection *
899new_section (abfd, idx)
900 bfd *abfd ATTRIBUTE_UNUSED;
901 int idx;
902{
903 asection *section;
904 char sname[16];
905 char *name;
906
907#if VMS_DEBUG
908 _bfd_vms_debug (5, "new_section %d\n", idx);
909#endif
910 sprintf (sname, SECTION_NAME_TEMPLATE, idx);
911
912 name = bfd_malloc (strlen (sname) + 1);
913 if (name == 0)
914 return 0;
915 strcpy (name, sname);
916
917 section = bfd_malloc (sizeof (asection));
918 if (section == 0)
919 {
920#if VMS_DEBUG
921 _bfd_vms_debug (6, "bfd_make_section (%s) failed", name);
922#endif
923 return 0;
924 }
925
926 section->_raw_size = 0;
927 section->vma = 0;
928 section->contents = 0;
929 section->_cooked_size = 0;
930 section->name = name;
931 section->index = idx;
932
933 return section;
934}
935
936static int
937alloc_section (abfd, idx)
938 bfd *abfd;
939 unsigned int idx;
940{
941#if VMS_DEBUG
942 _bfd_vms_debug (4, "alloc_section %d\n", idx);
943#endif
944
945 PRIV(sections) = ((asection **)
946 bfd_realloc (PRIV(sections), (idx+1) * sizeof (asection *)));
947 if (PRIV(sections) == 0)
948 return -1;
949
950 while (PRIV(section_count) <= idx)
951 {
952 PRIV(sections)[PRIV(section_count)] = new_section (abfd, PRIV(section_count));
953 if (PRIV(sections)[PRIV(section_count)] == 0)
954 return -1;
955 PRIV(section_count)++;
956 }
957
958 return 0;
959}
960
961/*
962 * tir_sta
963 *
964 * vax stack commands
965 *
966 * handle sta_xxx commands in tir section
967 * ptr points to data area in record
968 *
969 * see table 7-3 of the VAX/VMS linker manual
970 */
971
972static unsigned char *
973tir_sta (bfd *abfd, unsigned char *ptr)
974{
975 int cmd = *ptr++;
976
977#if VMS_DEBUG
978 _bfd_vms_debug (5, "tir_sta %d\n", cmd);
979#endif
980
981 switch (cmd)
982 {
983 /* stack */
984 case TIR_S_C_STA_GBL:
985 /*
986 * stack global
987 * arg: cs symbol name
988 *
989 * stack 32 bit value of symbol (high bits set to 0)
990 */
991 {
992 char *name;
993 vms_symbol_entry *entry;
994
995 name = _bfd_vms_save_counted_string (ptr);
996
997 entry = _bfd_vms_enter_symbol (abfd, name);
998 if (entry == (vms_symbol_entry *)NULL)
999 return 0;
1000
1001 _bfd_vms_push (abfd, (unsigned long) (entry->symbol->value), -1);
1002 ptr += *ptr + 1;
1003 }
1004 break;
1005
1006 case TIR_S_C_STA_SB:
1007 /*
1008 * stack signed byte
1009 * arg: by value
1010 *
1011 * stack byte value, sign extend to 32 bit
1012 */
1013 _bfd_vms_push (abfd, (long)*ptr++, -1);
1014 break;
1015
1016 case TIR_S_C_STA_SW:
1017 /*
1018 * stack signed short word
1019 * arg: sh value
1020 *
1021 * stack 16 bit value, sign extend to 32 bit
1022 */
1023 _bfd_vms_push (abfd, (long)bfd_getl16(ptr), -1);
1024 ptr += 2;
1025 break;
1026
1027 case TIR_S_C_STA_LW:
1028 /*
1029 * stack signed longword
1030 * arg: lw value
1031 *
1032 * stack 32 bit value
1033 */
1034 _bfd_vms_push (abfd, (long)bfd_getl32 (ptr), -1);
1035 ptr += 4;
1036 break;
1037
1038 case TIR_S_C_STA_PB:
1039 case TIR_S_C_STA_WPB:
1040 /*
1041 * stack psect base plus byte offset (word index)
1042 * arg: by section index
1043 * (sh section index)
1044 * by signed byte offset
1045 *
1046 */
1047 {
1048 unsigned long dummy;
1049 unsigned int psect;
1050
1051 if (cmd == TIR_S_C_STA_PB)
1052 psect = *ptr++;
1053 else
1054 {
1055 psect = bfd_getl16(ptr);
1056 ptr += 2;
1057 }
1058
1059 if (psect >= PRIV(section_count))
1060 {
1061 alloc_section (abfd, psect);
1062 }
1063
1064 dummy = (long)*ptr++;
1065 dummy += (PRIV(sections)[psect])->vma;
1066 _bfd_vms_push (abfd, dummy, psect);
1067 }
1068 break;
1069
1070 case TIR_S_C_STA_PW:
1071 case TIR_S_C_STA_WPW:
1072 /*
1073 * stack psect base plus word offset (word index)
1074 * arg: by section index
1075 * (sh section index)
1076 * sh signed short offset
1077 *
1078 */
1079 {
1080 unsigned long dummy;
1081 unsigned int psect;
1082
1083 if (cmd == TIR_S_C_STA_PW)
1084 psect = *ptr++;
1085 else
1086 {
1087 psect = bfd_getl16(ptr);
1088 ptr += 2;
1089 }
1090
1091 if (psect >= PRIV(section_count))
1092 {
1093 alloc_section (abfd, psect);
1094 }
1095
1096 dummy = bfd_getl16(ptr); ptr+=2;
1097 dummy += (PRIV(sections)[psect])->vma;
1098 _bfd_vms_push (abfd, dummy, psect);
1099 }
1100 break;
1101
1102 case TIR_S_C_STA_PL:
1103 case TIR_S_C_STA_WPL:
1104 /*
1105 * stack psect base plus long offset (word index)
1106 * arg: by section index
1107 * (sh section index)
1108 * lw signed longword offset
1109 *
1110 */
1111 {
1112 unsigned long dummy;
1113 unsigned int psect;
1114
1115 if (cmd == TIR_S_C_STA_PL)
1116 psect = *ptr++;
1117 else
1118 {
1119 psect = bfd_getl16(ptr);
1120 ptr += 2;
1121 }
1122
1123 if (psect >= PRIV(section_count))
1124 {
1125 alloc_section (abfd, psect);
1126 }
1127
1128 dummy = bfd_getl32 (ptr); ptr += 4;
1129 dummy += (PRIV(sections)[psect])->vma;
1130 _bfd_vms_push (abfd, dummy, psect);
1131 }
1132 break;
1133
1134 case TIR_S_C_STA_UB:
1135 /*
1136 * stack unsigned byte
1137 * arg: by value
1138 *
1139 * stack byte value
1140 */
1141 _bfd_vms_push (abfd, (unsigned long)*ptr++, -1);
1142 break;
1143
1144 case TIR_S_C_STA_UW:
1145 /*
1146 * stack unsigned short word
1147 * arg: sh value
1148 *
1149 * stack 16 bit value
1150 */
1151 _bfd_vms_push (abfd, (unsigned long)bfd_getl16(ptr), -1);
1152 ptr += 2;
1153 break;
1154
1155 case TIR_S_C_STA_BFI:
1156 /*
1157 * stack byte from image
1158 * arg: -
1159 *
1160 */
1161 /*FALLTHRU*/
1162 case TIR_S_C_STA_WFI:
1163 /*
1164 * stack byte from image
1165 * arg: -
1166 *
1167 */
1168 /*FALLTHRU*/
1169 case TIR_S_C_STA_LFI:
1170 /*
1171 * stack byte from image
1172 * arg: -
1173 *
1174 */
1175 (*_bfd_error_handler) (_("Stack-from-image not implemented"));
1176 return NULL;
1177
1178 case TIR_S_C_STA_EPM:
1179 /*
1180 * stack entry point mask
1181 * arg: cs symbol name
1182 *
1183 * stack (unsigned) entry point mask of symbol
1184 * err if symbol is no entry point
1185 */
1186 {
1187 char *name;
1188 vms_symbol_entry *entry;
1189
1190 name = _bfd_vms_save_counted_string (ptr);
1191 entry = _bfd_vms_enter_symbol (abfd, name);
1192 if (entry == (vms_symbol_entry *)NULL)
1193 return 0;
1194
1195 (*_bfd_error_handler) (_("Stack-entry-mask not fully implemented"));
1196 _bfd_vms_push (abfd, 0L, -1);
1197 ptr += *ptr + 1;
1198 }
1199 break;
1200
1201 case TIR_S_C_STA_CKARG:
1202 /*
1203 * compare procedure argument
1204 * arg: cs symbol name
1205 * by argument index
1206 * da argument descriptor
1207 *
1208 * compare argument descriptor with symbol argument (ARG$V_PASSMECH)
1209 * and stack TRUE (args match) or FALSE (args dont match) value
1210 */
1211 (*_bfd_error_handler) (_("PASSMECH not fully implemented"));
1212 _bfd_vms_push (abfd, 1L, -1);
1213 break;
1214
1215 case TIR_S_C_STA_LSY:
1216 /*
1217 * stack local symbol value
1218 * arg: sh environment index
1219 * cs symbol name
1220 */
1221 {
1222 int envidx;
1223 char *name;
1224 vms_symbol_entry *entry;
1225
1226 envidx = bfd_getl16(ptr); ptr += 2;
1227 name = _bfd_vms_save_counted_string (ptr);
1228 entry = _bfd_vms_enter_symbol (abfd, name);
1229 if (entry == (vms_symbol_entry *)NULL)
1230 return 0;
1231 (*_bfd_error_handler) (_("Stack-local-symbol not fully implemented"));
1232 _bfd_vms_push (abfd, 0L, -1);
1233 ptr += *ptr + 1;
1234 }
1235 break;
1236
1237 case TIR_S_C_STA_LIT:
1238 /*
1239 * stack literal
1240 * arg: by literal index
1241 *
1242 * stack literal
1243 */
1244 ptr++;
1245 _bfd_vms_push (abfd, 0L, -1);
1246 (*_bfd_error_handler) (_("Stack-literal not fully implemented"));
1247 break;
1248
1249 case TIR_S_C_STA_LEPM:
1250 /*
1251 * stack local symbol entry point mask
1252 * arg: sh environment index
1253 * cs symbol name
1254 *
1255 * stack (unsigned) entry point mask of symbol
1256 * err if symbol is no entry point
1257 */
1258 {
1259 int envidx;
1260 char *name;
1261 vms_symbol_entry *entry;
1262
1263 envidx = bfd_getl16(ptr); ptr += 2;
1264 name = _bfd_vms_save_counted_string (ptr);
1265 entry = _bfd_vms_enter_symbol (abfd, name);
1266 if (entry == (vms_symbol_entry *)NULL)
1267 return 0;
1268 (*_bfd_error_handler) (_("Stack-local-symbol-entry-point-mask not fully implemented"));
1269 _bfd_vms_push (abfd, 0L, -1);
1270 ptr += *ptr + 1;
1271 }
1272 break;
1273
1274 default:
1275 (*_bfd_error_handler) (_("Reserved STA cmd %d"), ptr[-1]);
1276 return NULL;
1277 break;
1278 }
1279
1280 return ptr;
1281}
1282
1283/*
1284 * tir_sto
1285 *
1286 * vax store commands
1287 *
1288 * handle sto_xxx commands in tir section
1289 * ptr points to data area in record
1290 *
1291 * see table 7-4 of the VAX/VMS linker manual
1292 */
1293
1294static unsigned char *
1295tir_sto (bfd *abfd, unsigned char *ptr)
1296{
1297 unsigned long dummy;
1298 int size;
1299 int psect;
1300
1301#if VMS_DEBUG
1302 _bfd_vms_debug (5, "tir_sto %d\n", *ptr);
1303#endif
1304
1305 switch (*ptr++)
1306 {
1307 case TIR_S_C_STO_SB:
1308 /*
1309 * store signed byte: pop stack, write byte
1310 * arg: -
1311 */
1312 dummy = _bfd_vms_pop (abfd, &psect);
1313 image_write_b (abfd, dummy & 0xff); /* FIXME: check top bits */
1314 break;
1315
1316 case TIR_S_C_STO_SW:
1317 /*
1318 * store signed word: pop stack, write word
1319 * arg: -
1320 */
1321 dummy = _bfd_vms_pop (abfd, &psect);
1322 image_write_w (abfd, dummy & 0xffff); /* FIXME: check top bits */
1323 break;
1324
1325 case TIR_S_C_STO_LW:
1326 /*
1327 * store longword: pop stack, write longword
1328 * arg: -
1329 */
1330 dummy = _bfd_vms_pop (abfd, &psect);
1331 image_write_l (abfd, dummy & 0xffffffff);/* FIXME: check top bits */
1332 break;
1333
1334 case TIR_S_C_STO_BD:
1335 /*
1336 * store byte displaced: pop stack, sub lc+1, write byte
1337 * arg: -
1338 */
1339 dummy = _bfd_vms_pop (abfd, &psect);
1340 dummy -= ((PRIV(sections)[psect])->vma + 1);
1341 image_write_b (abfd, dummy & 0xff);/* FIXME: check top bits */
1342 break;
1343
1344 case TIR_S_C_STO_WD:
1345 /*
1346 * store word displaced: pop stack, sub lc+2, write word
1347 * arg: -
1348 */
1349 dummy = _bfd_vms_pop (abfd, &psect);
1350 dummy -= ((PRIV(sections)[psect])->vma + 2);
1351 image_write_w (abfd, dummy & 0xffff);/* FIXME: check top bits */
1352 break;
1353 case TIR_S_C_STO_LD:
1354 /*
1355 * store long displaced: pop stack, sub lc+4, write long
1356 * arg: -
1357 */
1358 dummy = _bfd_vms_pop (abfd, &psect);
1359 dummy -= ((PRIV(sections)[psect])->vma + 4);
1360 image_write_l (abfd, dummy & 0xffffffff);/* FIXME: check top bits */
1361 break;
1362 case TIR_S_C_STO_LI:
1363 /*
1364 * store short literal: pop stack, write byte
1365 * arg: -
1366 */
1367 dummy = _bfd_vms_pop (abfd, &psect);
1368 image_write_b (abfd, dummy & 0xff);/* FIXME: check top bits */
1369 break;
1370 case TIR_S_C_STO_PIDR:
1371 /*
1372 * store position independent data reference: pop stack, write longword
1373 * arg: -
1374 * FIXME: incomplete !
1375 */
1376 dummy = _bfd_vms_pop (abfd, &psect);
1377 image_write_l (abfd, dummy & 0xffffffff);
1378 break;
1379 case TIR_S_C_STO_PICR:
1380 /*
1381 * store position independent code reference: pop stack, write longword
1382 * arg: -
1383 * FIXME: incomplete !
1384 */
1385 dummy = _bfd_vms_pop (abfd, &psect);
1386 image_write_b (abfd, 0x9f);
1387 image_write_l (abfd, dummy & 0xffffffff);
1388 break;
1389 case TIR_S_C_STO_RIVB:
1390 /*
1391 * store repeated immediate variable bytes
1392 * 1-byte count n field followed by n bytes of data
1393 * pop stack, write n bytes <stack> times
1394 */
1395 size = *ptr++;
1396 dummy = (unsigned long)_bfd_vms_pop (abfd, NULL);
1397 while (dummy-- > 0L)
1398 image_dump (abfd, ptr, size, 0);
1399 ptr += size;
1400 break;
1401 case TIR_S_C_STO_B:
1402 /*
1403 * store byte from top longword
1404 */
1405 dummy = (unsigned long)_bfd_vms_pop (abfd, NULL);
1406 image_write_b (abfd, dummy & 0xff);
1407 break;
1408 case TIR_S_C_STO_W:
1409 /*
1410 * store word from top longword
1411 */
1412 dummy = (unsigned long)_bfd_vms_pop (abfd, NULL);
1413 image_write_w (abfd, dummy & 0xffff);
1414 break;
1415 case TIR_S_C_STO_RB:
1416 /*
1417 * store repeated byte from top longword
1418 */
1419 size = (unsigned long)_bfd_vms_pop (abfd, NULL);
1420 dummy = (unsigned long)_bfd_vms_pop (abfd, NULL);
1421 while (size-- > 0)
1422 image_write_b (abfd, dummy & 0xff);
1423 break;
1424 case TIR_S_C_STO_RW:
1425 /*
1426 * store repeated word from top longword
1427 */
1428 size = (unsigned long)_bfd_vms_pop (abfd, NULL);
1429 dummy = (unsigned long)_bfd_vms_pop (abfd, NULL);
1430 while (size-- > 0)
1431 image_write_w (abfd, dummy & 0xffff);
1432 break;
1433
1434 case TIR_S_C_STO_RSB:
1435 case TIR_S_C_STO_RSW:
1436 case TIR_S_C_STO_RL:
1437 case TIR_S_C_STO_VPS:
1438 case TIR_S_C_STO_USB:
1439 case TIR_S_C_STO_USW:
1440 case TIR_S_C_STO_RUB:
1441 case TIR_S_C_STO_RUW:
1442 case TIR_S_C_STO_PIRR:
1443 (*_bfd_error_handler) (_("Unimplemented STO cmd %d"), ptr[-1]);
1444 break;
1445
1446 default:
1447 (*_bfd_error_handler) (_("Reserved STO cmd %d"), ptr[-1]);
1448 break;
1449 }
1450
1451 return ptr;
1452}
1453
1454/*
1455 * stack operator commands
1456 * all 32 bit signed arithmetic
1457 * all word just like a stack calculator
1458 * arguments are popped from stack, results are pushed on stack
1459 *
1460 * see table 7-5 of the VAX/VMS linker manual
1461 */
1462
1463static unsigned char *
1464tir_opr (bfd *abfd, unsigned char *ptr)
1465{
1466 long op1, op2;
1467
1468#if VMS_DEBUG
1469 _bfd_vms_debug (5, "tir_opr %d\n", *ptr);
1470#endif
1471
1472 switch (*ptr++)
1473 {
1474 /* operation */
1475 case TIR_S_C_OPR_NOP:
1476 /*
1477 * no-op
1478 */
1479 break;
1480
1481 case TIR_S_C_OPR_ADD:
1482 /*
1483 * add
1484 */
1485 op1 = (long)_bfd_vms_pop (abfd, NULL);
1486 op2 = (long)_bfd_vms_pop (abfd, NULL);
1487 _bfd_vms_push (abfd, (unsigned long) (op1 + op2), -1);
1488 break;
1489
1490 case TIR_S_C_OPR_SUB:
1491 /*
1492 * subtract
1493 */
1494 op1 = (long)_bfd_vms_pop (abfd, NULL);
1495 op2 = (long)_bfd_vms_pop (abfd, NULL);
1496 _bfd_vms_push (abfd, (unsigned long) (op2 - op1), -1);
1497 break;
1498
1499 case TIR_S_C_OPR_MUL:
1500 /*
1501 * multiply
1502 */
1503 op1 = (long)_bfd_vms_pop (abfd, NULL);
1504 op2 = (long)_bfd_vms_pop (abfd, NULL);
1505 _bfd_vms_push (abfd, (unsigned long) (op1 * op2), -1);
1506 break;
1507
1508 case TIR_S_C_OPR_DIV:
1509 /*
1510 * divide
1511 */
1512 op1 = (long)_bfd_vms_pop (abfd, NULL);
1513 op2 = (long)_bfd_vms_pop (abfd, NULL);
1514 if (op2 == 0)
1515 _bfd_vms_push (abfd, (unsigned long)0L, -1);
1516 else
1517 _bfd_vms_push (abfd, (unsigned long) (op2 / op1), -1);
1518 break;
1519
1520 case TIR_S_C_OPR_AND:
1521 /*
1522 * logical and
1523 */
1524 op1 = (long)_bfd_vms_pop (abfd, NULL);
1525 op2 = (long)_bfd_vms_pop (abfd, NULL);
1526 _bfd_vms_push (abfd, (unsigned long) (op1 & op2), -1);
1527 break;
1528
1529 case TIR_S_C_OPR_IOR:
1530 op1 = (long)_bfd_vms_pop (abfd, NULL);
1531 /*
1532 * logical inclusive or
1533 */
1534 op2 = (long)_bfd_vms_pop (abfd, NULL);
1535 _bfd_vms_push (abfd, (unsigned long) (op1 | op2), -1);
1536 break;
1537
1538 case TIR_S_C_OPR_EOR:
1539 /*
1540 * logical exclusive or
1541 */
1542 op1 = (long)_bfd_vms_pop (abfd, NULL);
1543 op2 = (long)_bfd_vms_pop (abfd, NULL);
1544 _bfd_vms_push (abfd, (unsigned long) (op1 ^ op2), -1);
1545 break;
1546
1547 case TIR_S_C_OPR_NEG:
1548 /*
1549 * negate
1550 */
1551 op1 = (long)_bfd_vms_pop (abfd, NULL);
1552 _bfd_vms_push (abfd, (unsigned long) (-op1), -1);
1553 break;
1554
1555 case TIR_S_C_OPR_COM:
1556 /*
1557 * complement
1558 */
1559 op1 = (long)_bfd_vms_pop (abfd, NULL);
1560 _bfd_vms_push (abfd, (unsigned long) (op1 ^ -1L), -1);
1561 break;
1562
1563 case TIR_S_C_OPR_INSV:
1564 /*
1565 * insert field
1566 */
1567 (void)_bfd_vms_pop (abfd, NULL);
1568 (*_bfd_error_handler) ("TIR_S_C_OPR_INSV incomplete");
1569 break;
1570
1571 case TIR_S_C_OPR_ASH:
1572 /*
1573 * arithmetic shift
1574 */
1575 op1 = (long)_bfd_vms_pop (abfd, NULL);
1576 op2 = (long)_bfd_vms_pop (abfd, NULL);
1577 if (HIGHBIT(op1)) /* shift right */
1578 op2 >>= op1;
1579 else /* shift left */
1580 op2 <<= op1;
1581 _bfd_vms_push (abfd, (unsigned long)op2, -1);
1582 (*_bfd_error_handler) (_("TIR_S_C_OPR_ASH incomplete"));
1583 break;
1584
1585 case TIR_S_C_OPR_USH:
1586 /*
1587 * unsigned shift
1588 */
1589 op1 = (long)_bfd_vms_pop (abfd, NULL);
1590 op2 = (long)_bfd_vms_pop (abfd, NULL);
1591 if (HIGHBIT(op1)) /* shift right */
1592 op2 >>= op1;
1593 else /* shift left */
1594 op2 <<= op1;
1595 _bfd_vms_push (abfd, (unsigned long)op2, -1);
1596 (*_bfd_error_handler) (_("TIR_S_C_OPR_USH incomplete"));
1597 break;
1598
1599 case TIR_S_C_OPR_ROT:
1600 /*
1601 * rotate
1602 */
1603 op1 = (long)_bfd_vms_pop (abfd, NULL);
1604 op2 = (long)_bfd_vms_pop (abfd, NULL);
1605 if (HIGHBIT(0)) /* shift right */
1606 op2 >>= op1;
1607 else /* shift left */
1608 op2 <<= op1;
1609 _bfd_vms_push (abfd, (unsigned long)op2, -1);
1610 (*_bfd_error_handler) (_("TIR_S_C_OPR_ROT incomplete"));
1611 break;
1612
1613 case TIR_S_C_OPR_SEL:
1614 /*
1615 * select
1616 */
1617 if ((long)_bfd_vms_pop (abfd, NULL) & 0x01L)
1618 (void)_bfd_vms_pop (abfd, NULL);
1619 else
1620 {
1621 op1 = (long)_bfd_vms_pop (abfd, NULL);
1622 (void)_bfd_vms_pop (abfd, NULL);
1623 _bfd_vms_push (abfd, (unsigned long)op1, -1);
1624 }
1625 break;
1626
1627 case TIR_S_C_OPR_REDEF:
1628 /*
1629 * redefine symbol to current location
1630 */
1631 (*_bfd_error_handler) (_("TIR_S_C_OPR_REDEF not supported"));
1632 break;
1633
1634 case TIR_S_C_OPR_DFLIT:
1635 /*
1636 * define a literal
1637 */
1638 (*_bfd_error_handler) (_("TIR_S_C_OPR_DFLIT not supported"));
1639 break;
1640
1641 default:
1642 (*_bfd_error_handler) (_("Reserved OPR cmd %d"), ptr[-1]);
1643 break;
1644 }
1645
1646 return ptr;
1647}
1648
1649static unsigned char *
1650tir_ctl (bfd *abfd, unsigned char *ptr)
1651/*
1652 * control commands
1653 *
1654 * see table 7-6 of the VAX/VMS linker manual
1655 */
1656{
1657 unsigned long dummy;
1658 unsigned int psect;
1659
1660#if VMS_DEBUG
1661 _bfd_vms_debug (5, "tir_ctl %d\n", *ptr);
1662#endif
1663
1664 switch (*ptr++)
1665 {
1666 case TIR_S_C_CTL_SETRB:
1667 /*
1668 * set relocation base: pop stack, set image location counter
1669 * arg: -
1670 */
1671 dummy = _bfd_vms_pop (abfd, &psect);
1672 if (psect >= PRIV(section_count))
1673 {
1674 alloc_section (abfd, psect);
1675 }
1676 image_set_ptr (abfd, psect, dummy);
1677 break;
1678 case TIR_S_C_CTL_AUGRB:
1679 /*
1680 * augment relocation base: increment image location counter by offset
1681 * arg: lw offset value
1682 */
1683 dummy = bfd_getl32 (ptr);
1684 image_inc_ptr (abfd, dummy);
1685 break;
1686 case TIR_S_C_CTL_DFLOC:
1687 /*
1688 * define location: pop index, save location counter under index
1689 * arg: -
1690 */
1691 dummy = _bfd_vms_pop (abfd, NULL);
1692 (*_bfd_error_handler) (_("TIR_S_C_CTL_DFLOC not fully implemented"));
1693 break;
1694 case TIR_S_C_CTL_STLOC:
1695 /*
1696 * set location: pop index, restore location counter from index
1697 * arg: -
1698 */
1699 dummy = _bfd_vms_pop (abfd, &psect);
1700 (*_bfd_error_handler) (_("TIR_S_C_CTL_STLOC not fully implemented"));
1701 break;
1702 case TIR_S_C_CTL_STKDL:
1703 /*
1704 * stack defined location: pop index, push location counter from index
1705 * arg: -
1706 */
1707 dummy = _bfd_vms_pop (abfd, &psect);
1708 (*_bfd_error_handler) (_("TIR_S_C_CTL_STKDL not fully implemented"));
1709 break;
1710 default:
1711 (*_bfd_error_handler) (_("Reserved CTL cmd %d"), ptr[-1]);
1712 break;
1713 }
1714 return ptr;
1715}
1716
1717/*
1718 * handle command from TIR section
1719 */
1720
1721static unsigned char *
1722tir_cmd (bfd *abfd, unsigned char *ptr)
1723{
1724 struct {
1725 int mincod;
1726 int maxcod;
1727 unsigned char * (*explain) (bfd *, unsigned char *);
1728 } tir_table[] = {
1729 { 0, TIR_S_C_MAXSTACOD, tir_sta }
1730 ,{ TIR_S_C_MINSTOCOD, TIR_S_C_MAXSTOCOD, tir_sto }
1731 ,{ TIR_S_C_MINOPRCOD, TIR_S_C_MAXOPRCOD, tir_opr }
1732 ,{ TIR_S_C_MINCTLCOD, TIR_S_C_MAXCTLCOD, tir_ctl }
1733 ,{ -1, -1, NULL }
1734 };
1735 int i = 0;
1736
1737#if VMS_DEBUG
1738 _bfd_vms_debug (4, "tir_cmd %d/%x\n", *ptr, *ptr);
1739 _bfd_hexdump (8, ptr, 16, (int)ptr);
1740#endif
1741
1742 if (*ptr & 0x80) /* store immediate */
1743 {
1744 i = 128 - (*ptr++ & 0x7f);
1745 image_dump (abfd, ptr, i, 0);
1746 ptr += i;
1747 }
1748 else
1749 {
1750 while (tir_table[i].mincod >= 0)
1751 {
1752 if ( (tir_table[i].mincod <= *ptr)
1753 && (*ptr <= tir_table[i].maxcod))
1754 {
1755 ptr = tir_table[i].explain (abfd, ptr);
1756 break;
1757 }
1758 i++;
1759 }
1760 if (tir_table[i].mincod < 0)
1761 {
1762 (*_bfd_error_handler) (_("Obj code %d not found"), *ptr);
1763 ptr = 0;
1764 }
1765 }
1766
1767 return ptr;
1768}
1769
1770/* handle command from ETIR section */
1771
1772static int
1773etir_cmd (abfd, cmd, ptr)
1774 bfd *abfd;
1775 int cmd;
1776 unsigned char *ptr;
1777{
1778 static struct {
1779 int mincod;
1780 int maxcod;
1781 boolean (*explain) PARAMS((bfd *, int, unsigned char *));
1782 } etir_table[] = {
1783 { ETIR_S_C_MINSTACOD, ETIR_S_C_MAXSTACOD, etir_sta },
1784 { ETIR_S_C_MINSTOCOD, ETIR_S_C_MAXSTOCOD, etir_sto },
1785 { ETIR_S_C_MINOPRCOD, ETIR_S_C_MAXOPRCOD, etir_opr },
1786 { ETIR_S_C_MINCTLCOD, ETIR_S_C_MAXCTLCOD, etir_ctl },
1787 { ETIR_S_C_MINSTCCOD, ETIR_S_C_MAXSTCCOD, etir_stc },
1788 { -1, -1, NULL }
1789 };
1790
1791 int i = 0;
1792
1793#if VMS_DEBUG
1794 _bfd_vms_debug (4, "etir_cmd %d/%x\n", cmd, cmd);
1795 _bfd_hexdump (8, ptr, 16, (int)ptr);
1796#endif
1797
1798 while (etir_table[i].mincod >= 0)
1799 {
1800 if ( (etir_table[i].mincod <= cmd)
1801 && (cmd <= etir_table[i].maxcod))
1802 {
1803 if (!etir_table[i].explain (abfd, cmd, ptr))
1804 return -1;
1805 break;
1806 }
1807 i++;
1808 }
1809
1810#if VMS_DEBUG
1811 _bfd_vms_debug (4, "etir_cmd: = 0\n");
1812#endif
1813 return 0;
1814}
1815
1816/* Text Information and Relocation Records (OBJ$C_TIR)
1817 handle tir record */
1818
1819static int
1820analyze_tir (abfd, ptr, length)
1821 bfd *abfd;
1822 unsigned char *ptr;
1823 unsigned int length;
1824{
1825 unsigned char *maxptr;
1826
1827#if VMS_DEBUG
1828 _bfd_vms_debug (3, "analyze_tir: %d bytes\n", length);
1829#endif
1830
1831 maxptr = ptr + length;
1832
1833 while (ptr < maxptr)
1834 {
1835 ptr = tir_cmd (abfd, ptr);
1836 if (ptr == 0)
1837 return -1;
1838 }
1839
1840 return 0;
1841}
1842
1843/* Text Information and Relocation Records (EOBJ$C_ETIR)
1844 handle etir record */
1845
1846static int
1847analyze_etir (abfd, ptr, length)
1848 bfd *abfd;
1849 unsigned char *ptr;
1850 unsigned int length;
1851{
1852 int cmd;
1853 unsigned char *maxptr;
1854 int result = 0;
1855
1856#if VMS_DEBUG
1857 _bfd_vms_debug (3, "analyze_etir: %d bytes\n", length);
1858#endif
1859
1860 maxptr = ptr + length;
1861
1862 while (ptr < maxptr)
1863 {
1864 cmd = bfd_getl16 (ptr);
1865 length = bfd_getl16 (ptr + 2);
1866 result = etir_cmd (abfd, cmd, ptr+4);
1867 if (result != 0)
1868 break;
1869 ptr += length;
1870 }
1871
1872#if VMS_DEBUG
1873 _bfd_vms_debug (3, "analyze_etir: = %d\n", result);
1874#endif
1875
1876 return result;
1877}
1878
1879/* process ETIR record
1880
1881 return 0 on success, -1 on error */
1882
1883int
1884_bfd_vms_slurp_tir (abfd, objtype)
1885 bfd *abfd;
1886 int objtype;
1887{
1888 int result;
1889
1890#if VMS_DEBUG
1891 _bfd_vms_debug (2, "TIR/ETIR\n");
1892#endif
1893
1894 switch (objtype)
1895 {
1896 case EOBJ_S_C_ETIR:
1897 PRIV(vms_rec) += 4; /* skip type, size */
1898 PRIV(rec_size) -= 4;
1899 result = analyze_etir (abfd, PRIV(vms_rec), PRIV(rec_size));
1900 break;
1901 case OBJ_S_C_TIR:
1902 PRIV(vms_rec) += 1; /* skip type */
1903 PRIV(rec_size) -= 1;
1904 result = analyze_tir (abfd, PRIV(vms_rec), PRIV(rec_size));
1905 break;
1906 default:
1907 result = -1;
1908 break;
1909 }
1910
1911 return result;
1912}
1913
1914/* process EDBG record
1915 return 0 on success, -1 on error
1916
1917 not implemented yet */
1918
1919int
1920_bfd_vms_slurp_dbg (abfd, objtype)
1921 bfd *abfd;
1922 int objtype ATTRIBUTE_UNUSED;
1923{
1924#if VMS_DEBUG
1925 _bfd_vms_debug (2, "DBG/EDBG\n");
1926#endif
1927
1928 abfd->flags |= (HAS_DEBUG | HAS_LINENO);
1929 return 0;
1930}
1931
1932/* process ETBT record
1933 return 0 on success, -1 on error
1934
1935 not implemented yet */
1936
1937int
1938_bfd_vms_slurp_tbt (abfd, objtype)
1939 bfd *abfd ATTRIBUTE_UNUSED;
1940 int objtype ATTRIBUTE_UNUSED;
1941{
1942#if VMS_DEBUG
1943 _bfd_vms_debug (2, "TBT/ETBT\n");
1944#endif
1945
1946 return 0;
1947}
1948
1949/* process LNK record
1950 return 0 on success, -1 on error
1951
1952 not implemented yet */
1953
1954int
1955_bfd_vms_slurp_lnk (abfd, objtype)
1956 bfd *abfd ATTRIBUTE_UNUSED;
1957 int objtype ATTRIBUTE_UNUSED;
1958{
1959#if VMS_DEBUG
1960 _bfd_vms_debug (2, "LNK\n");
1961#endif
1962
1963 return 0;
1964}
1965
1966
1967/*----------------------------------------------------------------------*/
1968/* */
1969/* WRITE ETIR SECTION */
1970/* */
1971/* this is still under construction and therefore not documented */
1972/* */
1973/*----------------------------------------------------------------------*/
1974
1975static void start_etir_record PARAMS ((bfd *abfd, int index, uquad offset, boolean justoffset));
1976static void sto_imm PARAMS ((bfd *abfd, vms_section *sptr, bfd_vma vaddr, int index));
1977static void end_etir_record PARAMS ((bfd *abfd));
1978
1979static void
1980sto_imm (abfd, sptr, vaddr, index)
1981 bfd *abfd;
1982 vms_section *sptr;
1983 bfd_vma vaddr;
1984 int index;
1985{
1986 int size;
1987 int ssize;
1988 unsigned char *cptr;
1989
1990#if VMS_DEBUG
1991 _bfd_vms_debug (8, "sto_imm %d bytes\n", sptr->size);
1992 _bfd_hexdump (9, sptr->contents, (int)sptr->size, (int)vaddr);
1993#endif
1994
1995 ssize = sptr->size;
1996 cptr = sptr->contents;
1997
1998 while (ssize > 0)
1999 {
2000
2001 size = ssize; /* try all the rest */
2002
2003 if (_bfd_vms_output_check (abfd, size) < 0)
2004 { /* doesn't fit, split ! */
2005 end_etir_record (abfd);
2006 start_etir_record (abfd, index, vaddr, false);
2007 size = _bfd_vms_output_check (abfd, 0); /* get max size */
2008 if (size > ssize) /* more than what's left ? */
2009 size = ssize;
2010 }
2011
2012 _bfd_vms_output_begin (abfd, ETIR_S_C_STO_IMM, -1);
2013 _bfd_vms_output_long (abfd, (unsigned long) (size));
2014 _bfd_vms_output_dump (abfd, cptr, size);
2015 _bfd_vms_output_flush (abfd);
2016
2017#if VMS_DEBUG
2018 _bfd_vms_debug (10, "dumped %d bytes\n", size);
2019 _bfd_hexdump (10, cptr, (int)size, (int)vaddr);
2020#endif
2021
2022 vaddr += size;
2023 ssize -= size;
2024 cptr += size;
2025 }
2026
2027 return;
2028}
2029
2030/*-------------------------------------------------------------------*/
2031
2032/* start ETIR record for section #index at virtual addr offset. */
2033
2034static void
2035start_etir_record (abfd, index, offset, justoffset)
2036 bfd *abfd;
2037 int index;
2038 uquad offset;
2039 boolean justoffset;
2040{
2041 if (!justoffset)
2042 {
2043 _bfd_vms_output_begin (abfd, EOBJ_S_C_ETIR, -1); /* one ETIR per section */
2044 _bfd_vms_output_push (abfd);
2045 }
2046
2047 _bfd_vms_output_begin (abfd, ETIR_S_C_STA_PQ, -1); /* push start offset */
2048 _bfd_vms_output_long (abfd, (unsigned long)index);
2049 _bfd_vms_output_quad (abfd, (uquad)offset);
2050 _bfd_vms_output_flush (abfd);
2051
2052 _bfd_vms_output_begin (abfd, ETIR_S_C_CTL_SETRB, -1); /* start = pop () */
2053 _bfd_vms_output_flush (abfd);
2054
2055 return;
2056}
2057
2058/* end etir record */
2059static void
2060end_etir_record (abfd)
2061 bfd *abfd;
2062{
2063 _bfd_vms_output_pop (abfd);
2064 _bfd_vms_output_end (abfd);
2065}
2066
2067/* write section contents for bfd abfd */
2068
2069int
2070_bfd_vms_write_tir (abfd, objtype)
2071 bfd *abfd;
2072 int objtype ATTRIBUTE_UNUSED;
2073{
2074 asection *section;
2075 vms_section *sptr;
2076 int nextoffset;
2077
2078#if VMS_DEBUG
2079 _bfd_vms_debug (2, "vms_write_tir (%p, %d)\n", abfd, objtype);
2080#endif
2081
2082 _bfd_vms_output_alignment (abfd, 4);
2083
2084 nextoffset = 0;
2085 PRIV(vms_linkage_index) = 1;
2086
2087 /* dump all other sections */
2088
2089 section = abfd->sections;
2090
2091 while (section != NULL)
2092 {
2093
2094#if VMS_DEBUG
2095 _bfd_vms_debug (4, "writing %d. section '%s' (%d bytes)\n", section->index, section->name, (int) (section->_raw_size));
2096#endif
2097
2098 if (section->flags & SEC_RELOC)
2099 {
2100 int i;
2101
2102 if ((i = section->reloc_count) <= 0)
2103 {
2104 (*_bfd_error_handler) (_("SEC_RELOC with no relocs in section %s"),
2105 section->name);
2106 }
2107#if VMS_DEBUG
2108 else
2109 {
2110 arelent **rptr;
2111 _bfd_vms_debug (4, "%d relocations:\n", i);
2112 rptr = section->orelocation;
2113 while (i-- > 0)
2114 {
2115 _bfd_vms_debug (4, "sym %s in sec %s, value %08lx, addr %08lx, off %08lx, len %d: %s\n",
2116 (*(*rptr)->sym_ptr_ptr)->name,
2117 (*(*rptr)->sym_ptr_ptr)->section->name,
2118 (long) (*(*rptr)->sym_ptr_ptr)->value,
2119 (*rptr)->address, (*rptr)->addend,
2120 bfd_get_reloc_size((*rptr)->howto),
2121 (*rptr)->howto->name);
2122 rptr++;
2123 }
2124 }
2125#endif
2126 }
2127
2128 if ((section->flags & SEC_HAS_CONTENTS)
2129 && (! bfd_is_com_section (section)))
2130 {
2131 bfd_vma vaddr; /* virtual addr in section */
2132
2133 sptr = _bfd_get_vms_section (abfd, section->index);
2134 if (sptr == NULL)
2135 {
2136 bfd_set_error (bfd_error_no_contents);
2137 return -1;
2138 }
2139
2140 vaddr = (bfd_vma) (sptr->offset);
2141
2142 start_etir_record (abfd, section->index, (uquad) sptr->offset,
2143 false);
2144
2145 while (sptr != NULL) /* one STA_PQ, CTL_SETRB per vms_section */
2146 {
2147
2148 if (section->flags & SEC_RELOC) /* check for relocs */
2149 {
2150 arelent **rptr = section->orelocation;
2151 int i = section->reloc_count;
2152 for (;;)
2153 {
2154 bfd_size_type addr = (*rptr)->address;
2155 bfd_size_type len = bfd_get_reloc_size ((*rptr)->howto);
2156 if (sptr->offset < addr) /* sptr starts before reloc */
2157 {
2158 bfd_size_type before = addr - sptr->offset;
2159 if (sptr->size <= before) /* complete before */
2160 {
2161 sto_imm (abfd, sptr, vaddr, section->index);
2162 vaddr += sptr->size;
2163 break;
2164 }
2165 else /* partly before */
2166 {
2167 int after = sptr->size - before;
2168 sptr->size = before;
2169 sto_imm (abfd, sptr, vaddr, section->index);
2170 vaddr += sptr->size;
2171 sptr->contents += before;
2172 sptr->offset += before;
2173 sptr->size = after;
2174 }
2175 }
2176 else if (sptr->offset == addr) /* sptr starts at reloc */
2177 {
2178 asymbol *sym = *(*rptr)->sym_ptr_ptr;
2179 asection *sec = sym->section;
2180
2181 switch ((*rptr)->howto->type)
2182 {
2183 case ALPHA_R_IGNORE:
2184 break;
2185
2186 case ALPHA_R_REFLONG:
2187 {
2188 if (bfd_is_und_section (sym->section))
2189 {
2190 if (_bfd_vms_output_check (abfd,
2191 strlen((char *)sym->name))
2192 < 0)
2193 {
2194 end_etir_record (abfd);
2195 start_etir_record (abfd,
2196 section->index,
2197 vaddr, false);
2198 }
2199 _bfd_vms_output_begin (abfd,
2200 ETIR_S_C_STO_GBL_LW,
2201 -1);
2202 _bfd_vms_output_counted (abfd,
2203 _bfd_vms_length_hash_symbol (abfd, sym->name, EOBJ_S_C_SYMSIZ));
2204 _bfd_vms_output_flush (abfd);
2205 }
2206 else if (bfd_is_abs_section (sym->section))
2207 {
2208 if (_bfd_vms_output_check (abfd, 16) < 0)
2209 {
2210 end_etir_record (abfd);
2211 start_etir_record (abfd,
2212 section->index,
2213 vaddr, false);
2214 }
2215 _bfd_vms_output_begin (abfd,
2216 ETIR_S_C_STA_LW,
2217 -1);
2218 _bfd_vms_output_quad (abfd,
2219 (uquad)sym->value);
2220 _bfd_vms_output_flush (abfd);
2221 _bfd_vms_output_begin (abfd,
2222 ETIR_S_C_STO_LW,
2223 -1);
2224 _bfd_vms_output_flush (abfd);
2225 }
2226 else
2227 {
2228 if (_bfd_vms_output_check (abfd, 32) < 0)
2229 {
2230 end_etir_record (abfd);
2231 start_etir_record (abfd,
2232 section->index,
2233 vaddr, false);
2234 }
2235 _bfd_vms_output_begin (abfd,
2236 ETIR_S_C_STA_PQ,
2237 -1);
2238 _bfd_vms_output_long (abfd,
2239 (unsigned long) (sec->index));
2240 _bfd_vms_output_quad (abfd,
2241 ((uquad) (*rptr)->addend
2242 + (uquad)sym->value));
2243 _bfd_vms_output_flush (abfd);
2244 _bfd_vms_output_begin (abfd,
2245 ETIR_S_C_STO_LW,
2246 -1);
2247 _bfd_vms_output_flush (abfd);
2248 }
2249 }
2250 break;
2251
2252 case ALPHA_R_REFQUAD:
2253 {
2254 if (bfd_is_und_section (sym->section))
2255 {
2256 if (_bfd_vms_output_check (abfd,
2257 strlen((char *)sym->name))
2258 < 0)
2259 {
2260 end_etir_record (abfd);
2261 start_etir_record (abfd,
2262 section->index,
2263 vaddr, false);
2264 }
2265 _bfd_vms_output_begin (abfd,
2266 ETIR_S_C_STO_GBL,
2267 -1);
2268 _bfd_vms_output_counted (abfd,
2269 _bfd_vms_length_hash_symbol (abfd, sym->name, EOBJ_S_C_SYMSIZ));
2270 _bfd_vms_output_flush (abfd);
2271 }
2272 else if (bfd_is_abs_section (sym->section))
2273 {
2274 if (_bfd_vms_output_check (abfd, 16) < 0)
2275 {
2276 end_etir_record (abfd);
2277 start_etir_record (abfd,
2278 section->index,
2279 vaddr, false);
2280 }
2281 _bfd_vms_output_begin (abfd,
2282 ETIR_S_C_STA_QW,
2283 -1);
2284 _bfd_vms_output_quad (abfd,
2285 (uquad)sym->value);
2286 _bfd_vms_output_flush (abfd);
2287 _bfd_vms_output_begin (abfd,
2288 ETIR_S_C_STO_QW,
2289 -1);
2290 _bfd_vms_output_flush (abfd);
2291 }
2292 else
2293 {
2294 if (_bfd_vms_output_check (abfd, 32) < 0)
2295 {
2296 end_etir_record (abfd);
2297 start_etir_record (abfd,
2298 section->index,
2299 vaddr, false);
2300 }
2301 _bfd_vms_output_begin (abfd,
2302 ETIR_S_C_STA_PQ,
2303 -1);
2304 _bfd_vms_output_long (abfd,
2305 (unsigned long) (sec->index));
2306 _bfd_vms_output_quad (abfd,
2307 ((uquad) (*rptr)->addend
2308 + (uquad)sym->value));
2309 _bfd_vms_output_flush (abfd);
2310 _bfd_vms_output_begin (abfd,
2311 ETIR_S_C_STO_OFF,
2312 -1);
2313 _bfd_vms_output_flush (abfd);
2314 }
2315 }
2316 break;
2317
2318 case ALPHA_R_HINT:
2319 {
2320 int hint_size;
2321
2322 hint_size = sptr->size;
2323 sptr->size = len;
2324 sto_imm (abfd, sptr, vaddr, section->index);
2325 sptr->size = hint_size;
2326#if 0
2327 vms_output_begin(abfd, ETIR_S_C_STO_HINT_GBL, -1);
2328 vms_output_long(abfd, (unsigned long) (sec->index));
2329 vms_output_quad(abfd, (uquad)addr);
2330
2331 vms_output_counted(abfd, _bfd_vms_length_hash_symbol (abfd, sym->name, EOBJ_S_C_SYMSIZ));
2332 vms_output_flush(abfd);
2333#endif
2334 }
2335 break;
2336 case ALPHA_R_LINKAGE:
2337 {
2338 if (_bfd_vms_output_check (abfd, 64) < 0)
2339 {
2340 end_etir_record (abfd);
2341 start_etir_record (abfd, section->index,
2342 vaddr, false);
2343 }
2344 _bfd_vms_output_begin (abfd,
2345 ETIR_S_C_STC_LP_PSB,
2346 -1);
2347 _bfd_vms_output_long (abfd,
2348 (unsigned long)PRIV(vms_linkage_index));
2349 PRIV(vms_linkage_index) += 2;
2350 _bfd_vms_output_counted (abfd,
2351 _bfd_vms_length_hash_symbol (abfd, sym->name, EOBJ_S_C_SYMSIZ));
2352 _bfd_vms_output_byte (abfd, 0);
2353 _bfd_vms_output_flush (abfd);
2354 }
2355 break;
2356
2357 case ALPHA_R_CODEADDR:
2358 {
2359 if (_bfd_vms_output_check (abfd,
2360 strlen((char *)sym->name))
2361 < 0)
2362 {
2363 end_etir_record (abfd);
2364 start_etir_record (abfd,
2365 section->index,
2366 vaddr, false);
2367 }
2368 _bfd_vms_output_begin (abfd,
2369 ETIR_S_C_STO_CA,
2370 -1);
2371 _bfd_vms_output_counted (abfd,
2372 _bfd_vms_length_hash_symbol (abfd, sym->name, EOBJ_S_C_SYMSIZ));
2373 _bfd_vms_output_flush (abfd);
2374 }
2375 break;
2376
2377 default:
2378 (*_bfd_error_handler) (_("Unhandled relocation %s"),
2379 (*rptr)->howto->name);
2380 break;
2381 }
2382
2383 vaddr += len;
2384
2385 if (len == sptr->size)
2386 {
2387 break;
2388 }
2389 else
2390 {
2391 sptr->contents += len;
2392 sptr->offset += len;
2393 sptr->size -= len;
2394 i--;
2395 rptr++;
2396 }
2397 }
2398 else /* sptr starts after reloc */
2399 {
2400 i--; /* check next reloc */
2401 rptr++;
2402 }
2403
2404 if (i==0) /* all reloc checked */
2405 {
2406 if (sptr->size > 0)
2407 {
2408 sto_imm (abfd, sptr, vaddr, section->index); /* dump rest */
2409 vaddr += sptr->size;
2410 }
2411 break;
2412 }
2413 } /* for (;;) */
2414 } /* if SEC_RELOC */
2415 else /* no relocs, just dump */
2416 {
2417 sto_imm (abfd, sptr, vaddr, section->index);
2418 vaddr += sptr->size;
2419 }
2420
2421 sptr = sptr->next;
2422
2423 } /* while (sptr != 0) */
2424
2425 end_etir_record (abfd);
2426
2427 } /* has_contents */
2428
2429 section = section->next;
2430 }
2431
2432 _bfd_vms_output_alignment(abfd, 2);
2433 return 0;
2434}
2435
2436/* write traceback data for bfd abfd */
2437
2438int
2439_bfd_vms_write_tbt (abfd, objtype)
2440 bfd *abfd ATTRIBUTE_UNUSED;
2441 int objtype ATTRIBUTE_UNUSED;
2442{
2443#if VMS_DEBUG
2444 _bfd_vms_debug (2, "vms_write_tbt (%p, %d)\n", abfd, objtype);
2445#endif
2446
2447 return 0;
2448}
2449
2450/* write debug info for bfd abfd */
2451
2452int
2453_bfd_vms_write_dbg (abfd, objtype)
2454 bfd *abfd ATTRIBUTE_UNUSED;
2455 int objtype ATTRIBUTE_UNUSED;
2456{
2457#if VMS_DEBUG
2458 _bfd_vms_debug (2, "vms_write_dbg (%p, objtype)\n", abfd, objtype);
2459#endif
2460
2461 return 0;
2462}
Note: See TracBrowser for help on using the repository browser.