1 /* vms-tir.c -- BFD back-end for VAX (openVMS/VAX) and
2 EVAX (openVMS/Alpha) files.
3 Copyright 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
5 TIR record handling functions
6 ETIR record handling functions
8 go and read the openVMS linker manual (esp. appendix B)
9 if you don't know what's going on here :-)
11 Written by Klaus K"ampf (kkaempf@rmi.de)
13 This program is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2 of the License, or
16 (at your option) any later version.
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
28 /* The following type abbreviations are used:
30 cs counted string (ascii string with length byte)
32 sh short (2 byte, 16 bit)
33 lw longword (4 byte, 32 bit)
34 qw quadword (8 byte, 64 bit)
46 static void image_set_ptr PARAMS ((bfd *abfd, int psect, uquad offset));
47 static void image_inc_ptr PARAMS ((bfd *abfd, uquad offset));
48 static void image_dump PARAMS ((bfd *abfd, unsigned char *ptr, int size, int offset));
49 static void image_write_b PARAMS ((bfd *abfd, unsigned int value));
50 static void image_write_w PARAMS ((bfd *abfd, unsigned int value));
51 static void image_write_l PARAMS ((bfd *abfd, unsigned long value));
52 static void image_write_q PARAMS ((bfd *abfd, uquad value));
54 /*-----------------------------------------------------------------------------*/
57 check_section (abfd, size)
63 offset = PRIV(image_ptr) - PRIV(image_section)->contents;
64 if ((bfd_size_type) (offset + size) > PRIV(image_section)->_raw_size)
66 PRIV(image_section)->contents = bfd_realloc (PRIV(image_section)->contents, offset + size);
67 if (PRIV(image_section)->contents == 0)
69 (*_bfd_error_handler) (_("No Mem !"));
72 PRIV(image_section)->_raw_size = offset + size;
73 PRIV(image_ptr) = PRIV(image_section)->contents + offset;
79 /* routines to fill sections contents during tir/etir read */
81 /* Initialize image buffer pointer to be filled */
84 image_set_ptr (abfd, psect, offset)
90 _bfd_vms_debug (4, "image_set_ptr (%d=%s, %d)\n",
91 psect, PRIV(sections)[psect]->name, offset);
94 PRIV(image_ptr) = PRIV(sections)[psect]->contents + offset;
95 PRIV(image_section) = PRIV(sections)[psect];
100 /* Increment image buffer pointer by offset */
103 image_inc_ptr (abfd, offset)
108 _bfd_vms_debug (4, "image_inc_ptr (%d)\n", offset);
111 PRIV(image_ptr) += offset;
117 /* Dump multiple bytes to section image */
120 image_dump (abfd, ptr, size, offset)
124 int offset ATTRIBUTE_UNUSED;
127 _bfd_vms_debug (8, "image_dump from (%p, %d) to (%p)\n", ptr, size, PRIV(image_ptr));
128 _bfd_hexdump (9, ptr, size, offset);
131 if (PRIV(is_vax) && check_section (abfd, size))
135 *PRIV(image_ptr)++ = *ptr++;
140 /* Write byte to section image */
143 image_write_b (abfd, value)
148 _bfd_vms_debug (6, "image_write_b(%02x)\n", (int)value);
151 if (PRIV(is_vax) && check_section (abfd, 1))
154 *PRIV(image_ptr)++ = (value & 0xff);
159 /* Write 2-byte word to image */
162 image_write_w (abfd, value)
167 _bfd_vms_debug (6, "image_write_w(%04x)\n", (int)value);
170 if (PRIV(is_vax) && check_section (abfd, 2))
173 bfd_putl16 (value, PRIV(image_ptr));
174 PRIV(image_ptr) += 2;
180 /* Write 4-byte long to image */
183 image_write_l (abfd, value)
188 _bfd_vms_debug (6, "image_write_l (%08lx)\n", value);
191 if (PRIV(is_vax) && check_section (abfd, 4))
194 bfd_putl32 (value, PRIV(image_ptr));
195 PRIV(image_ptr) += 4;
201 /* Write 8-byte quad to image */
204 image_write_q (abfd, value)
209 _bfd_vms_debug (6, "image_write_q (%016lx)\n", value);
212 if (PRIV(is_vax) && check_section (abfd, 8))
215 bfd_putl64 (value, PRIV(image_ptr));
216 PRIV(image_ptr) += 8;
222 #define HIGHBIT(op) ((op & 0x80000000L) == 0x80000000L)
228 handle sta_xxx commands in etir section
229 ptr points to data area in record
231 see table B-8 of the openVMS linker manual */
234 etir_sta (abfd, cmd, ptr)
241 _bfd_vms_debug (5, "etir_sta %d/%x\n", cmd, cmd);
242 _bfd_hexdump (8, ptr, 16, (int)ptr);
252 stack 32 bit value of symbol (high bits set to 0) */
254 case ETIR_S_C_STA_GBL:
257 vms_symbol_entry *entry;
259 name = _bfd_vms_save_counted_string (ptr);
260 entry = (vms_symbol_entry *)
261 bfd_hash_lookup (PRIV(vms_symbol_table), name, false, false);
262 if (entry == (vms_symbol_entry *)NULL)
265 _bfd_vms_debug (3, "ETIR_S_C_STA_GBL: no symbol \"%s\"\n", name);
267 _bfd_vms_push (abfd, (uquad)0, -1);
271 _bfd_vms_push (abfd, (uquad)(entry->symbol->value), -1);
279 stack 32 bit value, sign extend to 64 bit */
281 case ETIR_S_C_STA_LW:
282 _bfd_vms_push (abfd, (uquad)bfd_getl32 (ptr), -1);
288 stack 64 bit value of symbol */
290 case ETIR_S_C_STA_QW:
291 _bfd_vms_push (abfd, (uquad)bfd_getl64(ptr), -1);
294 /* stack psect base plus quadword offset
295 arg: lw section index
296 qw signed quadword offset (low 32 bits)
298 stack qw argument and section index
299 (see ETIR_S_C_STO_OFF, ETIR_S_C_CTL_SETRB) */
301 case ETIR_S_C_STA_PQ:
306 psect = bfd_getl32 (ptr);
307 if (psect >= PRIV(section_count))
309 (*_bfd_error_handler) (_("Bad section index in ETIR_S_C_STA_PQ"));
310 bfd_set_error (bfd_error_bad_value);
313 dummy = bfd_getl64 (ptr+4);
314 _bfd_vms_push (abfd, dummy, psect);
318 /* all not supported */
320 case ETIR_S_C_STA_LI:
321 case ETIR_S_C_STA_MOD:
322 case ETIR_S_C_STA_CKARG:
324 (*_bfd_error_handler) (_("Unsupported STA cmd %d"), cmd);
329 (*_bfd_error_handler) (_("Reserved STA cmd %d"), cmd);
334 _bfd_vms_debug (5, "etir_sta true\n");
345 handle sto_xxx commands in etir section
346 ptr points to data area in record
348 see table B-9 of the openVMS linker manual */
351 etir_sto (abfd, cmd, ptr)
360 _bfd_vms_debug (5, "etir_sto %d/%x\n", cmd, cmd);
361 _bfd_hexdump (8, ptr, 16, (int)ptr);
367 /* store byte: pop stack, write byte
371 dummy = _bfd_vms_pop (abfd, &psect);
373 if (is_share) /* FIXME */
374 (*_bfd_error_handler) ("ETIR_S_C_STO_B: byte fixups not supported");
376 image_write_b (abfd, dummy & 0xff); /* FIXME: check top bits */
379 /* store word: pop stack, write word
383 dummy = _bfd_vms_pop (abfd, &psect);
385 if (is_share) /* FIXME */
386 (*_bfd_error_handler) ("ETIR_S_C_STO_B: word fixups not supported");
388 image_write_w (abfd, dummy & 0xffff); /* FIXME: check top bits */
391 /* store longword: pop stack, write longword
394 case ETIR_S_C_STO_LW:
395 dummy = _bfd_vms_pop (abfd, &psect);
396 dummy += (PRIV(sections)[psect])->vma;
397 image_write_l (abfd, dummy & 0xffffffff);/* FIXME: check top bits */
400 /* store quadword: pop stack, write quadword
403 case ETIR_S_C_STO_QW:
404 dummy = _bfd_vms_pop (abfd, &psect);
405 dummy += (PRIV(sections)[psect])->vma;
406 image_write_q (abfd, dummy); /* FIXME: check top bits */
409 /* store immediate repeated: pop stack for repeat count
413 case ETIR_S_C_STO_IMMR:
417 size = bfd_getl32 (ptr);
418 dummy = (unsigned long)_bfd_vms_pop (abfd, NULL);
420 image_dump (abfd, ptr+4, size, 0);
424 /* store global: write symbol value
425 arg: cs global symbol name */
427 case ETIR_S_C_STO_GBL:
429 vms_symbol_entry *entry;
432 name = _bfd_vms_save_counted_string (ptr);
433 entry = (vms_symbol_entry *)bfd_hash_lookup (PRIV(vms_symbol_table), name, false, false);
434 if (entry == (vms_symbol_entry *)NULL)
436 (*_bfd_error_handler) (_("ETIR_S_C_STO_GBL: no symbol \"%s\""),
441 image_write_q (abfd, (uquad)(entry->symbol->value)); /* FIXME, reloc */
445 /* store code address: write address of entry point
446 arg: cs global symbol name (procedure) */
448 case ETIR_S_C_STO_CA:
450 vms_symbol_entry *entry;
453 name = _bfd_vms_save_counted_string (ptr);
454 entry = (vms_symbol_entry *) bfd_hash_lookup (PRIV(vms_symbol_table), name, false, false);
455 if (entry == (vms_symbol_entry *)NULL)
457 (*_bfd_error_handler) (_("ETIR_S_C_STO_CA: no symbol \"%s\""),
462 image_write_q (abfd, (uquad)(entry->symbol->value)); /* FIXME, reloc */
468 case ETIR_S_C_STO_RB:
469 case ETIR_S_C_STO_AB:
470 (*_bfd_error_handler) (_("ETIR_S_C_STO_RB/AB: Not supported"));
473 /* store offset to psect: pop stack, add low 32 bits to base of psect
476 case ETIR_S_C_STO_OFF:
481 q = _bfd_vms_pop (abfd, &psect);
482 q += (PRIV(sections)[psect])->vma;
483 image_write_q (abfd, q);
488 arg: lw count of bytes
491 case ETIR_S_C_STO_IMM:
495 size = bfd_getl32 (ptr);
496 image_dump (abfd, ptr+4, size, 0);
500 /* this code is 'reserved to digital' according to the openVMS linker manual,
501 however it is generated by the DEC C compiler and defined in the include file.
502 FIXME, since the following is just a guess
503 store global longword: store 32bit value of symbol
504 arg: cs symbol name */
506 case ETIR_S_C_STO_GBL_LW:
508 vms_symbol_entry *entry;
511 name = _bfd_vms_save_counted_string (ptr);
512 entry = (vms_symbol_entry *)bfd_hash_lookup (PRIV(vms_symbol_table), name, false, false);
513 if (entry == (vms_symbol_entry *)NULL)
516 _bfd_vms_debug (3, "ETIR_S_C_STO_GBL_LW: no symbol \"%s\"\n", name);
518 image_write_l (abfd, (unsigned long)0); /* FIXME, reloc */
521 image_write_l (abfd, (unsigned long)(entry->symbol->value)); /* FIXME, reloc */
527 case ETIR_S_C_STO_LP_PSB:
528 (*_bfd_error_handler) (_("ETIR_S_C_STO_LP_PSB: Not supported"));
533 case ETIR_S_C_STO_HINT_GBL:
534 (*_bfd_error_handler) (_("ETIR_S_C_STO_HINT_GBL: not implemented"));
539 case ETIR_S_C_STO_HINT_PS:
540 (*_bfd_error_handler) (_("ETIR_S_C_STO_HINT_PS: not implemented"));
544 (*_bfd_error_handler) (_("Reserved STO cmd %d"), cmd);
551 /* stack operator commands
552 all 32 bit signed arithmetic
553 all word just like a stack calculator
554 arguments are popped from stack, results are pushed on stack
556 see table B-10 of the openVMS linker manual */
559 etir_opr (abfd, cmd, ptr)
562 unsigned char *ptr ATTRIBUTE_UNUSED;
567 _bfd_vms_debug (5, "etir_opr %d/%x\n", cmd, cmd);
568 _bfd_hexdump (8, ptr, 16, (int)ptr);
577 case ETIR_S_C_OPR_NOP:
582 case ETIR_S_C_OPR_ADD:
583 op1 = (long)_bfd_vms_pop (abfd, NULL);
584 op2 = (long)_bfd_vms_pop (abfd, NULL);
585 _bfd_vms_push (abfd, (uquad)(op1 + op2), -1);
590 case ETIR_S_C_OPR_SUB:
591 op1 = (long)_bfd_vms_pop (abfd, NULL);
592 op2 = (long)_bfd_vms_pop (abfd, NULL);
593 _bfd_vms_push (abfd, (uquad)(op2 - op1), -1);
598 case ETIR_S_C_OPR_MUL:
599 op1 = (long)_bfd_vms_pop (abfd, NULL);
600 op2 = (long)_bfd_vms_pop (abfd, NULL);
601 _bfd_vms_push (abfd, (uquad)(op1 * op2), -1);
606 case ETIR_S_C_OPR_DIV:
607 op1 = (long)_bfd_vms_pop (abfd, NULL);
608 op2 = (long)_bfd_vms_pop (abfd, NULL);
610 _bfd_vms_push (abfd, (uquad)0L, -1);
612 _bfd_vms_push (abfd, (uquad)(op2 / op1), -1);
617 case ETIR_S_C_OPR_AND:
618 op1 = (long)_bfd_vms_pop (abfd, NULL);
619 op2 = (long)_bfd_vms_pop (abfd, NULL);
620 _bfd_vms_push (abfd, (uquad)(op1 & op2), -1);
623 /* logical inclusive or */
625 case ETIR_S_C_OPR_IOR:
626 op1 = (long)_bfd_vms_pop (abfd, NULL);
627 op2 = (long)_bfd_vms_pop (abfd, NULL);
628 _bfd_vms_push (abfd, (uquad)(op1 | op2), -1);
631 /* logical exclusive or */
633 case ETIR_S_C_OPR_EOR:
634 op1 = (long)_bfd_vms_pop (abfd, NULL);
635 op2 = (long)_bfd_vms_pop (abfd, NULL);
636 _bfd_vms_push (abfd, (uquad)(op1 ^ op2), -1);
641 case ETIR_S_C_OPR_NEG:
642 op1 = (long)_bfd_vms_pop (abfd, NULL);
643 _bfd_vms_push (abfd, (uquad)(-op1), -1);
648 case ETIR_S_C_OPR_COM:
649 op1 = (long)_bfd_vms_pop (abfd, NULL);
650 _bfd_vms_push (abfd, (uquad)(op1 ^ -1L), -1);
655 case ETIR_S_C_OPR_INSV:
656 (void)_bfd_vms_pop (abfd, NULL);
657 (*_bfd_error_handler) (_("ETIR_S_C_OPR_INSV: Not supported"));
660 /* arithmetic shift */
662 case ETIR_S_C_OPR_ASH:
663 op1 = (long)_bfd_vms_pop (abfd, NULL);
664 op2 = (long)_bfd_vms_pop (abfd, NULL);
665 if (op2 < 0) /* shift right */
667 else /* shift left */
669 _bfd_vms_push (abfd, (uquad)op1, -1);
674 case ETIR_S_C_OPR_USH:
675 (*_bfd_error_handler) (_("ETIR_S_C_OPR_USH: Not supported"));
680 case ETIR_S_C_OPR_ROT:
681 (*_bfd_error_handler) (_("ETIR_S_C_OPR_ROT: Not supported"));
686 case ETIR_S_C_OPR_SEL:
687 if ((long)_bfd_vms_pop (abfd, NULL) & 0x01L)
688 (void)_bfd_vms_pop (abfd, NULL);
691 op1 = (long)_bfd_vms_pop (abfd, NULL);
692 (void)_bfd_vms_pop (abfd, NULL);
693 _bfd_vms_push (abfd, (uquad)op1, -1);
697 /* redefine symbol to current location */
699 case ETIR_S_C_OPR_REDEF:
700 (*_bfd_error_handler) (_("ETIR_S_C_OPR_REDEF: Not supported"));
703 /* define a literal */
705 case ETIR_S_C_OPR_DFLIT:
706 (*_bfd_error_handler) (_("ETIR_S_C_OPR_DFLIT: Not supported"));
710 (*_bfd_error_handler) (_("Reserved OPR cmd %d"), cmd);
720 see table B-11 of the openVMS linker manual */
723 etir_ctl (abfd, cmd, ptr)
732 _bfd_vms_debug (5, "etir_ctl %d/%x\n", cmd, cmd);
733 _bfd_hexdump (8, ptr, 16, (int)ptr);
738 /* set relocation base: pop stack, set image location counter
741 case ETIR_S_C_CTL_SETRB:
742 dummy = _bfd_vms_pop (abfd, &psect);
743 image_set_ptr (abfd, psect, dummy);
746 /* augment relocation base: increment image location counter by offset
747 arg: lw offset value */
749 case ETIR_S_C_CTL_AUGRB:
750 dummy = bfd_getl32 (ptr);
751 image_inc_ptr (abfd, dummy);
754 /* define location: pop index, save location counter under index
757 case ETIR_S_C_CTL_DFLOC:
758 dummy = _bfd_vms_pop (abfd, NULL);
762 /* set location: pop index, restore location counter from index
765 case ETIR_S_C_CTL_STLOC:
766 dummy = _bfd_vms_pop (abfd, &psect);
770 /* stack defined location: pop index, push location counter from index
773 case ETIR_S_C_CTL_STKDL:
774 dummy = _bfd_vms_pop (abfd, &psect);
779 (*_bfd_error_handler) (_("Reserved CTL cmd %d"), cmd);
786 /* store conditional commands
788 see table B-12 and B-13 of the openVMS linker manual */
791 etir_stc (abfd, cmd, ptr)
794 unsigned char *ptr ATTRIBUTE_UNUSED;
798 _bfd_vms_debug (5, "etir_stc %d/%x\n", cmd, cmd);
799 _bfd_hexdump (8, ptr, 16, (int)ptr);
804 /* 200 Store-conditional Linkage Pair
807 case ETIR_S_C_STC_LP:
808 (*_bfd_error_handler) (_("ETIR_S_C_STC_LP: not supported"));
811 /* 201 Store-conditional Linkage Pair with Procedure Signature
812 arg: lw linkage index
817 case ETIR_S_C_STC_LP_PSB:
818 image_inc_ptr (abfd, 16); /* skip entry,procval */
821 /* 202 Store-conditional Address at global address
822 arg: lw linkage index
825 case ETIR_S_C_STC_GBL:
826 (*_bfd_error_handler) (_("ETIR_S_C_STC_GBL: not supported"));
829 /* 203 Store-conditional Code Address at global address
830 arg: lw linkage index
833 case ETIR_S_C_STC_GCA:
834 (*_bfd_error_handler) (_("ETIR_S_C_STC_GCA: not supported"));
837 /* 204 Store-conditional Address at psect + offset
838 arg: lw linkage index
842 case ETIR_S_C_STC_PS:
843 (*_bfd_error_handler) (_("ETIR_S_C_STC_PS: not supported"));
846 /* 205 Store-conditional NOP at address of global
849 case ETIR_S_C_STC_NOP_GBL:
851 /* 206 Store-conditional NOP at pect + offset
854 case ETIR_S_C_STC_NOP_PS:
856 /* 207 Store-conditional BSR at global address
859 case ETIR_S_C_STC_BSR_GBL:
861 /* 208 Store-conditional BSR at pect + offset
864 case ETIR_S_C_STC_BSR_PS:
866 /* 209 Store-conditional LDA at global address
869 case ETIR_S_C_STC_LDA_GBL:
871 /* 210 Store-conditional LDA at psect + offset
874 case ETIR_S_C_STC_LDA_PS:
876 /* 211 Store-conditional BSR or Hint at global address
879 case ETIR_S_C_STC_BOH_GBL:
881 /* 212 Store-conditional BSR or Hint at pect + offset
884 case ETIR_S_C_STC_BOH_PS:
886 /* 213 Store-conditional NOP,BSR or HINT at global address
889 case ETIR_S_C_STC_NBH_GBL:
891 /* 214 Store-conditional NOP,BSR or HINT at psect + offset
894 case ETIR_S_C_STC_NBH_PS:
895 /* FIXME (*_bfd_error_handler) ("ETIR_S_C_STC_xx: (%d) not supported", cmd); */
900 _bfd_vms_debug (3, "Reserved STC cmd %d", cmd);
909 new_section (abfd, idx)
910 bfd *abfd ATTRIBUTE_UNUSED;
918 _bfd_vms_debug (5, "new_section %d\n", idx);
920 sprintf (sname, SECTION_NAME_TEMPLATE, idx);
922 name = bfd_malloc (strlen (sname) + 1);
925 strcpy (name, sname);
927 section = bfd_malloc (sizeof (asection));
931 _bfd_vms_debug (6, "bfd_make_section (%s) failed", name);
936 section->_raw_size = 0;
938 section->contents = 0;
939 section->_cooked_size = 0;
940 section->name = name;
941 section->index = idx;
948 alloc_section (abfd, idx)
953 _bfd_vms_debug (4, "alloc_section %d\n", idx);
956 PRIV(sections) = ((asection **)
957 bfd_realloc (PRIV(sections), (idx+1) * sizeof (asection *)));
958 if (PRIV(sections) == 0)
961 while (PRIV(section_count) <= idx)
963 PRIV(sections)[PRIV(section_count)] = new_section (abfd, PRIV(section_count));
964 if (PRIV(sections)[PRIV(section_count)] == 0)
966 PRIV(section_count)++;
978 * handle sta_xxx commands in tir section
979 * ptr points to data area in record
981 * see table 7-3 of the VAX/VMS linker manual
984 static unsigned char *
985 tir_sta (bfd *abfd, unsigned char *ptr)
990 _bfd_vms_debug (5, "tir_sta %d\n", cmd);
996 case TIR_S_C_STA_GBL:
999 * arg: cs symbol name
1001 * stack 32 bit value of symbol (high bits set to 0)
1005 vms_symbol_entry *entry;
1007 name = _bfd_vms_save_counted_string (ptr);
1009 entry = _bfd_vms_enter_symbol (abfd, name);
1010 if (entry == (vms_symbol_entry *)NULL)
1013 _bfd_vms_push (abfd, (unsigned long)(entry->symbol->value), -1);
1018 case TIR_S_C_STA_SB:
1023 * stack byte value, sign extend to 32 bit
1025 _bfd_vms_push (abfd, (long)*ptr++, -1);
1028 case TIR_S_C_STA_SW:
1030 * stack signed short word
1033 * stack 16 bit value, sign extend to 32 bit
1035 _bfd_vms_push (abfd, (long)bfd_getl16(ptr), -1);
1039 case TIR_S_C_STA_LW:
1041 * stack signed longword
1044 * stack 32 bit value
1046 _bfd_vms_push (abfd, (long)bfd_getl32 (ptr), -1);
1050 case TIR_S_C_STA_PB:
1051 case TIR_S_C_STA_WPB:
1053 * stack psect base plus byte offset (word index)
1054 * arg: by section index
1055 * (sh section index)
1056 * by signed byte offset
1060 unsigned long dummy;
1063 if (cmd == TIR_S_C_STA_PB)
1067 psect = bfd_getl16(ptr);
1071 if (psect >= PRIV(section_count))
1073 alloc_section (abfd, psect);
1076 dummy = (long)*ptr++;
1077 dummy += (PRIV(sections)[psect])->vma;
1078 _bfd_vms_push (abfd, dummy, psect);
1082 case TIR_S_C_STA_PW:
1083 case TIR_S_C_STA_WPW:
1085 * stack psect base plus word offset (word index)
1086 * arg: by section index
1087 * (sh section index)
1088 * sh signed short offset
1092 unsigned long dummy;
1095 if (cmd == TIR_S_C_STA_PW)
1099 psect = bfd_getl16(ptr);
1103 if (psect >= PRIV(section_count))
1105 alloc_section (abfd, psect);
1108 dummy = bfd_getl16(ptr); ptr+=2;
1109 dummy += (PRIV(sections)[psect])->vma;
1110 _bfd_vms_push (abfd, dummy, psect);
1114 case TIR_S_C_STA_PL:
1115 case TIR_S_C_STA_WPL:
1117 * stack psect base plus long offset (word index)
1118 * arg: by section index
1119 * (sh section index)
1120 * lw signed longword offset
1124 unsigned long dummy;
1127 if (cmd == TIR_S_C_STA_PL)
1131 psect = bfd_getl16(ptr);
1135 if (psect >= PRIV(section_count))
1137 alloc_section (abfd, psect);
1140 dummy = bfd_getl32 (ptr); ptr += 4;
1141 dummy += (PRIV(sections)[psect])->vma;
1142 _bfd_vms_push (abfd, dummy, psect);
1146 case TIR_S_C_STA_UB:
1148 * stack unsigned byte
1153 _bfd_vms_push (abfd, (unsigned long)*ptr++, -1);
1156 case TIR_S_C_STA_UW:
1158 * stack unsigned short word
1161 * stack 16 bit value
1163 _bfd_vms_push (abfd, (unsigned long)bfd_getl16(ptr), -1);
1167 case TIR_S_C_STA_BFI:
1169 * stack byte from image
1174 case TIR_S_C_STA_WFI:
1176 * stack byte from image
1181 case TIR_S_C_STA_LFI:
1183 * stack byte from image
1187 (*_bfd_error_handler) (_("Stack-from-image not implemented"));
1190 case TIR_S_C_STA_EPM:
1192 * stack entry point mask
1193 * arg: cs symbol name
1195 * stack (unsigned) entry point mask of symbol
1196 * err if symbol is no entry point
1200 vms_symbol_entry *entry;
1202 name = _bfd_vms_save_counted_string (ptr);
1203 entry = _bfd_vms_enter_symbol (abfd, name);
1204 if (entry == (vms_symbol_entry *)NULL)
1207 (*_bfd_error_handler) (_("Stack-entry-mask not fully implemented"));
1208 _bfd_vms_push (abfd, 0L, -1);
1213 case TIR_S_C_STA_CKARG:
1215 * compare procedure argument
1216 * arg: cs symbol name
1218 * da argument descriptor
1220 * compare argument descriptor with symbol argument (ARG$V_PASSMECH)
1221 * and stack TRUE (args match) or FALSE (args dont match) value
1223 (*_bfd_error_handler) (_("PASSMECH not fully implemented"));
1224 _bfd_vms_push (abfd, 1L, -1);
1227 case TIR_S_C_STA_LSY:
1229 * stack local symbol value
1230 * arg: sh environment index
1236 vms_symbol_entry *entry;
1238 envidx = bfd_getl16(ptr); ptr += 2;
1239 name = _bfd_vms_save_counted_string (ptr);
1240 entry = _bfd_vms_enter_symbol (abfd, name);
1241 if (entry == (vms_symbol_entry *)NULL)
1243 (*_bfd_error_handler) (_("Stack-local-symbol not fully implemented"));
1244 _bfd_vms_push (abfd, 0L, -1);
1249 case TIR_S_C_STA_LIT:
1252 * arg: by literal index
1257 _bfd_vms_push (abfd, 0L, -1);
1258 (*_bfd_error_handler) (_("Stack-literal not fully implemented"));
1261 case TIR_S_C_STA_LEPM:
1263 * stack local symbol entry point mask
1264 * arg: sh environment index
1267 * stack (unsigned) entry point mask of symbol
1268 * err if symbol is no entry point
1273 vms_symbol_entry *entry;
1275 envidx = bfd_getl16(ptr); ptr += 2;
1276 name = _bfd_vms_save_counted_string (ptr);
1277 entry = _bfd_vms_enter_symbol (abfd, name);
1278 if (entry == (vms_symbol_entry *)NULL)
1280 (*_bfd_error_handler) (_("Stack-local-symbol-entry-point-mask not fully implemented"));
1281 _bfd_vms_push (abfd, 0L, -1);
1287 (*_bfd_error_handler) (_("Reserved STA cmd %d"), ptr[-1]);
1299 * vax store commands
1301 * handle sto_xxx commands in tir section
1302 * ptr points to data area in record
1304 * see table 7-4 of the VAX/VMS linker manual
1307 static unsigned char *
1308 tir_sto (bfd *abfd, unsigned char *ptr)
1310 unsigned long dummy;
1315 _bfd_vms_debug (5, "tir_sto %d\n", *ptr);
1320 case TIR_S_C_STO_SB:
1322 * store signed byte: pop stack, write byte
1325 dummy = _bfd_vms_pop (abfd, &psect);
1326 image_write_b (abfd, dummy & 0xff); /* FIXME: check top bits */
1329 case TIR_S_C_STO_SW:
1331 * store signed word: pop stack, write word
1334 dummy = _bfd_vms_pop (abfd, &psect);
1335 image_write_w (abfd, dummy & 0xffff); /* FIXME: check top bits */
1338 case TIR_S_C_STO_LW:
1340 * store longword: pop stack, write longword
1343 dummy = _bfd_vms_pop (abfd, &psect);
1344 image_write_l (abfd, dummy & 0xffffffff);/* FIXME: check top bits */
1347 case TIR_S_C_STO_BD:
1349 * store byte displaced: pop stack, sub lc+1, write byte
1352 dummy = _bfd_vms_pop (abfd, &psect);
1353 dummy -= ((PRIV(sections)[psect])->vma + 1);
1354 image_write_b (abfd, dummy & 0xff);/* FIXME: check top bits */
1357 case TIR_S_C_STO_WD:
1359 * store word displaced: pop stack, sub lc+2, write word
1362 dummy = _bfd_vms_pop (abfd, &psect);
1363 dummy -= ((PRIV(sections)[psect])->vma + 2);
1364 image_write_w (abfd, dummy & 0xffff);/* FIXME: check top bits */
1366 case TIR_S_C_STO_LD:
1368 * store long displaced: pop stack, sub lc+4, write long
1371 dummy = _bfd_vms_pop (abfd, &psect);
1372 dummy -= ((PRIV(sections)[psect])->vma + 4);
1373 image_write_l (abfd, dummy & 0xffffffff);/* FIXME: check top bits */
1375 case TIR_S_C_STO_LI:
1377 * store short literal: pop stack, write byte
1380 dummy = _bfd_vms_pop (abfd, &psect);
1381 image_write_b (abfd, dummy & 0xff);/* FIXME: check top bits */
1383 case TIR_S_C_STO_PIDR:
1385 * store position independent data reference: pop stack, write longword
1387 * FIXME: incomplete !
1389 dummy = _bfd_vms_pop (abfd, &psect);
1390 image_write_l (abfd, dummy & 0xffffffff);
1392 case TIR_S_C_STO_PICR:
1394 * store position independent code reference: pop stack, write longword
1396 * FIXME: incomplete !
1398 dummy = _bfd_vms_pop (abfd, &psect);
1399 image_write_b (abfd, 0x9f);
1400 image_write_l (abfd, dummy & 0xffffffff);
1402 case TIR_S_C_STO_RIVB:
1404 * store repeated immediate variable bytes
1405 * 1-byte count n field followed by n bytes of data
1406 * pop stack, write n bytes <stack> times
1409 dummy = (unsigned long)_bfd_vms_pop (abfd, NULL);
1410 while (dummy-- > 0L)
1411 image_dump (abfd, ptr, size, 0);
1416 * store byte from top longword
1418 dummy = (unsigned long)_bfd_vms_pop (abfd, NULL);
1419 image_write_b (abfd, dummy & 0xff);
1423 * store word from top longword
1425 dummy = (unsigned long)_bfd_vms_pop (abfd, NULL);
1426 image_write_w (abfd, dummy & 0xffff);
1428 case TIR_S_C_STO_RB:
1430 * store repeated byte from top longword
1432 size = (unsigned long)_bfd_vms_pop (abfd, NULL);
1433 dummy = (unsigned long)_bfd_vms_pop (abfd, NULL);
1435 image_write_b (abfd, dummy & 0xff);
1437 case TIR_S_C_STO_RW:
1439 * store repeated word from top longword
1441 size = (unsigned long)_bfd_vms_pop (abfd, NULL);
1442 dummy = (unsigned long)_bfd_vms_pop (abfd, NULL);
1444 image_write_w (abfd, dummy & 0xffff);
1447 case TIR_S_C_STO_RSB:
1448 case TIR_S_C_STO_RSW:
1449 case TIR_S_C_STO_RL:
1450 case TIR_S_C_STO_VPS:
1451 case TIR_S_C_STO_USB:
1452 case TIR_S_C_STO_USW:
1453 case TIR_S_C_STO_RUB:
1454 case TIR_S_C_STO_RUW:
1455 case TIR_S_C_STO_PIRR:
1456 (*_bfd_error_handler) (_("Unimplemented STO cmd %d"), ptr[-1]);
1460 (*_bfd_error_handler) (_("Reserved STO cmd %d"), ptr[-1]);
1469 * stack operator commands
1470 * all 32 bit signed arithmetic
1471 * all word just like a stack calculator
1472 * arguments are popped from stack, results are pushed on stack
1474 * see table 7-5 of the VAX/VMS linker manual
1477 static unsigned char *
1478 tir_opr (bfd *abfd, unsigned char *ptr)
1483 _bfd_vms_debug (5, "tir_opr %d\n", *ptr);
1489 case TIR_S_C_OPR_NOP:
1495 case TIR_S_C_OPR_ADD:
1499 op1 = (long)_bfd_vms_pop (abfd, NULL);
1500 op2 = (long)_bfd_vms_pop (abfd, NULL);
1501 _bfd_vms_push (abfd, (unsigned long)(op1 + op2), -1);
1504 case TIR_S_C_OPR_SUB:
1508 op1 = (long)_bfd_vms_pop (abfd, NULL);
1509 op2 = (long)_bfd_vms_pop (abfd, NULL);
1510 _bfd_vms_push (abfd, (unsigned long)(op2 - op1), -1);
1513 case TIR_S_C_OPR_MUL:
1517 op1 = (long)_bfd_vms_pop (abfd, NULL);
1518 op2 = (long)_bfd_vms_pop (abfd, NULL);
1519 _bfd_vms_push (abfd, (unsigned long)(op1 * op2), -1);
1522 case TIR_S_C_OPR_DIV:
1526 op1 = (long)_bfd_vms_pop (abfd, NULL);
1527 op2 = (long)_bfd_vms_pop (abfd, NULL);
1529 _bfd_vms_push (abfd, (unsigned long)0L, -1);
1531 _bfd_vms_push (abfd, (unsigned long)(op2 / op1), -1);
1534 case TIR_S_C_OPR_AND:
1538 op1 = (long)_bfd_vms_pop (abfd, NULL);
1539 op2 = (long)_bfd_vms_pop (abfd, NULL);
1540 _bfd_vms_push (abfd, (unsigned long)(op1 & op2), -1);
1543 case TIR_S_C_OPR_IOR:
1544 op1 = (long)_bfd_vms_pop (abfd, NULL);
1546 * logical inclusive or
1548 op2 = (long)_bfd_vms_pop (abfd, NULL);
1549 _bfd_vms_push (abfd, (unsigned long)(op1 | op2), -1);
1552 case TIR_S_C_OPR_EOR:
1554 * logical exclusive or
1556 op1 = (long)_bfd_vms_pop (abfd, NULL);
1557 op2 = (long)_bfd_vms_pop (abfd, NULL);
1558 _bfd_vms_push (abfd, (unsigned long)(op1 ^ op2), -1);
1561 case TIR_S_C_OPR_NEG:
1565 op1 = (long)_bfd_vms_pop (abfd, NULL);
1566 _bfd_vms_push (abfd, (unsigned long)(-op1), -1);
1569 case TIR_S_C_OPR_COM:
1573 op1 = (long)_bfd_vms_pop (abfd, NULL);
1574 _bfd_vms_push (abfd, (unsigned long)(op1 ^ -1L), -1);
1577 case TIR_S_C_OPR_INSV:
1581 (void)_bfd_vms_pop (abfd, NULL);
1582 (*_bfd_error_handler) ("TIR_S_C_OPR_INSV incomplete");
1585 case TIR_S_C_OPR_ASH:
1589 op1 = (long)_bfd_vms_pop (abfd, NULL);
1590 op2 = (long)_bfd_vms_pop (abfd, NULL);
1591 if (HIGHBIT(op1)) /* shift right */
1593 else /* shift left */
1595 _bfd_vms_push (abfd, (unsigned long)op2, -1);
1596 (*_bfd_error_handler) (_("TIR_S_C_OPR_ASH incomplete"));
1599 case TIR_S_C_OPR_USH:
1603 op1 = (long)_bfd_vms_pop (abfd, NULL);
1604 op2 = (long)_bfd_vms_pop (abfd, NULL);
1605 if (HIGHBIT(op1)) /* shift right */
1607 else /* shift left */
1609 _bfd_vms_push (abfd, (unsigned long)op2, -1);
1610 (*_bfd_error_handler) (_("TIR_S_C_OPR_USH incomplete"));
1613 case TIR_S_C_OPR_ROT:
1617 op1 = (long)_bfd_vms_pop (abfd, NULL);
1618 op2 = (long)_bfd_vms_pop (abfd, NULL);
1619 if (HIGHBIT(0)) /* shift right */
1621 else /* shift left */
1623 _bfd_vms_push (abfd, (unsigned long)op2, -1);
1624 (*_bfd_error_handler) (_("TIR_S_C_OPR_ROT incomplete"));
1627 case TIR_S_C_OPR_SEL:
1631 if ((long)_bfd_vms_pop (abfd, NULL) & 0x01L)
1632 (void)_bfd_vms_pop (abfd, NULL);
1635 op1 = (long)_bfd_vms_pop (abfd, NULL);
1636 (void)_bfd_vms_pop (abfd, NULL);
1637 _bfd_vms_push (abfd, (unsigned long)op1, -1);
1641 case TIR_S_C_OPR_REDEF:
1643 * redefine symbol to current location
1645 (*_bfd_error_handler) (_("TIR_S_C_OPR_REDEF not supported"));
1648 case TIR_S_C_OPR_DFLIT:
1652 (*_bfd_error_handler) (_("TIR_S_C_OPR_DFLIT not supported"));
1656 (*_bfd_error_handler) (_("Reserved OPR cmd %d"), ptr[-1]);
1664 static unsigned char *
1665 tir_ctl (bfd *abfd, unsigned char *ptr)
1669 * see table 7-6 of the VAX/VMS linker manual
1672 unsigned long dummy;
1676 _bfd_vms_debug (5, "tir_ctl %d\n", *ptr);
1681 case TIR_S_C_CTL_SETRB:
1683 * set relocation base: pop stack, set image location counter
1686 dummy = _bfd_vms_pop (abfd, &psect);
1687 if (psect >= PRIV(section_count))
1689 alloc_section (abfd, psect);
1691 image_set_ptr (abfd, psect, dummy);
1693 case TIR_S_C_CTL_AUGRB:
1695 * augment relocation base: increment image location counter by offset
1696 * arg: lw offset value
1698 dummy = bfd_getl32 (ptr);
1699 image_inc_ptr (abfd, dummy);
1701 case TIR_S_C_CTL_DFLOC:
1703 * define location: pop index, save location counter under index
1706 dummy = _bfd_vms_pop (abfd, NULL);
1707 (*_bfd_error_handler) (_("TIR_S_C_CTL_DFLOC not fully implemented"));
1709 case TIR_S_C_CTL_STLOC:
1711 * set location: pop index, restore location counter from index
1714 dummy = _bfd_vms_pop (abfd, &psect);
1715 (*_bfd_error_handler) (_("TIR_S_C_CTL_STLOC not fully implemented"));
1717 case TIR_S_C_CTL_STKDL:
1719 * stack defined location: pop index, push location counter from index
1722 dummy = _bfd_vms_pop (abfd, &psect);
1723 (*_bfd_error_handler) (_("TIR_S_C_CTL_STKDL not fully implemented"));
1726 (*_bfd_error_handler) (_("Reserved CTL cmd %d"), ptr[-1]);
1734 * handle command from TIR section
1737 static unsigned char *
1738 tir_cmd (bfd *abfd, unsigned char *ptr)
1743 unsigned char * (*explain)(bfd *, unsigned char *);
1745 { 0, TIR_S_C_MAXSTACOD, tir_sta }
1746 ,{ TIR_S_C_MINSTOCOD, TIR_S_C_MAXSTOCOD, tir_sto }
1747 ,{ TIR_S_C_MINOPRCOD, TIR_S_C_MAXOPRCOD, tir_opr }
1748 ,{ TIR_S_C_MINCTLCOD, TIR_S_C_MAXCTLCOD, tir_ctl }
1754 _bfd_vms_debug (4, "tir_cmd %d/%x\n", *ptr, *ptr);
1755 _bfd_hexdump (8, ptr, 16, (int)ptr);
1758 if (*ptr & 0x80) /* store immediate */
1760 i = 128 - (*ptr++ & 0x7f);
1761 image_dump (abfd, ptr, i, 0);
1766 while (tir_table[i].mincod >= 0)
1768 if ( (tir_table[i].mincod <= *ptr)
1769 && (*ptr <= tir_table[i].maxcod))
1771 ptr = tir_table[i].explain (abfd, ptr);
1776 if (tir_table[i].mincod < 0)
1778 (*_bfd_error_handler) (_("Obj code %d not found"), *ptr);
1787 /* handle command from ETIR section */
1790 etir_cmd (abfd, cmd, ptr)
1798 boolean (*explain) PARAMS((bfd *, int, unsigned char *));
1800 { ETIR_S_C_MINSTACOD, ETIR_S_C_MAXSTACOD, etir_sta },
1801 { ETIR_S_C_MINSTOCOD, ETIR_S_C_MAXSTOCOD, etir_sto },
1802 { ETIR_S_C_MINOPRCOD, ETIR_S_C_MAXOPRCOD, etir_opr },
1803 { ETIR_S_C_MINCTLCOD, ETIR_S_C_MAXCTLCOD, etir_ctl },
1804 { ETIR_S_C_MINSTCCOD, ETIR_S_C_MAXSTCCOD, etir_stc },
1811 _bfd_vms_debug (4, "etir_cmd %d/%x\n", cmd, cmd);
1812 _bfd_hexdump (8, ptr, 16, (int)ptr);
1815 while (etir_table[i].mincod >= 0)
1817 if ( (etir_table[i].mincod <= cmd)
1818 && (cmd <= etir_table[i].maxcod))
1820 if (!etir_table[i].explain (abfd, cmd, ptr))
1828 _bfd_vms_debug (4, "etir_cmd: = 0\n");
1834 /* Text Information and Relocation Records (OBJ$C_TIR)
1835 handle tir record */
1838 analyze_tir (abfd, ptr, length)
1841 unsigned int length;
1843 unsigned char *maxptr;
1846 _bfd_vms_debug (3, "analyze_tir: %d bytes\n", length);
1849 maxptr = ptr + length;
1851 while (ptr < maxptr)
1853 ptr = tir_cmd (abfd, ptr);
1862 /* Text Information and Relocation Records (EOBJ$C_ETIR)
1863 handle etir record */
1866 analyze_etir (abfd, ptr, length)
1869 unsigned int length;
1872 unsigned char *maxptr;
1876 _bfd_vms_debug (3, "analyze_etir: %d bytes\n", length);
1879 maxptr = ptr + length;
1881 while (ptr < maxptr)
1883 cmd = bfd_getl16 (ptr);
1884 length = bfd_getl16 (ptr + 2);
1885 result = etir_cmd (abfd, cmd, ptr+4);
1892 _bfd_vms_debug (3, "analyze_etir: = %d\n", result);
1899 /* process ETIR record
1901 return 0 on success, -1 on error */
1904 _bfd_vms_slurp_tir (abfd, objtype)
1911 _bfd_vms_debug (2, "TIR/ETIR\n");
1917 PRIV(vms_rec) += 4; /* skip type, size */
1918 PRIV(rec_size) -= 4;
1919 result = analyze_etir (abfd, PRIV(vms_rec), PRIV(rec_size));
1922 PRIV(vms_rec) += 1; /* skip type */
1923 PRIV(rec_size) -= 1;
1924 result = analyze_tir (abfd, PRIV(vms_rec), PRIV(rec_size));
1935 /* process EDBG record
1936 return 0 on success, -1 on error
1938 not implemented yet */
1941 _bfd_vms_slurp_dbg (abfd, objtype)
1943 int objtype ATTRIBUTE_UNUSED;
1946 _bfd_vms_debug (2, "DBG/EDBG\n");
1949 abfd->flags |= (HAS_DEBUG | HAS_LINENO);
1954 /* process ETBT record
1955 return 0 on success, -1 on error
1957 not implemented yet */
1960 _bfd_vms_slurp_tbt (abfd, objtype)
1961 bfd *abfd ATTRIBUTE_UNUSED;
1962 int objtype ATTRIBUTE_UNUSED;
1965 _bfd_vms_debug (2, "TBT/ETBT\n");
1972 /* process LNK record
1973 return 0 on success, -1 on error
1975 not implemented yet */
1978 _bfd_vms_slurp_lnk (abfd, objtype)
1979 bfd *abfd ATTRIBUTE_UNUSED;
1980 int objtype ATTRIBUTE_UNUSED;
1983 _bfd_vms_debug (2, "LNK\n");
1989 /*----------------------------------------------------------------------*/
1991 /* WRITE ETIR SECTION */
1993 /* this is still under construction and therefore not documented */
1995 /*----------------------------------------------------------------------*/
1997 static void start_etir_record PARAMS ((bfd *abfd, int index, uquad offset, boolean justoffset));
1998 static void sto_imm PARAMS ((bfd *abfd, vms_section *sptr, bfd_vma vaddr, int index));
1999 static void end_etir_record PARAMS ((bfd *abfd));
2002 sto_imm (abfd, sptr, vaddr, index)
2010 unsigned char *cptr;
2013 _bfd_vms_debug (8, "sto_imm %d bytes\n", sptr->size);
2014 _bfd_hexdump (9, sptr->contents, (int)sptr->size, (int)vaddr);
2018 cptr = sptr->contents;
2023 size = ssize; /* try all the rest */
2025 if (_bfd_vms_output_check (abfd, size) < 0)
2026 { /* doesn't fit, split ! */
2027 end_etir_record (abfd);
2028 start_etir_record (abfd, index, vaddr, false);
2029 size = _bfd_vms_output_check (abfd, 0); /* get max size */
2030 if (size > ssize) /* more than what's left ? */
2034 _bfd_vms_output_begin (abfd, ETIR_S_C_STO_IMM, -1);
2035 _bfd_vms_output_long (abfd, (unsigned long)(size));
2036 _bfd_vms_output_dump (abfd, cptr, size);
2037 _bfd_vms_output_flush (abfd);
2040 _bfd_vms_debug (10, "dumped %d bytes\n", size);
2041 _bfd_hexdump (10, cptr, (int)size, (int)vaddr);
2052 /*-------------------------------------------------------------------*/
2054 /* start ETIR record for section #index at virtual addr offset. */
2057 start_etir_record (abfd, index, offset, justoffset)
2065 _bfd_vms_output_begin (abfd, EOBJ_S_C_ETIR, -1); /* one ETIR per section */
2066 _bfd_vms_output_push (abfd);
2069 _bfd_vms_output_begin (abfd, ETIR_S_C_STA_PQ, -1); /* push start offset */
2070 _bfd_vms_output_long (abfd, (unsigned long)index);
2071 _bfd_vms_output_quad (abfd, (uquad)offset);
2072 _bfd_vms_output_flush (abfd);
2074 _bfd_vms_output_begin (abfd, ETIR_S_C_CTL_SETRB, -1); /* start = pop () */
2075 _bfd_vms_output_flush (abfd);
2081 /* end etir record */
2083 end_etir_record (abfd)
2086 _bfd_vms_output_pop (abfd);
2087 _bfd_vms_output_end (abfd);
2090 /* write section contents for bfd abfd */
2093 _bfd_vms_write_tir (abfd, objtype)
2095 int objtype ATTRIBUTE_UNUSED;
2102 _bfd_vms_debug (2, "vms_write_tir (%p, %d)\n", abfd, objtype);
2105 _bfd_vms_output_alignment (abfd, 4);
2108 PRIV(vms_linkage_index) = 1;
2110 /* dump all other sections */
2112 section = abfd->sections;
2114 while (section != NULL)
2118 _bfd_vms_debug (4, "writing %d. section '%s' (%d bytes)\n", section->index, section->name, (int)(section->_raw_size));
\r
2121 if (section->flags & SEC_RELOC)
2125 if ((i = section->reloc_count) <= 0)
2127 (*_bfd_error_handler) (_("SEC_RELOC with no relocs in section %s"),
2134 _bfd_vms_debug (4, "%d relocations:\n", i);
2135 rptr = section->orelocation;
2138 _bfd_vms_debug (4, "sym %s in sec %s, value %08lx, addr %08lx, off %08lx, len %d: %s\n",
2139 (*(*rptr)->sym_ptr_ptr)->name,
2140 (*(*rptr)->sym_ptr_ptr)->section->name,
2141 (long)(*(*rptr)->sym_ptr_ptr)->value,
2142 (*rptr)->address, (*rptr)->addend,
2143 bfd_get_reloc_size((*rptr)->howto),
2144 (*rptr)->howto->name);
2151 if ((section->flags & SEC_HAS_CONTENTS)
2152 && (! bfd_is_com_section (section)))
2154 bfd_vma vaddr; /* virtual addr in section */
2156 sptr = _bfd_get_vms_section (abfd, section->index);
2159 bfd_set_error (bfd_error_no_contents);
2163 vaddr = (bfd_vma)(sptr->offset);
2165 start_etir_record (abfd, section->index, (uquad) sptr->offset,
2168 while (sptr != NULL) /* one STA_PQ, CTL_SETRB per vms_section */
2171 if (section->flags & SEC_RELOC) /* check for relocs */
2173 arelent **rptr = section->orelocation;
2174 int i = section->reloc_count;
2177 bfd_size_type addr = (*rptr)->address;
2178 bfd_size_type len = bfd_get_reloc_size ((*rptr)->howto);
2179 if (sptr->offset < addr) /* sptr starts before reloc */
2181 bfd_size_type before = addr - sptr->offset;
2182 if (sptr->size <= before) /* complete before */
2184 sto_imm (abfd, sptr, vaddr, section->index);
2185 vaddr += sptr->size;
2188 else /* partly before */
2190 int after = sptr->size - before;
2191 sptr->size = before;
2192 sto_imm (abfd, sptr, vaddr, section->index);
2193 vaddr += sptr->size;
2194 sptr->contents += before;
2195 sptr->offset += before;
2199 else if (sptr->offset == addr) /* sptr starts at reloc */
2201 asymbol *sym = *(*rptr)->sym_ptr_ptr;
2202 asection *sec = sym->section;
2204 switch ((*rptr)->howto->type)
2206 case ALPHA_R_IGNORE:
2209 case ALPHA_R_REFLONG:
2211 if (bfd_is_und_section (sym->section))
2213 if (_bfd_vms_output_check (abfd,
2214 strlen((char *)sym->name))
2217 end_etir_record (abfd);
2218 start_etir_record (abfd,
2222 _bfd_vms_output_begin (abfd,
2223 ETIR_S_C_STO_GBL_LW,
2225 _bfd_vms_output_counted (abfd,
2226 _bfd_vms_length_hash_symbol (abfd, sym->name, EOBJ_S_C_SYMSIZ));
2227 _bfd_vms_output_flush (abfd);
2229 else if (bfd_is_abs_section (sym->section))
2231 if (_bfd_vms_output_check (abfd, 16) < 0)
2233 end_etir_record (abfd);
2234 start_etir_record (abfd,
2238 _bfd_vms_output_begin (abfd,
2241 _bfd_vms_output_quad (abfd,
2243 _bfd_vms_output_flush (abfd);
2244 _bfd_vms_output_begin (abfd,
2247 _bfd_vms_output_flush (abfd);
2251 if (_bfd_vms_output_check (abfd, 32) < 0)
2253 end_etir_record (abfd);
2254 start_etir_record (abfd,
2258 _bfd_vms_output_begin (abfd,
2261 _bfd_vms_output_long (abfd,
2262 (unsigned long)(sec->index));
2263 _bfd_vms_output_quad (abfd,
2264 ((uquad)(*rptr)->addend
2265 + (uquad)sym->value));
2266 _bfd_vms_output_flush (abfd);
2267 _bfd_vms_output_begin (abfd,
2270 _bfd_vms_output_flush (abfd);
2275 case ALPHA_R_REFQUAD:
2277 if (bfd_is_und_section (sym->section))
2279 if (_bfd_vms_output_check (abfd,
2280 strlen((char *)sym->name))
2283 end_etir_record (abfd);
2284 start_etir_record (abfd,
2288 _bfd_vms_output_begin (abfd,
2291 _bfd_vms_output_counted (abfd,
2292 _bfd_vms_length_hash_symbol (abfd, sym->name, EOBJ_S_C_SYMSIZ));
2293 _bfd_vms_output_flush (abfd);
2295 else if (bfd_is_abs_section (sym->section))
2297 if (_bfd_vms_output_check (abfd, 16) < 0)
2299 end_etir_record (abfd);
2300 start_etir_record (abfd,
2304 _bfd_vms_output_begin (abfd,
2307 _bfd_vms_output_quad (abfd,
2309 _bfd_vms_output_flush (abfd);
2310 _bfd_vms_output_begin (abfd,
2313 _bfd_vms_output_flush (abfd);
2317 if (_bfd_vms_output_check (abfd, 32) < 0)
2319 end_etir_record (abfd);
2320 start_etir_record (abfd,
2324 _bfd_vms_output_begin (abfd,
2327 _bfd_vms_output_long (abfd,
2328 (unsigned long)(sec->index));
2329 _bfd_vms_output_quad (abfd,
2330 ((uquad)(*rptr)->addend
2331 + (uquad)sym->value));
2332 _bfd_vms_output_flush (abfd);
2333 _bfd_vms_output_begin (abfd,
2336 _bfd_vms_output_flush (abfd);
2345 hint_size = sptr->size;
2347 sto_imm (abfd, sptr, vaddr, section->index);
2348 sptr->size = hint_size;
2350 vms_output_begin(abfd, ETIR_S_C_STO_HINT_GBL, -1);
2351 vms_output_long(abfd, (unsigned long)(sec->index));
2352 vms_output_quad(abfd, (uquad)addr);
2354 vms_output_counted(abfd, _bfd_vms_length_hash_symbol (abfd, sym->name, EOBJ_S_C_SYMSIZ));
2355 vms_output_flush(abfd);
2359 case ALPHA_R_LINKAGE:
2361 if (_bfd_vms_output_check (abfd, 64) < 0)
2363 end_etir_record (abfd);
2364 start_etir_record (abfd, section->index,
2367 _bfd_vms_output_begin (abfd,
2368 ETIR_S_C_STC_LP_PSB,
2370 _bfd_vms_output_long (abfd,
2371 (unsigned long)PRIV(vms_linkage_index));
2372 PRIV(vms_linkage_index) += 2;
2373 _bfd_vms_output_counted (abfd,
2374 _bfd_vms_length_hash_symbol (abfd, sym->name, EOBJ_S_C_SYMSIZ));
2375 _bfd_vms_output_byte (abfd, 0);
2376 _bfd_vms_output_flush (abfd);
2380 case ALPHA_R_CODEADDR:
2382 if (_bfd_vms_output_check (abfd,
2383 strlen((char *)sym->name))
2386 end_etir_record (abfd);
2387 start_etir_record (abfd,
2391 _bfd_vms_output_begin (abfd,
2394 _bfd_vms_output_counted (abfd,
2395 _bfd_vms_length_hash_symbol (abfd, sym->name, EOBJ_S_C_SYMSIZ));
2396 _bfd_vms_output_flush (abfd);
2401 (*_bfd_error_handler) (_("Unhandled relocation %s"),
2402 (*rptr)->howto->name);
2408 if (len == sptr->size)
2414 sptr->contents += len;
2415 sptr->offset += len;
2421 else /* sptr starts after reloc */
2423 i--; /* check next reloc */
2427 if (i==0) /* all reloc checked */
2431 sto_imm (abfd, sptr, vaddr, section->index); /* dump rest */
2432 vaddr += sptr->size;
2437 } /* if SEC_RELOC */
2438 else /* no relocs, just dump */
2440 sto_imm (abfd, sptr, vaddr, section->index);
2441 vaddr += sptr->size;
2446 } /* while (sptr != 0) */
2448 end_etir_record (abfd);
2450 } /* has_contents */
2452 section = section->next;
2455 _bfd_vms_output_alignment(abfd, 2);
2460 /* write traceback data for bfd abfd */
2463 _bfd_vms_write_tbt (abfd, objtype)
2464 bfd *abfd ATTRIBUTE_UNUSED;
2465 int objtype ATTRIBUTE_UNUSED;
2468 _bfd_vms_debug (2, "vms_write_tbt (%p, %d)\n", abfd, objtype);
2475 /* write debug info for bfd abfd */
2478 _bfd_vms_write_dbg (abfd, objtype)
2479 bfd *abfd ATTRIBUTE_UNUSED;
2480 int objtype ATTRIBUTE_UNUSED;
2483 _bfd_vms_debug (2, "vms_write_dbg (%p, objtype)\n", abfd, objtype);