1 /* vms.c -- BFD back-end for EVAX (openVMS/Alpha) files.
2 Copyright (C) 1996-2020 Free Software Foundation, Inc.
4 Initial version written by Klaus Kaempf (kkaempf@rmi.de)
5 Major rewrite by Adacore.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20 MA 02110-1301, USA. */
25 o Generation of shared image
26 o Relocation optimizations
32 o protected sections (for messages)
50 #include "vms/eihvn.h"
51 #include "vms/eobjrec.h"
54 #include "vms/esgps.h"
63 #include "vms/esdfm.h"
64 #include "vms/esdfv.h"
70 #include "vms/internal.h"
73 #define MIN(a,b) ((a) < (b) ? (a) : (b))
75 /* The r_type field in a reloc is one of the following values. */
76 #define ALPHA_R_IGNORE 0
77 #define ALPHA_R_REFQUAD 1
78 #define ALPHA_R_BRADDR 2
79 #define ALPHA_R_HINT 3
80 #define ALPHA_R_SREL16 4
81 #define ALPHA_R_SREL32 5
82 #define ALPHA_R_SREL64 6
83 #define ALPHA_R_OP_PUSH 7
84 #define ALPHA_R_OP_STORE 8
85 #define ALPHA_R_OP_PSUB 9
86 #define ALPHA_R_OP_PRSHIFT 10
87 #define ALPHA_R_LINKAGE 11
88 #define ALPHA_R_REFLONG 12
89 #define ALPHA_R_CODEADDR 13
90 #define ALPHA_R_NOP 14
91 #define ALPHA_R_BSR 15
92 #define ALPHA_R_LDA 16
93 #define ALPHA_R_BOH 17
95 /* These are used with DST_S_C_LINE_NUM. */
96 #define DST_S_C_LINE_NUM_HEADER_SIZE 4
98 /* These are used with DST_S_C_SOURCE */
100 #define DST_S_B_PCLINE_UNSBYTE 1
101 #define DST_S_W_PCLINE_UNSWORD 1
102 #define DST_S_L_PCLINE_UNSLONG 1
104 #define DST_S_B_MODBEG_NAME 14
105 #define DST_S_L_RTNBEG_ADDRESS 5
106 #define DST_S_B_RTNBEG_NAME 13
107 #define DST_S_L_RTNEND_SIZE 5
109 /* These are used with DST_S_C_SOURCE. */
110 #define DST_S_C_SOURCE_HEADER_SIZE 4
112 #define DST_S_B_SRC_DF_LENGTH 1
113 #define DST_S_W_SRC_DF_FILEID 3
114 #define DST_S_B_SRC_DF_FILENAME 20
115 #define DST_S_B_SRC_UNSBYTE 1
116 #define DST_S_W_SRC_UNSWORD 1
117 #define DST_S_L_SRC_UNSLONG 1
119 /* Debugger symbol definitions. */
121 #define DBG_S_L_DMT_MODBEG 0
122 #define DBG_S_L_DST_SIZE 4
123 #define DBG_S_W_DMT_PSECT_COUNT 8
124 #define DBG_S_C_DMT_HEADER_SIZE 12
126 #define DBG_S_L_DMT_PSECT_START 0
127 #define DBG_S_L_DMT_PSECT_LENGTH 4
128 #define DBG_S_C_DMT_PSECT_SIZE 8
130 /* VMS module header. */
146 #define EMH_DATE_LENGTH 17
148 /* VMS End-Of-Module records (EOM/EEOM). */
152 unsigned int eom_l_total_lps
;
153 unsigned short eom_w_comcod
;
154 bfd_boolean eom_has_transfer
;
155 unsigned char eom_b_tfrflg
;
156 unsigned int eom_l_psindx
;
157 unsigned int eom_l_tfradr
;
160 struct vms_symbol_entry
166 unsigned char data_type
;
167 unsigned short flags
;
169 /* Section and offset/value of the symbol. */
173 /* Section and offset/value for the entry point (only for subprg). */
174 asection
*code_section
;
175 unsigned int code_value
;
177 /* Symbol vector offset. */
178 unsigned int symbol_vector
;
180 /* Length of the name. */
181 unsigned char namelen
;
186 /* Stack value for push/pop commands. */
194 #define STACKSIZE 128
196 /* A minimal decoding of DST compilation units. We only decode
197 what's needed to get to the line number information. */
207 struct srecinfo
*next
;
215 struct lineinfo
*next
;
222 struct funcinfo
*next
;
230 /* Chain the previously read compilation unit. */
233 /* The module name. */
236 /* The start offset and size of debug info in the DST section. */
240 /* The lowest and highest addresses contained in this compilation
241 unit as specified in the compilation unit header. */
245 /* The listing line table. */
246 struct lineinfo
*line_table
;
248 /* The source record table. */
249 struct srecinfo
*srec_table
;
251 /* A list of the functions found in this module. */
252 struct funcinfo
*func_table
;
254 /* Current allocation of file_table. */
255 unsigned int file_table_count
;
257 /* An array of the files making up this module. */
258 struct fileinfo
*file_table
;
261 /* BFD private data for alpha-vms. */
263 struct vms_private_data_struct
265 /* If true, relocs have been read. */
266 bfd_boolean reloc_done
;
268 /* Record input buffer. */
269 struct vms_rec_rd recrd
;
270 struct vms_rec_wr recwr
;
272 struct hdr_struct hdr_data
; /* data from HDR/EMH record */
273 struct eom_struct eom_data
; /* data from EOM/EEOM record */
275 /* Transfer addresses (entry points). */
276 bfd_vma transfer_address
[4];
278 /* Array of GSD sections to get the correspond BFD one. */
279 unsigned int section_max
; /* Size of the sections array. */
280 unsigned int section_count
; /* Number of GSD sections. */
283 /* Array of raw symbols. */
284 struct vms_symbol_entry
**syms
;
286 /* Canonicalized symbols. */
289 /* Number of symbols. */
290 unsigned int gsd_sym_count
;
291 /* Size of the syms array. */
292 unsigned int max_sym_count
;
293 /* Number of procedure symbols. */
294 unsigned int norm_sym_count
;
296 /* Stack used to evaluate TIR/ETIR commands. */
297 struct stack_struct
*stack
;
300 /* Content reading. */
301 asection
*image_section
; /* section for image_ptr */
302 file_ptr image_offset
; /* Offset for image_ptr. */
304 struct module
*modules
; /* list of all compilation units */
306 /* The DST section. */
307 asection
*dst_section
;
309 unsigned int dst_ptr_offsets_count
; /* # of offsets in following array */
310 unsigned int *dst_ptr_offsets
; /* array of saved image_ptr offsets */
312 /* Shared library support */
313 bfd_vma symvva
; /* relative virtual address of symbol vector */
315 unsigned char matchctl
;
317 /* Shared library index. This is used for input bfd while linking. */
318 unsigned int shr_index
;
320 /* Used to place structures in the file. */
323 /* Simply linked list of eisd. */
324 struct vms_internal_eisd_map
*eisd_head
;
325 struct vms_internal_eisd_map
*eisd_tail
;
327 /* Simply linked list of eisd for shared libraries. */
328 struct vms_internal_eisd_map
*gbl_eisd_head
;
329 struct vms_internal_eisd_map
*gbl_eisd_tail
;
331 /* linkage index counter used by conditional store commands */
332 unsigned int vms_linkage_index
;
335 #define PRIV2(abfd, name) \
336 (((struct vms_private_data_struct *)(abfd)->tdata.any)->name)
337 #define PRIV(name) PRIV2(abfd,name)
340 /* Used to keep extra VMS specific information for a given section.
342 reloc_size holds the size of the relocation stream, note this
343 is very different from the number of relocations as VMS relocations
346 reloc_stream is the actual stream of relocation entries. */
348 struct vms_section_data_struct
350 /* Maximnum number of entries in sec->relocation. */
353 /* Corresponding eisd. Used only while generating executables. */
354 struct vms_internal_eisd_map
*eisd
;
356 /* PSC flags to be clear. */
359 /* PSC flags to be set. */
363 #define vms_section_data(sec) \
364 ((struct vms_section_data_struct *)sec->used_by_bfd)
366 /* To be called from the debugger. */
367 struct vms_private_data_struct
*bfd_vms_get_data (bfd
*);
369 static int vms_get_remaining_object_record (bfd
*, unsigned int);
370 static bfd_boolean
_bfd_vms_slurp_object_records (bfd
* abfd
);
371 static void alpha_vms_add_fixup_lp (struct bfd_link_info
*, bfd
*, bfd
*);
372 static void alpha_vms_add_fixup_ca (struct bfd_link_info
*, bfd
*, bfd
*);
373 static void alpha_vms_add_fixup_qr (struct bfd_link_info
*, bfd
*, bfd
*,
375 static void alpha_vms_add_fixup_lr (struct bfd_link_info
*, unsigned int,
377 static void alpha_vms_add_lw_reloc (struct bfd_link_info
*);
378 static void alpha_vms_add_qw_reloc (struct bfd_link_info
*);
387 /* Number of elements in VEC. */
389 #define VEC_COUNT(VEC) ((VEC).nbr_el)
391 /* Get the address of the Nth element. */
393 #define VEC_EL(VEC, TYPE, N) (((TYPE *)((VEC).els))[N])
395 #define VEC_INIT(VEC) \
402 /* Be sure there is room for a new element. */
404 static void vector_grow1 (struct vector_type
*vec
, size_t elsz
);
406 /* Allocate room for a new element and return its address. */
408 #define VEC_APPEND(VEC, TYPE) \
409 (vector_grow1 (&VEC, sizeof (TYPE)), &VEC_EL(VEC, TYPE, (VEC).nbr_el++))
411 /* Append an element. */
413 #define VEC_APPEND_EL(VEC, TYPE, EL) \
414 (*(VEC_APPEND (VEC, TYPE)) = EL)
416 struct alpha_vms_vma_ref
418 bfd_vma vma
; /* Vma in the output. */
419 bfd_vma ref
; /* Reference in the input. */
422 struct alpha_vms_shlib_el
425 bfd_boolean has_fixups
;
427 struct vector_type lp
; /* Vector of bfd_vma. */
428 struct vector_type ca
; /* Vector of bfd_vma. */
429 struct vector_type qr
; /* Vector of struct alpha_vms_vma_ref. */
432 /* Alpha VMS linker hash table. */
434 struct alpha_vms_link_hash_table
436 struct bfd_link_hash_table root
;
438 /* Vector of shared libraries. */
439 struct vector_type shrlibs
;
444 /* Base address. Used by fixups. */
448 #define alpha_vms_link_hash(INFO) \
449 ((struct alpha_vms_link_hash_table *)(INFO->hash))
451 /* Alpha VMS linker hash table entry. */
453 struct alpha_vms_link_hash_entry
455 struct bfd_link_hash_entry root
;
457 /* Pointer to the original vms symbol. */
458 struct vms_symbol_entry
*sym
;
463 /* Read & process EIHD record.
464 Return TRUE on success, FALSE on error. */
467 _bfd_vms_slurp_eihd (bfd
*abfd
, unsigned int *eisd_offset
,
468 unsigned int *eihs_offset
)
470 unsigned int imgtype
, size
;
472 struct vms_eihd
*eihd
= (struct vms_eihd
*)PRIV (recrd
.rec
);
474 vms_debug2 ((8, "_bfd_vms_slurp_eihd\n"));
476 /* PR 21813: Check for an undersized record. */
477 if (PRIV (recrd
.buf_size
) < sizeof (* eihd
))
479 _bfd_error_handler (_("corrupt EIHD record - size is too small"));
480 bfd_set_error (bfd_error_bad_value
);
484 size
= bfd_getl32 (eihd
->size
);
485 imgtype
= bfd_getl32 (eihd
->imgtype
);
487 if (imgtype
== EIHD__K_EXE
|| imgtype
== EIHD__K_LIM
)
488 abfd
->flags
|= EXEC_P
;
490 symvva
= bfd_getl64 (eihd
->symvva
);
493 PRIV (symvva
) = symvva
;
494 abfd
->flags
|= DYNAMIC
;
497 PRIV (ident
) = bfd_getl32 (eihd
->ident
);
498 PRIV (matchctl
) = eihd
->matchctl
;
500 *eisd_offset
= bfd_getl32 (eihd
->isdoff
);
501 *eihs_offset
= bfd_getl32 (eihd
->symdbgoff
);
503 vms_debug2 ((4, "EIHD size %d imgtype %d symvva 0x%lx eisd %d eihs %d\n",
504 size
, imgtype
, (unsigned long)symvva
,
505 *eisd_offset
, *eihs_offset
));
511 /* Read & process EISD record.
512 Return TRUE on success, FALSE on error. */
515 _bfd_vms_slurp_eisd (bfd
*abfd
, unsigned int offset
)
517 int section_count
= 0;
519 vms_debug2 ((8, "_bfd_vms_slurp_eisd\n"));
523 struct vms_eisd
*eisd
;
524 unsigned int rec_size
;
533 /* PR 17512: file: 3d9e9fe9. */
534 if (offset
> PRIV (recrd
.rec_size
)
535 || (PRIV (recrd
.rec_size
) - offset
536 < offsetof (struct vms_eisd
, eisdsize
) + 4))
538 eisd
= (struct vms_eisd
*) (PRIV (recrd
.rec
) + offset
);
539 rec_size
= bfd_getl32 (eisd
->eisdsize
);
543 /* Skip to next block if pad. */
544 if (rec_size
== 0xffffffff)
546 offset
= (offset
+ VMS_BLOCK_SIZE
) & ~(VMS_BLOCK_SIZE
- 1);
550 /* Make sure that there is enough data present in the record. */
551 if (rec_size
< offsetof (struct vms_eisd
, type
) + 1)
553 /* Make sure that the record is not too big either. */
554 if (rec_size
> PRIV (recrd
.rec_size
) - offset
)
559 size
= bfd_getl32 (eisd
->secsize
);
560 vaddr
= bfd_getl64 (eisd
->virt_addr
);
561 flags
= bfd_getl32 (eisd
->flags
);
562 vbn
= bfd_getl32 (eisd
->vbn
);
564 vms_debug2 ((4, "EISD at 0x%x size 0x%x addr 0x%lx flags 0x%x blk %d\n",
565 offset
, size
, (unsigned long)vaddr
, flags
, vbn
));
567 /* VMS combines psects from .obj files into isects in the .exe. This
568 process doesn't preserve enough information to reliably determine
569 what's in each section without examining the data. This is
570 especially true of DWARF debug sections. */
571 bfd_flags
= SEC_ALLOC
;
573 bfd_flags
|= SEC_HAS_CONTENTS
| SEC_LOAD
;
575 if (flags
& EISD__M_EXE
)
576 bfd_flags
|= SEC_CODE
;
578 if (flags
& EISD__M_NONSHRADR
)
579 bfd_flags
|= SEC_DATA
;
581 if (!(flags
& EISD__M_WRT
))
582 bfd_flags
|= SEC_READONLY
;
584 if (flags
& EISD__M_DZRO
)
585 bfd_flags
|= SEC_DATA
;
587 if (flags
& EISD__M_FIXUPVEC
)
588 bfd_flags
|= SEC_DATA
;
590 if (flags
& EISD__M_CRF
)
591 bfd_flags
|= SEC_DATA
;
593 if (flags
& EISD__M_GBL
)
595 if (rec_size
<= offsetof (struct vms_eisd
, gblnam
))
597 else if (rec_size
< sizeof (struct vms_eisd
))
598 name
= _bfd_vms_save_counted_string (abfd
, eisd
->gblnam
,
599 rec_size
- offsetof (struct vms_eisd
, gblnam
));
601 name
= _bfd_vms_save_counted_string (abfd
, eisd
->gblnam
,
603 if (name
== NULL
|| name
[0] == 0)
605 bfd_flags
|= SEC_COFF_SHARED_LIBRARY
;
606 bfd_flags
&= ~(SEC_ALLOC
| SEC_LOAD
);
608 else if (flags
& EISD__M_FIXUPVEC
)
610 else if (eisd
->type
== EISD__K_USRSTACK
)
616 name
= (char *) bfd_alloc (abfd
, 32);
619 if (flags
& EISD__M_DZRO
)
621 else if (flags
& EISD__M_EXE
)
623 else if (!(flags
& EISD__M_WRT
))
627 BFD_ASSERT (section_count
< 999);
628 sprintf (name
, "$%s_%03d$", pfx
, section_count
++);
631 section
= bfd_make_section (abfd
, name
);
636 section
->filepos
= vbn
? VMS_BLOCK_SIZE
* (vbn
- 1) : 0;
637 section
->size
= size
;
638 section
->vma
= vaddr
;
640 if (!bfd_set_section_flags (section
, bfd_flags
))
647 /* Read & process EIHS record.
648 Return TRUE on success, FALSE on error. */
651 _bfd_vms_slurp_eihs (bfd
*abfd
, unsigned int offset
)
653 unsigned char *p
= PRIV (recrd
.rec
) + offset
;
655 unsigned int gstsize ATTRIBUTE_UNUSED
;
657 unsigned int dstsize
;
659 unsigned int dmtbytes
;
662 /* PR 21611: Check that offset is valid. */
663 if (offset
> PRIV (recrd
.rec_size
) - (EIHS__L_DMTBYTES
+ 4))
665 _bfd_error_handler (_("unable to read EIHS record at offset %#x"),
667 bfd_set_error (bfd_error_file_truncated
);
671 gstvbn
= bfd_getl32 (p
+ EIHS__L_GSTVBN
);
672 gstsize
= bfd_getl32 (p
+ EIHS__L_GSTSIZE
);
673 dstvbn
= bfd_getl32 (p
+ EIHS__L_DSTVBN
);
674 dstsize
= bfd_getl32 (p
+ EIHS__L_DSTSIZE
);
675 dmtvbn
= bfd_getl32 (p
+ EIHS__L_DMTVBN
);
676 dmtbytes
= bfd_getl32 (p
+ EIHS__L_DMTBYTES
);
679 vms_debug (8, "_bfd_vms_slurp_ihs\n");
680 vms_debug (4, "EIHS record gstvbn %d gstsize %d dstvbn %d dstsize %d dmtvbn %d dmtbytes %d\n",
681 gstvbn
, gstsize
, dstvbn
, dstsize
, dmtvbn
, dmtbytes
);
686 flagword bfd_flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
;
688 section
= bfd_make_section (abfd
, "$DST$");
692 section
->size
= dstsize
;
693 section
->filepos
= VMS_BLOCK_SIZE
* (dstvbn
- 1);
695 if (!bfd_set_section_flags (section
, bfd_flags
))
698 PRIV (dst_section
) = section
;
699 abfd
->flags
|= (HAS_DEBUG
| HAS_LINENO
);
704 flagword bfd_flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
;
706 section
= bfd_make_section (abfd
, "$DMT$");
710 section
->size
= dmtbytes
;
711 section
->filepos
= VMS_BLOCK_SIZE
* (dmtvbn
- 1);
713 if (!bfd_set_section_flags (section
, bfd_flags
))
719 if (bfd_seek (abfd
, VMS_BLOCK_SIZE
* (gstvbn
- 1), SEEK_SET
))
721 bfd_set_error (bfd_error_file_truncated
);
725 if (!_bfd_vms_slurp_object_records (abfd
))
728 abfd
->flags
|= HAS_SYMS
;
734 /* Object file reading. */
736 /* Object file input functions. */
738 /* Get next record from object file to vms_buf.
739 Set PRIV(buf_size) and return it
741 This is a little tricky since it should be portable.
743 The openVMS object file has 'variable length' which means that
744 read() returns data in chunks of (hopefully) correct and expected
745 size. The linker (and other tools on VMS) depend on that. Unix
746 doesn't know about 'formatted' files, so reading and writing such
747 an object file in a Unix environment is not trivial.
749 With the tool 'file' (available on all VMS FTP sites), one
750 can view and change the attributes of a file. Changing from
751 'variable length' to 'fixed length, 512 bytes' reveals the
752 record size at the first 2 bytes of every record. The same
753 may happen during the transfer of object files from VMS to Unix,
754 at least with UCX, the DEC implementation of TCP/IP.
756 The VMS format repeats the size at bytes 2 & 3 of every record.
758 On the first call (file_format == FF_UNKNOWN) we check if
759 the first and the third byte pair (!) of the record match.
760 If they do it's an object file in an Unix environment or with
761 wrong attributes (FF_FOREIGN), else we should be in a VMS
762 environment where read() returns the record size (FF_NATIVE).
764 Reading is always done in 2 steps:
765 1. first just the record header is read and the size extracted,
766 2. then the read buffer is adjusted and the remaining bytes are
769 All file I/O is done on even file positions. */
771 #define VMS_OBJECT_ADJUSTMENT 2
774 maybe_adjust_record_pointer_for_object (bfd
*abfd
)
776 /* Set the file format once for all on the first invocation. */
777 if (PRIV (recrd
.file_format
) == FF_UNKNOWN
)
779 if (PRIV (recrd
.rec
)[0] == PRIV (recrd
.rec
)[4]
780 && PRIV (recrd
.rec
)[1] == PRIV (recrd
.rec
)[5])
781 PRIV (recrd
.file_format
) = FF_FOREIGN
;
783 PRIV (recrd
.file_format
) = FF_NATIVE
;
786 /* The adjustment is needed only in an Unix environment. */
787 if (PRIV (recrd
.file_format
) == FF_FOREIGN
)
788 PRIV (recrd
.rec
) += VMS_OBJECT_ADJUSTMENT
;
791 /* Implement step #1 of the object record reading procedure.
792 Return the record type or -1 on failure. */
795 _bfd_vms_get_object_record (bfd
*abfd
)
797 unsigned int test_len
= 6;
800 vms_debug2 ((8, "_bfd_vms_get_obj_record\n"));
802 /* Skip alignment byte if the current position is odd. */
803 if (PRIV (recrd
.file_format
) == FF_FOREIGN
&& (bfd_tell (abfd
) & 1))
805 if (bfd_bread (PRIV (recrd
.buf
), 1, abfd
) != 1)
807 bfd_set_error (bfd_error_file_truncated
);
812 /* Read the record header */
813 if (bfd_bread (PRIV (recrd
.buf
), test_len
, abfd
) != test_len
)
815 bfd_set_error (bfd_error_file_truncated
);
819 /* Reset the record pointer. */
820 PRIV (recrd
.rec
) = PRIV (recrd
.buf
);
821 maybe_adjust_record_pointer_for_object (abfd
);
823 if (vms_get_remaining_object_record (abfd
, test_len
) <= 0)
826 type
= bfd_getl16 (PRIV (recrd
.rec
));
828 vms_debug2 ((8, "_bfd_vms_get_obj_record: rec %p, size %d, type %d\n",
829 PRIV (recrd
.rec
), PRIV (recrd
.rec_size
), type
));
834 /* Implement step #2 of the object record reading procedure.
835 Return the size of the record or 0 on failure. */
838 vms_get_remaining_object_record (bfd
*abfd
, unsigned int read_so_far
)
840 unsigned int to_read
;
842 vms_debug2 ((8, "vms_get_remaining_obj_record\n"));
844 /* Extract record size. */
845 PRIV (recrd
.rec_size
) = bfd_getl16 (PRIV (recrd
.rec
) + 2);
847 if (PRIV (recrd
.rec_size
) == 0)
849 bfd_set_error (bfd_error_file_truncated
);
853 /* That's what the linker manual says. */
854 if (PRIV (recrd
.rec_size
) > EOBJ__C_MAXRECSIZ
)
856 bfd_set_error (bfd_error_file_truncated
);
860 /* Take into account object adjustment. */
861 to_read
= PRIV (recrd
.rec_size
);
862 if (PRIV (recrd
.file_format
) == FF_FOREIGN
)
863 to_read
+= VMS_OBJECT_ADJUSTMENT
;
865 /* Adjust the buffer. */
866 if (to_read
> PRIV (recrd
.buf_size
))
869 = (unsigned char *) bfd_realloc (PRIV (recrd
.buf
), to_read
);
870 if (PRIV (recrd
.buf
) == NULL
)
872 PRIV (recrd
.buf_size
) = to_read
;
874 /* PR 17512: file: 025-1974-0.004. */
875 else if (to_read
<= read_so_far
)
878 /* Read the remaining record. */
879 to_read
-= read_so_far
;
881 vms_debug2 ((8, "vms_get_remaining_obj_record: to_read %d\n", to_read
));
883 if (bfd_bread (PRIV (recrd
.buf
) + read_so_far
, to_read
, abfd
) != to_read
)
885 bfd_set_error (bfd_error_file_truncated
);
889 /* Reset the record pointer. */
890 PRIV (recrd
.rec
) = PRIV (recrd
.buf
);
891 maybe_adjust_record_pointer_for_object (abfd
);
893 vms_debug2 ((8, "vms_get_remaining_obj_record: size %d\n",
894 PRIV (recrd
.rec_size
)));
896 return PRIV (recrd
.rec_size
);
899 /* Read and process emh record.
900 Return TRUE on success, FALSE on error. */
903 _bfd_vms_slurp_ehdr (bfd
*abfd
)
906 unsigned char *vms_rec
;
910 vms_rec
= PRIV (recrd
.rec
);
911 /* PR 17512: file: 62736583. */
912 end
= PRIV (recrd
.buf
) + PRIV (recrd
.buf_size
);
914 vms_debug2 ((2, "HDR/EMH\n"));
916 subtype
= bfd_getl16 (vms_rec
+ 4);
918 vms_debug2 ((3, "subtype %d\n", subtype
));
924 if (vms_rec
+ 21 >= end
)
926 PRIV (hdr_data
).hdr_b_strlvl
= vms_rec
[6];
927 PRIV (hdr_data
).hdr_l_arch1
= bfd_getl32 (vms_rec
+ 8);
928 PRIV (hdr_data
).hdr_l_arch2
= bfd_getl32 (vms_rec
+ 12);
929 PRIV (hdr_data
).hdr_l_recsiz
= bfd_getl32 (vms_rec
+ 16);
930 if ((vms_rec
+ 20 + vms_rec
[20] + 1) >= end
)
932 PRIV (hdr_data
).hdr_t_name
933 = _bfd_vms_save_counted_string (abfd
, vms_rec
+ 20, vms_rec
[20]);
934 ptr
= vms_rec
+ 20 + vms_rec
[20] + 1;
935 if ((ptr
+ *ptr
+ 1) >= end
)
937 PRIV (hdr_data
).hdr_t_version
938 = _bfd_vms_save_counted_string (abfd
, ptr
, *ptr
);
942 PRIV (hdr_data
).hdr_t_date
943 = _bfd_vms_save_sized_string (abfd
, ptr
, 17);
947 if (vms_rec
+ PRIV (recrd
.rec_size
- 6) > end
)
949 PRIV (hdr_data
).hdr_c_lnm
950 = _bfd_vms_save_sized_string (abfd
, vms_rec
, PRIV (recrd
.rec_size
- 6));
954 if (vms_rec
+ PRIV (recrd
.rec_size
- 6) > end
)
956 PRIV (hdr_data
).hdr_c_src
957 = _bfd_vms_save_sized_string (abfd
, vms_rec
, PRIV (recrd
.rec_size
- 6));
961 if (vms_rec
+ PRIV (recrd
.rec_size
- 6) > end
)
963 PRIV (hdr_data
).hdr_c_ttl
964 = _bfd_vms_save_sized_string (abfd
, vms_rec
, PRIV (recrd
.rec_size
- 6));
974 bfd_set_error (bfd_error_wrong_format
);
981 /* Typical sections for evax object files. */
983 #define EVAX_ABS_NAME "$ABS$"
984 #define EVAX_CODE_NAME "$CODE$"
985 #define EVAX_LINK_NAME "$LINK$"
986 #define EVAX_DATA_NAME "$DATA$"
987 #define EVAX_BSS_NAME "$BSS$"
988 #define EVAX_READONLYADDR_NAME "$READONLY_ADDR$"
989 #define EVAX_READONLY_NAME "$READONLY$"
990 #define EVAX_LITERAL_NAME "$LITERAL$"
991 #define EVAX_LITERALS_NAME "$LITERALS"
992 #define EVAX_COMMON_NAME "$COMMON$"
993 #define EVAX_LOCAL_NAME "$LOCAL$"
995 struct sec_flags_struct
997 const char *name
; /* Name of section. */
999 flagword flags_always
; /* Flags we set always. */
1001 flagword flags_hassize
; /* Flags we set if the section has a size > 0. */
1004 /* These flags are deccrtl/vaxcrtl (openVMS 6.2 Alpha) compatible. */
1006 static const struct sec_flags_struct evax_section_flags
[] =
1014 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_EXE
,
1015 SEC_CODE
| SEC_READONLY
,
1016 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_EXE
,
1017 SEC_CODE
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1018 { EVAX_LITERAL_NAME
,
1019 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
| EGPS__V_NOMOD
,
1020 SEC_DATA
| SEC_READONLY
,
1021 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
,
1022 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1024 EGPS__V_REL
| EGPS__V_RD
,
1025 SEC_DATA
| SEC_READONLY
,
1026 EGPS__V_REL
| EGPS__V_RD
,
1027 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1029 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
,
1031 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1032 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1034 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
,
1036 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
,
1038 { EVAX_READONLYADDR_NAME
,
1039 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_RD
,
1040 SEC_DATA
| SEC_READONLY
,
1041 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_RD
,
1042 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1043 { EVAX_READONLY_NAME
,
1044 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
| EGPS__V_NOMOD
,
1045 SEC_DATA
| SEC_READONLY
,
1046 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
,
1047 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1049 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1051 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1052 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1053 { EVAX_LITERALS_NAME
,
1054 EGPS__V_PIC
| EGPS__V_OVR
,
1055 SEC_DATA
| SEC_READONLY
,
1056 EGPS__V_PIC
| EGPS__V_OVR
,
1057 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1059 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1061 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1062 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
}
1065 /* Retrieve BFD section flags by name and size. */
1068 vms_secflag_by_name (const struct sec_flags_struct
*section_flags
,
1074 while (section_flags
[i
].name
!= NULL
)
1076 if (strcmp (name
, section_flags
[i
].name
) == 0)
1079 return section_flags
[i
].flags_hassize
;
1081 return section_flags
[i
].flags_always
;
1086 return section_flags
[i
].flags_hassize
;
1087 return section_flags
[i
].flags_always
;
1090 /* Retrieve VMS section flags by name and size. */
1093 vms_esecflag_by_name (const struct sec_flags_struct
*section_flags
,
1099 while (section_flags
[i
].name
!= NULL
)
1101 if (strcmp (name
, section_flags
[i
].name
) == 0)
1104 return section_flags
[i
].vflags_hassize
;
1106 return section_flags
[i
].vflags_always
;
1111 return section_flags
[i
].vflags_hassize
;
1112 return section_flags
[i
].vflags_always
;
1115 /* Add SYM to the symbol table of ABFD.
1116 Return FALSE in case of error. */
1119 add_symbol_entry (bfd
*abfd
, struct vms_symbol_entry
*sym
)
1121 if (PRIV (gsd_sym_count
) >= PRIV (max_sym_count
))
1123 if (PRIV (max_sym_count
) == 0)
1125 PRIV (max_sym_count
) = 128;
1126 PRIV (syms
) = bfd_malloc
1127 (PRIV (max_sym_count
) * sizeof (struct vms_symbol_entry
*));
1131 PRIV (max_sym_count
) *= 2;
1132 PRIV (syms
) = bfd_realloc
1134 (PRIV (max_sym_count
) * sizeof (struct vms_symbol_entry
*)));
1136 if (PRIV (syms
) == NULL
)
1140 PRIV (syms
)[PRIV (gsd_sym_count
)++] = sym
;
1144 /* Create a symbol whose name is ASCIC and add it to ABFD.
1145 Return NULL in case of error. */
1147 static struct vms_symbol_entry
*
1148 add_symbol (bfd
*abfd
, const unsigned char *ascic
, unsigned int max
)
1150 struct vms_symbol_entry
*entry
;
1157 _bfd_error_handler (_("record is too small for symbol name length"));
1158 bfd_set_error (bfd_error_bad_value
);
1162 entry
= (struct vms_symbol_entry
*)bfd_zalloc (abfd
, sizeof (*entry
) + len
);
1165 entry
->namelen
= len
;
1166 memcpy (entry
->name
, ascic
, len
);
1167 entry
->name
[len
] = 0;
1168 entry
->owner
= abfd
;
1170 if (!add_symbol_entry (abfd
, entry
))
1175 /* Read and process EGSD. Return FALSE on failure. */
1178 _bfd_vms_slurp_egsd (bfd
*abfd
)
1181 unsigned int gsd_size
;
1182 unsigned char *vms_rec
;
1186 vms_debug2 ((2, "EGSD\n"));
1188 if (PRIV (recrd
.rec_size
) < 8)
1190 _bfd_error_handler (_("corrupt EGSD record: its size (%#x) is too small"),
1191 PRIV (recrd
.rec_size
));
1192 bfd_set_error (bfd_error_bad_value
);
1196 PRIV (recrd
.rec
) += 8; /* Skip type, size, align pad. */
1197 PRIV (recrd
.rec_size
) -= 8;
1199 /* Calculate base address for each section. */
1202 while (PRIV (recrd
.rec_size
) > 4)
1204 vms_rec
= PRIV (recrd
.rec
);
1206 gsd_type
= bfd_getl16 (vms_rec
);
1207 gsd_size
= bfd_getl16 (vms_rec
+ 2);
1209 vms_debug2 ((3, "egsd_type %d\n", gsd_type
));
1211 /* PR 21615: Check for size overflow. */
1212 if (PRIV (recrd
.rec_size
) < gsd_size
)
1214 _bfd_error_handler (_("corrupt EGSD record type %d: size (%#x) "
1215 "is larger than remaining space (%#x)"),
1216 gsd_type
, gsd_size
, PRIV (recrd
.rec_size
));
1217 bfd_set_error (bfd_error_bad_value
);
1224 _bfd_error_handler (_("corrupt EGSD record type %d: size (%#x) "
1226 gsd_type
, gsd_size
);
1227 bfd_set_error (bfd_error_bad_value
);
1234 /* Program section definition. */
1236 struct vms_egps
*egps
= (struct vms_egps
*) vms_rec
;
1237 flagword new_flags
, vms_flags
;
1240 if (offsetof (struct vms_egps
, flags
) + 2 > gsd_size
)
1242 vms_flags
= bfd_getl16 (egps
->flags
);
1244 if ((vms_flags
& EGPS__V_REL
) == 0)
1246 /* Use the global absolute section for all
1247 absolute sections. */
1248 section
= bfd_abs_section_ptr
;
1256 if (offsetof (struct vms_egps
, namlng
) >= gsd_size
)
1258 left
= gsd_size
- offsetof (struct vms_egps
, namlng
);
1259 name
= _bfd_vms_save_counted_string (abfd
, &egps
->namlng
, left
);
1260 if (name
== NULL
|| name
[0] == 0)
1263 section
= bfd_make_section (abfd
, name
);
1267 section
->filepos
= 0;
1268 section
->size
= bfd_getl32 (egps
->alloc
);
1269 section
->alignment_power
= egps
->align
& 31;
1271 vms_section_data (section
)->flags
= vms_flags
;
1272 vms_section_data (section
)->no_flags
= 0;
1274 new_flags
= vms_secflag_by_name (evax_section_flags
,
1277 if (section
->size
> 0)
1278 new_flags
|= SEC_LOAD
;
1279 if (!(vms_flags
& EGPS__V_NOMOD
) && section
->size
> 0)
1281 /* Set RELOC and HAS_CONTENTS if the section is not
1282 demand-zero and not empty. */
1283 new_flags
|= SEC_HAS_CONTENTS
;
1284 if (vms_flags
& EGPS__V_REL
)
1285 new_flags
|= SEC_RELOC
;
1287 if (vms_flags
& EGPS__V_EXE
)
1289 /* Set CODE if section is executable. */
1290 new_flags
|= SEC_CODE
;
1291 new_flags
&= ~SEC_DATA
;
1293 if (!bfd_set_section_flags (section
, new_flags
))
1296 /* Give a non-overlapping vma to non absolute sections. */
1297 align_addr
= (bfd_vma
) 1 << section
->alignment_power
;
1298 base_addr
= (base_addr
+ align_addr
- 1) & -align_addr
;
1299 section
->vma
= base_addr
;
1300 base_addr
+= section
->size
;
1303 /* Append it to the section array. */
1304 if (PRIV (section_count
) >= PRIV (section_max
))
1306 if (PRIV (section_max
) == 0)
1307 PRIV (section_max
) = 16;
1309 PRIV (section_max
) *= 2;
1310 PRIV (sections
) = bfd_realloc_or_free
1311 (PRIV (sections
), PRIV (section_max
) * sizeof (asection
*));
1312 if (PRIV (sections
) == NULL
)
1316 PRIV (sections
)[PRIV (section_count
)] = section
;
1317 PRIV (section_count
)++;
1323 unsigned int nameoff
;
1324 struct vms_symbol_entry
*entry
;
1325 struct vms_egsy
*egsy
= (struct vms_egsy
*) vms_rec
;
1328 if (offsetof (struct vms_egsy
, flags
) + 2 > gsd_size
)
1330 old_flags
= bfd_getl16 (egsy
->flags
);
1331 if (old_flags
& EGSY__V_DEF
)
1332 nameoff
= ESDF__B_NAMLNG
;
1334 nameoff
= ESRF__B_NAMLNG
;
1336 if (nameoff
>= gsd_size
)
1338 entry
= add_symbol (abfd
, vms_rec
+ nameoff
, gsd_size
- nameoff
);
1342 /* Allow only duplicate reference. */
1343 if ((entry
->flags
& EGSY__V_DEF
) && (old_flags
& EGSY__V_DEF
))
1346 if (entry
->typ
== 0)
1348 entry
->typ
= gsd_type
;
1349 entry
->data_type
= egsy
->datyp
;
1350 entry
->flags
= old_flags
;
1353 if (old_flags
& EGSY__V_DEF
)
1355 struct vms_esdf
*esdf
= (struct vms_esdf
*) vms_rec
;
1357 entry
->value
= bfd_getl64 (esdf
->value
);
1358 if (PRIV (sections
) == NULL
)
1361 psindx
= bfd_getl32 (esdf
->psindx
);
1362 /* PR 21813: Check for an out of range index. */
1363 if (psindx
< 0 || psindx
>= (int) PRIV (section_count
))
1366 _bfd_error_handler (_("corrupt EGSD record: its psindx "
1367 "field is too big (%#lx)"),
1369 bfd_set_error (bfd_error_bad_value
);
1372 entry
->section
= PRIV (sections
)[psindx
];
1374 if (old_flags
& EGSY__V_NORM
)
1376 PRIV (norm_sym_count
)++;
1378 entry
->code_value
= bfd_getl64 (esdf
->code_address
);
1379 psindx
= bfd_getl32 (esdf
->ca_psindx
);
1380 /* PR 21813: Check for an out of range index. */
1381 if (psindx
< 0 || psindx
>= (int) PRIV (section_count
))
1383 entry
->code_section
= PRIV (sections
)[psindx
];
1391 struct vms_symbol_entry
*entry
;
1392 struct vms_egst
*egst
= (struct vms_egst
*)vms_rec
;
1394 unsigned int nameoff
= offsetof (struct vms_egst
, namlng
);
1396 old_flags
= bfd_getl16 (egst
->header
.flags
);
1398 if (nameoff
>= gsd_size
)
1400 entry
= add_symbol (abfd
, &egst
->namlng
, gsd_size
- nameoff
);
1404 entry
->typ
= gsd_type
;
1405 entry
->data_type
= egst
->header
.datyp
;
1406 entry
->flags
= old_flags
;
1408 entry
->symbol_vector
= bfd_getl32 (egst
->value
);
1410 if (old_flags
& EGSY__V_REL
)
1412 if (PRIV (sections
) == NULL
)
1414 psindx
= bfd_getl32 (egst
->psindx
);
1415 /* PR 21813: Check for an out of range index. */
1416 if (psindx
< 0 || psindx
>= (int) PRIV (section_count
))
1418 entry
->section
= PRIV (sections
)[psindx
];
1421 entry
->section
= bfd_abs_section_ptr
;
1423 entry
->value
= bfd_getl64 (egst
->lp_2
);
1425 if (old_flags
& EGSY__V_NORM
)
1427 PRIV (norm_sym_count
)++;
1429 entry
->code_value
= bfd_getl64 (egst
->lp_1
);
1430 entry
->code_section
= bfd_abs_section_ptr
;
1437 /* Currently ignored. */
1442 _bfd_error_handler (_("unknown EGSD subtype %d"), gsd_type
);
1443 bfd_set_error (bfd_error_bad_value
);
1447 PRIV (recrd
.rec_size
) -= gsd_size
;
1448 PRIV (recrd
.rec
) += gsd_size
;
1451 /* FIXME: Should we complain if PRIV (recrd.rec_size) is not zero ? */
1453 if (PRIV (gsd_sym_count
) > 0)
1454 abfd
->flags
|= HAS_SYMS
;
1459 /* Stack routines for vms ETIR commands. */
1461 /* Push value and section index. */
1464 _bfd_vms_push (bfd
*abfd
, bfd_vma val
, unsigned int reloc
)
1466 vms_debug2 ((4, "<push %08lx (0x%08x) at %d>\n",
1467 (unsigned long)val
, reloc
, PRIV (stackptr
)));
1469 PRIV (stack
[PRIV (stackptr
)]).value
= val
;
1470 PRIV (stack
[PRIV (stackptr
)]).reloc
= reloc
;
1472 if (PRIV (stackptr
) >= STACKSIZE
)
1474 bfd_set_error (bfd_error_bad_value
);
1475 _bfd_error_handler (_("stack overflow (%d) in _bfd_vms_push"), PRIV (stackptr
));
1481 /* Pop value and section index. */
1484 _bfd_vms_pop (bfd
*abfd
, bfd_vma
*val
, unsigned int *rel
)
1486 if (PRIV (stackptr
) == 0)
1488 bfd_set_error (bfd_error_bad_value
);
1489 _bfd_error_handler (_("stack underflow in _bfd_vms_pop"));
1493 *val
= PRIV (stack
[PRIV (stackptr
)]).value
;
1494 *rel
= PRIV (stack
[PRIV (stackptr
)]).reloc
;
1496 vms_debug2 ((4, "<pop %08lx (0x%08x)>\n", (unsigned long)*val
, *rel
));
1500 /* Routines to fill sections contents during tir/etir read. */
1502 /* Initialize image buffer pointer to be filled. */
1505 image_set_ptr (bfd
*abfd
, bfd_vma vma
, int sect
, struct bfd_link_info
*info
)
1509 vms_debug2 ((4, "image_set_ptr (0x%08x, sect=%d)\n", (unsigned)vma
, sect
));
1511 if (PRIV (sections
) == NULL
)
1513 if (sect
< 0 || sect
>= (int) PRIV (section_count
))
1516 sec
= PRIV (sections
)[sect
];
1520 /* Reading contents to an output bfd. */
1522 if (sec
->output_section
== NULL
)
1524 /* Section discarded. */
1525 vms_debug2 ((5, " section %s discarded\n", sec
->name
));
1527 /* This is not used. */
1528 PRIV (image_section
) = NULL
;
1529 PRIV (image_offset
) = 0;
1532 PRIV (image_offset
) = sec
->output_offset
+ vma
;
1533 PRIV (image_section
) = sec
->output_section
;
1537 PRIV (image_offset
) = vma
;
1538 PRIV (image_section
) = sec
;
1542 /* Increment image buffer pointer by offset. */
1545 image_inc_ptr (bfd
*abfd
, bfd_vma offset
)
1547 vms_debug2 ((4, "image_inc_ptr (%u)\n", (unsigned)offset
));
1549 PRIV (image_offset
) += offset
;
1552 /* Save current DST location counter under specified index. */
1555 dst_define_location (bfd
*abfd
, unsigned int loc
)
1557 vms_debug2 ((4, "dst_define_location (%d)\n", (int)loc
));
1559 /* Grow the ptr offset table if necessary. */
1560 if (loc
+ 1 > PRIV (dst_ptr_offsets_count
))
1562 PRIV (dst_ptr_offsets
) = bfd_realloc (PRIV (dst_ptr_offsets
),
1563 (loc
+ 1) * sizeof (unsigned int));
1564 PRIV (dst_ptr_offsets_count
) = loc
+ 1;
1567 PRIV (dst_ptr_offsets
)[loc
] = PRIV (image_offset
);
1570 /* Restore saved DST location counter from specified index. */
1573 dst_restore_location (bfd
*abfd
, unsigned int loc
)
1575 vms_debug2 ((4, "dst_restore_location (%d)\n", (int)loc
));
1577 PRIV (image_offset
) = PRIV (dst_ptr_offsets
)[loc
];
1580 /* Retrieve saved DST location counter from specified index. */
1583 dst_retrieve_location (bfd
*abfd
, unsigned int loc
)
1585 vms_debug2 ((4, "dst_retrieve_location (%d)\n", (int)loc
));
1587 return PRIV (dst_ptr_offsets
)[loc
];
1590 /* Write multiple bytes to section image. */
1593 image_write (bfd
*abfd
, unsigned char *ptr
, unsigned int size
)
1596 _bfd_vms_debug (8, "image_write from (%p, %d) to (%ld)\n", ptr
, size
,
1597 (long)PRIV (image_offset
));
1600 if (PRIV (image_section
)->contents
!= NULL
)
1602 asection
*sec
= PRIV (image_section
);
1603 size_t off
= PRIV (image_offset
);
1607 || size
> sec
->size
- off
)
1609 bfd_set_error (bfd_error_bad_value
);
1613 memcpy (sec
->contents
+ off
, ptr
, size
);
1616 _bfd_hexdump (9, ptr
, size
, 0);
1619 PRIV (image_offset
) += size
;
1623 /* Write byte to section image. */
1626 image_write_b (bfd
* abfd
, unsigned int value
)
1628 unsigned char data
[1];
1630 vms_debug2 ((6, "image_write_b (%02x)\n", (int) value
));
1634 return image_write (abfd
, data
, sizeof (data
));
1637 /* Write 2-byte word to image. */
1640 image_write_w (bfd
* abfd
, unsigned int value
)
1642 unsigned char data
[2];
1644 vms_debug2 ((6, "image_write_w (%04x)\n", (int) value
));
1646 bfd_putl16 (value
, data
);
1647 return image_write (abfd
, data
, sizeof (data
));
1650 /* Write 4-byte long to image. */
1653 image_write_l (bfd
* abfd
, unsigned long value
)
1655 unsigned char data
[4];
1657 vms_debug2 ((6, "image_write_l (%08lx)\n", value
));
1659 bfd_putl32 (value
, data
);
1660 return image_write (abfd
, data
, sizeof (data
));
1663 /* Write 8-byte quad to image. */
1666 image_write_q (bfd
* abfd
, bfd_vma value
)
1668 unsigned char data
[8];
1670 vms_debug2 ((6, "image_write_q (%08lx)\n", (unsigned long)value
));
1672 bfd_putl64 (value
, data
);
1673 return image_write (abfd
, data
, sizeof (data
));
1677 _bfd_vms_etir_name (int cmd
)
1681 case ETIR__C_STA_GBL
: return "ETIR__C_STA_GBL";
1682 case ETIR__C_STA_LW
: return "ETIR__C_STA_LW";
1683 case ETIR__C_STA_QW
: return "ETIR__C_STA_QW";
1684 case ETIR__C_STA_PQ
: return "ETIR__C_STA_PQ";
1685 case ETIR__C_STA_LI
: return "ETIR__C_STA_LI";
1686 case ETIR__C_STA_MOD
: return "ETIR__C_STA_MOD";
1687 case ETIR__C_STA_CKARG
: return "ETIR__C_STA_CKARG";
1688 case ETIR__C_STO_B
: return "ETIR__C_STO_B";
1689 case ETIR__C_STO_W
: return "ETIR__C_STO_W";
1690 case ETIR__C_STO_GBL
: return "ETIR__C_STO_GBL";
1691 case ETIR__C_STO_CA
: return "ETIR__C_STO_CA";
1692 case ETIR__C_STO_RB
: return "ETIR__C_STO_RB";
1693 case ETIR__C_STO_AB
: return "ETIR__C_STO_AB";
1694 case ETIR__C_STO_OFF
: return "ETIR__C_STO_OFF";
1695 case ETIR__C_STO_IMM
: return "ETIR__C_STO_IMM";
1696 case ETIR__C_STO_IMMR
: return "ETIR__C_STO_IMMR";
1697 case ETIR__C_STO_LW
: return "ETIR__C_STO_LW";
1698 case ETIR__C_STO_QW
: return "ETIR__C_STO_QW";
1699 case ETIR__C_STO_GBL_LW
: return "ETIR__C_STO_GBL_LW";
1700 case ETIR__C_STO_LP_PSB
: return "ETIR__C_STO_LP_PSB";
1701 case ETIR__C_STO_HINT_GBL
: return "ETIR__C_STO_HINT_GBL";
1702 case ETIR__C_STO_HINT_PS
: return "ETIR__C_STO_HINT_PS";
1703 case ETIR__C_OPR_ADD
: return "ETIR__C_OPR_ADD";
1704 case ETIR__C_OPR_SUB
: return "ETIR__C_OPR_SUB";
1705 case ETIR__C_OPR_INSV
: return "ETIR__C_OPR_INSV";
1706 case ETIR__C_OPR_USH
: return "ETIR__C_OPR_USH";
1707 case ETIR__C_OPR_ROT
: return "ETIR__C_OPR_ROT";
1708 case ETIR__C_OPR_REDEF
: return "ETIR__C_OPR_REDEF";
1709 case ETIR__C_OPR_DFLIT
: return "ETIR__C_OPR_DFLIT";
1710 case ETIR__C_STC_LP
: return "ETIR__C_STC_LP";
1711 case ETIR__C_STC_GBL
: return "ETIR__C_STC_GBL";
1712 case ETIR__C_STC_GCA
: return "ETIR__C_STC_GCA";
1713 case ETIR__C_STC_PS
: return "ETIR__C_STC_PS";
1714 case ETIR__C_STC_NBH_PS
: return "ETIR__C_STC_NBH_PS";
1715 case ETIR__C_STC_NOP_GBL
: return "ETIR__C_STC_NOP_GBL";
1716 case ETIR__C_STC_NOP_PS
: return "ETIR__C_STC_NOP_PS";
1717 case ETIR__C_STC_BSR_GBL
: return "ETIR__C_STC_BSR_GBL";
1718 case ETIR__C_STC_BSR_PS
: return "ETIR__C_STC_BSR_PS";
1719 case ETIR__C_STC_LDA_GBL
: return "ETIR__C_STC_LDA_GBL";
1720 case ETIR__C_STC_LDA_PS
: return "ETIR__C_STC_LDA_PS";
1721 case ETIR__C_STC_BOH_GBL
: return "ETIR__C_STC_BOH_GBL";
1722 case ETIR__C_STC_BOH_PS
: return "ETIR__C_STC_BOH_PS";
1723 case ETIR__C_STC_NBH_GBL
: return "ETIR__C_STC_NBH_GBL";
1724 case ETIR__C_STC_LP_PSB
: return "ETIR__C_STC_LP_PSB";
1725 case ETIR__C_CTL_SETRB
: return "ETIR__C_CTL_SETRB";
1726 case ETIR__C_CTL_AUGRB
: return "ETIR__C_CTL_AUGRB";
1727 case ETIR__C_CTL_DFLOC
: return "ETIR__C_CTL_DFLOC";
1728 case ETIR__C_CTL_STLOC
: return "ETIR__C_CTL_STLOC";
1729 case ETIR__C_CTL_STKDL
: return "ETIR__C_CTL_STKDL";
1732 /* These names have not yet been added to this switch statement. */
1733 _bfd_error_handler (_("unknown ETIR command %d"), cmd
);
1738 #define HIGHBIT(op) ((op & 0x80000000L) == 0x80000000L)
1741 _bfd_vms_get_value (bfd
*abfd
,
1742 const unsigned char *ascic
,
1743 const unsigned char *max_ascic
,
1744 struct bfd_link_info
*info
,
1746 struct alpha_vms_link_hash_entry
**hp
)
1751 struct alpha_vms_link_hash_entry
*h
;
1753 /* Not linking. Do not try to resolve the symbol. */
1762 if (ascic
+ len
>= max_ascic
)
1764 _bfd_error_handler (_("corrupt vms value"));
1770 for (i
= 0; i
< len
; i
++)
1771 name
[i
] = ascic
[i
+ 1];
1774 h
= (struct alpha_vms_link_hash_entry
*)
1775 bfd_link_hash_lookup (info
->hash
, name
, FALSE
, FALSE
, TRUE
);
1780 && (h
->root
.type
== bfd_link_hash_defined
1781 || h
->root
.type
== bfd_link_hash_defweak
))
1782 *vma
= h
->root
.u
.def
.value
1783 + h
->root
.u
.def
.section
->output_offset
1784 + h
->root
.u
.def
.section
->output_section
->vma
;
1785 else if (h
&& h
->root
.type
== bfd_link_hash_undefweak
)
1789 (*info
->callbacks
->undefined_symbol
)
1790 (info
, name
, abfd
, PRIV (image_section
), PRIV (image_offset
), TRUE
);
1797 #define RELC_SHR_BASE 0x10000
1798 #define RELC_SEC_BASE 0x20000
1799 #define RELC_MASK 0x0ffff
1802 alpha_vms_sym_to_ctxt (struct alpha_vms_link_hash_entry
*h
)
1804 /* Handle undefined symbols. */
1805 if (h
== NULL
|| h
->sym
== NULL
)
1808 if (h
->sym
->typ
== EGSD__C_SYMG
)
1810 if (h
->sym
->flags
& EGSY__V_REL
)
1811 return RELC_SHR_BASE
+ PRIV2 (h
->sym
->owner
, shr_index
);
1814 /* Can this happen (non-relocatable symg) ? I'd like to see
1819 if (h
->sym
->typ
== EGSD__C_SYM
)
1821 if (h
->sym
->flags
& EGSY__V_REL
)
1830 alpha_vms_get_sym_value (asection
*sect
, bfd_vma addr
)
1832 return sect
->output_section
->vma
+ sect
->output_offset
+ addr
;
1836 alpha_vms_fix_sec_rel (bfd
*abfd
, struct bfd_link_info
*info
,
1837 unsigned int rel
, bfd_vma vma
)
1841 if (PRIV (sections
) == NULL
)
1844 sec
= PRIV (sections
)[rel
& RELC_MASK
];
1848 if (sec
->output_section
== NULL
)
1850 return vma
+ sec
->output_section
->vma
+ sec
->output_offset
;
1853 return vma
+ sec
->vma
;
1856 /* Read an ETIR record from ABFD. If INFO is not null, put the content into
1857 the output section (used during linking).
1858 Return FALSE in case of error. */
1861 _bfd_vms_slurp_etir (bfd
*abfd
, struct bfd_link_info
*info
)
1864 unsigned int length
;
1865 unsigned char *maxptr
;
1868 unsigned int rel1
= RELC_NONE
;
1869 unsigned int rel2
= RELC_NONE
;
1870 struct alpha_vms_link_hash_entry
*h
;
1872 PRIV (recrd
.rec
) += ETIR__C_HEADER_SIZE
;
1873 PRIV (recrd
.rec_size
) -= ETIR__C_HEADER_SIZE
;
1875 ptr
= PRIV (recrd
.rec
);
1876 length
= PRIV (recrd
.rec_size
);
1877 maxptr
= ptr
+ length
;
1879 vms_debug2 ((2, "ETIR: %d bytes\n", length
));
1881 while (ptr
< maxptr
)
1883 int cmd
, cmd_length
;
1885 if (ptr
+ 4 > maxptr
)
1888 cmd
= bfd_getl16 (ptr
);
1889 cmd_length
= bfd_getl16 (ptr
+ 2);
1891 /* PR 21589 and 21579: Check for a corrupt ETIR record. */
1892 if (cmd_length
< 4 || ptr
+ cmd_length
> maxptr
)
1895 _bfd_error_handler (_("corrupt ETIR record encountered"));
1896 bfd_set_error (bfd_error_bad_value
);
1902 _bfd_vms_debug (4, "etir: %s(%d)\n",
1903 _bfd_vms_etir_name (cmd
), cmd
);
1904 _bfd_hexdump (8, ptr
, cmd_length
- 4, 0);
1912 stack 32 bit value of symbol (high bits set to 0). */
1913 case ETIR__C_STA_GBL
:
1914 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
1915 if (!_bfd_vms_push (abfd
, op1
, alpha_vms_sym_to_ctxt (h
)))
1922 stack 32 bit value, sign extend to 64 bit. */
1923 case ETIR__C_STA_LW
:
1924 if (ptr
+ 4 > maxptr
)
1926 if (!_bfd_vms_push (abfd
, bfd_getl32 (ptr
), RELC_NONE
))
1933 stack 64 bit value of symbol. */
1934 case ETIR__C_STA_QW
:
1935 if (ptr
+ 8 > maxptr
)
1937 if (!_bfd_vms_push (abfd
, bfd_getl64 (ptr
), RELC_NONE
))
1941 /* Stack psect base plus quadword offset
1942 arg: lw section index
1943 qw signed quadword offset (low 32 bits)
1945 Stack qw argument and section index
1946 (see ETIR__C_STO_OFF, ETIR__C_CTL_SETRB). */
1947 case ETIR__C_STA_PQ
:
1951 if (ptr
+ 12 > maxptr
)
1953 psect
= bfd_getl32 (ptr
);
1954 if ((unsigned int) psect
>= PRIV (section_count
))
1956 _bfd_error_handler (_("bad section index in %s"),
1957 _bfd_vms_etir_name (cmd
));
1958 bfd_set_error (bfd_error_bad_value
);
1961 op1
= bfd_getl64 (ptr
+ 4);
1962 if (!_bfd_vms_push (abfd
, op1
, psect
| RELC_SEC_BASE
))
1967 case ETIR__C_STA_LI
:
1968 case ETIR__C_STA_MOD
:
1969 case ETIR__C_STA_CKARG
:
1970 _bfd_error_handler (_("unsupported STA cmd %s"),
1971 _bfd_vms_etir_name (cmd
));
1975 /* Store byte: pop stack, write byte
1978 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
1980 if (rel1
!= RELC_NONE
)
1982 image_write_b (abfd
, (unsigned int) op1
& 0xff);
1985 /* Store word: pop stack, write word
1988 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
1990 if (rel1
!= RELC_NONE
)
1992 image_write_w (abfd
, (unsigned int) op1
& 0xffff);
1995 /* Store longword: pop stack, write longword
1997 case ETIR__C_STO_LW
:
1998 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2000 if (rel1
& RELC_SEC_BASE
)
2002 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2005 else if (rel1
& RELC_SHR_BASE
)
2007 alpha_vms_add_fixup_lr (info
, rel1
& RELC_MASK
, op1
);
2010 if (rel1
!= RELC_NONE
)
2012 if (rel1
!= RELC_REL
)
2014 alpha_vms_add_lw_reloc (info
);
2016 image_write_l (abfd
, op1
);
2019 /* Store quadword: pop stack, write quadword
2021 case ETIR__C_STO_QW
:
2022 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2024 if (rel1
& RELC_SEC_BASE
)
2026 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2029 else if (rel1
& RELC_SHR_BASE
)
2031 if (rel1
!= RELC_NONE
)
2033 if (rel1
!= RELC_REL
)
2035 alpha_vms_add_qw_reloc (info
);
2037 image_write_q (abfd
, op1
);
2040 /* Store immediate repeated: pop stack for repeat count
2043 case ETIR__C_STO_IMMR
:
2047 if (ptr
+ 4 > maxptr
)
2049 size
= bfd_getl32 (ptr
);
2050 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2052 if (rel1
!= RELC_NONE
)
2055 image_write (abfd
, ptr
+ 4, size
);
2059 /* Store global: write symbol value
2060 arg: cs global symbol name. */
2061 case ETIR__C_STO_GBL
:
2062 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
2065 if (h
->sym
->typ
== EGSD__C_SYMG
)
2067 alpha_vms_add_fixup_qr
2068 (info
, abfd
, h
->sym
->owner
, h
->sym
->symbol_vector
);
2073 op1
= alpha_vms_get_sym_value (h
->sym
->section
,
2075 alpha_vms_add_qw_reloc (info
);
2078 image_write_q (abfd
, op1
);
2081 /* Store code address: write address of entry point
2082 arg: cs global symbol name (procedure). */
2083 case ETIR__C_STO_CA
:
2084 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
2087 if (h
->sym
->flags
& EGSY__V_NORM
)
2089 /* That's really a procedure. */
2090 if (h
->sym
->typ
== EGSD__C_SYMG
)
2092 alpha_vms_add_fixup_ca (info
, abfd
, h
->sym
->owner
);
2093 op1
= h
->sym
->symbol_vector
;
2097 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
2098 h
->sym
->code_value
);
2099 alpha_vms_add_qw_reloc (info
);
2104 /* Symbol is not a procedure. */
2108 image_write_q (abfd
, op1
);
2111 /* Store offset to psect: pop stack, add low 32 bits to base of psect
2113 case ETIR__C_STO_OFF
:
2114 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2117 if (!(rel1
& RELC_SEC_BASE
))
2120 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2122 image_write_q (abfd
, op1
);
2126 arg: lw count of bytes
2128 case ETIR__C_STO_IMM
:
2132 if (ptr
+ 4 > maxptr
)
2134 size
= bfd_getl32 (ptr
);
2135 image_write (abfd
, ptr
+ 4, size
);
2139 /* This code is 'reserved to digital' according to the openVMS
2140 linker manual, however it is generated by the DEC C compiler
2141 and defined in the include file.
2142 FIXME, since the following is just a guess
2143 store global longword: store 32bit value of symbol
2144 arg: cs symbol name. */
2145 case ETIR__C_STO_GBL_LW
:
2146 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
2150 image_write_l (abfd
, op1
);
2153 case ETIR__C_STO_RB
:
2154 case ETIR__C_STO_AB
:
2155 case ETIR__C_STO_LP_PSB
:
2156 _bfd_error_handler (_("%s: not supported"),
2157 _bfd_vms_etir_name (cmd
));
2160 case ETIR__C_STO_HINT_GBL
:
2161 case ETIR__C_STO_HINT_PS
:
2162 _bfd_error_handler (_("%s: not implemented"),
2163 _bfd_vms_etir_name (cmd
));
2167 /* 200 Store-conditional Linkage Pair
2169 case ETIR__C_STC_LP
:
2171 /* 202 Store-conditional Address at global address
2175 case ETIR__C_STC_GBL
:
2177 /* 203 Store-conditional Code Address at global address
2179 cs procedure name. */
2180 case ETIR__C_STC_GCA
:
2182 /* 204 Store-conditional Address at psect + offset
2186 case ETIR__C_STC_PS
:
2187 _bfd_error_handler (_("%s: not supported"),
2188 _bfd_vms_etir_name (cmd
));
2192 /* 201 Store-conditional Linkage Pair with Procedure Signature
2198 case ETIR__C_STC_LP_PSB
:
2199 _bfd_vms_get_value (abfd
, ptr
+ 4, maxptr
, info
, &op1
, &h
);
2202 if (h
->sym
->typ
== EGSD__C_SYMG
)
2204 alpha_vms_add_fixup_lp (info
, abfd
, h
->sym
->owner
);
2205 op1
= h
->sym
->symbol_vector
;
2210 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
2211 h
->sym
->code_value
);
2212 op2
= alpha_vms_get_sym_value (h
->sym
->section
,
2218 /* Undefined symbol. */
2222 image_write_q (abfd
, op1
);
2223 image_write_q (abfd
, op2
);
2226 /* 205 Store-conditional NOP at address of global
2228 case ETIR__C_STC_NOP_GBL
:
2231 /* 207 Store-conditional BSR at global address
2234 case ETIR__C_STC_BSR_GBL
:
2237 /* 209 Store-conditional LDA at global address
2240 case ETIR__C_STC_LDA_GBL
:
2243 /* 211 Store-conditional BSR or Hint at global address
2246 case ETIR__C_STC_BOH_GBL
:
2247 /* Currentl ignored. */
2250 /* 213 Store-conditional NOP,BSR or HINT at global address
2253 case ETIR__C_STC_NBH_GBL
:
2255 /* 206 Store-conditional NOP at pect + offset
2258 case ETIR__C_STC_NOP_PS
:
2260 /* 208 Store-conditional BSR at pect + offset
2263 case ETIR__C_STC_BSR_PS
:
2265 /* 210 Store-conditional LDA at psect + offset
2268 case ETIR__C_STC_LDA_PS
:
2270 /* 212 Store-conditional BSR or Hint at pect + offset
2273 case ETIR__C_STC_BOH_PS
:
2275 /* 214 Store-conditional NOP, BSR or HINT at psect + offset
2277 case ETIR__C_STC_NBH_PS
:
2278 _bfd_error_handler (_("%s: not supported"),
2279 _bfd_vms_etir_name (cmd
));
2283 /* Det relocation base: pop stack, set image location counter
2285 case ETIR__C_CTL_SETRB
:
2286 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2288 if (!(rel1
& RELC_SEC_BASE
))
2290 image_set_ptr (abfd
, op1
, rel1
& RELC_MASK
, info
);
2293 /* Augment relocation base: increment image location counter by offset
2294 arg: lw offset value. */
2295 case ETIR__C_CTL_AUGRB
:
2296 if (ptr
+ 4 > maxptr
)
2298 op1
= bfd_getl32 (ptr
);
2299 image_inc_ptr (abfd
, op1
);
2302 /* Define location: pop index, save location counter under index
2304 case ETIR__C_CTL_DFLOC
:
2305 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2307 if (rel1
!= RELC_NONE
)
2309 dst_define_location (abfd
, op1
);
2312 /* Set location: pop index, restore location counter from index
2314 case ETIR__C_CTL_STLOC
:
2315 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2317 if (rel1
!= RELC_NONE
)
2319 dst_restore_location (abfd
, op1
);
2322 /* Stack defined location: pop index, push location counter from index
2324 case ETIR__C_CTL_STKDL
:
2325 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2327 if (rel1
!= RELC_NONE
)
2329 if (!_bfd_vms_push (abfd
, dst_retrieve_location (abfd
, op1
),
2334 case ETIR__C_OPR_NOP
: /* No-op. */
2337 case ETIR__C_OPR_ADD
: /* Add. */
2338 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2339 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2341 if (rel1
== RELC_NONE
&& rel2
!= RELC_NONE
)
2343 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2345 if (!_bfd_vms_push (abfd
, op1
+ op2
, rel1
))
2349 case ETIR__C_OPR_SUB
: /* Subtract. */
2350 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2351 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2353 if (rel1
== RELC_NONE
&& rel2
!= RELC_NONE
)
2355 else if ((rel1
& RELC_SEC_BASE
) && (rel2
& RELC_SEC_BASE
))
2357 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2358 op2
= alpha_vms_fix_sec_rel (abfd
, info
, rel2
, op2
);
2361 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2363 if (!_bfd_vms_push (abfd
, op2
- op1
, rel1
))
2367 case ETIR__C_OPR_MUL
: /* Multiply. */
2368 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2369 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2371 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2373 if (!_bfd_vms_push (abfd
, op1
* op2
, RELC_NONE
))
2377 case ETIR__C_OPR_DIV
: /* Divide. */
2378 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2379 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2381 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2385 if (!_bfd_vms_push (abfd
, 0, RELC_NONE
))
2390 if (!_bfd_vms_push (abfd
, op2
/ op1
, RELC_NONE
))
2395 case ETIR__C_OPR_AND
: /* Logical AND. */
2396 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2397 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2399 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2401 if (!_bfd_vms_push (abfd
, op1
& op2
, RELC_NONE
))
2405 case ETIR__C_OPR_IOR
: /* Logical inclusive OR. */
2406 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2407 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2409 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2411 if (!_bfd_vms_push (abfd
, op1
| op2
, RELC_NONE
))
2415 case ETIR__C_OPR_EOR
: /* Logical exclusive OR. */
2416 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2417 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2419 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2421 if (!_bfd_vms_push (abfd
, op1
^ op2
, RELC_NONE
))
2425 case ETIR__C_OPR_NEG
: /* Negate. */
2426 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2428 if (rel1
!= RELC_NONE
)
2430 if (!_bfd_vms_push (abfd
, -op1
, RELC_NONE
))
2434 case ETIR__C_OPR_COM
: /* Complement. */
2435 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2437 if (rel1
!= RELC_NONE
)
2439 if (!_bfd_vms_push (abfd
, ~op1
, RELC_NONE
))
2443 case ETIR__C_OPR_ASH
: /* Arithmetic shift. */
2444 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2445 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2447 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2450 _bfd_error_handler (_("invalid use of %s with contexts"),
2451 _bfd_vms_etir_name (cmd
));
2454 if ((int)op2
< 0) /* Shift right. */
2456 else /* Shift left. */
2458 if (!_bfd_vms_push (abfd
, op1
, RELC_NONE
)) /* FIXME: sym. */
2462 case ETIR__C_OPR_INSV
: /* Insert field. */
2463 case ETIR__C_OPR_USH
: /* Unsigned shift. */
2464 case ETIR__C_OPR_ROT
: /* Rotate. */
2465 case ETIR__C_OPR_REDEF
: /* Redefine symbol to current location. */
2466 case ETIR__C_OPR_DFLIT
: /* Define a literal. */
2467 _bfd_error_handler (_("%s: not supported"),
2468 _bfd_vms_etir_name (cmd
));
2472 case ETIR__C_OPR_SEL
: /* Select. */
2473 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2477 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2482 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2483 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2485 if (!_bfd_vms_push (abfd
, op1
, rel1
))
2491 _bfd_error_handler (_("reserved cmd %d"), cmd
);
2496 ptr
+= cmd_length
- 4;
2502 /* Process EDBG/ETBT record.
2503 Return TRUE on success, FALSE on error */
2506 vms_slurp_debug (bfd
*abfd
)
2508 asection
*section
= PRIV (dst_section
);
2510 if (section
== NULL
)
2512 /* We have no way to find out beforehand how much debug info there
2513 is in an object file, so pick an initial amount and grow it as
2515 flagword flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
| SEC_RELOC
2518 section
= bfd_make_section (abfd
, "$DST$");
2521 if (!bfd_set_section_flags (section
, flags
))
2523 PRIV (dst_section
) = section
;
2526 PRIV (image_section
) = section
;
2527 PRIV (image_offset
) = section
->size
;
2529 if (!_bfd_vms_slurp_etir (abfd
, NULL
))
2532 section
->size
= PRIV (image_offset
);
2536 /* Process EDBG record.
2537 Return TRUE on success, FALSE on error. */
2540 _bfd_vms_slurp_edbg (bfd
*abfd
)
2542 vms_debug2 ((2, "EDBG\n"));
2544 abfd
->flags
|= HAS_DEBUG
| HAS_LINENO
;
2546 return vms_slurp_debug (abfd
);
2549 /* Process ETBT record.
2550 Return TRUE on success, FALSE on error. */
2553 _bfd_vms_slurp_etbt (bfd
*abfd
)
2555 vms_debug2 ((2, "ETBT\n"));
2557 abfd
->flags
|= HAS_LINENO
;
2559 return vms_slurp_debug (abfd
);
2562 /* Process EEOM record.
2563 Return TRUE on success, FALSE on error. */
2566 _bfd_vms_slurp_eeom (bfd
*abfd
)
2568 struct vms_eeom
*eeom
= (struct vms_eeom
*) PRIV (recrd
.rec
);
2570 vms_debug2 ((2, "EEOM\n"));
2572 /* PR 21813: Check for an undersized record. */
2573 if (PRIV (recrd
.buf_size
) < sizeof (* eeom
))
2575 _bfd_error_handler (_("corrupt EEOM record - size is too small"));
2576 bfd_set_error (bfd_error_bad_value
);
2580 PRIV (eom_data
).eom_l_total_lps
= bfd_getl32 (eeom
->total_lps
);
2581 PRIV (eom_data
).eom_w_comcod
= bfd_getl16 (eeom
->comcod
);
2582 if (PRIV (eom_data
).eom_w_comcod
> 1)
2584 _bfd_error_handler (_("object module not error-free !"));
2585 bfd_set_error (bfd_error_bad_value
);
2589 PRIV (eom_data
).eom_has_transfer
= FALSE
;
2590 if (PRIV (recrd
.rec_size
) > 10)
2592 PRIV (eom_data
).eom_has_transfer
= TRUE
;
2593 PRIV (eom_data
).eom_b_tfrflg
= eeom
->tfrflg
;
2594 PRIV (eom_data
).eom_l_psindx
= bfd_getl32 (eeom
->psindx
);
2595 PRIV (eom_data
).eom_l_tfradr
= bfd_getl32 (eeom
->tfradr
);
2597 abfd
->start_address
= PRIV (eom_data
).eom_l_tfradr
;
2602 /* Slurp an ordered set of VMS object records. Return FALSE on error. */
2605 _bfd_vms_slurp_object_records (bfd
* abfd
)
2612 vms_debug2 ((7, "reading at %08lx\n", (unsigned long)bfd_tell (abfd
)));
2614 type
= _bfd_vms_get_object_record (abfd
);
2617 vms_debug2 ((2, "next_record failed\n"));
2624 err
= _bfd_vms_slurp_ehdr (abfd
);
2627 err
= _bfd_vms_slurp_eeom (abfd
);
2630 err
= _bfd_vms_slurp_egsd (abfd
);
2633 err
= TRUE
; /* _bfd_vms_slurp_etir (abfd); */
2636 err
= _bfd_vms_slurp_edbg (abfd
);
2639 err
= _bfd_vms_slurp_etbt (abfd
);
2646 vms_debug2 ((2, "slurp type %d failed\n", type
));
2650 while (type
!= EOBJ__C_EEOM
);
2655 /* Initialize private data */
2657 vms_initialize (bfd
* abfd
)
2661 amt
= sizeof (struct vms_private_data_struct
);
2662 abfd
->tdata
.any
= bfd_zalloc (abfd
, amt
);
2663 if (abfd
->tdata
.any
== NULL
)
2666 PRIV (recrd
.file_format
) = FF_UNKNOWN
;
2668 amt
= sizeof (struct stack_struct
) * STACKSIZE
;
2669 PRIV (stack
) = bfd_alloc (abfd
, amt
);
2670 if (PRIV (stack
) == NULL
)
2676 bfd_release (abfd
, abfd
->tdata
.any
);
2677 abfd
->tdata
.any
= NULL
;
2681 /* Free malloc'd memory. */
2684 alpha_vms_free_private (bfd
*abfd
)
2686 struct module
*module
;
2688 free (PRIV (recrd
.buf
));
2689 free (PRIV (sections
));
2691 free (PRIV (dst_ptr_offsets
));
2693 for (module
= PRIV (modules
); module
; module
= module
->next
)
2694 free (module
->file_table
);
2697 /* Check the format for a file being read.
2698 Return a (bfd_target *) if it's an object file or zero if not. */
2700 static const struct bfd_target
*
2701 alpha_vms_object_p (bfd
*abfd
)
2703 void *tdata_save
= abfd
->tdata
.any
;
2704 unsigned int test_len
;
2707 vms_debug2 ((1, "vms_object_p(%p)\n", abfd
));
2709 /* Allocate alpha-vms specific data. */
2710 if (!vms_initialize (abfd
))
2712 abfd
->tdata
.any
= tdata_save
;
2716 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
))
2717 goto err_wrong_format
;
2719 /* The first challenge with VMS is to discover the kind of the file.
2721 Image files (executable or shared images) are stored as a raw
2722 stream of bytes (like on UNIX), but there is no magic number.
2724 Object files are written with RMS (record management service), ie
2725 each records are preceeded by its length (on a word - 2 bytes), and
2726 padded for word-alignment. That would be simple but when files
2727 are transfered to a UNIX filesystem (using ftp), records are lost.
2728 Only the raw content of the records are transfered. Fortunately,
2729 the Alpha Object file format also store the length of the record
2730 in the records. Is that clear ? */
2732 /* Minimum is 6 bytes for objects (2 bytes size, 2 bytes record id,
2733 2 bytes size repeated) and 12 bytes for images (4 bytes major id,
2734 4 bytes minor id, 4 bytes length). */
2737 /* Size the main buffer. */
2738 buf
= (unsigned char *) bfd_malloc (test_len
);
2741 PRIV (recrd
.buf
) = buf
;
2742 PRIV (recrd
.buf_size
) = test_len
;
2744 /* Initialize the record pointer. */
2745 PRIV (recrd
.rec
) = buf
;
2747 if (bfd_bread (buf
, test_len
, abfd
) != test_len
)
2748 goto err_wrong_format
;
2750 /* Is it an image? */
2751 if ((bfd_getl32 (buf
) == EIHD__K_MAJORID
)
2752 && (bfd_getl32 (buf
+ 4) == EIHD__K_MINORID
))
2754 unsigned int to_read
;
2755 unsigned int read_so_far
;
2756 unsigned int remaining
;
2757 unsigned int eisd_offset
, eihs_offset
;
2759 /* Extract the header size. */
2760 PRIV (recrd
.rec_size
) = bfd_getl32 (buf
+ EIHD__L_SIZE
);
2762 /* The header size is 0 for DSF files. */
2763 if (PRIV (recrd
.rec_size
) == 0)
2764 PRIV (recrd
.rec_size
) = sizeof (struct vms_eihd
);
2766 if (PRIV (recrd
.rec_size
) > PRIV (recrd
.buf_size
))
2768 buf
= bfd_realloc_or_free (buf
, PRIV (recrd
.rec_size
));
2772 PRIV (recrd
.buf
) = NULL
;
2775 PRIV (recrd
.buf
) = buf
;
2776 PRIV (recrd
.buf_size
) = PRIV (recrd
.rec_size
);
2779 /* PR 21813: Check for a truncated record. */
2780 if (PRIV (recrd
.rec_size
< test_len
))
2782 /* Read the remaining record. */
2783 remaining
= PRIV (recrd
.rec_size
) - test_len
;
2784 to_read
= MIN (VMS_BLOCK_SIZE
- test_len
, remaining
);
2785 read_so_far
= test_len
;
2787 while (remaining
> 0)
2789 if (bfd_bread (buf
+ read_so_far
, to_read
, abfd
) != to_read
)
2790 goto err_wrong_format
;
2792 read_so_far
+= to_read
;
2793 remaining
-= to_read
;
2795 to_read
= MIN (VMS_BLOCK_SIZE
, remaining
);
2798 /* Reset the record pointer. */
2799 PRIV (recrd
.rec
) = buf
;
2801 /* PR 17512: file: 7d7c57c2. */
2802 if (PRIV (recrd
.rec_size
) < sizeof (struct vms_eihd
))
2804 vms_debug2 ((2, "file type is image\n"));
2806 if (!_bfd_vms_slurp_eihd (abfd
, &eisd_offset
, &eihs_offset
))
2807 goto err_wrong_format
;
2809 if (!_bfd_vms_slurp_eisd (abfd
, eisd_offset
))
2810 goto err_wrong_format
;
2812 /* EIHS is optional. */
2813 if (eihs_offset
!= 0 && !_bfd_vms_slurp_eihs (abfd
, eihs_offset
))
2814 goto err_wrong_format
;
2820 /* Assume it's a module and adjust record pointer if necessary. */
2821 maybe_adjust_record_pointer_for_object (abfd
);
2823 /* But is it really a module? */
2824 if (bfd_getl16 (PRIV (recrd
.rec
)) <= EOBJ__C_MAXRECTYP
2825 && bfd_getl16 (PRIV (recrd
.rec
) + 2) <= EOBJ__C_MAXRECSIZ
)
2827 if (vms_get_remaining_object_record (abfd
, test_len
) <= 0)
2828 goto err_wrong_format
;
2830 vms_debug2 ((2, "file type is module\n"));
2832 type
= bfd_getl16 (PRIV (recrd
.rec
));
2833 if (type
!= EOBJ__C_EMH
|| !_bfd_vms_slurp_ehdr (abfd
))
2834 goto err_wrong_format
;
2836 if (!_bfd_vms_slurp_object_records (abfd
))
2837 goto err_wrong_format
;
2840 goto err_wrong_format
;
2843 /* Set arch_info to alpha. */
2845 if (! bfd_default_set_arch_mach (abfd
, bfd_arch_alpha
, 0))
2846 goto err_wrong_format
;
2851 bfd_set_error (bfd_error_wrong_format
);
2854 alpha_vms_free_private (abfd
);
2855 if (abfd
->tdata
.any
!= tdata_save
&& abfd
->tdata
.any
!= NULL
)
2856 bfd_release (abfd
, abfd
->tdata
.any
);
2857 abfd
->tdata
.any
= tdata_save
;
2863 /* Write an EMH/MHD record. */
2866 _bfd_vms_write_emh (bfd
*abfd
)
2868 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2870 _bfd_vms_output_alignment (recwr
, 2);
2873 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
2874 _bfd_vms_output_short (recwr
, EMH__C_MHD
);
2875 _bfd_vms_output_short (recwr
, EOBJ__C_STRLVL
);
2876 _bfd_vms_output_long (recwr
, 0);
2877 _bfd_vms_output_long (recwr
, 0);
2878 _bfd_vms_output_long (recwr
, MAX_OUTREC_SIZE
);
2880 /* Create module name from filename. */
2881 if (bfd_get_filename (abfd
) != 0)
2883 char *module
= vms_get_module_name (bfd_get_filename (abfd
), TRUE
);
2884 _bfd_vms_output_counted (recwr
, module
);
2888 _bfd_vms_output_counted (recwr
, "NONAME");
2890 _bfd_vms_output_counted (recwr
, BFD_VERSION_STRING
);
2891 _bfd_vms_output_dump (recwr
, get_vms_time_string (), EMH_DATE_LENGTH
);
2892 _bfd_vms_output_fill (recwr
, 0, EMH_DATE_LENGTH
);
2893 _bfd_vms_output_end (abfd
, recwr
);
2896 /* Write an EMH/LMN record. */
2899 _bfd_vms_write_lmn (bfd
*abfd
, const char *name
)
2902 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2903 unsigned int ver
= BFD_VERSION
/ 10000;
2906 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
2907 _bfd_vms_output_short (recwr
, EMH__C_LNM
);
2908 snprintf (version
, sizeof (version
), "%s %d.%d.%d", name
,
2909 ver
/ 10000, (ver
/ 100) % 100, ver
% 100);
2910 _bfd_vms_output_dump (recwr
, (unsigned char *)version
, strlen (version
));
2911 _bfd_vms_output_end (abfd
, recwr
);
2915 /* Write eom record for bfd abfd. Return FALSE on error. */
2918 _bfd_vms_write_eeom (bfd
*abfd
)
2920 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2922 vms_debug2 ((2, "vms_write_eeom\n"));
2924 _bfd_vms_output_alignment (recwr
, 2);
2926 _bfd_vms_output_begin (recwr
, EOBJ__C_EEOM
);
2927 _bfd_vms_output_long (recwr
, PRIV (vms_linkage_index
+ 1) >> 1);
2928 _bfd_vms_output_byte (recwr
, 0); /* Completion code. */
2929 _bfd_vms_output_byte (recwr
, 0); /* Fill byte. */
2931 if ((abfd
->flags
& EXEC_P
) == 0
2932 && bfd_get_start_address (abfd
) != (bfd_vma
)-1)
2936 section
= bfd_get_section_by_name (abfd
, ".link");
2939 bfd_set_error (bfd_error_nonrepresentable_section
);
2942 _bfd_vms_output_short (recwr
, 0);
2943 _bfd_vms_output_long (recwr
, (unsigned long) section
->target_index
);
2944 _bfd_vms_output_long (recwr
,
2945 (unsigned long) bfd_get_start_address (abfd
));
2946 _bfd_vms_output_long (recwr
, 0);
2949 _bfd_vms_output_end (abfd
, recwr
);
2954 vector_grow1 (struct vector_type
*vec
, size_t elsz
)
2956 if (vec
->nbr_el
+ 1 < vec
->max_el
)
2959 if (vec
->max_el
== 0)
2962 vec
->els
= bfd_malloc2 (vec
->max_el
, elsz
);
2967 vec
->els
= bfd_realloc2 (vec
->els
, vec
->max_el
, elsz
);
2971 /* Bump ABFD file position to next block. */
2974 alpha_vms_file_position_block (bfd
*abfd
)
2977 PRIV (file_pos
) += VMS_BLOCK_SIZE
- 1;
2978 PRIV (file_pos
) -= (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
2981 /* Convert from internal structure SRC to external structure DST. */
2984 alpha_vms_swap_eisd_out (struct vms_internal_eisd_map
*src
,
2985 struct vms_eisd
*dst
)
2987 bfd_putl32 (src
->u
.eisd
.majorid
, dst
->majorid
);
2988 bfd_putl32 (src
->u
.eisd
.minorid
, dst
->minorid
);
2989 bfd_putl32 (src
->u
.eisd
.eisdsize
, dst
->eisdsize
);
2990 if (src
->u
.eisd
.eisdsize
<= EISD__K_LENEND
)
2992 bfd_putl32 (src
->u
.eisd
.secsize
, dst
->secsize
);
2993 bfd_putl64 (src
->u
.eisd
.virt_addr
, dst
->virt_addr
);
2994 bfd_putl32 (src
->u
.eisd
.flags
, dst
->flags
);
2995 bfd_putl32 (src
->u
.eisd
.vbn
, dst
->vbn
);
2996 dst
->pfc
= src
->u
.eisd
.pfc
;
2997 dst
->matchctl
= src
->u
.eisd
.matchctl
;
2998 dst
->type
= src
->u
.eisd
.type
;
3000 if (src
->u
.eisd
.flags
& EISD__M_GBL
)
3002 bfd_putl32 (src
->u
.gbl_eisd
.ident
, dst
->ident
);
3003 memcpy (dst
->gblnam
, src
->u
.gbl_eisd
.gblnam
,
3004 src
->u
.gbl_eisd
.gblnam
[0] + 1);
3008 /* Append EISD to the list of extra eisd for ABFD. */
3011 alpha_vms_append_extra_eisd (bfd
*abfd
, struct vms_internal_eisd_map
*eisd
)
3014 if (PRIV (gbl_eisd_head
) == NULL
)
3015 PRIV (gbl_eisd_head
) = eisd
;
3017 PRIV (gbl_eisd_tail
)->next
= eisd
;
3018 PRIV (gbl_eisd_tail
) = eisd
;
3021 /* Create an EISD for shared image SHRIMG.
3022 Return FALSE in case of error. */
3025 alpha_vms_create_eisd_for_shared (bfd
*abfd
, bfd
*shrimg
)
3027 struct vms_internal_eisd_map
*eisd
;
3030 namlen
= strlen (PRIV2 (shrimg
, hdr_data
.hdr_t_name
));
3031 if (namlen
+ 5 > EISD__K_GBLNAMLEN
)
3037 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
3041 /* Fill the fields. */
3042 eisd
->u
.gbl_eisd
.common
.majorid
= EISD__K_MAJORID
;
3043 eisd
->u
.gbl_eisd
.common
.minorid
= EISD__K_MINORID
;
3044 eisd
->u
.gbl_eisd
.common
.eisdsize
= (EISD__K_LEN
+ 4 + namlen
+ 5 + 3) & ~3;
3045 eisd
->u
.gbl_eisd
.common
.secsize
= VMS_BLOCK_SIZE
; /* Must not be 0. */
3046 eisd
->u
.gbl_eisd
.common
.virt_addr
= 0;
3047 eisd
->u
.gbl_eisd
.common
.flags
= EISD__M_GBL
;
3048 eisd
->u
.gbl_eisd
.common
.vbn
= 0;
3049 eisd
->u
.gbl_eisd
.common
.pfc
= 0;
3050 eisd
->u
.gbl_eisd
.common
.matchctl
= PRIV2 (shrimg
, matchctl
);
3051 eisd
->u
.gbl_eisd
.common
.type
= EISD__K_SHRPIC
;
3053 eisd
->u
.gbl_eisd
.ident
= PRIV2 (shrimg
, ident
);
3054 eisd
->u
.gbl_eisd
.gblnam
[0] = namlen
+ 4;
3055 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1, PRIV2 (shrimg
, hdr_data
.hdr_t_name
),
3057 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1 + namlen
, "_001", 4);
3059 /* Append it to the list. */
3060 alpha_vms_append_extra_eisd (abfd
, eisd
);
3065 /* Create an EISD for section SEC.
3066 Return FALSE in case of failure. */
3069 alpha_vms_create_eisd_for_section (bfd
*abfd
, asection
*sec
)
3071 struct vms_internal_eisd_map
*eisd
;
3073 /* Only for allocating section. */
3074 if (!(sec
->flags
& SEC_ALLOC
))
3077 BFD_ASSERT (vms_section_data (sec
)->eisd
== NULL
);
3078 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
3081 vms_section_data (sec
)->eisd
= eisd
;
3083 /* Fill the fields. */
3084 eisd
->u
.eisd
.majorid
= EISD__K_MAJORID
;
3085 eisd
->u
.eisd
.minorid
= EISD__K_MINORID
;
3086 eisd
->u
.eisd
.eisdsize
= EISD__K_LEN
;
3087 eisd
->u
.eisd
.secsize
=
3088 (sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
3089 eisd
->u
.eisd
.virt_addr
= sec
->vma
;
3090 eisd
->u
.eisd
.flags
= 0;
3091 eisd
->u
.eisd
.vbn
= 0; /* To be later defined. */
3092 eisd
->u
.eisd
.pfc
= 0; /* Default. */
3093 eisd
->u
.eisd
.matchctl
= EISD__K_MATALL
;
3094 eisd
->u
.eisd
.type
= EISD__K_NORMAL
;
3096 if (sec
->flags
& SEC_CODE
)
3097 eisd
->u
.eisd
.flags
|= EISD__M_EXE
;
3098 if (!(sec
->flags
& SEC_READONLY
))
3099 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
3101 /* If relocations or fixup will be applied, make this isect writeable. */
3102 if (sec
->flags
& SEC_RELOC
)
3103 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
3105 if (!(sec
->flags
& SEC_HAS_CONTENTS
))
3107 eisd
->u
.eisd
.flags
|= EISD__M_DZRO
;
3108 eisd
->u
.eisd
.flags
&= ~EISD__M_CRF
;
3110 if (sec
->flags
& SEC_LINKER_CREATED
)
3112 if (strcmp (sec
->name
, "$FIXUP$") == 0)
3113 eisd
->u
.eisd
.flags
|= EISD__M_FIXUPVEC
;
3116 /* Append it to the list. */
3118 if (PRIV (eisd_head
) == NULL
)
3119 PRIV (eisd_head
) = eisd
;
3121 PRIV (eisd_tail
)->next
= eisd
;
3122 PRIV (eisd_tail
) = eisd
;
3127 /* Layout executable ABFD and write it to the disk.
3128 Return FALSE in case of failure. */
3131 alpha_vms_write_exec (bfd
*abfd
)
3133 struct vms_eihd eihd
;
3134 struct vms_eiha
*eiha
;
3135 struct vms_eihi
*eihi
;
3136 struct vms_eihs
*eihs
= NULL
;
3138 struct vms_internal_eisd_map
*first_eisd
;
3139 struct vms_internal_eisd_map
*eisd
;
3142 file_ptr gst_filepos
= 0;
3143 unsigned int lnkflags
= 0;
3145 /* Build the EIHD. */
3146 PRIV (file_pos
) = EIHD__C_LENGTH
;
3148 memset (&eihd
, 0, sizeof (eihd
));
3149 memset (eihd
.fill_2
, 0xff, sizeof (eihd
.fill_2
));
3151 bfd_putl32 (EIHD__K_MAJORID
, eihd
.majorid
);
3152 bfd_putl32 (EIHD__K_MINORID
, eihd
.minorid
);
3154 bfd_putl32 (sizeof (eihd
), eihd
.size
);
3155 bfd_putl32 (0, eihd
.isdoff
);
3156 bfd_putl32 (0, eihd
.activoff
);
3157 bfd_putl32 (0, eihd
.symdbgoff
);
3158 bfd_putl32 (0, eihd
.imgidoff
);
3159 bfd_putl32 (0, eihd
.patchoff
);
3160 bfd_putl64 (0, eihd
.iafva
);
3161 bfd_putl32 (0, eihd
.version_array_off
);
3163 bfd_putl32 (EIHD__K_EXE
, eihd
.imgtype
);
3164 bfd_putl32 (0, eihd
.subtype
);
3166 bfd_putl32 (0, eihd
.imgiocnt
);
3167 bfd_putl32 (-1, eihd
.privreqs
);
3168 bfd_putl32 (-1, eihd
.privreqs
+ 4);
3170 bfd_putl32 ((sizeof (eihd
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
3172 bfd_putl32 (0, eihd
.ident
);
3173 bfd_putl32 (0, eihd
.sysver
);
3176 bfd_putl32 (0, eihd
.symvect_size
);
3177 bfd_putl32 (16, eihd
.virt_mem_block_size
);
3178 bfd_putl32 (0, eihd
.ext_fixup_off
);
3179 bfd_putl32 (0, eihd
.noopt_psect_off
);
3180 bfd_putl32 (-1, eihd
.alias
);
3183 eiha
= (struct vms_eiha
*)((char *) &eihd
+ PRIV (file_pos
));
3184 bfd_putl32 (PRIV (file_pos
), eihd
.activoff
);
3185 PRIV (file_pos
) += sizeof (struct vms_eiha
);
3187 bfd_putl32 (sizeof (struct vms_eiha
), eiha
->size
);
3188 bfd_putl32 (0, eiha
->spare
);
3189 bfd_putl64 (PRIV (transfer_address
[0]), eiha
->tfradr1
);
3190 bfd_putl64 (PRIV (transfer_address
[1]), eiha
->tfradr2
);
3191 bfd_putl64 (PRIV (transfer_address
[2]), eiha
->tfradr3
);
3192 bfd_putl64 (PRIV (transfer_address
[3]), eiha
->tfradr4
);
3193 bfd_putl64 (0, eiha
->inishr
);
3196 eihi
= (struct vms_eihi
*)((char *) &eihd
+ PRIV (file_pos
));
3197 bfd_putl32 (PRIV (file_pos
), eihd
.imgidoff
);
3198 PRIV (file_pos
) += sizeof (struct vms_eihi
);
3200 bfd_putl32 (EIHI__K_MAJORID
, eihi
->majorid
);
3201 bfd_putl32 (EIHI__K_MINORID
, eihi
->minorid
);
3206 /* Set module name. */
3207 module
= vms_get_module_name (bfd_get_filename (abfd
), TRUE
);
3208 len
= strlen (module
);
3209 if (len
> sizeof (eihi
->imgnam
) - 1)
3210 len
= sizeof (eihi
->imgnam
) - 1;
3211 eihi
->imgnam
[0] = len
;
3212 memcpy (eihi
->imgnam
+ 1, module
, len
);
3220 vms_get_time (&hi
, &lo
);
3221 bfd_putl32 (lo
, eihi
->linktime
+ 0);
3222 bfd_putl32 (hi
, eihi
->linktime
+ 4);
3225 eihi
->linkid
[0] = 0;
3226 eihi
->imgbid
[0] = 0;
3229 dst
= PRIV (dst_section
);
3230 dmt
= bfd_get_section_by_name (abfd
, "$DMT$");
3231 if (dst
!= NULL
&& dst
->size
!= 0)
3233 eihs
= (struct vms_eihs
*)((char *) &eihd
+ PRIV (file_pos
));
3234 bfd_putl32 (PRIV (file_pos
), eihd
.symdbgoff
);
3235 PRIV (file_pos
) += sizeof (struct vms_eihs
);
3237 bfd_putl32 (EIHS__K_MAJORID
, eihs
->majorid
);
3238 bfd_putl32 (EIHS__K_MINORID
, eihs
->minorid
);
3239 bfd_putl32 (0, eihs
->dstvbn
);
3240 bfd_putl32 (0, eihs
->dstsize
);
3241 bfd_putl32 (0, eihs
->gstvbn
);
3242 bfd_putl32 (0, eihs
->gstsize
);
3243 bfd_putl32 (0, eihs
->dmtvbn
);
3244 bfd_putl32 (0, eihs
->dmtsize
);
3247 /* One EISD per section. */
3248 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3250 if (!alpha_vms_create_eisd_for_section (abfd
, sec
))
3254 /* Merge section EIDS which extra ones. */
3255 if (PRIV (eisd_tail
))
3256 PRIV (eisd_tail
)->next
= PRIV (gbl_eisd_head
);
3258 PRIV (eisd_head
) = PRIV (gbl_eisd_head
);
3259 if (PRIV (gbl_eisd_tail
))
3260 PRIV (eisd_tail
) = PRIV (gbl_eisd_tail
);
3262 first_eisd
= PRIV (eisd_head
);
3264 /* Add end of eisd. */
3267 eisd
= bfd_zalloc (abfd
, sizeof (*eisd
));
3270 eisd
->u
.eisd
.majorid
= 0;
3271 eisd
->u
.eisd
.minorid
= 0;
3272 eisd
->u
.eisd
.eisdsize
= 0;
3273 alpha_vms_append_extra_eisd (abfd
, eisd
);
3276 /* Place EISD in the file. */
3277 for (eisd
= first_eisd
; eisd
; eisd
= eisd
->next
)
3279 file_ptr room
= VMS_BLOCK_SIZE
- (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
3281 /* First block is a little bit special: there is a word at the end. */
3282 if (PRIV (file_pos
) < VMS_BLOCK_SIZE
&& room
> 2)
3284 if (room
< eisd
->u
.eisd
.eisdsize
+ EISD__K_LENEND
)
3285 alpha_vms_file_position_block (abfd
);
3287 eisd
->file_pos
= PRIV (file_pos
);
3288 PRIV (file_pos
) += eisd
->u
.eisd
.eisdsize
;
3290 if (eisd
->u
.eisd
.flags
& EISD__M_FIXUPVEC
)
3291 bfd_putl64 (eisd
->u
.eisd
.virt_addr
, eihd
.iafva
);
3294 if (first_eisd
!= NULL
)
3296 bfd_putl32 (first_eisd
->file_pos
, eihd
.isdoff
);
3297 /* Real size of end of eisd marker. */
3298 PRIV (file_pos
) += EISD__K_LENEND
;
3301 bfd_putl32 (PRIV (file_pos
), eihd
.size
);
3302 bfd_putl32 ((PRIV (file_pos
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
3305 /* Place sections. */
3306 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3308 if (!(sec
->flags
& SEC_HAS_CONTENTS
))
3311 eisd
= vms_section_data (sec
)->eisd
;
3313 /* Align on a block. */
3314 alpha_vms_file_position_block (abfd
);
3315 sec
->filepos
= PRIV (file_pos
);
3318 eisd
->u
.eisd
.vbn
= (sec
->filepos
/ VMS_BLOCK_SIZE
) + 1;
3320 PRIV (file_pos
) += sec
->size
;
3324 if (eihs
!= NULL
&& dst
!= NULL
)
3326 bfd_putl32 ((dst
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dstvbn
);
3327 bfd_putl32 (dst
->size
, eihs
->dstsize
);
3331 lnkflags
|= EIHD__M_DBGDMT
;
3332 bfd_putl32 ((dmt
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dmtvbn
);
3333 bfd_putl32 (dmt
->size
, eihs
->dmtsize
);
3335 if (PRIV (gsd_sym_count
) != 0)
3337 alpha_vms_file_position_block (abfd
);
3338 gst_filepos
= PRIV (file_pos
);
3339 bfd_putl32 ((gst_filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->gstvbn
);
3340 bfd_putl32 ((PRIV (gsd_sym_count
) + 4) / 5 + 4, eihs
->gstsize
);
3344 /* Write EISD in hdr. */
3345 for (eisd
= first_eisd
; eisd
&& eisd
->file_pos
< VMS_BLOCK_SIZE
;
3347 alpha_vms_swap_eisd_out
3348 (eisd
, (struct vms_eisd
*)((char *)&eihd
+ eisd
->file_pos
));
3350 /* Write first block. */
3351 bfd_putl32 (lnkflags
, eihd
.lnkflags
);
3352 if (bfd_bwrite (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
3355 /* Write remaining eisd. */
3358 unsigned char blk
[VMS_BLOCK_SIZE
];
3359 struct vms_internal_eisd_map
*next_eisd
;
3361 memset (blk
, 0xff, sizeof (blk
));
3362 while (eisd
!= NULL
)
3364 alpha_vms_swap_eisd_out
3366 (struct vms_eisd
*)(blk
+ (eisd
->file_pos
% VMS_BLOCK_SIZE
)));
3368 next_eisd
= eisd
->next
;
3369 if (next_eisd
== NULL
3370 || (next_eisd
->file_pos
/ VMS_BLOCK_SIZE
3371 != eisd
->file_pos
/ VMS_BLOCK_SIZE
))
3373 if (bfd_bwrite (blk
, sizeof (blk
), abfd
) != sizeof (blk
))
3376 memset (blk
, 0xff, sizeof (blk
));
3382 /* Write sections. */
3383 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3385 unsigned char blk
[VMS_BLOCK_SIZE
];
3388 if (sec
->size
== 0 || !(sec
->flags
& SEC_HAS_CONTENTS
))
3390 if (bfd_bwrite (sec
->contents
, sec
->size
, abfd
) != sec
->size
)
3394 len
= VMS_BLOCK_SIZE
- sec
->size
% VMS_BLOCK_SIZE
;
3395 if (len
!= VMS_BLOCK_SIZE
)
3397 memset (blk
, 0, len
);
3398 if (bfd_bwrite (blk
, len
, abfd
) != len
)
3404 if (gst_filepos
!= 0)
3406 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3409 _bfd_vms_write_emh (abfd
);
3410 _bfd_vms_write_lmn (abfd
, "GNU LD");
3412 /* PSC for the absolute section. */
3413 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3414 _bfd_vms_output_long (recwr
, 0);
3415 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3416 _bfd_vms_output_short (recwr
, 0);
3417 _bfd_vms_output_short (recwr
, EGPS__V_PIC
| EGPS__V_LIB
| EGPS__V_RD
);
3418 _bfd_vms_output_long (recwr
, 0);
3419 _bfd_vms_output_counted (recwr
, ".$$ABS$$.");
3420 _bfd_vms_output_end_subrec (recwr
);
3421 _bfd_vms_output_end (abfd
, recwr
);
3423 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
3425 struct vms_symbol_entry
*sym
= PRIV (syms
)[i
];
3431 _bfd_vms_output_alignment (recwr
, 8);
3432 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3433 _bfd_vms_output_long (recwr
, 0);
3435 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYMG
);
3436 _bfd_vms_output_short (recwr
, 0); /* Data type, alignment. */
3437 _bfd_vms_output_short (recwr
, sym
->flags
);
3439 if (sym
->code_section
)
3440 ep
= alpha_vms_get_sym_value (sym
->code_section
, sym
->code_value
);
3443 BFD_ASSERT (sym
->code_value
== 0);
3446 val
= alpha_vms_get_sym_value (sym
->section
, sym
->value
);
3447 _bfd_vms_output_quad
3448 (recwr
, sym
->typ
== EGSD__C_SYMG
? sym
->symbol_vector
: val
);
3449 _bfd_vms_output_quad (recwr
, ep
);
3450 _bfd_vms_output_quad (recwr
, val
);
3451 _bfd_vms_output_long (recwr
, 0);
3452 _bfd_vms_output_counted (recwr
, sym
->name
);
3453 _bfd_vms_output_end_subrec (recwr
);
3455 _bfd_vms_output_end (abfd
, recwr
);
3458 _bfd_vms_output_end (abfd
, recwr
);
3460 if (!_bfd_vms_write_eeom (abfd
))
3468 /* Write section and symbol directory of bfd abfd. Return FALSE on error. */
3471 _bfd_vms_write_egsd (bfd
*abfd
)
3475 unsigned int symnum
;
3477 flagword new_flags
, old_flags
;
3478 int abs_section_index
= -1;
3479 unsigned int target_index
= 0;
3480 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3482 vms_debug2 ((2, "vms_write_egsd\n"));
3484 /* Egsd is quadword aligned. */
3485 _bfd_vms_output_alignment (recwr
, 8);
3487 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3488 _bfd_vms_output_long (recwr
, 0);
3490 /* Number sections. */
3491 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3493 if (section
->flags
& SEC_DEBUGGING
)
3495 if (!strcmp (section
->name
, ".vmsdebug"))
3497 section
->flags
|= SEC_DEBUGGING
;
3500 section
->target_index
= target_index
++;
3503 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3505 vms_debug2 ((3, "Section #%d %s, %d bytes\n",
3506 section
->target_index
, section
->name
, (int)section
->size
));
3508 /* Don't write out the VMS debug info section since it is in the
3509 ETBT and EDBG sections in etir. */
3510 if (section
->flags
& SEC_DEBUGGING
)
3513 /* 13 bytes egsd, max 31 chars name -> should be 44 bytes. */
3514 if (_bfd_vms_output_check (recwr
, 64) < 0)
3516 _bfd_vms_output_end (abfd
, recwr
);
3517 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3518 _bfd_vms_output_long (recwr
, 0);
3521 /* Don't know if this is necessary for the linker but for now it keeps
3522 vms_slurp_gsd happy. */
3523 sname
= section
->name
;
3526 /* Remove leading dot. */
3528 if ((*sname
== 't') && (strcmp (sname
, "text") == 0))
3529 sname
= EVAX_CODE_NAME
;
3530 else if ((*sname
== 'd') && (strcmp (sname
, "data") == 0))
3531 sname
= EVAX_DATA_NAME
;
3532 else if ((*sname
== 'b') && (strcmp (sname
, "bss") == 0))
3533 sname
= EVAX_BSS_NAME
;
3534 else if ((*sname
== 'l') && (strcmp (sname
, "link") == 0))
3535 sname
= EVAX_LINK_NAME
;
3536 else if ((*sname
== 'r') && (strcmp (sname
, "rdata") == 0))
3537 sname
= EVAX_READONLY_NAME
;
3538 else if ((*sname
== 'l') && (strcmp (sname
, "literal") == 0))
3539 sname
= EVAX_LITERAL_NAME
;
3540 else if ((*sname
== 'l') && (strcmp (sname
, "literals") == 0))
3541 sname
= EVAX_LITERALS_NAME
;
3542 else if ((*sname
== 'c') && (strcmp (sname
, "comm") == 0))
3543 sname
= EVAX_COMMON_NAME
;
3544 else if ((*sname
== 'l') && (strcmp (sname
, "lcomm") == 0))
3545 sname
= EVAX_LOCAL_NAME
;
3548 if (bfd_is_com_section (section
))
3549 new_flags
= (EGPS__V_OVR
| EGPS__V_REL
| EGPS__V_GBL
| EGPS__V_RD
3550 | EGPS__V_WRT
| EGPS__V_NOMOD
| EGPS__V_COM
);
3552 new_flags
= vms_esecflag_by_name (evax_section_flags
, sname
,
3555 /* Modify them as directed. */
3556 if (section
->flags
& SEC_READONLY
)
3557 new_flags
&= ~EGPS__V_WRT
;
3559 new_flags
&= ~vms_section_data (section
)->no_flags
;
3560 new_flags
|= vms_section_data (section
)->flags
;
3562 vms_debug2 ((3, "sec flags %x\n", section
->flags
));
3563 vms_debug2 ((3, "new_flags %x, _raw_size %lu\n",
3564 new_flags
, (unsigned long)section
->size
));
3566 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3567 _bfd_vms_output_short (recwr
, section
->alignment_power
& 0xff);
3568 _bfd_vms_output_short (recwr
, new_flags
);
3569 _bfd_vms_output_long (recwr
, (unsigned long) section
->size
);
3570 _bfd_vms_output_counted (recwr
, sname
);
3571 _bfd_vms_output_end_subrec (recwr
);
3573 /* If the section is an obsolute one, remind its index as it will be
3574 used later for absolute symbols. */
3575 if ((new_flags
& EGPS__V_REL
) == 0 && abs_section_index
< 0)
3576 abs_section_index
= section
->target_index
;
3579 /* Output symbols. */
3580 vms_debug2 ((3, "%d symbols found\n", abfd
->symcount
));
3582 bfd_set_start_address (abfd
, (bfd_vma
) -1);
3584 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3586 symbol
= abfd
->outsymbols
[symnum
];
3587 old_flags
= symbol
->flags
;
3589 /* Work-around a missing feature: consider __main as the main entry
3591 if (symbol
->name
[0] == '_' && strcmp (symbol
->name
, "__main") == 0)
3592 bfd_set_start_address (abfd
, (bfd_vma
)symbol
->value
);
3594 /* Only put in the GSD the global and the undefined symbols. */
3595 if (old_flags
& BSF_FILE
)
3598 if ((old_flags
& BSF_GLOBAL
) == 0 && !bfd_is_und_section (symbol
->section
))
3600 /* If the LIB$INITIIALIZE section is present, add a reference to
3601 LIB$INITIALIZE symbol. FIXME: this should be done explicitely
3602 in the assembly file. */
3603 if (!((old_flags
& BSF_SECTION_SYM
) != 0
3604 && strcmp (symbol
->section
->name
, "LIB$INITIALIZE") == 0))
3608 /* 13 bytes egsd, max 64 chars name -> should be 77 bytes. Add 16 more
3609 bytes for a possible ABS section. */
3610 if (_bfd_vms_output_check (recwr
, 80 + 16) < 0)
3612 _bfd_vms_output_end (abfd
, recwr
);
3613 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3614 _bfd_vms_output_long (recwr
, 0);
3617 if ((old_flags
& BSF_GLOBAL
) != 0
3618 && bfd_is_abs_section (symbol
->section
)
3619 && abs_section_index
<= 0)
3621 /* Create an absolute section if none was defined. It is highly
3622 unlikely that the name $ABS$ clashes with a user defined
3623 non-absolute section name. */
3624 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3625 _bfd_vms_output_short (recwr
, 4);
3626 _bfd_vms_output_short (recwr
, EGPS__V_SHR
);
3627 _bfd_vms_output_long (recwr
, 0);
3628 _bfd_vms_output_counted (recwr
, "$ABS$");
3629 _bfd_vms_output_end_subrec (recwr
);
3631 abs_section_index
= target_index
++;
3634 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYM
);
3636 /* Data type, alignment. */
3637 _bfd_vms_output_short (recwr
, 0);
3641 if (old_flags
& BSF_WEAK
)
3642 new_flags
|= EGSY__V_WEAK
;
3643 if (bfd_is_com_section (symbol
->section
)) /* .comm */
3644 new_flags
|= (EGSY__V_WEAK
| EGSY__V_COMM
);
3646 if (old_flags
& BSF_FUNCTION
)
3648 new_flags
|= EGSY__V_NORM
;
3649 new_flags
|= EGSY__V_REL
;
3651 if (old_flags
& BSF_GLOBAL
)
3653 new_flags
|= EGSY__V_DEF
;
3654 if (!bfd_is_abs_section (symbol
->section
))
3655 new_flags
|= EGSY__V_REL
;
3657 _bfd_vms_output_short (recwr
, new_flags
);
3659 if (old_flags
& BSF_GLOBAL
)
3661 /* Symbol definition. */
3662 bfd_vma code_address
= 0;
3663 unsigned long ca_psindx
= 0;
3664 unsigned long psindx
;
3666 if ((old_flags
& BSF_FUNCTION
) && symbol
->udata
.p
!= NULL
)
3671 ((struct evax_private_udata_struct
*)symbol
->udata
.p
)->enbsym
;
3672 code_address
= sym
->value
;
3673 ca_psindx
= sym
->section
->target_index
;
3675 if (bfd_is_abs_section (symbol
->section
))
3676 psindx
= abs_section_index
;
3678 psindx
= symbol
->section
->target_index
;
3680 _bfd_vms_output_quad (recwr
, symbol
->value
);
3681 _bfd_vms_output_quad (recwr
, code_address
);
3682 _bfd_vms_output_long (recwr
, ca_psindx
);
3683 _bfd_vms_output_long (recwr
, psindx
);
3685 _bfd_vms_output_counted (recwr
, symbol
->name
);
3687 _bfd_vms_output_end_subrec (recwr
);
3690 _bfd_vms_output_alignment (recwr
, 8);
3691 _bfd_vms_output_end (abfd
, recwr
);
3696 /* Write object header for bfd abfd. Return FALSE on error. */
3699 _bfd_vms_write_ehdr (bfd
*abfd
)
3702 unsigned int symnum
;
3703 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3705 vms_debug2 ((2, "vms_write_ehdr (%p)\n", abfd
));
3707 _bfd_vms_output_alignment (recwr
, 2);
3709 _bfd_vms_write_emh (abfd
);
3710 _bfd_vms_write_lmn (abfd
, "GNU AS");
3713 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3714 _bfd_vms_output_short (recwr
, EMH__C_SRC
);
3716 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3718 symbol
= abfd
->outsymbols
[symnum
];
3720 if (symbol
->flags
& BSF_FILE
)
3722 _bfd_vms_output_dump (recwr
, (unsigned char *) symbol
->name
,
3723 (int) strlen (symbol
->name
));
3728 if (symnum
== abfd
->symcount
)
3729 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("noname"));
3731 _bfd_vms_output_end (abfd
, recwr
);
3734 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3735 _bfd_vms_output_short (recwr
, EMH__C_TTL
);
3736 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("TTL"));
3737 _bfd_vms_output_end (abfd
, recwr
);
3740 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3741 _bfd_vms_output_short (recwr
, EMH__C_CPR
);
3742 _bfd_vms_output_dump (recwr
,
3743 (unsigned char *)"GNU BFD ported by Klaus Kämpf 1994-1996",
3745 _bfd_vms_output_end (abfd
, recwr
);
3750 /* Part 4.6, relocations. */
3753 /* WRITE ETIR SECTION
3755 This is still under construction and therefore not documented. */
3757 /* Close the etir/etbt record. */
3760 end_etir_record (bfd
* abfd
)
3762 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3764 _bfd_vms_output_end (abfd
, recwr
);
3768 start_etir_or_etbt_record (bfd
*abfd
, asection
*section
, bfd_vma offset
)
3770 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3772 if (section
->flags
& SEC_DEBUGGING
)
3774 _bfd_vms_output_begin (recwr
, EOBJ__C_ETBT
);
3778 /* Push start offset. */
3779 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3780 _bfd_vms_output_long (recwr
, (unsigned long) 0);
3781 _bfd_vms_output_end_subrec (recwr
);
3784 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_DFLOC
);
3785 _bfd_vms_output_end_subrec (recwr
);
3790 _bfd_vms_output_begin (recwr
, EOBJ__C_ETIR
);
3794 /* Push start offset. */
3795 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3796 _bfd_vms_output_long (recwr
, (unsigned long) section
->target_index
);
3797 _bfd_vms_output_quad (recwr
, offset
);
3798 _bfd_vms_output_end_subrec (recwr
);
3800 /* Start = pop (). */
3801 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_SETRB
);
3802 _bfd_vms_output_end_subrec (recwr
);
3807 /* Output a STO_IMM command for SSIZE bytes of data from CPR at virtual
3808 address VADDR in section specified by SEC_INDEX and NAME. */
3811 sto_imm (bfd
*abfd
, asection
*section
,
3812 bfd_size_type ssize
, unsigned char *cptr
, bfd_vma vaddr
)
3815 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3818 _bfd_vms_debug (8, "sto_imm %d bytes\n", (int) ssize
);
3819 _bfd_hexdump (9, cptr
, (int) ssize
, (int) vaddr
);
3824 /* Try all the rest. */
3827 if (_bfd_vms_output_check (recwr
, size
) < 0)
3829 /* Doesn't fit, split ! */
3830 end_etir_record (abfd
);
3832 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3834 size
= _bfd_vms_output_check (recwr
, 0); /* get max size */
3835 if (size
> ssize
) /* more than what's left ? */
3839 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_IMM
);
3840 _bfd_vms_output_long (recwr
, (unsigned long) (size
));
3841 _bfd_vms_output_dump (recwr
, cptr
, size
);
3842 _bfd_vms_output_end_subrec (recwr
);
3845 _bfd_vms_debug (10, "dumped %d bytes\n", (int) size
);
3846 _bfd_hexdump (10, cptr
, (int) size
, (int) vaddr
);
3856 etir_output_check (bfd
*abfd
, asection
*section
, bfd_vma vaddr
, int checklen
)
3858 if (_bfd_vms_output_check (&PRIV (recwr
), checklen
) < 0)
3860 /* Not enough room in this record. Close it and open a new one. */
3861 end_etir_record (abfd
);
3862 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3866 /* Return whether RELOC must be deferred till the end. */
3869 defer_reloc_p (arelent
*reloc
)
3871 switch (reloc
->howto
->type
)
3884 /* Write section contents for bfd abfd. Return FALSE on error. */
3887 _bfd_vms_write_etir (bfd
* abfd
, int objtype ATTRIBUTE_UNUSED
)
3890 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3892 vms_debug2 ((2, "vms_write_tir (%p, %d)\n", abfd
, objtype
));
3894 _bfd_vms_output_alignment (recwr
, 4);
3896 PRIV (vms_linkage_index
) = 0;
3898 for (section
= abfd
->sections
; section
; section
= section
->next
)
3900 vms_debug2 ((4, "writing %d. section '%s' (%d bytes)\n",
3901 section
->target_index
, section
->name
, (int) (section
->size
)));
3903 if (!(section
->flags
& SEC_HAS_CONTENTS
)
3904 || bfd_is_com_section (section
))
3907 if (!section
->contents
)
3909 bfd_set_error (bfd_error_no_contents
);
3913 start_etir_or_etbt_record (abfd
, section
, 0);
3915 if (section
->flags
& SEC_RELOC
)
3917 bfd_vma curr_addr
= 0;
3918 unsigned char *curr_data
= section
->contents
;
3920 int pass2_needed
= 0;
3921 int pass2_in_progress
= 0;
3924 if (section
->reloc_count
== 0)
3926 (_("SEC_RELOC with no relocs in section %pA"), section
);
3931 int i
= section
->reloc_count
;
3932 arelent
**rptr
= section
->orelocation
;
3933 _bfd_vms_debug (4, "%d relocations:\n", i
);
3936 _bfd_vms_debug (4, "sym %s in sec %s, value %08lx, "
3937 "addr %08lx, off %08lx, len %d: %s\n",
3938 (*(*rptr
)->sym_ptr_ptr
)->name
,
3939 (*(*rptr
)->sym_ptr_ptr
)->section
->name
,
3940 (long) (*(*rptr
)->sym_ptr_ptr
)->value
,
3941 (unsigned long)(*rptr
)->address
,
3942 (unsigned long)(*rptr
)->addend
,
3943 bfd_get_reloc_size ((*rptr
)->howto
),
3944 ( *rptr
)->howto
->name
);
3951 for (irel
= 0; irel
< section
->reloc_count
; irel
++)
3953 struct evax_private_udata_struct
*udata
;
3954 arelent
*rptr
= section
->orelocation
[irel
];
3955 bfd_vma addr
= rptr
->address
;
3956 asymbol
*sym
= *rptr
->sym_ptr_ptr
;
3957 asection
*sec
= sym
->section
;
3958 bfd_boolean defer
= defer_reloc_p (rptr
);
3961 if (pass2_in_progress
)
3963 /* Non-deferred relocs have already been output. */
3969 /* Deferred relocs must be output at the very end. */
3976 /* Regular relocs are intertwined with binary data. */
3977 if (curr_addr
> addr
)
3978 _bfd_error_handler (_("size error in section %pA"),
3980 size
= addr
- curr_addr
;
3981 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
3986 size
= bfd_get_reloc_size (rptr
->howto
);
3988 switch (rptr
->howto
->type
)
3990 case ALPHA_R_IGNORE
:
3993 case ALPHA_R_REFLONG
:
3994 if (bfd_is_und_section (sym
->section
))
3996 bfd_vma addend
= rptr
->addend
;
3997 slen
= strlen ((char *) sym
->name
);
3998 etir_output_check (abfd
, section
, curr_addr
, slen
);
4001 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
4002 _bfd_vms_output_counted (recwr
, sym
->name
);
4003 _bfd_vms_output_end_subrec (recwr
);
4004 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
4005 _bfd_vms_output_long (recwr
, (unsigned long) addend
);
4006 _bfd_vms_output_end_subrec (recwr
);
4007 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
4008 _bfd_vms_output_end_subrec (recwr
);
4009 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
4010 _bfd_vms_output_end_subrec (recwr
);
4014 _bfd_vms_output_begin_subrec
4015 (recwr
, ETIR__C_STO_GBL_LW
);
4016 _bfd_vms_output_counted (recwr
, sym
->name
);
4017 _bfd_vms_output_end_subrec (recwr
);
4020 else if (bfd_is_abs_section (sym
->section
))
4022 etir_output_check (abfd
, section
, curr_addr
, 16);
4023 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
4024 _bfd_vms_output_long (recwr
, (unsigned long) sym
->value
);
4025 _bfd_vms_output_end_subrec (recwr
);
4026 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
4027 _bfd_vms_output_end_subrec (recwr
);
4031 etir_output_check (abfd
, section
, curr_addr
, 32);
4032 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
4033 _bfd_vms_output_long (recwr
,
4034 (unsigned long) sec
->target_index
);
4035 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
4036 _bfd_vms_output_end_subrec (recwr
);
4037 /* ??? Table B-8 of the OpenVMS Linker Utilily Manual
4038 says that we should have a ETIR__C_STO_OFF here.
4039 But the relocation would not be BFD_RELOC_32 then.
4040 This case is very likely unreachable. */
4041 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
4042 _bfd_vms_output_end_subrec (recwr
);
4046 case ALPHA_R_REFQUAD
:
4047 if (bfd_is_und_section (sym
->section
))
4049 bfd_vma addend
= rptr
->addend
;
4050 slen
= strlen ((char *) sym
->name
);
4051 etir_output_check (abfd
, section
, curr_addr
, slen
);
4054 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
4055 _bfd_vms_output_counted (recwr
, sym
->name
);
4056 _bfd_vms_output_end_subrec (recwr
);
4057 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
4058 _bfd_vms_output_quad (recwr
, addend
);
4059 _bfd_vms_output_end_subrec (recwr
);
4060 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
4061 _bfd_vms_output_end_subrec (recwr
);
4062 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
4063 _bfd_vms_output_end_subrec (recwr
);
4067 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_GBL
);
4068 _bfd_vms_output_counted (recwr
, sym
->name
);
4069 _bfd_vms_output_end_subrec (recwr
);
4072 else if (bfd_is_abs_section (sym
->section
))
4074 etir_output_check (abfd
, section
, curr_addr
, 16);
4075 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
4076 _bfd_vms_output_quad (recwr
, sym
->value
);
4077 _bfd_vms_output_end_subrec (recwr
);
4078 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
4079 _bfd_vms_output_end_subrec (recwr
);
4083 etir_output_check (abfd
, section
, curr_addr
, 32);
4084 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
4085 _bfd_vms_output_long (recwr
,
4086 (unsigned long) sec
->target_index
);
4087 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
4088 _bfd_vms_output_end_subrec (recwr
);
4089 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_OFF
);
4090 _bfd_vms_output_end_subrec (recwr
);
4095 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
4098 case ALPHA_R_LINKAGE
:
4100 etir_output_check (abfd
, section
, curr_addr
, 64);
4101 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LP_PSB
);
4102 _bfd_vms_output_long
4103 (recwr
, (unsigned long) rptr
->addend
);
4104 if (rptr
->addend
> PRIV (vms_linkage_index
))
4105 PRIV (vms_linkage_index
) = rptr
->addend
;
4106 _bfd_vms_output_counted (recwr
, sym
->name
);
4107 _bfd_vms_output_byte (recwr
, 0);
4108 _bfd_vms_output_end_subrec (recwr
);
4111 case ALPHA_R_CODEADDR
:
4112 slen
= strlen ((char *) sym
->name
);
4113 etir_output_check (abfd
, section
, curr_addr
, slen
);
4114 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_CA
);
4115 _bfd_vms_output_counted (recwr
, sym
->name
);
4116 _bfd_vms_output_end_subrec (recwr
);
4121 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4122 etir_output_check (abfd
, section
, curr_addr
,
4123 32 + 1 + strlen (udata
->origname
));
4124 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_NOP_GBL
);
4125 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
4126 _bfd_vms_output_long
4127 (recwr
, (unsigned long) section
->target_index
);
4128 _bfd_vms_output_quad (recwr
, rptr
->address
);
4129 _bfd_vms_output_long (recwr
, (unsigned long) 0x47ff041f);
4130 _bfd_vms_output_long
4131 (recwr
, (unsigned long) section
->target_index
);
4132 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4133 _bfd_vms_output_counted (recwr
, udata
->origname
);
4134 _bfd_vms_output_end_subrec (recwr
);
4138 _bfd_error_handler (_("spurious ALPHA_R_BSR reloc"));
4143 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4144 etir_output_check (abfd
, section
, curr_addr
,
4145 32 + 1 + strlen (udata
->origname
));
4146 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LDA_GBL
);
4147 _bfd_vms_output_long
4148 (recwr
, (unsigned long) udata
->lkindex
+ 1);
4149 _bfd_vms_output_long
4150 (recwr
, (unsigned long) section
->target_index
);
4151 _bfd_vms_output_quad (recwr
, rptr
->address
);
4152 _bfd_vms_output_long (recwr
, (unsigned long) 0x237B0000);
4153 _bfd_vms_output_long
4154 (recwr
, (unsigned long) udata
->bsym
->section
->target_index
);
4155 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4156 _bfd_vms_output_counted (recwr
, udata
->origname
);
4157 _bfd_vms_output_end_subrec (recwr
);
4162 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4163 etir_output_check (abfd
, section
, curr_addr
,
4164 32 + 1 + strlen (udata
->origname
));
4165 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_BOH_GBL
);
4166 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
4167 _bfd_vms_output_long
4168 (recwr
, (unsigned long) section
->target_index
);
4169 _bfd_vms_output_quad (recwr
, rptr
->address
);
4170 _bfd_vms_output_long (recwr
, (unsigned long) 0xD3400000);
4171 _bfd_vms_output_long
4172 (recwr
, (unsigned long) section
->target_index
);
4173 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4174 _bfd_vms_output_counted (recwr
, udata
->origname
);
4175 _bfd_vms_output_end_subrec (recwr
);
4179 _bfd_error_handler (_("unhandled relocation %s"),
4186 } /* End of relocs loop. */
4188 if (!pass2_in_progress
)
4190 /* Output rest of section. */
4191 if (curr_addr
> section
->size
)
4193 _bfd_error_handler (_("size error in section %pA"), section
);
4196 size
= section
->size
- curr_addr
;
4197 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
4203 pass2_in_progress
= 1;
4209 else /* (section->flags & SEC_RELOC) */
4210 sto_imm (abfd
, section
, section
->size
, section
->contents
, 0);
4212 end_etir_record (abfd
);
4215 _bfd_vms_output_alignment (recwr
, 2);
4219 /* Write cached information into a file being written, at bfd_close. */
4222 alpha_vms_write_object_contents (bfd
*abfd
)
4224 vms_debug2 ((1, "vms_write_object_contents (%p)\n", abfd
));
4226 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
4228 return alpha_vms_write_exec (abfd
);
4232 if (abfd
->section_count
> 0) /* we have sections */
4234 if (!_bfd_vms_write_ehdr (abfd
))
4236 if (!_bfd_vms_write_egsd (abfd
))
4238 if (!_bfd_vms_write_etir (abfd
, EOBJ__C_ETIR
))
4240 if (!_bfd_vms_write_eeom (abfd
))
4247 /* Debug stuff: nearest line. */
4249 #define SET_MODULE_PARSED(m) \
4250 do { if ((m)->name == NULL) (m)->name = ""; } while (0)
4251 #define IS_MODULE_PARSED(m) ((m)->name != NULL)
4253 /* Build a new module for the specified BFD. */
4255 static struct module
*
4256 new_module (bfd
*abfd
)
4258 struct module
*module
4259 = (struct module
*) bfd_zalloc (abfd
, sizeof (struct module
));
4260 module
->file_table_count
= 16; /* Arbitrary. */
4262 = bfd_malloc (module
->file_table_count
* sizeof (struct fileinfo
));
4266 /* Parse debug info for a module and internalize it. */
4269 parse_module (bfd
*abfd
, struct module
*module
, unsigned char *ptr
,
4272 unsigned char *maxptr
= ptr
+ length
;
4273 unsigned char *src_ptr
, *pcl_ptr
;
4274 unsigned int prev_linum
= 0, curr_linenum
= 0;
4275 bfd_vma prev_pc
= 0, curr_pc
= 0;
4276 struct srecinfo
*curr_srec
, *srec
;
4277 struct lineinfo
*curr_line
, *line
;
4278 struct funcinfo
*funcinfo
;
4280 /* Initialize tables with zero element. */
4281 curr_srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4282 module
->srec_table
= curr_srec
;
4284 curr_line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4285 module
->line_table
= curr_line
;
4287 while (length
== -1 || ptr
< maxptr
)
4289 /* The first byte is not counted in the recorded length. */
4290 int rec_length
= bfd_getl16 (ptr
) + 1;
4291 int rec_type
= bfd_getl16 (ptr
+ 2);
4293 vms_debug2 ((2, "DST record: leng %d, type %d\n", rec_length
, rec_type
));
4295 if (length
== -1 && rec_type
== DST__K_MODEND
)
4302 = _bfd_vms_save_counted_string (abfd
, ptr
+ DST_S_B_MODBEG_NAME
,
4303 maxptr
- (ptr
+ DST_S_B_MODBEG_NAME
));
4310 vms_debug2 ((3, "module: %s\n", module
->name
));
4317 funcinfo
= (struct funcinfo
*)
4318 bfd_zalloc (abfd
, sizeof (struct funcinfo
));
4320 = _bfd_vms_save_counted_string (abfd
, ptr
+ DST_S_B_RTNBEG_NAME
,
4321 maxptr
- (ptr
+ DST_S_B_RTNBEG_NAME
));
4322 funcinfo
->low
= bfd_getl32 (ptr
+ DST_S_L_RTNBEG_ADDRESS
);
4323 funcinfo
->next
= module
->func_table
;
4324 module
->func_table
= funcinfo
;
4326 vms_debug2 ((3, "routine: %s at 0x%lx\n",
4327 funcinfo
->name
, (unsigned long) funcinfo
->low
));
4331 module
->func_table
->high
= module
->func_table
->low
4332 + bfd_getl32 (ptr
+ DST_S_L_RTNEND_SIZE
) - 1;
4334 if (module
->func_table
->high
> module
->high
)
4335 module
->high
= module
->func_table
->high
;
4337 vms_debug2 ((3, "end routine\n"));
4341 vms_debug2 ((3, "prologue\n"));
4345 vms_debug2 ((3, "epilog\n"));
4349 vms_debug2 ((3, "block\n"));
4353 vms_debug2 ((3, "end block\n"));
4357 src_ptr
= ptr
+ DST_S_C_SOURCE_HEADER_SIZE
;
4359 vms_debug2 ((3, "source info\n"));
4361 while (src_ptr
< ptr
+ rec_length
)
4363 int cmd
= src_ptr
[0], cmd_length
, data
;
4367 case DST__K_SRC_DECLFILE
:
4370 = bfd_getl16 (src_ptr
+ DST_S_W_SRC_DF_FILEID
);
4371 char *filename
= _bfd_vms_save_counted_string
4373 src_ptr
+ DST_S_B_SRC_DF_FILENAME
,
4374 ptr
+ rec_length
- (src_ptr
+ DST_S_B_SRC_DF_FILENAME
));
4376 while (fileid
>= module
->file_table_count
)
4378 module
->file_table_count
*= 2;
4380 = bfd_realloc (module
->file_table
,
4381 module
->file_table_count
4382 * sizeof (struct fileinfo
));
4385 module
->file_table
[fileid
].name
= filename
;
4386 module
->file_table
[fileid
].srec
= 1;
4387 cmd_length
= src_ptr
[DST_S_B_SRC_DF_LENGTH
] + 2;
4388 vms_debug2 ((4, "DST_S_C_SRC_DECLFILE: %d, %s\n",
4389 fileid
, module
->file_table
[fileid
].name
));
4393 case DST__K_SRC_DEFLINES_B
:
4394 /* Perform the association and set the next higher index
4396 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4397 srec
= (struct srecinfo
*)
4398 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4399 srec
->line
= curr_srec
->line
+ data
;
4400 srec
->srec
= curr_srec
->srec
+ data
;
4401 srec
->sfile
= curr_srec
->sfile
;
4402 curr_srec
->next
= srec
;
4405 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_B: %d\n", data
));
4408 case DST__K_SRC_DEFLINES_W
:
4409 /* Perform the association and set the next higher index
4411 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4412 srec
= (struct srecinfo
*)
4413 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4414 srec
->line
= curr_srec
->line
+ data
;
4415 srec
->srec
= curr_srec
->srec
+ data
,
4416 srec
->sfile
= curr_srec
->sfile
;
4417 curr_srec
->next
= srec
;
4420 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_W: %d\n", data
));
4423 case DST__K_SRC_INCRLNUM_B
:
4424 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4425 curr_srec
->line
+= data
;
4427 vms_debug2 ((4, "DST_S_C_SRC_INCRLNUM_B: %d\n", data
));
4430 case DST__K_SRC_SETFILE
:
4431 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4432 curr_srec
->sfile
= data
;
4433 curr_srec
->srec
= module
->file_table
[data
].srec
;
4435 vms_debug2 ((4, "DST_S_C_SRC_SETFILE: %d\n", data
));
4438 case DST__K_SRC_SETLNUM_L
:
4439 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4440 curr_srec
->line
= data
;
4442 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_L: %d\n", data
));
4445 case DST__K_SRC_SETLNUM_W
:
4446 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4447 curr_srec
->line
= data
;
4449 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_W: %d\n", data
));
4452 case DST__K_SRC_SETREC_L
:
4453 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4454 curr_srec
->srec
= data
;
4455 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4457 vms_debug2 ((4, "DST_S_C_SRC_SETREC_L: %d\n", data
));
4460 case DST__K_SRC_SETREC_W
:
4461 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4462 curr_srec
->srec
= data
;
4463 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4465 vms_debug2 ((4, "DST_S_C_SRC_SETREC_W: %d\n", data
));
4468 case DST__K_SRC_FORMFEED
:
4470 vms_debug2 ((4, "DST_S_C_SRC_FORMFEED\n"));
4474 _bfd_error_handler (_("unknown source command %d"),
4480 src_ptr
+= cmd_length
;
4484 case DST__K_LINE_NUM
:
4485 pcl_ptr
= ptr
+ DST_S_C_LINE_NUM_HEADER_SIZE
;
4487 vms_debug2 ((3, "line info\n"));
4489 while (pcl_ptr
< ptr
+ rec_length
)
4491 /* The command byte is signed so we must sign-extend it. */
4492 int cmd
= ((signed char *)pcl_ptr
)[0], cmd_length
, data
;
4496 case DST__K_DELTA_PC_W
:
4497 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4501 vms_debug2 ((4, "DST__K_DELTA_PC_W: %d\n", data
));
4504 case DST__K_DELTA_PC_L
:
4505 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4509 vms_debug2 ((4, "DST__K_DELTA_PC_L: %d\n", data
));
4512 case DST__K_INCR_LINUM
:
4513 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4514 curr_linenum
+= data
;
4516 vms_debug2 ((4, "DST__K_INCR_LINUM: %d\n", data
));
4519 case DST__K_INCR_LINUM_W
:
4520 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4521 curr_linenum
+= data
;
4523 vms_debug2 ((4, "DST__K_INCR_LINUM_W: %d\n", data
));
4526 case DST__K_INCR_LINUM_L
:
4527 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4528 curr_linenum
+= data
;
4530 vms_debug2 ((4, "DST__K_INCR_LINUM_L: %d\n", data
));
4533 case DST__K_SET_LINUM_INCR
:
4535 (_("%s not implemented"), "DST__K_SET_LINUM_INCR");
4539 case DST__K_SET_LINUM_INCR_W
:
4541 (_("%s not implemented"), "DST__K_SET_LINUM_INCR_W");
4545 case DST__K_RESET_LINUM_INCR
:
4547 (_("%s not implemented"), "DST__K_RESET_LINUM_INCR");
4551 case DST__K_BEG_STMT_MODE
:
4553 (_("%s not implemented"), "DST__K_BEG_STMT_MODE");
4557 case DST__K_END_STMT_MODE
:
4559 (_("%s not implemented"), "DST__K_END_STMT_MODE");
4563 case DST__K_SET_LINUM_B
:
4564 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4565 curr_linenum
= data
;
4567 vms_debug2 ((4, "DST__K_SET_LINUM_B: %d\n", data
));
4570 case DST__K_SET_LINUM
:
4571 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4572 curr_linenum
= data
;
4574 vms_debug2 ((4, "DST__K_SET_LINE_NUM: %d\n", data
));
4577 case DST__K_SET_LINUM_L
:
4578 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4579 curr_linenum
= data
;
4581 vms_debug2 ((4, "DST__K_SET_LINUM_L: %d\n", data
));
4586 (_("%s not implemented"), "DST__K_SET_PC");
4590 case DST__K_SET_PC_W
:
4592 (_("%s not implemented"), "DST__K_SET_PC_W");
4596 case DST__K_SET_PC_L
:
4598 (_("%s not implemented"), "DST__K_SET_PC_L");
4602 case DST__K_SET_STMTNUM
:
4604 (_("%s not implemented"), "DST__K_SET_STMTNUM");
4609 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4612 vms_debug2 ((4, "DST__K_TERM: %d\n", data
));
4616 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4619 vms_debug2 ((4, "DST__K_TERM_W: %d\n", data
));
4623 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4626 vms_debug2 ((4, "DST__K_TERM_L: %d\n", data
));
4629 case DST__K_SET_ABS_PC
:
4630 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4633 vms_debug2 ((4, "DST__K_SET_ABS_PC: 0x%x\n", data
));
4642 vms_debug2 ((4, "bump pc to 0x%lx and line to %d\n",
4643 (unsigned long)curr_pc
, curr_linenum
));
4647 _bfd_error_handler (_("unknown line command %d"), cmd
);
4653 if ((curr_linenum
!= prev_linum
&& curr_pc
!= prev_pc
)
4655 || cmd
== DST__K_DELTA_PC_L
4656 || cmd
== DST__K_DELTA_PC_W
)
4658 line
= (struct lineinfo
*)
4659 bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4660 line
->address
= curr_pc
;
4661 line
->line
= curr_linenum
;
4663 curr_line
->next
= line
;
4666 prev_linum
= curr_linenum
;
4668 vms_debug2 ((4, "-> correlate pc 0x%lx with line %d\n",
4669 (unsigned long)curr_pc
, curr_linenum
));
4672 pcl_ptr
+= cmd_length
;
4676 case 0x17: /* Undocumented type used by DEC C to declare equates. */
4677 vms_debug2 ((3, "undocumented type 0x17\n"));
4681 vms_debug2 ((3, "ignoring record\n"));
4689 /* Finalize tables with EOL marker. */
4690 srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4691 srec
->line
= (unsigned int) -1;
4692 srec
->srec
= (unsigned int) -1;
4693 curr_srec
->next
= srec
;
4695 line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4696 line
->line
= (unsigned int) -1;
4697 line
->address
= (bfd_vma
) -1;
4698 curr_line
->next
= line
;
4700 /* Advertise that this module has been parsed. This is needed
4701 because parsing can be either performed at module creation
4702 or deferred until debug info is consumed. */
4703 SET_MODULE_PARSED (module
);
4706 /* Build the list of modules for the specified BFD. */
4708 static struct module
*
4709 build_module_list (bfd
*abfd
)
4711 struct module
*module
, *list
= NULL
;
4714 if ((dmt
= bfd_get_section_by_name (abfd
, "$DMT$")))
4716 /* We have a DMT section so this must be an image. Parse the
4717 section and build the list of modules. This is sufficient
4718 since we can compute the start address and the end address
4719 of every module from the section contents. */
4720 bfd_size_type size
= bfd_section_size (dmt
);
4721 unsigned char *ptr
, *end
;
4723 ptr
= (unsigned char *) bfd_alloc (abfd
, size
);
4727 if (! bfd_get_section_contents (abfd
, dmt
, ptr
, 0, size
))
4730 vms_debug2 ((2, "DMT\n"));
4736 /* Each header declares a module with its start offset and size
4737 of debug info in the DST section, as well as the count of
4738 program sections (i.e. address spans) it contains. */
4739 int modbeg
= bfd_getl32 (ptr
+ DBG_S_L_DMT_MODBEG
);
4740 int msize
= bfd_getl32 (ptr
+ DBG_S_L_DST_SIZE
);
4741 int count
= bfd_getl16 (ptr
+ DBG_S_W_DMT_PSECT_COUNT
);
4742 ptr
+= DBG_S_C_DMT_HEADER_SIZE
;
4744 vms_debug2 ((3, "module: modbeg = %d, size = %d, count = %d\n",
4745 modbeg
, msize
, count
));
4747 /* We create a 'module' structure for each program section since
4748 we only support contiguous addresses in a 'module' structure.
4749 As a consequence, the actual debug info in the DST section is
4750 shared and can be parsed multiple times; that doesn't seem to
4751 cause problems in practice. */
4754 int start
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_START
);
4755 int length
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_LENGTH
);
4756 module
= new_module (abfd
);
4757 module
->modbeg
= modbeg
;
4758 module
->size
= msize
;
4759 module
->low
= start
;
4760 module
->high
= start
+ length
;
4761 module
->next
= list
;
4763 ptr
+= DBG_S_C_DMT_PSECT_SIZE
;
4765 vms_debug2 ((4, "section: start = 0x%x, length = %d\n",
4772 /* We don't have a DMT section so this must be an object. Parse
4773 the module right now in order to compute its start address and
4775 void *dst
= PRIV (dst_section
)->contents
;
4780 module
= new_module (abfd
);
4781 parse_module (abfd
, module
, PRIV (dst_section
)->contents
, -1);
4788 /* Calculate and return the name of the source file and the line nearest
4789 to the wanted location in the specified module. */
4792 module_find_nearest_line (bfd
*abfd
, struct module
*module
, bfd_vma addr
,
4793 const char **file
, const char **func
,
4796 struct funcinfo
*funcinfo
;
4797 struct lineinfo
*lineinfo
;
4798 struct srecinfo
*srecinfo
;
4799 bfd_boolean ret
= FALSE
;
4801 /* Parse this module if that was not done at module creation. */
4802 if (! IS_MODULE_PARSED (module
))
4804 unsigned int size
= module
->size
;
4805 unsigned int modbeg
= PRIV (dst_section
)->filepos
+ module
->modbeg
;
4806 unsigned char *buffer
= (unsigned char *) bfd_malloc (module
->size
);
4808 if (bfd_seek (abfd
, modbeg
, SEEK_SET
) != 0
4809 || bfd_bread (buffer
, size
, abfd
) != size
)
4811 bfd_set_error (bfd_error_no_debug_section
);
4815 parse_module (abfd
, module
, buffer
, size
);
4819 /* Find out the function (if any) that contains the address. */
4820 for (funcinfo
= module
->func_table
; funcinfo
; funcinfo
= funcinfo
->next
)
4821 if (addr
>= funcinfo
->low
&& addr
<= funcinfo
->high
)
4823 *func
= funcinfo
->name
;
4828 /* Find out the source file and the line nearest to the address. */
4829 for (lineinfo
= module
->line_table
; lineinfo
; lineinfo
= lineinfo
->next
)
4830 if (lineinfo
->next
&& addr
< lineinfo
->next
->address
)
4832 for (srecinfo
= module
->srec_table
; srecinfo
; srecinfo
= srecinfo
->next
)
4833 if (srecinfo
->next
&& lineinfo
->line
< srecinfo
->next
->line
)
4835 if (srecinfo
->sfile
> 0)
4837 *file
= module
->file_table
[srecinfo
->sfile
].name
;
4838 *line
= srecinfo
->srec
+ lineinfo
->line
- srecinfo
->line
;
4842 *file
= module
->name
;
4843 *line
= lineinfo
->line
;
4854 /* Provided a BFD, a section and an offset into the section, calculate and
4855 return the name of the source file and the line nearest to the wanted
4859 _bfd_vms_find_nearest_line (bfd
*abfd
,
4860 asymbol
**symbols ATTRIBUTE_UNUSED
,
4866 unsigned int *discriminator
)
4868 struct module
*module
;
4870 /* What address are we looking for? */
4871 bfd_vma addr
= section
->vma
+ offset
;
4879 /* We can't do anything if there is no DST (debug symbol table). */
4880 if (PRIV (dst_section
) == NULL
)
4883 /* Create the module list - if not already done. */
4884 if (PRIV (modules
) == NULL
)
4886 PRIV (modules
) = build_module_list (abfd
);
4887 if (PRIV (modules
) == NULL
)
4891 for (module
= PRIV (modules
); module
; module
= module
->next
)
4892 if (addr
>= module
->low
&& addr
<= module
->high
)
4893 return module_find_nearest_line (abfd
, module
, addr
, file
, func
, line
);
4898 /* Canonicalizations. */
4899 /* Set name, value, section and flags of SYM from E. */
4902 alpha_vms_convert_symbol (bfd
*abfd
, struct vms_symbol_entry
*e
, asymbol
*sym
)
4911 flags
= BSF_NO_FLAGS
;
4917 if (e
->flags
& EGSY__V_WEAK
)
4920 if (e
->flags
& EGSY__V_DEF
)
4922 /* Symbol definition. */
4923 flags
|= BSF_GLOBAL
;
4924 if (e
->flags
& EGSY__V_NORM
)
4925 flags
|= BSF_FUNCTION
;
4931 /* Symbol reference. */
4932 sec
= bfd_und_section_ptr
;
4937 /* A universal symbol is by definition global... */
4938 flags
|= BSF_GLOBAL
;
4940 /* ...and dynamic in shared libraries. */
4941 if (abfd
->flags
& DYNAMIC
)
4942 flags
|= BSF_DYNAMIC
;
4944 if (e
->flags
& EGSY__V_WEAK
)
4947 if (!(e
->flags
& EGSY__V_DEF
))
4950 if (e
->flags
& EGSY__V_NORM
)
4951 flags
|= BSF_FUNCTION
;
4954 /* sec = e->section; */
4955 sec
= bfd_abs_section_ptr
;
4970 /* Return the number of bytes required to store a vector of pointers
4971 to asymbols for all the symbols in the BFD abfd, including a
4972 terminal NULL pointer. If there are no symbols in the BFD,
4973 then return 0. If an error occurs, return -1. */
4976 alpha_vms_get_symtab_upper_bound (bfd
*abfd
)
4978 vms_debug2 ((1, "alpha_vms_get_symtab_upper_bound (%p), %d symbols\n",
4979 abfd
, PRIV (gsd_sym_count
)));
4981 return (PRIV (gsd_sym_count
) + 1) * sizeof (asymbol
*);
4984 /* Read the symbols from the BFD abfd, and fills in the vector
4985 location with pointers to the symbols and a trailing NULL.
4987 Return number of symbols read. */
4990 alpha_vms_canonicalize_symtab (bfd
*abfd
, asymbol
**symbols
)
4994 vms_debug2 ((1, "alpha_vms_canonicalize_symtab (%p, <ret>)\n", abfd
));
4996 if (PRIV (csymbols
) == NULL
)
4998 PRIV (csymbols
) = (asymbol
**) bfd_alloc
4999 (abfd
, PRIV (gsd_sym_count
) * sizeof (asymbol
*));
5001 /* Traverse table and fill symbols vector. */
5002 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
5004 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
5007 sym
= bfd_make_empty_symbol (abfd
);
5008 if (sym
== NULL
|| !alpha_vms_convert_symbol (abfd
, e
, sym
))
5010 bfd_release (abfd
, PRIV (csymbols
));
5011 PRIV (csymbols
) = NULL
;
5015 PRIV (csymbols
)[i
] = sym
;
5019 if (symbols
!= NULL
)
5021 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
5022 symbols
[i
] = PRIV (csymbols
)[i
];
5026 return PRIV (gsd_sym_count
);
5029 /* Read and convert relocations from ETIR. We do it once for all sections. */
5032 alpha_vms_slurp_relocs (bfd
*abfd
)
5036 vms_debug2 ((3, "alpha_vms_slurp_relocs\n"));
5038 /* We slurp relocs only once, for all sections. */
5039 if (PRIV (reloc_done
))
5041 PRIV (reloc_done
) = TRUE
;
5043 if (alpha_vms_canonicalize_symtab (abfd
, NULL
) < 0)
5046 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
5051 unsigned char *begin
;
5054 bfd_reloc_code_real_type reloc_code
;
5060 bfd_vma cur_address
;
5062 unsigned char *cur_sym
= NULL
;
5064 bfd_vma cur_addend
= 0;
5066 /* Skip non-ETIR records. */
5067 type
= _bfd_vms_get_object_record (abfd
);
5068 if (type
== EOBJ__C_EEOM
)
5070 if (type
!= EOBJ__C_ETIR
)
5073 begin
= PRIV (recrd
.rec
) + 4;
5074 end
= PRIV (recrd
.rec
) + PRIV (recrd
.rec_size
);
5076 for (ptr
= begin
; ptr
< end
; ptr
+= length
)
5080 cmd
= bfd_getl16 (ptr
);
5081 length
= bfd_getl16 (ptr
+ 2);
5083 cur_address
= vaddr
;
5085 vms_debug2 ((4, "alpha_vms_slurp_relocs: etir %s\n",
5086 _bfd_vms_etir_name (cmd
)));
5090 case ETIR__C_STA_GBL
: /* ALPHA_R_REFLONG und_section, step 1 */
5091 /* ALPHA_R_REFQUAD und_section, step 1 */
5096 case ETIR__C_STA_PQ
: /* ALPHA_R_REF{LONG|QUAD}, others part 1 */
5097 cur_psidx
= bfd_getl32 (ptr
+ 4);
5098 cur_addend
= bfd_getl64 (ptr
+ 8);
5102 case ETIR__C_CTL_SETRB
:
5103 if (prev_cmd
!= ETIR__C_STA_PQ
)
5106 /* xgettext:c-format */
5107 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (prev_cmd
),
5108 _bfd_vms_etir_name (cmd
));
5111 cur_psect
= cur_psidx
;
5117 case ETIR__C_STA_LW
: /* ALPHA_R_REFLONG abs_section, step 1 */
5118 /* ALPHA_R_REFLONG und_section, step 2 */
5121 if (prev_cmd
!= ETIR__C_STA_GBL
)
5124 /* xgettext:c-format */
5125 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
5126 _bfd_vms_etir_name (ETIR__C_STA_LW
));
5130 cur_addend
= bfd_getl32 (ptr
+ 4);
5134 case ETIR__C_STA_QW
: /* ALPHA_R_REFQUAD abs_section, step 1 */
5135 /* ALPHA_R_REFQUAD und_section, step 2 */
5136 if (prev_cmd
!= -1 && prev_cmd
!= ETIR__C_STA_GBL
)
5139 /* xgettext:c-format */
5140 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
5141 _bfd_vms_etir_name (ETIR__C_STA_QW
));
5144 cur_addend
= bfd_getl64 (ptr
+ 4);
5148 case ETIR__C_STO_LW
: /* ALPHA_R_REFLONG und_section, step 4 */
5149 /* ALPHA_R_REFLONG abs_section, step 2 */
5150 /* ALPHA_R_REFLONG others, step 2 */
5151 if (prev_cmd
!= ETIR__C_OPR_ADD
5152 && prev_cmd
!= ETIR__C_STA_LW
5153 && prev_cmd
!= ETIR__C_STA_PQ
)
5155 /* xgettext:c-format */
5156 _bfd_error_handler (_("unknown reloc %s + %s"),
5157 _bfd_vms_etir_name (prev_cmd
),
5158 _bfd_vms_etir_name (ETIR__C_STO_LW
));
5161 reloc_code
= BFD_RELOC_32
;
5164 case ETIR__C_STO_QW
: /* ALPHA_R_REFQUAD und_section, step 4 */
5165 /* ALPHA_R_REFQUAD abs_section, step 2 */
5166 if (prev_cmd
!= ETIR__C_OPR_ADD
&& prev_cmd
!= ETIR__C_STA_QW
)
5168 /* xgettext:c-format */
5169 _bfd_error_handler (_("unknown reloc %s + %s"),
5170 _bfd_vms_etir_name (prev_cmd
),
5171 _bfd_vms_etir_name (ETIR__C_STO_QW
));
5174 reloc_code
= BFD_RELOC_64
;
5177 case ETIR__C_STO_OFF
: /* ALPHA_R_REFQUAD others, step 2 */
5178 if (prev_cmd
!= ETIR__C_STA_PQ
)
5180 /* xgettext:c-format */
5181 _bfd_error_handler (_("unknown reloc %s + %s"),
5182 _bfd_vms_etir_name (prev_cmd
),
5183 _bfd_vms_etir_name (ETIR__C_STO_OFF
));
5186 reloc_code
= BFD_RELOC_64
;
5189 case ETIR__C_OPR_ADD
: /* ALPHA_R_REFLONG und_section, step 3 */
5190 /* ALPHA_R_REFQUAD und_section, step 3 */
5191 if (prev_cmd
!= ETIR__C_STA_LW
&& prev_cmd
!= ETIR__C_STA_QW
)
5193 /* xgettext:c-format */
5194 _bfd_error_handler (_("unknown reloc %s + %s"),
5195 _bfd_vms_etir_name (prev_cmd
),
5196 _bfd_vms_etir_name (ETIR__C_OPR_ADD
));
5199 prev_cmd
= ETIR__C_OPR_ADD
;
5202 case ETIR__C_STO_CA
: /* ALPHA_R_CODEADDR */
5203 reloc_code
= BFD_RELOC_ALPHA_CODEADDR
;
5207 case ETIR__C_STO_GBL
: /* ALPHA_R_REFQUAD und_section */
5208 reloc_code
= BFD_RELOC_64
;
5212 case ETIR__C_STO_GBL_LW
: /* ALPHA_R_REFLONG und_section */
5213 reloc_code
= BFD_RELOC_32
;
5217 case ETIR__C_STC_LP_PSB
: /* ALPHA_R_LINKAGE */
5218 reloc_code
= BFD_RELOC_ALPHA_LINKAGE
;
5222 case ETIR__C_STC_NOP_GBL
: /* ALPHA_R_NOP */
5223 reloc_code
= BFD_RELOC_ALPHA_NOP
;
5226 case ETIR__C_STC_BSR_GBL
: /* ALPHA_R_BSR */
5227 reloc_code
= BFD_RELOC_ALPHA_BSR
;
5230 case ETIR__C_STC_LDA_GBL
: /* ALPHA_R_LDA */
5231 reloc_code
= BFD_RELOC_ALPHA_LDA
;
5234 case ETIR__C_STC_BOH_GBL
: /* ALPHA_R_BOH */
5235 reloc_code
= BFD_RELOC_ALPHA_BOH
;
5239 cur_sym
= ptr
+ 4 + 32;
5240 cur_address
= bfd_getl64 (ptr
+ 4 + 8);
5241 cur_addend
= bfd_getl64 (ptr
+ 4 + 24);
5244 case ETIR__C_STO_IMM
:
5245 vaddr
+= bfd_getl32 (ptr
+ 4);
5249 _bfd_error_handler (_("unknown reloc %s"),
5250 _bfd_vms_etir_name (cmd
));
5256 struct vms_section_data_struct
*vms_sec
;
5260 /* Get section to which the relocation applies. */
5261 if (cur_psect
< 0 || cur_psect
> (int)PRIV (section_count
))
5263 _bfd_error_handler (_("invalid section index in ETIR"));
5267 if (PRIV (sections
) == NULL
)
5269 sec
= PRIV (sections
)[cur_psect
];
5270 if (sec
== bfd_abs_section_ptr
)
5272 _bfd_error_handler (_("relocation for non-REL psect"));
5276 vms_sec
= vms_section_data (sec
);
5278 /* Allocate a reloc entry. */
5279 if (sec
->reloc_count
>= vms_sec
->reloc_max
)
5281 if (vms_sec
->reloc_max
== 0)
5283 vms_sec
->reloc_max
= 64;
5284 sec
->relocation
= bfd_zmalloc
5285 (vms_sec
->reloc_max
* sizeof (arelent
));
5289 vms_sec
->reloc_max
*= 2;
5290 sec
->relocation
= bfd_realloc
5291 (sec
->relocation
, vms_sec
->reloc_max
* sizeof (arelent
));
5294 reloc
= &sec
->relocation
[sec
->reloc_count
];
5297 reloc
->howto
= bfd_reloc_type_lookup (abfd
, reloc_code
);
5299 if (cur_sym
!= NULL
)
5302 unsigned int symlen
= *cur_sym
;
5305 /* Linear search. */
5310 for (j
= 0; j
< PRIV (gsd_sym_count
); j
++)
5311 if (PRIV (syms
)[j
]->namelen
== symlen
5312 && memcmp (PRIV (syms
)[j
]->name
, cur_sym
, symlen
) == 0)
5314 sym
= &PRIV (csymbols
)[j
];
5319 _bfd_error_handler (_("unknown symbol in command %s"),
5320 _bfd_vms_etir_name (cmd
));
5321 reloc
->sym_ptr_ptr
= NULL
;
5324 reloc
->sym_ptr_ptr
= sym
;
5326 else if (cur_psidx
>= 0)
5328 if (PRIV (sections
) == NULL
|| cur_psidx
>= (int) PRIV (section_count
))
5330 reloc
->sym_ptr_ptr
=
5331 PRIV (sections
)[cur_psidx
]->symbol_ptr_ptr
;
5334 reloc
->sym_ptr_ptr
= NULL
;
5336 reloc
->address
= cur_address
;
5337 reloc
->addend
= cur_addend
;
5339 if (reloc_code
== ALPHA_R_LINKAGE
)
5342 size
= bfd_get_reloc_size (reloc
->howto
);
5352 vms_debug2 ((3, "alpha_vms_slurp_relocs: result = TRUE\n"));
5357 /* Return the number of bytes required to store the relocation
5358 information associated with the given section. */
5361 alpha_vms_get_reloc_upper_bound (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*section
)
5363 alpha_vms_slurp_relocs (abfd
);
5365 return (section
->reloc_count
+ 1) * sizeof (arelent
*);
5368 /* Convert relocations from VMS (external) form into BFD internal
5369 form. Return the number of relocations. */
5372 alpha_vms_canonicalize_reloc (bfd
*abfd
, asection
*section
, arelent
**relptr
,
5373 asymbol
**symbols ATTRIBUTE_UNUSED
)
5378 if (!alpha_vms_slurp_relocs (abfd
))
5381 count
= section
->reloc_count
;
5382 tblptr
= section
->relocation
;
5385 *relptr
++ = tblptr
++;
5387 *relptr
= (arelent
*) NULL
;
5388 return section
->reloc_count
;
5391 /* Install a new set of internal relocs. */
5393 #define alpha_vms_set_reloc _bfd_generic_set_reloc
5396 /* This is just copied from ecoff-alpha, needs to be fixed probably. */
5398 /* How to process the various reloc types. */
5400 static bfd_reloc_status_type
5401 reloc_nil (bfd
* abfd ATTRIBUTE_UNUSED
,
5402 arelent
*reloc ATTRIBUTE_UNUSED
,
5403 asymbol
*sym ATTRIBUTE_UNUSED
,
5404 void * data ATTRIBUTE_UNUSED
,
5405 asection
*sec ATTRIBUTE_UNUSED
,
5406 bfd
*output_bfd ATTRIBUTE_UNUSED
,
5407 char **error_message ATTRIBUTE_UNUSED
)
5410 vms_debug (1, "reloc_nil (abfd %p, output_bfd %p)\n", abfd
, output_bfd
);
5411 vms_debug (2, "In section %s, symbol %s\n",
5412 sec
->name
, sym
->name
);
5413 vms_debug (2, "reloc sym %s, addr %08lx, addend %08lx, reloc is a %s\n",
5414 reloc
->sym_ptr_ptr
[0]->name
,
5415 (unsigned long)reloc
->address
,
5416 (unsigned long)reloc
->addend
, reloc
->howto
->name
);
5417 vms_debug (2, "data at %p\n", data
);
5418 /* _bfd_hexdump (2, data, bfd_get_reloc_size (reloc->howto), 0); */
5421 return bfd_reloc_ok
;
5424 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
5425 from smaller values. Start with zero, widen, *then* decrement. */
5426 #define MINUS_ONE (((bfd_vma)0) - 1)
5428 static reloc_howto_type alpha_howto_table
[] =
5430 HOWTO (ALPHA_R_IGNORE
, /* Type. */
5431 0, /* Rightshift. */
5432 0, /* Size (0 = byte, 1 = short, 2 = long). */
5434 TRUE
, /* PC relative. */
5436 complain_overflow_dont
,/* Complain_on_overflow. */
5437 reloc_nil
, /* Special_function. */
5438 "IGNORE", /* Name. */
5439 TRUE
, /* Partial_inplace. */
5440 0, /* Source mask */
5442 TRUE
), /* PC rel offset. */
5444 /* A 64 bit reference to a symbol. */
5445 HOWTO (ALPHA_R_REFQUAD
, /* Type. */
5446 0, /* Rightshift. */
5447 4, /* Size (0 = byte, 1 = short, 2 = long). */
5449 FALSE
, /* PC relative. */
5451 complain_overflow_bitfield
, /* Complain_on_overflow. */
5452 reloc_nil
, /* Special_function. */
5453 "REFQUAD", /* Name. */
5454 TRUE
, /* Partial_inplace. */
5455 MINUS_ONE
, /* Source mask. */
5456 MINUS_ONE
, /* Dest mask. */
5457 FALSE
), /* PC rel offset. */
5459 /* A 21 bit branch. The native assembler generates these for
5460 branches within the text segment, and also fills in the PC
5461 relative offset in the instruction. */
5462 HOWTO (ALPHA_R_BRADDR
, /* Type. */
5463 2, /* Rightshift. */
5464 2, /* Size (0 = byte, 1 = short, 2 = long). */
5466 TRUE
, /* PC relative. */
5468 complain_overflow_signed
, /* Complain_on_overflow. */
5469 reloc_nil
, /* Special_function. */
5470 "BRADDR", /* Name. */
5471 TRUE
, /* Partial_inplace. */
5472 0x1fffff, /* Source mask. */
5473 0x1fffff, /* Dest mask. */
5474 FALSE
), /* PC rel offset. */
5476 /* A hint for a jump to a register. */
5477 HOWTO (ALPHA_R_HINT
, /* Type. */
5478 2, /* Rightshift. */
5479 1, /* Size (0 = byte, 1 = short, 2 = long). */
5481 TRUE
, /* PC relative. */
5483 complain_overflow_dont
,/* Complain_on_overflow. */
5484 reloc_nil
, /* Special_function. */
5486 TRUE
, /* Partial_inplace. */
5487 0x3fff, /* Source mask. */
5488 0x3fff, /* Dest mask. */
5489 FALSE
), /* PC rel offset. */
5491 /* 16 bit PC relative offset. */
5492 HOWTO (ALPHA_R_SREL16
, /* Type. */
5493 0, /* Rightshift. */
5494 1, /* Size (0 = byte, 1 = short, 2 = long). */
5496 TRUE
, /* PC relative. */
5498 complain_overflow_signed
, /* Complain_on_overflow. */
5499 reloc_nil
, /* Special_function. */
5500 "SREL16", /* Name. */
5501 TRUE
, /* Partial_inplace. */
5502 0xffff, /* Source mask. */
5503 0xffff, /* Dest mask. */
5504 FALSE
), /* PC rel offset. */
5506 /* 32 bit PC relative offset. */
5507 HOWTO (ALPHA_R_SREL32
, /* Type. */
5508 0, /* Rightshift. */
5509 2, /* Size (0 = byte, 1 = short, 2 = long). */
5511 TRUE
, /* PC relative. */
5513 complain_overflow_signed
, /* Complain_on_overflow. */
5514 reloc_nil
, /* Special_function. */
5515 "SREL32", /* Name. */
5516 TRUE
, /* Partial_inplace. */
5517 0xffffffff, /* Source mask. */
5518 0xffffffff, /* Dest mask. */
5519 FALSE
), /* PC rel offset. */
5521 /* A 64 bit PC relative offset. */
5522 HOWTO (ALPHA_R_SREL64
, /* Type. */
5523 0, /* Rightshift. */
5524 4, /* Size (0 = byte, 1 = short, 2 = long). */
5526 TRUE
, /* PC relative. */
5528 complain_overflow_signed
, /* Complain_on_overflow. */
5529 reloc_nil
, /* Special_function. */
5530 "SREL64", /* Name. */
5531 TRUE
, /* Partial_inplace. */
5532 MINUS_ONE
, /* Source mask. */
5533 MINUS_ONE
, /* Dest mask. */
5534 FALSE
), /* PC rel offset. */
5536 /* Push a value on the reloc evaluation stack. */
5537 HOWTO (ALPHA_R_OP_PUSH
, /* Type. */
5538 0, /* Rightshift. */
5539 0, /* Size (0 = byte, 1 = short, 2 = long). */
5541 FALSE
, /* PC relative. */
5543 complain_overflow_dont
,/* Complain_on_overflow. */
5544 reloc_nil
, /* Special_function. */
5545 "OP_PUSH", /* Name. */
5546 FALSE
, /* Partial_inplace. */
5547 0, /* Source mask. */
5549 FALSE
), /* PC rel offset. */
5551 /* Store the value from the stack at the given address. Store it in
5552 a bitfield of size r_size starting at bit position r_offset. */
5553 HOWTO (ALPHA_R_OP_STORE
, /* Type. */
5554 0, /* Rightshift. */
5555 4, /* Size (0 = byte, 1 = short, 2 = long). */
5557 FALSE
, /* PC relative. */
5559 complain_overflow_dont
,/* Complain_on_overflow. */
5560 reloc_nil
, /* Special_function. */
5561 "OP_STORE", /* Name. */
5562 FALSE
, /* Partial_inplace. */
5563 0, /* Source mask. */
5564 MINUS_ONE
, /* Dest mask. */
5565 FALSE
), /* PC rel offset. */
5567 /* Subtract the reloc address from the value on the top of the
5568 relocation stack. */
5569 HOWTO (ALPHA_R_OP_PSUB
, /* Type. */
5570 0, /* Rightshift. */
5571 0, /* Size (0 = byte, 1 = short, 2 = long). */
5573 FALSE
, /* PC relative. */
5575 complain_overflow_dont
,/* Complain_on_overflow. */
5576 reloc_nil
, /* Special_function. */
5577 "OP_PSUB", /* Name. */
5578 FALSE
, /* Partial_inplace. */
5579 0, /* Source mask. */
5581 FALSE
), /* PC rel offset. */
5583 /* Shift the value on the top of the relocation stack right by the
5585 HOWTO (ALPHA_R_OP_PRSHIFT
, /* Type. */
5586 0, /* Rightshift. */
5587 0, /* Size (0 = byte, 1 = short, 2 = long). */
5589 FALSE
, /* PC relative. */
5591 complain_overflow_dont
,/* Complain_on_overflow. */
5592 reloc_nil
, /* Special_function. */
5593 "OP_PRSHIFT", /* Name. */
5594 FALSE
, /* Partial_inplace. */
5595 0, /* Source mask. */
5597 FALSE
), /* PC rel offset. */
5599 /* Hack. Linkage is done by linker. */
5600 HOWTO (ALPHA_R_LINKAGE
, /* Type. */
5601 0, /* Rightshift. */
5602 0, /* Size (0 = byte, 1 = short, 2 = long). */
5604 FALSE
, /* PC relative. */
5606 complain_overflow_dont
,/* Complain_on_overflow. */
5607 reloc_nil
, /* Special_function. */
5608 "LINKAGE", /* Name. */
5609 FALSE
, /* Partial_inplace. */
5610 0, /* Source mask. */
5612 FALSE
), /* PC rel offset. */
5614 /* A 32 bit reference to a symbol. */
5615 HOWTO (ALPHA_R_REFLONG
, /* Type. */
5616 0, /* Rightshift. */
5617 2, /* Size (0 = byte, 1 = short, 2 = long). */
5619 FALSE
, /* PC relative. */
5621 complain_overflow_bitfield
, /* Complain_on_overflow. */
5622 reloc_nil
, /* Special_function. */
5623 "REFLONG", /* Name. */
5624 TRUE
, /* Partial_inplace. */
5625 0xffffffff, /* Source mask. */
5626 0xffffffff, /* Dest mask. */
5627 FALSE
), /* PC rel offset. */
5629 /* A 64 bit reference to a procedure, written as 32 bit value. */
5630 HOWTO (ALPHA_R_CODEADDR
, /* Type. */
5631 0, /* Rightshift. */
5632 4, /* Size (0 = byte, 1 = short, 2 = long). */
5634 FALSE
, /* PC relative. */
5636 complain_overflow_signed
,/* Complain_on_overflow. */
5637 reloc_nil
, /* Special_function. */
5638 "CODEADDR", /* Name. */
5639 FALSE
, /* Partial_inplace. */
5640 0xffffffff, /* Source mask. */
5641 0xffffffff, /* Dest mask. */
5642 FALSE
), /* PC rel offset. */
5644 HOWTO (ALPHA_R_NOP
, /* Type. */
5645 0, /* Rightshift. */
5646 3, /* Size (0 = byte, 1 = short, 2 = long). */
5648 /* The following value must match that of ALPHA_R_BSR/ALPHA_R_BOH
5649 because the calculations for the 3 relocations are the same.
5650 See B.4.5.2 of the OpenVMS Linker Utility Manual. */
5651 TRUE
, /* PC relative. */
5653 complain_overflow_dont
,/* Complain_on_overflow. */
5654 reloc_nil
, /* Special_function. */
5656 FALSE
, /* Partial_inplace. */
5657 0xffffffff, /* Source mask. */
5658 0xffffffff, /* Dest mask. */
5659 FALSE
), /* PC rel offset. */
5661 HOWTO (ALPHA_R_BSR
, /* Type. */
5662 0, /* Rightshift. */
5663 3, /* Size (0 = byte, 1 = short, 2 = long). */
5665 TRUE
, /* PC relative. */
5667 complain_overflow_dont
,/* Complain_on_overflow. */
5668 reloc_nil
, /* Special_function. */
5670 FALSE
, /* Partial_inplace. */
5671 0xffffffff, /* Source mask. */
5672 0xffffffff, /* Dest mask. */
5673 FALSE
), /* PC rel offset. */
5675 HOWTO (ALPHA_R_LDA
, /* Type. */
5676 0, /* Rightshift. */
5677 3, /* Size (0 = byte, 1 = short, 2 = long). */
5679 FALSE
, /* PC relative. */
5681 complain_overflow_dont
,/* Complain_on_overflow. */
5682 reloc_nil
, /* Special_function. */
5684 FALSE
, /* Partial_inplace. */
5685 0xffffffff, /* Source mask. */
5686 0xffffffff, /* Dest mask. */
5687 FALSE
), /* PC rel offset. */
5689 HOWTO (ALPHA_R_BOH
, /* Type. */
5690 0, /* Rightshift. */
5691 3, /* Size (0 = byte, 1 = short, 2 = long, 3 = nil). */
5693 TRUE
, /* PC relative. */
5695 complain_overflow_dont
,/* Complain_on_overflow. */
5696 reloc_nil
, /* Special_function. */
5698 FALSE
, /* Partial_inplace. */
5699 0xffffffff, /* Source mask. */
5700 0xffffffff, /* Dest mask. */
5701 FALSE
), /* PC rel offset. */
5704 /* Return a pointer to a howto structure which, when invoked, will perform
5705 the relocation code on data from the architecture noted. */
5707 static reloc_howto_type
*
5708 alpha_vms_bfd_reloc_type_lookup (bfd
* abfd ATTRIBUTE_UNUSED
,
5709 bfd_reloc_code_real_type code
)
5713 vms_debug2 ((1, "vms_bfd_reloc_type_lookup (%p, %d)\t", abfd
, code
));
5717 case BFD_RELOC_16
: alpha_type
= ALPHA_R_SREL16
; break;
5718 case BFD_RELOC_32
: alpha_type
= ALPHA_R_REFLONG
; break;
5719 case BFD_RELOC_64
: alpha_type
= ALPHA_R_REFQUAD
; break;
5720 case BFD_RELOC_CTOR
: alpha_type
= ALPHA_R_REFQUAD
; break;
5721 case BFD_RELOC_23_PCREL_S2
: alpha_type
= ALPHA_R_BRADDR
; break;
5722 case BFD_RELOC_ALPHA_HINT
: alpha_type
= ALPHA_R_HINT
; break;
5723 case BFD_RELOC_16_PCREL
: alpha_type
= ALPHA_R_SREL16
; break;
5724 case BFD_RELOC_32_PCREL
: alpha_type
= ALPHA_R_SREL32
; break;
5725 case BFD_RELOC_64_PCREL
: alpha_type
= ALPHA_R_SREL64
; break;
5726 case BFD_RELOC_ALPHA_LINKAGE
: alpha_type
= ALPHA_R_LINKAGE
; break;
5727 case BFD_RELOC_ALPHA_CODEADDR
: alpha_type
= ALPHA_R_CODEADDR
; break;
5728 case BFD_RELOC_ALPHA_NOP
: alpha_type
= ALPHA_R_NOP
; break;
5729 case BFD_RELOC_ALPHA_BSR
: alpha_type
= ALPHA_R_BSR
; break;
5730 case BFD_RELOC_ALPHA_LDA
: alpha_type
= ALPHA_R_LDA
; break;
5731 case BFD_RELOC_ALPHA_BOH
: alpha_type
= ALPHA_R_BOH
; break;
5733 _bfd_error_handler (_("reloc (%d) is *UNKNOWN*"), code
);
5736 vms_debug2 ((2, "reloc is %s\n", alpha_howto_table
[alpha_type
].name
));
5737 return & alpha_howto_table
[alpha_type
];
5740 static reloc_howto_type
*
5741 alpha_vms_bfd_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
5747 i
< sizeof (alpha_howto_table
) / sizeof (alpha_howto_table
[0]);
5749 if (alpha_howto_table
[i
].name
!= NULL
5750 && strcasecmp (alpha_howto_table
[i
].name
, r_name
) == 0)
5751 return &alpha_howto_table
[i
];
5757 alpha_vms_get_synthetic_symtab (bfd
*abfd
,
5758 long symcount ATTRIBUTE_UNUSED
,
5759 asymbol
**usyms ATTRIBUTE_UNUSED
,
5760 long dynsymcount ATTRIBUTE_UNUSED
,
5761 asymbol
**dynsyms ATTRIBUTE_UNUSED
,
5768 syms
= (asymbol
*) bfd_malloc (PRIV (norm_sym_count
) * sizeof (asymbol
));
5773 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
5775 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
5786 flags
= BSF_LOCAL
| BSF_SYNTHETIC
;
5793 if ((e
->flags
& EGSY__V_DEF
) && (e
->flags
& EGSY__V_NORM
))
5795 value
= e
->code_value
;
5796 sec
= e
->code_section
;
5807 sname
= bfd_alloc (abfd
, l
+ 5);
5810 memcpy (sname
, name
, l
);
5811 memcpy (sname
+ l
, "..en", 5);
5818 sym
->udata
.p
= NULL
;
5827 vms_time_to_str (unsigned char *buf
)
5829 time_t t
= vms_rawtime_to_time_t (buf
);
5830 char *res
= ctime (&t
);
5833 res
= "*invalid time*";
5840 evax_bfd_print_emh (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5842 struct vms_emh_common
*emh
= (struct vms_emh_common
*)rec
;
5843 unsigned int subtype
;
5846 subtype
= (unsigned) bfd_getl16 (emh
->subtyp
);
5848 /* xgettext:c-format */
5849 fprintf (file
, _(" EMH %u (len=%u): "), subtype
, rec_len
);
5851 /* PR 21618: Check for invalid lengths. */
5852 if (rec_len
< sizeof (* emh
))
5854 fprintf (file
, _(" Error: The length is less than the length of an EMH record\n"));
5857 extra
= rec_len
- sizeof (struct vms_emh_common
);
5863 struct vms_emh_mhd
*mhd
= (struct vms_emh_mhd
*) rec
;
5865 const char * nextname
;
5866 const char * maxname
;
5868 /* PR 21840: Check for invalid lengths. */
5869 if (rec_len
< sizeof (* mhd
))
5871 fprintf (file
, _(" Error: The record length is less than the size of an EMH_MHD record\n"));
5874 fprintf (file
, _("Module header\n"));
5875 fprintf (file
, _(" structure level: %u\n"), mhd
->strlvl
);
5876 fprintf (file
, _(" max record size: %u\n"),
5877 (unsigned) bfd_getl32 (mhd
->recsiz
));
5878 name
= (char *)(mhd
+ 1);
5879 maxname
= (char *) rec
+ rec_len
;
5880 if (name
> maxname
- 2)
5882 fprintf (file
, _(" Error: The module name is missing\n"));
5885 nextname
= name
+ name
[0] + 1;
5886 if (nextname
>= maxname
)
5888 fprintf (file
, _(" Error: The module name is too long\n"));
5891 fprintf (file
, _(" module name : %.*s\n"), name
[0], name
+ 1);
5893 if (name
> maxname
- 2)
5895 fprintf (file
, _(" Error: The module version is missing\n"));
5898 nextname
= name
+ name
[0] + 1;
5899 if (nextname
>= maxname
)
5901 fprintf (file
, _(" Error: The module version is too long\n"));
5904 fprintf (file
, _(" module version : %.*s\n"), name
[0], name
+ 1);
5906 if ((maxname
- name
) < 17 && maxname
[-1] != 0)
5907 fprintf (file
, _(" Error: The compile date is truncated\n"));
5909 fprintf (file
, _(" compile date : %.17s\n"), name
);
5914 fprintf (file
, _("Language Processor Name\n"));
5915 fprintf (file
, _(" language name: %.*s\n"), extra
, (char *)(emh
+ 1));
5919 fprintf (file
, _("Source Files Header\n"));
5920 fprintf (file
, _(" file: %.*s\n"), extra
, (char *)(emh
+ 1));
5924 fprintf (file
, _("Title Text Header\n"));
5925 fprintf (file
, _(" title: %.*s\n"), extra
, (char *)(emh
+ 1));
5929 fprintf (file
, _("Copyright Header\n"));
5930 fprintf (file
, _(" copyright: %.*s\n"), extra
, (char *)(emh
+ 1));
5934 fprintf (file
, _("unhandled emh subtype %u\n"), subtype
);
5940 evax_bfd_print_eeom (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5942 struct vms_eeom
*eeom
= (struct vms_eeom
*)rec
;
5944 fprintf (file
, _(" EEOM (len=%u):\n"), rec_len
);
5946 /* PR 21618: Check for invalid lengths. */
5947 if (rec_len
< sizeof (* eeom
))
5949 fprintf (file
, _(" Error: The length is less than the length of an EEOM record\n"));
5953 fprintf (file
, _(" number of cond linkage pairs: %u\n"),
5954 (unsigned)bfd_getl32 (eeom
->total_lps
));
5955 fprintf (file
, _(" completion code: %u\n"),
5956 (unsigned)bfd_getl16 (eeom
->comcod
));
5959 fprintf (file
, _(" transfer addr flags: 0x%02x\n"), eeom
->tfrflg
);
5960 fprintf (file
, _(" transfer addr psect: %u\n"),
5961 (unsigned)bfd_getl32 (eeom
->psindx
));
5962 fprintf (file
, _(" transfer address : 0x%08x\n"),
5963 (unsigned)bfd_getl32 (eeom
->tfradr
));
5968 exav_bfd_print_egsy_flags (unsigned int flags
, FILE *file
)
5970 if (flags
& EGSY__V_WEAK
)
5971 fputs (_(" WEAK"), file
);
5972 if (flags
& EGSY__V_DEF
)
5973 fputs (_(" DEF"), file
);
5974 if (flags
& EGSY__V_UNI
)
5975 fputs (_(" UNI"), file
);
5976 if (flags
& EGSY__V_REL
)
5977 fputs (_(" REL"), file
);
5978 if (flags
& EGSY__V_COMM
)
5979 fputs (_(" COMM"), file
);
5980 if (flags
& EGSY__V_VECEP
)
5981 fputs (_(" VECEP"), file
);
5982 if (flags
& EGSY__V_NORM
)
5983 fputs (_(" NORM"), file
);
5984 if (flags
& EGSY__V_QUAD_VAL
)
5985 fputs (_(" QVAL"), file
);
5989 evax_bfd_print_egsd_flags (FILE *file
, unsigned int flags
)
5991 if (flags
& EGPS__V_PIC
)
5992 fputs (_(" PIC"), file
);
5993 if (flags
& EGPS__V_LIB
)
5994 fputs (_(" LIB"), file
);
5995 if (flags
& EGPS__V_OVR
)
5996 fputs (_(" OVR"), file
);
5997 if (flags
& EGPS__V_REL
)
5998 fputs (_(" REL"), file
);
5999 if (flags
& EGPS__V_GBL
)
6000 fputs (_(" GBL"), file
);
6001 if (flags
& EGPS__V_SHR
)
6002 fputs (_(" SHR"), file
);
6003 if (flags
& EGPS__V_EXE
)
6004 fputs (_(" EXE"), file
);
6005 if (flags
& EGPS__V_RD
)
6006 fputs (_(" RD"), file
);
6007 if (flags
& EGPS__V_WRT
)
6008 fputs (_(" WRT"), file
);
6009 if (flags
& EGPS__V_VEC
)
6010 fputs (_(" VEC"), file
);
6011 if (flags
& EGPS__V_NOMOD
)
6012 fputs (_(" NOMOD"), file
);
6013 if (flags
& EGPS__V_COM
)
6014 fputs (_(" COM"), file
);
6015 if (flags
& EGPS__V_ALLOC_64BIT
)
6016 fputs (_(" 64B"), file
);
6020 evax_bfd_print_egsd (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
6022 unsigned int off
= sizeof (struct vms_egsd
);
6025 fprintf (file
, _(" EGSD (len=%u):\n"), rec_len
);
6028 for (off
= sizeof (struct vms_egsd
); off
< rec_len
; )
6030 struct vms_egsd_entry
*e
= (struct vms_egsd_entry
*)(rec
+ off
);
6034 type
= (unsigned)bfd_getl16 (e
->gsdtyp
);
6035 len
= (unsigned)bfd_getl16 (e
->gsdsiz
);
6037 /* xgettext:c-format */
6038 fprintf (file
, _(" EGSD entry %2u (type: %u, len: %u): "),
6042 if (off
+ len
> rec_len
|| off
+ len
< off
)
6044 fprintf (file
, _(" Error: length larger than remaining space in record\n"));
6052 struct vms_egps
*egps
= (struct vms_egps
*)e
;
6053 unsigned int flags
= bfd_getl16 (egps
->flags
);
6056 fprintf (file
, _("PSC - Program section definition\n"));
6057 fprintf (file
, _(" alignment : 2**%u\n"), egps
->align
);
6058 fprintf (file
, _(" flags : 0x%04x"), flags
);
6059 evax_bfd_print_egsd_flags (file
, flags
);
6061 l
= bfd_getl32 (egps
->alloc
);
6062 fprintf (file
, _(" alloc (len): %u (0x%08x)\n"), l
, l
);
6063 fprintf (file
, _(" name : %.*s\n"),
6064 egps
->namlng
, egps
->name
);
6069 struct vms_esgps
*esgps
= (struct vms_esgps
*)e
;
6070 unsigned int flags
= bfd_getl16 (esgps
->flags
);
6073 fprintf (file
, _("SPSC - Shared Image Program section def\n"));
6074 fprintf (file
, _(" alignment : 2**%u\n"), esgps
->align
);
6075 fprintf (file
, _(" flags : 0x%04x"), flags
);
6076 evax_bfd_print_egsd_flags (file
, flags
);
6078 l
= bfd_getl32 (esgps
->alloc
);
6079 fprintf (file
, _(" alloc (len) : %u (0x%08x)\n"), l
, l
);
6080 fprintf (file
, _(" image offset : 0x%08x\n"),
6081 (unsigned int)bfd_getl32 (esgps
->base
));
6082 fprintf (file
, _(" symvec offset : 0x%08x\n"),
6083 (unsigned int)bfd_getl32 (esgps
->value
));
6084 fprintf (file
, _(" name : %.*s\n"),
6085 esgps
->namlng
, esgps
->name
);
6090 struct vms_egsy
*egsy
= (struct vms_egsy
*)e
;
6091 unsigned int flags
= bfd_getl16 (egsy
->flags
);
6093 if (flags
& EGSY__V_DEF
)
6095 struct vms_esdf
*esdf
= (struct vms_esdf
*)e
;
6097 fprintf (file
, _("SYM - Global symbol definition\n"));
6098 fprintf (file
, _(" flags: 0x%04x"), flags
);
6099 exav_bfd_print_egsy_flags (flags
, file
);
6101 fprintf (file
, _(" psect offset: 0x%08x\n"),
6102 (unsigned)bfd_getl32 (esdf
->value
));
6103 if (flags
& EGSY__V_NORM
)
6105 fprintf (file
, _(" code address: 0x%08x\n"),
6106 (unsigned)bfd_getl32 (esdf
->code_address
));
6107 fprintf (file
, _(" psect index for entry point : %u\n"),
6108 (unsigned)bfd_getl32 (esdf
->ca_psindx
));
6110 fprintf (file
, _(" psect index : %u\n"),
6111 (unsigned)bfd_getl32 (esdf
->psindx
));
6112 fprintf (file
, _(" name : %.*s\n"),
6113 esdf
->namlng
, esdf
->name
);
6117 struct vms_esrf
*esrf
= (struct vms_esrf
*)e
;
6119 fprintf (file
, _("SYM - Global symbol reference\n"));
6120 fprintf (file
, _(" name : %.*s\n"),
6121 esrf
->namlng
, esrf
->name
);
6127 struct vms_eidc
*eidc
= (struct vms_eidc
*)e
;
6128 unsigned int flags
= bfd_getl32 (eidc
->flags
);
6131 fprintf (file
, _("IDC - Ident Consistency check\n"));
6132 fprintf (file
, _(" flags : 0x%08x"), flags
);
6133 if (flags
& EIDC__V_BINIDENT
)
6134 fputs (" BINDENT", file
);
6136 fprintf (file
, _(" id match : %x\n"),
6137 (flags
>> EIDC__V_IDMATCH_SH
) & EIDC__V_IDMATCH_MASK
);
6138 fprintf (file
, _(" error severity: %x\n"),
6139 (flags
>> EIDC__V_ERRSEV_SH
) & EIDC__V_ERRSEV_MASK
);
6141 fprintf (file
, _(" entity name : %.*s\n"), p
[0], p
+ 1);
6143 fprintf (file
, _(" object name : %.*s\n"), p
[0], p
+ 1);
6145 if (flags
& EIDC__V_BINIDENT
)
6146 fprintf (file
, _(" binary ident : 0x%08x\n"),
6147 (unsigned)bfd_getl32 (p
+ 1));
6149 fprintf (file
, _(" ascii ident : %.*s\n"), p
[0], p
+ 1);
6154 struct vms_egst
*egst
= (struct vms_egst
*)e
;
6155 unsigned int flags
= bfd_getl16 (egst
->header
.flags
);
6157 fprintf (file
, _("SYMG - Universal symbol definition\n"));
6158 fprintf (file
, _(" flags: 0x%04x"), flags
);
6159 exav_bfd_print_egsy_flags (flags
, file
);
6161 fprintf (file
, _(" symbol vector offset: 0x%08x\n"),
6162 (unsigned)bfd_getl32 (egst
->value
));
6163 fprintf (file
, _(" entry point: 0x%08x\n"),
6164 (unsigned)bfd_getl32 (egst
->lp_1
));
6165 fprintf (file
, _(" proc descr : 0x%08x\n"),
6166 (unsigned)bfd_getl32 (egst
->lp_2
));
6167 fprintf (file
, _(" psect index: %u\n"),
6168 (unsigned)bfd_getl32 (egst
->psindx
));
6169 fprintf (file
, _(" name : %.*s\n"),
6170 egst
->namlng
, egst
->name
);
6175 struct vms_esdfv
*esdfv
= (struct vms_esdfv
*)e
;
6176 unsigned int flags
= bfd_getl16 (esdfv
->flags
);
6178 fprintf (file
, _("SYMV - Vectored symbol definition\n"));
6179 fprintf (file
, _(" flags: 0x%04x"), flags
);
6180 exav_bfd_print_egsy_flags (flags
, file
);
6182 fprintf (file
, _(" vector : 0x%08x\n"),
6183 (unsigned)bfd_getl32 (esdfv
->vector
));
6184 fprintf (file
, _(" psect offset: %u\n"),
6185 (unsigned)bfd_getl32 (esdfv
->value
));
6186 fprintf (file
, _(" psect index : %u\n"),
6187 (unsigned)bfd_getl32 (esdfv
->psindx
));
6188 fprintf (file
, _(" name : %.*s\n"),
6189 esdfv
->namlng
, esdfv
->name
);
6194 struct vms_esdfm
*esdfm
= (struct vms_esdfm
*)e
;
6195 unsigned int flags
= bfd_getl16 (esdfm
->flags
);
6197 fprintf (file
, _("SYMM - Global symbol definition with version\n"));
6198 fprintf (file
, _(" flags: 0x%04x"), flags
);
6199 exav_bfd_print_egsy_flags (flags
, file
);
6201 fprintf (file
, _(" version mask: 0x%08x\n"),
6202 (unsigned)bfd_getl32 (esdfm
->version_mask
));
6203 fprintf (file
, _(" psect offset: %u\n"),
6204 (unsigned)bfd_getl32 (esdfm
->value
));
6205 fprintf (file
, _(" psect index : %u\n"),
6206 (unsigned)bfd_getl32 (esdfm
->psindx
));
6207 fprintf (file
, _(" name : %.*s\n"),
6208 esdfm
->namlng
, esdfm
->name
);
6212 fprintf (file
, _("unhandled egsd entry type %u\n"), type
);
6220 evax_bfd_print_hex (FILE *file
, const char *pfx
,
6221 const unsigned char *buf
, unsigned int len
)
6227 for (i
= 0; i
< len
; i
++)
6231 fprintf (file
, " %02x", buf
[i
]);
6244 evax_bfd_print_etir_stc_ir (FILE *file
, const unsigned char *buf
, int is_ps
)
6246 /* xgettext:c-format */
6247 fprintf (file
, _(" linkage index: %u, replacement insn: 0x%08x\n"),
6248 (unsigned)bfd_getl32 (buf
),
6249 (unsigned)bfd_getl32 (buf
+ 16));
6250 /* xgettext:c-format */
6251 fprintf (file
, _(" psect idx 1: %u, offset 1: 0x%08x %08x\n"),
6252 (unsigned)bfd_getl32 (buf
+ 4),
6253 (unsigned)bfd_getl32 (buf
+ 12),
6254 (unsigned)bfd_getl32 (buf
+ 8));
6255 /* xgettext:c-format */
6256 fprintf (file
, _(" psect idx 2: %u, offset 2: 0x%08x %08x\n"),
6257 (unsigned)bfd_getl32 (buf
+ 20),
6258 (unsigned)bfd_getl32 (buf
+ 28),
6259 (unsigned)bfd_getl32 (buf
+ 24));
6261 /* xgettext:c-format */
6262 fprintf (file
, _(" psect idx 3: %u, offset 3: 0x%08x %08x\n"),
6263 (unsigned)bfd_getl32 (buf
+ 32),
6264 (unsigned)bfd_getl32 (buf
+ 40),
6265 (unsigned)bfd_getl32 (buf
+ 36));
6267 fprintf (file
, _(" global name: %.*s\n"), buf
[32], buf
+ 33);
6271 evax_bfd_print_etir (FILE *file
, const char *name
,
6272 unsigned char *rec
, unsigned int rec_len
)
6274 unsigned int off
= sizeof (struct vms_egsd
);
6275 unsigned int sec_len
= 0;
6277 /* xgettext:c-format */
6278 fprintf (file
, _(" %s (len=%u+%u):\n"), name
,
6279 (unsigned)(rec_len
- sizeof (struct vms_eobjrec
)),
6280 (unsigned)sizeof (struct vms_eobjrec
));
6282 for (off
= sizeof (struct vms_eobjrec
); off
< rec_len
; )
6284 struct vms_etir
*etir
= (struct vms_etir
*)(rec
+ off
);
6289 type
= bfd_getl16 (etir
->rectyp
);
6290 size
= bfd_getl16 (etir
->size
);
6291 buf
= rec
+ off
+ sizeof (struct vms_etir
);
6293 if (off
+ size
> rec_len
|| off
+ size
< off
)
6295 fprintf (file
, _(" Error: length larger than remaining space in record\n"));
6299 /* xgettext:c-format */
6300 fprintf (file
, _(" (type: %3u, size: 4+%3u): "), type
, size
- 4);
6303 case ETIR__C_STA_GBL
:
6304 fprintf (file
, _("STA_GBL (stack global) %.*s\n"),
6307 case ETIR__C_STA_LW
:
6308 fprintf (file
, _("STA_LW (stack longword) 0x%08x\n"),
6309 (unsigned)bfd_getl32 (buf
));
6311 case ETIR__C_STA_QW
:
6312 fprintf (file
, _("STA_QW (stack quadword) 0x%08x %08x\n"),
6313 (unsigned)bfd_getl32 (buf
+ 4),
6314 (unsigned)bfd_getl32 (buf
+ 0));
6316 case ETIR__C_STA_PQ
:
6317 fprintf (file
, _("STA_PQ (stack psect base + offset)\n"));
6318 /* xgettext:c-format */
6319 fprintf (file
, _(" psect: %u, offset: 0x%08x %08x\n"),
6320 (unsigned)bfd_getl32 (buf
+ 0),
6321 (unsigned)bfd_getl32 (buf
+ 8),
6322 (unsigned)bfd_getl32 (buf
+ 4));
6324 case ETIR__C_STA_LI
:
6325 fprintf (file
, _("STA_LI (stack literal)\n"));
6327 case ETIR__C_STA_MOD
:
6328 fprintf (file
, _("STA_MOD (stack module)\n"));
6330 case ETIR__C_STA_CKARG
:
6331 fprintf (file
, _("STA_CKARG (compare procedure argument)\n"));
6335 fprintf (file
, _("STO_B (store byte)\n"));
6338 fprintf (file
, _("STO_W (store word)\n"));
6340 case ETIR__C_STO_LW
:
6341 fprintf (file
, _("STO_LW (store longword)\n"));
6343 case ETIR__C_STO_QW
:
6344 fprintf (file
, _("STO_QW (store quadword)\n"));
6346 case ETIR__C_STO_IMMR
:
6348 unsigned int len
= bfd_getl32 (buf
);
6350 _("STO_IMMR (store immediate repeat) %u bytes\n"),
6352 evax_bfd_print_hex (file
, " ", buf
+ 4, len
);
6356 case ETIR__C_STO_GBL
:
6357 fprintf (file
, _("STO_GBL (store global) %.*s\n"),
6360 case ETIR__C_STO_CA
:
6361 fprintf (file
, _("STO_CA (store code address) %.*s\n"),
6364 case ETIR__C_STO_RB
:
6365 fprintf (file
, _("STO_RB (store relative branch)\n"));
6367 case ETIR__C_STO_AB
:
6368 fprintf (file
, _("STO_AB (store absolute branch)\n"));
6370 case ETIR__C_STO_OFF
:
6371 fprintf (file
, _("STO_OFF (store offset to psect)\n"));
6373 case ETIR__C_STO_IMM
:
6375 unsigned int len
= bfd_getl32 (buf
);
6377 _("STO_IMM (store immediate) %u bytes\n"),
6379 evax_bfd_print_hex (file
, " ", buf
+ 4, len
);
6383 case ETIR__C_STO_GBL_LW
:
6384 fprintf (file
, _("STO_GBL_LW (store global longword) %.*s\n"),
6387 case ETIR__C_STO_LP_PSB
:
6388 fprintf (file
, _("STO_OFF (store LP with procedure signature)\n"));
6390 case ETIR__C_STO_HINT_GBL
:
6391 fprintf (file
, _("STO_BR_GBL (store branch global) *todo*\n"));
6393 case ETIR__C_STO_HINT_PS
:
6394 fprintf (file
, _("STO_BR_PS (store branch psect + offset) *todo*\n"));
6397 case ETIR__C_OPR_NOP
:
6398 fprintf (file
, _("OPR_NOP (no-operation)\n"));
6400 case ETIR__C_OPR_ADD
:
6401 fprintf (file
, _("OPR_ADD (add)\n"));
6403 case ETIR__C_OPR_SUB
:
6404 fprintf (file
, _("OPR_SUB (subtract)\n"));
6406 case ETIR__C_OPR_MUL
:
6407 fprintf (file
, _("OPR_MUL (multiply)\n"));
6409 case ETIR__C_OPR_DIV
:
6410 fprintf (file
, _("OPR_DIV (divide)\n"));
6412 case ETIR__C_OPR_AND
:
6413 fprintf (file
, _("OPR_AND (logical and)\n"));
6415 case ETIR__C_OPR_IOR
:
6416 fprintf (file
, _("OPR_IOR (logical inclusive or)\n"));
6418 case ETIR__C_OPR_EOR
:
6419 fprintf (file
, _("OPR_EOR (logical exclusive or)\n"));
6421 case ETIR__C_OPR_NEG
:
6422 fprintf (file
, _("OPR_NEG (negate)\n"));
6424 case ETIR__C_OPR_COM
:
6425 fprintf (file
, _("OPR_COM (complement)\n"));
6427 case ETIR__C_OPR_INSV
:
6428 fprintf (file
, _("OPR_INSV (insert field)\n"));
6430 case ETIR__C_OPR_ASH
:
6431 fprintf (file
, _("OPR_ASH (arithmetic shift)\n"));
6433 case ETIR__C_OPR_USH
:
6434 fprintf (file
, _("OPR_USH (unsigned shift)\n"));
6436 case ETIR__C_OPR_ROT
:
6437 fprintf (file
, _("OPR_ROT (rotate)\n"));
6439 case ETIR__C_OPR_SEL
:
6440 fprintf (file
, _("OPR_SEL (select)\n"));
6442 case ETIR__C_OPR_REDEF
:
6443 fprintf (file
, _("OPR_REDEF (redefine symbol to curr location)\n"));
6445 case ETIR__C_OPR_DFLIT
:
6446 fprintf (file
, _("OPR_REDEF (define a literal)\n"));
6449 case ETIR__C_STC_LP
:
6450 fprintf (file
, _("STC_LP (store cond linkage pair)\n"));
6452 case ETIR__C_STC_LP_PSB
:
6454 _("STC_LP_PSB (store cond linkage pair + signature)\n"));
6455 /* xgettext:c-format */
6456 fprintf (file
, _(" linkage index: %u, procedure: %.*s\n"),
6457 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6458 buf
+= 4 + 1 + buf
[4];
6459 fprintf (file
, _(" signature: %.*s\n"), buf
[0], buf
+ 1);
6461 case ETIR__C_STC_GBL
:
6462 fprintf (file
, _("STC_GBL (store cond global)\n"));
6463 /* xgettext:c-format */
6464 fprintf (file
, _(" linkage index: %u, global: %.*s\n"),
6465 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6467 case ETIR__C_STC_GCA
:
6468 fprintf (file
, _("STC_GCA (store cond code address)\n"));
6469 /* xgettext:c-format */
6470 fprintf (file
, _(" linkage index: %u, procedure name: %.*s\n"),
6471 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6473 case ETIR__C_STC_PS
:
6474 fprintf (file
, _("STC_PS (store cond psect + offset)\n"));
6476 /* xgettext:c-format */
6477 _(" linkage index: %u, psect: %u, offset: 0x%08x %08x\n"),
6478 (unsigned)bfd_getl32 (buf
),
6479 (unsigned)bfd_getl32 (buf
+ 4),
6480 (unsigned)bfd_getl32 (buf
+ 12),
6481 (unsigned)bfd_getl32 (buf
+ 8));
6483 case ETIR__C_STC_NOP_GBL
:
6484 fprintf (file
, _("STC_NOP_GBL (store cond NOP at global addr)\n"));
6485 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6487 case ETIR__C_STC_NOP_PS
:
6488 fprintf (file
, _("STC_NOP_PS (store cond NOP at psect + offset)\n"));
6489 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6491 case ETIR__C_STC_BSR_GBL
:
6492 fprintf (file
, _("STC_BSR_GBL (store cond BSR at global addr)\n"));
6493 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6495 case ETIR__C_STC_BSR_PS
:
6496 fprintf (file
, _("STC_BSR_PS (store cond BSR at psect + offset)\n"));
6497 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6499 case ETIR__C_STC_LDA_GBL
:
6500 fprintf (file
, _("STC_LDA_GBL (store cond LDA at global addr)\n"));
6501 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6503 case ETIR__C_STC_LDA_PS
:
6504 fprintf (file
, _("STC_LDA_PS (store cond LDA at psect + offset)\n"));
6505 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6507 case ETIR__C_STC_BOH_GBL
:
6508 fprintf (file
, _("STC_BOH_GBL (store cond BOH at global addr)\n"));
6509 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6511 case ETIR__C_STC_BOH_PS
:
6512 fprintf (file
, _("STC_BOH_PS (store cond BOH at psect + offset)\n"));
6513 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6515 case ETIR__C_STC_NBH_GBL
:
6517 _("STC_NBH_GBL (store cond or hint at global addr)\n"));
6519 case ETIR__C_STC_NBH_PS
:
6521 _("STC_NBH_PS (store cond or hint at psect + offset)\n"));
6524 case ETIR__C_CTL_SETRB
:
6525 fprintf (file
, _("CTL_SETRB (set relocation base)\n"));
6528 case ETIR__C_CTL_AUGRB
:
6530 unsigned int val
= bfd_getl32 (buf
);
6531 fprintf (file
, _("CTL_AUGRB (augment relocation base) %u\n"), val
);
6534 case ETIR__C_CTL_DFLOC
:
6535 fprintf (file
, _("CTL_DFLOC (define location)\n"));
6537 case ETIR__C_CTL_STLOC
:
6538 fprintf (file
, _("CTL_STLOC (set location)\n"));
6540 case ETIR__C_CTL_STKDL
:
6541 fprintf (file
, _("CTL_STKDL (stack defined location)\n"));
6544 fprintf (file
, _("*unhandled*\n"));
6552 evax_bfd_print_eobj (struct bfd
*abfd
, FILE *file
)
6554 bfd_boolean is_first
= TRUE
;
6555 bfd_boolean has_records
= FALSE
;
6559 unsigned int rec_len
;
6560 unsigned int pad_len
;
6562 unsigned int hdr_size
;
6567 unsigned char buf
[6];
6572 if (bfd_bread (buf
, sizeof (buf
), abfd
) != sizeof (buf
))
6574 fprintf (file
, _("cannot read GST record length\n"));
6577 rec_len
= bfd_getl16 (buf
+ 0);
6578 if (rec_len
== bfd_getl16 (buf
+ 4)
6579 && bfd_getl16 (buf
+ 2) == EOBJ__C_EMH
)
6581 /* The format is raw: record-size, type, record-size. */
6583 pad_len
= (rec_len
+ 1) & ~1U;
6586 else if (rec_len
== EOBJ__C_EMH
)
6588 has_records
= FALSE
;
6589 pad_len
= bfd_getl16 (buf
+ 2);
6595 fprintf (file
, _("cannot find EMH in first GST record\n"));
6598 rec
= bfd_malloc (pad_len
);
6599 memcpy (rec
, buf
+ sizeof (buf
) - hdr_size
, hdr_size
);
6603 unsigned int rec_len2
= 0;
6604 unsigned char hdr
[4];
6608 unsigned char buf_len
[2];
6610 if (bfd_bread (buf_len
, sizeof (buf_len
), abfd
)
6611 != sizeof (buf_len
))
6613 fprintf (file
, _("cannot read GST record length\n"));
6616 rec_len2
= (unsigned)bfd_getl16 (buf_len
);
6619 if (bfd_bread (hdr
, sizeof (hdr
), abfd
) != sizeof (hdr
))
6621 fprintf (file
, _("cannot read GST record header\n"));
6624 rec_len
= (unsigned)bfd_getl16 (hdr
+ 2);
6626 pad_len
= (rec_len
+ 1) & ~1U;
6629 rec
= bfd_malloc (pad_len
);
6630 memcpy (rec
, hdr
, sizeof (hdr
));
6631 hdr_size
= sizeof (hdr
);
6632 if (has_records
&& rec_len2
!= rec_len
)
6634 fprintf (file
, _(" corrupted GST\n"));
6639 if (bfd_bread (rec
+ hdr_size
, pad_len
- hdr_size
, abfd
)
6640 != pad_len
- hdr_size
)
6642 fprintf (file
, _("cannot read GST record\n"));
6646 type
= (unsigned)bfd_getl16 (rec
);
6651 evax_bfd_print_emh (file
, rec
, rec_len
);
6654 evax_bfd_print_egsd (file
, rec
, rec_len
);
6657 evax_bfd_print_eeom (file
, rec
, rec_len
);
6662 evax_bfd_print_etir (file
, "ETIR", rec
, rec_len
);
6665 evax_bfd_print_etir (file
, "EDBG", rec
, rec_len
);
6668 evax_bfd_print_etir (file
, "ETBT", rec
, rec_len
);
6671 fprintf (file
, _(" unhandled EOBJ record type %u\n"), type
);
6679 evax_bfd_print_relocation_records (FILE *file
, const unsigned char *rel
,
6680 unsigned int stride
)
6688 count
= bfd_getl32 (rel
+ 0);
6692 base
= bfd_getl32 (rel
+ 4);
6694 /* xgettext:c-format */
6695 fprintf (file
, _(" bitcount: %u, base addr: 0x%08x\n"),
6699 for (j
= 0; count
> 0; j
+= 4, count
-= 32)
6705 val
= bfd_getl32 (rel
);
6708 /* xgettext:c-format */
6709 fprintf (file
, _(" bitmap: 0x%08x (count: %u):\n"), val
, count
);
6711 for (k
= 0; k
< 32; k
++)
6712 if (val
& (1u << k
))
6716 fprintf (file
, _(" %08x"), base
+ (j
* 8 + k
) * stride
);
6731 evax_bfd_print_address_fixups (FILE *file
, const unsigned char *rel
)
6738 count
= bfd_getl32 (rel
+ 0);
6741 /* xgettext:c-format */
6742 fprintf (file
, _(" image %u (%u entries)\n"),
6743 (unsigned)bfd_getl32 (rel
+ 4), count
);
6745 for (j
= 0; j
< count
; j
++)
6747 /* xgettext:c-format */
6748 fprintf (file
, _(" offset: 0x%08x, val: 0x%08x\n"),
6749 (unsigned)bfd_getl32 (rel
+ 0),
6750 (unsigned)bfd_getl32 (rel
+ 4));
6757 evax_bfd_print_reference_fixups (FILE *file
, const unsigned char *rel
)
6766 count
= bfd_getl32 (rel
+ 0);
6769 /* xgettext:c-format */
6770 fprintf (file
, _(" image %u (%u entries), offsets:\n"),
6771 (unsigned)bfd_getl32 (rel
+ 4), count
);
6773 for (j
= 0; j
< count
; j
++)
6777 fprintf (file
, _(" 0x%08x"), (unsigned)bfd_getl32 (rel
));
6792 evax_bfd_print_indent (int indent
, FILE *file
)
6794 for (; indent
; indent
--)
6799 evax_bfd_get_dsc_name (unsigned int v
)
6803 case DSC__K_DTYPE_Z
:
6804 return "Z (Unspecified)";
6805 case DSC__K_DTYPE_V
:
6807 case DSC__K_DTYPE_BU
:
6808 return "BU (Byte logical)";
6809 case DSC__K_DTYPE_WU
:
6810 return "WU (Word logical)";
6811 case DSC__K_DTYPE_LU
:
6812 return "LU (Longword logical)";
6813 case DSC__K_DTYPE_QU
:
6814 return "QU (Quadword logical)";
6815 case DSC__K_DTYPE_B
:
6816 return "B (Byte integer)";
6817 case DSC__K_DTYPE_W
:
6818 return "W (Word integer)";
6819 case DSC__K_DTYPE_L
:
6820 return "L (Longword integer)";
6821 case DSC__K_DTYPE_Q
:
6822 return "Q (Quadword integer)";
6823 case DSC__K_DTYPE_F
:
6824 return "F (Single-precision floating)";
6825 case DSC__K_DTYPE_D
:
6826 return "D (Double-precision floating)";
6827 case DSC__K_DTYPE_FC
:
6828 return "FC (Complex)";
6829 case DSC__K_DTYPE_DC
:
6830 return "DC (Double-precision Complex)";
6831 case DSC__K_DTYPE_T
:
6832 return "T (ASCII text string)";
6833 case DSC__K_DTYPE_NU
:
6834 return "NU (Numeric string, unsigned)";
6835 case DSC__K_DTYPE_NL
:
6836 return "NL (Numeric string, left separate sign)";
6837 case DSC__K_DTYPE_NLO
:
6838 return "NLO (Numeric string, left overpunched sign)";
6839 case DSC__K_DTYPE_NR
:
6840 return "NR (Numeric string, right separate sign)";
6841 case DSC__K_DTYPE_NRO
:
6842 return "NRO (Numeric string, right overpunched sig)";
6843 case DSC__K_DTYPE_NZ
:
6844 return "NZ (Numeric string, zoned sign)";
6845 case DSC__K_DTYPE_P
:
6846 return "P (Packed decimal string)";
6847 case DSC__K_DTYPE_ZI
:
6848 return "ZI (Sequence of instructions)";
6849 case DSC__K_DTYPE_ZEM
:
6850 return "ZEM (Procedure entry mask)";
6851 case DSC__K_DTYPE_DSC
:
6852 return "DSC (Descriptor, used for arrays of dyn strings)";
6853 case DSC__K_DTYPE_OU
:
6854 return "OU (Octaword logical)";
6855 case DSC__K_DTYPE_O
:
6856 return "O (Octaword integer)";
6857 case DSC__K_DTYPE_G
:
6858 return "G (Double precision G floating, 64 bit)";
6859 case DSC__K_DTYPE_H
:
6860 return "H (Quadruple precision floating, 128 bit)";
6861 case DSC__K_DTYPE_GC
:
6862 return "GC (Double precision complex, G floating)";
6863 case DSC__K_DTYPE_HC
:
6864 return "HC (Quadruple precision complex, H floating)";
6865 case DSC__K_DTYPE_CIT
:
6866 return "CIT (COBOL intermediate temporary)";
6867 case DSC__K_DTYPE_BPV
:
6868 return "BPV (Bound Procedure Value)";
6869 case DSC__K_DTYPE_BLV
:
6870 return "BLV (Bound Label Value)";
6871 case DSC__K_DTYPE_VU
:
6872 return "VU (Bit Unaligned)";
6873 case DSC__K_DTYPE_ADT
:
6874 return "ADT (Absolute Date-Time)";
6875 case DSC__K_DTYPE_VT
:
6876 return "VT (Varying Text)";
6877 case DSC__K_DTYPE_T2
:
6878 return "T2 (16-bit char)";
6879 case DSC__K_DTYPE_VT2
:
6880 return "VT2 (16-bit varying char)";
6882 return "?? (unknown)";
6887 evax_bfd_print_desc (const unsigned char *buf
, int indent
, FILE *file
)
6889 unsigned char bclass
= buf
[3];
6890 unsigned char dtype
= buf
[2];
6891 unsigned int len
= (unsigned)bfd_getl16 (buf
);
6892 unsigned int pointer
= (unsigned)bfd_getl32 (buf
+ 4);
6894 evax_bfd_print_indent (indent
, file
);
6896 if (len
== 1 && pointer
== 0xffffffffUL
)
6899 fprintf (file
, _("64 bits *unhandled*\n"));
6903 /* xgettext:c-format */
6904 fprintf (file
, _("class: %u, dtype: %u, length: %u, pointer: 0x%08x\n"),
6905 bclass
, dtype
, len
, pointer
);
6908 case DSC__K_CLASS_NCA
:
6910 const struct vms_dsc_nca
*dsc
= (const void *)buf
;
6912 const unsigned char *b
;
6914 evax_bfd_print_indent (indent
, file
);
6915 fprintf (file
, _("non-contiguous array of %s\n"),
6916 evax_bfd_get_dsc_name (dsc
->dtype
));
6917 evax_bfd_print_indent (indent
+ 1, file
);
6919 /* xgettext:c-format */
6920 _("dimct: %u, aflags: 0x%02x, digits: %u, scale: %u\n"),
6921 dsc
->dimct
, dsc
->aflags
, dsc
->digits
, dsc
->scale
);
6922 evax_bfd_print_indent (indent
+ 1, file
);
6924 /* xgettext:c-format */
6925 _("arsize: %u, a0: 0x%08x\n"),
6926 (unsigned)bfd_getl32 (dsc
->arsize
),
6927 (unsigned)bfd_getl32 (dsc
->a0
));
6928 evax_bfd_print_indent (indent
+ 1, file
);
6929 fprintf (file
, _("Strides:\n"));
6930 b
= buf
+ sizeof (*dsc
);
6931 for (i
= 0; i
< dsc
->dimct
; i
++)
6933 evax_bfd_print_indent (indent
+ 2, file
);
6934 fprintf (file
, "[%u]: %u\n", i
+ 1,
6935 (unsigned)bfd_getl32 (b
));
6938 evax_bfd_print_indent (indent
+ 1, file
);
6939 fprintf (file
, _("Bounds:\n"));
6940 b
= buf
+ sizeof (*dsc
);
6941 for (i
= 0; i
< dsc
->dimct
; i
++)
6943 evax_bfd_print_indent (indent
+ 2, file
);
6944 /* xgettext:c-format */
6945 fprintf (file
, _("[%u]: Lower: %u, upper: %u\n"), i
+ 1,
6946 (unsigned)bfd_getl32 (b
+ 0),
6947 (unsigned)bfd_getl32 (b
+ 4));
6952 case DSC__K_CLASS_UBS
:
6954 const struct vms_dsc_ubs
*ubs
= (const void *)buf
;
6956 evax_bfd_print_indent (indent
, file
);
6957 fprintf (file
, _("unaligned bit-string of %s\n"),
6958 evax_bfd_get_dsc_name (ubs
->dtype
));
6959 evax_bfd_print_indent (indent
+ 1, file
);
6961 /* xgettext:c-format */
6962 _("base: %u, pos: %u\n"),
6963 (unsigned)bfd_getl32 (ubs
->base
),
6964 (unsigned)bfd_getl32 (ubs
->pos
));
6968 fprintf (file
, _("*unhandled*\n"));
6975 evax_bfd_print_valspec (const unsigned char *buf
, int indent
, FILE *file
)
6977 unsigned int vflags
= buf
[0];
6978 unsigned int value
= (unsigned)bfd_getl32 (buf
+ 1);
6979 unsigned int len
= 5;
6981 evax_bfd_print_indent (indent
, file
);
6982 /* xgettext:c-format */
6983 fprintf (file
, _("vflags: 0x%02x, value: 0x%08x "), vflags
, value
);
6988 case DST__K_VFLAGS_NOVAL
:
6989 fprintf (file
, _("(no value)\n"));
6991 case DST__K_VFLAGS_NOTACTIVE
:
6992 fprintf (file
, _("(not active)\n"));
6994 case DST__K_VFLAGS_UNALLOC
:
6995 fprintf (file
, _("(not allocated)\n"));
6997 case DST__K_VFLAGS_DSC
:
6998 fprintf (file
, _("(descriptor)\n"));
6999 evax_bfd_print_desc (buf
+ value
, indent
+ 1, file
);
7001 case DST__K_VFLAGS_TVS
:
7002 fprintf (file
, _("(trailing value)\n"));
7004 case DST__K_VS_FOLLOWS
:
7005 fprintf (file
, _("(value spec follows)\n"));
7007 case DST__K_VFLAGS_BITOFFS
:
7008 fprintf (file
, _("(at bit offset %u)\n"), value
);
7011 /* xgettext:c-format */
7012 fprintf (file
, _("(reg: %u, disp: %u, indir: %u, kind: "),
7013 (vflags
& DST__K_REGNUM_MASK
) >> DST__K_REGNUM_SHIFT
,
7014 vflags
& DST__K_DISP
? 1 : 0,
7015 vflags
& DST__K_INDIR
? 1 : 0);
7016 switch (vflags
& DST__K_VALKIND_MASK
)
7018 case DST__K_VALKIND_LITERAL
:
7019 fputs (_("literal"), file
);
7021 case DST__K_VALKIND_ADDR
:
7022 fputs (_("address"), file
);
7024 case DST__K_VALKIND_DESC
:
7025 fputs (_("desc"), file
);
7027 case DST__K_VALKIND_REG
:
7028 fputs (_("reg"), file
);
7031 fputs (")\n", file
);
7038 evax_bfd_print_typspec (const unsigned char *buf
, int indent
, FILE *file
)
7040 unsigned char kind
= buf
[2];
7041 unsigned int len
= (unsigned)bfd_getl16 (buf
);
7043 evax_bfd_print_indent (indent
, file
);
7044 /* xgettext:c-format */
7045 fprintf (file
, _("len: %2u, kind: %2u "), len
, kind
);
7049 case DST__K_TS_ATOM
:
7050 /* xgettext:c-format */
7051 fprintf (file
, _("atomic, type=0x%02x %s\n"),
7052 buf
[0], evax_bfd_get_dsc_name (buf
[0]));
7055 fprintf (file
, _("indirect, defined at 0x%08x\n"),
7056 (unsigned)bfd_getl32 (buf
));
7058 case DST__K_TS_TPTR
:
7059 fprintf (file
, _("typed pointer\n"));
7060 evax_bfd_print_typspec (buf
, indent
+ 1, file
);
7063 fprintf (file
, _("pointer\n"));
7065 case DST__K_TS_ARRAY
:
7067 const unsigned char *vs
;
7068 unsigned int vec_len
;
7071 fprintf (file
, _("array, dim: %u, bitmap: "), buf
[0]);
7072 vec_len
= (buf
[0] + 1 + 7) / 8;
7073 for (i
= 0; i
< vec_len
; i
++)
7074 fprintf (file
, " %02x", buf
[i
+ 1]);
7076 vs
= buf
+ 1 + vec_len
;
7077 evax_bfd_print_indent (indent
, file
);
7078 fprintf (file
, _("array descriptor:\n"));
7079 vs
+= evax_bfd_print_valspec (vs
, indent
+ 1, file
);
7080 for (i
= 0; i
< buf
[0] + 1U; i
++)
7081 if (buf
[1 + i
/ 8] & (1 << (i
% 8)))
7083 evax_bfd_print_indent (indent
, file
);
7085 fprintf (file
, _("type spec for element:\n"));
7087 fprintf (file
, _("type spec for subscript %u:\n"), i
);
7088 evax_bfd_print_typspec (vs
, indent
+ 1, file
);
7089 vs
+= bfd_getl16 (vs
);
7094 fprintf (file
, _("*unhandled*\n"));
7099 evax_bfd_print_dst (struct bfd
*abfd
, unsigned int dst_size
, FILE *file
)
7101 unsigned int off
= 0;
7102 unsigned int pc
= 0;
7103 unsigned int line
= 0;
7105 fprintf (file
, _("Debug symbol table:\n"));
7107 while (dst_size
> 0)
7109 struct vms_dst_header dsth
;
7114 if (bfd_bread (&dsth
, sizeof (dsth
), abfd
) != sizeof (dsth
))
7116 fprintf (file
, _("cannot read DST header\n"));
7119 len
= bfd_getl16 (dsth
.length
);
7120 type
= bfd_getl16 (dsth
.type
);
7121 /* xgettext:c-format */
7122 fprintf (file
, _(" type: %3u, len: %3u (at 0x%08x): "),
7132 len
-= sizeof (dsth
);
7133 buf
= bfd_malloc (len
);
7134 if (bfd_bread (buf
, len
, abfd
) != len
)
7136 fprintf (file
, _("cannot read DST symbol\n"));
7141 case DSC__K_DTYPE_V
:
7142 case DSC__K_DTYPE_BU
:
7143 case DSC__K_DTYPE_WU
:
7144 case DSC__K_DTYPE_LU
:
7145 case DSC__K_DTYPE_QU
:
7146 case DSC__K_DTYPE_B
:
7147 case DSC__K_DTYPE_W
:
7148 case DSC__K_DTYPE_L
:
7149 case DSC__K_DTYPE_Q
:
7150 case DSC__K_DTYPE_F
:
7151 case DSC__K_DTYPE_D
:
7152 case DSC__K_DTYPE_FC
:
7153 case DSC__K_DTYPE_DC
:
7154 case DSC__K_DTYPE_T
:
7155 case DSC__K_DTYPE_NU
:
7156 case DSC__K_DTYPE_NL
:
7157 case DSC__K_DTYPE_NLO
:
7158 case DSC__K_DTYPE_NR
:
7159 case DSC__K_DTYPE_NRO
:
7160 case DSC__K_DTYPE_NZ
:
7161 case DSC__K_DTYPE_P
:
7162 case DSC__K_DTYPE_ZI
:
7163 case DSC__K_DTYPE_ZEM
:
7164 case DSC__K_DTYPE_DSC
:
7165 case DSC__K_DTYPE_OU
:
7166 case DSC__K_DTYPE_O
:
7167 case DSC__K_DTYPE_G
:
7168 case DSC__K_DTYPE_H
:
7169 case DSC__K_DTYPE_GC
:
7170 case DSC__K_DTYPE_HC
:
7171 case DSC__K_DTYPE_CIT
:
7172 case DSC__K_DTYPE_BPV
:
7173 case DSC__K_DTYPE_BLV
:
7174 case DSC__K_DTYPE_VU
:
7175 case DSC__K_DTYPE_ADT
:
7176 case DSC__K_DTYPE_VT
:
7177 case DSC__K_DTYPE_T2
:
7178 case DSC__K_DTYPE_VT2
:
7179 fprintf (file
, _("standard data: %s\n"),
7180 evax_bfd_get_dsc_name (type
));
7181 evax_bfd_print_valspec (buf
, 4, file
);
7182 fprintf (file
, _(" name: %.*s\n"), buf
[5], buf
+ 6);
7186 struct vms_dst_modbeg
*dst
= (void *)buf
;
7187 const char *name
= (const char *)buf
+ sizeof (*dst
);
7189 fprintf (file
, _("modbeg\n"));
7190 /* xgettext:c-format */
7191 fprintf (file
, _(" flags: %d, language: %u, "
7192 "major: %u, minor: %u\n"),
7194 (unsigned)bfd_getl32 (dst
->language
),
7195 (unsigned)bfd_getl16 (dst
->major
),
7196 (unsigned)bfd_getl16 (dst
->minor
));
7197 fprintf (file
, _(" module name: %.*s\n"),
7199 name
+= name
[0] + 1;
7200 fprintf (file
, _(" compiler : %.*s\n"),
7205 fprintf (file
, _("modend\n"));
7209 struct vms_dst_rtnbeg
*dst
= (void *)buf
;
7210 const char *name
= (const char *)buf
+ sizeof (*dst
);
7212 fputs (_("rtnbeg\n"), file
);
7213 /* xgettext:c-format */
7214 fprintf (file
, _(" flags: %u, address: 0x%08x, "
7215 "pd-address: 0x%08x\n"),
7217 (unsigned)bfd_getl32 (dst
->address
),
7218 (unsigned)bfd_getl32 (dst
->pd_address
));
7219 fprintf (file
, _(" routine name: %.*s\n"),
7225 struct vms_dst_rtnend
*dst
= (void *)buf
;
7227 fprintf (file
, _("rtnend: size 0x%08x\n"),
7228 (unsigned)bfd_getl32 (dst
->size
));
7233 struct vms_dst_prolog
*dst
= (void *)buf
;
7235 fprintf (file
, _("prolog: bkpt address 0x%08x\n"),
7236 (unsigned)bfd_getl32 (dst
->bkpt_addr
));
7241 struct vms_dst_epilog
*dst
= (void *)buf
;
7243 /* xgettext:c-format */
7244 fprintf (file
, _("epilog: flags: %u, count: %u\n"),
7245 dst
->flags
, (unsigned)bfd_getl32 (dst
->count
));
7250 struct vms_dst_blkbeg
*dst
= (void *)buf
;
7251 const char *name
= (const char *)buf
+ sizeof (*dst
);
7253 /* xgettext:c-format */
7254 fprintf (file
, _("blkbeg: address: 0x%08x, name: %.*s\n"),
7255 (unsigned)bfd_getl32 (dst
->address
),
7261 struct vms_dst_blkend
*dst
= (void *)buf
;
7263 fprintf (file
, _("blkend: size: 0x%08x\n"),
7264 (unsigned)bfd_getl32 (dst
->size
));
7267 case DST__K_TYPSPEC
:
7269 fprintf (file
, _("typspec (len: %u)\n"), len
);
7270 fprintf (file
, _(" name: %.*s\n"), buf
[0], buf
+ 1);
7271 evax_bfd_print_typspec (buf
+ 1 + buf
[0], 5, file
);
7276 fprintf (file
, _("septyp, name: %.*s\n"), buf
[5], buf
+ 6);
7277 evax_bfd_print_valspec (buf
, 4, file
);
7282 struct vms_dst_recbeg
*recbeg
= (void *)buf
;
7283 const char *name
= (const char *)buf
+ sizeof (*recbeg
);
7285 fprintf (file
, _("recbeg: name: %.*s\n"), name
[0], name
+ 1);
7286 evax_bfd_print_valspec (buf
, 4, file
);
7287 fprintf (file
, _(" len: %u bits\n"),
7288 (unsigned)bfd_getl32 (name
+ 1 + name
[0]));
7292 fprintf (file
, _("recend\n"));
7294 case DST__K_ENUMBEG
:
7295 /* xgettext:c-format */
7296 fprintf (file
, _("enumbeg, len: %u, name: %.*s\n"),
7297 buf
[0], buf
[1], buf
+ 2);
7299 case DST__K_ENUMELT
:
7300 fprintf (file
, _("enumelt, name: %.*s\n"), buf
[5], buf
+ 6);
7301 evax_bfd_print_valspec (buf
, 4, file
);
7303 case DST__K_ENUMEND
:
7304 fprintf (file
, _("enumend\n"));
7308 struct vms_dst_label
*lab
= (void *)buf
;
7309 fprintf (file
, _("label, name: %.*s\n"),
7310 lab
->name
[0], lab
->name
+ 1);
7311 fprintf (file
, _(" address: 0x%08x\n"),
7312 (unsigned)bfd_getl32 (lab
->value
));
7315 case DST__K_DIS_RANGE
:
7317 unsigned int cnt
= bfd_getl32 (buf
);
7318 unsigned char *rng
= buf
+ 4;
7321 fprintf (file
, _("discontiguous range (nbr: %u)\n"), cnt
);
7322 for (i
= 0; i
< cnt
; i
++, rng
+= 8)
7323 /* xgettext:c-format */
7324 fprintf (file
, _(" address: 0x%08x, size: %u\n"),
7325 (unsigned)bfd_getl32 (rng
),
7326 (unsigned)bfd_getl32 (rng
+ 4));
7330 case DST__K_LINE_NUM
:
7332 unsigned char *buf_orig
= buf
;
7334 fprintf (file
, _("line num (len: %u)\n"), len
);
7339 unsigned char cmdlen
;
7349 case DST__K_DELTA_PC_W
:
7350 val
= bfd_getl16 (buf
+ 1);
7351 fprintf (file
, _("delta_pc_w %u\n"), val
);
7356 case DST__K_INCR_LINUM
:
7358 fprintf (file
, _("incr_linum(b): +%u\n"), val
);
7362 case DST__K_INCR_LINUM_W
:
7363 val
= bfd_getl16 (buf
+ 1);
7364 fprintf (file
, _("incr_linum_w: +%u\n"), val
);
7368 case DST__K_INCR_LINUM_L
:
7369 val
= bfd_getl32 (buf
+ 1);
7370 fprintf (file
, _("incr_linum_l: +%u\n"), val
);
7374 case DST__K_SET_LINUM
:
7375 line
= bfd_getl16 (buf
+ 1);
7376 fprintf (file
, _("set_line_num(w) %u\n"), line
);
7379 case DST__K_SET_LINUM_B
:
7381 fprintf (file
, _("set_line_num_b %u\n"), line
);
7384 case DST__K_SET_LINUM_L
:
7385 line
= bfd_getl32 (buf
+ 1);
7386 fprintf (file
, _("set_line_num_l %u\n"), line
);
7389 case DST__K_SET_ABS_PC
:
7390 pc
= bfd_getl32 (buf
+ 1);
7391 fprintf (file
, _("set_abs_pc: 0x%08x\n"), pc
);
7394 case DST__K_DELTA_PC_L
:
7395 fprintf (file
, _("delta_pc_l: +0x%08x\n"),
7396 (unsigned)bfd_getl32 (buf
+ 1));
7400 fprintf (file
, _("term(b): 0x%02x"), buf
[1]);
7402 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7406 val
= bfd_getl16 (buf
+ 1);
7407 fprintf (file
, _("term_w: 0x%04x"), val
);
7409 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7415 fprintf (file
, _("delta pc +%-4d"), -cmd
);
7416 line
++; /* FIXME: curr increment. */
7418 /* xgettext:c-format */
7419 fprintf (file
, _(" pc: 0x%08x line: %5u\n"),
7424 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7437 unsigned char *buf_orig
= buf
;
7439 fprintf (file
, _("source (len: %u)\n"), len
);
7443 signed char cmd
= buf
[0];
7444 unsigned char cmdlen
= 0;
7448 case DST__K_SRC_DECLFILE
:
7450 struct vms_dst_src_decl_src
*src
= (void *)(buf
+ 1);
7453 /* xgettext:c-format */
7454 fprintf (file
, _(" declfile: len: %u, flags: %u, "
7456 src
->length
, src
->flags
,
7457 (unsigned)bfd_getl16 (src
->fileid
));
7458 /* xgettext:c-format */
7459 fprintf (file
, _(" rms: cdt: 0x%08x %08x, "
7460 "ebk: 0x%08x, ffb: 0x%04x, "
7462 (unsigned)bfd_getl32 (src
->rms_cdt
+ 4),
7463 (unsigned)bfd_getl32 (src
->rms_cdt
+ 0),
7464 (unsigned)bfd_getl32 (src
->rms_ebk
),
7465 (unsigned)bfd_getl16 (src
->rms_ffb
),
7467 name
= (const char *)buf
+ 1 + sizeof (*src
);
7468 fprintf (file
, _(" filename : %.*s\n"),
7470 name
+= name
[0] + 1;
7471 fprintf (file
, _(" module name: %.*s\n"),
7473 cmdlen
= 2 + src
->length
;
7476 case DST__K_SRC_SETFILE
:
7477 fprintf (file
, _(" setfile %u\n"),
7478 (unsigned)bfd_getl16 (buf
+ 1));
7481 case DST__K_SRC_SETREC_W
:
7482 fprintf (file
, _(" setrec %u\n"),
7483 (unsigned)bfd_getl16 (buf
+ 1));
7486 case DST__K_SRC_SETREC_L
:
7487 fprintf (file
, _(" setrec %u\n"),
7488 (unsigned)bfd_getl32 (buf
+ 1));
7491 case DST__K_SRC_SETLNUM_W
:
7492 fprintf (file
, _(" setlnum %u\n"),
7493 (unsigned)bfd_getl16 (buf
+ 1));
7496 case DST__K_SRC_SETLNUM_L
:
7497 fprintf (file
, _(" setlnum %u\n"),
7498 (unsigned)bfd_getl32 (buf
+ 1));
7501 case DST__K_SRC_DEFLINES_W
:
7502 fprintf (file
, _(" deflines %u\n"),
7503 (unsigned)bfd_getl16 (buf
+ 1));
7506 case DST__K_SRC_DEFLINES_B
:
7507 fprintf (file
, _(" deflines %u\n"), buf
[1]);
7510 case DST__K_SRC_FORMFEED
:
7511 fprintf (file
, _(" formfeed\n"));
7515 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7527 fprintf (file
, _("*unhandled* dst type %u\n"), type
);
7535 evax_bfd_print_image (bfd
*abfd
, FILE *file
)
7537 struct vms_eihd eihd
;
7540 unsigned int eiha_off
;
7541 unsigned int eihi_off
;
7542 unsigned int eihs_off
;
7543 unsigned int eisd_off
;
7544 unsigned int eihef_off
= 0;
7545 unsigned int eihnp_off
= 0;
7546 unsigned int dmt_vbn
= 0;
7547 unsigned int dmt_size
= 0;
7548 unsigned int dst_vbn
= 0;
7549 unsigned int dst_size
= 0;
7550 unsigned int gst_vbn
= 0;
7551 unsigned int gst_size
= 0;
7552 unsigned int eiaf_vbn
= 0;
7553 unsigned int eiaf_size
= 0;
7554 unsigned int eihvn_off
;
7556 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
)
7557 || bfd_bread (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
7559 fprintf (file
, _("cannot read EIHD\n"));
7562 /* xgettext:c-format */
7563 fprintf (file
, _("EIHD: (size: %u, nbr blocks: %u)\n"),
7564 (unsigned)bfd_getl32 (eihd
.size
),
7565 (unsigned)bfd_getl32 (eihd
.hdrblkcnt
));
7566 /* xgettext:c-format */
7567 fprintf (file
, _(" majorid: %u, minorid: %u\n"),
7568 (unsigned)bfd_getl32 (eihd
.majorid
),
7569 (unsigned)bfd_getl32 (eihd
.minorid
));
7571 val
= (unsigned)bfd_getl32 (eihd
.imgtype
);
7575 name
= _("executable");
7578 name
= _("linkable image");
7581 name
= _("unknown");
7584 /* xgettext:c-format */
7585 fprintf (file
, _(" image type: %u (%s)"), val
, name
);
7587 val
= (unsigned)bfd_getl32 (eihd
.subtype
);
7590 case EIHD__C_NATIVE
:
7597 name
= _("unknown");
7600 /* xgettext:c-format */
7601 fprintf (file
, _(", subtype: %u (%s)\n"), val
, name
);
7603 eisd_off
= bfd_getl32 (eihd
.isdoff
);
7604 eiha_off
= bfd_getl32 (eihd
.activoff
);
7605 eihi_off
= bfd_getl32 (eihd
.imgidoff
);
7606 eihs_off
= bfd_getl32 (eihd
.symdbgoff
);
7607 /* xgettext:c-format */
7608 fprintf (file
, _(" offsets: isd: %u, activ: %u, symdbg: %u, "
7609 "imgid: %u, patch: %u\n"),
7610 eisd_off
, eiha_off
, eihs_off
, eihi_off
,
7611 (unsigned)bfd_getl32 (eihd
.patchoff
));
7612 fprintf (file
, _(" fixup info rva: "));
7613 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.iafva
));
7614 fprintf (file
, _(", symbol vector rva: "));
7615 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.symvva
));
7616 eihvn_off
= bfd_getl32 (eihd
.version_array_off
);
7617 fprintf (file
, _("\n"
7618 " version array off: %u\n"),
7621 /* xgettext:c-format */
7622 _(" img I/O count: %u, nbr channels: %u, req pri: %08x%08x\n"),
7623 (unsigned)bfd_getl32 (eihd
.imgiocnt
),
7624 (unsigned)bfd_getl32 (eihd
.iochancnt
),
7625 (unsigned)bfd_getl32 (eihd
.privreqs
+ 4),
7626 (unsigned)bfd_getl32 (eihd
.privreqs
+ 0));
7627 val
= (unsigned)bfd_getl32 (eihd
.lnkflags
);
7628 fprintf (file
, _(" linker flags: %08x:"), val
);
7629 if (val
& EIHD__M_LNKDEBUG
)
7630 fprintf (file
, " LNKDEBUG");
7631 if (val
& EIHD__M_LNKNOTFR
)
7632 fprintf (file
, " LNKNOTFR");
7633 if (val
& EIHD__M_NOP0BUFS
)
7634 fprintf (file
, " NOP0BUFS");
7635 if (val
& EIHD__M_PICIMG
)
7636 fprintf (file
, " PICIMG");
7637 if (val
& EIHD__M_P0IMAGE
)
7638 fprintf (file
, " P0IMAGE");
7639 if (val
& EIHD__M_DBGDMT
)
7640 fprintf (file
, " DBGDMT");
7641 if (val
& EIHD__M_INISHR
)
7642 fprintf (file
, " INISHR");
7643 if (val
& EIHD__M_XLATED
)
7644 fprintf (file
, " XLATED");
7645 if (val
& EIHD__M_BIND_CODE_SEC
)
7646 fprintf (file
, " BIND_CODE_SEC");
7647 if (val
& EIHD__M_BIND_DATA_SEC
)
7648 fprintf (file
, " BIND_DATA_SEC");
7649 if (val
& EIHD__M_MKTHREADS
)
7650 fprintf (file
, " MKTHREADS");
7651 if (val
& EIHD__M_UPCALLS
)
7652 fprintf (file
, " UPCALLS");
7653 if (val
& EIHD__M_OMV_READY
)
7654 fprintf (file
, " OMV_READY");
7655 if (val
& EIHD__M_EXT_BIND_SECT
)
7656 fprintf (file
, " EXT_BIND_SECT");
7657 fprintf (file
, "\n");
7658 /* xgettext:c-format */
7659 fprintf (file
, _(" ident: 0x%08x, sysver: 0x%08x, "
7660 "match ctrl: %u, symvect_size: %u\n"),
7661 (unsigned)bfd_getl32 (eihd
.ident
),
7662 (unsigned)bfd_getl32 (eihd
.sysver
),
7664 (unsigned)bfd_getl32 (eihd
.symvect_size
));
7665 fprintf (file
, _(" BPAGE: %u"),
7666 (unsigned)bfd_getl32 (eihd
.virt_mem_block_size
));
7667 if (val
& (EIHD__M_OMV_READY
| EIHD__M_EXT_BIND_SECT
))
7669 eihef_off
= bfd_getl32 (eihd
.ext_fixup_off
);
7670 eihnp_off
= bfd_getl32 (eihd
.noopt_psect_off
);
7671 /* xgettext:c-format */
7672 fprintf (file
, _(", ext fixup offset: %u, no_opt psect off: %u"),
7673 eihef_off
, eihnp_off
);
7675 fprintf (file
, _(", alias: %u\n"), (unsigned)bfd_getl16 (eihd
.alias
));
7679 struct vms_eihvn eihvn
;
7683 fprintf (file
, _("system version array information:\n"));
7684 if (bfd_seek (abfd
, (file_ptr
) eihvn_off
, SEEK_SET
)
7685 || bfd_bread (&eihvn
, sizeof (eihvn
), abfd
) != sizeof (eihvn
))
7687 fprintf (file
, _("cannot read EIHVN header\n"));
7690 mask
= bfd_getl32 (eihvn
.subsystem_mask
);
7691 for (j
= 0; j
< 32; j
++)
7692 if (mask
& (1 << j
))
7694 struct vms_eihvn_subversion ver
;
7695 if (bfd_bread (&ver
, sizeof (ver
), abfd
) != sizeof (ver
))
7697 fprintf (file
, _("cannot read EIHVN version\n"));
7700 fprintf (file
, _(" %02u "), j
);
7703 case EIHVN__BASE_IMAGE_BIT
:
7704 fputs (_("BASE_IMAGE "), file
);
7706 case EIHVN__MEMORY_MANAGEMENT_BIT
:
7707 fputs (_("MEMORY_MANAGEMENT"), file
);
7710 fputs (_("IO "), file
);
7712 case EIHVN__FILES_VOLUMES_BIT
:
7713 fputs (_("FILES_VOLUMES "), file
);
7715 case EIHVN__PROCESS_SCHED_BIT
:
7716 fputs (_("PROCESS_SCHED "), file
);
7718 case EIHVN__SYSGEN_BIT
:
7719 fputs (_("SYSGEN "), file
);
7721 case EIHVN__CLUSTERS_LOCKMGR_BIT
:
7722 fputs (_("CLUSTERS_LOCKMGR "), file
);
7724 case EIHVN__LOGICAL_NAMES_BIT
:
7725 fputs (_("LOGICAL_NAMES "), file
);
7727 case EIHVN__SECURITY_BIT
:
7728 fputs (_("SECURITY "), file
);
7730 case EIHVN__IMAGE_ACTIVATOR_BIT
:
7731 fputs (_("IMAGE_ACTIVATOR "), file
);
7733 case EIHVN__NETWORKS_BIT
:
7734 fputs (_("NETWORKS "), file
);
7736 case EIHVN__COUNTERS_BIT
:
7737 fputs (_("COUNTERS "), file
);
7739 case EIHVN__STABLE_BIT
:
7740 fputs (_("STABLE "), file
);
7742 case EIHVN__MISC_BIT
:
7743 fputs (_("MISC "), file
);
7745 case EIHVN__CPU_BIT
:
7746 fputs (_("CPU "), file
);
7748 case EIHVN__VOLATILE_BIT
:
7749 fputs (_("VOLATILE "), file
);
7751 case EIHVN__SHELL_BIT
:
7752 fputs (_("SHELL "), file
);
7754 case EIHVN__POSIX_BIT
:
7755 fputs (_("POSIX "), file
);
7757 case EIHVN__MULTI_PROCESSING_BIT
:
7758 fputs (_("MULTI_PROCESSING "), file
);
7760 case EIHVN__GALAXY_BIT
:
7761 fputs (_("GALAXY "), file
);
7764 fputs (_("*unknown* "), file
);
7767 fprintf (file
, ": %u.%u\n",
7768 (unsigned)bfd_getl16 (ver
.major
),
7769 (unsigned)bfd_getl16 (ver
.minor
));
7775 struct vms_eiha eiha
;
7777 if (bfd_seek (abfd
, (file_ptr
) eiha_off
, SEEK_SET
)
7778 || bfd_bread (&eiha
, sizeof (eiha
), abfd
) != sizeof (eiha
))
7780 fprintf (file
, _("cannot read EIHA\n"));
7783 fprintf (file
, _("Image activation: (size=%u)\n"),
7784 (unsigned)bfd_getl32 (eiha
.size
));
7785 /* xgettext:c-format */
7786 fprintf (file
, _(" First address : 0x%08x 0x%08x\n"),
7787 (unsigned)bfd_getl32 (eiha
.tfradr1_h
),
7788 (unsigned)bfd_getl32 (eiha
.tfradr1
));
7789 /* xgettext:c-format */
7790 fprintf (file
, _(" Second address: 0x%08x 0x%08x\n"),
7791 (unsigned)bfd_getl32 (eiha
.tfradr2_h
),
7792 (unsigned)bfd_getl32 (eiha
.tfradr2
));
7793 /* xgettext:c-format */
7794 fprintf (file
, _(" Third address : 0x%08x 0x%08x\n"),
7795 (unsigned)bfd_getl32 (eiha
.tfradr3_h
),
7796 (unsigned)bfd_getl32 (eiha
.tfradr3
));
7797 /* xgettext:c-format */
7798 fprintf (file
, _(" Fourth address: 0x%08x 0x%08x\n"),
7799 (unsigned)bfd_getl32 (eiha
.tfradr4_h
),
7800 (unsigned)bfd_getl32 (eiha
.tfradr4
));
7801 /* xgettext:c-format */
7802 fprintf (file
, _(" Shared image : 0x%08x 0x%08x\n"),
7803 (unsigned)bfd_getl32 (eiha
.inishr_h
),
7804 (unsigned)bfd_getl32 (eiha
.inishr
));
7808 struct vms_eihi eihi
;
7810 if (bfd_seek (abfd
, (file_ptr
) eihi_off
, SEEK_SET
)
7811 || bfd_bread (&eihi
, sizeof (eihi
), abfd
) != sizeof (eihi
))
7813 fprintf (file
, _("cannot read EIHI\n"));
7816 /* xgettext:c-format */
7817 fprintf (file
, _("Image identification: (major: %u, minor: %u)\n"),
7818 (unsigned)bfd_getl32 (eihi
.majorid
),
7819 (unsigned)bfd_getl32 (eihi
.minorid
));
7820 fprintf (file
, _(" image name : %.*s\n"),
7821 eihi
.imgnam
[0], eihi
.imgnam
+ 1);
7822 fprintf (file
, _(" link time : %s\n"),
7823 vms_time_to_str (eihi
.linktime
));
7824 fprintf (file
, _(" image ident : %.*s\n"),
7825 eihi
.imgid
[0], eihi
.imgid
+ 1);
7826 fprintf (file
, _(" linker ident : %.*s\n"),
7827 eihi
.linkid
[0], eihi
.linkid
+ 1);
7828 fprintf (file
, _(" image build ident: %.*s\n"),
7829 eihi
.imgbid
[0], eihi
.imgbid
+ 1);
7833 struct vms_eihs eihs
;
7835 if (bfd_seek (abfd
, (file_ptr
) eihs_off
, SEEK_SET
)
7836 || bfd_bread (&eihs
, sizeof (eihs
), abfd
) != sizeof (eihs
))
7838 fprintf (file
, _("cannot read EIHS\n"));
7841 /* xgettext:c-format */
7842 fprintf (file
, _("Image symbol & debug table: (major: %u, minor: %u)\n"),
7843 (unsigned)bfd_getl32 (eihs
.majorid
),
7844 (unsigned)bfd_getl32 (eihs
.minorid
));
7845 dst_vbn
= bfd_getl32 (eihs
.dstvbn
);
7846 dst_size
= bfd_getl32 (eihs
.dstsize
);
7847 /* xgettext:c-format */
7848 fprintf (file
, _(" debug symbol table : vbn: %u, size: %u (0x%x)\n"),
7849 dst_vbn
, dst_size
, dst_size
);
7850 gst_vbn
= bfd_getl32 (eihs
.gstvbn
);
7851 gst_size
= bfd_getl32 (eihs
.gstsize
);
7852 /* xgettext:c-format */
7853 fprintf (file
, _(" global symbol table: vbn: %u, records: %u\n"),
7855 dmt_vbn
= bfd_getl32 (eihs
.dmtvbn
);
7856 dmt_size
= bfd_getl32 (eihs
.dmtsize
);
7857 /* xgettext:c-format */
7858 fprintf (file
, _(" debug module table : vbn: %u, size: %u\n"),
7861 while (eisd_off
!= 0)
7863 struct vms_eisd eisd
;
7868 if (bfd_seek (abfd
, (file_ptr
) eisd_off
, SEEK_SET
)
7869 || bfd_bread (&eisd
, sizeof (eisd
), abfd
) != sizeof (eisd
))
7871 fprintf (file
, _("cannot read EISD\n"));
7874 len
= (unsigned)bfd_getl32 (eisd
.eisdsize
);
7875 if (len
!= (unsigned)-1)
7879 eisd_off
= (eisd_off
+ VMS_BLOCK_SIZE
) & ~(VMS_BLOCK_SIZE
- 1);
7881 /* xgettext:c-format */
7882 fprintf (file
, _("Image section descriptor: (major: %u, minor: %u, "
7883 "size: %u, offset: %u)\n"),
7884 (unsigned)bfd_getl32 (eisd
.majorid
),
7885 (unsigned)bfd_getl32 (eisd
.minorid
),
7889 /* xgettext:c-format */
7890 fprintf (file
, _(" section: base: 0x%08x%08x size: 0x%08x\n"),
7891 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 4),
7892 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 0),
7893 (unsigned)bfd_getl32 (eisd
.secsize
));
7894 val
= (unsigned)bfd_getl32 (eisd
.flags
);
7895 fprintf (file
, _(" flags: 0x%04x"), val
);
7896 if (val
& EISD__M_GBL
)
7897 fprintf (file
, " GBL");
7898 if (val
& EISD__M_CRF
)
7899 fprintf (file
, " CRF");
7900 if (val
& EISD__M_DZRO
)
7901 fprintf (file
, " DZRO");
7902 if (val
& EISD__M_WRT
)
7903 fprintf (file
, " WRT");
7904 if (val
& EISD__M_INITALCODE
)
7905 fprintf (file
, " INITALCODE");
7906 if (val
& EISD__M_BASED
)
7907 fprintf (file
, " BASED");
7908 if (val
& EISD__M_FIXUPVEC
)
7909 fprintf (file
, " FIXUPVEC");
7910 if (val
& EISD__M_RESIDENT
)
7911 fprintf (file
, " RESIDENT");
7912 if (val
& EISD__M_VECTOR
)
7913 fprintf (file
, " VECTOR");
7914 if (val
& EISD__M_PROTECT
)
7915 fprintf (file
, " PROTECT");
7916 if (val
& EISD__M_LASTCLU
)
7917 fprintf (file
, " LASTCLU");
7918 if (val
& EISD__M_EXE
)
7919 fprintf (file
, " EXE");
7920 if (val
& EISD__M_NONSHRADR
)
7921 fprintf (file
, " NONSHRADR");
7922 if (val
& EISD__M_QUAD_LENGTH
)
7923 fprintf (file
, " QUAD_LENGTH");
7924 if (val
& EISD__M_ALLOC_64BIT
)
7925 fprintf (file
, " ALLOC_64BIT");
7926 fprintf (file
, "\n");
7927 if (val
& EISD__M_FIXUPVEC
)
7929 eiaf_vbn
= bfd_getl32 (eisd
.vbn
);
7930 eiaf_size
= bfd_getl32 (eisd
.secsize
);
7932 /* xgettext:c-format */
7933 fprintf (file
, _(" vbn: %u, pfc: %u, matchctl: %u type: %u ("),
7934 (unsigned)bfd_getl32 (eisd
.vbn
),
7935 eisd
.pfc
, eisd
.matchctl
, eisd
.type
);
7938 case EISD__K_NORMAL
:
7939 fputs (_("NORMAL"), file
);
7941 case EISD__K_SHRFXD
:
7942 fputs (_("SHRFXD"), file
);
7944 case EISD__K_PRVFXD
:
7945 fputs (_("PRVFXD"), file
);
7947 case EISD__K_SHRPIC
:
7948 fputs (_("SHRPIC"), file
);
7950 case EISD__K_PRVPIC
:
7951 fputs (_("PRVPIC"), file
);
7953 case EISD__K_USRSTACK
:
7954 fputs (_("USRSTACK"), file
);
7957 fputs (_("*unknown*"), file
);
7960 fputs (_(")\n"), file
);
7961 if (val
& EISD__M_GBL
)
7962 /* xgettext:c-format */
7963 fprintf (file
, _(" ident: 0x%08x, name: %.*s\n"),
7964 (unsigned)bfd_getl32 (eisd
.ident
),
7965 eisd
.gblnam
[0], eisd
.gblnam
+ 1);
7971 if (bfd_seek (abfd
, (file_ptr
) (dmt_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7973 fprintf (file
, _("cannot read DMT\n"));
7977 fprintf (file
, _("Debug module table:\n"));
7979 while (dmt_size
> 0)
7981 struct vms_dmt_header dmth
;
7984 if (bfd_bread (&dmth
, sizeof (dmth
), abfd
) != sizeof (dmth
))
7986 fprintf (file
, _("cannot read DMT header\n"));
7989 count
= bfd_getl16 (dmth
.psect_count
);
7991 /* xgettext:c-format */
7992 _(" module offset: 0x%08x, size: 0x%08x, (%u psects)\n"),
7993 (unsigned)bfd_getl32 (dmth
.modbeg
),
7994 (unsigned)bfd_getl32 (dmth
.size
), count
);
7995 dmt_size
-= sizeof (dmth
);
7998 struct vms_dmt_psect dmtp
;
8000 if (bfd_bread (&dmtp
, sizeof (dmtp
), abfd
) != sizeof (dmtp
))
8002 fprintf (file
, _("cannot read DMT psect\n"));
8005 /* xgettext:c-format */
8006 fprintf (file
, _(" psect start: 0x%08x, length: %u\n"),
8007 (unsigned)bfd_getl32 (dmtp
.start
),
8008 (unsigned)bfd_getl32 (dmtp
.length
));
8010 dmt_size
-= sizeof (dmtp
);
8017 if (bfd_seek (abfd
, (file_ptr
) (dst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
8019 fprintf (file
, _("cannot read DST\n"));
8023 evax_bfd_print_dst (abfd
, dst_size
, file
);
8027 if (bfd_seek (abfd
, (file_ptr
) (gst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
8029 fprintf (file
, _("cannot read GST\n"));
8033 fprintf (file
, _("Global symbol table:\n"));
8034 evax_bfd_print_eobj (abfd
, file
);
8039 struct vms_eiaf
*eiaf
;
8040 unsigned int qrelfixoff
;
8041 unsigned int lrelfixoff
;
8042 unsigned int qdotadroff
;
8043 unsigned int ldotadroff
;
8044 unsigned int shrimgcnt
;
8045 unsigned int shlstoff
;
8046 unsigned int codeadroff
;
8047 unsigned int lpfixoff
;
8048 unsigned int chgprtoff
;
8050 buf
= bfd_malloc (eiaf_size
);
8052 if (bfd_seek (abfd
, (file_ptr
) (eiaf_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
)
8053 || bfd_bread (buf
, eiaf_size
, abfd
) != eiaf_size
)
8055 fprintf (file
, _("cannot read EIHA\n"));
8059 eiaf
= (struct vms_eiaf
*)buf
;
8061 /* xgettext:c-format */
8062 _("Image activator fixup: (major: %u, minor: %u)\n"),
8063 (unsigned)bfd_getl32 (eiaf
->majorid
),
8064 (unsigned)bfd_getl32 (eiaf
->minorid
));
8065 /* xgettext:c-format */
8066 fprintf (file
, _(" iaflink : 0x%08x %08x\n"),
8067 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 0),
8068 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 4));
8069 /* xgettext:c-format */
8070 fprintf (file
, _(" fixuplnk: 0x%08x %08x\n"),
8071 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 0),
8072 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 4));
8073 fprintf (file
, _(" size : %u\n"),
8074 (unsigned)bfd_getl32 (eiaf
->size
));
8075 fprintf (file
, _(" flags: 0x%08x\n"),
8076 (unsigned)bfd_getl32 (eiaf
->flags
));
8077 qrelfixoff
= bfd_getl32 (eiaf
->qrelfixoff
);
8078 lrelfixoff
= bfd_getl32 (eiaf
->lrelfixoff
);
8079 /* xgettext:c-format */
8080 fprintf (file
, _(" qrelfixoff: %5u, lrelfixoff: %5u\n"),
8081 qrelfixoff
, lrelfixoff
);
8082 qdotadroff
= bfd_getl32 (eiaf
->qdotadroff
);
8083 ldotadroff
= bfd_getl32 (eiaf
->ldotadroff
);
8084 /* xgettext:c-format */
8085 fprintf (file
, _(" qdotadroff: %5u, ldotadroff: %5u\n"),
8086 qdotadroff
, ldotadroff
);
8087 codeadroff
= bfd_getl32 (eiaf
->codeadroff
);
8088 lpfixoff
= bfd_getl32 (eiaf
->lpfixoff
);
8089 /* xgettext:c-format */
8090 fprintf (file
, _(" codeadroff: %5u, lpfixoff : %5u\n"),
8091 codeadroff
, lpfixoff
);
8092 chgprtoff
= bfd_getl32 (eiaf
->chgprtoff
);
8093 fprintf (file
, _(" chgprtoff : %5u\n"), chgprtoff
);
8094 shrimgcnt
= bfd_getl32 (eiaf
->shrimgcnt
);
8095 shlstoff
= bfd_getl32 (eiaf
->shlstoff
);
8096 /* xgettext:c-format */
8097 fprintf (file
, _(" shlstoff : %5u, shrimgcnt : %5u\n"),
8098 shlstoff
, shrimgcnt
);
8099 /* xgettext:c-format */
8100 fprintf (file
, _(" shlextra : %5u, permctx : %5u\n"),
8101 (unsigned)bfd_getl32 (eiaf
->shlextra
),
8102 (unsigned)bfd_getl32 (eiaf
->permctx
));
8103 fprintf (file
, _(" base_va : 0x%08x\n"),
8104 (unsigned)bfd_getl32 (eiaf
->base_va
));
8105 fprintf (file
, _(" lppsbfixoff: %5u\n"),
8106 (unsigned)bfd_getl32 (eiaf
->lppsbfixoff
));
8110 struct vms_shl
*shl
= (struct vms_shl
*)(buf
+ shlstoff
);
8113 fprintf (file
, _(" Shareable images:\n"));
8114 for (j
= 0; j
< shrimgcnt
; j
++, shl
++)
8117 /* xgettext:c-format */
8118 _(" %u: size: %u, flags: 0x%02x, name: %.*s\n"),
8119 j
, shl
->size
, shl
->flags
,
8120 shl
->imgnam
[0], shl
->imgnam
+ 1);
8123 if (qrelfixoff
!= 0)
8125 fprintf (file
, _(" quad-word relocation fixups:\n"));
8126 evax_bfd_print_relocation_records (file
, buf
+ qrelfixoff
, 8);
8128 if (lrelfixoff
!= 0)
8130 fprintf (file
, _(" long-word relocation fixups:\n"));
8131 evax_bfd_print_relocation_records (file
, buf
+ lrelfixoff
, 4);
8133 if (qdotadroff
!= 0)
8135 fprintf (file
, _(" quad-word .address reference fixups:\n"));
8136 evax_bfd_print_address_fixups (file
, buf
+ qdotadroff
);
8138 if (ldotadroff
!= 0)
8140 fprintf (file
, _(" long-word .address reference fixups:\n"));
8141 evax_bfd_print_address_fixups (file
, buf
+ ldotadroff
);
8143 if (codeadroff
!= 0)
8145 fprintf (file
, _(" Code Address Reference Fixups:\n"));
8146 evax_bfd_print_reference_fixups (file
, buf
+ codeadroff
);
8150 fprintf (file
, _(" Linkage Pairs Reference Fixups:\n"));
8151 evax_bfd_print_reference_fixups (file
, buf
+ lpfixoff
);
8155 unsigned int count
= (unsigned)bfd_getl32 (buf
+ chgprtoff
);
8156 struct vms_eicp
*eicp
= (struct vms_eicp
*)(buf
+ chgprtoff
+ 4);
8159 fprintf (file
, _(" Change Protection (%u entries):\n"), count
);
8160 for (j
= 0; j
< count
; j
++, eicp
++)
8162 unsigned int prot
= bfd_getl32 (eicp
->newprt
);
8164 /* xgettext:c-format */
8165 _(" base: 0x%08x %08x, size: 0x%08x, prot: 0x%08x "),
8166 (unsigned)bfd_getl32 (eicp
->baseva
+ 4),
8167 (unsigned)bfd_getl32 (eicp
->baseva
+ 0),
8168 (unsigned)bfd_getl32 (eicp
->size
),
8169 (unsigned)bfd_getl32 (eicp
->newprt
));
8173 fprintf (file
, "NA");
8175 case PRT__C_RESERVED
:
8176 fprintf (file
, "RES");
8179 fprintf (file
, "KW");
8182 fprintf (file
, "KR");
8185 fprintf (file
, "UW");
8188 fprintf (file
, "EW");
8191 fprintf (file
, "ERKW");
8194 fprintf (file
, "ER");
8197 fprintf (file
, "SW");
8200 fprintf (file
, "SREW");
8203 fprintf (file
, "SRKW");
8206 fprintf (file
, "SR");
8209 fprintf (file
, "URSW");
8212 fprintf (file
, "UREW");
8215 fprintf (file
, "URKW");
8218 fprintf (file
, "UR");
8232 vms_bfd_print_private_bfd_data (bfd
*abfd
, void *ptr
)
8234 FILE *file
= (FILE *)ptr
;
8236 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
8237 evax_bfd_print_image (abfd
, file
);
8240 if (bfd_seek (abfd
, 0, SEEK_SET
))
8242 evax_bfd_print_eobj (abfd
, file
);
8249 /* Slurp ETIR/EDBG/ETBT VMS object records. */
8252 alpha_vms_read_sections_content (bfd
*abfd
, struct bfd_link_info
*info
)
8254 asection
*cur_section
;
8255 file_ptr cur_offset
;
8256 asection
*dst_section
;
8257 file_ptr dst_offset
;
8259 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
8265 dst_section
= PRIV (dst_section
);
8269 if (info
->strip
== strip_all
|| info
->strip
== strip_debugger
)
8271 /* Discard the DST section. */
8275 else if (dst_section
)
8277 dst_offset
= dst_section
->output_offset
;
8278 dst_section
= dst_section
->output_section
;
8287 type
= _bfd_vms_get_object_record (abfd
);
8290 vms_debug2 ((2, "next_record failed\n"));
8296 PRIV (image_section
) = cur_section
;
8297 PRIV (image_offset
) = cur_offset
;
8298 res
= _bfd_vms_slurp_etir (abfd
, info
);
8299 cur_section
= PRIV (image_section
);
8300 cur_offset
= PRIV (image_offset
);
8304 if (dst_section
== NULL
)
8306 PRIV (image_section
) = dst_section
;
8307 PRIV (image_offset
) = dst_offset
;
8308 res
= _bfd_vms_slurp_etir (abfd
, info
);
8309 dst_offset
= PRIV (image_offset
);
8318 vms_debug2 ((2, "slurp eobj type %d failed\n", type
));
8325 alpha_vms_sizeof_headers (bfd
*abfd ATTRIBUTE_UNUSED
,
8326 struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8331 /* Add a linkage pair fixup at address SECT + OFFSET to SHLIB. */
8334 alpha_vms_add_fixup_lp (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
8336 struct alpha_vms_shlib_el
*sl
;
8337 asection
*sect
= PRIV2 (src
, image_section
);
8338 file_ptr offset
= PRIV2 (src
, image_offset
);
8340 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8341 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8342 sl
->has_fixups
= TRUE
;
8343 VEC_APPEND_EL (sl
->lp
, bfd_vma
,
8344 sect
->output_section
->vma
+ sect
->output_offset
+ offset
);
8345 sect
->output_section
->flags
|= SEC_RELOC
;
8348 /* Add a code address fixup at address SECT + OFFSET to SHLIB. */
8351 alpha_vms_add_fixup_ca (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
8353 struct alpha_vms_shlib_el
*sl
;
8354 asection
*sect
= PRIV2 (src
, image_section
);
8355 file_ptr offset
= PRIV2 (src
, image_offset
);
8357 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8358 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8359 sl
->has_fixups
= TRUE
;
8360 VEC_APPEND_EL (sl
->ca
, bfd_vma
,
8361 sect
->output_section
->vma
+ sect
->output_offset
+ offset
);
8362 sect
->output_section
->flags
|= SEC_RELOC
;
8365 /* Add a quad word relocation fixup at address SECT + OFFSET to SHLIB. */
8368 alpha_vms_add_fixup_qr (struct bfd_link_info
*info
, bfd
*src
,
8369 bfd
*shlib
, bfd_vma vec
)
8371 struct alpha_vms_shlib_el
*sl
;
8372 struct alpha_vms_vma_ref
*r
;
8373 asection
*sect
= PRIV2 (src
, image_section
);
8374 file_ptr offset
= PRIV2 (src
, image_offset
);
8376 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8377 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8378 sl
->has_fixups
= TRUE
;
8379 r
= VEC_APPEND (sl
->qr
, struct alpha_vms_vma_ref
);
8380 r
->vma
= sect
->output_section
->vma
+ sect
->output_offset
+ offset
;
8382 sect
->output_section
->flags
|= SEC_RELOC
;
8386 alpha_vms_add_fixup_lr (struct bfd_link_info
*info ATTRIBUTE_UNUSED
,
8387 unsigned int shr ATTRIBUTE_UNUSED
,
8388 bfd_vma vec ATTRIBUTE_UNUSED
)
8390 /* Not yet supported. */
8394 /* Add relocation. FIXME: Not yet emitted. */
8397 alpha_vms_add_lw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8402 alpha_vms_add_qw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8406 static struct bfd_hash_entry
*
8407 alpha_vms_link_hash_newfunc (struct bfd_hash_entry
*entry
,
8408 struct bfd_hash_table
*table
,
8411 struct alpha_vms_link_hash_entry
*ret
=
8412 (struct alpha_vms_link_hash_entry
*) entry
;
8414 /* Allocate the structure if it has not already been allocated by a
8417 ret
= ((struct alpha_vms_link_hash_entry
*)
8418 bfd_hash_allocate (table
,
8419 sizeof (struct alpha_vms_link_hash_entry
)));
8423 /* Call the allocation method of the superclass. */
8424 ret
= ((struct alpha_vms_link_hash_entry
*)
8425 _bfd_link_hash_newfunc ((struct bfd_hash_entry
*) ret
,
8430 return (struct bfd_hash_entry
*) ret
;
8434 alpha_vms_bfd_link_hash_table_free (bfd
*abfd
)
8436 struct alpha_vms_link_hash_table
*t
;
8439 t
= (struct alpha_vms_link_hash_table
*) abfd
->link
.hash
;
8440 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8442 struct alpha_vms_shlib_el
*shlib
;
8444 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8445 free (&VEC_EL (shlib
->ca
, bfd_vma
, 0));
8446 free (&VEC_EL (shlib
->lp
, bfd_vma
, 0));
8447 free (&VEC_EL (shlib
->qr
, struct alpha_vms_vma_ref
, 0));
8449 free (&VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, 0));
8451 _bfd_generic_link_hash_table_free (abfd
);
8454 /* Create an Alpha/VMS link hash table. */
8456 static struct bfd_link_hash_table
*
8457 alpha_vms_bfd_link_hash_table_create (bfd
*abfd
)
8459 struct alpha_vms_link_hash_table
*ret
;
8460 bfd_size_type amt
= sizeof (struct alpha_vms_link_hash_table
);
8462 ret
= (struct alpha_vms_link_hash_table
*) bfd_malloc (amt
);
8465 if (!_bfd_link_hash_table_init (&ret
->root
, abfd
,
8466 alpha_vms_link_hash_newfunc
,
8467 sizeof (struct alpha_vms_link_hash_entry
)))
8473 VEC_INIT (ret
->shrlibs
);
8475 ret
->root
.hash_table_free
= alpha_vms_bfd_link_hash_table_free
;
8481 alpha_vms_link_add_object_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8485 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
8487 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
8488 struct alpha_vms_link_hash_entry
*h
;
8489 struct bfd_link_hash_entry
*h_root
;
8492 if (!alpha_vms_convert_symbol (abfd
, e
, &sym
))
8495 if ((e
->flags
& EGSY__V_DEF
) && abfd
->selective_search
)
8497 /* In selective_search mode, only add definition that are
8499 h
= (struct alpha_vms_link_hash_entry
*)bfd_link_hash_lookup
8500 (info
->hash
, sym
.name
, FALSE
, FALSE
, FALSE
);
8501 if (h
== NULL
|| h
->root
.type
!= bfd_link_hash_undefined
)
8507 h_root
= (struct bfd_link_hash_entry
*) h
;
8508 if (!_bfd_generic_link_add_one_symbol (info
, abfd
, sym
.name
, sym
.flags
,
8509 sym
.section
, sym
.value
, NULL
,
8510 FALSE
, FALSE
, &h_root
))
8512 h
= (struct alpha_vms_link_hash_entry
*) h_root
;
8514 if ((e
->flags
& EGSY__V_DEF
)
8516 && abfd
->xvec
== info
->output_bfd
->xvec
)
8520 if (abfd
->flags
& DYNAMIC
)
8522 struct alpha_vms_shlib_el
*shlib
;
8524 /* We do not want to include any of the sections in a dynamic
8525 object in the output file. See comment in elflink.c. */
8526 bfd_section_list_clear (abfd
);
8528 shlib
= VEC_APPEND (alpha_vms_link_hash (info
)->shrlibs
,
8529 struct alpha_vms_shlib_el
);
8531 VEC_INIT (shlib
->ca
);
8532 VEC_INIT (shlib
->lp
);
8533 VEC_INIT (shlib
->qr
);
8534 PRIV (shr_index
) = VEC_COUNT (alpha_vms_link_hash (info
)->shrlibs
) - 1;
8541 alpha_vms_link_add_archive_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8544 struct bfd_link_hash_entry
**pundef
;
8545 struct bfd_link_hash_entry
**next_pundef
;
8547 /* We only accept VMS libraries. */
8548 if (info
->output_bfd
->xvec
!= abfd
->xvec
)
8550 bfd_set_error (bfd_error_wrong_format
);
8554 /* The archive_pass field in the archive itself is used to
8555 initialize PASS, since we may search the same archive multiple
8557 pass
= ++abfd
->archive_pass
;
8559 /* Look through the list of undefined symbols. */
8560 for (pundef
= &info
->hash
->undefs
; *pundef
!= NULL
; pundef
= next_pundef
)
8562 struct bfd_link_hash_entry
*h
;
8568 next_pundef
= &(*pundef
)->u
.undef
.next
;
8570 /* When a symbol is defined, it is not necessarily removed from
8572 if (h
->type
!= bfd_link_hash_undefined
8573 && h
->type
!= bfd_link_hash_common
)
8575 /* Remove this entry from the list, for general cleanliness
8576 and because we are going to look through the list again
8577 if we search any more libraries. We can't remove the
8578 entry if it is the tail, because that would lose any
8579 entries we add to the list later on. */
8580 if (*pundef
!= info
->hash
->undefs_tail
)
8582 *pundef
= *next_pundef
;
8583 next_pundef
= pundef
;
8588 /* Look for this symbol in the archive hash table. */
8589 symidx
= _bfd_vms_lib_find_symbol (abfd
, h
->root
.string
);
8590 if (symidx
== BFD_NO_MORE_SYMBOLS
)
8592 /* Nothing in this slot. */
8596 element
= bfd_get_elt_at_index (abfd
, symidx
);
8597 if (element
== NULL
)
8600 if (element
->archive_pass
== -1 || element
->archive_pass
== pass
)
8602 /* Next symbol if this archive is wrong or already handled. */
8606 if (! bfd_check_format (element
, bfd_object
))
8608 element
->archive_pass
= -1;
8612 orig_element
= element
;
8613 if (bfd_is_thin_archive (abfd
))
8615 element
= _bfd_vms_lib_get_imagelib_file (element
);
8616 if (element
== NULL
|| !bfd_check_format (element
, bfd_object
))
8618 orig_element
->archive_pass
= -1;
8623 /* Unlike the generic linker, we know that this element provides
8624 a definition for an undefined symbol and we know that we want
8625 to include it. We don't need to check anything. */
8626 if (!(*info
->callbacks
8627 ->add_archive_element
) (info
, element
, h
->root
.string
, &element
))
8629 if (!alpha_vms_link_add_object_symbols (element
, info
))
8632 orig_element
->archive_pass
= pass
;
8639 alpha_vms_bfd_link_add_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8641 switch (bfd_get_format (abfd
))
8644 vms_debug2 ((2, "vms_link_add_symbols for object %s\n",
8646 return alpha_vms_link_add_object_symbols (abfd
, info
);
8649 vms_debug2 ((2, "vms_link_add_symbols for archive %s\n",
8651 return alpha_vms_link_add_archive_symbols (abfd
, info
);
8654 bfd_set_error (bfd_error_wrong_format
);
8660 alpha_vms_build_fixups (struct bfd_link_info
*info
)
8662 struct alpha_vms_link_hash_table
*t
= alpha_vms_link_hash (info
);
8663 unsigned char *content
;
8665 unsigned int sz
= 0;
8666 unsigned int lp_sz
= 0;
8667 unsigned int ca_sz
= 0;
8668 unsigned int qr_sz
= 0;
8669 unsigned int shrimg_cnt
= 0;
8670 unsigned int chgprt_num
= 0;
8671 unsigned int chgprt_sz
= 0;
8672 struct vms_eiaf
*eiaf
;
8676 /* Shared libraries. */
8677 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8679 struct alpha_vms_shlib_el
*shlib
;
8681 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8683 if (!shlib
->has_fixups
)
8688 if (VEC_COUNT (shlib
->ca
) > 0)
8690 /* Header + entries. */
8692 ca_sz
+= VEC_COUNT (shlib
->ca
) * 4;
8694 if (VEC_COUNT (shlib
->lp
) > 0)
8696 /* Header + entries. */
8698 lp_sz
+= VEC_COUNT (shlib
->lp
) * 4;
8700 if (VEC_COUNT (shlib
->qr
) > 0)
8702 /* Header + entries. */
8704 qr_sz
+= VEC_COUNT (shlib
->qr
) * 8;
8715 /* Finish now if there is no content. */
8716 if (ca_sz
+ lp_sz
+ qr_sz
== 0)
8719 /* Add an eicp entry for the fixup itself. */
8721 for (sec
= info
->output_bfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
8723 /* This isect could be made RO or EXE after relocations are applied. */
8724 if ((sec
->flags
& SEC_RELOC
) != 0
8725 && (sec
->flags
& (SEC_CODE
| SEC_READONLY
)) != 0)
8728 chgprt_sz
= 4 + chgprt_num
* sizeof (struct vms_eicp
);
8730 /* Allocate section content (round-up size) */
8731 sz
= sizeof (struct vms_eiaf
) + shrimg_cnt
* sizeof (struct vms_shl
)
8732 + ca_sz
+ lp_sz
+ qr_sz
+ chgprt_sz
;
8733 sz
= (sz
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
8734 content
= bfd_zalloc (info
->output_bfd
, sz
);
8735 if (content
== NULL
)
8738 sec
= alpha_vms_link_hash (info
)->fixup
;
8739 sec
->contents
= content
;
8742 eiaf
= (struct vms_eiaf
*)content
;
8743 off
= sizeof (struct vms_eiaf
);
8744 bfd_putl32 (0, eiaf
->majorid
);
8745 bfd_putl32 (0, eiaf
->minorid
);
8746 bfd_putl32 (0, eiaf
->iaflink
);
8747 bfd_putl32 (0, eiaf
->fixuplnk
);
8748 bfd_putl32 (sizeof (struct vms_eiaf
), eiaf
->size
);
8749 bfd_putl32 (0, eiaf
->flags
);
8750 bfd_putl32 (0, eiaf
->qrelfixoff
);
8751 bfd_putl32 (0, eiaf
->lrelfixoff
);
8752 bfd_putl32 (0, eiaf
->qdotadroff
);
8753 bfd_putl32 (0, eiaf
->ldotadroff
);
8754 bfd_putl32 (0, eiaf
->codeadroff
);
8755 bfd_putl32 (0, eiaf
->lpfixoff
);
8756 bfd_putl32 (0, eiaf
->chgprtoff
);
8757 bfd_putl32 (shrimg_cnt
? off
: 0, eiaf
->shlstoff
);
8758 bfd_putl32 (shrimg_cnt
, eiaf
->shrimgcnt
);
8759 bfd_putl32 (0, eiaf
->shlextra
);
8760 bfd_putl32 (0, eiaf
->permctx
);
8761 bfd_putl32 (0, eiaf
->base_va
);
8762 bfd_putl32 (0, eiaf
->lppsbfixoff
);
8769 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8771 struct alpha_vms_shlib_el
*shlib
;
8772 struct vms_shl
*shl
;
8774 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8776 if (!shlib
->has_fixups
)
8779 /* Renumber shared images. */
8780 PRIV2 (shlib
->abfd
, shr_index
) = shrimg_cnt
++;
8782 shl
= (struct vms_shl
*)(content
+ off
);
8783 bfd_putl32 (0, shl
->baseva
);
8784 bfd_putl32 (0, shl
->shlptr
);
8785 bfd_putl32 (0, shl
->ident
);
8786 bfd_putl32 (0, shl
->permctx
);
8787 shl
->size
= sizeof (struct vms_shl
);
8788 bfd_putl16 (0, shl
->fill_1
);
8790 bfd_putl32 (0, shl
->icb
);
8791 shl
->imgnam
[0] = strlen (PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
));
8792 memcpy (shl
->imgnam
+ 1, PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
),
8795 off
+= sizeof (struct vms_shl
);
8801 bfd_putl32 (off
, eiaf
->codeadroff
);
8803 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8805 struct alpha_vms_shlib_el
*shlib
;
8808 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8810 if (VEC_COUNT (shlib
->ca
) == 0)
8813 bfd_putl32 (VEC_COUNT (shlib
->ca
), content
+ off
);
8814 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8817 for (j
= 0; j
< VEC_COUNT (shlib
->ca
); j
++)
8819 bfd_putl32 (VEC_EL (shlib
->ca
, bfd_vma
, j
) - t
->base_addr
,
8825 bfd_putl32 (0, content
+ off
);
8826 bfd_putl32 (0, content
+ off
+ 4);
8833 bfd_putl32 (off
, eiaf
->lpfixoff
);
8835 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8837 struct alpha_vms_shlib_el
*shlib
;
8840 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8842 if (VEC_COUNT (shlib
->lp
) == 0)
8845 bfd_putl32 (VEC_COUNT (shlib
->lp
), content
+ off
);
8846 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8849 for (j
= 0; j
< VEC_COUNT (shlib
->lp
); j
++)
8851 bfd_putl32 (VEC_EL (shlib
->lp
, bfd_vma
, j
) - t
->base_addr
,
8857 bfd_putl32 (0, content
+ off
);
8858 bfd_putl32 (0, content
+ off
+ 4);
8865 bfd_putl32 (off
, eiaf
->qdotadroff
);
8867 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8869 struct alpha_vms_shlib_el
*shlib
;
8872 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8874 if (VEC_COUNT (shlib
->qr
) == 0)
8877 bfd_putl32 (VEC_COUNT (shlib
->qr
), content
+ off
);
8878 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8881 for (j
= 0; j
< VEC_COUNT (shlib
->qr
); j
++)
8883 struct alpha_vms_vma_ref
*r
;
8884 r
= &VEC_EL (shlib
->qr
, struct alpha_vms_vma_ref
, j
);
8885 bfd_putl32 (r
->vma
- t
->base_addr
, content
+ off
);
8886 bfd_putl32 (r
->ref
, content
+ off
+ 4);
8891 bfd_putl32 (0, content
+ off
);
8892 bfd_putl32 (0, content
+ off
+ 4);
8897 /* Write the change protection table. */
8898 bfd_putl32 (off
, eiaf
->chgprtoff
);
8899 bfd_putl32 (chgprt_num
, content
+ off
);
8902 for (sec
= info
->output_bfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
8904 struct vms_eicp
*eicp
;
8907 if ((sec
->flags
& SEC_LINKER_CREATED
) != 0 &&
8908 strcmp (sec
->name
, "$FIXUP$") == 0)
8910 else if ((sec
->flags
& SEC_RELOC
) != 0
8911 && (sec
->flags
& (SEC_CODE
| SEC_READONLY
)) != 0)
8916 eicp
= (struct vms_eicp
*)(content
+ off
);
8917 bfd_putl64 (sec
->vma
- t
->base_addr
, eicp
->baseva
);
8918 bfd_putl32 ((sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1),
8920 bfd_putl32 (prot
, eicp
->newprt
);
8921 off
+= sizeof (struct vms_eicp
);
8927 /* Called by bfd_hash_traverse to fill the symbol table.
8928 Return FALSE in case of failure. */
8931 alpha_vms_link_output_symbol (struct bfd_hash_entry
*bh
, void *infov
)
8933 struct bfd_link_hash_entry
*hc
= (struct bfd_link_hash_entry
*) bh
;
8934 struct bfd_link_info
*info
= (struct bfd_link_info
*)infov
;
8935 struct alpha_vms_link_hash_entry
*h
;
8936 struct vms_symbol_entry
*sym
;
8938 if (hc
->type
== bfd_link_hash_warning
)
8941 if (hc
->type
== bfd_link_hash_new
)
8944 h
= (struct alpha_vms_link_hash_entry
*) hc
;
8946 switch (h
->root
.type
)
8948 case bfd_link_hash_undefined
:
8950 case bfd_link_hash_new
:
8951 case bfd_link_hash_warning
:
8953 case bfd_link_hash_undefweak
:
8955 case bfd_link_hash_defined
:
8956 case bfd_link_hash_defweak
:
8958 asection
*sec
= h
->root
.u
.def
.section
;
8960 /* FIXME: this is certainly a symbol from a dynamic library. */
8961 if (bfd_is_abs_section (sec
))
8964 if (sec
->owner
->flags
& DYNAMIC
)
8968 case bfd_link_hash_common
:
8970 case bfd_link_hash_indirect
:
8974 /* Do not write not kept symbols. */
8975 if (info
->strip
== strip_some
8976 && bfd_hash_lookup (info
->keep_hash
, h
->root
.root
.string
,
8977 FALSE
, FALSE
) != NULL
)
8982 /* This symbol doesn't come from a VMS object. So we suppose it is
8984 int len
= strlen (h
->root
.root
.string
);
8986 sym
= (struct vms_symbol_entry
*)bfd_zalloc (info
->output_bfd
,
8987 sizeof (*sym
) + len
);
8991 memcpy (sym
->name
, h
->root
.root
.string
, len
);
8993 sym
->owner
= info
->output_bfd
;
8995 sym
->typ
= EGSD__C_SYMG
;
8997 sym
->flags
= EGSY__V_DEF
| EGSY__V_REL
;
8998 sym
->symbol_vector
= h
->root
.u
.def
.value
;
8999 sym
->section
= h
->root
.u
.def
.section
;
9000 sym
->value
= h
->root
.u
.def
.value
;
9005 if (!add_symbol_entry (info
->output_bfd
, sym
))
9012 alpha_vms_bfd_final_link (bfd
*abfd
, struct bfd_link_info
*info
)
9015 struct bfd_link_order
*p
;
9023 if (bfd_link_relocatable (info
))
9025 /* FIXME: we do not yet support relocatable link. It is not obvious
9026 how to do it for debug infos. */
9027 (*info
->callbacks
->einfo
)(_("%P: relocatable link is not supported\n"));
9031 abfd
->outsymbols
= NULL
;
9034 /* Mark all sections which will be included in the output file. */
9035 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9036 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
9037 if (p
->type
== bfd_indirect_link_order
)
9038 p
->u
.indirect
.section
->linker_mark
= TRUE
;
9041 /* Handle all the link order information for the sections. */
9042 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9044 printf ("For section %s (at 0x%08x, flags=0x%08x):\n",
9045 o
->name
, (unsigned)o
->vma
, (unsigned)o
->flags
);
9047 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
9049 printf (" at 0x%08x - 0x%08x: ",
9050 (unsigned)p
->offset
, (unsigned)(p
->offset
+ p
->size
- 1));
9053 case bfd_section_reloc_link_order
:
9054 case bfd_symbol_reloc_link_order
:
9055 printf (" section/symbol reloc\n");
9057 case bfd_indirect_link_order
:
9058 printf (" section %s of %s\n",
9059 p
->u
.indirect
.section
->name
,
9060 p
->u
.indirect
.section
->owner
->filename
);
9062 case bfd_data_link_order
:
9063 printf (" explicit data\n");
9066 printf (" *unknown* type %u\n", p
->type
);
9073 /* Generate the symbol table. */
9074 BFD_ASSERT (PRIV (syms
) == NULL
);
9075 if (info
->strip
!= strip_all
)
9076 bfd_hash_traverse (&info
->hash
->table
, alpha_vms_link_output_symbol
, info
);
9078 /* Find the entry point. */
9079 if (bfd_get_start_address (abfd
) == 0)
9081 bfd
*startbfd
= NULL
;
9083 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9085 /* Consider only VMS object files. */
9086 if (sub
->xvec
!= abfd
->xvec
)
9089 if (!PRIV2 (sub
, eom_data
).eom_has_transfer
)
9091 if ((PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
) && startbfd
)
9093 if (startbfd
!= NULL
9094 && !(PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
))
9096 (*info
->callbacks
->einfo
)
9097 /* xgettext:c-format */
9098 (_("%P: multiple entry points: in modules %pB and %pB\n"),
9107 unsigned int ps_idx
= PRIV2 (startbfd
, eom_data
).eom_l_psindx
;
9108 bfd_vma tfradr
= PRIV2 (startbfd
, eom_data
).eom_l_tfradr
;
9111 sec
= PRIV2 (startbfd
, sections
)[ps_idx
];
9113 bfd_set_start_address
9114 (abfd
, sec
->output_section
->vma
+ sec
->output_offset
+ tfradr
);
9118 /* Set transfer addresses. */
9121 struct bfd_link_hash_entry
*h
;
9124 PRIV (transfer_address
[i
++]) = 0xffffffff00000340ULL
; /* SYS$IMGACT */
9125 h
= bfd_link_hash_lookup (info
->hash
, "LIB$INITIALIZE", FALSE
, FALSE
, TRUE
);
9126 if (h
!= NULL
&& h
->type
== bfd_link_hash_defined
)
9127 PRIV (transfer_address
[i
++]) =
9128 alpha_vms_get_sym_value (h
->u
.def
.section
, h
->u
.def
.value
);
9129 PRIV (transfer_address
[i
++]) = bfd_get_start_address (abfd
);
9131 PRIV (transfer_address
[i
++]) = 0;
9134 /* Allocate contents.
9135 Also compute the virtual base address. */
9136 base_addr
= (bfd_vma
)-1;
9138 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9140 if (o
->flags
& SEC_HAS_CONTENTS
)
9142 o
->contents
= bfd_alloc (abfd
, o
->size
);
9143 if (o
->contents
== NULL
)
9146 if (o
->flags
& SEC_LOAD
)
9148 if (o
->vma
< base_addr
)
9150 if (o
->vma
+ o
->size
> last_addr
)
9151 last_addr
= o
->vma
+ o
->size
;
9153 /* Clear the RELOC flags. Currently we don't support incremental
9154 linking. We use the RELOC flag for computing the eicp entries. */
9155 o
->flags
&= ~SEC_RELOC
;
9158 /* Create the fixup section. */
9159 fixupsec
= bfd_make_section_anyway_with_flags
9160 (info
->output_bfd
, "$FIXUP$",
9161 SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
9162 if (fixupsec
== NULL
)
9164 last_addr
= (last_addr
+ 0xffff) & ~0xffff;
9165 fixupsec
->vma
= last_addr
;
9167 alpha_vms_link_hash (info
)->fixup
= fixupsec
;
9168 alpha_vms_link_hash (info
)->base_addr
= base_addr
;
9170 /* Create the DMT section, if necessary. */
9171 BFD_ASSERT (PRIV (dst_section
) == NULL
);
9172 dst
= bfd_get_section_by_name (abfd
, "$DST$");
9173 if (dst
!= NULL
&& dst
->size
== 0)
9177 PRIV (dst_section
) = dst
;
9178 dmt
= bfd_make_section_anyway_with_flags
9179 (info
->output_bfd
, "$DMT$",
9180 SEC_DEBUGGING
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
9187 /* Read all sections from the inputs. */
9188 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9190 if (sub
->flags
& DYNAMIC
)
9192 alpha_vms_create_eisd_for_shared (abfd
, sub
);
9196 if (!alpha_vms_read_sections_content (sub
, info
))
9200 /* Handle all the link order information for the sections.
9201 Note: past this point, it is not possible to create new sections. */
9202 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9204 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
9208 case bfd_section_reloc_link_order
:
9209 case bfd_symbol_reloc_link_order
:
9212 case bfd_indirect_link_order
:
9216 if (! _bfd_default_link_order (abfd
, info
, o
, p
))
9223 /* Compute fixups. */
9224 if (!alpha_vms_build_fixups (info
))
9227 /* Compute the DMT. */
9231 unsigned char *contents
= NULL
;
9233 /* In pass 1, compute the size. In pass 2, write the DMT contents. */
9234 for (pass
= 0; pass
< 2; pass
++)
9236 unsigned int off
= 0;
9238 /* For each object file (ie for each module). */
9239 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9242 struct vms_dmt_header
*dmth
= NULL
;
9243 unsigned int psect_count
;
9245 /* Skip this module if it has no DST. */
9246 sub_dst
= PRIV2 (sub
, dst_section
);
9247 if (sub_dst
== NULL
|| sub_dst
->size
== 0)
9252 /* Write the header. */
9253 dmth
= (struct vms_dmt_header
*)(contents
+ off
);
9254 bfd_putl32 (sub_dst
->output_offset
, dmth
->modbeg
);
9255 bfd_putl32 (sub_dst
->size
, dmth
->size
);
9258 off
+= sizeof (struct vms_dmt_header
);
9261 /* For each section (ie for each psect). */
9262 for (o
= sub
->sections
; o
!= NULL
; o
= o
->next
)
9264 /* Only consider interesting sections. */
9265 if (!(o
->flags
& SEC_ALLOC
))
9267 if (o
->flags
& SEC_LINKER_CREATED
)
9272 /* Write an entry. */
9273 struct vms_dmt_psect
*dmtp
;
9275 dmtp
= (struct vms_dmt_psect
*)(contents
+ off
);
9276 bfd_putl32 (o
->output_offset
+ o
->output_section
->vma
,
9278 bfd_putl32 (o
->size
, dmtp
->length
);
9281 off
+= sizeof (struct vms_dmt_psect
);
9284 bfd_putl32 (psect_count
, dmth
->psect_count
);
9289 contents
= bfd_zalloc (info
->output_bfd
, off
);
9290 if (contents
== NULL
)
9292 dmt
->contents
= contents
;
9297 BFD_ASSERT (off
== dmt
->size
);
9305 /* Read the contents of a section.
9306 buf points to a buffer of buf_size bytes to be filled with
9307 section data (starting at offset into section) */
9310 alpha_vms_get_section_contents (bfd
*abfd
, asection
*section
,
9311 void *buf
, file_ptr offset
,
9312 bfd_size_type count
)
9316 /* Image are easy. */
9317 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
9318 return _bfd_generic_get_section_contents (abfd
, section
,
9319 buf
, offset
, count
);
9322 if (offset
+ count
< count
9323 || offset
+ count
> section
->size
)
9325 bfd_set_error (bfd_error_invalid_operation
);
9329 /* If the section is already in memory, just copy it. */
9330 if (section
->flags
& SEC_IN_MEMORY
)
9332 BFD_ASSERT (section
->contents
!= NULL
);
9333 memcpy (buf
, section
->contents
+ offset
, count
);
9336 if (section
->size
== 0)
9339 /* Alloc in memory and read ETIRs. */
9340 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
9342 BFD_ASSERT (sec
->contents
== NULL
);
9344 if (sec
->size
!= 0 && (sec
->flags
& SEC_HAS_CONTENTS
))
9346 sec
->contents
= bfd_alloc (abfd
, sec
->size
);
9347 if (sec
->contents
== NULL
)
9351 if (!alpha_vms_read_sections_content (abfd
, NULL
))
9353 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
9355 sec
->flags
|= SEC_IN_MEMORY
;
9356 memcpy (buf
, section
->contents
+ offset
, count
);
9361 /* Set the format of a file being written. */
9364 alpha_vms_mkobject (bfd
* abfd
)
9366 const bfd_arch_info_type
*arch
;
9368 vms_debug2 ((1, "alpha_vms_mkobject (%p)\n", abfd
));
9370 if (!vms_initialize (abfd
))
9373 PRIV (recwr
.buf
) = bfd_alloc (abfd
, MAX_OUTREC_SIZE
);
9374 if (PRIV (recwr
.buf
) == NULL
)
9377 arch
= bfd_scan_arch ("alpha");
9381 bfd_set_error (bfd_error_wrong_format
);
9385 abfd
->arch_info
= arch
;
9392 /* Called when the BFD is being closed to do any necessary cleanup. */
9395 vms_close_and_cleanup (bfd
* abfd
)
9397 vms_debug2 ((1, "vms_close_and_cleanup (%p)\n", abfd
));
9399 if (abfd
== NULL
|| abfd
->tdata
.any
== NULL
)
9402 if (abfd
->format
== bfd_object
)
9404 alpha_vms_free_private (abfd
);
9407 if (abfd
->direction
== write_direction
)
9409 /* Last step on VMS is to convert the file to variable record length
9411 if (!bfd_cache_close (abfd
))
9413 if (!_bfd_vms_convert_to_var_unix_filename (abfd
->filename
))
9419 return _bfd_generic_close_and_cleanup (abfd
);
9422 /* Called when a new section is created. */
9425 vms_new_section_hook (bfd
* abfd
, asection
*section
)
9429 vms_debug2 ((1, "vms_new_section_hook (%p, [%u]%s)\n",
9430 abfd
, section
->index
, section
->name
));
9432 if (!bfd_set_section_alignment (section
, 0))
9435 vms_debug2 ((7, "%u: %s\n", section
->index
, section
->name
));
9437 amt
= sizeof (struct vms_section_data_struct
);
9438 section
->used_by_bfd
= bfd_zalloc (abfd
, amt
);
9439 if (section
->used_by_bfd
== NULL
)
9442 /* Create the section symbol. */
9443 return _bfd_generic_new_section_hook (abfd
, section
);
9446 /* Part 4.5, symbols. */
9448 /* Print symbol to file according to how. how is one of
9449 bfd_print_symbol_name just print the name
9450 bfd_print_symbol_more print more (???)
9451 bfd_print_symbol_all print all we know, which is not much right now :-). */
9454 vms_print_symbol (bfd
* abfd
,
9457 bfd_print_symbol_type how
)
9459 vms_debug2 ((1, "vms_print_symbol (%p, %p, %p, %d)\n",
9460 abfd
, file
, symbol
, how
));
9464 case bfd_print_symbol_name
:
9465 case bfd_print_symbol_more
:
9466 fprintf ((FILE *)file
," %s", symbol
->name
);
9469 case bfd_print_symbol_all
:
9471 const char *section_name
= symbol
->section
->name
;
9473 bfd_print_symbol_vandf (abfd
, file
, symbol
);
9475 fprintf ((FILE *) file
," %-8s %s", section_name
, symbol
->name
);
9481 /* Return information about symbol in ret.
9483 fill type, value and name
9486 B bss segment symbol
9488 D data segment symbol
9490 t a static function symbol
9491 T text segment symbol
9496 vms_get_symbol_info (bfd
* abfd ATTRIBUTE_UNUSED
,
9502 vms_debug2 ((1, "vms_get_symbol_info (%p, %p, %p)\n", abfd
, symbol
, ret
));
9504 sec
= symbol
->section
;
9511 else if (bfd_is_com_section (sec
))
9513 else if (bfd_is_abs_section (sec
))
9515 else if (bfd_is_und_section (sec
))
9517 else if (bfd_is_ind_section (sec
))
9519 else if ((symbol
->flags
& BSF_FUNCTION
)
9520 || (bfd_section_flags (sec
) & SEC_CODE
))
9522 else if (bfd_section_flags (sec
) & SEC_DATA
)
9524 else if (bfd_section_flags (sec
) & SEC_ALLOC
)
9529 if (ret
->type
!= 'U')
9530 ret
->value
= symbol
->value
+ symbol
->section
->vma
;
9533 ret
->name
= symbol
->name
;
9536 /* Return TRUE if the given symbol sym in the BFD abfd is
9537 a compiler generated local label, else return FALSE. */
9540 vms_bfd_is_local_label_name (bfd
* abfd ATTRIBUTE_UNUSED
,
9543 return name
[0] == '$';
9546 /* Part 4.7, writing an object file. */
9548 /* Sets the contents of the section section in BFD abfd to the data starting
9549 in memory at LOCATION. The data is written to the output section starting
9550 at offset offset for count bytes.
9552 Normally TRUE is returned, else FALSE. Possible error returns are:
9553 o bfd_error_no_contents - The output section does not have the
9554 SEC_HAS_CONTENTS attribute, so nothing can be written to it.
9555 o and some more too */
9558 _bfd_vms_set_section_contents (bfd
* abfd
,
9560 const void * location
,
9562 bfd_size_type count
)
9564 if (section
->contents
== NULL
)
9566 section
->contents
= bfd_alloc (abfd
, section
->size
);
9567 if (section
->contents
== NULL
)
9570 memcpy (section
->contents
+ offset
, location
, (size_t) count
);
9576 /* Set the architecture and machine type in BFD abfd to arch and mach.
9577 Find the correct pointer to a structure and insert it into the arch_info
9581 alpha_vms_set_arch_mach (bfd
*abfd
,
9582 enum bfd_architecture arch
, unsigned long mach
)
9584 if (arch
!= bfd_arch_alpha
9585 && arch
!= bfd_arch_unknown
)
9588 return bfd_default_set_arch_mach (abfd
, arch
, mach
);
9591 /* Set section VMS flags. Clear NO_FLAGS and set FLAGS. */
9594 bfd_vms_set_section_flags (bfd
*abfd ATTRIBUTE_UNUSED
,
9595 asection
*sec
, flagword no_flags
, flagword flags
)
9597 vms_section_data (sec
)->no_flags
= no_flags
;
9598 vms_section_data (sec
)->flags
= flags
;
9601 struct vms_private_data_struct
*
9602 bfd_vms_get_data (bfd
*abfd
)
9604 return (struct vms_private_data_struct
*)abfd
->tdata
.any
;
9607 #define vms_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false
9608 #define vms_bfd_link_just_syms _bfd_generic_link_just_syms
9609 #define vms_bfd_copy_link_hash_symbol_type \
9610 _bfd_generic_copy_link_hash_symbol_type
9611 #define vms_bfd_is_group_section bfd_generic_is_group_section
9612 #define vms_bfd_group_name bfd_generic_group_name
9613 #define vms_bfd_discard_group bfd_generic_discard_group
9614 #define vms_section_already_linked _bfd_generic_section_already_linked
9615 #define vms_bfd_define_common_symbol bfd_generic_define_common_symbol
9616 #define vms_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
9617 #define vms_bfd_define_start_stop bfd_generic_define_start_stop
9618 #define vms_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
9620 #define vms_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
9621 #define vms_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
9622 #define vms_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data
9623 #define vms_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
9624 #define vms_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
9625 #define vms_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
9627 /* Symbols table. */
9628 #define alpha_vms_make_empty_symbol _bfd_generic_make_empty_symbol
9629 #define alpha_vms_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false
9630 #define alpha_vms_print_symbol vms_print_symbol
9631 #define alpha_vms_get_symbol_info vms_get_symbol_info
9632 #define alpha_vms_get_symbol_version_string \
9633 _bfd_nosymbols_get_symbol_version_string
9635 #define alpha_vms_read_minisymbols _bfd_generic_read_minisymbols
9636 #define alpha_vms_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
9637 #define alpha_vms_get_lineno _bfd_nosymbols_get_lineno
9638 #define alpha_vms_find_inliner_info _bfd_nosymbols_find_inliner_info
9639 #define alpha_vms_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
9640 #define alpha_vms_find_nearest_line _bfd_vms_find_nearest_line
9641 #define alpha_vms_find_line _bfd_nosymbols_find_line
9642 #define alpha_vms_bfd_is_local_label_name vms_bfd_is_local_label_name
9644 /* Generic table. */
9645 #define alpha_vms_close_and_cleanup vms_close_and_cleanup
9646 #define alpha_vms_bfd_free_cached_info vms_bfd_free_cached_info
9647 #define alpha_vms_new_section_hook vms_new_section_hook
9648 #define alpha_vms_set_section_contents _bfd_vms_set_section_contents
9649 #define alpha_vms_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
9651 #define alpha_vms_bfd_get_relocated_section_contents \
9652 bfd_generic_get_relocated_section_contents
9654 #define alpha_vms_bfd_relax_section bfd_generic_relax_section
9655 #define alpha_vms_bfd_gc_sections bfd_generic_gc_sections
9656 #define alpha_vms_bfd_lookup_section_flags bfd_generic_lookup_section_flags
9657 #define alpha_vms_bfd_merge_sections bfd_generic_merge_sections
9658 #define alpha_vms_bfd_is_group_section bfd_generic_is_group_section
9659 #define alpha_vms_bfd_group_name bfd_generic_group_name
9660 #define alpha_vms_bfd_discard_group bfd_generic_discard_group
9661 #define alpha_vms_section_already_linked \
9662 _bfd_generic_section_already_linked
9664 #define alpha_vms_bfd_define_common_symbol bfd_generic_define_common_symbol
9665 #define alpha_vms_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
9666 #define alpha_vms_bfd_define_start_stop bfd_generic_define_start_stop
9667 #define alpha_vms_bfd_link_just_syms _bfd_generic_link_just_syms
9668 #define alpha_vms_bfd_copy_link_hash_symbol_type \
9669 _bfd_generic_copy_link_hash_symbol_type
9671 #define alpha_vms_bfd_link_split_section _bfd_generic_link_split_section
9673 #define alpha_vms_get_dynamic_symtab_upper_bound \
9674 _bfd_nodynamic_get_dynamic_symtab_upper_bound
9675 #define alpha_vms_canonicalize_dynamic_symtab \
9676 _bfd_nodynamic_canonicalize_dynamic_symtab
9677 #define alpha_vms_get_dynamic_reloc_upper_bound \
9678 _bfd_nodynamic_get_dynamic_reloc_upper_bound
9679 #define alpha_vms_canonicalize_dynamic_reloc \
9680 _bfd_nodynamic_canonicalize_dynamic_reloc
9681 #define alpha_vms_bfd_link_check_relocs _bfd_generic_link_check_relocs
9683 const bfd_target alpha_vms_vec
=
9685 "vms-alpha", /* Name. */
9686 bfd_target_evax_flavour
,
9687 BFD_ENDIAN_LITTLE
, /* Data byte order is little. */
9688 BFD_ENDIAN_LITTLE
, /* Header byte order is little. */
9690 (HAS_RELOC
| EXEC_P
| HAS_LINENO
| HAS_DEBUG
| HAS_SYMS
| HAS_LOCALS
9691 | WP_TEXT
| D_PAGED
), /* Object flags. */
9692 (SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
9693 | SEC_READONLY
| SEC_CODE
| SEC_DATA
9694 | SEC_HAS_CONTENTS
| SEC_IN_MEMORY
), /* Sect flags. */
9695 0, /* symbol_leading_char. */
9696 ' ', /* ar_pad_char. */
9697 15, /* ar_max_namelen. */
9698 0, /* match priority. */
9699 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
9700 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
9701 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
9702 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
9703 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
9704 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
9706 { /* bfd_check_format. */
9709 _bfd_vms_lib_alpha_archive_p
,
9712 { /* bfd_set_format. */
9713 _bfd_bool_bfd_false_error
,
9715 _bfd_vms_lib_alpha_mkarchive
,
9716 _bfd_bool_bfd_false_error
9718 { /* bfd_write_contents. */
9719 _bfd_bool_bfd_false_error
,
9720 alpha_vms_write_object_contents
,
9721 _bfd_vms_lib_write_archive_contents
,
9722 _bfd_bool_bfd_false_error
9725 BFD_JUMP_TABLE_GENERIC (alpha_vms
),
9726 BFD_JUMP_TABLE_COPY (vms
),
9727 BFD_JUMP_TABLE_CORE (_bfd_nocore
),
9728 BFD_JUMP_TABLE_ARCHIVE (_bfd_vms_lib
),
9729 BFD_JUMP_TABLE_SYMBOLS (alpha_vms
),
9730 BFD_JUMP_TABLE_RELOCS (alpha_vms
),
9731 BFD_JUMP_TABLE_WRITE (alpha_vms
),
9732 BFD_JUMP_TABLE_LINK (alpha_vms
),
9733 BFD_JUMP_TABLE_DYNAMIC (alpha_vms
),