1 /* evax-etir.c -- BFD back-end for ALPHA EVAX (openVMS/Alpha) files.
2 Copyright 1996, 1997, 1998 Free Software Foundation, Inc.
3 ETIR record handling functions
5 go and read the openVMS linker manual (esp. appendix B)
6 if you don't know what's going on here :-)
8 Written by Klaus K"ampf (kkaempf@progis.de)
9 of proGIS Softwareentwicklung, Aachen, Germany
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
26 /* The following type abbreviations are used:
28 cs counted string (ascii string with length byte)
30 sh short (2 byte, 16 bit)
31 lw longword (4 byte, 32 bit)
32 qw quadword (8 byte, 64 bit)
45 static void location_save
46 PARAMS ((bfd
*abfd
, unsigned long index
, unsigned long loc
, int section
));
47 static unsigned long location_restore
48 PARAMS ((bfd
*abfd
, unsigned long index
, int *section
));
51 static void image_set_ptr
PARAMS ((bfd
*abfd
, int psect
, uquad offset
));
52 static void image_inc_ptr
PARAMS ((bfd
*abfd
, uquad offset
));
53 static void image_dump
PARAMS ((bfd
*abfd
, unsigned char *ptr
, int size
, int offset
));
54 static void image_write_b
PARAMS ((bfd
*abfd
, unsigned int value
));
55 static void image_write_w
PARAMS ((bfd
*abfd
, unsigned int value
));
56 static void image_write_l
PARAMS ((bfd
*abfd
, unsigned long value
));
57 static void image_write_q
PARAMS ((bfd
*abfd
, uquad value
));
59 /*-----------------------------------------------------------------------------*/
63 /* Save location counter at index */
66 location_save (abfd
, index
, loc
, section
)
72 PRIV(location_stack
)[index
].value
= loc
;
73 PRIV(location_stack
)[index
].psect
= section
;
78 /* Restore location counter from index */
81 location_restore (abfd
, index
, section
)
87 *section
= PRIV(location_stack
)[index
].psect
;
88 return PRIV(location_stack
)[index
].value
;
93 /* routines to fill sections contents during etir read */
95 /* Initialize image buffer pointer to be filled */
98 image_set_ptr (abfd
, psect
, offset
)
104 evax_debug (4, "image_set_ptr(%d=%s, %d)\n",
105 psect
, PRIV(sections
)[psect
]->name
, offset
);
108 PRIV(image_ptr
) = PRIV(sections
)[psect
]->contents
+ offset
;
113 /* Increment image buffer pointer by offset */
116 image_inc_ptr (abfd
, offset
)
121 evax_debug (4, "image_inc_ptr(%d)\n", offset
);
124 PRIV(image_ptr
) += offset
;
130 /* Dump multiple bytes to section image */
133 image_dump (abfd
, ptr
, size
, offset
)
140 evax_debug (6, "image_dump from (%p, %d) to (%p)\n", ptr
, size
, PRIV(image_ptr
));
141 _bfd_hexdump (7, ptr
, size
, offset
);
145 *PRIV(image_ptr
)++ = *ptr
++;
150 /* Write byte to section image */
153 image_write_b (abfd
, value
)
158 evax_debug (6, "image_write_b(%02x)\n", (int)value
);
161 *PRIV(image_ptr
)++ = (value
& 0xff);
166 /* Write 2-byte word to image */
169 image_write_w (abfd
, value
)
174 evax_debug (6, "image_write_w(%04x)\n", (int)value
);
177 bfd_putl16 (value
, PRIV(image_ptr
));
178 PRIV(image_ptr
) += 2;
184 /* Write 4-byte long to image */
187 image_write_l (abfd
, value
)
192 evax_debug (6, "image_write_l(%08lx)\n", value
);
195 bfd_putl32 (value
, PRIV(image_ptr
));
196 PRIV(image_ptr
) += 4;
202 /* Write 4-byte long to image */
205 image_write_q (abfd
, value
)
210 evax_debug (6, "image_write_q(%016lx)\n", value
);
213 bfd_putl64 (value
, PRIV(image_ptr
));
214 PRIV(image_ptr
) += 8;
220 #define HIGHBIT(op) ((op & 0x80000000L) == 0x80000000L)
226 handle sta_xxx commands in etir section
227 ptr points to data area in record
229 see table B-8 of the openVMS linker manual */
232 etir_sta (abfd
, cmd
, ptr
)
245 stack 32 bit value of symbol (high bits set to 0) */
247 case ETIR_S_C_STA_GBL
:
250 evax_symbol_entry
*entry
;
252 name
= _bfd_evax_save_counted_string ((char *)ptr
);
253 entry
= (evax_symbol_entry
*)
254 bfd_hash_lookup (PRIV(evax_symbol_table
), name
, false, false);
255 if (entry
== (evax_symbol_entry
*)NULL
)
258 evax_debug (3, "ETIR_S_C_STA_GBL: no symbol \"%s\"\n", name
);
264 _bfd_evax_push (abfd
, (uquad
)(entry
->symbol
->value
), -1);
272 stack 32 bit value, sign extend to 64 bit */
274 case ETIR_S_C_STA_LW
:
275 _bfd_evax_push (abfd
, (uquad
)bfd_getl32 (ptr
), -1);
281 stack 64 bit value of symbol */
283 case ETIR_S_C_STA_QW
:
284 _bfd_evax_push (abfd
, (uquad
)bfd_getl64(ptr
), -1);
287 /* stack psect base plus quadword offset
288 arg: lw section index
289 qw signed quadword offset (low 32 bits)
291 stack qw argument and section index
292 (see ETIR_S_C_STO_OFF, ETIR_S_C_CTL_SETRB) */
294 case ETIR_S_C_STA_PQ
:
299 psect
= bfd_getl32 (ptr
);
300 if (psect
>= PRIV(egsd_sec_count
))
302 (*_bfd_error_handler
) (_("Bad section index in ETIR_S_C_STA_PQ"));
303 bfd_set_error (bfd_error_bad_value
);
306 dummy
= bfd_getl64 (ptr
+4);
307 _bfd_evax_push (abfd
, dummy
, psect
);
311 /* all not supported */
313 case ETIR_S_C_STA_LI
:
314 case ETIR_S_C_STA_MOD
:
315 case ETIR_S_C_STA_CKARG
:
317 (*_bfd_error_handler
) (_("Unsupported STA cmd %d"), cmd
);
322 (*_bfd_error_handler
) (_("Reserved STA cmd %d"), cmd
);
335 handle sto_xxx commands in etir section
336 ptr points to data area in record
338 see table B-9 of the openVMS linker manual */
341 etir_sto (abfd
, cmd
, ptr
)
352 /* store byte: pop stack, write byte
356 dummy
= _bfd_evax_pop (abfd
, &psect
);
358 if (is_share
) /* FIXME */
359 (*_bfd_error_handler
) ("ETIR_S_C_STO_B: byte fixups not supported");
361 image_write_b (abfd
, dummy
& 0xff); /* FIXME: check top bits */
364 /* store word: pop stack, write word
368 dummy
= _bfd_evax_pop (abfd
, &psect
);
370 if (is_share
) /* FIXME */
371 (*_bfd_error_handler
) ("ETIR_S_C_STO_B: word fixups not supported");
373 image_write_w (abfd
, dummy
& 0xffff); /* FIXME: check top bits */
376 /* store longword: pop stack, write longword
379 case ETIR_S_C_STO_LW
:
380 dummy
= _bfd_evax_pop (abfd
, &psect
);
381 dummy
+= (PRIV(sections
)[psect
])->vma
;
382 image_write_l (abfd
, dummy
& 0xffffffff);/* FIXME: check top bits */
385 evax_debug (3, "ETIR_S_C_STO_LW: Relocation !\n");
387 evax_debug (3, "ETIR_S_C_STO_LW: Fix-up share !\n");
391 /* store quadword: pop stack, write quadword
394 case ETIR_S_C_STO_QW
:
395 dummy
= _bfd_evax_pop (abfd
, &psect
);
396 dummy
+= (PRIV(sections
)[psect
])->vma
;
397 image_write_q(abfd
, dummy
); /* FIXME: check top bits */
400 evax_debug (3, "ETIR_S_C_STO_LW: Relocation !\n");
402 evax_debug (3, "ETIR_S_C_STO_LW: Fix-up share !\n");
406 /* store immediate repeated: pop stack for repeat count
410 case ETIR_S_C_STO_IMMR
:
414 size
= bfd_getl32 (ptr
);
415 dummy
= (unsigned long)_bfd_evax_pop (abfd
, NULL
);
417 image_dump (abfd
, ptr
+4, size
, 0);
421 /* store global: write symbol value
422 arg: cs global symbol name */
424 case ETIR_S_C_STO_GBL
:
426 evax_symbol_entry
*entry
;
429 name
= _bfd_evax_save_counted_string ((char *)ptr
);
430 entry
= (evax_symbol_entry
*)bfd_hash_lookup (PRIV(evax_symbol_table
), name
, false, false);
431 if (entry
== (evax_symbol_entry
*)NULL
)
433 (*_bfd_error_handler
) (_("ETIR_S_C_STO_GBL: no symbol \"%s\""),
438 image_write_q (abfd
, (uquad
)(entry
->symbol
->value
)); /* FIXME, reloc */
442 /* store code address: write address of entry point
443 arg: cs global symbol name (procedure) */
445 case ETIR_S_C_STO_CA
:
447 evax_symbol_entry
*entry
;
450 name
= _bfd_evax_save_counted_string ((char *)ptr
);
451 entry
= (evax_symbol_entry
*) bfd_hash_lookup (PRIV(evax_symbol_table
), name
, false, false);
452 if (entry
== (evax_symbol_entry
*)NULL
)
454 (*_bfd_error_handler
) (_("ETIR_S_C_STO_CA: no symbol \"%s\""),
459 image_write_q (abfd
, (uquad
)(entry
->symbol
->value
)); /* FIXME, reloc */
465 case ETIR_S_C_STO_RB
:
466 case ETIR_S_C_STO_AB
:
467 (*_bfd_error_handler
) (_("ETIR_S_C_STO_RB/AB: Not supported"));
470 /* store offset to psect: pop stack, add low 32 bits to base of psect
473 case ETIR_S_C_STO_OFF
:
478 q
= _bfd_evax_pop (abfd
, &psect
);
479 q
+= (PRIV(sections
)[psect
])->vma
;
480 image_write_q (abfd
, q
);
485 arg: lw count of bytes
488 case ETIR_S_C_STO_IMM
:
492 size
= bfd_getl32 (ptr
);
493 image_dump (abfd
, ptr
+4, size
, 0);
497 /* this code is 'reserved to digital' according to the openVMS linker manual,
498 however it is generated by the DEC C compiler and defined in the include file.
499 FIXME, since the following is just a guess
500 store global longword: store 32bit value of symbol
501 arg: cs symbol name */
503 case ETIR_S_C_STO_GBL_LW
:
505 evax_symbol_entry
*entry
;
508 name
= _bfd_evax_save_counted_string ((char *)ptr
);
509 entry
= (evax_symbol_entry
*)bfd_hash_lookup (PRIV(evax_symbol_table
), name
, false, false);
510 if (entry
== (evax_symbol_entry
*)NULL
)
513 evax_debug (3, "ETIR_S_C_STO_GBL_LW: no symbol \"%s\"\n", name
);
518 image_write_l (abfd
, (unsigned long)(entry
->symbol
->value
)); /* FIXME, reloc */
524 case ETIR_S_C_STO_LP_PSB
:
525 (*_bfd_error_handler
) (_("ETIR_S_C_STO_LP_PSB: Not supported"));
530 case ETIR_S_C_STO_HINT_GBL
:
531 (*_bfd_error_handler
) (_("ETIR_S_C_STO_HINT_GBL: not implemented"));
536 case ETIR_S_C_STO_HINT_PS
:
537 (*_bfd_error_handler
) (_("ETIR_S_C_STO_HINT_PS: not implemented"));
541 (*_bfd_error_handler
) (_("Reserved STO cmd %d"), cmd
);
548 /* stack operator commands
549 all 32 bit signed arithmetic
550 all word just like a stack calculator
551 arguments are popped from stack, results are pushed on stack
553 see table B-10 of the openVMS linker manual */
556 etir_opr (abfd
, cmd
, ptr
)
569 case ETIR_S_C_OPR_NOP
:
574 case ETIR_S_C_OPR_ADD
:
575 op1
= (long)_bfd_evax_pop (abfd
, NULL
);
576 op2
= (long)_bfd_evax_pop (abfd
, NULL
);
577 _bfd_evax_push (abfd
, (uquad
)(op1
+ op2
), -1);
582 case ETIR_S_C_OPR_SUB
:
583 op1
= (long)_bfd_evax_pop (abfd
, NULL
);
584 op2
= (long)_bfd_evax_pop (abfd
, NULL
);
585 _bfd_evax_push (abfd
, (uquad
)(op2
- op1
), -1);
590 case ETIR_S_C_OPR_MUL
:
591 op1
= (long)_bfd_evax_pop (abfd
, NULL
);
592 op2
= (long)_bfd_evax_pop (abfd
, NULL
);
593 _bfd_evax_push (abfd
, (uquad
)(op1
* op2
), -1);
598 case ETIR_S_C_OPR_DIV
:
599 op1
= (long)_bfd_evax_pop (abfd
, NULL
);
600 op2
= (long)_bfd_evax_pop (abfd
, NULL
);
602 _bfd_evax_push (abfd
, (uquad
)0L, -1);
604 _bfd_evax_push (abfd
, (uquad
)(op2
/ op1
), -1);
609 case ETIR_S_C_OPR_AND
:
610 op1
= (long)_bfd_evax_pop (abfd
, NULL
);
611 op2
= (long)_bfd_evax_pop (abfd
, NULL
);
612 _bfd_evax_push (abfd
, (uquad
)(op1
& op2
), -1);
615 /* logical inclusive or */
617 case ETIR_S_C_OPR_IOR
:
618 op1
= (long)_bfd_evax_pop (abfd
, NULL
);
619 op2
= (long)_bfd_evax_pop (abfd
, NULL
);
620 _bfd_evax_push (abfd
, (uquad
)(op1
| op2
), -1);
623 /* logical exclusive or */
625 case ETIR_S_C_OPR_EOR
:
626 op1
= (long)_bfd_evax_pop (abfd
, NULL
);
627 op2
= (long)_bfd_evax_pop (abfd
, NULL
);
628 _bfd_evax_push (abfd
, (uquad
)(op1
^ op2
), -1);
633 case ETIR_S_C_OPR_NEG
:
634 op1
= (long)_bfd_evax_pop (abfd
, NULL
);
635 _bfd_evax_push (abfd
, (uquad
)(-op1
), -1);
640 case ETIR_S_C_OPR_COM
:
641 op1
= (long)_bfd_evax_pop (abfd
, NULL
);
642 _bfd_evax_push (abfd
, (uquad
)(op1
^ -1L), -1);
647 case ETIR_S_C_OPR_INSV
:
648 (void)_bfd_evax_pop (abfd
, NULL
);
649 (*_bfd_error_handler
) (_("ETIR_S_C_OPR_INSV: Not supported"));
652 /* arithmetic shift */
654 case ETIR_S_C_OPR_ASH
:
655 op1
= (long)_bfd_evax_pop (abfd
, NULL
);
656 op2
= (long)_bfd_evax_pop (abfd
, NULL
);
657 if (op2
< 0) /* shift right */
659 else /* shift left */
661 _bfd_evax_push (abfd
, (uquad
)op1
, -1);
666 case ETIR_S_C_OPR_USH
:
667 (*_bfd_error_handler
) (_("ETIR_S_C_OPR_USH: Not supported"));
672 case ETIR_S_C_OPR_ROT
:
673 (*_bfd_error_handler
) (_("ETIR_S_C_OPR_ROT: Not supported"));
678 case ETIR_S_C_OPR_SEL
:
679 if ((long)_bfd_evax_pop (abfd
, NULL
) & 0x01L
)
680 (void)_bfd_evax_pop (abfd
, NULL
);
683 op1
= (long)_bfd_evax_pop (abfd
, NULL
);
684 (void)_bfd_evax_pop (abfd
, NULL
);
685 _bfd_evax_push (abfd
, (uquad
)op1
, -1);
689 /* redefine symbol to current location */
691 case ETIR_S_C_OPR_REDEF
:
692 (*_bfd_error_handler
) (_("ETIR_S_C_OPR_REDEF: Not supported"));
695 /* define a literal */
697 case ETIR_S_C_OPR_DFLIT
:
698 (*_bfd_error_handler
) (_("ETIR_S_C_OPR_DFLIT: Not supported"));
702 (*_bfd_error_handler
) (_("Reserved OPR cmd %d"), cmd
);
712 see table B-11 of the openVMS linker manual */
715 etir_ctl (abfd
, cmd
, ptr
)
725 /* set relocation base: pop stack, set image location counter
728 case ETIR_S_C_CTL_SETRB
:
729 dummy
= _bfd_evax_pop (abfd
, &psect
);
730 image_set_ptr (abfd
, psect
, dummy
);
733 /* augment relocation base: increment image location counter by offset
734 arg: lw offset value */
736 case ETIR_S_C_CTL_AUGRB
:
737 dummy
= bfd_getl32 (ptr
);
738 image_inc_ptr (abfd
, dummy
);
741 /* define location: pop index, save location counter under index
744 case ETIR_S_C_CTL_DFLOC
:
745 dummy
= _bfd_evax_pop (abfd
, NULL
);
749 /* set location: pop index, restore location counter from index
752 case ETIR_S_C_CTL_STLOC
:
753 dummy
= _bfd_evax_pop (abfd
, &psect
);
757 /* stack defined location: pop index, push location counter from index
760 case ETIR_S_C_CTL_STKDL
:
761 dummy
= _bfd_evax_pop (abfd
, &psect
);
766 (*_bfd_error_handler
) (_("Reserved CTL cmd %d"), cmd
);
773 /* store conditional commands
775 see table B-12 and B-13 of the openVMS linker manual */
778 etir_stc (abfd
, cmd
, ptr
)
786 /* 200 Store-conditional Linkage Pair
789 case ETIR_S_C_STC_LP
:
790 (*_bfd_error_handler
) (_("ETIR_S_C_STC_LP: not supported"));
793 /* 201 Store-conditional Linkage Pair with Procedure Signature
794 arg: lw linkage index
799 case ETIR_S_C_STC_LP_PSB
:
800 image_inc_ptr (abfd
, 16); /* skip entry,procval */
803 /* 202 Store-conditional Address at global address
804 arg: lw linkage index
807 case ETIR_S_C_STC_GBL
:
808 (*_bfd_error_handler
) (_("ETIR_S_C_STC_GBL: not supported"));
811 /* 203 Store-conditional Code Address at global address
812 arg: lw linkage index
815 case ETIR_S_C_STC_GCA
:
816 (*_bfd_error_handler
) (_("ETIR_S_C_STC_GCA: not supported"));
819 /* 204 Store-conditional Address at psect + offset
820 arg: lw linkage index
824 case ETIR_S_C_STC_PS
:
825 (*_bfd_error_handler
) (_("ETIR_S_C_STC_PS: not supported"));
828 /* 205 Store-conditional NOP at address of global
831 case ETIR_S_C_STC_NOP_GBL
:
833 /* 206 Store-conditional NOP at pect + offset
836 case ETIR_S_C_STC_NOP_PS
:
838 /* 207 Store-conditional BSR at global address
841 case ETIR_S_C_STC_BSR_GBL
:
843 /* 208 Store-conditional BSR at pect + offset
846 case ETIR_S_C_STC_BSR_PS
:
848 /* 209 Store-conditional LDA at global address
851 case ETIR_S_C_STC_LDA_GBL
:
853 /* 210 Store-conditional LDA at psect + offset
856 case ETIR_S_C_STC_LDA_PS
:
858 /* 211 Store-conditional BSR or Hint at global address
861 case ETIR_S_C_STC_BOH_GBL
:
863 /* 212 Store-conditional BSR or Hint at pect + offset
866 case ETIR_S_C_STC_BOH_PS
:
868 /* 213 Store-conditional NOP,BSR or HINT at global address
871 case ETIR_S_C_STC_NBH_GBL
:
873 /* 214 Store-conditional NOP,BSR or HINT at psect + offset
876 case ETIR_S_C_STC_NBH_PS
:
877 /* FIXME (*_bfd_error_handler) ("ETIR_S_C_STC_xx: (%d) not supported", cmd); */
882 evax_debug (3, "Reserved STC cmd %d", cmd
);
890 /* handle command from ETIR section */
893 tir_cmd (abfd
, cmd
, ptr
)
901 boolean (*explain
) PARAMS((bfd
*, int, unsigned char *));
903 { ETIR_S_C_MINSTACOD
, ETIR_S_C_MAXSTACOD
, etir_sta
},
904 { ETIR_S_C_MINSTOCOD
, ETIR_S_C_MAXSTOCOD
, etir_sto
},
905 { ETIR_S_C_MINOPRCOD
, ETIR_S_C_MAXOPRCOD
, etir_opr
},
906 { ETIR_S_C_MINCTLCOD
, ETIR_S_C_MAXCTLCOD
, etir_ctl
},
907 { ETIR_S_C_MINSTCCOD
, ETIR_S_C_MAXSTCCOD
, etir_stc
},
914 while (tir_table
[i
].mincod
>= 0)
916 if ( (tir_table
[i
].mincod
<= cmd
)
917 && (cmd
<= tir_table
[i
].maxcod
))
919 res
= tir_table
[i
].explain (abfd
, cmd
, ptr
);
929 /* Text Information and Relocation Records (OBJ$C_TIR)
930 handle etir record */
933 analyze_etir (abfd
, ptr
, length
)
939 unsigned char *maxptr
;
942 maxptr
= ptr
+ length
;
946 cmd
= bfd_getl16 (ptr
);
947 length
= bfd_getl16 (ptr
+ 2);
948 res
= tir_cmd (abfd
, cmd
, ptr
+4);
957 /* process ETIR record
959 return 0 on success, -1 on error */
962 _bfd_evax_slurp_etir (abfd
)
967 evax_debug (2, "ETIR\n");
970 PRIV(evax_rec
) += 4; /* skip type, size */
972 if (analyze_etir (abfd
, PRIV(evax_rec
), PRIV(rec_size
)))
979 /* process EDBG record
980 return 0 on success, -1 on error
982 not implemented yet */
985 _bfd_evax_slurp_edbg (abfd
)
989 evax_debug (2, "EDBG\n");
992 abfd
->flags
|= (HAS_DEBUG
| HAS_LINENO
);
997 /* process ETBT record
998 return 0 on success, -1 on error
1000 not implemented yet */
1003 _bfd_evax_slurp_etbt (abfd
)
1007 evax_debug (2, "ETBT\n");
1013 /*----------------------------------------------------------------------*/
1015 /* WRITE ETIR SECTION */
1017 /* this is still under construction and therefore not documented */
1019 /*----------------------------------------------------------------------*/
1021 static void start_etir_record
PARAMS ((bfd
*abfd
, int index
, uquad offset
, boolean justoffset
));
1022 static void sto_imm
PARAMS ((bfd
*abfd
, evax_section
*sptr
, bfd_vma vaddr
, int index
));
1023 static void end_etir_record
PARAMS ((bfd
*abfd
));
1026 sto_imm (abfd
, sptr
, vaddr
, index
)
1034 unsigned char *cptr
;
1037 evax_debug (8, "sto_imm %d bytes\n", sptr
->size
);
1038 _bfd_hexdump (9, sptr
->contents
, (int)sptr
->size
, (int)vaddr
);
1042 cptr
= sptr
->contents
;
1047 size
= ssize
; /* try all the rest */
1049 if (_bfd_evax_output_check (abfd
, size
) < 0)
1050 { /* doesn't fit, split ! */
1051 end_etir_record (abfd
);
1052 start_etir_record (abfd
, index
, vaddr
, false);
1053 size
= _bfd_evax_output_check (abfd
, 0); /* get max size */
1054 if (size
> ssize
) /* more than what's left ? */
1058 _bfd_evax_output_begin (abfd
, ETIR_S_C_STO_IMM
, -1);
1059 _bfd_evax_output_long (abfd
, (unsigned long)(size
));
1060 _bfd_evax_output_dump (abfd
, cptr
, size
);
1061 _bfd_evax_output_flush (abfd
);
1064 evax_debug (10, "dumped %d bytes\n", size
);
1065 _bfd_hexdump (10, cptr
, (int)size
, (int)vaddr
);
1076 /*-------------------------------------------------------------------*/
1078 /* start ETIR record for section #index at virtual addr offset. */
1081 start_etir_record (abfd
, index
, offset
, justoffset
)
1089 _bfd_evax_output_begin (abfd
, EOBJ_S_C_ETIR
, -1); /* one ETIR per section */
1090 _bfd_evax_output_push (abfd
);
1093 _bfd_evax_output_begin (abfd
, ETIR_S_C_STA_PQ
, -1); /* push start offset */
1094 _bfd_evax_output_long (abfd
, (unsigned long)index
);
1095 _bfd_evax_output_quad (abfd
, (uquad
)offset
);
1096 _bfd_evax_output_flush (abfd
);
1098 _bfd_evax_output_begin (abfd
, ETIR_S_C_CTL_SETRB
, -1); /* start = pop() */
1099 _bfd_evax_output_flush (abfd
);
1105 /* end etir record */
1107 end_etir_record (abfd
)
1110 _bfd_evax_output_pop (abfd
);
1111 _bfd_evax_output_end (abfd
);
1114 /* write section contents for bfd abfd */
1117 _bfd_evax_write_etir (abfd
)
1125 evax_debug (2, "evax_write_etir(%p)\n", abfd
);
1128 _bfd_evax_output_alignment (abfd
, 4);
1131 PRIV(evax_linkage_index
) = 1;
1133 /* dump all other sections */
1135 section
= abfd
->sections
;
1137 while (section
!= NULL
)
1141 evax_debug (4, "writing %d. section '%s' (%d bytes)\n", section
->index
, section
->name
, (int)(section
->_raw_size
));
1144 if (section
->flags
& SEC_RELOC
)
1148 if ((i
= section
->reloc_count
) <= 0)
1150 (*_bfd_error_handler
) (_("SEC_RELOC with no relocs in section %s"),
1157 evax_debug (4, "%d relocations:\n", i
);
1158 rptr
= section
->orelocation
;
1161 evax_debug (4, "sym %s in sec %s, value %08lx, addr %08lx, off %08lx, len %d: %s\n",
1162 (*(*rptr
)->sym_ptr_ptr
)->name
,
1163 (*(*rptr
)->sym_ptr_ptr
)->section
->name
,
1164 (long)(*(*rptr
)->sym_ptr_ptr
)->value
,
1165 (*rptr
)->address
, (*rptr
)->addend
,
1166 bfd_get_reloc_size((*rptr
)->howto
),
1167 (*rptr
)->howto
->name
);
1174 if ((section
->flags
& SEC_HAS_CONTENTS
)
1175 && (! bfd_is_com_section (section
)))
1177 bfd_vma vaddr
; /* virtual addr in section */
1179 sptr
= _bfd_get_evax_section (abfd
, section
->index
);
1182 bfd_set_error (bfd_error_no_contents
);
1186 vaddr
= (bfd_vma
)(sptr
->offset
);
1188 start_etir_record (abfd
, section
->index
, (uquad
) sptr
->offset
,
1191 while (sptr
!= NULL
) /* one STA_PQ, CTL_SETRB per evax_section */
1194 if (section
->flags
& SEC_RELOC
) /* check for relocs */
1196 arelent
**rptr
= section
->orelocation
;
1197 int i
= section
->reloc_count
;
1200 bfd_size_type addr
= (*rptr
)->address
;
1201 int len
= bfd_get_reloc_size ((*rptr
)->howto
);
1202 if (sptr
->offset
< addr
) /* sptr starts before reloc */
1204 int before
= addr
- sptr
->offset
;
1205 if (sptr
->size
<= before
) /* complete before */
1207 sto_imm (abfd
, sptr
, vaddr
, section
->index
);
1208 vaddr
+= sptr
->size
;
1211 else /* partly before */
1213 int after
= sptr
->size
- before
;
1214 sptr
->size
= before
;
1215 sto_imm (abfd
, sptr
, vaddr
, section
->index
);
1216 vaddr
+= sptr
->size
;
1217 sptr
->contents
+= before
;
1218 sptr
->offset
+= before
;
1222 else if (sptr
->offset
== addr
) /* sptr starts at reloc */
1224 asymbol
*sym
= *(*rptr
)->sym_ptr_ptr
;
1225 asection
*sec
= sym
->section
;
1227 switch ((*rptr
)->howto
->type
)
1229 case ALPHA_R_IGNORE
:
1232 case ALPHA_R_REFLONG
:
1234 if (bfd_is_und_section (sym
->section
))
1236 if (_bfd_evax_output_check (abfd
,
1237 strlen((char *)sym
->name
))
1240 end_etir_record (abfd
);
1241 start_etir_record (abfd
,
1245 _bfd_evax_output_begin (abfd
,
1246 ETIR_S_C_STO_GBL_LW
,
1248 _bfd_evax_output_counted (abfd
,
1249 _bfd_evax_length_hash_symbol (abfd
, sym
->name
, EOBJ_S_C_SYMSIZ
));
1250 _bfd_evax_output_flush (abfd
);
1252 else if (bfd_is_abs_section (sym
->section
))
1254 if (_bfd_evax_output_check (abfd
, 16) < 0)
1256 end_etir_record (abfd
);
1257 start_etir_record (abfd
,
1261 _bfd_evax_output_begin (abfd
,
1264 _bfd_evax_output_quad (abfd
,
1266 _bfd_evax_output_flush (abfd
);
1267 _bfd_evax_output_begin (abfd
,
1270 _bfd_evax_output_flush (abfd
);
1274 if (_bfd_evax_output_check (abfd
, 32) < 0)
1276 end_etir_record (abfd
);
1277 start_etir_record (abfd
,
1281 _bfd_evax_output_begin (abfd
,
1284 _bfd_evax_output_long (abfd
,
1285 (unsigned long)(sec
->index
));
1286 _bfd_evax_output_quad (abfd
,
1287 ((uquad
)(*rptr
)->addend
1288 + (uquad
)sym
->value
));
1289 _bfd_evax_output_flush (abfd
);
1290 _bfd_evax_output_begin (abfd
,
1293 _bfd_evax_output_flush (abfd
);
1298 case ALPHA_R_REFQUAD
:
1300 if (bfd_is_und_section (sym
->section
))
1302 if (_bfd_evax_output_check (abfd
,
1303 strlen((char *)sym
->name
))
1306 end_etir_record (abfd
);
1307 start_etir_record (abfd
,
1311 _bfd_evax_output_begin (abfd
,
1314 _bfd_evax_output_counted (abfd
,
1315 _bfd_evax_length_hash_symbol (abfd
, sym
->name
, EOBJ_S_C_SYMSIZ
));
1316 _bfd_evax_output_flush (abfd
);
1318 else if (bfd_is_abs_section (sym
->section
))
1320 if (_bfd_evax_output_check (abfd
, 16) < 0)
1322 end_etir_record (abfd
);
1323 start_etir_record (abfd
,
1327 _bfd_evax_output_begin (abfd
,
1330 _bfd_evax_output_quad (abfd
,
1332 _bfd_evax_output_flush (abfd
);
1333 _bfd_evax_output_begin (abfd
,
1336 _bfd_evax_output_flush (abfd
);
1340 if (_bfd_evax_output_check (abfd
, 32) < 0)
1342 end_etir_record (abfd
);
1343 start_etir_record (abfd
,
1347 _bfd_evax_output_begin (abfd
,
1350 _bfd_evax_output_long (abfd
,
1351 (unsigned long)(sec
->index
));
1352 _bfd_evax_output_quad (abfd
,
1353 ((uquad
)(*rptr
)->addend
1354 + (uquad
)sym
->value
));
1355 _bfd_evax_output_flush (abfd
);
1356 _bfd_evax_output_begin (abfd
,
1359 _bfd_evax_output_flush (abfd
);
1368 hint_size
= sptr
->size
;
1370 sto_imm (abfd
, sptr
, vaddr
, section
->index
);
1371 sptr
->size
= hint_size
;
1373 evax_output_begin(abfd
, ETIR_S_C_STO_HINT_GBL
, -1);
1374 evax_output_long(abfd
, (unsigned long)(sec
->index
));
1375 evax_output_quad(abfd
, (uquad
)addr
);
1377 evax_output_counted(abfd
, _bfd_evax_length_hash_symbol (abfd
, sym
->name
, EOBJ_S_C_SYMSIZ
));
1378 evax_output_flush(abfd
);
1382 case ALPHA_R_LINKAGE
:
1384 if (_bfd_evax_output_check (abfd
, 64) < 0)
1386 end_etir_record (abfd
);
1387 start_etir_record (abfd
, section
->index
,
1390 _bfd_evax_output_begin (abfd
,
1391 ETIR_S_C_STC_LP_PSB
,
1393 _bfd_evax_output_long (abfd
,
1394 (unsigned long)PRIV(evax_linkage_index
));
1395 PRIV(evax_linkage_index
) += 2;
1396 _bfd_evax_output_counted (abfd
,
1397 _bfd_evax_length_hash_symbol (abfd
, sym
->name
, EOBJ_S_C_SYMSIZ
));
1398 _bfd_evax_output_byte (abfd
, 0);
1399 _bfd_evax_output_flush (abfd
);
1403 case ALPHA_R_CODEADDR
:
1405 if (_bfd_evax_output_check (abfd
,
1406 strlen((char *)sym
->name
))
1409 end_etir_record (abfd
);
1410 start_etir_record (abfd
,
1414 _bfd_evax_output_begin (abfd
,
1417 _bfd_evax_output_counted (abfd
,
1418 _bfd_evax_length_hash_symbol (abfd
, sym
->name
, EOBJ_S_C_SYMSIZ
));
1419 _bfd_evax_output_flush (abfd
);
1424 (*_bfd_error_handler
) (_("Unhandled relocation %s"),
1425 (*rptr
)->howto
->name
);
1431 if (len
== sptr
->size
)
1437 sptr
->contents
+= len
;
1438 sptr
->offset
+= len
;
1444 else /* sptr starts after reloc */
1446 i
--; /* check next reloc */
1450 if (i
==0) /* all reloc checked */
1454 sto_imm (abfd
, sptr
, vaddr
, section
->index
); /* dump rest */
1455 vaddr
+= sptr
->size
;
1460 } /* if SEC_RELOC */
1461 else /* no relocs, just dump */
1463 sto_imm (abfd
, sptr
, vaddr
, section
->index
);
1464 vaddr
+= sptr
->size
;
1469 } /* while (sptr != 0) */
1471 end_etir_record (abfd
);
1473 } /* has_contents */
1475 section
= section
->next
;
1478 _bfd_evax_output_alignment(abfd
, 2);
1483 /* write traceback data for bfd abfd */
1486 _bfd_evax_write_etbt (abfd
)
1490 evax_debug (2, "evax_write_etbt(%p)\n", abfd
);
1497 /* write debug info for bfd abfd */
1500 _bfd_evax_write_edbg (abfd
)
1504 evax_debug (2, "evax_write_edbg(%p)\n", abfd
);
This page took 0.075853 seconds and 4 git commands to generate.