1 /* vms-tir.c -- BFD back-end for VAX (openVMS/VAX) and
2 EVAX (openVMS/Alpha) files.
3 Copyright 1996, 1997, 1998 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 ((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
)
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
)
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
)
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
)
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
)
955 _bfd_vms_debug (4, "alloc_section %d\n", idx
);
958 PRIV(sections
) = ((asection
**)
959 bfd_realloc (PRIV(sections
), (idx
+1) * sizeof (asection
*)));
960 if (PRIV(sections
) == 0)
963 while (PRIV(section_count
) <= idx
)
965 PRIV(sections
)[PRIV(section_count
)] = new_section (abfd
, PRIV(section_count
));
966 if (PRIV(sections
)[PRIV(section_count
)] == 0)
968 PRIV(section_count
)++;
980 * handle sta_xxx commands in tir section
981 * ptr points to data area in record
983 * see table 7-3 of the VAX/VMS linker manual
986 static unsigned char *
987 tir_sta (bfd
*abfd
, unsigned char *ptr
)
992 _bfd_vms_debug (5, "tir_sta %d\n", cmd
);
998 case TIR_S_C_STA_GBL
:
1001 * arg: cs symbol name
1003 * stack 32 bit value of symbol (high bits set to 0)
1007 vms_symbol_entry
*entry
;
1009 name
= _bfd_vms_save_counted_string (ptr
);
1011 entry
= _bfd_vms_enter_symbol (abfd
, name
);
1012 if (entry
== (vms_symbol_entry
*)NULL
)
1015 _bfd_vms_push (abfd
, (unsigned long)(entry
->symbol
->value
), -1);
1020 case TIR_S_C_STA_SB
:
1025 * stack byte value, sign extend to 32 bit
1027 _bfd_vms_push (abfd
, (long)*ptr
++, -1);
1030 case TIR_S_C_STA_SW
:
1032 * stack signed short word
1035 * stack 16 bit value, sign extend to 32 bit
1037 _bfd_vms_push (abfd
, (long)bfd_getl16(ptr
), -1);
1041 case TIR_S_C_STA_LW
:
1043 * stack signed longword
1046 * stack 32 bit value
1048 _bfd_vms_push (abfd
, (long)bfd_getl32 (ptr
), -1);
1052 case TIR_S_C_STA_PB
:
1053 case TIR_S_C_STA_WPB
:
1055 * stack psect base plus byte offset (word index)
1056 * arg: by section index
1057 * (sh section index)
1058 * by signed byte offset
1062 unsigned long dummy
;
1065 if (cmd
== TIR_S_C_STA_PB
)
1069 psect
= bfd_getl16(ptr
);
1073 if (psect
>= PRIV(section_count
))
1075 alloc_section (abfd
, psect
);
1078 dummy
= (long)*ptr
++;
1079 dummy
+= (PRIV(sections
)[psect
])->vma
;
1080 _bfd_vms_push (abfd
, dummy
, psect
);
1084 case TIR_S_C_STA_PW
:
1085 case TIR_S_C_STA_WPW
:
1087 * stack psect base plus word offset (word index)
1088 * arg: by section index
1089 * (sh section index)
1090 * sh signed short offset
1094 unsigned long dummy
;
1097 if (cmd
== TIR_S_C_STA_PW
)
1101 psect
= bfd_getl16(ptr
);
1105 if (psect
>= PRIV(section_count
))
1107 alloc_section (abfd
, psect
);
1110 dummy
= bfd_getl16(ptr
); ptr
+=2;
1111 dummy
+= (PRIV(sections
)[psect
])->vma
;
1112 _bfd_vms_push (abfd
, dummy
, psect
);
1116 case TIR_S_C_STA_PL
:
1117 case TIR_S_C_STA_WPL
:
1119 * stack psect base plus long offset (word index)
1120 * arg: by section index
1121 * (sh section index)
1122 * lw signed longword offset
1126 unsigned long dummy
;
1129 if (cmd
== TIR_S_C_STA_PL
)
1133 psect
= bfd_getl16(ptr
);
1137 if (psect
>= PRIV(section_count
))
1139 alloc_section (abfd
, psect
);
1142 dummy
= bfd_getl32 (ptr
); ptr
+= 4;
1143 dummy
+= (PRIV(sections
)[psect
])->vma
;
1144 _bfd_vms_push (abfd
, dummy
, psect
);
1148 case TIR_S_C_STA_UB
:
1150 * stack unsigned byte
1155 _bfd_vms_push (abfd
, (unsigned long)*ptr
++, -1);
1158 case TIR_S_C_STA_UW
:
1160 * stack unsigned short word
1163 * stack 16 bit value
1165 _bfd_vms_push (abfd
, (unsigned long)bfd_getl16(ptr
), -1);
1169 case TIR_S_C_STA_BFI
:
1171 * stack byte from image
1176 case TIR_S_C_STA_WFI
:
1178 * stack byte from image
1183 case TIR_S_C_STA_LFI
:
1185 * stack byte from image
1189 (*_bfd_error_handler
) (_("Stack-from-image not implemented"));
1192 case TIR_S_C_STA_EPM
:
1194 * stack entry point mask
1195 * arg: cs symbol name
1197 * stack (unsigned) entry point mask of symbol
1198 * err if symbol is no entry point
1202 vms_symbol_entry
*entry
;
1204 name
= _bfd_vms_save_counted_string (ptr
);
1205 entry
= _bfd_vms_enter_symbol (abfd
, name
);
1206 if (entry
== (vms_symbol_entry
*)NULL
)
1209 (*_bfd_error_handler
) (_("Stack-entry-mask not fully implemented"));
1210 _bfd_vms_push (abfd
, 0L, -1);
1215 case TIR_S_C_STA_CKARG
:
1217 * compare procedure argument
1218 * arg: cs symbol name
1220 * da argument descriptor
1222 * compare argument descriptor with symbol argument (ARG$V_PASSMECH)
1223 * and stack TRUE (args match) or FALSE (args dont match) value
1225 (*_bfd_error_handler
) (_("PASSMECH not fully implemented"));
1226 _bfd_vms_push (abfd
, 1L, -1);
1229 case TIR_S_C_STA_LSY
:
1231 * stack local symbol value
1232 * arg: sh environment index
1238 vms_symbol_entry
*entry
;
1240 envidx
= bfd_getl16(ptr
); ptr
+= 2;
1241 name
= _bfd_vms_save_counted_string (ptr
);
1242 entry
= _bfd_vms_enter_symbol (abfd
, name
);
1243 if (entry
== (vms_symbol_entry
*)NULL
)
1245 (*_bfd_error_handler
) (_("Stack-local-symbol not fully implemented"));
1246 _bfd_vms_push (abfd
, 0L, -1);
1251 case TIR_S_C_STA_LIT
:
1254 * arg: by literal index
1259 _bfd_vms_push (abfd
, 0L, -1);
1260 (*_bfd_error_handler
) (_("Stack-literal not fully implemented"));
1263 case TIR_S_C_STA_LEPM
:
1265 * stack local symbol entry point mask
1266 * arg: sh environment index
1269 * stack (unsigned) entry point mask of symbol
1270 * err if symbol is no entry point
1275 vms_symbol_entry
*entry
;
1277 envidx
= bfd_getl16(ptr
); ptr
+= 2;
1278 name
= _bfd_vms_save_counted_string (ptr
);
1279 entry
= _bfd_vms_enter_symbol (abfd
, name
);
1280 if (entry
== (vms_symbol_entry
*)NULL
)
1282 (*_bfd_error_handler
) (_("Stack-local-symbol-entry-point-mask not fully implemented"));
1283 _bfd_vms_push (abfd
, 0L, -1);
1289 (*_bfd_error_handler
) (_("Reserved STA cmd %d"), ptr
[-1]);
1301 * vax store commands
1303 * handle sto_xxx commands in tir section
1304 * ptr points to data area in record
1306 * see table 7-4 of the VAX/VMS linker manual
1309 static unsigned char *
1310 tir_sto (bfd
*abfd
, unsigned char *ptr
)
1312 unsigned long dummy
;
1317 _bfd_vms_debug (5, "tir_sto %d\n", *ptr
);
1322 case TIR_S_C_STO_SB
:
1324 * store signed byte: pop stack, write byte
1327 dummy
= _bfd_vms_pop (abfd
, &psect
);
1328 image_write_b (abfd
, dummy
& 0xff); /* FIXME: check top bits */
1331 case TIR_S_C_STO_SW
:
1333 * store signed word: pop stack, write word
1336 dummy
= _bfd_vms_pop (abfd
, &psect
);
1337 image_write_w (abfd
, dummy
& 0xffff); /* FIXME: check top bits */
1340 case TIR_S_C_STO_LW
:
1342 * store longword: pop stack, write longword
1345 dummy
= _bfd_vms_pop (abfd
, &psect
);
1346 image_write_l (abfd
, dummy
& 0xffffffff);/* FIXME: check top bits */
1349 case TIR_S_C_STO_BD
:
1351 * store byte displaced: pop stack, sub lc+1, write byte
1354 dummy
= _bfd_vms_pop (abfd
, &psect
);
1355 dummy
-= ((PRIV(sections
)[psect
])->vma
+ 1);
1356 image_write_b (abfd
, dummy
& 0xff);/* FIXME: check top bits */
1359 case TIR_S_C_STO_WD
:
1361 * store word displaced: pop stack, sub lc+2, write word
1364 dummy
= _bfd_vms_pop (abfd
, &psect
);
1365 dummy
-= ((PRIV(sections
)[psect
])->vma
+ 2);
1366 image_write_w (abfd
, dummy
& 0xffff);/* FIXME: check top bits */
1368 case TIR_S_C_STO_LD
:
1370 * store long displaced: pop stack, sub lc+4, write long
1373 dummy
= _bfd_vms_pop (abfd
, &psect
);
1374 dummy
-= ((PRIV(sections
)[psect
])->vma
+ 4);
1375 image_write_l (abfd
, dummy
& 0xffffffff);/* FIXME: check top bits */
1377 case TIR_S_C_STO_LI
:
1379 * store short literal: pop stack, write byte
1382 dummy
= _bfd_vms_pop (abfd
, &psect
);
1383 image_write_b (abfd
, dummy
& 0xff);/* FIXME: check top bits */
1385 case TIR_S_C_STO_PIDR
:
1387 * store position independent data reference: pop stack, write longword
1389 * FIXME: incomplete !
1391 dummy
= _bfd_vms_pop (abfd
, &psect
);
1392 image_write_l (abfd
, dummy
& 0xffffffff);
1394 case TIR_S_C_STO_PICR
:
1396 * store position independent code reference: pop stack, write longword
1398 * FIXME: incomplete !
1400 dummy
= _bfd_vms_pop (abfd
, &psect
);
1401 image_write_b (abfd
, 0x9f);
1402 image_write_l (abfd
, dummy
& 0xffffffff);
1404 case TIR_S_C_STO_RIVB
:
1406 * store repeated immediate variable bytes
1407 * 1-byte count n field followed by n bytes of data
1408 * pop stack, write n bytes <stack> times
1411 dummy
= (unsigned long)_bfd_vms_pop (abfd
, NULL
);
1412 while (dummy
-- > 0L)
1413 image_dump (abfd
, ptr
, size
, 0);
1418 * store byte from top longword
1420 dummy
= (unsigned long)_bfd_vms_pop (abfd
, NULL
);
1421 image_write_b (abfd
, dummy
& 0xff);
1425 * store word from top longword
1427 dummy
= (unsigned long)_bfd_vms_pop (abfd
, NULL
);
1428 image_write_w (abfd
, dummy
& 0xffff);
1430 case TIR_S_C_STO_RB
:
1432 * store repeated byte from top longword
1434 size
= (unsigned long)_bfd_vms_pop (abfd
, NULL
);
1435 dummy
= (unsigned long)_bfd_vms_pop (abfd
, NULL
);
1437 image_write_b (abfd
, dummy
& 0xff);
1439 case TIR_S_C_STO_RW
:
1441 * store repeated word from top longword
1443 size
= (unsigned long)_bfd_vms_pop (abfd
, NULL
);
1444 dummy
= (unsigned long)_bfd_vms_pop (abfd
, NULL
);
1446 image_write_w (abfd
, dummy
& 0xffff);
1449 case TIR_S_C_STO_RSB
:
1450 case TIR_S_C_STO_RSW
:
1451 case TIR_S_C_STO_RL
:
1452 case TIR_S_C_STO_VPS
:
1453 case TIR_S_C_STO_USB
:
1454 case TIR_S_C_STO_USW
:
1455 case TIR_S_C_STO_RUB
:
1456 case TIR_S_C_STO_RUW
:
1457 case TIR_S_C_STO_PIRR
:
1458 (*_bfd_error_handler
) (_("Unimplemented STO cmd %d"), ptr
[-1]);
1462 (*_bfd_error_handler
) (_("Reserved STO cmd %d"), ptr
[-1]);
1471 * stack operator commands
1472 * all 32 bit signed arithmetic
1473 * all word just like a stack calculator
1474 * arguments are popped from stack, results are pushed on stack
1476 * see table 7-5 of the VAX/VMS linker manual
1479 static unsigned char *
1480 tir_opr (bfd
*abfd
, unsigned char *ptr
)
1485 _bfd_vms_debug (5, "tir_opr %d\n", *ptr
);
1491 case TIR_S_C_OPR_NOP
:
1497 case TIR_S_C_OPR_ADD
:
1501 op1
= (long)_bfd_vms_pop (abfd
, NULL
);
1502 op2
= (long)_bfd_vms_pop (abfd
, NULL
);
1503 _bfd_vms_push (abfd
, (unsigned long)(op1
+ op2
), -1);
1506 case TIR_S_C_OPR_SUB
:
1510 op1
= (long)_bfd_vms_pop (abfd
, NULL
);
1511 op2
= (long)_bfd_vms_pop (abfd
, NULL
);
1512 _bfd_vms_push (abfd
, (unsigned long)(op2
- op1
), -1);
1515 case TIR_S_C_OPR_MUL
:
1519 op1
= (long)_bfd_vms_pop (abfd
, NULL
);
1520 op2
= (long)_bfd_vms_pop (abfd
, NULL
);
1521 _bfd_vms_push (abfd
, (unsigned long)(op1
* op2
), -1);
1524 case TIR_S_C_OPR_DIV
:
1528 op1
= (long)_bfd_vms_pop (abfd
, NULL
);
1529 op2
= (long)_bfd_vms_pop (abfd
, NULL
);
1531 _bfd_vms_push (abfd
, (unsigned long)0L, -1);
1533 _bfd_vms_push (abfd
, (unsigned long)(op2
/ op1
), -1);
1536 case TIR_S_C_OPR_AND
:
1540 op1
= (long)_bfd_vms_pop (abfd
, NULL
);
1541 op2
= (long)_bfd_vms_pop (abfd
, NULL
);
1542 _bfd_vms_push (abfd
, (unsigned long)(op1
& op2
), -1);
1545 case TIR_S_C_OPR_IOR
:
1546 op1
= (long)_bfd_vms_pop (abfd
, NULL
);
1548 * logical inclusive or
1550 op2
= (long)_bfd_vms_pop (abfd
, NULL
);
1551 _bfd_vms_push (abfd
, (unsigned long)(op1
| op2
), -1);
1554 case TIR_S_C_OPR_EOR
:
1556 * logical exclusive or
1558 op1
= (long)_bfd_vms_pop (abfd
, NULL
);
1559 op2
= (long)_bfd_vms_pop (abfd
, NULL
);
1560 _bfd_vms_push (abfd
, (unsigned long)(op1
^ op2
), -1);
1563 case TIR_S_C_OPR_NEG
:
1567 op1
= (long)_bfd_vms_pop (abfd
, NULL
);
1568 _bfd_vms_push (abfd
, (unsigned long)(-op1
), -1);
1571 case TIR_S_C_OPR_COM
:
1575 op1
= (long)_bfd_vms_pop (abfd
, NULL
);
1576 _bfd_vms_push (abfd
, (unsigned long)(op1
^ -1L), -1);
1579 case TIR_S_C_OPR_INSV
:
1583 (void)_bfd_vms_pop (abfd
, NULL
);
1584 (*_bfd_error_handler
) ("TIR_S_C_OPR_INSV incomplete");
1587 case TIR_S_C_OPR_ASH
:
1591 op1
= (long)_bfd_vms_pop (abfd
, NULL
);
1592 op2
= (long)_bfd_vms_pop (abfd
, NULL
);
1593 if (HIGHBIT(op1
)) /* shift right */
1595 else /* shift left */
1597 _bfd_vms_push (abfd
, (unsigned long)op2
, -1);
1598 (*_bfd_error_handler
) (_("TIR_S_C_OPR_ASH incomplete"));
1601 case TIR_S_C_OPR_USH
:
1605 op1
= (long)_bfd_vms_pop (abfd
, NULL
);
1606 op2
= (long)_bfd_vms_pop (abfd
, NULL
);
1607 if (HIGHBIT(op1
)) /* shift right */
1609 else /* shift left */
1611 _bfd_vms_push (abfd
, (unsigned long)op2
, -1);
1612 (*_bfd_error_handler
) (_("TIR_S_C_OPR_USH incomplete"));
1615 case TIR_S_C_OPR_ROT
:
1619 op1
= (long)_bfd_vms_pop (abfd
, NULL
);
1620 op2
= (long)_bfd_vms_pop (abfd
, NULL
);
1621 if (HIGHBIT(0)) /* shift right */
1623 else /* shift left */
1625 _bfd_vms_push (abfd
, (unsigned long)op2
, -1);
1626 (*_bfd_error_handler
) (_("TIR_S_C_OPR_ROT incomplete"));
1629 case TIR_S_C_OPR_SEL
:
1633 if ((long)_bfd_vms_pop (abfd
, NULL
) & 0x01L
)
1634 (void)_bfd_vms_pop (abfd
, NULL
);
1637 op1
= (long)_bfd_vms_pop (abfd
, NULL
);
1638 (void)_bfd_vms_pop (abfd
, NULL
);
1639 _bfd_vms_push (abfd
, (unsigned long)op1
, -1);
1643 case TIR_S_C_OPR_REDEF
:
1645 * redefine symbol to current location
1647 (*_bfd_error_handler
) (_("TIR_S_C_OPR_REDEF not supported"));
1650 case TIR_S_C_OPR_DFLIT
:
1654 (*_bfd_error_handler
) (_("TIR_S_C_OPR_DFLIT not supported"));
1658 (*_bfd_error_handler
) (_("Reserved OPR cmd %d"), ptr
[-1]);
1666 static unsigned char *
1667 tir_ctl (bfd
*abfd
, unsigned char *ptr
)
1671 * see table 7-6 of the VAX/VMS linker manual
1674 unsigned long dummy
;
1678 _bfd_vms_debug (5, "tir_ctl %d\n", *ptr
);
1683 case TIR_S_C_CTL_SETRB
:
1685 * set relocation base: pop stack, set image location counter
1688 dummy
= _bfd_vms_pop (abfd
, &psect
);
1689 if (psect
>= PRIV(section_count
))
1691 alloc_section (abfd
, psect
);
1693 image_set_ptr (abfd
, psect
, dummy
);
1695 case TIR_S_C_CTL_AUGRB
:
1697 * augment relocation base: increment image location counter by offset
1698 * arg: lw offset value
1700 dummy
= bfd_getl32 (ptr
);
1701 image_inc_ptr (abfd
, dummy
);
1703 case TIR_S_C_CTL_DFLOC
:
1705 * define location: pop index, save location counter under index
1708 dummy
= _bfd_vms_pop (abfd
, NULL
);
1709 (*_bfd_error_handler
) (_("TIR_S_C_CTL_DFLOC not fully implemented"));
1711 case TIR_S_C_CTL_STLOC
:
1713 * set location: pop index, restore location counter from index
1716 dummy
= _bfd_vms_pop (abfd
, &psect
);
1717 (*_bfd_error_handler
) (_("TIR_S_C_CTL_STLOC not fully implemented"));
1719 case TIR_S_C_CTL_STKDL
:
1721 * stack defined location: pop index, push location counter from index
1724 dummy
= _bfd_vms_pop (abfd
, &psect
);
1725 (*_bfd_error_handler
) (_("TIR_S_C_CTL_STKDL not fully implemented"));
1728 (*_bfd_error_handler
) (_("Reserved CTL cmd %d"), ptr
[-1]);
1736 * handle command from TIR section
1739 static unsigned char *
1740 tir_cmd (bfd
*abfd
, unsigned char *ptr
)
1745 unsigned char * (*explain
)(bfd
*, unsigned char *);
1747 { 0, TIR_S_C_MAXSTACOD
, tir_sta
}
1748 ,{ TIR_S_C_MINSTOCOD
, TIR_S_C_MAXSTOCOD
, tir_sto
}
1749 ,{ TIR_S_C_MINOPRCOD
, TIR_S_C_MAXOPRCOD
, tir_opr
}
1750 ,{ TIR_S_C_MINCTLCOD
, TIR_S_C_MAXCTLCOD
, tir_ctl
}
1756 _bfd_vms_debug (4, "tir_cmd %d/%x\n", *ptr
, *ptr
);
1757 _bfd_hexdump (8, ptr
, 16, (int)ptr
);
1760 if (*ptr
& 0x80) /* store immediate */
1762 i
= 128 - (*ptr
++ & 0x7f);
1763 image_dump (abfd
, ptr
, i
, 0);
1768 while (tir_table
[i
].mincod
>= 0)
1770 if ( (tir_table
[i
].mincod
<= *ptr
)
1771 && (*ptr
<= tir_table
[i
].maxcod
))
1773 ptr
= tir_table
[i
].explain (abfd
, ptr
);
1778 if (tir_table
[i
].mincod
< 0)
1780 (*_bfd_error_handler
) (_("Obj code %d not found"), *ptr
);
1789 /* handle command from ETIR section */
1792 etir_cmd (abfd
, cmd
, ptr
)
1800 boolean (*explain
) PARAMS((bfd
*, int, unsigned char *));
1802 { ETIR_S_C_MINSTACOD
, ETIR_S_C_MAXSTACOD
, etir_sta
},
1803 { ETIR_S_C_MINSTOCOD
, ETIR_S_C_MAXSTOCOD
, etir_sto
},
1804 { ETIR_S_C_MINOPRCOD
, ETIR_S_C_MAXOPRCOD
, etir_opr
},
1805 { ETIR_S_C_MINCTLCOD
, ETIR_S_C_MAXCTLCOD
, etir_ctl
},
1806 { ETIR_S_C_MINSTCCOD
, ETIR_S_C_MAXSTCCOD
, etir_stc
},
1813 _bfd_vms_debug (4, "etir_cmd %d/%x\n", cmd
, cmd
);
1814 _bfd_hexdump (8, ptr
, 16, (int)ptr
);
1817 while (etir_table
[i
].mincod
>= 0)
1819 if ( (etir_table
[i
].mincod
<= cmd
)
1820 && (cmd
<= etir_table
[i
].maxcod
))
1822 if (!etir_table
[i
].explain (abfd
, cmd
, ptr
))
1830 _bfd_vms_debug (4, "etir_cmd: = 0\n");
1836 /* Text Information and Relocation Records (OBJ$C_TIR)
1837 handle tir record */
1840 analyze_tir (abfd
, ptr
, length
)
1843 unsigned int length
;
1845 unsigned char *maxptr
;
1848 _bfd_vms_debug (3, "analyze_tir: %d bytes\n", length
);
1851 maxptr
= ptr
+ length
;
1853 while (ptr
< maxptr
)
1855 ptr
= tir_cmd (abfd
, ptr
);
1864 /* Text Information and Relocation Records (EOBJ$C_ETIR)
1865 handle etir record */
1868 analyze_etir (abfd
, ptr
, length
)
1871 unsigned int length
;
1874 unsigned char *maxptr
;
1878 _bfd_vms_debug (3, "analyze_etir: %d bytes\n", length
);
1881 maxptr
= ptr
+ length
;
1883 while (ptr
< maxptr
)
1885 cmd
= bfd_getl16 (ptr
);
1886 length
= bfd_getl16 (ptr
+ 2);
1887 result
= etir_cmd (abfd
, cmd
, ptr
+4);
1894 _bfd_vms_debug (3, "analyze_etir: = %d\n", result
);
1901 /* process ETIR record
1903 return 0 on success, -1 on error */
1906 _bfd_vms_slurp_tir (abfd
, objtype
)
1913 _bfd_vms_debug (2, "TIR/ETIR\n");
1919 PRIV(vms_rec
) += 4; /* skip type, size */
1920 PRIV(rec_size
) -= 4;
1921 result
= analyze_etir (abfd
, PRIV(vms_rec
), PRIV(rec_size
));
1924 PRIV(vms_rec
) += 1; /* skip type */
1925 PRIV(rec_size
) -= 1;
1926 result
= analyze_tir (abfd
, PRIV(vms_rec
), PRIV(rec_size
));
1937 /* process EDBG record
1938 return 0 on success, -1 on error
1940 not implemented yet */
1943 _bfd_vms_slurp_dbg (abfd
, objtype
)
1948 _bfd_vms_debug (2, "DBG/EDBG\n");
1951 abfd
->flags
|= (HAS_DEBUG
| HAS_LINENO
);
1956 /* process ETBT record
1957 return 0 on success, -1 on error
1959 not implemented yet */
1962 _bfd_vms_slurp_tbt (abfd
, objtype
)
1967 _bfd_vms_debug (2, "TBT/ETBT\n");
1974 /* process LNK record
1975 return 0 on success, -1 on error
1977 not implemented yet */
1980 _bfd_vms_slurp_lnk (abfd
, objtype
)
1985 _bfd_vms_debug (2, "LNK\n");
1991 /*----------------------------------------------------------------------*/
1993 /* WRITE ETIR SECTION */
1995 /* this is still under construction and therefore not documented */
1997 /*----------------------------------------------------------------------*/
1999 static void start_etir_record
PARAMS ((bfd
*abfd
, int index
, uquad offset
, boolean justoffset
));
2000 static void sto_imm
PARAMS ((bfd
*abfd
, vms_section
*sptr
, bfd_vma vaddr
, int index
));
2001 static void end_etir_record
PARAMS ((bfd
*abfd
));
2004 sto_imm (abfd
, sptr
, vaddr
, index
)
2012 unsigned char *cptr
;
2015 _bfd_vms_debug (8, "sto_imm %d bytes\n", sptr
->size
);
2016 _bfd_hexdump (9, sptr
->contents
, (int)sptr
->size
, (int)vaddr
);
2020 cptr
= sptr
->contents
;
2025 size
= ssize
; /* try all the rest */
2027 if (_bfd_vms_output_check (abfd
, size
) < 0)
2028 { /* doesn't fit, split ! */
2029 end_etir_record (abfd
);
2030 start_etir_record (abfd
, index
, vaddr
, false);
2031 size
= _bfd_vms_output_check (abfd
, 0); /* get max size */
2032 if (size
> ssize
) /* more than what's left ? */
2036 _bfd_vms_output_begin (abfd
, ETIR_S_C_STO_IMM
, -1);
2037 _bfd_vms_output_long (abfd
, (unsigned long)(size
));
2038 _bfd_vms_output_dump (abfd
, cptr
, size
);
2039 _bfd_vms_output_flush (abfd
);
2042 _bfd_vms_debug (10, "dumped %d bytes\n", size
);
2043 _bfd_hexdump (10, cptr
, (int)size
, (int)vaddr
);
2054 /*-------------------------------------------------------------------*/
2056 /* start ETIR record for section #index at virtual addr offset. */
2059 start_etir_record (abfd
, index
, offset
, justoffset
)
2067 _bfd_vms_output_begin (abfd
, EOBJ_S_C_ETIR
, -1); /* one ETIR per section */
2068 _bfd_vms_output_push (abfd
);
2071 _bfd_vms_output_begin (abfd
, ETIR_S_C_STA_PQ
, -1); /* push start offset */
2072 _bfd_vms_output_long (abfd
, (unsigned long)index
);
2073 _bfd_vms_output_quad (abfd
, (uquad
)offset
);
2074 _bfd_vms_output_flush (abfd
);
2076 _bfd_vms_output_begin (abfd
, ETIR_S_C_CTL_SETRB
, -1); /* start = pop () */
2077 _bfd_vms_output_flush (abfd
);
2083 /* end etir record */
2085 end_etir_record (abfd
)
2088 _bfd_vms_output_pop (abfd
);
2089 _bfd_vms_output_end (abfd
);
2092 /* write section contents for bfd abfd */
2095 _bfd_vms_write_tir (abfd
, objtype
)
2104 _bfd_vms_debug (2, "vms_write_tir (%p, %d)\n", abfd
, objtype
);
2107 _bfd_vms_output_alignment (abfd
, 4);
2110 PRIV(vms_linkage_index
) = 1;
2112 /* dump all other sections */
2114 section
= abfd
->sections
;
2116 while (section
!= NULL
)
2120 _bfd_vms_debug (4, "writing %d. section '%s' (%d bytes)\n", section
->index
, section
->name
, (int)(section
->_raw_size
));
2123 if (section
->flags
& SEC_RELOC
)
2127 if ((i
= section
->reloc_count
) <= 0)
2129 (*_bfd_error_handler
) (_("SEC_RELOC with no relocs in section %s"),
2136 _bfd_vms_debug (4, "%d relocations:\n", i
);
2137 rptr
= section
->orelocation
;
2140 _bfd_vms_debug (4, "sym %s in sec %s, value %08lx, addr %08lx, off %08lx, len %d: %s\n",
2141 (*(*rptr
)->sym_ptr_ptr
)->name
,
2142 (*(*rptr
)->sym_ptr_ptr
)->section
->name
,
2143 (long)(*(*rptr
)->sym_ptr_ptr
)->value
,
2144 (*rptr
)->address
, (*rptr
)->addend
,
2145 bfd_get_reloc_size((*rptr
)->howto
),
2146 (*rptr
)->howto
->name
);
2153 if ((section
->flags
& SEC_HAS_CONTENTS
)
2154 && (! bfd_is_com_section (section
)))
2156 bfd_vma vaddr
; /* virtual addr in section */
2158 sptr
= _bfd_get_vms_section (abfd
, section
->index
);
2161 bfd_set_error (bfd_error_no_contents
);
2165 vaddr
= (bfd_vma
)(sptr
->offset
);
2167 start_etir_record (abfd
, section
->index
, (uquad
) sptr
->offset
,
2170 while (sptr
!= NULL
) /* one STA_PQ, CTL_SETRB per vms_section */
2173 if (section
->flags
& SEC_RELOC
) /* check for relocs */
2175 arelent
**rptr
= section
->orelocation
;
2176 int i
= section
->reloc_count
;
2179 bfd_size_type addr
= (*rptr
)->address
;
2180 int len
= bfd_get_reloc_size ((*rptr
)->howto
);
2181 if (sptr
->offset
< addr
) /* sptr starts before reloc */
2183 int before
= addr
- sptr
->offset
;
2184 if (sptr
->size
<= before
) /* complete before */
2186 sto_imm (abfd
, sptr
, vaddr
, section
->index
);
2187 vaddr
+= sptr
->size
;
2190 else /* partly before */
2192 int after
= sptr
->size
- before
;
2193 sptr
->size
= before
;
2194 sto_imm (abfd
, sptr
, vaddr
, section
->index
);
2195 vaddr
+= sptr
->size
;
2196 sptr
->contents
+= before
;
2197 sptr
->offset
+= before
;
2201 else if (sptr
->offset
== addr
) /* sptr starts at reloc */
2203 asymbol
*sym
= *(*rptr
)->sym_ptr_ptr
;
2204 asection
*sec
= sym
->section
;
2206 switch ((*rptr
)->howto
->type
)
2208 case ALPHA_R_IGNORE
:
2211 case ALPHA_R_REFLONG
:
2213 if (bfd_is_und_section (sym
->section
))
2215 if (_bfd_vms_output_check (abfd
,
2216 strlen((char *)sym
->name
))
2219 end_etir_record (abfd
);
2220 start_etir_record (abfd
,
2224 _bfd_vms_output_begin (abfd
,
2225 ETIR_S_C_STO_GBL_LW
,
2227 _bfd_vms_output_counted (abfd
,
2228 _bfd_vms_length_hash_symbol (abfd
, sym
->name
, EOBJ_S_C_SYMSIZ
));
2229 _bfd_vms_output_flush (abfd
);
2231 else if (bfd_is_abs_section (sym
->section
))
2233 if (_bfd_vms_output_check (abfd
, 16) < 0)
2235 end_etir_record (abfd
);
2236 start_etir_record (abfd
,
2240 _bfd_vms_output_begin (abfd
,
2243 _bfd_vms_output_quad (abfd
,
2245 _bfd_vms_output_flush (abfd
);
2246 _bfd_vms_output_begin (abfd
,
2249 _bfd_vms_output_flush (abfd
);
2253 if (_bfd_vms_output_check (abfd
, 32) < 0)
2255 end_etir_record (abfd
);
2256 start_etir_record (abfd
,
2260 _bfd_vms_output_begin (abfd
,
2263 _bfd_vms_output_long (abfd
,
2264 (unsigned long)(sec
->index
));
2265 _bfd_vms_output_quad (abfd
,
2266 ((uquad
)(*rptr
)->addend
2267 + (uquad
)sym
->value
));
2268 _bfd_vms_output_flush (abfd
);
2269 _bfd_vms_output_begin (abfd
,
2272 _bfd_vms_output_flush (abfd
);
2277 case ALPHA_R_REFQUAD
:
2279 if (bfd_is_und_section (sym
->section
))
2281 if (_bfd_vms_output_check (abfd
,
2282 strlen((char *)sym
->name
))
2285 end_etir_record (abfd
);
2286 start_etir_record (abfd
,
2290 _bfd_vms_output_begin (abfd
,
2293 _bfd_vms_output_counted (abfd
,
2294 _bfd_vms_length_hash_symbol (abfd
, sym
->name
, EOBJ_S_C_SYMSIZ
));
2295 _bfd_vms_output_flush (abfd
);
2297 else if (bfd_is_abs_section (sym
->section
))
2299 if (_bfd_vms_output_check (abfd
, 16) < 0)
2301 end_etir_record (abfd
);
2302 start_etir_record (abfd
,
2306 _bfd_vms_output_begin (abfd
,
2309 _bfd_vms_output_quad (abfd
,
2311 _bfd_vms_output_flush (abfd
);
2312 _bfd_vms_output_begin (abfd
,
2315 _bfd_vms_output_flush (abfd
);
2319 if (_bfd_vms_output_check (abfd
, 32) < 0)
2321 end_etir_record (abfd
);
2322 start_etir_record (abfd
,
2326 _bfd_vms_output_begin (abfd
,
2329 _bfd_vms_output_long (abfd
,
2330 (unsigned long)(sec
->index
));
2331 _bfd_vms_output_quad (abfd
,
2332 ((uquad
)(*rptr
)->addend
2333 + (uquad
)sym
->value
));
2334 _bfd_vms_output_flush (abfd
);
2335 _bfd_vms_output_begin (abfd
,
2338 _bfd_vms_output_flush (abfd
);
2347 hint_size
= sptr
->size
;
2349 sto_imm (abfd
, sptr
, vaddr
, section
->index
);
2350 sptr
->size
= hint_size
;
2352 vms_output_begin(abfd
, ETIR_S_C_STO_HINT_GBL
, -1);
2353 vms_output_long(abfd
, (unsigned long)(sec
->index
));
2354 vms_output_quad(abfd
, (uquad
)addr
);
2356 vms_output_counted(abfd
, _bfd_vms_length_hash_symbol (abfd
, sym
->name
, EOBJ_S_C_SYMSIZ
));
2357 vms_output_flush(abfd
);
2361 case ALPHA_R_LINKAGE
:
2363 if (_bfd_vms_output_check (abfd
, 64) < 0)
2365 end_etir_record (abfd
);
2366 start_etir_record (abfd
, section
->index
,
2369 _bfd_vms_output_begin (abfd
,
2370 ETIR_S_C_STC_LP_PSB
,
2372 _bfd_vms_output_long (abfd
,
2373 (unsigned long)PRIV(vms_linkage_index
));
2374 PRIV(vms_linkage_index
) += 2;
2375 _bfd_vms_output_counted (abfd
,
2376 _bfd_vms_length_hash_symbol (abfd
, sym
->name
, EOBJ_S_C_SYMSIZ
));
2377 _bfd_vms_output_byte (abfd
, 0);
2378 _bfd_vms_output_flush (abfd
);
2382 case ALPHA_R_CODEADDR
:
2384 if (_bfd_vms_output_check (abfd
,
2385 strlen((char *)sym
->name
))
2388 end_etir_record (abfd
);
2389 start_etir_record (abfd
,
2393 _bfd_vms_output_begin (abfd
,
2396 _bfd_vms_output_counted (abfd
,
2397 _bfd_vms_length_hash_symbol (abfd
, sym
->name
, EOBJ_S_C_SYMSIZ
));
2398 _bfd_vms_output_flush (abfd
);
2403 (*_bfd_error_handler
) (_("Unhandled relocation %s"),
2404 (*rptr
)->howto
->name
);
2410 if (len
== sptr
->size
)
2416 sptr
->contents
+= len
;
2417 sptr
->offset
+= len
;
2423 else /* sptr starts after reloc */
2425 i
--; /* check next reloc */
2429 if (i
==0) /* all reloc checked */
2433 sto_imm (abfd
, sptr
, vaddr
, section
->index
); /* dump rest */
2434 vaddr
+= sptr
->size
;
2439 } /* if SEC_RELOC */
2440 else /* no relocs, just dump */
2442 sto_imm (abfd
, sptr
, vaddr
, section
->index
);
2443 vaddr
+= sptr
->size
;
2448 } /* while (sptr != 0) */
2450 end_etir_record (abfd
);
2452 } /* has_contents */
2454 section
= section
->next
;
2457 _bfd_vms_output_alignment(abfd
, 2);
2462 /* write traceback data for bfd abfd */
2465 _bfd_vms_write_tbt (abfd
, objtype
)
2470 _bfd_vms_debug (2, "vms_write_tbt (%p, %d)\n", abfd
, objtype
);
2477 /* write debug info for bfd abfd */
2480 _bfd_vms_write_dbg (abfd
, objtype
)
2485 _bfd_vms_debug (2, "vms_write_dbg (%p, objtype)\n", abfd
, objtype
);
This page took 0.07911 seconds and 4 git commands to generate.