1 /* vms.c -- BFD back-end for EVAX (openVMS/Alpha) files.
2 Copyright (C) 1996-2023 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)
51 #include "vms/eihvn.h"
52 #include "vms/eobjrec.h"
55 #include "vms/esgps.h"
64 #include "vms/esdfm.h"
65 #include "vms/esdfv.h"
71 #include "vms/internal.h"
74 #define MIN(a,b) ((a) < (b) ? (a) : (b))
79 /* The r_type field in a reloc is one of the following values. */
80 #define ALPHA_R_IGNORE 0
81 #define ALPHA_R_REFQUAD 1
82 #define ALPHA_R_BRADDR 2
83 #define ALPHA_R_HINT 3
84 #define ALPHA_R_SREL16 4
85 #define ALPHA_R_SREL32 5
86 #define ALPHA_R_SREL64 6
87 #define ALPHA_R_OP_PUSH 7
88 #define ALPHA_R_OP_STORE 8
89 #define ALPHA_R_OP_PSUB 9
90 #define ALPHA_R_OP_PRSHIFT 10
91 #define ALPHA_R_LINKAGE 11
92 #define ALPHA_R_REFLONG 12
93 #define ALPHA_R_CODEADDR 13
94 #define ALPHA_R_NOP 14
95 #define ALPHA_R_BSR 15
96 #define ALPHA_R_LDA 16
97 #define ALPHA_R_BOH 17
99 /* These are used with DST_S_C_LINE_NUM. */
100 #define DST_S_C_LINE_NUM_HEADER_SIZE 4
102 /* These are used with DST_S_C_SOURCE */
104 #define DST_S_B_PCLINE_UNSBYTE 1
105 #define DST_S_W_PCLINE_UNSWORD 1
106 #define DST_S_L_PCLINE_UNSLONG 1
108 #define DST_S_B_MODBEG_NAME 14
109 #define DST_S_L_RTNBEG_ADDRESS 5
110 #define DST_S_B_RTNBEG_NAME 13
111 #define DST_S_L_RTNEND_SIZE 5
113 /* These are used with DST_S_C_SOURCE. */
114 #define DST_S_C_SOURCE_HEADER_SIZE 4
116 #define DST_S_B_SRC_DF_LENGTH 1
117 #define DST_S_W_SRC_DF_FILEID 3
118 #define DST_S_B_SRC_DF_FILENAME 20
119 #define DST_S_B_SRC_UNSBYTE 1
120 #define DST_S_W_SRC_UNSWORD 1
121 #define DST_S_L_SRC_UNSLONG 1
123 /* Debugger symbol definitions. */
125 #define DBG_S_L_DMT_MODBEG 0
126 #define DBG_S_L_DST_SIZE 4
127 #define DBG_S_W_DMT_PSECT_COUNT 8
128 #define DBG_S_C_DMT_HEADER_SIZE 12
130 #define DBG_S_L_DMT_PSECT_START 0
131 #define DBG_S_L_DMT_PSECT_LENGTH 4
132 #define DBG_S_C_DMT_PSECT_SIZE 8
134 /* VMS module header. */
150 #define EMH_DATE_LENGTH 17
152 /* VMS End-Of-Module records (EOM/EEOM). */
156 unsigned int eom_l_total_lps
;
157 unsigned short eom_w_comcod
;
158 bool eom_has_transfer
;
159 unsigned char eom_b_tfrflg
;
160 unsigned int eom_l_psindx
;
161 unsigned int eom_l_tfradr
;
164 struct vms_symbol_entry
170 unsigned char data_type
;
171 unsigned short flags
;
173 /* Section and offset/value of the symbol. */
177 /* Section and offset/value for the entry point (only for subprg). */
178 asection
*code_section
;
179 unsigned int code_value
;
181 /* Symbol vector offset. */
182 unsigned int symbol_vector
;
184 /* Length of the name. */
185 unsigned char namelen
;
190 /* Stack value for push/pop commands. */
198 #define STACKSIZE 128
200 /* A minimal decoding of DST compilation units. We only decode
201 what's needed to get to the line number information. */
211 struct srecinfo
*next
;
219 struct lineinfo
*next
;
226 struct funcinfo
*next
;
234 /* Chain the previously read compilation unit. */
237 /* The module name. */
240 /* The start offset and size of debug info in the DST section. */
244 /* The lowest and highest addresses contained in this compilation
245 unit as specified in the compilation unit header. */
249 /* The listing line table. */
250 struct lineinfo
*line_table
;
252 /* The source record table. */
253 struct srecinfo
*srec_table
;
255 /* A list of the functions found in this module. */
256 struct funcinfo
*func_table
;
258 /* Current allocation of file_table. */
259 unsigned int file_table_count
;
261 /* An array of the files making up this module. */
262 struct fileinfo
*file_table
;
265 /* BFD private data for alpha-vms. */
267 struct vms_private_data_struct
269 /* If 1, relocs have been read successfully, if 0 they have yet to be
270 read, if -1 reading relocs failed. */
273 /* Record input buffer. */
274 struct vms_rec_rd recrd
;
275 struct vms_rec_wr recwr
;
277 struct hdr_struct hdr_data
; /* data from HDR/EMH record */
278 struct eom_struct eom_data
; /* data from EOM/EEOM record */
280 /* Transfer addresses (entry points). */
281 bfd_vma transfer_address
[4];
283 /* Array of GSD sections to get the correspond BFD one. */
284 unsigned int section_max
; /* Size of the sections array. */
285 unsigned int section_count
; /* Number of GSD sections. */
288 /* Array of raw symbols. */
289 struct vms_symbol_entry
**syms
;
291 /* Canonicalized symbols. */
294 /* Number of symbols. */
295 unsigned int gsd_sym_count
;
296 /* Size of the syms array. */
297 unsigned int max_sym_count
;
298 /* Number of procedure symbols. */
299 unsigned int norm_sym_count
;
301 /* Stack used to evaluate TIR/ETIR commands. */
302 struct stack_struct
*stack
;
305 /* Content reading. */
306 asection
*image_section
; /* section for image_ptr */
307 file_ptr image_offset
; /* Offset for image_ptr. */
309 struct module
*modules
; /* list of all compilation units */
311 /* The DST section. */
312 asection
*dst_section
;
314 unsigned int dst_ptr_offsets_count
; /* # of offsets in following array */
315 unsigned int *dst_ptr_offsets
; /* array of saved image_ptr offsets */
317 /* Shared library support */
318 bfd_vma symvva
; /* relative virtual address of symbol vector */
320 unsigned char matchctl
;
322 /* Shared library index. This is used for input bfd while linking. */
323 unsigned int shr_index
;
325 /* Used to place structures in the file. */
328 /* Simply linked list of eisd. */
329 struct vms_internal_eisd_map
*eisd_head
;
330 struct vms_internal_eisd_map
*eisd_tail
;
332 /* Simply linked list of eisd for shared libraries. */
333 struct vms_internal_eisd_map
*gbl_eisd_head
;
334 struct vms_internal_eisd_map
*gbl_eisd_tail
;
336 /* linkage index counter used by conditional store commands */
337 unsigned int vms_linkage_index
;
340 #define PRIV2(abfd, name) \
341 (((struct vms_private_data_struct *)(abfd)->tdata.any)->name)
342 #define PRIV(name) PRIV2(abfd,name)
345 /* Used to keep extra VMS specific information for a given section.
347 reloc_size holds the size of the relocation stream, note this
348 is very different from the number of relocations as VMS relocations
351 reloc_stream is the actual stream of relocation entries. */
353 struct vms_section_data_struct
355 /* Maximnum number of entries in sec->relocation. */
358 /* Corresponding eisd. Used only while generating executables. */
359 struct vms_internal_eisd_map
*eisd
;
361 /* PSC flags to be clear. */
364 /* PSC flags to be set. */
368 #define vms_section_data(sec) \
369 ((struct vms_section_data_struct *)sec->used_by_bfd)
371 /* To be called from the debugger. */
372 struct vms_private_data_struct
*bfd_vms_get_data (bfd
*);
374 static int vms_get_remaining_object_record (bfd
*, unsigned int);
375 static bool _bfd_vms_slurp_object_records (bfd
* abfd
);
376 static bool alpha_vms_add_fixup_lp (struct bfd_link_info
*, bfd
*, bfd
*);
377 static bool alpha_vms_add_fixup_ca (struct bfd_link_info
*, bfd
*, bfd
*);
378 static bool alpha_vms_add_fixup_qr (struct bfd_link_info
*, bfd
*, bfd
*,
380 static bool alpha_vms_add_fixup_lr (struct bfd_link_info
*, unsigned int,
382 static bool alpha_vms_add_lw_reloc (struct bfd_link_info
*);
383 static bool alpha_vms_add_qw_reloc (struct bfd_link_info
*);
392 /* Number of elements in VEC. */
394 #define VEC_COUNT(VEC) ((VEC).nbr_el)
396 /* Get the address of the Nth element. */
398 #define VEC_EL(VEC, TYPE, N) (((TYPE *)((VEC).els))[N])
400 #define VEC_INIT(VEC) \
407 /* Be sure there is room for a new element. */
409 static void *vector_grow1 (struct vector_type
*vec
, size_t elsz
);
411 /* Allocate room for a new element and return its address. */
413 #define VEC_APPEND(VEC, TYPE) \
414 ((TYPE *) vector_grow1 (&VEC, sizeof (TYPE)))
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
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_read (PRIV (recrd
.buf
), 1, abfd
) != 1)
807 bfd_set_error (bfd_error_file_truncated
);
812 /* Read the record header */
813 if (bfd_read (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_or_free (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_read (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_or_free
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 if (nameoff
>= gsd_size
)
1398 entry
= add_symbol (abfd
, &egst
->namlng
, gsd_size
- nameoff
);
1402 old_flags
= bfd_getl16 (egst
->header
.flags
);
1403 entry
->typ
= gsd_type
;
1404 entry
->data_type
= egst
->header
.datyp
;
1405 entry
->flags
= old_flags
;
1407 entry
->symbol_vector
= bfd_getl32 (egst
->value
);
1409 if (old_flags
& EGSY__V_REL
)
1411 if (PRIV (sections
) == NULL
)
1413 psindx
= bfd_getl32 (egst
->psindx
);
1414 /* PR 21813: Check for an out of range index. */
1415 if (psindx
< 0 || psindx
>= (int) PRIV (section_count
))
1417 entry
->section
= PRIV (sections
)[psindx
];
1420 entry
->section
= bfd_abs_section_ptr
;
1422 entry
->value
= bfd_getl64 (egst
->lp_2
);
1424 if (old_flags
& EGSY__V_NORM
)
1426 PRIV (norm_sym_count
)++;
1428 entry
->code_value
= bfd_getl64 (egst
->lp_1
);
1429 entry
->code_section
= bfd_abs_section_ptr
;
1436 /* Currently ignored. */
1441 _bfd_error_handler (_("unknown EGSD subtype %d"), gsd_type
);
1442 bfd_set_error (bfd_error_bad_value
);
1446 PRIV (recrd
.rec_size
) -= gsd_size
;
1447 PRIV (recrd
.rec
) += gsd_size
;
1450 /* FIXME: Should we complain if PRIV (recrd.rec_size) is not zero ? */
1452 if (PRIV (gsd_sym_count
) > 0)
1453 abfd
->flags
|= HAS_SYMS
;
1458 /* Stack routines for vms ETIR commands. */
1460 /* Push value and section index. */
1463 _bfd_vms_push (bfd
*abfd
, bfd_vma val
, unsigned int reloc
)
1465 vms_debug2 ((4, "<push %08lx (0x%08x) at %d>\n",
1466 (unsigned long)val
, reloc
, PRIV (stackptr
)));
1468 PRIV (stack
[PRIV (stackptr
)]).value
= val
;
1469 PRIV (stack
[PRIV (stackptr
)]).reloc
= reloc
;
1471 if (PRIV (stackptr
) >= STACKSIZE
)
1473 bfd_set_error (bfd_error_bad_value
);
1474 _bfd_error_handler (_("stack overflow (%d) in _bfd_vms_push"), PRIV (stackptr
));
1480 /* Pop value and section index. */
1483 _bfd_vms_pop (bfd
*abfd
, bfd_vma
*val
, unsigned int *rel
)
1485 if (PRIV (stackptr
) == 0)
1487 bfd_set_error (bfd_error_bad_value
);
1488 _bfd_error_handler (_("stack underflow in _bfd_vms_pop"));
1492 *val
= PRIV (stack
[PRIV (stackptr
)]).value
;
1493 *rel
= PRIV (stack
[PRIV (stackptr
)]).reloc
;
1495 vms_debug2 ((4, "<pop %08lx (0x%08x)>\n", (unsigned long)*val
, *rel
));
1499 /* Routines to fill sections contents during tir/etir read. */
1501 /* Initialize image buffer pointer to be filled. */
1504 image_set_ptr (bfd
*abfd
, bfd_vma vma
, int sect
, struct bfd_link_info
*info
)
1508 vms_debug2 ((4, "image_set_ptr (0x%08x, sect=%d)\n", (unsigned)vma
, sect
));
1510 if (PRIV (sections
) == NULL
)
1512 if (sect
< 0 || sect
>= (int) PRIV (section_count
))
1515 sec
= PRIV (sections
)[sect
];
1519 /* Reading contents to an output bfd. */
1521 if (sec
->output_section
== NULL
)
1523 /* Section discarded. */
1524 vms_debug2 ((5, " section %s discarded\n", sec
->name
));
1526 /* This is not used. */
1527 PRIV (image_section
) = NULL
;
1528 PRIV (image_offset
) = 0;
1531 PRIV (image_offset
) = sec
->output_offset
+ vma
;
1532 PRIV (image_section
) = sec
->output_section
;
1536 PRIV (image_offset
) = vma
;
1537 PRIV (image_section
) = sec
;
1541 /* Increment image buffer pointer by offset. */
1544 image_inc_ptr (bfd
*abfd
, bfd_vma offset
)
1546 vms_debug2 ((4, "image_inc_ptr (%u)\n", (unsigned)offset
));
1548 PRIV (image_offset
) += offset
;
1551 /* Save current DST location counter under specified index. */
1554 dst_define_location (bfd
*abfd
, unsigned int loc
)
1556 vms_debug2 ((4, "dst_define_location (%d)\n", (int)loc
));
1560 /* 16M entries ought to be plenty. */
1561 bfd_set_error (bfd_error_bad_value
);
1562 _bfd_error_handler (_("dst_define_location %u too large"), loc
);
1566 /* Grow the ptr offset table if necessary. */
1567 if (loc
+ 1 > PRIV (dst_ptr_offsets_count
))
1569 PRIV (dst_ptr_offsets
)
1570 = bfd_realloc_or_free (PRIV (dst_ptr_offsets
),
1571 (loc
+ 1) * sizeof (unsigned int));
1572 if (PRIV (dst_ptr_offsets
) == NULL
)
1574 memset (PRIV (dst_ptr_offsets
) + PRIV (dst_ptr_offsets_count
), 0,
1575 (loc
- PRIV (dst_ptr_offsets_count
)) * sizeof (unsigned int));
1576 PRIV (dst_ptr_offsets_count
) = loc
+ 1;
1579 PRIV (dst_ptr_offsets
)[loc
] = PRIV (image_offset
);
1583 /* Restore saved DST location counter from specified index. */
1586 dst_restore_location (bfd
*abfd
, unsigned int loc
)
1588 vms_debug2 ((4, "dst_restore_location (%d)\n", (int)loc
));
1590 if (loc
< PRIV (dst_ptr_offsets_count
))
1592 PRIV (image_offset
) = PRIV (dst_ptr_offsets
)[loc
];
1598 /* Retrieve saved DST location counter from specified index. */
1601 dst_retrieve_location (bfd
*abfd
, bfd_vma
*loc
)
1603 vms_debug2 ((4, "dst_retrieve_location (%d)\n", (int) *loc
));
1605 if (*loc
< PRIV (dst_ptr_offsets_count
))
1607 *loc
= PRIV (dst_ptr_offsets
)[*loc
];
1613 /* Write multiple bytes to section image. */
1616 image_write (bfd
*abfd
, unsigned char *ptr
, unsigned int size
)
1618 asection
*sec
= PRIV (image_section
);
1619 size_t off
= PRIV (image_offset
);
1623 || size
> sec
->size
- off
)
1625 bfd_set_error (bfd_error_bad_value
);
1630 _bfd_vms_debug (8, "image_write from (%p, %d) to (%ld)\n", ptr
, size
,
1634 if (PRIV (image_section
)->contents
!= NULL
)
1635 memcpy (sec
->contents
+ off
, ptr
, size
);
1639 for (i
= 0; i
< size
; i
++)
1642 bfd_set_error (bfd_error_bad_value
);
1648 _bfd_hexdump (9, ptr
, size
, 0);
1651 PRIV (image_offset
) += size
;
1655 /* Write byte to section image. */
1658 image_write_b (bfd
* abfd
, unsigned int value
)
1660 unsigned char data
[1];
1662 vms_debug2 ((6, "image_write_b (%02x)\n", (int) value
));
1666 return image_write (abfd
, data
, sizeof (data
));
1669 /* Write 2-byte word to image. */
1672 image_write_w (bfd
* abfd
, unsigned int value
)
1674 unsigned char data
[2];
1676 vms_debug2 ((6, "image_write_w (%04x)\n", (int) value
));
1678 bfd_putl16 (value
, data
);
1679 return image_write (abfd
, data
, sizeof (data
));
1682 /* Write 4-byte long to image. */
1685 image_write_l (bfd
* abfd
, unsigned long value
)
1687 unsigned char data
[4];
1689 vms_debug2 ((6, "image_write_l (%08lx)\n", value
));
1691 bfd_putl32 (value
, data
);
1692 return image_write (abfd
, data
, sizeof (data
));
1695 /* Write 8-byte quad to image. */
1698 image_write_q (bfd
* abfd
, bfd_vma value
)
1700 unsigned char data
[8];
1702 vms_debug2 ((6, "image_write_q (%08lx)\n", (unsigned long)value
));
1704 bfd_putl64 (value
, data
);
1705 return image_write (abfd
, data
, sizeof (data
));
1709 _bfd_vms_etir_name (int cmd
)
1713 case ETIR__C_STA_GBL
: return "ETIR__C_STA_GBL";
1714 case ETIR__C_STA_LW
: return "ETIR__C_STA_LW";
1715 case ETIR__C_STA_QW
: return "ETIR__C_STA_QW";
1716 case ETIR__C_STA_PQ
: return "ETIR__C_STA_PQ";
1717 case ETIR__C_STA_LI
: return "ETIR__C_STA_LI";
1718 case ETIR__C_STA_MOD
: return "ETIR__C_STA_MOD";
1719 case ETIR__C_STA_CKARG
: return "ETIR__C_STA_CKARG";
1720 case ETIR__C_STO_B
: return "ETIR__C_STO_B";
1721 case ETIR__C_STO_W
: return "ETIR__C_STO_W";
1722 case ETIR__C_STO_GBL
: return "ETIR__C_STO_GBL";
1723 case ETIR__C_STO_CA
: return "ETIR__C_STO_CA";
1724 case ETIR__C_STO_RB
: return "ETIR__C_STO_RB";
1725 case ETIR__C_STO_AB
: return "ETIR__C_STO_AB";
1726 case ETIR__C_STO_OFF
: return "ETIR__C_STO_OFF";
1727 case ETIR__C_STO_IMM
: return "ETIR__C_STO_IMM";
1728 case ETIR__C_STO_IMMR
: return "ETIR__C_STO_IMMR";
1729 case ETIR__C_STO_LW
: return "ETIR__C_STO_LW";
1730 case ETIR__C_STO_QW
: return "ETIR__C_STO_QW";
1731 case ETIR__C_STO_GBL_LW
: return "ETIR__C_STO_GBL_LW";
1732 case ETIR__C_STO_LP_PSB
: return "ETIR__C_STO_LP_PSB";
1733 case ETIR__C_STO_HINT_GBL
: return "ETIR__C_STO_HINT_GBL";
1734 case ETIR__C_STO_HINT_PS
: return "ETIR__C_STO_HINT_PS";
1735 case ETIR__C_OPR_ADD
: return "ETIR__C_OPR_ADD";
1736 case ETIR__C_OPR_SUB
: return "ETIR__C_OPR_SUB";
1737 case ETIR__C_OPR_INSV
: return "ETIR__C_OPR_INSV";
1738 case ETIR__C_OPR_USH
: return "ETIR__C_OPR_USH";
1739 case ETIR__C_OPR_ROT
: return "ETIR__C_OPR_ROT";
1740 case ETIR__C_OPR_REDEF
: return "ETIR__C_OPR_REDEF";
1741 case ETIR__C_OPR_DFLIT
: return "ETIR__C_OPR_DFLIT";
1742 case ETIR__C_STC_LP
: return "ETIR__C_STC_LP";
1743 case ETIR__C_STC_GBL
: return "ETIR__C_STC_GBL";
1744 case ETIR__C_STC_GCA
: return "ETIR__C_STC_GCA";
1745 case ETIR__C_STC_PS
: return "ETIR__C_STC_PS";
1746 case ETIR__C_STC_NBH_PS
: return "ETIR__C_STC_NBH_PS";
1747 case ETIR__C_STC_NOP_GBL
: return "ETIR__C_STC_NOP_GBL";
1748 case ETIR__C_STC_NOP_PS
: return "ETIR__C_STC_NOP_PS";
1749 case ETIR__C_STC_BSR_GBL
: return "ETIR__C_STC_BSR_GBL";
1750 case ETIR__C_STC_BSR_PS
: return "ETIR__C_STC_BSR_PS";
1751 case ETIR__C_STC_LDA_GBL
: return "ETIR__C_STC_LDA_GBL";
1752 case ETIR__C_STC_LDA_PS
: return "ETIR__C_STC_LDA_PS";
1753 case ETIR__C_STC_BOH_GBL
: return "ETIR__C_STC_BOH_GBL";
1754 case ETIR__C_STC_BOH_PS
: return "ETIR__C_STC_BOH_PS";
1755 case ETIR__C_STC_NBH_GBL
: return "ETIR__C_STC_NBH_GBL";
1756 case ETIR__C_STC_LP_PSB
: return "ETIR__C_STC_LP_PSB";
1757 case ETIR__C_CTL_SETRB
: return "ETIR__C_CTL_SETRB";
1758 case ETIR__C_CTL_AUGRB
: return "ETIR__C_CTL_AUGRB";
1759 case ETIR__C_CTL_DFLOC
: return "ETIR__C_CTL_DFLOC";
1760 case ETIR__C_CTL_STLOC
: return "ETIR__C_CTL_STLOC";
1761 case ETIR__C_CTL_STKDL
: return "ETIR__C_CTL_STKDL";
1764 /* These names have not yet been added to this switch statement. */
1765 _bfd_error_handler (_("unknown ETIR command %d"), cmd
);
1770 #define HIGHBIT(op) ((op & 0x80000000L) == 0x80000000L)
1773 _bfd_vms_get_value (bfd
*abfd
,
1774 const unsigned char *ascic
,
1775 const unsigned char *max_ascic
,
1776 struct bfd_link_info
*info
,
1778 struct alpha_vms_link_hash_entry
**hp
)
1783 struct alpha_vms_link_hash_entry
*h
;
1785 /* Not linking. Do not try to resolve the symbol. */
1794 if (ascic
+ len
>= max_ascic
)
1796 _bfd_error_handler (_("corrupt vms value"));
1802 for (i
= 0; i
< len
; i
++)
1803 name
[i
] = ascic
[i
+ 1];
1806 h
= (struct alpha_vms_link_hash_entry
*)
1807 bfd_link_hash_lookup (info
->hash
, name
, false, false, true);
1812 && (h
->root
.type
== bfd_link_hash_defined
1813 || h
->root
.type
== bfd_link_hash_defweak
))
1814 *vma
= h
->root
.u
.def
.value
1815 + h
->root
.u
.def
.section
->output_offset
1816 + h
->root
.u
.def
.section
->output_section
->vma
;
1817 else if (h
&& h
->root
.type
== bfd_link_hash_undefweak
)
1821 (*info
->callbacks
->undefined_symbol
)
1822 (info
, name
, abfd
, PRIV (image_section
), PRIV (image_offset
), true);
1829 #define RELC_SHR_BASE 0x10000
1830 #define RELC_SEC_BASE 0x20000
1831 #define RELC_MASK 0x0ffff
1834 alpha_vms_sym_to_ctxt (struct alpha_vms_link_hash_entry
*h
)
1836 /* Handle undefined symbols. */
1837 if (h
== NULL
|| h
->sym
== NULL
)
1840 if (h
->sym
->typ
== EGSD__C_SYMG
)
1842 if (h
->sym
->flags
& EGSY__V_REL
)
1843 return RELC_SHR_BASE
+ PRIV2 (h
->sym
->owner
, shr_index
);
1846 /* Can this happen (non-relocatable symg) ? I'd like to see
1851 if (h
->sym
->typ
== EGSD__C_SYM
)
1853 if (h
->sym
->flags
& EGSY__V_REL
)
1862 alpha_vms_get_sym_value (asection
*sect
, bfd_vma addr
)
1864 return sect
->output_section
->vma
+ sect
->output_offset
+ addr
;
1868 alpha_vms_fix_sec_rel (bfd
*abfd
, struct bfd_link_info
*info
,
1869 unsigned int rel
, bfd_vma vma
)
1873 if (PRIV (sections
) == NULL
)
1876 sec
= PRIV (sections
)[rel
& RELC_MASK
];
1880 if (sec
->output_section
== NULL
)
1882 return vma
+ sec
->output_section
->vma
+ sec
->output_offset
;
1885 return vma
+ sec
->vma
;
1888 /* Read an ETIR record from ABFD. If INFO is not null, put the content into
1889 the output section (used during linking).
1890 Return FALSE in case of error. */
1893 _bfd_vms_slurp_etir (bfd
*abfd
, struct bfd_link_info
*info
)
1896 unsigned int length
;
1897 unsigned char *maxptr
;
1900 unsigned int rel1
= RELC_NONE
;
1901 unsigned int rel2
= RELC_NONE
;
1902 struct alpha_vms_link_hash_entry
*h
;
1904 PRIV (recrd
.rec
) += ETIR__C_HEADER_SIZE
;
1905 PRIV (recrd
.rec_size
) -= ETIR__C_HEADER_SIZE
;
1907 ptr
= PRIV (recrd
.rec
);
1908 length
= PRIV (recrd
.rec_size
);
1909 maxptr
= ptr
+ length
;
1911 vms_debug2 ((2, "ETIR: %d bytes\n", length
));
1913 while (ptr
< maxptr
)
1915 int cmd
, cmd_length
;
1917 if (ptr
+ 4 > maxptr
)
1920 cmd
= bfd_getl16 (ptr
);
1921 cmd_length
= bfd_getl16 (ptr
+ 2);
1923 /* PR 21589 and 21579: Check for a corrupt ETIR record. */
1924 if (cmd_length
< 4 || ptr
+ cmd_length
> maxptr
)
1927 _bfd_error_handler (_("corrupt ETIR record encountered"));
1928 bfd_set_error (bfd_error_bad_value
);
1935 _bfd_vms_debug (4, "etir: %s(%d)\n",
1936 _bfd_vms_etir_name (cmd
), cmd
);
1937 _bfd_hexdump (8, ptr
, cmd_length
, 0);
1945 stack 32 bit value of symbol (high bits set to 0). */
1946 case ETIR__C_STA_GBL
:
1947 _bfd_vms_get_value (abfd
, ptr
, ptr
+ cmd_length
, info
, &op1
, &h
);
1948 if (!_bfd_vms_push (abfd
, op1
, alpha_vms_sym_to_ctxt (h
)))
1955 stack 32 bit value, sign extend to 64 bit. */
1956 case ETIR__C_STA_LW
:
1959 if (!_bfd_vms_push (abfd
, bfd_getl32 (ptr
), RELC_NONE
))
1966 stack 64 bit value of symbol. */
1967 case ETIR__C_STA_QW
:
1970 if (!_bfd_vms_push (abfd
, bfd_getl64 (ptr
), RELC_NONE
))
1974 /* Stack psect base plus quadword offset
1975 arg: lw section index
1976 qw signed quadword offset (low 32 bits)
1978 Stack qw argument and section index
1979 (see ETIR__C_STO_OFF, ETIR__C_CTL_SETRB). */
1980 case ETIR__C_STA_PQ
:
1984 if (cmd_length
< 12)
1986 psect
= bfd_getl32 (ptr
);
1987 if ((unsigned int) psect
>= PRIV (section_count
))
1989 _bfd_error_handler (_("bad section index in %s"),
1990 _bfd_vms_etir_name (cmd
));
1991 bfd_set_error (bfd_error_bad_value
);
1994 op1
= bfd_getl64 (ptr
+ 4);
1995 if (!_bfd_vms_push (abfd
, op1
, psect
| RELC_SEC_BASE
))
2000 case ETIR__C_STA_LI
:
2001 case ETIR__C_STA_MOD
:
2002 case ETIR__C_STA_CKARG
:
2003 _bfd_error_handler (_("unsupported STA cmd %s"),
2004 _bfd_vms_etir_name (cmd
));
2008 /* Store byte: pop stack, write byte
2011 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2013 if (rel1
!= RELC_NONE
)
2015 if (!image_write_b (abfd
, (unsigned int) op1
& 0xff))
2019 /* Store word: pop stack, write word
2022 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2024 if (rel1
!= RELC_NONE
)
2026 if (!image_write_w (abfd
, (unsigned int) op1
& 0xffff))
2030 /* Store longword: pop stack, write longword
2032 case ETIR__C_STO_LW
:
2033 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2035 if (rel1
& RELC_SEC_BASE
)
2037 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2040 else if (rel1
& RELC_SHR_BASE
)
2042 if (!alpha_vms_add_fixup_lr (info
, rel1
& RELC_MASK
, op1
))
2046 if (rel1
!= RELC_NONE
)
2048 if (rel1
!= RELC_REL
)
2050 if (!alpha_vms_add_lw_reloc (info
))
2053 if (!image_write_l (abfd
, op1
))
2057 /* Store quadword: pop stack, write quadword
2059 case ETIR__C_STO_QW
:
2060 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2062 if (rel1
& RELC_SEC_BASE
)
2064 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2067 else if (rel1
& RELC_SHR_BASE
)
2069 if (rel1
!= RELC_NONE
)
2071 if (rel1
!= RELC_REL
)
2073 if (!alpha_vms_add_qw_reloc (info
))
2076 if (!image_write_q (abfd
, op1
))
2080 /* Store immediate repeated: pop stack for repeat count
2083 case ETIR__C_STO_IMMR
:
2089 size
= bfd_getl32 (ptr
);
2090 if (size
> cmd_length
- 4)
2092 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2094 if (rel1
!= RELC_NONE
)
2100 if (!image_write (abfd
, ptr
+ 4, size
))
2105 /* Store global: write symbol value
2106 arg: cs global symbol name. */
2107 case ETIR__C_STO_GBL
:
2108 _bfd_vms_get_value (abfd
, ptr
, ptr
+ cmd_length
, info
, &op1
, &h
);
2111 if (h
->sym
->typ
== EGSD__C_SYMG
)
2113 if (!alpha_vms_add_fixup_qr (info
, abfd
, h
->sym
->owner
,
2114 h
->sym
->symbol_vector
))
2120 op1
= alpha_vms_get_sym_value (h
->sym
->section
,
2122 if (!alpha_vms_add_qw_reloc (info
))
2126 if (!image_write_q (abfd
, op1
))
2130 /* Store code address: write address of entry point
2131 arg: cs global symbol name (procedure). */
2132 case ETIR__C_STO_CA
:
2133 _bfd_vms_get_value (abfd
, ptr
, ptr
+ cmd_length
, info
, &op1
, &h
);
2136 if (h
->sym
->flags
& EGSY__V_NORM
)
2138 /* That's really a procedure. */
2139 if (h
->sym
->typ
== EGSD__C_SYMG
)
2141 if (!alpha_vms_add_fixup_ca (info
, abfd
, h
->sym
->owner
))
2143 op1
= h
->sym
->symbol_vector
;
2147 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
2148 h
->sym
->code_value
);
2149 if (!alpha_vms_add_qw_reloc (info
))
2155 /* Symbol is not a procedure. */
2159 if (!image_write_q (abfd
, op1
))
2163 /* Store offset to psect: pop stack, add low 32 bits to base of psect
2165 case ETIR__C_STO_OFF
:
2166 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2169 if (!(rel1
& RELC_SEC_BASE
))
2172 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2174 if (!image_write_q (abfd
, op1
))
2179 arg: lw count of bytes
2181 case ETIR__C_STO_IMM
:
2187 size
= bfd_getl32 (ptr
);
2188 if (!image_write (abfd
, ptr
+ 4, size
))
2193 /* This code is 'reserved to digital' according to the openVMS
2194 linker manual, however it is generated by the DEC C compiler
2195 and defined in the include file.
2196 FIXME, since the following is just a guess
2197 store global longword: store 32bit value of symbol
2198 arg: cs symbol name. */
2199 case ETIR__C_STO_GBL_LW
:
2200 _bfd_vms_get_value (abfd
, ptr
, ptr
+ cmd_length
, info
, &op1
, &h
);
2204 if (!image_write_l (abfd
, op1
))
2208 case ETIR__C_STO_RB
:
2209 case ETIR__C_STO_AB
:
2210 case ETIR__C_STO_LP_PSB
:
2211 _bfd_error_handler (_("%s: not supported"),
2212 _bfd_vms_etir_name (cmd
));
2215 case ETIR__C_STO_HINT_GBL
:
2216 case ETIR__C_STO_HINT_PS
:
2217 _bfd_error_handler (_("%s: not implemented"),
2218 _bfd_vms_etir_name (cmd
));
2222 /* 200 Store-conditional Linkage Pair
2224 case ETIR__C_STC_LP
:
2226 /* 202 Store-conditional Address at global address
2230 case ETIR__C_STC_GBL
:
2232 /* 203 Store-conditional Code Address at global address
2234 cs procedure name. */
2235 case ETIR__C_STC_GCA
:
2237 /* 204 Store-conditional Address at psect + offset
2241 case ETIR__C_STC_PS
:
2242 _bfd_error_handler (_("%s: not supported"),
2243 _bfd_vms_etir_name (cmd
));
2247 /* 201 Store-conditional Linkage Pair with Procedure Signature
2253 case ETIR__C_STC_LP_PSB
:
2256 _bfd_vms_get_value (abfd
, ptr
+ 4, ptr
+ cmd_length
, info
, &op1
, &h
);
2259 if (h
->sym
->typ
== EGSD__C_SYMG
)
2261 if (!alpha_vms_add_fixup_lp (info
, abfd
, h
->sym
->owner
))
2263 op1
= h
->sym
->symbol_vector
;
2268 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
2269 h
->sym
->code_value
);
2270 op2
= alpha_vms_get_sym_value (h
->sym
->section
,
2276 /* Undefined symbol. */
2280 if (!image_write_q (abfd
, op1
)
2281 || !image_write_q (abfd
, op2
))
2285 /* 205 Store-conditional NOP at address of global
2287 case ETIR__C_STC_NOP_GBL
:
2290 /* 207 Store-conditional BSR at global address
2293 case ETIR__C_STC_BSR_GBL
:
2296 /* 209 Store-conditional LDA at global address
2299 case ETIR__C_STC_LDA_GBL
:
2302 /* 211 Store-conditional BSR or Hint at global address
2305 case ETIR__C_STC_BOH_GBL
:
2306 /* Currentl ignored. */
2309 /* 213 Store-conditional NOP,BSR or HINT at global address
2312 case ETIR__C_STC_NBH_GBL
:
2314 /* 206 Store-conditional NOP at pect + offset
2317 case ETIR__C_STC_NOP_PS
:
2319 /* 208 Store-conditional BSR at pect + offset
2322 case ETIR__C_STC_BSR_PS
:
2324 /* 210 Store-conditional LDA at psect + offset
2327 case ETIR__C_STC_LDA_PS
:
2329 /* 212 Store-conditional BSR or Hint at pect + offset
2332 case ETIR__C_STC_BOH_PS
:
2334 /* 214 Store-conditional NOP, BSR or HINT at psect + offset
2336 case ETIR__C_STC_NBH_PS
:
2337 _bfd_error_handler (_("%s: not supported"),
2338 _bfd_vms_etir_name (cmd
));
2342 /* Det relocation base: pop stack, set image location counter
2344 case ETIR__C_CTL_SETRB
:
2345 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2347 if (!(rel1
& RELC_SEC_BASE
))
2349 image_set_ptr (abfd
, op1
, rel1
& RELC_MASK
, info
);
2352 /* Augment relocation base: increment image location counter by offset
2353 arg: lw offset value. */
2354 case ETIR__C_CTL_AUGRB
:
2357 op1
= bfd_getl32 (ptr
);
2358 image_inc_ptr (abfd
, op1
);
2361 /* Define location: pop index, save location counter under index
2363 case ETIR__C_CTL_DFLOC
:
2364 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2366 if (rel1
!= RELC_NONE
)
2368 if (!dst_define_location (abfd
, op1
))
2372 /* Set location: pop index, restore location counter from index
2374 case ETIR__C_CTL_STLOC
:
2375 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2377 if (rel1
!= RELC_NONE
)
2379 if (!dst_restore_location (abfd
, op1
))
2381 bfd_set_error (bfd_error_bad_value
);
2382 _bfd_error_handler (_("invalid %s"), "ETIR__C_CTL_STLOC");
2387 /* Stack defined location: pop index, push location counter from index
2389 case ETIR__C_CTL_STKDL
:
2390 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2392 if (rel1
!= RELC_NONE
)
2394 if (!dst_retrieve_location (abfd
, &op1
))
2396 bfd_set_error (bfd_error_bad_value
);
2397 _bfd_error_handler (_("invalid %s"), "ETIR__C_CTL_STKDL");
2400 if (!_bfd_vms_push (abfd
, op1
, RELC_NONE
))
2404 case ETIR__C_OPR_NOP
: /* No-op. */
2407 case ETIR__C_OPR_ADD
: /* Add. */
2408 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2409 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2411 if (rel1
== RELC_NONE
&& rel2
!= RELC_NONE
)
2413 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2415 if (!_bfd_vms_push (abfd
, op1
+ op2
, rel1
))
2419 case ETIR__C_OPR_SUB
: /* Subtract. */
2420 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2421 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2423 if (rel1
== RELC_NONE
&& rel2
!= RELC_NONE
)
2425 else if ((rel1
& RELC_SEC_BASE
) && (rel2
& RELC_SEC_BASE
))
2427 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2428 op2
= alpha_vms_fix_sec_rel (abfd
, info
, rel2
, op2
);
2431 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2433 if (!_bfd_vms_push (abfd
, op2
- op1
, rel1
))
2437 case ETIR__C_OPR_MUL
: /* Multiply. */
2438 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2439 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2441 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2443 if (!_bfd_vms_push (abfd
, op1
* op2
, RELC_NONE
))
2447 case ETIR__C_OPR_DIV
: /* Divide. */
2448 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2449 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2451 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2455 /* Divide by zero is supposed to give a result of zero,
2456 and a non-fatal warning message. */
2457 _bfd_error_handler (_("%s divide by zero"), "ETIR__C_OPR_DIV");
2458 if (!_bfd_vms_push (abfd
, 0, RELC_NONE
))
2463 if (!_bfd_vms_push (abfd
, op2
/ op1
, RELC_NONE
))
2468 case ETIR__C_OPR_AND
: /* Logical AND. */
2469 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2470 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2472 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2474 if (!_bfd_vms_push (abfd
, op1
& op2
, RELC_NONE
))
2478 case ETIR__C_OPR_IOR
: /* Logical inclusive OR. */
2479 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2480 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2482 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2484 if (!_bfd_vms_push (abfd
, op1
| op2
, RELC_NONE
))
2488 case ETIR__C_OPR_EOR
: /* Logical exclusive OR. */
2489 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2490 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2492 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2494 if (!_bfd_vms_push (abfd
, op1
^ op2
, RELC_NONE
))
2498 case ETIR__C_OPR_NEG
: /* Negate. */
2499 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2501 if (rel1
!= RELC_NONE
)
2503 if (!_bfd_vms_push (abfd
, -op1
, RELC_NONE
))
2507 case ETIR__C_OPR_COM
: /* Complement. */
2508 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2510 if (rel1
!= RELC_NONE
)
2512 if (!_bfd_vms_push (abfd
, ~op1
, RELC_NONE
))
2516 case ETIR__C_OPR_ASH
: /* Arithmetic shift. */
2517 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2518 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2520 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2523 _bfd_error_handler (_("invalid use of %s with contexts"),
2524 _bfd_vms_etir_name (cmd
));
2527 if ((bfd_signed_vma
) op2
< 0)
2532 if (op2
>= CHAR_BIT
* sizeof (op1
))
2533 op2
= CHAR_BIT
* sizeof (op1
) - 1;
2534 /* op1 = (bfd_signed_vma) op1 >> op2; */
2535 sign
= op1
& ((bfd_vma
) 1 << (CHAR_BIT
* sizeof (op1
) - 1));
2538 op1
= (op1
^ sign
) - sign
;
2543 if (op2
>= CHAR_BIT
* sizeof (op1
))
2548 if (!_bfd_vms_push (abfd
, op1
, RELC_NONE
)) /* FIXME: sym. */
2552 case ETIR__C_OPR_INSV
: /* Insert field. */
2553 case ETIR__C_OPR_USH
: /* Unsigned shift. */
2554 case ETIR__C_OPR_ROT
: /* Rotate. */
2555 case ETIR__C_OPR_REDEF
: /* Redefine symbol to current location. */
2556 case ETIR__C_OPR_DFLIT
: /* Define a literal. */
2557 _bfd_error_handler (_("%s: not supported"),
2558 _bfd_vms_etir_name (cmd
));
2562 case ETIR__C_OPR_SEL
: /* Select. */
2563 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2567 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2572 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2573 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2575 if (!_bfd_vms_push (abfd
, op1
, rel1
))
2581 _bfd_error_handler (_("reserved cmd %d"), cmd
);
2592 /* Process EDBG/ETBT record.
2593 Return TRUE on success, FALSE on error */
2596 vms_slurp_debug (bfd
*abfd
)
2598 asection
*section
= PRIV (dst_section
);
2600 if (section
== NULL
)
2602 /* We have no way to find out beforehand how much debug info there
2603 is in an object file, so pick an initial amount and grow it as
2605 flagword flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
| SEC_RELOC
2608 section
= bfd_make_section (abfd
, "$DST$");
2611 if (!bfd_set_section_flags (section
, flags
))
2613 PRIV (dst_section
) = section
;
2616 PRIV (image_section
) = section
;
2617 PRIV (image_offset
) = section
->size
;
2619 if (!_bfd_vms_slurp_etir (abfd
, NULL
))
2622 section
->size
= PRIV (image_offset
);
2626 /* Process EDBG record.
2627 Return TRUE on success, FALSE on error. */
2630 _bfd_vms_slurp_edbg (bfd
*abfd
)
2632 vms_debug2 ((2, "EDBG\n"));
2634 abfd
->flags
|= HAS_DEBUG
| HAS_LINENO
;
2636 return vms_slurp_debug (abfd
);
2639 /* Process ETBT record.
2640 Return TRUE on success, FALSE on error. */
2643 _bfd_vms_slurp_etbt (bfd
*abfd
)
2645 vms_debug2 ((2, "ETBT\n"));
2647 abfd
->flags
|= HAS_LINENO
;
2649 return vms_slurp_debug (abfd
);
2652 /* Process EEOM record.
2653 Return TRUE on success, FALSE on error. */
2656 _bfd_vms_slurp_eeom (bfd
*abfd
)
2658 struct vms_eeom
*eeom
= (struct vms_eeom
*) PRIV (recrd
.rec
);
2660 vms_debug2 ((2, "EEOM\n"));
2662 /* PR 21813: Check for an undersized record. */
2663 if (PRIV (recrd
.buf_size
) < sizeof (* eeom
))
2665 _bfd_error_handler (_("corrupt EEOM record - size is too small"));
2666 bfd_set_error (bfd_error_bad_value
);
2670 PRIV (eom_data
).eom_l_total_lps
= bfd_getl32 (eeom
->total_lps
);
2671 PRIV (eom_data
).eom_w_comcod
= bfd_getl16 (eeom
->comcod
);
2672 if (PRIV (eom_data
).eom_w_comcod
> 1)
2674 _bfd_error_handler (_("object module not error-free !"));
2675 bfd_set_error (bfd_error_bad_value
);
2679 PRIV (eom_data
).eom_has_transfer
= false;
2680 if (PRIV (recrd
.rec_size
) > 10)
2682 PRIV (eom_data
).eom_has_transfer
= true;
2683 PRIV (eom_data
).eom_b_tfrflg
= eeom
->tfrflg
;
2684 PRIV (eom_data
).eom_l_psindx
= bfd_getl32 (eeom
->psindx
);
2685 PRIV (eom_data
).eom_l_tfradr
= bfd_getl32 (eeom
->tfradr
);
2687 abfd
->start_address
= PRIV (eom_data
).eom_l_tfradr
;
2692 /* Slurp an ordered set of VMS object records. Return FALSE on error. */
2695 _bfd_vms_slurp_object_records (bfd
* abfd
)
2702 vms_debug2 ((7, "reading at %08lx\n", (unsigned long)bfd_tell (abfd
)));
2704 type
= _bfd_vms_get_object_record (abfd
);
2707 vms_debug2 ((2, "next_record failed\n"));
2714 ok
= _bfd_vms_slurp_ehdr (abfd
);
2717 ok
= _bfd_vms_slurp_eeom (abfd
);
2720 ok
= _bfd_vms_slurp_egsd (abfd
);
2723 ok
= true; /* _bfd_vms_slurp_etir (abfd); */
2726 ok
= _bfd_vms_slurp_edbg (abfd
);
2729 ok
= _bfd_vms_slurp_etbt (abfd
);
2736 vms_debug2 ((2, "slurp type %d failed\n", type
));
2740 while (type
!= EOBJ__C_EEOM
);
2745 /* Initialize private data */
2747 vms_initialize (bfd
* abfd
)
2751 amt
= sizeof (struct vms_private_data_struct
);
2752 abfd
->tdata
.any
= bfd_zalloc (abfd
, amt
);
2753 if (abfd
->tdata
.any
== NULL
)
2756 PRIV (recrd
.file_format
) = FF_UNKNOWN
;
2758 amt
= sizeof (struct stack_struct
) * STACKSIZE
;
2759 PRIV (stack
) = bfd_alloc (abfd
, amt
);
2760 if (PRIV (stack
) == NULL
)
2766 bfd_release (abfd
, abfd
->tdata
.any
);
2767 abfd
->tdata
.any
= NULL
;
2771 /* Free malloc'd memory. */
2774 alpha_vms_free_private (bfd
*abfd
)
2776 struct module
*module
;
2778 free (PRIV (recrd
.buf
));
2779 free (PRIV (sections
));
2781 free (PRIV (dst_ptr_offsets
));
2783 for (module
= PRIV (modules
); module
; module
= module
->next
)
2784 free (module
->file_table
);
2787 /* Check the format for a file being read.
2788 Return a (bfd_target *) if it's an object file or zero if not. */
2791 alpha_vms_object_p (bfd
*abfd
)
2793 void *tdata_save
= abfd
->tdata
.any
;
2794 unsigned int test_len
;
2797 vms_debug2 ((1, "vms_object_p(%p)\n", abfd
));
2799 /* Allocate alpha-vms specific data. */
2800 if (!vms_initialize (abfd
))
2802 abfd
->tdata
.any
= tdata_save
;
2806 if (bfd_seek (abfd
, 0, SEEK_SET
))
2809 /* The first challenge with VMS is to discover the kind of the file.
2811 Image files (executable or shared images) are stored as a raw
2812 stream of bytes (like on UNIX), but there is no magic number.
2814 Object files are written with RMS (record management service), ie
2815 each records are preceeded by its length (on a word - 2 bytes), and
2816 padded for word-alignment. That would be simple but when files
2817 are transfered to a UNIX filesystem (using ftp), records are lost.
2818 Only the raw content of the records are transfered. Fortunately,
2819 the Alpha Object file format also store the length of the record
2820 in the records. Is that clear ? */
2822 /* Minimum is 6 bytes for objects (2 bytes size, 2 bytes record id,
2823 2 bytes size repeated) and 12 bytes for images (4 bytes major id,
2824 4 bytes minor id, 4 bytes length). */
2826 buf
= _bfd_malloc_and_read (abfd
, test_len
, test_len
);
2829 PRIV (recrd
.buf
) = buf
;
2830 PRIV (recrd
.buf_size
) = test_len
;
2831 PRIV (recrd
.rec
) = buf
;
2833 /* Is it an image? */
2834 if ((bfd_getl32 (buf
) == EIHD__K_MAJORID
)
2835 && (bfd_getl32 (buf
+ 4) == EIHD__K_MINORID
))
2837 unsigned int eisd_offset
, eihs_offset
;
2839 /* Extract the header size. */
2840 PRIV (recrd
.rec_size
) = bfd_getl32 (buf
+ EIHD__L_SIZE
);
2842 /* The header size is 0 for DSF files. */
2843 if (PRIV (recrd
.rec_size
) == 0)
2844 PRIV (recrd
.rec_size
) = sizeof (struct vms_eihd
);
2846 /* PR 21813: Check for a truncated record. */
2847 /* PR 17512: file: 7d7c57c2. */
2848 if (PRIV (recrd
.rec_size
) < sizeof (struct vms_eihd
))
2849 goto err_wrong_format
;
2851 if (bfd_seek (abfd
, 0, SEEK_SET
))
2854 free (PRIV (recrd
.buf
));
2855 PRIV (recrd
.buf
) = NULL
;
2856 buf
= _bfd_malloc_and_read (abfd
, PRIV (recrd
.rec_size
),
2857 PRIV (recrd
.rec_size
));
2861 PRIV (recrd
.buf
) = buf
;
2862 PRIV (recrd
.buf_size
) = PRIV (recrd
.rec_size
);
2863 PRIV (recrd
.rec
) = buf
;
2865 vms_debug2 ((2, "file type is image\n"));
2867 if (!_bfd_vms_slurp_eihd (abfd
, &eisd_offset
, &eihs_offset
))
2868 goto err_wrong_format
;
2870 if (!_bfd_vms_slurp_eisd (abfd
, eisd_offset
))
2871 goto err_wrong_format
;
2873 /* EIHS is optional. */
2874 if (eihs_offset
!= 0 && !_bfd_vms_slurp_eihs (abfd
, eihs_offset
))
2875 goto err_wrong_format
;
2881 /* Assume it's a module and adjust record pointer if necessary. */
2882 maybe_adjust_record_pointer_for_object (abfd
);
2884 /* But is it really a module? */
2885 if (bfd_getl16 (PRIV (recrd
.rec
)) <= EOBJ__C_MAXRECTYP
2886 && bfd_getl16 (PRIV (recrd
.rec
) + 2) <= EOBJ__C_MAXRECSIZ
)
2888 if (vms_get_remaining_object_record (abfd
, test_len
) <= 0)
2889 goto err_wrong_format
;
2891 vms_debug2 ((2, "file type is module\n"));
2893 type
= bfd_getl16 (PRIV (recrd
.rec
));
2894 if (type
!= EOBJ__C_EMH
|| !_bfd_vms_slurp_ehdr (abfd
))
2895 goto err_wrong_format
;
2897 if (!_bfd_vms_slurp_object_records (abfd
))
2898 goto err_wrong_format
;
2901 goto err_wrong_format
;
2904 /* Set arch_info to alpha. */
2906 if (! bfd_default_set_arch_mach (abfd
, bfd_arch_alpha
, 0))
2907 goto err_wrong_format
;
2909 return alpha_vms_free_private
;
2912 bfd_set_error (bfd_error_wrong_format
);
2915 alpha_vms_free_private (abfd
);
2916 if (abfd
->tdata
.any
!= tdata_save
&& abfd
->tdata
.any
!= NULL
)
2917 bfd_release (abfd
, abfd
->tdata
.any
);
2918 abfd
->tdata
.any
= tdata_save
;
2924 /* Write an EMH/MHD record. */
2927 _bfd_vms_write_emh (bfd
*abfd
)
2929 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2930 unsigned char tbuf
[18];
2932 _bfd_vms_output_alignment (recwr
, 2);
2935 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
2936 _bfd_vms_output_short (recwr
, EMH__C_MHD
);
2937 _bfd_vms_output_short (recwr
, EOBJ__C_STRLVL
);
2938 _bfd_vms_output_long (recwr
, 0);
2939 _bfd_vms_output_long (recwr
, 0);
2940 _bfd_vms_output_long (recwr
, MAX_OUTREC_SIZE
);
2942 /* Create module name from filename. */
2943 if (bfd_get_filename (abfd
) != 0)
2945 char *module
= vms_get_module_name (bfd_get_filename (abfd
), true);
2946 _bfd_vms_output_counted (recwr
, module
);
2950 _bfd_vms_output_counted (recwr
, "NONAME");
2952 _bfd_vms_output_counted (recwr
, BFD_VERSION_STRING
);
2953 _bfd_vms_output_dump (recwr
, get_vms_time_string (tbuf
), EMH_DATE_LENGTH
);
2954 _bfd_vms_output_fill (recwr
, 0, EMH_DATE_LENGTH
);
2955 return _bfd_vms_output_end (abfd
, recwr
);
2958 /* Write an EMH/LMN record. */
2961 _bfd_vms_write_lmn (bfd
*abfd
, const char *name
)
2964 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2965 unsigned int ver
= BFD_VERSION
/ 10000;
2968 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
2969 _bfd_vms_output_short (recwr
, EMH__C_LNM
);
2970 snprintf (version
, sizeof (version
), "%s %d.%d.%d", name
,
2971 ver
/ 10000, (ver
/ 100) % 100, ver
% 100);
2972 _bfd_vms_output_dump (recwr
, (unsigned char *)version
, strlen (version
));
2973 return _bfd_vms_output_end (abfd
, recwr
);
2977 /* Write eom record for bfd abfd. Return FALSE on error. */
2980 _bfd_vms_write_eeom (bfd
*abfd
)
2982 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2984 vms_debug2 ((2, "vms_write_eeom\n"));
2986 _bfd_vms_output_alignment (recwr
, 2);
2988 _bfd_vms_output_begin (recwr
, EOBJ__C_EEOM
);
2989 _bfd_vms_output_long (recwr
, PRIV (vms_linkage_index
+ 1) >> 1);
2990 _bfd_vms_output_byte (recwr
, 0); /* Completion code. */
2991 _bfd_vms_output_byte (recwr
, 0); /* Fill byte. */
2993 if ((abfd
->flags
& EXEC_P
) == 0
2994 && bfd_get_start_address (abfd
) != (bfd_vma
)-1)
2998 section
= bfd_get_section_by_name (abfd
, ".link");
3001 bfd_set_error (bfd_error_nonrepresentable_section
);
3004 _bfd_vms_output_short (recwr
, 0);
3005 _bfd_vms_output_long (recwr
, (unsigned long) section
->target_index
);
3006 _bfd_vms_output_long (recwr
,
3007 (unsigned long) bfd_get_start_address (abfd
));
3008 _bfd_vms_output_long (recwr
, 0);
3011 return _bfd_vms_output_end (abfd
, recwr
);
3015 vector_grow1 (struct vector_type
*vec
, size_t elsz
)
3017 if (vec
->nbr_el
>= vec
->max_el
)
3019 if (vec
->max_el
== 0)
3022 vec
->els
= bfd_malloc (vec
->max_el
* elsz
);
3027 if (vec
->max_el
> -1u / 2)
3029 bfd_set_error (bfd_error_file_too_big
);
3033 if (_bfd_mul_overflow (vec
->max_el
, elsz
, &amt
))
3035 bfd_set_error (bfd_error_file_too_big
);
3038 vec
->els
= bfd_realloc_or_free (vec
->els
, amt
);
3041 if (vec
->els
== NULL
)
3043 return (char *) vec
->els
+ elsz
* vec
->nbr_el
++;
3046 /* Bump ABFD file position to next block. */
3049 alpha_vms_file_position_block (bfd
*abfd
)
3052 PRIV (file_pos
) += VMS_BLOCK_SIZE
- 1;
3053 PRIV (file_pos
) -= (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
3056 /* Convert from internal structure SRC to external structure DST. */
3059 alpha_vms_swap_eisd_out (struct vms_internal_eisd_map
*src
,
3060 struct vms_eisd
*dst
)
3062 bfd_putl32 (src
->u
.eisd
.majorid
, dst
->majorid
);
3063 bfd_putl32 (src
->u
.eisd
.minorid
, dst
->minorid
);
3064 bfd_putl32 (src
->u
.eisd
.eisdsize
, dst
->eisdsize
);
3065 if (src
->u
.eisd
.eisdsize
<= EISD__K_LENEND
)
3067 bfd_putl32 (src
->u
.eisd
.secsize
, dst
->secsize
);
3068 bfd_putl64 (src
->u
.eisd
.virt_addr
, dst
->virt_addr
);
3069 bfd_putl32 (src
->u
.eisd
.flags
, dst
->flags
);
3070 bfd_putl32 (src
->u
.eisd
.vbn
, dst
->vbn
);
3071 dst
->pfc
= src
->u
.eisd
.pfc
;
3072 dst
->matchctl
= src
->u
.eisd
.matchctl
;
3073 dst
->type
= src
->u
.eisd
.type
;
3075 if (src
->u
.eisd
.flags
& EISD__M_GBL
)
3077 bfd_putl32 (src
->u
.gbl_eisd
.ident
, dst
->ident
);
3078 memcpy (dst
->gblnam
, src
->u
.gbl_eisd
.gblnam
,
3079 src
->u
.gbl_eisd
.gblnam
[0] + 1);
3083 /* Append EISD to the list of extra eisd for ABFD. */
3086 alpha_vms_append_extra_eisd (bfd
*abfd
, struct vms_internal_eisd_map
*eisd
)
3089 if (PRIV (gbl_eisd_head
) == NULL
)
3090 PRIV (gbl_eisd_head
) = eisd
;
3092 PRIV (gbl_eisd_tail
)->next
= eisd
;
3093 PRIV (gbl_eisd_tail
) = eisd
;
3096 /* Create an EISD for shared image SHRIMG.
3097 Return FALSE in case of error. */
3100 alpha_vms_create_eisd_for_shared (bfd
*abfd
, bfd
*shrimg
)
3102 struct vms_internal_eisd_map
*eisd
;
3105 namlen
= strlen (PRIV2 (shrimg
, hdr_data
.hdr_t_name
));
3106 if (namlen
+ 5 > EISD__K_GBLNAMLEN
)
3112 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
3116 /* Fill the fields. */
3117 eisd
->u
.gbl_eisd
.common
.majorid
= EISD__K_MAJORID
;
3118 eisd
->u
.gbl_eisd
.common
.minorid
= EISD__K_MINORID
;
3119 eisd
->u
.gbl_eisd
.common
.eisdsize
= (EISD__K_LEN
+ 4 + namlen
+ 5 + 3) & ~3;
3120 eisd
->u
.gbl_eisd
.common
.secsize
= VMS_BLOCK_SIZE
; /* Must not be 0. */
3121 eisd
->u
.gbl_eisd
.common
.virt_addr
= 0;
3122 eisd
->u
.gbl_eisd
.common
.flags
= EISD__M_GBL
;
3123 eisd
->u
.gbl_eisd
.common
.vbn
= 0;
3124 eisd
->u
.gbl_eisd
.common
.pfc
= 0;
3125 eisd
->u
.gbl_eisd
.common
.matchctl
= PRIV2 (shrimg
, matchctl
);
3126 eisd
->u
.gbl_eisd
.common
.type
= EISD__K_SHRPIC
;
3128 eisd
->u
.gbl_eisd
.ident
= PRIV2 (shrimg
, ident
);
3129 eisd
->u
.gbl_eisd
.gblnam
[0] = namlen
+ 4;
3130 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1, PRIV2 (shrimg
, hdr_data
.hdr_t_name
),
3132 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1 + namlen
, "_001", 4);
3134 /* Append it to the list. */
3135 alpha_vms_append_extra_eisd (abfd
, eisd
);
3140 /* Create an EISD for section SEC.
3141 Return FALSE in case of failure. */
3144 alpha_vms_create_eisd_for_section (bfd
*abfd
, asection
*sec
)
3146 struct vms_internal_eisd_map
*eisd
;
3148 /* Only for allocating section. */
3149 if (!(sec
->flags
& SEC_ALLOC
))
3152 BFD_ASSERT (vms_section_data (sec
)->eisd
== NULL
);
3153 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
3156 vms_section_data (sec
)->eisd
= eisd
;
3158 /* Fill the fields. */
3159 eisd
->u
.eisd
.majorid
= EISD__K_MAJORID
;
3160 eisd
->u
.eisd
.minorid
= EISD__K_MINORID
;
3161 eisd
->u
.eisd
.eisdsize
= EISD__K_LEN
;
3162 eisd
->u
.eisd
.secsize
=
3163 (sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
3164 eisd
->u
.eisd
.virt_addr
= sec
->vma
;
3165 eisd
->u
.eisd
.flags
= 0;
3166 eisd
->u
.eisd
.vbn
= 0; /* To be later defined. */
3167 eisd
->u
.eisd
.pfc
= 0; /* Default. */
3168 eisd
->u
.eisd
.matchctl
= EISD__K_MATALL
;
3169 eisd
->u
.eisd
.type
= EISD__K_NORMAL
;
3171 if (sec
->flags
& SEC_CODE
)
3172 eisd
->u
.eisd
.flags
|= EISD__M_EXE
;
3173 if (!(sec
->flags
& SEC_READONLY
))
3174 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
3176 /* If relocations or fixup will be applied, make this isect writeable. */
3177 if (sec
->flags
& SEC_RELOC
)
3178 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
3180 if (!(sec
->flags
& SEC_HAS_CONTENTS
))
3182 eisd
->u
.eisd
.flags
|= EISD__M_DZRO
;
3183 eisd
->u
.eisd
.flags
&= ~EISD__M_CRF
;
3185 if (sec
->flags
& SEC_LINKER_CREATED
)
3187 if (strcmp (sec
->name
, "$FIXUP$") == 0)
3188 eisd
->u
.eisd
.flags
|= EISD__M_FIXUPVEC
;
3191 /* Append it to the list. */
3193 if (PRIV (eisd_head
) == NULL
)
3194 PRIV (eisd_head
) = eisd
;
3196 PRIV (eisd_tail
)->next
= eisd
;
3197 PRIV (eisd_tail
) = eisd
;
3202 /* Layout executable ABFD and write it to the disk.
3203 Return FALSE in case of failure. */
3206 alpha_vms_write_exec (bfd
*abfd
)
3208 struct vms_eihd eihd
;
3209 struct vms_eiha
*eiha
;
3210 struct vms_eihi
*eihi
;
3211 struct vms_eihs
*eihs
= NULL
;
3213 struct vms_internal_eisd_map
*first_eisd
;
3214 struct vms_internal_eisd_map
*eisd
;
3217 file_ptr gst_filepos
= 0;
3218 unsigned int lnkflags
= 0;
3220 /* Build the EIHD. */
3221 PRIV (file_pos
) = EIHD__C_LENGTH
;
3223 memset (&eihd
, 0, sizeof (eihd
));
3224 memset (eihd
.fill_2
, 0xff, sizeof (eihd
.fill_2
));
3226 bfd_putl32 (EIHD__K_MAJORID
, eihd
.majorid
);
3227 bfd_putl32 (EIHD__K_MINORID
, eihd
.minorid
);
3229 bfd_putl32 (sizeof (eihd
), eihd
.size
);
3230 bfd_putl32 (0, eihd
.isdoff
);
3231 bfd_putl32 (0, eihd
.activoff
);
3232 bfd_putl32 (0, eihd
.symdbgoff
);
3233 bfd_putl32 (0, eihd
.imgidoff
);
3234 bfd_putl32 (0, eihd
.patchoff
);
3235 bfd_putl64 (0, eihd
.iafva
);
3236 bfd_putl32 (0, eihd
.version_array_off
);
3238 bfd_putl32 (EIHD__K_EXE
, eihd
.imgtype
);
3239 bfd_putl32 (0, eihd
.subtype
);
3241 bfd_putl32 (0, eihd
.imgiocnt
);
3242 bfd_putl32 (-1, eihd
.privreqs
);
3243 bfd_putl32 (-1, eihd
.privreqs
+ 4);
3245 bfd_putl32 ((sizeof (eihd
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
3247 bfd_putl32 (0, eihd
.ident
);
3248 bfd_putl32 (0, eihd
.sysver
);
3251 bfd_putl32 (0, eihd
.symvect_size
);
3252 bfd_putl32 (16, eihd
.virt_mem_block_size
);
3253 bfd_putl32 (0, eihd
.ext_fixup_off
);
3254 bfd_putl32 (0, eihd
.noopt_psect_off
);
3255 bfd_putl16 (-1, eihd
.alias
);
3258 eiha
= (struct vms_eiha
*)((char *) &eihd
+ PRIV (file_pos
));
3259 bfd_putl32 (PRIV (file_pos
), eihd
.activoff
);
3260 PRIV (file_pos
) += sizeof (struct vms_eiha
);
3262 bfd_putl32 (sizeof (struct vms_eiha
), eiha
->size
);
3263 bfd_putl32 (0, eiha
->spare
);
3264 bfd_putl64 (PRIV (transfer_address
[0]), eiha
->tfradr1
);
3265 bfd_putl64 (PRIV (transfer_address
[1]), eiha
->tfradr2
);
3266 bfd_putl64 (PRIV (transfer_address
[2]), eiha
->tfradr3
);
3267 bfd_putl64 (PRIV (transfer_address
[3]), eiha
->tfradr4
);
3268 bfd_putl64 (0, eiha
->inishr
);
3271 eihi
= (struct vms_eihi
*)((char *) &eihd
+ PRIV (file_pos
));
3272 bfd_putl32 (PRIV (file_pos
), eihd
.imgidoff
);
3273 PRIV (file_pos
) += sizeof (struct vms_eihi
);
3275 bfd_putl32 (EIHI__K_MAJORID
, eihi
->majorid
);
3276 bfd_putl32 (EIHI__K_MINORID
, eihi
->minorid
);
3281 /* Set module name. */
3282 module
= vms_get_module_name (bfd_get_filename (abfd
), true);
3283 len
= strlen (module
);
3284 if (len
> sizeof (eihi
->imgnam
) - 1)
3285 len
= sizeof (eihi
->imgnam
) - 1;
3286 eihi
->imgnam
[0] = len
;
3287 memcpy (eihi
->imgnam
+ 1, module
, len
);
3295 vms_get_time (&hi
, &lo
);
3296 bfd_putl32 (lo
, eihi
->linktime
+ 0);
3297 bfd_putl32 (hi
, eihi
->linktime
+ 4);
3300 eihi
->linkid
[0] = 0;
3301 eihi
->imgbid
[0] = 0;
3304 dst
= PRIV (dst_section
);
3305 dmt
= bfd_get_section_by_name (abfd
, "$DMT$");
3306 if (dst
!= NULL
&& dst
->size
!= 0)
3308 eihs
= (struct vms_eihs
*)((char *) &eihd
+ PRIV (file_pos
));
3309 bfd_putl32 (PRIV (file_pos
), eihd
.symdbgoff
);
3310 PRIV (file_pos
) += sizeof (struct vms_eihs
);
3312 bfd_putl32 (EIHS__K_MAJORID
, eihs
->majorid
);
3313 bfd_putl32 (EIHS__K_MINORID
, eihs
->minorid
);
3314 bfd_putl32 (0, eihs
->dstvbn
);
3315 bfd_putl32 (0, eihs
->dstsize
);
3316 bfd_putl32 (0, eihs
->gstvbn
);
3317 bfd_putl32 (0, eihs
->gstsize
);
3318 bfd_putl32 (0, eihs
->dmtvbn
);
3319 bfd_putl32 (0, eihs
->dmtsize
);
3322 /* One EISD per section. */
3323 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3325 if (!alpha_vms_create_eisd_for_section (abfd
, sec
))
3329 /* Merge section EIDS which extra ones. */
3330 if (PRIV (eisd_tail
))
3331 PRIV (eisd_tail
)->next
= PRIV (gbl_eisd_head
);
3333 PRIV (eisd_head
) = PRIV (gbl_eisd_head
);
3334 if (PRIV (gbl_eisd_tail
))
3335 PRIV (eisd_tail
) = PRIV (gbl_eisd_tail
);
3337 first_eisd
= PRIV (eisd_head
);
3339 /* Add end of eisd. */
3342 eisd
= bfd_zalloc (abfd
, sizeof (*eisd
));
3345 eisd
->u
.eisd
.majorid
= 0;
3346 eisd
->u
.eisd
.minorid
= 0;
3347 eisd
->u
.eisd
.eisdsize
= 0;
3348 alpha_vms_append_extra_eisd (abfd
, eisd
);
3351 /* Place EISD in the file. */
3352 for (eisd
= first_eisd
; eisd
; eisd
= eisd
->next
)
3354 file_ptr room
= VMS_BLOCK_SIZE
- (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
3356 /* First block is a little bit special: there is a word at the end. */
3357 if (PRIV (file_pos
) < VMS_BLOCK_SIZE
&& room
> 2)
3359 if (room
< eisd
->u
.eisd
.eisdsize
+ EISD__K_LENEND
)
3360 alpha_vms_file_position_block (abfd
);
3362 eisd
->file_pos
= PRIV (file_pos
);
3363 PRIV (file_pos
) += eisd
->u
.eisd
.eisdsize
;
3365 if (eisd
->u
.eisd
.flags
& EISD__M_FIXUPVEC
)
3366 bfd_putl64 (eisd
->u
.eisd
.virt_addr
, eihd
.iafva
);
3369 if (first_eisd
!= NULL
)
3371 bfd_putl32 (first_eisd
->file_pos
, eihd
.isdoff
);
3372 /* Real size of end of eisd marker. */
3373 PRIV (file_pos
) += EISD__K_LENEND
;
3376 bfd_putl32 (PRIV (file_pos
), eihd
.size
);
3377 bfd_putl32 ((PRIV (file_pos
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
3380 /* Place sections. */
3381 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3383 if (!(sec
->flags
& SEC_HAS_CONTENTS
)
3384 || sec
->contents
== NULL
)
3387 eisd
= vms_section_data (sec
)->eisd
;
3389 /* Align on a block. */
3390 alpha_vms_file_position_block (abfd
);
3391 sec
->filepos
= PRIV (file_pos
);
3394 eisd
->u
.eisd
.vbn
= (sec
->filepos
/ VMS_BLOCK_SIZE
) + 1;
3396 PRIV (file_pos
) += sec
->size
;
3400 if (eihs
!= NULL
&& dst
!= NULL
)
3402 bfd_putl32 ((dst
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dstvbn
);
3403 bfd_putl32 (dst
->size
, eihs
->dstsize
);
3407 lnkflags
|= EIHD__M_DBGDMT
;
3408 bfd_putl32 ((dmt
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dmtvbn
);
3409 bfd_putl32 (dmt
->size
, eihs
->dmtsize
);
3411 if (PRIV (gsd_sym_count
) != 0)
3413 alpha_vms_file_position_block (abfd
);
3414 gst_filepos
= PRIV (file_pos
);
3415 bfd_putl32 ((gst_filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->gstvbn
);
3416 bfd_putl32 ((PRIV (gsd_sym_count
) + 4) / 5 + 4, eihs
->gstsize
);
3420 /* Write EISD in hdr. */
3421 for (eisd
= first_eisd
; eisd
&& eisd
->file_pos
< VMS_BLOCK_SIZE
;
3423 alpha_vms_swap_eisd_out
3424 (eisd
, (struct vms_eisd
*)((char *)&eihd
+ eisd
->file_pos
));
3426 /* Write first block. */
3427 bfd_putl32 (lnkflags
, eihd
.lnkflags
);
3428 if (bfd_write (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
3431 /* Write remaining eisd. */
3434 unsigned char blk
[VMS_BLOCK_SIZE
];
3435 struct vms_internal_eisd_map
*next_eisd
;
3437 memset (blk
, 0xff, sizeof (blk
));
3438 while (eisd
!= NULL
)
3440 alpha_vms_swap_eisd_out
3442 (struct vms_eisd
*)(blk
+ (eisd
->file_pos
% VMS_BLOCK_SIZE
)));
3444 next_eisd
= eisd
->next
;
3445 if (next_eisd
== NULL
3446 || (next_eisd
->file_pos
/ VMS_BLOCK_SIZE
3447 != eisd
->file_pos
/ VMS_BLOCK_SIZE
))
3449 if (bfd_write (blk
, sizeof (blk
), abfd
) != sizeof (blk
))
3452 memset (blk
, 0xff, sizeof (blk
));
3458 /* Write sections. */
3459 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3461 unsigned char blk
[VMS_BLOCK_SIZE
];
3464 if (sec
->size
== 0 || !(sec
->flags
& SEC_HAS_CONTENTS
)
3465 || sec
->contents
== NULL
)
3467 if (bfd_write (sec
->contents
, sec
->size
, abfd
) != sec
->size
)
3471 len
= VMS_BLOCK_SIZE
- sec
->size
% VMS_BLOCK_SIZE
;
3472 if (len
!= VMS_BLOCK_SIZE
)
3474 memset (blk
, 0, len
);
3475 if (bfd_write (blk
, len
, abfd
) != len
)
3481 if (gst_filepos
!= 0)
3483 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3486 if (!_bfd_vms_write_emh (abfd
)
3487 || !_bfd_vms_write_lmn (abfd
, "GNU LD"))
3490 /* PSC for the absolute section. */
3491 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3492 _bfd_vms_output_long (recwr
, 0);
3493 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3494 _bfd_vms_output_short (recwr
, 0);
3495 _bfd_vms_output_short (recwr
, EGPS__V_PIC
| EGPS__V_LIB
| EGPS__V_RD
);
3496 _bfd_vms_output_long (recwr
, 0);
3497 _bfd_vms_output_counted (recwr
, ".$$ABS$$.");
3498 _bfd_vms_output_end_subrec (recwr
);
3499 if (!_bfd_vms_output_end (abfd
, recwr
))
3502 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
3504 struct vms_symbol_entry
*sym
= PRIV (syms
)[i
];
3510 _bfd_vms_output_alignment (recwr
, 8);
3511 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3512 _bfd_vms_output_long (recwr
, 0);
3514 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYMG
);
3515 _bfd_vms_output_short (recwr
, 0); /* Data type, alignment. */
3516 _bfd_vms_output_short (recwr
, sym
->flags
);
3518 if (sym
->code_section
)
3519 ep
= alpha_vms_get_sym_value (sym
->code_section
, sym
->code_value
);
3522 BFD_ASSERT (sym
->code_value
== 0);
3525 val
= alpha_vms_get_sym_value (sym
->section
, sym
->value
);
3526 _bfd_vms_output_quad
3527 (recwr
, sym
->typ
== EGSD__C_SYMG
? sym
->symbol_vector
: val
);
3528 _bfd_vms_output_quad (recwr
, ep
);
3529 _bfd_vms_output_quad (recwr
, val
);
3530 _bfd_vms_output_long (recwr
, 0);
3531 _bfd_vms_output_counted (recwr
, sym
->name
);
3532 _bfd_vms_output_end_subrec (recwr
);
3534 && !_bfd_vms_output_end (abfd
, recwr
))
3538 && !_bfd_vms_output_end (abfd
, recwr
))
3541 if (!_bfd_vms_write_eeom (abfd
))
3549 /* Write section and symbol directory of bfd abfd. Return FALSE on error. */
3552 _bfd_vms_write_egsd (bfd
*abfd
)
3556 unsigned int symnum
;
3558 flagword new_flags
, old_flags
;
3559 int abs_section_index
= -1;
3560 unsigned int target_index
= 0;
3561 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3563 vms_debug2 ((2, "vms_write_egsd\n"));
3565 /* Egsd is quadword aligned. */
3566 _bfd_vms_output_alignment (recwr
, 8);
3568 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3569 _bfd_vms_output_long (recwr
, 0);
3571 /* Number sections. */
3572 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3574 if (section
->flags
& SEC_DEBUGGING
)
3576 if (!strcmp (section
->name
, ".vmsdebug"))
3578 section
->flags
|= SEC_DEBUGGING
;
3581 section
->target_index
= target_index
++;
3584 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3586 vms_debug2 ((3, "Section #%d %s, %d bytes\n",
3587 section
->target_index
, section
->name
, (int)section
->size
));
3589 /* Don't write out the VMS debug info section since it is in the
3590 ETBT and EDBG sections in etir. */
3591 if (section
->flags
& SEC_DEBUGGING
)
3594 /* 13 bytes egsd, max 31 chars name -> should be 44 bytes. */
3595 if (_bfd_vms_output_check (recwr
, 64) < 0)
3597 if (!_bfd_vms_output_end (abfd
, recwr
))
3599 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3600 _bfd_vms_output_long (recwr
, 0);
3603 /* Don't know if this is necessary for the linker but for now it keeps
3604 vms_slurp_gsd happy. */
3605 sname
= section
->name
;
3608 /* Remove leading dot. */
3610 if ((*sname
== 't') && (strcmp (sname
, "text") == 0))
3611 sname
= EVAX_CODE_NAME
;
3612 else if ((*sname
== 'd') && (strcmp (sname
, "data") == 0))
3613 sname
= EVAX_DATA_NAME
;
3614 else if ((*sname
== 'b') && (strcmp (sname
, "bss") == 0))
3615 sname
= EVAX_BSS_NAME
;
3616 else if ((*sname
== 'l') && (strcmp (sname
, "link") == 0))
3617 sname
= EVAX_LINK_NAME
;
3618 else if ((*sname
== 'r') && (strcmp (sname
, "rdata") == 0))
3619 sname
= EVAX_READONLY_NAME
;
3620 else if ((*sname
== 'l') && (strcmp (sname
, "literal") == 0))
3621 sname
= EVAX_LITERAL_NAME
;
3622 else if ((*sname
== 'l') && (strcmp (sname
, "literals") == 0))
3623 sname
= EVAX_LITERALS_NAME
;
3624 else if ((*sname
== 'c') && (strcmp (sname
, "comm") == 0))
3625 sname
= EVAX_COMMON_NAME
;
3626 else if ((*sname
== 'l') && (strcmp (sname
, "lcomm") == 0))
3627 sname
= EVAX_LOCAL_NAME
;
3630 if (bfd_is_com_section (section
))
3631 new_flags
= (EGPS__V_OVR
| EGPS__V_REL
| EGPS__V_GBL
| EGPS__V_RD
3632 | EGPS__V_WRT
| EGPS__V_NOMOD
| EGPS__V_COM
);
3634 new_flags
= vms_esecflag_by_name (evax_section_flags
, sname
,
3637 /* Modify them as directed. */
3638 if (section
->flags
& SEC_READONLY
)
3639 new_flags
&= ~EGPS__V_WRT
;
3641 new_flags
&= ~vms_section_data (section
)->no_flags
;
3642 new_flags
|= vms_section_data (section
)->flags
;
3644 vms_debug2 ((3, "sec flags %x\n", section
->flags
));
3645 vms_debug2 ((3, "new_flags %x, _raw_size %lu\n",
3646 new_flags
, (unsigned long)section
->size
));
3648 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3649 _bfd_vms_output_short (recwr
, section
->alignment_power
& 0xff);
3650 _bfd_vms_output_short (recwr
, new_flags
);
3651 _bfd_vms_output_long (recwr
, (unsigned long) section
->size
);
3652 _bfd_vms_output_counted (recwr
, sname
);
3653 _bfd_vms_output_end_subrec (recwr
);
3655 /* If the section is an obsolute one, remind its index as it will be
3656 used later for absolute symbols. */
3657 if ((new_flags
& EGPS__V_REL
) == 0 && abs_section_index
< 0)
3658 abs_section_index
= section
->target_index
;
3661 /* Output symbols. */
3662 vms_debug2 ((3, "%d symbols found\n", abfd
->symcount
));
3664 bfd_set_start_address (abfd
, (bfd_vma
) -1);
3666 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3668 symbol
= abfd
->outsymbols
[symnum
];
3669 old_flags
= symbol
->flags
;
3671 /* Work-around a missing feature: consider __main as the main entry
3673 if (symbol
->name
[0] == '_' && strcmp (symbol
->name
, "__main") == 0)
3674 bfd_set_start_address (abfd
, (bfd_vma
)symbol
->value
);
3676 /* Only put in the GSD the global and the undefined symbols. */
3677 if (old_flags
& BSF_FILE
)
3680 if ((old_flags
& BSF_GLOBAL
) == 0 && !bfd_is_und_section (symbol
->section
))
3682 /* If the LIB$INITIIALIZE section is present, add a reference to
3683 LIB$INITIALIZE symbol. FIXME: this should be done explicitely
3684 in the assembly file. */
3685 if (!((old_flags
& BSF_SECTION_SYM
) != 0
3686 && strcmp (symbol
->section
->name
, "LIB$INITIALIZE") == 0))
3690 /* 13 bytes egsd, max 64 chars name -> should be 77 bytes. Add 16 more
3691 bytes for a possible ABS section. */
3692 if (_bfd_vms_output_check (recwr
, 80 + 16) < 0)
3694 if (!_bfd_vms_output_end (abfd
, recwr
))
3696 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3697 _bfd_vms_output_long (recwr
, 0);
3700 if ((old_flags
& BSF_GLOBAL
) != 0
3701 && bfd_is_abs_section (symbol
->section
)
3702 && abs_section_index
<= 0)
3704 /* Create an absolute section if none was defined. It is highly
3705 unlikely that the name $ABS$ clashes with a user defined
3706 non-absolute section name. */
3707 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3708 _bfd_vms_output_short (recwr
, 4);
3709 _bfd_vms_output_short (recwr
, EGPS__V_SHR
);
3710 _bfd_vms_output_long (recwr
, 0);
3711 _bfd_vms_output_counted (recwr
, "$ABS$");
3712 _bfd_vms_output_end_subrec (recwr
);
3714 abs_section_index
= target_index
++;
3717 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYM
);
3719 /* Data type, alignment. */
3720 _bfd_vms_output_short (recwr
, 0);
3724 if (old_flags
& BSF_WEAK
)
3725 new_flags
|= EGSY__V_WEAK
;
3726 if (bfd_is_com_section (symbol
->section
)) /* .comm */
3727 new_flags
|= (EGSY__V_WEAK
| EGSY__V_COMM
);
3729 if (old_flags
& BSF_FUNCTION
)
3731 new_flags
|= EGSY__V_NORM
;
3732 new_flags
|= EGSY__V_REL
;
3734 if (old_flags
& BSF_GLOBAL
)
3736 new_flags
|= EGSY__V_DEF
;
3737 if (!bfd_is_abs_section (symbol
->section
))
3738 new_flags
|= EGSY__V_REL
;
3740 _bfd_vms_output_short (recwr
, new_flags
);
3742 if (old_flags
& BSF_GLOBAL
)
3744 /* Symbol definition. */
3745 bfd_vma code_address
= 0;
3746 unsigned long ca_psindx
= 0;
3747 unsigned long psindx
;
3749 if ((old_flags
& BSF_FUNCTION
) && symbol
->udata
.p
!= NULL
)
3754 ((struct evax_private_udata_struct
*)symbol
->udata
.p
)->enbsym
;
3755 code_address
= sym
->value
;
3756 ca_psindx
= sym
->section
->target_index
;
3758 if (bfd_is_abs_section (symbol
->section
))
3759 psindx
= abs_section_index
;
3761 psindx
= symbol
->section
->target_index
;
3763 _bfd_vms_output_quad (recwr
, symbol
->value
);
3764 _bfd_vms_output_quad (recwr
, code_address
);
3765 _bfd_vms_output_long (recwr
, ca_psindx
);
3766 _bfd_vms_output_long (recwr
, psindx
);
3768 _bfd_vms_output_counted (recwr
, symbol
->name
);
3770 _bfd_vms_output_end_subrec (recwr
);
3773 _bfd_vms_output_alignment (recwr
, 8);
3774 return _bfd_vms_output_end (abfd
, recwr
);
3777 /* Write object header for bfd abfd. Return FALSE on error. */
3780 _bfd_vms_write_ehdr (bfd
*abfd
)
3783 unsigned int symnum
;
3784 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3786 vms_debug2 ((2, "vms_write_ehdr (%p)\n", abfd
));
3788 _bfd_vms_output_alignment (recwr
, 2);
3790 if (!_bfd_vms_write_emh (abfd
)
3791 || !_bfd_vms_write_lmn (abfd
, "GNU AS"))
3795 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3796 _bfd_vms_output_short (recwr
, EMH__C_SRC
);
3798 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3800 symbol
= abfd
->outsymbols
[symnum
];
3802 if (symbol
->flags
& BSF_FILE
)
3804 _bfd_vms_output_dump (recwr
, (unsigned char *) symbol
->name
,
3805 (int) strlen (symbol
->name
));
3810 if (symnum
== abfd
->symcount
)
3811 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("noname"));
3813 if (!_bfd_vms_output_end (abfd
, recwr
))
3817 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3818 _bfd_vms_output_short (recwr
, EMH__C_TTL
);
3819 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("TTL"));
3820 if (!_bfd_vms_output_end (abfd
, recwr
))
3824 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3825 _bfd_vms_output_short (recwr
, EMH__C_CPR
);
3826 _bfd_vms_output_dump (recwr
,
3827 (unsigned char *)"GNU BFD ported by Klaus Kämpf 1994-1996",
3829 return _bfd_vms_output_end (abfd
, recwr
);
3832 /* Part 4.6, relocations. */
3835 /* WRITE ETIR SECTION
3837 This is still under construction and therefore not documented. */
3839 /* Close the etir/etbt record. */
3842 end_etir_record (bfd
* abfd
)
3844 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3846 return _bfd_vms_output_end (abfd
, recwr
);
3850 start_etir_or_etbt_record (bfd
*abfd
, asection
*section
, bfd_vma offset
)
3852 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3854 if (section
->flags
& SEC_DEBUGGING
)
3856 _bfd_vms_output_begin (recwr
, EOBJ__C_ETBT
);
3860 /* Push start offset. */
3861 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3862 _bfd_vms_output_long (recwr
, (unsigned long) 0);
3863 _bfd_vms_output_end_subrec (recwr
);
3866 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_DFLOC
);
3867 _bfd_vms_output_end_subrec (recwr
);
3872 _bfd_vms_output_begin (recwr
, EOBJ__C_ETIR
);
3876 /* Push start offset. */
3877 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3878 _bfd_vms_output_long (recwr
, (unsigned long) section
->target_index
);
3879 _bfd_vms_output_quad (recwr
, offset
);
3880 _bfd_vms_output_end_subrec (recwr
);
3882 /* Start = pop (). */
3883 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_SETRB
);
3884 _bfd_vms_output_end_subrec (recwr
);
3889 /* Output a STO_IMM command for SSIZE bytes of data from CPR at virtual
3890 address VADDR in section specified by SEC_INDEX and NAME. */
3893 sto_imm (bfd
*abfd
, asection
*section
,
3894 bfd_size_type ssize
, unsigned char *cptr
, bfd_vma vaddr
)
3897 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3900 _bfd_vms_debug (8, "sto_imm %d bytes\n", (int) ssize
);
3901 _bfd_hexdump (9, cptr
, (int) ssize
, (int) vaddr
);
3906 /* Try all the rest. */
3909 if (_bfd_vms_output_check (recwr
, size
) < 0)
3911 /* Doesn't fit, split ! */
3912 if (!end_etir_record (abfd
))
3915 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3917 size
= _bfd_vms_output_check (recwr
, 0); /* get max size */
3918 if (size
> ssize
) /* more than what's left ? */
3922 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_IMM
);
3923 _bfd_vms_output_long (recwr
, (unsigned long) (size
));
3924 _bfd_vms_output_dump (recwr
, cptr
, size
);
3925 _bfd_vms_output_end_subrec (recwr
);
3928 _bfd_vms_debug (10, "dumped %d bytes\n", (int) size
);
3929 _bfd_hexdump (10, cptr
, (int) size
, (int) vaddr
);
3940 etir_output_check (bfd
*abfd
, asection
*section
, bfd_vma vaddr
, int checklen
)
3942 if (_bfd_vms_output_check (&PRIV (recwr
), checklen
) < 0)
3944 /* Not enough room in this record. Close it and open a new one. */
3945 if (!end_etir_record (abfd
))
3947 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3952 /* Return whether RELOC must be deferred till the end. */
3955 defer_reloc_p (arelent
*reloc
)
3957 switch (reloc
->howto
->type
)
3970 /* Write section contents for bfd abfd. Return FALSE on error. */
3973 _bfd_vms_write_etir (bfd
* abfd
, int objtype ATTRIBUTE_UNUSED
)
3976 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3978 vms_debug2 ((2, "vms_write_tir (%p, %d)\n", abfd
, objtype
));
3980 _bfd_vms_output_alignment (recwr
, 4);
3982 PRIV (vms_linkage_index
) = 0;
3984 for (section
= abfd
->sections
; section
; section
= section
->next
)
3986 vms_debug2 ((4, "writing %d. section '%s' (%d bytes)\n",
3987 section
->target_index
, section
->name
, (int) (section
->size
)));
3989 if (!(section
->flags
& SEC_HAS_CONTENTS
)
3990 || bfd_is_com_section (section
))
3993 if (!section
->contents
)
3995 bfd_set_error (bfd_error_no_contents
);
3999 start_etir_or_etbt_record (abfd
, section
, 0);
4001 if (section
->flags
& SEC_RELOC
)
4003 bfd_vma curr_addr
= 0;
4004 unsigned char *curr_data
= section
->contents
;
4006 int pass2_needed
= 0;
4007 int pass2_in_progress
= 0;
4010 if (section
->reloc_count
== 0)
4012 (_("SEC_RELOC with no relocs in section %pA"), section
);
4017 int i
= section
->reloc_count
;
4018 arelent
**rptr
= section
->orelocation
;
4019 _bfd_vms_debug (4, "%d relocations:\n", i
);
4022 _bfd_vms_debug (4, "sym %s in sec %s, value %08lx, "
4023 "addr %08lx, off %08lx, len %d: %s\n",
4024 (*(*rptr
)->sym_ptr_ptr
)->name
,
4025 (*(*rptr
)->sym_ptr_ptr
)->section
->name
,
4026 (long) (*(*rptr
)->sym_ptr_ptr
)->value
,
4027 (unsigned long)(*rptr
)->address
,
4028 (unsigned long)(*rptr
)->addend
,
4029 bfd_get_reloc_size ((*rptr
)->howto
),
4030 ( *rptr
)->howto
->name
);
4037 for (irel
= 0; irel
< section
->reloc_count
; irel
++)
4039 struct evax_private_udata_struct
*udata
;
4040 arelent
*rptr
= section
->orelocation
[irel
];
4041 bfd_vma addr
= rptr
->address
;
4042 asymbol
*sym
= *rptr
->sym_ptr_ptr
;
4043 asection
*sec
= sym
->section
;
4044 bool defer
= defer_reloc_p (rptr
);
4047 if (pass2_in_progress
)
4049 /* Non-deferred relocs have already been output. */
4055 /* Deferred relocs must be output at the very end. */
4062 /* Regular relocs are intertwined with binary data. */
4063 if (curr_addr
> addr
)
4064 _bfd_error_handler (_("size error in section %pA"),
4066 size
= addr
- curr_addr
;
4067 if (!sto_imm (abfd
, section
, size
, curr_data
, curr_addr
))
4073 size
= bfd_get_reloc_size (rptr
->howto
);
4075 switch (rptr
->howto
->type
)
4077 case ALPHA_R_IGNORE
:
4080 case ALPHA_R_REFLONG
:
4081 if (bfd_is_und_section (sym
->section
))
4083 bfd_vma addend
= rptr
->addend
;
4084 slen
= strlen ((char *) sym
->name
);
4085 if (!etir_output_check (abfd
, section
, curr_addr
, slen
))
4089 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
4090 _bfd_vms_output_counted (recwr
, sym
->name
);
4091 _bfd_vms_output_end_subrec (recwr
);
4092 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
4093 _bfd_vms_output_long (recwr
, (unsigned long) addend
);
4094 _bfd_vms_output_end_subrec (recwr
);
4095 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
4096 _bfd_vms_output_end_subrec (recwr
);
4097 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
4098 _bfd_vms_output_end_subrec (recwr
);
4102 _bfd_vms_output_begin_subrec
4103 (recwr
, ETIR__C_STO_GBL_LW
);
4104 _bfd_vms_output_counted (recwr
, sym
->name
);
4105 _bfd_vms_output_end_subrec (recwr
);
4108 else if (bfd_is_abs_section (sym
->section
))
4110 if (!etir_output_check (abfd
, section
, curr_addr
, 16))
4112 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
4113 _bfd_vms_output_long (recwr
, (unsigned long) sym
->value
);
4114 _bfd_vms_output_end_subrec (recwr
);
4115 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
4116 _bfd_vms_output_end_subrec (recwr
);
4120 if (!etir_output_check (abfd
, section
, curr_addr
, 32))
4122 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
4123 _bfd_vms_output_long (recwr
,
4124 (unsigned long) sec
->target_index
);
4125 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
4126 _bfd_vms_output_end_subrec (recwr
);
4127 /* ??? Table B-8 of the OpenVMS Linker Utilily Manual
4128 says that we should have a ETIR__C_STO_OFF here.
4129 But the relocation would not be BFD_RELOC_32 then.
4130 This case is very likely unreachable. */
4131 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
4132 _bfd_vms_output_end_subrec (recwr
);
4136 case ALPHA_R_REFQUAD
:
4137 if (bfd_is_und_section (sym
->section
))
4139 bfd_vma addend
= rptr
->addend
;
4140 slen
= strlen ((char *) sym
->name
);
4141 if (!etir_output_check (abfd
, section
, curr_addr
, slen
))
4145 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
4146 _bfd_vms_output_counted (recwr
, sym
->name
);
4147 _bfd_vms_output_end_subrec (recwr
);
4148 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
4149 _bfd_vms_output_quad (recwr
, addend
);
4150 _bfd_vms_output_end_subrec (recwr
);
4151 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
4152 _bfd_vms_output_end_subrec (recwr
);
4153 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
4154 _bfd_vms_output_end_subrec (recwr
);
4158 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_GBL
);
4159 _bfd_vms_output_counted (recwr
, sym
->name
);
4160 _bfd_vms_output_end_subrec (recwr
);
4163 else if (bfd_is_abs_section (sym
->section
))
4165 if (!etir_output_check (abfd
, section
, curr_addr
, 16))
4167 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
4168 _bfd_vms_output_quad (recwr
, sym
->value
);
4169 _bfd_vms_output_end_subrec (recwr
);
4170 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
4171 _bfd_vms_output_end_subrec (recwr
);
4175 if (!etir_output_check (abfd
, section
, curr_addr
, 32))
4177 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
4178 _bfd_vms_output_long (recwr
,
4179 (unsigned long) sec
->target_index
);
4180 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
4181 _bfd_vms_output_end_subrec (recwr
);
4182 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_OFF
);
4183 _bfd_vms_output_end_subrec (recwr
);
4188 if (!sto_imm (abfd
, section
, size
, curr_data
, curr_addr
))
4192 case ALPHA_R_LINKAGE
:
4194 if (!etir_output_check (abfd
, section
, curr_addr
, 64))
4196 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LP_PSB
);
4197 _bfd_vms_output_long
4198 (recwr
, (unsigned long) rptr
->addend
);
4199 if (rptr
->addend
> PRIV (vms_linkage_index
))
4200 PRIV (vms_linkage_index
) = rptr
->addend
;
4201 _bfd_vms_output_counted (recwr
, sym
->name
);
4202 _bfd_vms_output_byte (recwr
, 0);
4203 _bfd_vms_output_end_subrec (recwr
);
4206 case ALPHA_R_CODEADDR
:
4207 slen
= strlen ((char *) sym
->name
);
4208 if (!etir_output_check (abfd
, section
, curr_addr
, slen
))
4210 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_CA
);
4211 _bfd_vms_output_counted (recwr
, sym
->name
);
4212 _bfd_vms_output_end_subrec (recwr
);
4217 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4218 if (!etir_output_check (abfd
, section
, curr_addr
,
4219 32 + 1 + strlen (udata
->origname
)))
4221 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_NOP_GBL
);
4222 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
4223 _bfd_vms_output_long
4224 (recwr
, (unsigned long) section
->target_index
);
4225 _bfd_vms_output_quad (recwr
, rptr
->address
);
4226 _bfd_vms_output_long (recwr
, (unsigned long) 0x47ff041f);
4227 _bfd_vms_output_long
4228 (recwr
, (unsigned long) section
->target_index
);
4229 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4230 _bfd_vms_output_counted (recwr
, udata
->origname
);
4231 _bfd_vms_output_end_subrec (recwr
);
4235 _bfd_error_handler (_("spurious ALPHA_R_BSR reloc"));
4240 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4241 if (!etir_output_check (abfd
, section
, curr_addr
,
4242 32 + 1 + strlen (udata
->origname
)))
4244 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LDA_GBL
);
4245 _bfd_vms_output_long
4246 (recwr
, (unsigned long) udata
->lkindex
+ 1);
4247 _bfd_vms_output_long
4248 (recwr
, (unsigned long) section
->target_index
);
4249 _bfd_vms_output_quad (recwr
, rptr
->address
);
4250 _bfd_vms_output_long (recwr
, (unsigned long) 0x237B0000);
4251 _bfd_vms_output_long
4252 (recwr
, (unsigned long) udata
->bsym
->section
->target_index
);
4253 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4254 _bfd_vms_output_counted (recwr
, udata
->origname
);
4255 _bfd_vms_output_end_subrec (recwr
);
4260 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4261 if (!etir_output_check (abfd
, section
, curr_addr
,
4262 32 + 1 + strlen (udata
->origname
)))
4264 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_BOH_GBL
);
4265 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
4266 _bfd_vms_output_long
4267 (recwr
, (unsigned long) section
->target_index
);
4268 _bfd_vms_output_quad (recwr
, rptr
->address
);
4269 _bfd_vms_output_long (recwr
, (unsigned long) 0xD3400000);
4270 _bfd_vms_output_long
4271 (recwr
, (unsigned long) section
->target_index
);
4272 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4273 _bfd_vms_output_counted (recwr
, udata
->origname
);
4274 _bfd_vms_output_end_subrec (recwr
);
4278 _bfd_error_handler (_("unhandled relocation %s"),
4285 } /* End of relocs loop. */
4287 if (!pass2_in_progress
)
4289 /* Output rest of section. */
4290 if (curr_addr
> section
->size
)
4292 _bfd_error_handler (_("size error in section %pA"), section
);
4295 size
= section
->size
- curr_addr
;
4296 if (!sto_imm (abfd
, section
, size
, curr_data
, curr_addr
))
4303 pass2_in_progress
= 1;
4309 else /* (section->flags & SEC_RELOC) */
4310 if (!sto_imm (abfd
, section
, section
->size
, section
->contents
, 0))
4313 if (!end_etir_record (abfd
))
4317 _bfd_vms_output_alignment (recwr
, 2);
4321 /* Write cached information into a file being written, at bfd_close. */
4324 alpha_vms_write_object_contents (bfd
*abfd
)
4326 vms_debug2 ((1, "vms_write_object_contents (%p)\n", abfd
));
4328 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
4330 return alpha_vms_write_exec (abfd
);
4334 if (abfd
->section_count
> 0) /* we have sections */
4336 if (!_bfd_vms_write_ehdr (abfd
))
4338 if (!_bfd_vms_write_egsd (abfd
))
4340 if (!_bfd_vms_write_etir (abfd
, EOBJ__C_ETIR
))
4342 if (!_bfd_vms_write_eeom (abfd
))
4349 /* Debug stuff: nearest line. */
4351 #define SET_MODULE_PARSED(m) \
4352 do { if ((m)->name == NULL) (m)->name = ""; } while (0)
4353 #define IS_MODULE_PARSED(m) ((m)->name != NULL)
4355 /* Build a new module for the specified BFD. */
4357 static struct module
*
4358 new_module (bfd
*abfd
)
4360 struct module
*module
4361 = (struct module
*) bfd_zalloc (abfd
, sizeof (struct module
));
4362 module
->file_table_count
= 16; /* Arbitrary. */
4364 = bfd_zmalloc (module
->file_table_count
* sizeof (struct fileinfo
));
4368 /* Parse debug info for a module and internalize it. */
4371 parse_module (bfd
*abfd
, struct module
*module
, unsigned char *ptr
,
4372 bfd_size_type length
)
4374 unsigned char *maxptr
= ptr
+ length
;
4375 unsigned char *src_ptr
, *pcl_ptr
;
4376 unsigned int prev_linum
= 0, curr_linenum
= 0;
4377 bfd_vma prev_pc
= 0, curr_pc
= 0;
4378 struct srecinfo
*curr_srec
, *srec
;
4379 struct lineinfo
*curr_line
, *line
;
4380 struct funcinfo
*funcinfo
;
4382 /* Initialize tables with zero element. */
4383 curr_srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4386 module
->srec_table
= curr_srec
;
4388 curr_line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4391 module
->line_table
= curr_line
;
4393 while (ptr
+ 3 < maxptr
)
4395 /* The first byte is not counted in the recorded length. */
4396 int rec_length
= bfd_getl16 (ptr
) + 1;
4397 int rec_type
= bfd_getl16 (ptr
+ 2);
4399 vms_debug2 ((2, "DST record: leng %d, type %d\n", rec_length
, rec_type
));
4401 if (rec_length
> maxptr
- ptr
)
4403 if (rec_type
== DST__K_MODEND
)
4409 if (rec_length
<= DST_S_B_MODBEG_NAME
)
4412 = _bfd_vms_save_counted_string (abfd
, ptr
+ DST_S_B_MODBEG_NAME
,
4413 rec_length
- DST_S_B_MODBEG_NAME
);
4420 vms_debug2 ((3, "module: %s\n", module
->name
));
4427 if (rec_length
<= DST_S_B_RTNBEG_NAME
)
4429 funcinfo
= (struct funcinfo
*)
4430 bfd_zalloc (abfd
, sizeof (struct funcinfo
));
4434 = _bfd_vms_save_counted_string (abfd
, ptr
+ DST_S_B_RTNBEG_NAME
,
4435 rec_length
- DST_S_B_RTNBEG_NAME
);
4436 funcinfo
->low
= bfd_getl32 (ptr
+ DST_S_L_RTNBEG_ADDRESS
);
4437 funcinfo
->next
= module
->func_table
;
4438 module
->func_table
= funcinfo
;
4440 vms_debug2 ((3, "routine: %s at 0x%lx\n",
4441 funcinfo
->name
, (unsigned long) funcinfo
->low
));
4445 if (rec_length
< DST_S_L_RTNEND_SIZE
+ 4)
4447 if (!module
->func_table
)
4449 module
->func_table
->high
= module
->func_table
->low
4450 + bfd_getl32 (ptr
+ DST_S_L_RTNEND_SIZE
) - 1;
4452 if (module
->func_table
->high
> module
->high
)
4453 module
->high
= module
->func_table
->high
;
4455 vms_debug2 ((3, "end routine\n"));
4459 vms_debug2 ((3, "prologue\n"));
4463 vms_debug2 ((3, "epilog\n"));
4467 vms_debug2 ((3, "block\n"));
4471 vms_debug2 ((3, "end block\n"));
4475 src_ptr
= ptr
+ DST_S_C_SOURCE_HEADER_SIZE
;
4477 vms_debug2 ((3, "source info\n"));
4479 while (src_ptr
- ptr
< rec_length
)
4481 int cmd
= src_ptr
[0], cmd_length
, data
;
4485 case DST__K_SRC_DECLFILE
:
4486 if (src_ptr
- ptr
+ DST_S_B_SRC_DF_LENGTH
>= rec_length
)
4487 cmd_length
= 0x10000;
4489 cmd_length
= src_ptr
[DST_S_B_SRC_DF_LENGTH
] + 2;
4492 case DST__K_SRC_DEFLINES_B
:
4496 case DST__K_SRC_DEFLINES_W
:
4500 case DST__K_SRC_INCRLNUM_B
:
4504 case DST__K_SRC_SETFILE
:
4508 case DST__K_SRC_SETLNUM_L
:
4512 case DST__K_SRC_SETLNUM_W
:
4516 case DST__K_SRC_SETREC_L
:
4520 case DST__K_SRC_SETREC_W
:
4524 case DST__K_SRC_FORMFEED
:
4533 if (src_ptr
- ptr
+ cmd_length
> rec_length
)
4538 case DST__K_SRC_DECLFILE
:
4541 = bfd_getl16 (src_ptr
+ DST_S_W_SRC_DF_FILEID
);
4542 char *filename
= _bfd_vms_save_counted_string
4544 src_ptr
+ DST_S_B_SRC_DF_FILENAME
,
4545 ptr
+ rec_length
- (src_ptr
+ DST_S_B_SRC_DF_FILENAME
));
4547 if (fileid
>= module
->file_table_count
)
4549 unsigned int old_count
= module
->file_table_count
;
4550 module
->file_table_count
+= fileid
;
4552 = bfd_realloc_or_free (module
->file_table
,
4553 module
->file_table_count
4554 * sizeof (struct fileinfo
));
4555 if (module
->file_table
== NULL
)
4557 memset (module
->file_table
+ old_count
, 0,
4558 fileid
* sizeof (struct fileinfo
));
4561 module
->file_table
[fileid
].name
= filename
;
4562 module
->file_table
[fileid
].srec
= 1;
4563 vms_debug2 ((4, "DST_S_C_SRC_DECLFILE: %d, %s\n",
4564 fileid
, module
->file_table
[fileid
].name
));
4568 case DST__K_SRC_DEFLINES_B
:
4569 /* Perform the association and set the next higher index
4571 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4572 srec
= (struct srecinfo
*)
4573 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4574 srec
->line
= curr_srec
->line
+ data
;
4575 srec
->srec
= curr_srec
->srec
+ data
;
4576 srec
->sfile
= curr_srec
->sfile
;
4577 curr_srec
->next
= srec
;
4579 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_B: %d\n", data
));
4582 case DST__K_SRC_DEFLINES_W
:
4583 /* Perform the association and set the next higher index
4585 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4586 srec
= (struct srecinfo
*)
4587 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4588 srec
->line
= curr_srec
->line
+ data
;
4589 srec
->srec
= curr_srec
->srec
+ data
,
4590 srec
->sfile
= curr_srec
->sfile
;
4591 curr_srec
->next
= srec
;
4593 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_W: %d\n", data
));
4596 case DST__K_SRC_INCRLNUM_B
:
4597 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4598 curr_srec
->line
+= data
;
4599 vms_debug2 ((4, "DST_S_C_SRC_INCRLNUM_B: %d\n", data
));
4602 case DST__K_SRC_SETFILE
:
4603 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4604 if ((unsigned int) data
< module
->file_table_count
)
4606 curr_srec
->sfile
= data
;
4607 curr_srec
->srec
= module
->file_table
[data
].srec
;
4609 vms_debug2 ((4, "DST_S_C_SRC_SETFILE: %d\n", data
));
4612 case DST__K_SRC_SETLNUM_L
:
4613 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4614 curr_srec
->line
= data
;
4615 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_L: %d\n", data
));
4618 case DST__K_SRC_SETLNUM_W
:
4619 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4620 curr_srec
->line
= data
;
4621 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_W: %d\n", data
));
4624 case DST__K_SRC_SETREC_L
:
4625 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4626 curr_srec
->srec
= data
;
4627 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4628 vms_debug2 ((4, "DST_S_C_SRC_SETREC_L: %d\n", data
));
4631 case DST__K_SRC_SETREC_W
:
4632 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4633 curr_srec
->srec
= data
;
4634 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4635 vms_debug2 ((4, "DST_S_C_SRC_SETREC_W: %d\n", data
));
4638 case DST__K_SRC_FORMFEED
:
4639 vms_debug2 ((4, "DST_S_C_SRC_FORMFEED\n"));
4643 _bfd_error_handler (_("unknown source command %d"),
4648 src_ptr
+= cmd_length
;
4652 case DST__K_LINE_NUM
:
4653 pcl_ptr
= ptr
+ DST_S_C_LINE_NUM_HEADER_SIZE
;
4655 vms_debug2 ((3, "line info\n"));
4657 while (pcl_ptr
- ptr
< rec_length
)
4659 /* The command byte is signed so we must sign-extend it. */
4660 int cmd
= ((signed char *)pcl_ptr
)[0], cmd_length
, data
;
4664 case DST__K_DELTA_PC_W
:
4668 case DST__K_DELTA_PC_L
:
4672 case DST__K_INCR_LINUM
:
4676 case DST__K_INCR_LINUM_W
:
4680 case DST__K_INCR_LINUM_L
:
4684 case DST__K_SET_LINUM_INCR
:
4688 case DST__K_SET_LINUM_INCR_W
:
4692 case DST__K_RESET_LINUM_INCR
:
4696 case DST__K_BEG_STMT_MODE
:
4700 case DST__K_END_STMT_MODE
:
4704 case DST__K_SET_LINUM_B
:
4708 case DST__K_SET_LINUM
:
4712 case DST__K_SET_LINUM_L
:
4720 case DST__K_SET_PC_W
:
4724 case DST__K_SET_PC_L
:
4728 case DST__K_SET_STMTNUM
:
4744 case DST__K_SET_ABS_PC
:
4756 if (pcl_ptr
- ptr
+ cmd_length
> rec_length
)
4761 case DST__K_DELTA_PC_W
:
4762 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4765 vms_debug2 ((4, "DST__K_DELTA_PC_W: %d\n", data
));
4768 case DST__K_DELTA_PC_L
:
4769 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4772 vms_debug2 ((4, "DST__K_DELTA_PC_L: %d\n", data
));
4775 case DST__K_INCR_LINUM
:
4776 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4777 curr_linenum
+= data
;
4778 vms_debug2 ((4, "DST__K_INCR_LINUM: %d\n", data
));
4781 case DST__K_INCR_LINUM_W
:
4782 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4783 curr_linenum
+= data
;
4784 vms_debug2 ((4, "DST__K_INCR_LINUM_W: %d\n", data
));
4787 case DST__K_INCR_LINUM_L
:
4788 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4789 curr_linenum
+= data
;
4790 vms_debug2 ((4, "DST__K_INCR_LINUM_L: %d\n", data
));
4793 case DST__K_SET_LINUM_INCR
:
4795 (_("%s not implemented"), "DST__K_SET_LINUM_INCR");
4798 case DST__K_SET_LINUM_INCR_W
:
4800 (_("%s not implemented"), "DST__K_SET_LINUM_INCR_W");
4803 case DST__K_RESET_LINUM_INCR
:
4805 (_("%s not implemented"), "DST__K_RESET_LINUM_INCR");
4808 case DST__K_BEG_STMT_MODE
:
4810 (_("%s not implemented"), "DST__K_BEG_STMT_MODE");
4813 case DST__K_END_STMT_MODE
:
4815 (_("%s not implemented"), "DST__K_END_STMT_MODE");
4818 case DST__K_SET_LINUM_B
:
4819 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4820 curr_linenum
= data
;
4821 vms_debug2 ((4, "DST__K_SET_LINUM_B: %d\n", data
));
4824 case DST__K_SET_LINUM
:
4825 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4826 curr_linenum
= data
;
4827 vms_debug2 ((4, "DST__K_SET_LINE_NUM: %d\n", data
));
4830 case DST__K_SET_LINUM_L
:
4831 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4832 curr_linenum
= data
;
4833 vms_debug2 ((4, "DST__K_SET_LINUM_L: %d\n", data
));
4838 (_("%s not implemented"), "DST__K_SET_PC");
4841 case DST__K_SET_PC_W
:
4843 (_("%s not implemented"), "DST__K_SET_PC_W");
4846 case DST__K_SET_PC_L
:
4848 (_("%s not implemented"), "DST__K_SET_PC_L");
4851 case DST__K_SET_STMTNUM
:
4853 (_("%s not implemented"), "DST__K_SET_STMTNUM");
4857 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4859 vms_debug2 ((4, "DST__K_TERM: %d\n", data
));
4863 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4865 vms_debug2 ((4, "DST__K_TERM_W: %d\n", data
));
4869 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4871 vms_debug2 ((4, "DST__K_TERM_L: %d\n", data
));
4874 case DST__K_SET_ABS_PC
:
4875 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4877 vms_debug2 ((4, "DST__K_SET_ABS_PC: 0x%x\n", data
));
4885 vms_debug2 ((4, "bump pc to 0x%lx and line to %d\n",
4886 (unsigned long)curr_pc
, curr_linenum
));
4889 _bfd_error_handler (_("unknown line command %d"), cmd
);
4893 if ((curr_linenum
!= prev_linum
&& curr_pc
!= prev_pc
)
4895 || cmd
== DST__K_DELTA_PC_L
4896 || cmd
== DST__K_DELTA_PC_W
)
4898 line
= (struct lineinfo
*)
4899 bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4900 line
->address
= curr_pc
;
4901 line
->line
= curr_linenum
;
4903 curr_line
->next
= line
;
4906 prev_linum
= curr_linenum
;
4908 vms_debug2 ((4, "-> correlate pc 0x%lx with line %d\n",
4909 (unsigned long)curr_pc
, curr_linenum
));
4912 pcl_ptr
+= cmd_length
;
4916 case 0x17: /* Undocumented type used by DEC C to declare equates. */
4917 vms_debug2 ((3, "undocumented type 0x17\n"));
4921 vms_debug2 ((3, "ignoring record\n"));
4929 /* Finalize tables with EOL marker. */
4930 srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4931 srec
->line
= (unsigned int) -1;
4932 srec
->srec
= (unsigned int) -1;
4933 curr_srec
->next
= srec
;
4935 line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4936 line
->line
= (unsigned int) -1;
4937 line
->address
= (bfd_vma
) -1;
4938 curr_line
->next
= line
;
4940 /* Advertise that this module has been parsed. This is needed
4941 because parsing can be either performed at module creation
4942 or deferred until debug info is consumed. */
4943 SET_MODULE_PARSED (module
);
4947 /* Build the list of modules for the specified BFD. */
4949 static struct module
*
4950 build_module_list (bfd
*abfd
)
4952 struct module
*module
, *list
= NULL
;
4955 if ((dmt
= bfd_get_section_by_name (abfd
, "$DMT$")))
4957 /* We have a DMT section so this must be an image. Parse the
4958 section and build the list of modules. This is sufficient
4959 since we can compute the start address and the end address
4960 of every module from the section contents. */
4961 bfd_size_type size
= bfd_section_size (dmt
);
4962 unsigned char *buf
, *ptr
, *end
;
4964 if (! bfd_malloc_and_get_section (abfd
, dmt
, &buf
))
4967 vms_debug2 ((2, "DMT\n"));
4971 while (end
- ptr
>= DBG_S_C_DMT_HEADER_SIZE
)
4973 /* Each header declares a module with its start offset and size
4974 of debug info in the DST section, as well as the count of
4975 program sections (i.e. address spans) it contains. */
4976 unsigned int modbeg
= bfd_getl32 (ptr
+ DBG_S_L_DMT_MODBEG
);
4977 unsigned int msize
= bfd_getl32 (ptr
+ DBG_S_L_DST_SIZE
);
4978 int count
= bfd_getl16 (ptr
+ DBG_S_W_DMT_PSECT_COUNT
);
4979 ptr
+= DBG_S_C_DMT_HEADER_SIZE
;
4981 vms_debug2 ((3, "module: modbeg = %u, size = %u, count = %d\n",
4982 modbeg
, msize
, count
));
4984 /* We create a 'module' structure for each program section since
4985 we only support contiguous addresses in a 'module' structure.
4986 As a consequence, the actual debug info in the DST section is
4987 shared and can be parsed multiple times; that doesn't seem to
4988 cause problems in practice. */
4989 while (count
-- > 0 && end
- ptr
>= DBG_S_C_DMT_PSECT_SIZE
)
4991 unsigned int start
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_START
);
4992 unsigned int length
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_LENGTH
);
4993 module
= new_module (abfd
);
4994 module
->modbeg
= modbeg
;
4995 module
->size
= msize
;
4996 module
->low
= start
;
4997 module
->high
= start
+ length
;
4998 module
->next
= list
;
5000 ptr
+= DBG_S_C_DMT_PSECT_SIZE
;
5002 vms_debug2 ((4, "section: start = 0x%x, length = %u\n",
5010 /* We don't have a DMT section so this must be an object. Parse
5011 the module right now in order to compute its start address and
5013 void *dst
= PRIV (dst_section
)->contents
;
5018 module
= new_module (abfd
);
5019 if (!parse_module (abfd
, module
, PRIV (dst_section
)->contents
,
5020 PRIV (dst_section
)->size
))
5028 /* Calculate and return the name of the source file and the line nearest
5029 to the wanted location in the specified module. */
5032 module_find_nearest_line (bfd
*abfd
, struct module
*module
, bfd_vma addr
,
5033 const char **file
, const char **func
,
5036 struct funcinfo
*funcinfo
;
5037 struct lineinfo
*lineinfo
;
5038 struct srecinfo
*srecinfo
;
5041 /* Parse this module if that was not done at module creation. */
5042 if (! IS_MODULE_PARSED (module
))
5044 unsigned int size
= module
->size
;
5045 unsigned int modbeg
= PRIV (dst_section
)->filepos
+ module
->modbeg
;
5046 unsigned char *buffer
;
5048 if (bfd_seek (abfd
, modbeg
, SEEK_SET
) != 0
5049 || (buffer
= _bfd_malloc_and_read (abfd
, size
, size
)) == NULL
)
5051 bfd_set_error (bfd_error_no_debug_section
);
5055 ret
= parse_module (abfd
, module
, buffer
, size
);
5061 /* Find out the function (if any) that contains the address. */
5062 for (funcinfo
= module
->func_table
; funcinfo
; funcinfo
= funcinfo
->next
)
5063 if (addr
>= funcinfo
->low
&& addr
<= funcinfo
->high
)
5065 *func
= funcinfo
->name
;
5070 /* Find out the source file and the line nearest to the address. */
5071 for (lineinfo
= module
->line_table
; lineinfo
; lineinfo
= lineinfo
->next
)
5072 if (lineinfo
->next
&& addr
< lineinfo
->next
->address
)
5074 for (srecinfo
= module
->srec_table
; srecinfo
; srecinfo
= srecinfo
->next
)
5075 if (srecinfo
->next
&& lineinfo
->line
< srecinfo
->next
->line
)
5077 if (srecinfo
->sfile
> 0)
5079 *file
= module
->file_table
[srecinfo
->sfile
].name
;
5080 *line
= srecinfo
->srec
+ lineinfo
->line
- srecinfo
->line
;
5084 *file
= module
->name
;
5085 *line
= lineinfo
->line
;
5096 /* Provided a BFD, a section and an offset into the section, calculate and
5097 return the name of the source file and the line nearest to the wanted
5101 _bfd_vms_find_nearest_line (bfd
*abfd
,
5102 asymbol
**symbols ATTRIBUTE_UNUSED
,
5108 unsigned int *discriminator
)
5110 struct module
*module
;
5112 /* What address are we looking for? */
5113 bfd_vma addr
= section
->vma
+ offset
;
5121 /* We can't do anything if there is no DST (debug symbol table). */
5122 if (PRIV (dst_section
) == NULL
)
5125 /* Create the module list - if not already done. */
5126 if (PRIV (modules
) == NULL
)
5128 PRIV (modules
) = build_module_list (abfd
);
5129 if (PRIV (modules
) == NULL
)
5133 for (module
= PRIV (modules
); module
; module
= module
->next
)
5134 if (addr
>= module
->low
&& addr
<= module
->high
)
5135 return module_find_nearest_line (abfd
, module
, addr
, file
, func
, line
);
5140 /* Canonicalizations. */
5141 /* Set name, value, section and flags of SYM from E. */
5144 alpha_vms_convert_symbol (bfd
*abfd
, struct vms_symbol_entry
*e
, asymbol
*sym
)
5153 flags
= BSF_NO_FLAGS
;
5159 if (e
->flags
& EGSY__V_WEAK
)
5162 if (e
->flags
& EGSY__V_DEF
)
5164 /* Symbol definition. */
5165 flags
|= BSF_GLOBAL
;
5166 if (e
->flags
& EGSY__V_NORM
)
5167 flags
|= BSF_FUNCTION
;
5173 /* Symbol reference. */
5174 sec
= bfd_und_section_ptr
;
5179 /* A universal symbol is by definition global... */
5180 flags
|= BSF_GLOBAL
;
5182 /* ...and dynamic in shared libraries. */
5183 if (abfd
->flags
& DYNAMIC
)
5184 flags
|= BSF_DYNAMIC
;
5186 if (e
->flags
& EGSY__V_WEAK
)
5189 if (!(e
->flags
& EGSY__V_DEF
))
5192 if (e
->flags
& EGSY__V_NORM
)
5193 flags
|= BSF_FUNCTION
;
5196 /* sec = e->section; */
5197 sec
= bfd_abs_section_ptr
;
5212 /* Return the number of bytes required to store a vector of pointers
5213 to asymbols for all the symbols in the BFD abfd, including a
5214 terminal NULL pointer. If there are no symbols in the BFD,
5215 then return 0. If an error occurs, return -1. */
5218 alpha_vms_get_symtab_upper_bound (bfd
*abfd
)
5220 vms_debug2 ((1, "alpha_vms_get_symtab_upper_bound (%p), %d symbols\n",
5221 abfd
, PRIV (gsd_sym_count
)));
5223 return (PRIV (gsd_sym_count
) + 1) * sizeof (asymbol
*);
5226 /* Read the symbols from the BFD abfd, and fills in the vector
5227 location with pointers to the symbols and a trailing NULL.
5229 Return number of symbols read. */
5232 alpha_vms_canonicalize_symtab (bfd
*abfd
, asymbol
**symbols
)
5236 vms_debug2 ((1, "alpha_vms_canonicalize_symtab (%p, <ret>)\n", abfd
));
5238 if (PRIV (csymbols
) == NULL
)
5240 PRIV (csymbols
) = (asymbol
**) bfd_alloc
5241 (abfd
, PRIV (gsd_sym_count
) * sizeof (asymbol
*));
5243 /* Traverse table and fill symbols vector. */
5244 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
5246 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
5249 sym
= bfd_make_empty_symbol (abfd
);
5250 if (sym
== NULL
|| !alpha_vms_convert_symbol (abfd
, e
, sym
))
5252 bfd_release (abfd
, PRIV (csymbols
));
5253 PRIV (csymbols
) = NULL
;
5257 PRIV (csymbols
)[i
] = sym
;
5261 if (symbols
!= NULL
)
5263 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
5264 symbols
[i
] = PRIV (csymbols
)[i
];
5268 return PRIV (gsd_sym_count
);
5271 /* Read and convert relocations from ETIR. We do it once for all sections. */
5274 alpha_vms_slurp_relocs (bfd
*abfd
)
5278 vms_debug2 ((3, "alpha_vms_slurp_relocs\n"));
5280 /* We slurp relocs only once, for all sections. */
5281 if (PRIV (reloc_done
) != 0)
5282 return PRIV (reloc_done
) == 1;
5284 if (alpha_vms_canonicalize_symtab (abfd
, NULL
) < 0)
5287 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
5292 unsigned char *begin
;
5295 bfd_reloc_code_real_type reloc_code
;
5301 bfd_vma cur_address
;
5303 unsigned char *cur_sym
= NULL
;
5305 bfd_vma cur_addend
= 0;
5307 /* Skip non-ETIR records. */
5308 type
= _bfd_vms_get_object_record (abfd
);
5311 if (type
== EOBJ__C_EEOM
)
5313 if (type
!= EOBJ__C_ETIR
)
5316 begin
= PRIV (recrd
.rec
) + 4;
5317 end
= PRIV (recrd
.rec
) + PRIV (recrd
.rec_size
);
5319 for (ptr
= begin
; ptr
+ 4 <= end
; ptr
+= length
)
5323 cmd
= bfd_getl16 (ptr
);
5324 length
= bfd_getl16 (ptr
+ 2);
5325 if (length
< 4 || length
> end
- ptr
)
5328 _bfd_error_handler (_("corrupt reloc record"));
5332 cur_address
= vaddr
;
5334 vms_debug2 ((4, "alpha_vms_slurp_relocs: etir %s\n",
5335 _bfd_vms_etir_name (cmd
)));
5339 case ETIR__C_STA_GBL
: /* ALPHA_R_REFLONG und_section, step 1 */
5340 /* ALPHA_R_REFQUAD und_section, step 1 */
5345 case ETIR__C_STA_PQ
: /* ALPHA_R_REF{LONG|QUAD}, others part 1 */
5348 cur_psidx
= bfd_getl32 (ptr
+ 4);
5349 cur_addend
= bfd_getl64 (ptr
+ 8);
5353 case ETIR__C_CTL_SETRB
:
5354 if (prev_cmd
!= ETIR__C_STA_PQ
)
5357 /* xgettext:c-format */
5358 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (prev_cmd
),
5359 _bfd_vms_etir_name (cmd
));
5362 cur_psect
= cur_psidx
;
5368 case ETIR__C_STA_LW
: /* ALPHA_R_REFLONG abs_section, step 1 */
5369 /* ALPHA_R_REFLONG und_section, step 2 */
5372 if (prev_cmd
!= ETIR__C_STA_GBL
)
5375 /* xgettext:c-format */
5376 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
5377 _bfd_vms_etir_name (ETIR__C_STA_LW
));
5383 cur_addend
= bfd_getl32 (ptr
+ 4);
5387 case ETIR__C_STA_QW
: /* ALPHA_R_REFQUAD abs_section, step 1 */
5388 /* ALPHA_R_REFQUAD und_section, step 2 */
5389 if (prev_cmd
!= -1 && prev_cmd
!= ETIR__C_STA_GBL
)
5392 /* xgettext:c-format */
5393 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
5394 _bfd_vms_etir_name (ETIR__C_STA_QW
));
5399 cur_addend
= bfd_getl64 (ptr
+ 4);
5403 case ETIR__C_STO_LW
: /* ALPHA_R_REFLONG und_section, step 4 */
5404 /* ALPHA_R_REFLONG abs_section, step 2 */
5405 /* ALPHA_R_REFLONG others, step 2 */
5406 if (prev_cmd
!= ETIR__C_OPR_ADD
5407 && prev_cmd
!= ETIR__C_STA_LW
5408 && prev_cmd
!= ETIR__C_STA_PQ
)
5410 /* xgettext:c-format */
5411 _bfd_error_handler (_("unknown reloc %s + %s"),
5412 _bfd_vms_etir_name (prev_cmd
),
5413 _bfd_vms_etir_name (ETIR__C_STO_LW
));
5416 reloc_code
= BFD_RELOC_32
;
5419 case ETIR__C_STO_QW
: /* ALPHA_R_REFQUAD und_section, step 4 */
5420 /* ALPHA_R_REFQUAD abs_section, step 2 */
5421 if (prev_cmd
!= ETIR__C_OPR_ADD
&& prev_cmd
!= ETIR__C_STA_QW
)
5423 /* xgettext:c-format */
5424 _bfd_error_handler (_("unknown reloc %s + %s"),
5425 _bfd_vms_etir_name (prev_cmd
),
5426 _bfd_vms_etir_name (ETIR__C_STO_QW
));
5429 reloc_code
= BFD_RELOC_64
;
5432 case ETIR__C_STO_OFF
: /* ALPHA_R_REFQUAD others, step 2 */
5433 if (prev_cmd
!= ETIR__C_STA_PQ
)
5435 /* xgettext:c-format */
5436 _bfd_error_handler (_("unknown reloc %s + %s"),
5437 _bfd_vms_etir_name (prev_cmd
),
5438 _bfd_vms_etir_name (ETIR__C_STO_OFF
));
5441 reloc_code
= BFD_RELOC_64
;
5444 case ETIR__C_OPR_ADD
: /* ALPHA_R_REFLONG und_section, step 3 */
5445 /* ALPHA_R_REFQUAD und_section, step 3 */
5446 if (prev_cmd
!= ETIR__C_STA_LW
&& prev_cmd
!= ETIR__C_STA_QW
)
5448 /* xgettext:c-format */
5449 _bfd_error_handler (_("unknown reloc %s + %s"),
5450 _bfd_vms_etir_name (prev_cmd
),
5451 _bfd_vms_etir_name (ETIR__C_OPR_ADD
));
5454 prev_cmd
= ETIR__C_OPR_ADD
;
5457 case ETIR__C_STO_CA
: /* ALPHA_R_CODEADDR */
5458 reloc_code
= BFD_RELOC_ALPHA_CODEADDR
;
5462 case ETIR__C_STO_GBL
: /* ALPHA_R_REFQUAD und_section */
5463 reloc_code
= BFD_RELOC_64
;
5467 case ETIR__C_STO_GBL_LW
: /* ALPHA_R_REFLONG und_section */
5468 reloc_code
= BFD_RELOC_32
;
5472 case ETIR__C_STC_LP_PSB
: /* ALPHA_R_LINKAGE */
5473 reloc_code
= BFD_RELOC_ALPHA_LINKAGE
;
5477 case ETIR__C_STC_NOP_GBL
: /* ALPHA_R_NOP */
5478 reloc_code
= BFD_RELOC_ALPHA_NOP
;
5481 case ETIR__C_STC_BSR_GBL
: /* ALPHA_R_BSR */
5482 reloc_code
= BFD_RELOC_ALPHA_BSR
;
5485 case ETIR__C_STC_LDA_GBL
: /* ALPHA_R_LDA */
5486 reloc_code
= BFD_RELOC_ALPHA_LDA
;
5489 case ETIR__C_STC_BOH_GBL
: /* ALPHA_R_BOH */
5490 reloc_code
= BFD_RELOC_ALPHA_BOH
;
5496 cur_sym
= ptr
+ 4 + 32;
5497 cur_address
= bfd_getl64 (ptr
+ 4 + 8);
5498 cur_addend
= bfd_getl64 (ptr
+ 4 + 24);
5501 case ETIR__C_STO_IMM
:
5504 vaddr
+= bfd_getl32 (ptr
+ 4);
5508 _bfd_error_handler (_("unknown reloc %s"),
5509 _bfd_vms_etir_name (cmd
));
5515 struct vms_section_data_struct
*vms_sec
;
5519 /* Get section to which the relocation applies. */
5520 if (cur_psect
< 0 || cur_psect
> (int)PRIV (section_count
))
5522 _bfd_error_handler (_("invalid section index in ETIR"));
5526 if (PRIV (sections
) == NULL
)
5528 sec
= PRIV (sections
)[cur_psect
];
5529 if (sec
== bfd_abs_section_ptr
)
5531 _bfd_error_handler (_("relocation for non-REL psect"));
5535 vms_sec
= vms_section_data (sec
);
5537 /* Allocate a reloc entry. */
5538 if (sec
->reloc_count
>= vms_sec
->reloc_max
)
5540 if (vms_sec
->reloc_max
== 0)
5542 vms_sec
->reloc_max
= 64;
5543 sec
->relocation
= bfd_zmalloc
5544 (vms_sec
->reloc_max
* sizeof (arelent
));
5548 vms_sec
->reloc_max
*= 2;
5549 sec
->relocation
= bfd_realloc_or_free
5550 (sec
->relocation
, vms_sec
->reloc_max
* sizeof (arelent
));
5551 if (sec
->relocation
== NULL
)
5555 reloc
= &sec
->relocation
[sec
->reloc_count
];
5558 reloc
->howto
= bfd_reloc_type_lookup (abfd
, reloc_code
);
5560 if (cur_sym
!= NULL
)
5566 /* Linear search. */
5567 if (end
- cur_sym
< 1)
5571 if (end
- cur_sym
< symlen
)
5575 for (j
= 0; j
< PRIV (gsd_sym_count
); j
++)
5576 if (PRIV (syms
)[j
]->namelen
== symlen
5577 && memcmp (PRIV (syms
)[j
]->name
, cur_sym
, symlen
) == 0)
5579 sym
= &PRIV (csymbols
)[j
];
5584 _bfd_error_handler (_("unknown symbol in command %s"),
5585 _bfd_vms_etir_name (cmd
));
5586 reloc
->sym_ptr_ptr
= NULL
;
5589 reloc
->sym_ptr_ptr
= sym
;
5591 else if (cur_psidx
>= 0)
5593 if (PRIV (sections
) == NULL
|| cur_psidx
>= (int) PRIV (section_count
))
5595 reloc
->sym_ptr_ptr
=
5596 PRIV (sections
)[cur_psidx
]->symbol_ptr_ptr
;
5599 reloc
->sym_ptr_ptr
= NULL
;
5601 reloc
->address
= cur_address
;
5602 reloc
->addend
= cur_addend
;
5604 if (reloc_code
== ALPHA_R_LINKAGE
)
5607 size
= bfd_get_reloc_size (reloc
->howto
);
5617 vms_debug2 ((3, "alpha_vms_slurp_relocs: result = true\n"));
5618 PRIV (reloc_done
) = 1;
5622 PRIV (reloc_done
) = -1;
5626 /* Return the number of bytes required to store the relocation
5627 information associated with the given section. */
5630 alpha_vms_get_reloc_upper_bound (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*section
)
5632 if (!alpha_vms_slurp_relocs (abfd
))
5635 return (section
->reloc_count
+ 1L) * sizeof (arelent
*);
5638 /* Convert relocations from VMS (external) form into BFD internal
5639 form. Return the number of relocations. */
5642 alpha_vms_canonicalize_reloc (bfd
*abfd
, asection
*section
, arelent
**relptr
,
5643 asymbol
**symbols ATTRIBUTE_UNUSED
)
5648 if (!alpha_vms_slurp_relocs (abfd
))
5651 count
= section
->reloc_count
;
5652 tblptr
= section
->relocation
;
5655 *relptr
++ = tblptr
++;
5657 *relptr
= (arelent
*) NULL
;
5658 return section
->reloc_count
;
5661 /* Install a new set of internal relocs. */
5663 #define alpha_vms_set_reloc _bfd_generic_set_reloc
5666 /* This is just copied from ecoff-alpha, needs to be fixed probably. */
5668 /* How to process the various reloc types. */
5670 static bfd_reloc_status_type
5671 reloc_nil (bfd
* abfd ATTRIBUTE_UNUSED
,
5672 arelent
*reloc ATTRIBUTE_UNUSED
,
5673 asymbol
*sym ATTRIBUTE_UNUSED
,
5674 void * data ATTRIBUTE_UNUSED
,
5675 asection
*sec ATTRIBUTE_UNUSED
,
5676 bfd
*output_bfd ATTRIBUTE_UNUSED
,
5677 char **error_message ATTRIBUTE_UNUSED
)
5680 vms_debug (1, "reloc_nil (abfd %p, output_bfd %p)\n", abfd
, output_bfd
);
5681 vms_debug (2, "In section %s, symbol %s\n",
5682 sec
->name
, sym
->name
);
5683 vms_debug (2, "reloc sym %s, addr %08lx, addend %08lx, reloc is a %s\n",
5684 reloc
->sym_ptr_ptr
[0]->name
,
5685 (unsigned long)reloc
->address
,
5686 (unsigned long)reloc
->addend
, reloc
->howto
->name
);
5687 vms_debug (2, "data at %p\n", data
);
5688 /* _bfd_hexdump (2, data, bfd_get_reloc_size (reloc->howto), 0); */
5691 return bfd_reloc_ok
;
5694 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
5695 from smaller values. Start with zero, widen, *then* decrement. */
5696 #define MINUS_ONE (((bfd_vma)0) - 1)
5698 static reloc_howto_type alpha_howto_table
[] =
5700 HOWTO (ALPHA_R_IGNORE
, /* Type. */
5701 0, /* Rightshift. */
5704 true, /* PC relative. */
5706 complain_overflow_dont
,/* Complain_on_overflow. */
5707 reloc_nil
, /* Special_function. */
5708 "IGNORE", /* Name. */
5709 true, /* Partial_inplace. */
5710 0, /* Source mask */
5712 true), /* PC rel offset. */
5714 /* A 64 bit reference to a symbol. */
5715 HOWTO (ALPHA_R_REFQUAD
, /* Type. */
5716 0, /* Rightshift. */
5719 false, /* PC relative. */
5721 complain_overflow_bitfield
, /* Complain_on_overflow. */
5722 reloc_nil
, /* Special_function. */
5723 "REFQUAD", /* Name. */
5724 true, /* Partial_inplace. */
5725 MINUS_ONE
, /* Source mask. */
5726 MINUS_ONE
, /* Dest mask. */
5727 false), /* PC rel offset. */
5729 /* A 21 bit branch. The native assembler generates these for
5730 branches within the text segment, and also fills in the PC
5731 relative offset in the instruction. */
5732 HOWTO (ALPHA_R_BRADDR
, /* Type. */
5733 2, /* Rightshift. */
5736 true, /* PC relative. */
5738 complain_overflow_signed
, /* Complain_on_overflow. */
5739 reloc_nil
, /* Special_function. */
5740 "BRADDR", /* Name. */
5741 true, /* Partial_inplace. */
5742 0x1fffff, /* Source mask. */
5743 0x1fffff, /* Dest mask. */
5744 false), /* PC rel offset. */
5746 /* A hint for a jump to a register. */
5747 HOWTO (ALPHA_R_HINT
, /* Type. */
5748 2, /* Rightshift. */
5751 true, /* PC relative. */
5753 complain_overflow_dont
,/* Complain_on_overflow. */
5754 reloc_nil
, /* Special_function. */
5756 true, /* Partial_inplace. */
5757 0x3fff, /* Source mask. */
5758 0x3fff, /* Dest mask. */
5759 false), /* PC rel offset. */
5761 /* 16 bit PC relative offset. */
5762 HOWTO (ALPHA_R_SREL16
, /* Type. */
5763 0, /* Rightshift. */
5766 true, /* PC relative. */
5768 complain_overflow_signed
, /* Complain_on_overflow. */
5769 reloc_nil
, /* Special_function. */
5770 "SREL16", /* Name. */
5771 true, /* Partial_inplace. */
5772 0xffff, /* Source mask. */
5773 0xffff, /* Dest mask. */
5774 false), /* PC rel offset. */
5776 /* 32 bit PC relative offset. */
5777 HOWTO (ALPHA_R_SREL32
, /* Type. */
5778 0, /* Rightshift. */
5781 true, /* PC relative. */
5783 complain_overflow_signed
, /* Complain_on_overflow. */
5784 reloc_nil
, /* Special_function. */
5785 "SREL32", /* Name. */
5786 true, /* Partial_inplace. */
5787 0xffffffff, /* Source mask. */
5788 0xffffffff, /* Dest mask. */
5789 false), /* PC rel offset. */
5791 /* A 64 bit PC relative offset. */
5792 HOWTO (ALPHA_R_SREL64
, /* Type. */
5793 0, /* Rightshift. */
5796 true, /* PC relative. */
5798 complain_overflow_signed
, /* Complain_on_overflow. */
5799 reloc_nil
, /* Special_function. */
5800 "SREL64", /* Name. */
5801 true, /* Partial_inplace. */
5802 MINUS_ONE
, /* Source mask. */
5803 MINUS_ONE
, /* Dest mask. */
5804 false), /* PC rel offset. */
5806 /* Push a value on the reloc evaluation stack. */
5807 HOWTO (ALPHA_R_OP_PUSH
, /* Type. */
5808 0, /* Rightshift. */
5811 false, /* PC relative. */
5813 complain_overflow_dont
,/* Complain_on_overflow. */
5814 reloc_nil
, /* Special_function. */
5815 "OP_PUSH", /* Name. */
5816 false, /* Partial_inplace. */
5817 0, /* Source mask. */
5819 false), /* PC rel offset. */
5821 /* Store the value from the stack at the given address. Store it in
5822 a bitfield of size r_size starting at bit position r_offset. */
5823 HOWTO (ALPHA_R_OP_STORE
, /* Type. */
5824 0, /* Rightshift. */
5827 false, /* PC relative. */
5829 complain_overflow_dont
,/* Complain_on_overflow. */
5830 reloc_nil
, /* Special_function. */
5831 "OP_STORE", /* Name. */
5832 false, /* Partial_inplace. */
5833 0, /* Source mask. */
5834 MINUS_ONE
, /* Dest mask. */
5835 false), /* PC rel offset. */
5837 /* Subtract the reloc address from the value on the top of the
5838 relocation stack. */
5839 HOWTO (ALPHA_R_OP_PSUB
, /* Type. */
5840 0, /* Rightshift. */
5843 false, /* PC relative. */
5845 complain_overflow_dont
,/* Complain_on_overflow. */
5846 reloc_nil
, /* Special_function. */
5847 "OP_PSUB", /* Name. */
5848 false, /* Partial_inplace. */
5849 0, /* Source mask. */
5851 false), /* PC rel offset. */
5853 /* Shift the value on the top of the relocation stack right by the
5855 HOWTO (ALPHA_R_OP_PRSHIFT
, /* Type. */
5856 0, /* Rightshift. */
5859 false, /* PC relative. */
5861 complain_overflow_dont
,/* Complain_on_overflow. */
5862 reloc_nil
, /* Special_function. */
5863 "OP_PRSHIFT", /* Name. */
5864 false, /* Partial_inplace. */
5865 0, /* Source mask. */
5867 false), /* PC rel offset. */
5869 /* Hack. Linkage is done by linker. */
5870 HOWTO (ALPHA_R_LINKAGE
, /* Type. */
5871 0, /* Rightshift. */
5874 false, /* PC relative. */
5876 complain_overflow_dont
,/* Complain_on_overflow. */
5877 reloc_nil
, /* Special_function. */
5878 "LINKAGE", /* Name. */
5879 false, /* Partial_inplace. */
5880 0, /* Source mask. */
5882 false), /* PC rel offset. */
5884 /* A 32 bit reference to a symbol. */
5885 HOWTO (ALPHA_R_REFLONG
, /* Type. */
5886 0, /* Rightshift. */
5889 false, /* PC relative. */
5891 complain_overflow_bitfield
, /* Complain_on_overflow. */
5892 reloc_nil
, /* Special_function. */
5893 "REFLONG", /* Name. */
5894 true, /* Partial_inplace. */
5895 0xffffffff, /* Source mask. */
5896 0xffffffff, /* Dest mask. */
5897 false), /* PC rel offset. */
5899 /* A 64 bit reference to a procedure, written as 32 bit value. */
5900 HOWTO (ALPHA_R_CODEADDR
, /* Type. */
5901 0, /* Rightshift. */
5904 false, /* PC relative. */
5906 complain_overflow_signed
,/* Complain_on_overflow. */
5907 reloc_nil
, /* Special_function. */
5908 "CODEADDR", /* Name. */
5909 false, /* Partial_inplace. */
5910 0xffffffff, /* Source mask. */
5911 0xffffffff, /* Dest mask. */
5912 false), /* PC rel offset. */
5914 HOWTO (ALPHA_R_NOP
, /* Type. */
5915 0, /* Rightshift. */
5918 /* The following value must match that of ALPHA_R_BSR/ALPHA_R_BOH
5919 because the calculations for the 3 relocations are the same.
5920 See B.4.5.2 of the OpenVMS Linker Utility Manual. */
5921 true, /* PC relative. */
5923 complain_overflow_dont
,/* Complain_on_overflow. */
5924 reloc_nil
, /* Special_function. */
5926 false, /* Partial_inplace. */
5927 0xffffffff, /* Source mask. */
5928 0xffffffff, /* Dest mask. */
5929 false), /* PC rel offset. */
5931 HOWTO (ALPHA_R_BSR
, /* Type. */
5932 0, /* Rightshift. */
5935 true, /* PC relative. */
5937 complain_overflow_dont
,/* Complain_on_overflow. */
5938 reloc_nil
, /* Special_function. */
5940 false, /* Partial_inplace. */
5941 0xffffffff, /* Source mask. */
5942 0xffffffff, /* Dest mask. */
5943 false), /* PC rel offset. */
5945 HOWTO (ALPHA_R_LDA
, /* Type. */
5946 0, /* Rightshift. */
5949 false, /* PC relative. */
5951 complain_overflow_dont
,/* Complain_on_overflow. */
5952 reloc_nil
, /* Special_function. */
5954 false, /* Partial_inplace. */
5955 0xffffffff, /* Source mask. */
5956 0xffffffff, /* Dest mask. */
5957 false), /* PC rel offset. */
5959 HOWTO (ALPHA_R_BOH
, /* Type. */
5960 0, /* Rightshift. */
5963 true, /* PC relative. */
5965 complain_overflow_dont
,/* Complain_on_overflow. */
5966 reloc_nil
, /* Special_function. */
5968 false, /* Partial_inplace. */
5969 0xffffffff, /* Source mask. */
5970 0xffffffff, /* Dest mask. */
5971 false), /* PC rel offset. */
5974 /* Return a pointer to a howto structure which, when invoked, will perform
5975 the relocation code on data from the architecture noted. */
5977 static reloc_howto_type
*
5978 alpha_vms_bfd_reloc_type_lookup (bfd
* abfd ATTRIBUTE_UNUSED
,
5979 bfd_reloc_code_real_type code
)
5983 vms_debug2 ((1, "vms_bfd_reloc_type_lookup (%p, %d)\t", abfd
, code
));
5987 case BFD_RELOC_16
: alpha_type
= ALPHA_R_SREL16
; break;
5988 case BFD_RELOC_32
: alpha_type
= ALPHA_R_REFLONG
; break;
5989 case BFD_RELOC_64
: alpha_type
= ALPHA_R_REFQUAD
; break;
5990 case BFD_RELOC_CTOR
: alpha_type
= ALPHA_R_REFQUAD
; break;
5991 case BFD_RELOC_23_PCREL_S2
: alpha_type
= ALPHA_R_BRADDR
; break;
5992 case BFD_RELOC_ALPHA_HINT
: alpha_type
= ALPHA_R_HINT
; break;
5993 case BFD_RELOC_16_PCREL
: alpha_type
= ALPHA_R_SREL16
; break;
5994 case BFD_RELOC_32_PCREL
: alpha_type
= ALPHA_R_SREL32
; break;
5995 case BFD_RELOC_64_PCREL
: alpha_type
= ALPHA_R_SREL64
; break;
5996 case BFD_RELOC_ALPHA_LINKAGE
: alpha_type
= ALPHA_R_LINKAGE
; break;
5997 case BFD_RELOC_ALPHA_CODEADDR
: alpha_type
= ALPHA_R_CODEADDR
; break;
5998 case BFD_RELOC_ALPHA_NOP
: alpha_type
= ALPHA_R_NOP
; break;
5999 case BFD_RELOC_ALPHA_BSR
: alpha_type
= ALPHA_R_BSR
; break;
6000 case BFD_RELOC_ALPHA_LDA
: alpha_type
= ALPHA_R_LDA
; break;
6001 case BFD_RELOC_ALPHA_BOH
: alpha_type
= ALPHA_R_BOH
; break;
6003 _bfd_error_handler (_("reloc (%d) is *UNKNOWN*"), code
);
6006 vms_debug2 ((2, "reloc is %s\n", alpha_howto_table
[alpha_type
].name
));
6007 return & alpha_howto_table
[alpha_type
];
6010 static reloc_howto_type
*
6011 alpha_vms_bfd_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
6017 i
< sizeof (alpha_howto_table
) / sizeof (alpha_howto_table
[0]);
6019 if (alpha_howto_table
[i
].name
!= NULL
6020 && strcasecmp (alpha_howto_table
[i
].name
, r_name
) == 0)
6021 return &alpha_howto_table
[i
];
6027 alpha_vms_get_synthetic_symtab (bfd
*abfd
,
6028 long symcount ATTRIBUTE_UNUSED
,
6029 asymbol
**usyms ATTRIBUTE_UNUSED
,
6030 long dynsymcount ATTRIBUTE_UNUSED
,
6031 asymbol
**dynsyms ATTRIBUTE_UNUSED
,
6038 syms
= (asymbol
*) bfd_malloc (PRIV (norm_sym_count
) * sizeof (asymbol
));
6043 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
6045 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
6056 flags
= BSF_LOCAL
| BSF_SYNTHETIC
;
6063 if ((e
->flags
& EGSY__V_DEF
) && (e
->flags
& EGSY__V_NORM
))
6065 value
= e
->code_value
;
6066 sec
= e
->code_section
;
6077 sname
= bfd_alloc (abfd
, l
+ 5);
6080 memcpy (sname
, name
, l
);
6081 memcpy (sname
+ l
, "..en", 5);
6088 sym
->udata
.p
= NULL
;
6097 vms_time_to_str (unsigned char *buf
)
6099 time_t t
= vms_rawtime_to_time_t (buf
);
6100 char *res
= ctime (&t
);
6103 res
= "*invalid time*";
6110 evax_bfd_print_emh (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
6112 struct vms_emh_common
*emh
= (struct vms_emh_common
*)rec
;
6113 unsigned int subtype
;
6116 subtype
= (unsigned) bfd_getl16 (emh
->subtyp
);
6118 /* xgettext:c-format */
6119 fprintf (file
, _(" EMH %u (len=%u): "), subtype
, rec_len
);
6121 /* PR 21618: Check for invalid lengths. */
6122 if (rec_len
< sizeof (* emh
))
6124 fprintf (file
, _(" Error: The length is less than the length of an EMH record\n"));
6127 extra
= rec_len
- sizeof (struct vms_emh_common
);
6133 struct vms_emh_mhd
*mhd
= (struct vms_emh_mhd
*) rec
;
6134 unsigned char *name
;
6135 unsigned char *nextname
;
6136 unsigned char *maxname
;
6138 /* PR 21840: Check for invalid lengths. */
6139 if (rec_len
< sizeof (* mhd
))
6141 fprintf (file
, _(" Error: The record length is less than the size of an EMH_MHD record\n"));
6144 fprintf (file
, _("Module header\n"));
6145 fprintf (file
, _(" structure level: %u\n"), mhd
->strlvl
);
6146 fprintf (file
, _(" max record size: %u\n"),
6147 (unsigned) bfd_getl32 (mhd
->recsiz
));
6148 name
= (unsigned char *) (mhd
+ 1);
6149 maxname
= (unsigned char *) rec
+ rec_len
;
6150 if (name
> maxname
- 2)
6152 fprintf (file
, _(" Error: The module name is missing\n"));
6155 nextname
= name
+ name
[0] + 1;
6156 if (nextname
>= maxname
)
6158 fprintf (file
, _(" Error: The module name is too long\n"));
6161 fprintf (file
, _(" module name : %.*s\n"), name
[0], name
+ 1);
6163 if (name
> maxname
- 2)
6165 fprintf (file
, _(" Error: The module version is missing\n"));
6168 nextname
= name
+ name
[0] + 1;
6169 if (nextname
>= maxname
)
6171 fprintf (file
, _(" Error: The module version is too long\n"));
6174 fprintf (file
, _(" module version : %.*s\n"), name
[0], name
+ 1);
6176 if ((maxname
- name
) < 17 && maxname
[-1] != 0)
6177 fprintf (file
, _(" Error: The compile date is truncated\n"));
6179 fprintf (file
, _(" compile date : %.17s\n"), name
);
6184 fprintf (file
, _("Language Processor Name\n"));
6185 fprintf (file
, _(" language name: %.*s\n"), extra
, (char *)(emh
+ 1));
6189 fprintf (file
, _("Source Files Header\n"));
6190 fprintf (file
, _(" file: %.*s\n"), extra
, (char *)(emh
+ 1));
6194 fprintf (file
, _("Title Text Header\n"));
6195 fprintf (file
, _(" title: %.*s\n"), extra
, (char *)(emh
+ 1));
6199 fprintf (file
, _("Copyright Header\n"));
6200 fprintf (file
, _(" copyright: %.*s\n"), extra
, (char *)(emh
+ 1));
6204 fprintf (file
, _("unhandled emh subtype %u\n"), subtype
);
6210 evax_bfd_print_eeom (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
6212 struct vms_eeom
*eeom
= (struct vms_eeom
*)rec
;
6214 fprintf (file
, _(" EEOM (len=%u):\n"), rec_len
);
6216 /* PR 21618: Check for invalid lengths. */
6217 if (rec_len
< sizeof (* eeom
))
6219 fprintf (file
, _(" Error: The length is less than the length of an EEOM record\n"));
6223 fprintf (file
, _(" number of cond linkage pairs: %u\n"),
6224 (unsigned)bfd_getl32 (eeom
->total_lps
));
6225 fprintf (file
, _(" completion code: %u\n"),
6226 (unsigned)bfd_getl16 (eeom
->comcod
));
6229 fprintf (file
, _(" transfer addr flags: 0x%02x\n"), eeom
->tfrflg
);
6230 fprintf (file
, _(" transfer addr psect: %u\n"),
6231 (unsigned)bfd_getl32 (eeom
->psindx
));
6232 fprintf (file
, _(" transfer address : 0x%08x\n"),
6233 (unsigned)bfd_getl32 (eeom
->tfradr
));
6238 exav_bfd_print_egsy_flags (unsigned int flags
, FILE *file
)
6240 if (flags
& EGSY__V_WEAK
)
6241 fputs (_(" WEAK"), file
);
6242 if (flags
& EGSY__V_DEF
)
6243 fputs (_(" DEF"), file
);
6244 if (flags
& EGSY__V_UNI
)
6245 fputs (_(" UNI"), file
);
6246 if (flags
& EGSY__V_REL
)
6247 fputs (_(" REL"), file
);
6248 if (flags
& EGSY__V_COMM
)
6249 fputs (_(" COMM"), file
);
6250 if (flags
& EGSY__V_VECEP
)
6251 fputs (_(" VECEP"), file
);
6252 if (flags
& EGSY__V_NORM
)
6253 fputs (_(" NORM"), file
);
6254 if (flags
& EGSY__V_QUAD_VAL
)
6255 fputs (_(" QVAL"), file
);
6259 evax_bfd_print_egsd_flags (FILE *file
, unsigned int flags
)
6261 if (flags
& EGPS__V_PIC
)
6262 fputs (_(" PIC"), file
);
6263 if (flags
& EGPS__V_LIB
)
6264 fputs (_(" LIB"), file
);
6265 if (flags
& EGPS__V_OVR
)
6266 fputs (_(" OVR"), file
);
6267 if (flags
& EGPS__V_REL
)
6268 fputs (_(" REL"), file
);
6269 if (flags
& EGPS__V_GBL
)
6270 fputs (_(" GBL"), file
);
6271 if (flags
& EGPS__V_SHR
)
6272 fputs (_(" SHR"), file
);
6273 if (flags
& EGPS__V_EXE
)
6274 fputs (_(" EXE"), file
);
6275 if (flags
& EGPS__V_RD
)
6276 fputs (_(" RD"), file
);
6277 if (flags
& EGPS__V_WRT
)
6278 fputs (_(" WRT"), file
);
6279 if (flags
& EGPS__V_VEC
)
6280 fputs (_(" VEC"), file
);
6281 if (flags
& EGPS__V_NOMOD
)
6282 fputs (_(" NOMOD"), file
);
6283 if (flags
& EGPS__V_COM
)
6284 fputs (_(" COM"), file
);
6285 if (flags
& EGPS__V_ALLOC_64BIT
)
6286 fputs (_(" 64B"), file
);
6290 evax_bfd_print_egsd (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
6292 unsigned int off
= sizeof (struct vms_egsd
);
6295 fprintf (file
, _(" EGSD (len=%u):\n"), rec_len
);
6296 if (rec_len
< sizeof (struct vms_egsd
) + sizeof (struct vms_egsd_entry
))
6299 while (off
<= rec_len
- sizeof (struct vms_egsd_entry
))
6301 struct vms_egsd_entry
*e
= (struct vms_egsd_entry
*)(rec
+ off
);
6306 type
= (unsigned)bfd_getl16 (e
->gsdtyp
);
6307 len
= (unsigned)bfd_getl16 (e
->gsdsiz
);
6309 /* xgettext:c-format */
6310 fprintf (file
, _(" EGSD entry %2u (type: %u, len: %u): "),
6314 if (len
< sizeof (struct vms_egsd_entry
) || len
> rec_len
- off
)
6316 fprintf (file
, _(" Erroneous length\n"));
6323 if (len
>= offsetof (struct vms_egps
, name
))
6325 struct vms_egps
*egps
= (struct vms_egps
*) e
;
6326 unsigned int flags
= bfd_getl16 (egps
->flags
);
6329 fprintf (file
, _("PSC - Program section definition\n"));
6330 fprintf (file
, _(" alignment : 2**%u\n"), egps
->align
);
6331 fprintf (file
, _(" flags : 0x%04x"), flags
);
6332 evax_bfd_print_egsd_flags (file
, flags
);
6334 l
= bfd_getl32 (egps
->alloc
);
6335 fprintf (file
, _(" alloc (len): %u (0x%08x)\n"), l
, l
);
6336 rest
= len
- offsetof (struct vms_egps
, name
);
6337 fprintf (file
, _(" name : %.*s\n"),
6338 egps
->namlng
> rest
? rest
: egps
->namlng
,
6343 if (len
>= offsetof (struct vms_esgps
, name
))
6345 struct vms_esgps
*esgps
= (struct vms_esgps
*) e
;
6346 unsigned int flags
= bfd_getl16 (esgps
->flags
);
6349 fprintf (file
, _("SPSC - Shared Image Program section def\n"));
6350 fprintf (file
, _(" alignment : 2**%u\n"), esgps
->align
);
6351 fprintf (file
, _(" flags : 0x%04x"), flags
);
6352 evax_bfd_print_egsd_flags (file
, flags
);
6354 l
= bfd_getl32 (esgps
->alloc
);
6355 fprintf (file
, _(" alloc (len) : %u (0x%08x)\n"), l
, l
);
6356 fprintf (file
, _(" image offset : 0x%08x\n"),
6357 (unsigned int) bfd_getl32 (esgps
->base
));
6358 fprintf (file
, _(" symvec offset : 0x%08x\n"),
6359 (unsigned int) bfd_getl32 (esgps
->value
));
6360 rest
= len
- offsetof (struct vms_esgps
, name
);
6361 fprintf (file
, _(" name : %.*s\n"),
6362 esgps
->namlng
> rest
? rest
: esgps
->namlng
,
6367 if (len
>= sizeof (struct vms_egsy
))
6369 struct vms_egsy
*egsy
= (struct vms_egsy
*) e
;
6370 unsigned int flags
= bfd_getl16 (egsy
->flags
);
6372 if ((flags
& EGSY__V_DEF
) != 0
6373 && len
>= offsetof (struct vms_esdf
, name
))
6375 struct vms_esdf
*esdf
= (struct vms_esdf
*) e
;
6377 fprintf (file
, _("SYM - Global symbol definition\n"));
6378 fprintf (file
, _(" flags: 0x%04x"), flags
);
6379 exav_bfd_print_egsy_flags (flags
, file
);
6381 fprintf (file
, _(" psect offset: 0x%08x\n"),
6382 (unsigned) bfd_getl32 (esdf
->value
));
6383 if (flags
& EGSY__V_NORM
)
6385 fprintf (file
, _(" code address: 0x%08x\n"),
6386 (unsigned) bfd_getl32 (esdf
->code_address
));
6387 fprintf (file
, _(" psect index for entry point : %u\n"),
6388 (unsigned) bfd_getl32 (esdf
->ca_psindx
));
6390 fprintf (file
, _(" psect index : %u\n"),
6391 (unsigned) bfd_getl32 (esdf
->psindx
));
6392 rest
= len
- offsetof (struct vms_esdf
, name
);
6393 fprintf (file
, _(" name : %.*s\n"),
6394 esdf
->namlng
> rest
? rest
: esdf
->namlng
,
6397 else if (len
>= offsetof (struct vms_esrf
, name
))
6399 struct vms_esrf
*esrf
= (struct vms_esrf
*)e
;
6401 fprintf (file
, _("SYM - Global symbol reference\n"));
6402 rest
= len
- offsetof (struct vms_esrf
, name
);
6403 fprintf (file
, _(" name : %.*s\n"),
6404 esrf
->namlng
> rest
? rest
: esrf
->namlng
,
6410 if (len
>= sizeof (struct vms_eidc
))
6412 struct vms_eidc
*eidc
= (struct vms_eidc
*) e
;
6413 unsigned int flags
= bfd_getl32 (eidc
->flags
);
6416 fprintf (file
, _("IDC - Ident Consistency check\n"));
6417 fprintf (file
, _(" flags : 0x%08x"), flags
);
6418 if (flags
& EIDC__V_BINIDENT
)
6419 fputs (" BINDENT", file
);
6421 fprintf (file
, _(" id match : %x\n"),
6422 (flags
>> EIDC__V_IDMATCH_SH
) & EIDC__V_IDMATCH_MASK
);
6423 fprintf (file
, _(" error severity: %x\n"),
6424 (flags
>> EIDC__V_ERRSEV_SH
) & EIDC__V_ERRSEV_MASK
);
6426 rest
= len
- (p
- (unsigned char *) e
);
6427 fprintf (file
, _(" entity name : %.*s\n"),
6428 p
[0] > rest
- 1 ? rest
- 1 : p
[0], p
+ 1);
6429 if (rest
> 1u + p
[0])
6433 fprintf (file
, _(" object name : %.*s\n"),
6434 p
[0] > rest
- 1 ? rest
- 1 : p
[0], p
+ 1);
6435 if (rest
> 1u + p
[0])
6439 if (flags
& EIDC__V_BINIDENT
)
6442 fprintf (file
, _(" binary ident : 0x%08x\n"),
6443 (unsigned) bfd_getl32 (p
));
6446 fprintf (file
, _(" ascii ident : %.*s\n"),
6447 p
[0] > rest
- 1 ? rest
- 1 : p
[0], p
+ 1);
6453 if (len
>= offsetof (struct vms_egst
, name
))
6455 struct vms_egst
*egst
= (struct vms_egst
*) e
;
6456 unsigned int flags
= bfd_getl16 (egst
->header
.flags
);
6458 fprintf (file
, _("SYMG - Universal symbol definition\n"));
6459 fprintf (file
, _(" flags: 0x%04x"), flags
);
6460 exav_bfd_print_egsy_flags (flags
, file
);
6462 fprintf (file
, _(" symbol vector offset: 0x%08x\n"),
6463 (unsigned) bfd_getl32 (egst
->value
));
6464 fprintf (file
, _(" entry point: 0x%08x\n"),
6465 (unsigned) bfd_getl32 (egst
->lp_1
));
6466 fprintf (file
, _(" proc descr : 0x%08x\n"),
6467 (unsigned) bfd_getl32 (egst
->lp_2
));
6468 fprintf (file
, _(" psect index: %u\n"),
6469 (unsigned) bfd_getl32 (egst
->psindx
));
6470 rest
= len
- offsetof (struct vms_egst
, name
);
6471 fprintf (file
, _(" name : %.*s\n"),
6472 egst
->namlng
> rest
? rest
: egst
->namlng
,
6477 if (len
>= offsetof (struct vms_esdfv
, name
))
6479 struct vms_esdfv
*esdfv
= (struct vms_esdfv
*) e
;
6480 unsigned int flags
= bfd_getl16 (esdfv
->flags
);
6482 fprintf (file
, _("SYMV - Vectored symbol definition\n"));
6483 fprintf (file
, _(" flags: 0x%04x"), flags
);
6484 exav_bfd_print_egsy_flags (flags
, file
);
6486 fprintf (file
, _(" vector : 0x%08x\n"),
6487 (unsigned) bfd_getl32 (esdfv
->vector
));
6488 fprintf (file
, _(" psect offset: %u\n"),
6489 (unsigned) bfd_getl32 (esdfv
->value
));
6490 fprintf (file
, _(" psect index : %u\n"),
6491 (unsigned) bfd_getl32 (esdfv
->psindx
));
6492 rest
= len
- offsetof (struct vms_esdfv
, name
);
6493 fprintf (file
, _(" name : %.*s\n"),
6494 esdfv
->namlng
> rest
? rest
: esdfv
->namlng
,
6499 if (len
>= offsetof (struct vms_esdfm
, name
))
6501 struct vms_esdfm
*esdfm
= (struct vms_esdfm
*) e
;
6502 unsigned int flags
= bfd_getl16 (esdfm
->flags
);
6505 _("SYMM - Global symbol definition with version\n"));
6506 fprintf (file
, _(" flags: 0x%04x"), flags
);
6507 exav_bfd_print_egsy_flags (flags
, file
);
6509 fprintf (file
, _(" version mask: 0x%08x\n"),
6510 (unsigned)bfd_getl32 (esdfm
->version_mask
));
6511 fprintf (file
, _(" psect offset: %u\n"),
6512 (unsigned)bfd_getl32 (esdfm
->value
));
6513 fprintf (file
, _(" psect index : %u\n"),
6514 (unsigned)bfd_getl32 (esdfm
->psindx
));
6515 rest
= len
- offsetof (struct vms_esdfm
, name
);
6516 fprintf (file
, _(" name : %.*s\n"),
6517 esdfm
->namlng
> rest
? rest
: esdfm
->namlng
,
6522 fprintf (file
, _("unhandled egsd entry type %u\n"), type
);
6530 evax_bfd_print_hex (FILE *file
, const char *pfx
,
6531 const unsigned char *buf
, unsigned int len
)
6537 for (i
= 0; i
< len
; i
++)
6541 fprintf (file
, " %02x", buf
[i
]);
6554 evax_bfd_print_etir_stc_ir (FILE *file
, const unsigned char *buf
,
6555 unsigned int len
, int is_ps
)
6557 if (is_ps
? len
< 44 : len
< 33)
6560 /* xgettext:c-format */
6561 fprintf (file
, _(" linkage index: %u, replacement insn: 0x%08x\n"),
6562 (unsigned)bfd_getl32 (buf
),
6563 (unsigned)bfd_getl32 (buf
+ 16));
6564 /* xgettext:c-format */
6565 fprintf (file
, _(" psect idx 1: %u, offset 1: 0x%08x %08x\n"),
6566 (unsigned)bfd_getl32 (buf
+ 4),
6567 (unsigned)bfd_getl32 (buf
+ 12),
6568 (unsigned)bfd_getl32 (buf
+ 8));
6569 /* xgettext:c-format */
6570 fprintf (file
, _(" psect idx 2: %u, offset 2: 0x%08x %08x\n"),
6571 (unsigned)bfd_getl32 (buf
+ 20),
6572 (unsigned)bfd_getl32 (buf
+ 28),
6573 (unsigned)bfd_getl32 (buf
+ 24));
6575 /* xgettext:c-format */
6576 fprintf (file
, _(" psect idx 3: %u, offset 3: 0x%08x %08x\n"),
6577 (unsigned)bfd_getl32 (buf
+ 32),
6578 (unsigned)bfd_getl32 (buf
+ 40),
6579 (unsigned)bfd_getl32 (buf
+ 36));
6581 fprintf (file
, _(" global name: %.*s\n"),
6582 buf
[32] > len
- 33 ? len
- 33 : buf
[32],
6587 evax_bfd_print_etir (FILE *file
, const char *name
,
6588 unsigned char *rec
, unsigned int rec_len
)
6590 unsigned int off
= sizeof (struct vms_eobjrec
);
6592 /* xgettext:c-format */
6593 fprintf (file
, _(" %s (len=%u):\n"), name
, (unsigned) rec_len
);
6594 if (rec_len
< sizeof (struct vms_eobjrec
) + sizeof (struct vms_etir
))
6597 while (off
<= rec_len
- sizeof (struct vms_etir
))
6599 struct vms_etir
*etir
= (struct vms_etir
*)(rec
+ off
);
6605 type
= bfd_getl16 (etir
->rectyp
);
6606 size
= bfd_getl16 (etir
->size
);
6607 buf
= rec
+ off
+ sizeof (struct vms_etir
);
6609 if (size
< sizeof (struct vms_etir
) || size
> rec_len
- off
)
6611 fprintf (file
, _(" Erroneous length\n"));
6615 /* xgettext:c-format */
6616 fprintf (file
, _(" (type: %3u, size: %3u): "), type
, size
);
6617 rest
= size
- sizeof (struct vms_etir
);
6620 case ETIR__C_STA_GBL
:
6622 fprintf (file
, _("STA_GBL (stack global) %.*s\n"),
6623 buf
[0] > rest
- 1 ? rest
- 1 : buf
[0], buf
+ 1);
6625 case ETIR__C_STA_LW
:
6626 fprintf (file
, _("STA_LW (stack longword)"));
6628 fprintf (file
, " 0x%08x\n",
6629 (unsigned) bfd_getl32 (buf
));
6631 case ETIR__C_STA_QW
:
6632 fprintf (file
, _("STA_QW (stack quadword)"));
6634 fprintf (file
, " 0x%08x %08x\n",
6635 (unsigned) bfd_getl32 (buf
+ 4),
6636 (unsigned) bfd_getl32 (buf
+ 0));
6638 case ETIR__C_STA_PQ
:
6639 fprintf (file
, _("STA_PQ (stack psect base + offset)\n"));
6641 /* xgettext:c-format */
6642 fprintf (file
, _(" psect: %u, offset: 0x%08x %08x\n"),
6643 (unsigned) bfd_getl32 (buf
+ 0),
6644 (unsigned) bfd_getl32 (buf
+ 8),
6645 (unsigned) bfd_getl32 (buf
+ 4));
6647 case ETIR__C_STA_LI
:
6648 fprintf (file
, _("STA_LI (stack literal)\n"));
6650 case ETIR__C_STA_MOD
:
6651 fprintf (file
, _("STA_MOD (stack module)\n"));
6653 case ETIR__C_STA_CKARG
:
6654 fprintf (file
, _("STA_CKARG (compare procedure argument)\n"));
6658 fprintf (file
, _("STO_B (store byte)\n"));
6661 fprintf (file
, _("STO_W (store word)\n"));
6663 case ETIR__C_STO_LW
:
6664 fprintf (file
, _("STO_LW (store longword)\n"));
6666 case ETIR__C_STO_QW
:
6667 fprintf (file
, _("STO_QW (store quadword)\n"));
6669 case ETIR__C_STO_IMMR
:
6672 unsigned int rpt
= bfd_getl32 (buf
);
6674 _("STO_IMMR (store immediate repeat) %u bytes\n"),
6678 evax_bfd_print_hex (file
, " ", buf
+ 4, rpt
);
6681 case ETIR__C_STO_GBL
:
6683 fprintf (file
, _("STO_GBL (store global) %.*s\n"),
6684 buf
[0] > rest
- 1 ? rest
- 1 : buf
[0], buf
+ 1);
6686 case ETIR__C_STO_CA
:
6688 fprintf (file
, _("STO_CA (store code address) %.*s\n"),
6689 buf
[0] > rest
- 1 ? rest
- 1 : buf
[0], buf
+ 1);
6691 case ETIR__C_STO_RB
:
6692 fprintf (file
, _("STO_RB (store relative branch)\n"));
6694 case ETIR__C_STO_AB
:
6695 fprintf (file
, _("STO_AB (store absolute branch)\n"));
6697 case ETIR__C_STO_OFF
:
6698 fprintf (file
, _("STO_OFF (store offset to psect)\n"));
6700 case ETIR__C_STO_IMM
:
6703 unsigned int rpt
= bfd_getl32 (buf
);
6705 _("STO_IMM (store immediate) %u bytes\n"),
6709 evax_bfd_print_hex (file
, " ", buf
+ 4, rpt
);
6712 case ETIR__C_STO_GBL_LW
:
6714 fprintf (file
, _("STO_GBL_LW (store global longword) %.*s\n"),
6715 buf
[0] > rest
- 1 ? rest
- 1 : buf
[0], buf
+ 1);
6717 case ETIR__C_STO_LP_PSB
:
6718 fprintf (file
, _("STO_OFF (store LP with procedure signature)\n"));
6720 case ETIR__C_STO_HINT_GBL
:
6721 fprintf (file
, _("STO_BR_GBL (store branch global) *todo*\n"));
6723 case ETIR__C_STO_HINT_PS
:
6724 fprintf (file
, _("STO_BR_PS (store branch psect + offset) *todo*\n"));
6727 case ETIR__C_OPR_NOP
:
6728 fprintf (file
, _("OPR_NOP (no-operation)\n"));
6730 case ETIR__C_OPR_ADD
:
6731 fprintf (file
, _("OPR_ADD (add)\n"));
6733 case ETIR__C_OPR_SUB
:
6734 fprintf (file
, _("OPR_SUB (subtract)\n"));
6736 case ETIR__C_OPR_MUL
:
6737 fprintf (file
, _("OPR_MUL (multiply)\n"));
6739 case ETIR__C_OPR_DIV
:
6740 fprintf (file
, _("OPR_DIV (divide)\n"));
6742 case ETIR__C_OPR_AND
:
6743 fprintf (file
, _("OPR_AND (logical and)\n"));
6745 case ETIR__C_OPR_IOR
:
6746 fprintf (file
, _("OPR_IOR (logical inclusive or)\n"));
6748 case ETIR__C_OPR_EOR
:
6749 fprintf (file
, _("OPR_EOR (logical exclusive or)\n"));
6751 case ETIR__C_OPR_NEG
:
6752 fprintf (file
, _("OPR_NEG (negate)\n"));
6754 case ETIR__C_OPR_COM
:
6755 fprintf (file
, _("OPR_COM (complement)\n"));
6757 case ETIR__C_OPR_INSV
:
6758 fprintf (file
, _("OPR_INSV (insert field)\n"));
6760 case ETIR__C_OPR_ASH
:
6761 fprintf (file
, _("OPR_ASH (arithmetic shift)\n"));
6763 case ETIR__C_OPR_USH
:
6764 fprintf (file
, _("OPR_USH (unsigned shift)\n"));
6766 case ETIR__C_OPR_ROT
:
6767 fprintf (file
, _("OPR_ROT (rotate)\n"));
6769 case ETIR__C_OPR_SEL
:
6770 fprintf (file
, _("OPR_SEL (select)\n"));
6772 case ETIR__C_OPR_REDEF
:
6773 fprintf (file
, _("OPR_REDEF (redefine symbol to curr location)\n"));
6775 case ETIR__C_OPR_DFLIT
:
6776 fprintf (file
, _("OPR_REDEF (define a literal)\n"));
6779 case ETIR__C_STC_LP
:
6780 fprintf (file
, _("STC_LP (store cond linkage pair)\n"));
6782 case ETIR__C_STC_LP_PSB
:
6784 _("STC_LP_PSB (store cond linkage pair + signature)\n"));
6787 /* xgettext:c-format */
6788 fprintf (file
, _(" linkage index: %u, procedure: %.*s\n"),
6789 (unsigned) bfd_getl32 (buf
),
6790 buf
[4] > rest
- 5 ? rest
- 5 : buf
[4], buf
+ 5);
6791 if (rest
> 4 + 1u + buf
[4])
6793 rest
-= 4 + 1 + buf
[4];
6794 buf
+= 4 + 1 + buf
[4];
6795 fprintf (file
, _(" signature: %.*s\n"),
6796 buf
[0] > rest
- 1 ? rest
- 1: buf
[0], buf
+ 1);
6800 case ETIR__C_STC_GBL
:
6801 fprintf (file
, _("STC_GBL (store cond global)\n"));
6803 /* xgettext:c-format */
6804 fprintf (file
, _(" linkage index: %u, global: %.*s\n"),
6805 (unsigned) bfd_getl32 (buf
),
6806 buf
[4] > rest
- 5 ? rest
- 5 : buf
[4], buf
+ 5);
6808 case ETIR__C_STC_GCA
:
6809 fprintf (file
, _("STC_GCA (store cond code address)\n"));
6811 /* xgettext:c-format */
6812 fprintf (file
, _(" linkage index: %u, procedure name: %.*s\n"),
6813 (unsigned) bfd_getl32 (buf
),
6814 buf
[4] > rest
- 5 ? rest
- 5 : buf
[4], buf
+ 5);
6816 case ETIR__C_STC_PS
:
6817 fprintf (file
, _("STC_PS (store cond psect + offset)\n"));
6820 /* xgettext:c-format */
6821 _(" linkage index: %u, psect: %u, offset: 0x%08x %08x\n"),
6822 (unsigned)bfd_getl32 (buf
),
6823 (unsigned)bfd_getl32 (buf
+ 4),
6824 (unsigned)bfd_getl32 (buf
+ 12),
6825 (unsigned)bfd_getl32 (buf
+ 8));
6827 case ETIR__C_STC_NOP_GBL
:
6828 fprintf (file
, _("STC_NOP_GBL (store cond NOP at global addr)\n"));
6829 evax_bfd_print_etir_stc_ir (file
, buf
, rest
, 0);
6831 case ETIR__C_STC_NOP_PS
:
6832 fprintf (file
, _("STC_NOP_PS (store cond NOP at psect + offset)\n"));
6833 evax_bfd_print_etir_stc_ir (file
, buf
, rest
, 1);
6835 case ETIR__C_STC_BSR_GBL
:
6836 fprintf (file
, _("STC_BSR_GBL (store cond BSR at global addr)\n"));
6837 evax_bfd_print_etir_stc_ir (file
, buf
, rest
, 0);
6839 case ETIR__C_STC_BSR_PS
:
6840 fprintf (file
, _("STC_BSR_PS (store cond BSR at psect + offset)\n"));
6841 evax_bfd_print_etir_stc_ir (file
, buf
, rest
, 1);
6843 case ETIR__C_STC_LDA_GBL
:
6844 fprintf (file
, _("STC_LDA_GBL (store cond LDA at global addr)\n"));
6845 evax_bfd_print_etir_stc_ir (file
, buf
, rest
, 0);
6847 case ETIR__C_STC_LDA_PS
:
6848 fprintf (file
, _("STC_LDA_PS (store cond LDA at psect + offset)\n"));
6849 evax_bfd_print_etir_stc_ir (file
, buf
, rest
, 1);
6851 case ETIR__C_STC_BOH_GBL
:
6852 fprintf (file
, _("STC_BOH_GBL (store cond BOH at global addr)\n"));
6853 evax_bfd_print_etir_stc_ir (file
, buf
, rest
, 0);
6855 case ETIR__C_STC_BOH_PS
:
6856 fprintf (file
, _("STC_BOH_PS (store cond BOH at psect + offset)\n"));
6857 evax_bfd_print_etir_stc_ir (file
, buf
, rest
, 1);
6859 case ETIR__C_STC_NBH_GBL
:
6861 _("STC_NBH_GBL (store cond or hint at global addr)\n"));
6863 case ETIR__C_STC_NBH_PS
:
6865 _("STC_NBH_PS (store cond or hint at psect + offset)\n"));
6868 case ETIR__C_CTL_SETRB
:
6869 fprintf (file
, _("CTL_SETRB (set relocation base)\n"));
6871 case ETIR__C_CTL_AUGRB
:
6874 unsigned int val
= bfd_getl32 (buf
);
6875 fprintf (file
, _("CTL_AUGRB (augment relocation base) %u\n"),
6879 case ETIR__C_CTL_DFLOC
:
6880 fprintf (file
, _("CTL_DFLOC (define location)\n"));
6882 case ETIR__C_CTL_STLOC
:
6883 fprintf (file
, _("CTL_STLOC (set location)\n"));
6885 case ETIR__C_CTL_STKDL
:
6886 fprintf (file
, _("CTL_STKDL (stack defined location)\n"));
6889 fprintf (file
, _("*unhandled*\n"));
6897 evax_bfd_print_eobj (struct bfd
*abfd
, FILE *file
)
6899 bool is_first
= true;
6900 bool has_records
= true;
6904 unsigned int rec_len
;
6905 unsigned int pad_len
;
6907 unsigned int hdr_size
;
6909 unsigned char buf
[6];
6911 hdr_size
= has_records
? 6 : 4;
6912 if (bfd_read (buf
, hdr_size
, abfd
) != hdr_size
)
6914 fprintf (file
, _("cannot read GST record header\n"));
6918 type
= bfd_getl16 (buf
);
6919 rec_len
= bfd_getl16 (buf
+ 2);
6923 unsigned int rec_len2
= bfd_getl16 (buf
+ 4);
6928 if (type
== rec_len2
&& rec_len
== EOBJ__C_EMH
)
6929 /* Matched a VMS record EMH. */
6933 has_records
= false;
6934 if (type
!= EOBJ__C_EMH
)
6937 fprintf (file
, _("cannot find EMH in first GST record\n"));
6945 /* VMS record format is: record-size, type, record-size.
6946 See maybe_adjust_record_pointer_for_object comment. */
6947 if (type
== rec_len2
)
6954 pad_len
= (rec_len
+ 1) & ~1U;
6959 if (rec_len
< hdr_size
)
6961 fprintf (file
, _("corrupted GST\n"));
6965 rec
= bfd_malloc (pad_len
);
6969 memcpy (rec
, buf
+ (has_records
? 2 : 0), hdr_size
);
6971 if (bfd_read (rec
+ hdr_size
, pad_len
- hdr_size
, abfd
)
6972 != pad_len
- hdr_size
)
6974 fprintf (file
, _("cannot read GST record\n"));
6982 evax_bfd_print_emh (file
, rec
, rec_len
);
6985 evax_bfd_print_egsd (file
, rec
, rec_len
);
6988 evax_bfd_print_eeom (file
, rec
, rec_len
);
6992 evax_bfd_print_etir (file
, "ETIR", rec
, rec_len
);
6995 evax_bfd_print_etir (file
, "EDBG", rec
, rec_len
);
6998 evax_bfd_print_etir (file
, "ETBT", rec
, rec_len
);
7001 fprintf (file
, _(" unhandled EOBJ record type %u\n"), type
);
7009 evax_bfd_print_relocation_records (FILE *file
, const unsigned char *buf
,
7010 size_t buf_size
, size_t off
,
7011 unsigned int stride
)
7013 while (off
<= buf_size
- 8)
7019 count
= bfd_getl32 (buf
+ off
+ 0);
7023 base
= bfd_getl32 (buf
+ off
+ 4);
7025 /* xgettext:c-format */
7026 fprintf (file
, _(" bitcount: %u, base addr: 0x%08x\n"),
7030 for (j
= 0; count
> 0 && off
<= buf_size
- 4; j
+= 4, count
-= 32)
7036 val
= bfd_getl32 (buf
+ off
);
7039 /* xgettext:c-format */
7040 fprintf (file
, _(" bitmap: 0x%08x (count: %u):\n"), val
, count
);
7042 for (k
= 0; k
< 32; k
++)
7043 if (val
& (1u << k
))
7047 fprintf (file
, _(" %08x"), base
+ (j
* 8 + k
) * stride
);
7062 evax_bfd_print_address_fixups (FILE *file
, const unsigned char *buf
,
7063 size_t buf_size
, size_t off
)
7065 while (off
<= buf_size
- 8)
7070 count
= bfd_getl32 (buf
+ off
+ 0);
7073 /* xgettext:c-format */
7074 fprintf (file
, _(" image %u (%u entries)\n"),
7075 (unsigned) bfd_getl32 (buf
+ off
+ 4), count
);
7077 for (j
= 0; j
< count
&& off
<= buf_size
- 8; j
++)
7079 /* xgettext:c-format */
7080 fprintf (file
, _(" offset: 0x%08x, val: 0x%08x\n"),
7081 (unsigned) bfd_getl32 (buf
+ off
+ 0),
7082 (unsigned) bfd_getl32 (buf
+ off
+ 4));
7089 evax_bfd_print_reference_fixups (FILE *file
, const unsigned char *buf
,
7090 size_t buf_size
, size_t off
)
7094 while (off
<= buf_size
- 8)
7099 count
= bfd_getl32 (buf
+ off
+ 0);
7102 /* xgettext:c-format */
7103 fprintf (file
, _(" image %u (%u entries), offsets:\n"),
7104 (unsigned) bfd_getl32 (buf
+ off
+ 4), count
);
7106 for (j
= 0; j
< count
&& off
<= buf_size
- 4; j
++)
7110 fprintf (file
, _(" 0x%08x"), (unsigned) bfd_getl32 (buf
+ off
));
7125 evax_bfd_print_indent (int indent
, FILE *file
)
7127 for (; indent
; indent
--)
7132 evax_bfd_get_dsc_name (unsigned int v
)
7136 case DSC__K_DTYPE_Z
:
7137 return "Z (Unspecified)";
7138 case DSC__K_DTYPE_V
:
7140 case DSC__K_DTYPE_BU
:
7141 return "BU (Byte logical)";
7142 case DSC__K_DTYPE_WU
:
7143 return "WU (Word logical)";
7144 case DSC__K_DTYPE_LU
:
7145 return "LU (Longword logical)";
7146 case DSC__K_DTYPE_QU
:
7147 return "QU (Quadword logical)";
7148 case DSC__K_DTYPE_B
:
7149 return "B (Byte integer)";
7150 case DSC__K_DTYPE_W
:
7151 return "W (Word integer)";
7152 case DSC__K_DTYPE_L
:
7153 return "L (Longword integer)";
7154 case DSC__K_DTYPE_Q
:
7155 return "Q (Quadword integer)";
7156 case DSC__K_DTYPE_F
:
7157 return "F (Single-precision floating)";
7158 case DSC__K_DTYPE_D
:
7159 return "D (Double-precision floating)";
7160 case DSC__K_DTYPE_FC
:
7161 return "FC (Complex)";
7162 case DSC__K_DTYPE_DC
:
7163 return "DC (Double-precision Complex)";
7164 case DSC__K_DTYPE_T
:
7165 return "T (ASCII text string)";
7166 case DSC__K_DTYPE_NU
:
7167 return "NU (Numeric string, unsigned)";
7168 case DSC__K_DTYPE_NL
:
7169 return "NL (Numeric string, left separate sign)";
7170 case DSC__K_DTYPE_NLO
:
7171 return "NLO (Numeric string, left overpunched sign)";
7172 case DSC__K_DTYPE_NR
:
7173 return "NR (Numeric string, right separate sign)";
7174 case DSC__K_DTYPE_NRO
:
7175 return "NRO (Numeric string, right overpunched sig)";
7176 case DSC__K_DTYPE_NZ
:
7177 return "NZ (Numeric string, zoned sign)";
7178 case DSC__K_DTYPE_P
:
7179 return "P (Packed decimal string)";
7180 case DSC__K_DTYPE_ZI
:
7181 return "ZI (Sequence of instructions)";
7182 case DSC__K_DTYPE_ZEM
:
7183 return "ZEM (Procedure entry mask)";
7184 case DSC__K_DTYPE_DSC
:
7185 return "DSC (Descriptor, used for arrays of dyn strings)";
7186 case DSC__K_DTYPE_OU
:
7187 return "OU (Octaword logical)";
7188 case DSC__K_DTYPE_O
:
7189 return "O (Octaword integer)";
7190 case DSC__K_DTYPE_G
:
7191 return "G (Double precision G floating, 64 bit)";
7192 case DSC__K_DTYPE_H
:
7193 return "H (Quadruple precision floating, 128 bit)";
7194 case DSC__K_DTYPE_GC
:
7195 return "GC (Double precision complex, G floating)";
7196 case DSC__K_DTYPE_HC
:
7197 return "HC (Quadruple precision complex, H floating)";
7198 case DSC__K_DTYPE_CIT
:
7199 return "CIT (COBOL intermediate temporary)";
7200 case DSC__K_DTYPE_BPV
:
7201 return "BPV (Bound Procedure Value)";
7202 case DSC__K_DTYPE_BLV
:
7203 return "BLV (Bound Label Value)";
7204 case DSC__K_DTYPE_VU
:
7205 return "VU (Bit Unaligned)";
7206 case DSC__K_DTYPE_ADT
:
7207 return "ADT (Absolute Date-Time)";
7208 case DSC__K_DTYPE_VT
:
7209 return "VT (Varying Text)";
7210 case DSC__K_DTYPE_T2
:
7211 return "T2 (16-bit char)";
7212 case DSC__K_DTYPE_VT2
:
7213 return "VT2 (16-bit varying char)";
7215 return "?? (unknown)";
7220 evax_bfd_print_desc (const unsigned char *buf
, unsigned int bufsize
,
7221 int indent
, FILE *file
)
7226 unsigned char bclass
= buf
[3];
7227 unsigned char dtype
= buf
[2];
7228 unsigned int len
= (unsigned)bfd_getl16 (buf
);
7229 unsigned int pointer
= (unsigned)bfd_getl32 (buf
+ 4);
7231 evax_bfd_print_indent (indent
, file
);
7233 if (len
== 1 && pointer
== 0xffffffffUL
)
7236 fprintf (file
, _("64 bits *unhandled*\n"));
7240 /* xgettext:c-format */
7241 fprintf (file
, _("class: %u, dtype: %u, length: %u, pointer: 0x%08x\n"),
7242 bclass
, dtype
, len
, pointer
);
7245 case DSC__K_CLASS_NCA
:
7247 const struct vms_dsc_nca
*dsc
= (const void *)buf
;
7249 const unsigned char *b
;
7251 evax_bfd_print_indent (indent
, file
);
7252 fprintf (file
, _("non-contiguous array of %s\n"),
7253 evax_bfd_get_dsc_name (dsc
->dtype
));
7254 if (bufsize
>= sizeof (*dsc
))
7256 evax_bfd_print_indent (indent
+ 1, file
);
7258 /* xgettext:c-format */
7259 _("dimct: %u, aflags: 0x%02x, digits: %u, scale: %u\n"),
7260 dsc
->dimct
, dsc
->aflags
, dsc
->digits
, dsc
->scale
);
7261 evax_bfd_print_indent (indent
+ 1, file
);
7263 /* xgettext:c-format */
7264 _("arsize: %u, a0: 0x%08x\n"),
7265 (unsigned) bfd_getl32 (dsc
->arsize
),
7266 (unsigned) bfd_getl32 (dsc
->a0
));
7267 evax_bfd_print_indent (indent
+ 1, file
);
7268 fprintf (file
, _("Strides:\n"));
7269 b
= buf
+ sizeof (*dsc
);
7270 bufsize
-= sizeof (*dsc
);
7271 for (i
= 0; i
< dsc
->dimct
; i
++)
7275 evax_bfd_print_indent (indent
+ 2, file
);
7276 fprintf (file
, "[%u]: %u\n", i
+ 1,
7277 (unsigned) bfd_getl32 (b
));
7281 evax_bfd_print_indent (indent
+ 1, file
);
7282 fprintf (file
, _("Bounds:\n"));
7283 for (i
= 0; i
< dsc
->dimct
; i
++)
7287 evax_bfd_print_indent (indent
+ 2, file
);
7288 /* xgettext:c-format */
7289 fprintf (file
, _("[%u]: Lower: %u, upper: %u\n"), i
+ 1,
7290 (unsigned) bfd_getl32 (b
+ 0),
7291 (unsigned) bfd_getl32 (b
+ 4));
7298 case DSC__K_CLASS_UBS
:
7300 const struct vms_dsc_ubs
*ubs
= (const void *)buf
;
7302 evax_bfd_print_indent (indent
, file
);
7303 fprintf (file
, _("unaligned bit-string of %s\n"),
7304 evax_bfd_get_dsc_name (ubs
->dtype
));
7305 if (bufsize
>= sizeof (*ubs
))
7307 evax_bfd_print_indent (indent
+ 1, file
);
7309 /* xgettext:c-format */
7310 _("base: %u, pos: %u\n"),
7311 (unsigned) bfd_getl32 (ubs
->base
),
7312 (unsigned) bfd_getl32 (ubs
->pos
));
7317 fprintf (file
, _("*unhandled*\n"));
7324 evax_bfd_print_valspec (const unsigned char *buf
, unsigned int bufsize
,
7325 int indent
, FILE *file
)
7330 unsigned int vflags
= buf
[0];
7331 unsigned int value
= (unsigned) bfd_getl32 (buf
+ 1);
7332 unsigned int len
= 5;
7334 evax_bfd_print_indent (indent
, file
);
7335 /* xgettext:c-format */
7336 fprintf (file
, _("vflags: 0x%02x, value: 0x%08x "), vflags
, value
);
7342 case DST__K_VFLAGS_NOVAL
:
7343 fprintf (file
, _("(no value)\n"));
7345 case DST__K_VFLAGS_NOTACTIVE
:
7346 fprintf (file
, _("(not active)\n"));
7348 case DST__K_VFLAGS_UNALLOC
:
7349 fprintf (file
, _("(not allocated)\n"));
7351 case DST__K_VFLAGS_DSC
:
7352 fprintf (file
, _("(descriptor)\n"));
7353 if (value
<= bufsize
)
7354 evax_bfd_print_desc (buf
+ value
, bufsize
- value
, indent
+ 1, file
);
7356 case DST__K_VFLAGS_TVS
:
7357 fprintf (file
, _("(trailing value)\n"));
7359 case DST__K_VS_FOLLOWS
:
7360 fprintf (file
, _("(value spec follows)\n"));
7362 case DST__K_VFLAGS_BITOFFS
:
7363 fprintf (file
, _("(at bit offset %u)\n"), value
);
7366 /* xgettext:c-format */
7367 fprintf (file
, _("(reg: %u, disp: %u, indir: %u, kind: "),
7368 (vflags
& DST__K_REGNUM_MASK
) >> DST__K_REGNUM_SHIFT
,
7369 vflags
& DST__K_DISP
? 1 : 0,
7370 vflags
& DST__K_INDIR
? 1 : 0);
7371 switch (vflags
& DST__K_VALKIND_MASK
)
7373 case DST__K_VALKIND_LITERAL
:
7374 fputs (_("literal"), file
);
7376 case DST__K_VALKIND_ADDR
:
7377 fputs (_("address"), file
);
7379 case DST__K_VALKIND_DESC
:
7380 fputs (_("desc"), file
);
7382 case DST__K_VALKIND_REG
:
7383 fputs (_("reg"), file
);
7386 fputs (")\n", file
);
7393 evax_bfd_print_typspec (const unsigned char *buf
, unsigned int bufsize
,
7394 int indent
, FILE *file
)
7399 unsigned char kind
= buf
[2];
7400 unsigned int len
= (unsigned) bfd_getl16 (buf
);
7402 evax_bfd_print_indent (indent
, file
);
7403 /* xgettext:c-format */
7404 fprintf (file
, _("len: %2u, kind: %2u "), len
, kind
);
7409 case DST__K_TS_ATOM
:
7410 /* xgettext:c-format */
7412 fprintf (file
, _("atomic, type=0x%02x %s\n"),
7413 buf
[0], evax_bfd_get_dsc_name (buf
[0]));
7417 fprintf (file
, _("indirect, defined at 0x%08x\n"),
7418 (unsigned) bfd_getl32 (buf
));
7420 case DST__K_TS_TPTR
:
7421 fprintf (file
, _("typed pointer\n"));
7422 evax_bfd_print_typspec (buf
, bufsize
, indent
+ 1, file
);
7425 fprintf (file
, _("pointer\n"));
7427 case DST__K_TS_ARRAY
:
7429 const unsigned char *vs
;
7430 unsigned int vs_len
;
7431 unsigned int vec_len
;
7436 fprintf (file
, _("array, dim: %u, bitmap: "), buf
[0]);
7438 vec_len
= (buf
[0] + 1 + 7) / 8;
7439 for (i
= 0; i
< vec_len
; i
++)
7443 fprintf (file
, " %02x", buf
[i
+ 1]);
7449 vs
= buf
+ 1 + vec_len
;
7450 evax_bfd_print_indent (indent
, file
);
7451 fprintf (file
, _("array descriptor:\n"));
7452 vs_len
= evax_bfd_print_valspec (vs
, bufsize
, indent
+ 1, file
);
7454 if (bufsize
> vs_len
)
7457 for (i
= 0; i
< buf
[0] + 1U; i
++)
7458 if (buf
[1 + i
/ 8] & (1 << (i
% 8)))
7460 evax_bfd_print_indent (indent
, file
);
7462 fprintf (file
, _("type spec for element:\n"));
7464 fprintf (file
, _("type spec for subscript %u:\n"), i
);
7465 evax_bfd_print_typspec (vs
, bufsize
, indent
+ 1, file
);
7468 vs_len
= bfd_getl16 (vs
);
7469 if (bufsize
<= vs_len
)
7478 fprintf (file
, _("*unhandled*\n"));
7483 evax_bfd_print_dst (struct bfd
*abfd
, unsigned int dst_size
, FILE *file
)
7485 unsigned int off
= 0;
7486 unsigned int pc
= 0;
7487 unsigned int line
= 0;
7489 fprintf (file
, _("Debug symbol table:\n"));
7491 while (dst_size
> 0)
7493 struct vms_dst_header dsth
;
7498 if (bfd_read (&dsth
, sizeof (dsth
), abfd
) != sizeof (dsth
))
7500 fprintf (file
, _("cannot read DST header\n"));
7503 len
= bfd_getl16 (dsth
.length
);
7504 type
= bfd_getl16 (dsth
.type
);
7505 /* xgettext:c-format */
7506 fprintf (file
, _(" type: %3u, len: %3u (at 0x%08x): "),
7508 if (len
< sizeof (dsth
))
7515 len
-= sizeof (dsth
);
7520 buf
= _bfd_malloc_and_read (abfd
, len
, len
);
7523 fprintf (file
, _("cannot read DST symbol\n"));
7529 case DSC__K_DTYPE_V
:
7530 case DSC__K_DTYPE_BU
:
7531 case DSC__K_DTYPE_WU
:
7532 case DSC__K_DTYPE_LU
:
7533 case DSC__K_DTYPE_QU
:
7534 case DSC__K_DTYPE_B
:
7535 case DSC__K_DTYPE_W
:
7536 case DSC__K_DTYPE_L
:
7537 case DSC__K_DTYPE_Q
:
7538 case DSC__K_DTYPE_F
:
7539 case DSC__K_DTYPE_D
:
7540 case DSC__K_DTYPE_FC
:
7541 case DSC__K_DTYPE_DC
:
7542 case DSC__K_DTYPE_T
:
7543 case DSC__K_DTYPE_NU
:
7544 case DSC__K_DTYPE_NL
:
7545 case DSC__K_DTYPE_NLO
:
7546 case DSC__K_DTYPE_NR
:
7547 case DSC__K_DTYPE_NRO
:
7548 case DSC__K_DTYPE_NZ
:
7549 case DSC__K_DTYPE_P
:
7550 case DSC__K_DTYPE_ZI
:
7551 case DSC__K_DTYPE_ZEM
:
7552 case DSC__K_DTYPE_DSC
:
7553 case DSC__K_DTYPE_OU
:
7554 case DSC__K_DTYPE_O
:
7555 case DSC__K_DTYPE_G
:
7556 case DSC__K_DTYPE_H
:
7557 case DSC__K_DTYPE_GC
:
7558 case DSC__K_DTYPE_HC
:
7559 case DSC__K_DTYPE_CIT
:
7560 case DSC__K_DTYPE_BPV
:
7561 case DSC__K_DTYPE_BLV
:
7562 case DSC__K_DTYPE_VU
:
7563 case DSC__K_DTYPE_ADT
:
7564 case DSC__K_DTYPE_VT
:
7565 case DSC__K_DTYPE_T2
:
7566 case DSC__K_DTYPE_VT2
:
7567 fprintf (file
, _("standard data: %s\n"),
7568 evax_bfd_get_dsc_name (type
));
7569 evax_bfd_print_valspec (buf
, len
, 4, file
);
7571 fprintf (file
, _(" name: %.*s\n"),
7572 buf
[5] > len
- 6 ? len
- 6 : buf
[5], buf
+ 6);
7576 struct vms_dst_modbeg
*dst
= (void *)buf
;
7577 unsigned char *name
= buf
+ sizeof (*dst
);
7579 fprintf (file
, _("modbeg\n"));
7580 if (len
< sizeof (*dst
))
7582 /* xgettext:c-format */
7583 fprintf (file
, _(" flags: %d, language: %u, "
7584 "major: %u, minor: %u\n"),
7586 (unsigned)bfd_getl32 (dst
->language
),
7587 (unsigned)bfd_getl16 (dst
->major
),
7588 (unsigned)bfd_getl16 (dst
->minor
));
7589 len
-= sizeof (*dst
);
7593 fprintf (file
, _(" module name: %.*s\n"),
7594 name
[0] > nlen
? nlen
: name
[0], name
+ 1);
7598 name
+= name
[0] + 1;
7600 fprintf (file
, _(" compiler : %.*s\n"),
7601 name
[0] > nlen
? nlen
: name
[0], name
+ 1);
7607 fprintf (file
, _("modend\n"));
7611 struct vms_dst_rtnbeg
*dst
= (void *)buf
;
7612 unsigned char *name
= buf
+ sizeof (*dst
);
7614 fputs (_("rtnbeg\n"), file
);
7615 if (len
>= sizeof (*dst
))
7617 /* xgettext:c-format */
7618 fprintf (file
, _(" flags: %u, address: 0x%08x, "
7619 "pd-address: 0x%08x\n"),
7621 (unsigned) bfd_getl32 (dst
->address
),
7622 (unsigned) bfd_getl32 (dst
->pd_address
));
7623 len
-= sizeof (*dst
);
7627 fprintf (file
, _(" routine name: %.*s\n"),
7628 name
[0] > nlen
? nlen
: name
[0], name
+ 1);
7635 struct vms_dst_rtnend
*dst
= (void *)buf
;
7637 if (len
>= sizeof (*dst
))
7638 fprintf (file
, _("rtnend: size 0x%08x\n"),
7639 (unsigned) bfd_getl32 (dst
->size
));
7644 struct vms_dst_prolog
*dst
= (void *)buf
;
7646 if (len
>= sizeof (*dst
))
7647 /* xgettext:c-format */
7648 fprintf (file
, _("prolog: bkpt address 0x%08x\n"),
7649 (unsigned) bfd_getl32 (dst
->bkpt_addr
));
7654 struct vms_dst_epilog
*dst
= (void *)buf
;
7656 if (len
>= sizeof (*dst
))
7657 /* xgettext:c-format */
7658 fprintf (file
, _("epilog: flags: %u, count: %u\n"),
7659 dst
->flags
, (unsigned) bfd_getl32 (dst
->count
));
7664 struct vms_dst_blkbeg
*dst
= (void *)buf
;
7665 unsigned char *name
= buf
+ sizeof (*dst
);
7667 if (len
> sizeof (*dst
))
7670 len
-= sizeof (*dst
);
7672 /* xgettext:c-format */
7673 fprintf (file
, _("blkbeg: address: 0x%08x, name: %.*s\n"),
7674 (unsigned) bfd_getl32 (dst
->address
),
7675 name
[0] > nlen
? nlen
: name
[0], name
+ 1);
7681 struct vms_dst_blkend
*dst
= (void *)buf
;
7683 if (len
>= sizeof (*dst
))
7684 /* xgettext:c-format */
7685 fprintf (file
, _("blkend: size: 0x%08x\n"),
7686 (unsigned) bfd_getl32 (dst
->size
));
7689 case DST__K_TYPSPEC
:
7691 fprintf (file
, _("typspec (len: %u)\n"), len
);
7695 fprintf (file
, _(" name: %.*s\n"),
7696 buf
[0] > nlen
? nlen
: buf
[0], buf
+ 1);
7698 evax_bfd_print_typspec (buf
+ 1 + buf
[0], len
- (1 + buf
[0]),
7707 fprintf (file
, _("septyp, name: %.*s\n"),
7708 buf
[5] > len
- 6 ? len
- 6 : buf
[5], buf
+ 6);
7709 evax_bfd_print_valspec (buf
, len
, 4, file
);
7715 struct vms_dst_recbeg
*recbeg
= (void *)buf
;
7716 unsigned char *name
= buf
+ sizeof (*recbeg
);
7718 if (len
> sizeof (*recbeg
))
7720 int nlen
= len
- sizeof (*recbeg
) - 1;
7723 fprintf (file
, _("recbeg: name: %.*s\n"), nlen
, name
+ 1);
7724 evax_bfd_print_valspec (buf
, len
, 4, file
);
7727 fprintf (file
, _(" len: %u bits\n"),
7728 (unsigned) bfd_getl32 (name
+ 1 + nlen
));
7733 fprintf (file
, _("recend\n"));
7735 case DST__K_ENUMBEG
:
7737 /* xgettext:c-format */
7738 fprintf (file
, _("enumbeg, len: %u, name: %.*s\n"),
7739 buf
[0], buf
[1] > len
- 2 ? len
- 2 : buf
[1], buf
+ 2);
7741 case DST__K_ENUMELT
:
7744 fprintf (file
, _("enumelt, name: %.*s\n"),
7745 buf
[5] > len
- 6 ? len
- 6 : buf
[5], buf
+ 6);
7746 evax_bfd_print_valspec (buf
, len
, 4, file
);
7749 case DST__K_ENUMEND
:
7750 fprintf (file
, _("enumend\n"));
7754 struct vms_dst_label
*lab
= (void *)buf
;
7755 if (len
>= sizeof (*lab
))
7757 fprintf (file
, _("label, name: %.*s\n"),
7758 lab
->name
[0] > len
- 1 ? len
- 1 : lab
->name
[0],
7760 fprintf (file
, _(" address: 0x%08x\n"),
7761 (unsigned) bfd_getl32 (lab
->value
));
7765 case DST__K_DIS_RANGE
:
7768 unsigned int cnt
= bfd_getl32 (buf
);
7769 unsigned char *rng
= buf
+ 4;
7772 fprintf (file
, _("discontiguous range (nbr: %u)\n"), cnt
);
7774 for (i
= 0; i
< cnt
; i
++, rng
+= 8)
7778 /* xgettext:c-format */
7779 fprintf (file
, _(" address: 0x%08x, size: %u\n"),
7780 (unsigned) bfd_getl32 (rng
),
7781 (unsigned) bfd_getl32 (rng
+ 4));
7786 case DST__K_LINE_NUM
:
7788 unsigned char *buf_orig
= buf
;
7790 fprintf (file
, _("line num (len: %u)\n"), len
);
7805 case DST__K_DELTA_PC_W
:
7808 val
= bfd_getl16 (buf
);
7809 fprintf (file
, _("delta_pc_w %u\n"), val
);
7814 case DST__K_INCR_LINUM
:
7818 fprintf (file
, _("incr_linum(b): +%u\n"), val
);
7822 case DST__K_INCR_LINUM_W
:
7825 val
= bfd_getl16 (buf
);
7826 fprintf (file
, _("incr_linum_w: +%u\n"), val
);
7830 case DST__K_INCR_LINUM_L
:
7833 val
= bfd_getl32 (buf
);
7834 fprintf (file
, _("incr_linum_l: +%u\n"), val
);
7838 case DST__K_SET_LINUM
:
7841 line
= bfd_getl16 (buf
);
7842 fprintf (file
, _("set_line_num(w) %u\n"), line
);
7845 case DST__K_SET_LINUM_B
:
7849 fprintf (file
, _("set_line_num_b %u\n"), line
);
7852 case DST__K_SET_LINUM_L
:
7855 line
= bfd_getl32 (buf
);
7856 fprintf (file
, _("set_line_num_l %u\n"), line
);
7859 case DST__K_SET_ABS_PC
:
7862 pc
= bfd_getl32 (buf
);
7863 fprintf (file
, _("set_abs_pc: 0x%08x\n"), pc
);
7866 case DST__K_DELTA_PC_L
:
7869 fprintf (file
, _("delta_pc_l: +0x%08x\n"),
7870 (unsigned) bfd_getl32 (buf
));
7876 fprintf (file
, _("term(b): 0x%02x"), *buf
);
7878 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7884 val
= bfd_getl16 (buf
);
7885 fprintf (file
, _("term_w: 0x%04x"), val
);
7887 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7893 fprintf (file
, _("delta pc +%-4d"), -cmd
);
7894 line
++; /* FIXME: curr increment. */
7896 /* xgettext:c-format */
7897 fprintf (file
, _(" pc: 0x%08x line: %5u\n"),
7902 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7915 unsigned char *buf_orig
= buf
;
7917 fprintf (file
, _("source (len: %u)\n"), len
);
7927 case DST__K_SRC_DECLFILE
:
7929 struct vms_dst_src_decl_src
*src
= (void *) buf
;
7930 unsigned char *name
;
7933 if (len
< sizeof (*src
))
7935 /* xgettext:c-format */
7936 fprintf (file
, _(" declfile: len: %u, flags: %u, "
7938 src
->length
, src
->flags
,
7939 (unsigned)bfd_getl16 (src
->fileid
));
7940 /* xgettext:c-format */
7941 fprintf (file
, _(" rms: cdt: 0x%08x %08x, "
7942 "ebk: 0x%08x, ffb: 0x%04x, "
7944 (unsigned)bfd_getl32 (src
->rms_cdt
+ 4),
7945 (unsigned)bfd_getl32 (src
->rms_cdt
+ 0),
7946 (unsigned)bfd_getl32 (src
->rms_ebk
),
7947 (unsigned)bfd_getl16 (src
->rms_ffb
),
7949 if (src
->length
> len
|| src
->length
<= sizeof (*src
))
7951 nlen
= src
->length
- sizeof (*src
) - 1;
7952 name
= buf
+ sizeof (*src
);
7953 fprintf (file
, _(" filename : %.*s\n"),
7954 name
[0] > nlen
? nlen
: name
[0], name
+ 1);
7955 if (name
[0] >= nlen
)
7957 nlen
-= name
[0] + 1;
7958 name
+= name
[0] + 1;
7959 fprintf (file
, _(" module name: %.*s\n"),
7960 name
[0] > nlen
? nlen
: name
[0], name
+ 1);
7963 cmdlen
= src
->length
;
7966 case DST__K_SRC_SETFILE
:
7969 fprintf (file
, _(" setfile %u\n"),
7970 (unsigned) bfd_getl16 (buf
));
7973 case DST__K_SRC_SETREC_W
:
7976 fprintf (file
, _(" setrec %u\n"),
7977 (unsigned) bfd_getl16 (buf
));
7980 case DST__K_SRC_SETREC_L
:
7983 fprintf (file
, _(" setrec %u\n"),
7984 (unsigned) bfd_getl32 (buf
));
7987 case DST__K_SRC_SETLNUM_W
:
7990 fprintf (file
, _(" setlnum %u\n"),
7991 (unsigned) bfd_getl16 (buf
));
7994 case DST__K_SRC_SETLNUM_L
:
7997 fprintf (file
, _(" setlnum %u\n"),
7998 (unsigned) bfd_getl32 (buf
));
8001 case DST__K_SRC_DEFLINES_W
:
8004 fprintf (file
, _(" deflines %u\n"),
8005 (unsigned) bfd_getl16 (buf
));
8008 case DST__K_SRC_DEFLINES_B
:
8011 fprintf (file
, _(" deflines %u\n"), *buf
);
8014 case DST__K_SRC_FORMFEED
:
8015 fprintf (file
, _(" formfeed\n"));
8019 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
8031 fprintf (file
, _("*unhandled* dst type %u\n"), type
);
8039 evax_bfd_print_image (bfd
*abfd
, FILE *file
)
8041 struct vms_eihd eihd
;
8044 unsigned int eiha_off
;
8045 unsigned int eihi_off
;
8046 unsigned int eihs_off
;
8047 unsigned int eisd_off
;
8048 unsigned int eihef_off
= 0;
8049 unsigned int eihnp_off
= 0;
8050 unsigned int dmt_vbn
= 0;
8051 unsigned int dmt_size
= 0;
8052 unsigned int dst_vbn
= 0;
8053 unsigned int dst_size
= 0;
8054 unsigned int gst_vbn
= 0;
8055 unsigned int gst_size
= 0;
8056 unsigned int eiaf_vbn
= 0;
8057 unsigned int eiaf_size
= 0;
8058 unsigned int eihvn_off
;
8060 if (bfd_seek (abfd
, 0, SEEK_SET
)
8061 || bfd_read (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
8063 fprintf (file
, _("cannot read EIHD\n"));
8066 /* xgettext:c-format */
8067 fprintf (file
, _("EIHD: (size: %u, nbr blocks: %u)\n"),
8068 (unsigned)bfd_getl32 (eihd
.size
),
8069 (unsigned)bfd_getl32 (eihd
.hdrblkcnt
));
8070 /* xgettext:c-format */
8071 fprintf (file
, _(" majorid: %u, minorid: %u\n"),
8072 (unsigned)bfd_getl32 (eihd
.majorid
),
8073 (unsigned)bfd_getl32 (eihd
.minorid
));
8075 val
= (unsigned)bfd_getl32 (eihd
.imgtype
);
8079 name
= _("executable");
8082 name
= _("linkable image");
8085 name
= _("unknown");
8088 /* xgettext:c-format */
8089 fprintf (file
, _(" image type: %u (%s)"), val
, name
);
8091 val
= (unsigned)bfd_getl32 (eihd
.subtype
);
8094 case EIHD__C_NATIVE
:
8101 name
= _("unknown");
8104 /* xgettext:c-format */
8105 fprintf (file
, _(", subtype: %u (%s)\n"), val
, name
);
8107 eisd_off
= bfd_getl32 (eihd
.isdoff
);
8108 eiha_off
= bfd_getl32 (eihd
.activoff
);
8109 eihi_off
= bfd_getl32 (eihd
.imgidoff
);
8110 eihs_off
= bfd_getl32 (eihd
.symdbgoff
);
8111 /* xgettext:c-format */
8112 fprintf (file
, _(" offsets: isd: %u, activ: %u, symdbg: %u, "
8113 "imgid: %u, patch: %u\n"),
8114 eisd_off
, eiha_off
, eihs_off
, eihi_off
,
8115 (unsigned)bfd_getl32 (eihd
.patchoff
));
8116 fprintf (file
, _(" fixup info rva: "));
8117 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.iafva
));
8118 fprintf (file
, _(", symbol vector rva: "));
8119 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.symvva
));
8120 eihvn_off
= bfd_getl32 (eihd
.version_array_off
);
8121 fprintf (file
, _("\n"
8122 " version array off: %u\n"),
8125 /* xgettext:c-format */
8126 _(" img I/O count: %u, nbr channels: %u, req pri: %08x%08x\n"),
8127 (unsigned)bfd_getl32 (eihd
.imgiocnt
),
8128 (unsigned)bfd_getl32 (eihd
.iochancnt
),
8129 (unsigned)bfd_getl32 (eihd
.privreqs
+ 4),
8130 (unsigned)bfd_getl32 (eihd
.privreqs
+ 0));
8131 val
= (unsigned)bfd_getl32 (eihd
.lnkflags
);
8132 fprintf (file
, _(" linker flags: %08x:"), val
);
8133 if (val
& EIHD__M_LNKDEBUG
)
8134 fprintf (file
, " LNKDEBUG");
8135 if (val
& EIHD__M_LNKNOTFR
)
8136 fprintf (file
, " LNKNOTFR");
8137 if (val
& EIHD__M_NOP0BUFS
)
8138 fprintf (file
, " NOP0BUFS");
8139 if (val
& EIHD__M_PICIMG
)
8140 fprintf (file
, " PICIMG");
8141 if (val
& EIHD__M_P0IMAGE
)
8142 fprintf (file
, " P0IMAGE");
8143 if (val
& EIHD__M_DBGDMT
)
8144 fprintf (file
, " DBGDMT");
8145 if (val
& EIHD__M_INISHR
)
8146 fprintf (file
, " INISHR");
8147 if (val
& EIHD__M_XLATED
)
8148 fprintf (file
, " XLATED");
8149 if (val
& EIHD__M_BIND_CODE_SEC
)
8150 fprintf (file
, " BIND_CODE_SEC");
8151 if (val
& EIHD__M_BIND_DATA_SEC
)
8152 fprintf (file
, " BIND_DATA_SEC");
8153 if (val
& EIHD__M_MKTHREADS
)
8154 fprintf (file
, " MKTHREADS");
8155 if (val
& EIHD__M_UPCALLS
)
8156 fprintf (file
, " UPCALLS");
8157 if (val
& EIHD__M_OMV_READY
)
8158 fprintf (file
, " OMV_READY");
8159 if (val
& EIHD__M_EXT_BIND_SECT
)
8160 fprintf (file
, " EXT_BIND_SECT");
8161 fprintf (file
, "\n");
8162 /* xgettext:c-format */
8163 fprintf (file
, _(" ident: 0x%08x, sysver: 0x%08x, "
8164 "match ctrl: %u, symvect_size: %u\n"),
8165 (unsigned)bfd_getl32 (eihd
.ident
),
8166 (unsigned)bfd_getl32 (eihd
.sysver
),
8168 (unsigned)bfd_getl32 (eihd
.symvect_size
));
8169 fprintf (file
, _(" BPAGE: %u"),
8170 (unsigned)bfd_getl32 (eihd
.virt_mem_block_size
));
8171 if (val
& (EIHD__M_OMV_READY
| EIHD__M_EXT_BIND_SECT
))
8173 eihef_off
= bfd_getl32 (eihd
.ext_fixup_off
);
8174 eihnp_off
= bfd_getl32 (eihd
.noopt_psect_off
);
8175 /* xgettext:c-format */
8176 fprintf (file
, _(", ext fixup offset: %u, no_opt psect off: %u"),
8177 eihef_off
, eihnp_off
);
8179 fprintf (file
, _(", alias: %u\n"), (unsigned)bfd_getl16 (eihd
.alias
));
8183 struct vms_eihvn eihvn
;
8187 fprintf (file
, _("system version array information:\n"));
8188 if (bfd_seek (abfd
, eihvn_off
, SEEK_SET
)
8189 || bfd_read (&eihvn
, sizeof (eihvn
), abfd
) != sizeof (eihvn
))
8191 fprintf (file
, _("cannot read EIHVN header\n"));
8194 mask
= bfd_getl32 (eihvn
.subsystem_mask
);
8195 for (j
= 0; j
< 32; j
++)
8196 if (mask
& (1u << j
))
8198 struct vms_eihvn_subversion ver
;
8199 if (bfd_read (&ver
, sizeof (ver
), abfd
) != sizeof (ver
))
8201 fprintf (file
, _("cannot read EIHVN version\n"));
8204 fprintf (file
, _(" %02u "), j
);
8207 case EIHVN__BASE_IMAGE_BIT
:
8208 fputs (_("BASE_IMAGE "), file
);
8210 case EIHVN__MEMORY_MANAGEMENT_BIT
:
8211 fputs (_("MEMORY_MANAGEMENT"), file
);
8214 fputs (_("IO "), file
);
8216 case EIHVN__FILES_VOLUMES_BIT
:
8217 fputs (_("FILES_VOLUMES "), file
);
8219 case EIHVN__PROCESS_SCHED_BIT
:
8220 fputs (_("PROCESS_SCHED "), file
);
8222 case EIHVN__SYSGEN_BIT
:
8223 fputs (_("SYSGEN "), file
);
8225 case EIHVN__CLUSTERS_LOCKMGR_BIT
:
8226 fputs (_("CLUSTERS_LOCKMGR "), file
);
8228 case EIHVN__LOGICAL_NAMES_BIT
:
8229 fputs (_("LOGICAL_NAMES "), file
);
8231 case EIHVN__SECURITY_BIT
:
8232 fputs (_("SECURITY "), file
);
8234 case EIHVN__IMAGE_ACTIVATOR_BIT
:
8235 fputs (_("IMAGE_ACTIVATOR "), file
);
8237 case EIHVN__NETWORKS_BIT
:
8238 fputs (_("NETWORKS "), file
);
8240 case EIHVN__COUNTERS_BIT
:
8241 fputs (_("COUNTERS "), file
);
8243 case EIHVN__STABLE_BIT
:
8244 fputs (_("STABLE "), file
);
8246 case EIHVN__MISC_BIT
:
8247 fputs (_("MISC "), file
);
8249 case EIHVN__CPU_BIT
:
8250 fputs (_("CPU "), file
);
8252 case EIHVN__VOLATILE_BIT
:
8253 fputs (_("VOLATILE "), file
);
8255 case EIHVN__SHELL_BIT
:
8256 fputs (_("SHELL "), file
);
8258 case EIHVN__POSIX_BIT
:
8259 fputs (_("POSIX "), file
);
8261 case EIHVN__MULTI_PROCESSING_BIT
:
8262 fputs (_("MULTI_PROCESSING "), file
);
8264 case EIHVN__GALAXY_BIT
:
8265 fputs (_("GALAXY "), file
);
8268 fputs (_("*unknown* "), file
);
8271 fprintf (file
, ": %u.%u\n",
8272 (unsigned)bfd_getl16 (ver
.major
),
8273 (unsigned)bfd_getl16 (ver
.minor
));
8279 struct vms_eiha eiha
;
8281 if (bfd_seek (abfd
, eiha_off
, SEEK_SET
)
8282 || bfd_read (&eiha
, sizeof (eiha
), abfd
) != sizeof (eiha
))
8284 fprintf (file
, _("cannot read EIHA\n"));
8287 fprintf (file
, _("Image activation: (size=%u)\n"),
8288 (unsigned)bfd_getl32 (eiha
.size
));
8289 /* xgettext:c-format */
8290 fprintf (file
, _(" First address : 0x%08x 0x%08x\n"),
8291 (unsigned)bfd_getl32 (eiha
.tfradr1_h
),
8292 (unsigned)bfd_getl32 (eiha
.tfradr1
));
8293 /* xgettext:c-format */
8294 fprintf (file
, _(" Second address: 0x%08x 0x%08x\n"),
8295 (unsigned)bfd_getl32 (eiha
.tfradr2_h
),
8296 (unsigned)bfd_getl32 (eiha
.tfradr2
));
8297 /* xgettext:c-format */
8298 fprintf (file
, _(" Third address : 0x%08x 0x%08x\n"),
8299 (unsigned)bfd_getl32 (eiha
.tfradr3_h
),
8300 (unsigned)bfd_getl32 (eiha
.tfradr3
));
8301 /* xgettext:c-format */
8302 fprintf (file
, _(" Fourth address: 0x%08x 0x%08x\n"),
8303 (unsigned)bfd_getl32 (eiha
.tfradr4_h
),
8304 (unsigned)bfd_getl32 (eiha
.tfradr4
));
8305 /* xgettext:c-format */
8306 fprintf (file
, _(" Shared image : 0x%08x 0x%08x\n"),
8307 (unsigned)bfd_getl32 (eiha
.inishr_h
),
8308 (unsigned)bfd_getl32 (eiha
.inishr
));
8312 struct vms_eihi eihi
;
8314 if (bfd_seek (abfd
, eihi_off
, SEEK_SET
)
8315 || bfd_read (&eihi
, sizeof (eihi
), abfd
) != sizeof (eihi
))
8317 fprintf (file
, _("cannot read EIHI\n"));
8320 /* xgettext:c-format */
8321 fprintf (file
, _("Image identification: (major: %u, minor: %u)\n"),
8322 (unsigned)bfd_getl32 (eihi
.majorid
),
8323 (unsigned)bfd_getl32 (eihi
.minorid
));
8324 fprintf (file
, _(" image name : %.*s\n"),
8325 eihi
.imgnam
[0], eihi
.imgnam
+ 1);
8326 fprintf (file
, _(" link time : %s\n"),
8327 vms_time_to_str (eihi
.linktime
));
8328 fprintf (file
, _(" image ident : %.*s\n"),
8329 eihi
.imgid
[0], eihi
.imgid
+ 1);
8330 fprintf (file
, _(" linker ident : %.*s\n"),
8331 eihi
.linkid
[0], eihi
.linkid
+ 1);
8332 fprintf (file
, _(" image build ident: %.*s\n"),
8333 eihi
.imgbid
[0], eihi
.imgbid
+ 1);
8337 struct vms_eihs eihs
;
8339 if (bfd_seek (abfd
, eihs_off
, SEEK_SET
)
8340 || bfd_read (&eihs
, sizeof (eihs
), abfd
) != sizeof (eihs
))
8342 fprintf (file
, _("cannot read EIHS\n"));
8345 /* xgettext:c-format */
8346 fprintf (file
, _("Image symbol & debug table: (major: %u, minor: %u)\n"),
8347 (unsigned)bfd_getl32 (eihs
.majorid
),
8348 (unsigned)bfd_getl32 (eihs
.minorid
));
8349 dst_vbn
= bfd_getl32 (eihs
.dstvbn
);
8350 dst_size
= bfd_getl32 (eihs
.dstsize
);
8351 /* xgettext:c-format */
8352 fprintf (file
, _(" debug symbol table : vbn: %u, size: %u (0x%x)\n"),
8353 dst_vbn
, dst_size
, dst_size
);
8354 gst_vbn
= bfd_getl32 (eihs
.gstvbn
);
8355 gst_size
= bfd_getl32 (eihs
.gstsize
);
8356 /* xgettext:c-format */
8357 fprintf (file
, _(" global symbol table: vbn: %u, records: %u\n"),
8359 dmt_vbn
= bfd_getl32 (eihs
.dmtvbn
);
8360 dmt_size
= bfd_getl32 (eihs
.dmtsize
);
8361 /* xgettext:c-format */
8362 fprintf (file
, _(" debug module table : vbn: %u, size: %u\n"),
8365 while (eisd_off
!= 0)
8367 struct vms_eisd eisd
;
8372 if (bfd_seek (abfd
, eisd_off
, SEEK_SET
)
8373 || bfd_read (&eisd
, sizeof (eisd
), abfd
) != sizeof (eisd
))
8375 fprintf (file
, _("cannot read EISD\n"));
8378 len
= (unsigned)bfd_getl32 (eisd
.eisdsize
);
8379 if (len
!= (unsigned)-1)
8383 eisd_off
= (eisd_off
+ VMS_BLOCK_SIZE
) & ~(VMS_BLOCK_SIZE
- 1);
8385 /* xgettext:c-format */
8386 fprintf (file
, _("Image section descriptor: (major: %u, minor: %u, "
8387 "size: %u, offset: %u)\n"),
8388 (unsigned)bfd_getl32 (eisd
.majorid
),
8389 (unsigned)bfd_getl32 (eisd
.minorid
),
8393 /* xgettext:c-format */
8394 fprintf (file
, _(" section: base: 0x%08x%08x size: 0x%08x\n"),
8395 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 4),
8396 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 0),
8397 (unsigned)bfd_getl32 (eisd
.secsize
));
8398 val
= (unsigned)bfd_getl32 (eisd
.flags
);
8399 fprintf (file
, _(" flags: 0x%04x"), val
);
8400 if (val
& EISD__M_GBL
)
8401 fprintf (file
, " GBL");
8402 if (val
& EISD__M_CRF
)
8403 fprintf (file
, " CRF");
8404 if (val
& EISD__M_DZRO
)
8405 fprintf (file
, " DZRO");
8406 if (val
& EISD__M_WRT
)
8407 fprintf (file
, " WRT");
8408 if (val
& EISD__M_INITALCODE
)
8409 fprintf (file
, " INITALCODE");
8410 if (val
& EISD__M_BASED
)
8411 fprintf (file
, " BASED");
8412 if (val
& EISD__M_FIXUPVEC
)
8413 fprintf (file
, " FIXUPVEC");
8414 if (val
& EISD__M_RESIDENT
)
8415 fprintf (file
, " RESIDENT");
8416 if (val
& EISD__M_VECTOR
)
8417 fprintf (file
, " VECTOR");
8418 if (val
& EISD__M_PROTECT
)
8419 fprintf (file
, " PROTECT");
8420 if (val
& EISD__M_LASTCLU
)
8421 fprintf (file
, " LASTCLU");
8422 if (val
& EISD__M_EXE
)
8423 fprintf (file
, " EXE");
8424 if (val
& EISD__M_NONSHRADR
)
8425 fprintf (file
, " NONSHRADR");
8426 if (val
& EISD__M_QUAD_LENGTH
)
8427 fprintf (file
, " QUAD_LENGTH");
8428 if (val
& EISD__M_ALLOC_64BIT
)
8429 fprintf (file
, " ALLOC_64BIT");
8430 fprintf (file
, "\n");
8431 if (val
& EISD__M_FIXUPVEC
)
8433 eiaf_vbn
= bfd_getl32 (eisd
.vbn
);
8434 eiaf_size
= bfd_getl32 (eisd
.secsize
);
8436 /* xgettext:c-format */
8437 fprintf (file
, _(" vbn: %u, pfc: %u, matchctl: %u type: %u ("),
8438 (unsigned)bfd_getl32 (eisd
.vbn
),
8439 eisd
.pfc
, eisd
.matchctl
, eisd
.type
);
8442 case EISD__K_NORMAL
:
8443 fputs (_("NORMAL"), file
);
8445 case EISD__K_SHRFXD
:
8446 fputs (_("SHRFXD"), file
);
8448 case EISD__K_PRVFXD
:
8449 fputs (_("PRVFXD"), file
);
8451 case EISD__K_SHRPIC
:
8452 fputs (_("SHRPIC"), file
);
8454 case EISD__K_PRVPIC
:
8455 fputs (_("PRVPIC"), file
);
8457 case EISD__K_USRSTACK
:
8458 fputs (_("USRSTACK"), file
);
8461 fputs (_("*unknown*"), file
);
8464 fputs (_(")\n"), file
);
8465 if (val
& EISD__M_GBL
)
8466 /* xgettext:c-format */
8467 fprintf (file
, _(" ident: 0x%08x, name: %.*s\n"),
8468 (unsigned)bfd_getl32 (eisd
.ident
),
8469 eisd
.gblnam
[0], eisd
.gblnam
+ 1);
8475 if (bfd_seek (abfd
, (file_ptr
) (dmt_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
8477 fprintf (file
, _("cannot read DMT\n"));
8481 fprintf (file
, _("Debug module table:\n"));
8483 while (dmt_size
> 0)
8485 struct vms_dmt_header dmth
;
8488 if (bfd_read (&dmth
, sizeof (dmth
), abfd
) != sizeof (dmth
))
8490 fprintf (file
, _("cannot read DMT header\n"));
8493 count
= bfd_getl16 (dmth
.psect_count
);
8495 /* xgettext:c-format */
8496 _(" module offset: 0x%08x, size: 0x%08x, (%u psects)\n"),
8497 (unsigned)bfd_getl32 (dmth
.modbeg
),
8498 (unsigned)bfd_getl32 (dmth
.size
), count
);
8499 dmt_size
-= sizeof (dmth
);
8502 struct vms_dmt_psect dmtp
;
8504 if (bfd_read (&dmtp
, sizeof (dmtp
), abfd
) != sizeof (dmtp
))
8506 fprintf (file
, _("cannot read DMT psect\n"));
8509 /* xgettext:c-format */
8510 fprintf (file
, _(" psect start: 0x%08x, length: %u\n"),
8511 (unsigned)bfd_getl32 (dmtp
.start
),
8512 (unsigned)bfd_getl32 (dmtp
.length
));
8514 dmt_size
-= sizeof (dmtp
);
8521 if (bfd_seek (abfd
, (file_ptr
) (dst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
8523 fprintf (file
, _("cannot read DST\n"));
8527 evax_bfd_print_dst (abfd
, dst_size
, file
);
8531 if (bfd_seek (abfd
, (file_ptr
) (gst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
8533 fprintf (file
, _("cannot read GST\n"));
8537 fprintf (file
, _("Global symbol table:\n"));
8538 evax_bfd_print_eobj (abfd
, file
);
8540 if (eiaf_vbn
!= 0 && eiaf_size
>= sizeof (struct vms_eiaf
))
8543 struct vms_eiaf
*eiaf
;
8544 unsigned int qrelfixoff
;
8545 unsigned int lrelfixoff
;
8546 unsigned int qdotadroff
;
8547 unsigned int ldotadroff
;
8548 unsigned int shrimgcnt
;
8549 unsigned int shlstoff
;
8550 unsigned int codeadroff
;
8551 unsigned int lpfixoff
;
8552 unsigned int chgprtoff
;
8553 file_ptr f_off
= (file_ptr
) (eiaf_vbn
- 1) * VMS_BLOCK_SIZE
;
8555 if (bfd_seek (abfd
, f_off
, SEEK_SET
) != 0
8556 || (buf
= _bfd_malloc_and_read (abfd
, eiaf_size
, eiaf_size
)) == NULL
)
8558 fprintf (file
, _("cannot read EIHA\n"));
8561 eiaf
= (struct vms_eiaf
*)buf
;
8563 /* xgettext:c-format */
8564 _("Image activator fixup: (major: %u, minor: %u)\n"),
8565 (unsigned)bfd_getl32 (eiaf
->majorid
),
8566 (unsigned)bfd_getl32 (eiaf
->minorid
));
8567 /* xgettext:c-format */
8568 fprintf (file
, _(" iaflink : 0x%08x %08x\n"),
8569 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 0),
8570 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 4));
8571 /* xgettext:c-format */
8572 fprintf (file
, _(" fixuplnk: 0x%08x %08x\n"),
8573 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 0),
8574 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 4));
8575 fprintf (file
, _(" size : %u\n"),
8576 (unsigned)bfd_getl32 (eiaf
->size
));
8577 fprintf (file
, _(" flags: 0x%08x\n"),
8578 (unsigned)bfd_getl32 (eiaf
->flags
));
8579 qrelfixoff
= bfd_getl32 (eiaf
->qrelfixoff
);
8580 lrelfixoff
= bfd_getl32 (eiaf
->lrelfixoff
);
8581 /* xgettext:c-format */
8582 fprintf (file
, _(" qrelfixoff: %5u, lrelfixoff: %5u\n"),
8583 qrelfixoff
, lrelfixoff
);
8584 qdotadroff
= bfd_getl32 (eiaf
->qdotadroff
);
8585 ldotadroff
= bfd_getl32 (eiaf
->ldotadroff
);
8586 /* xgettext:c-format */
8587 fprintf (file
, _(" qdotadroff: %5u, ldotadroff: %5u\n"),
8588 qdotadroff
, ldotadroff
);
8589 codeadroff
= bfd_getl32 (eiaf
->codeadroff
);
8590 lpfixoff
= bfd_getl32 (eiaf
->lpfixoff
);
8591 /* xgettext:c-format */
8592 fprintf (file
, _(" codeadroff: %5u, lpfixoff : %5u\n"),
8593 codeadroff
, lpfixoff
);
8594 chgprtoff
= bfd_getl32 (eiaf
->chgprtoff
);
8595 fprintf (file
, _(" chgprtoff : %5u\n"), chgprtoff
);
8596 shrimgcnt
= bfd_getl32 (eiaf
->shrimgcnt
);
8597 shlstoff
= bfd_getl32 (eiaf
->shlstoff
);
8598 /* xgettext:c-format */
8599 fprintf (file
, _(" shlstoff : %5u, shrimgcnt : %5u\n"),
8600 shlstoff
, shrimgcnt
);
8601 /* xgettext:c-format */
8602 fprintf (file
, _(" shlextra : %5u, permctx : %5u\n"),
8603 (unsigned)bfd_getl32 (eiaf
->shlextra
),
8604 (unsigned)bfd_getl32 (eiaf
->permctx
));
8605 fprintf (file
, _(" base_va : 0x%08x\n"),
8606 (unsigned)bfd_getl32 (eiaf
->base_va
));
8607 fprintf (file
, _(" lppsbfixoff: %5u\n"),
8608 (unsigned)bfd_getl32 (eiaf
->lppsbfixoff
));
8614 fprintf (file
, _(" Shareable images:\n"));
8616 j
< shrimgcnt
&& shlstoff
<= eiaf_size
- sizeof (struct vms_shl
);
8617 j
++, shlstoff
+= sizeof (struct vms_shl
))
8619 struct vms_shl
*shl
= (struct vms_shl
*) (buf
+ shlstoff
);
8621 /* xgettext:c-format */
8622 _(" %u: size: %u, flags: 0x%02x, name: %.*s\n"),
8623 j
, shl
->size
, shl
->flags
,
8624 shl
->imgnam
[0], shl
->imgnam
+ 1);
8627 if (qrelfixoff
!= 0)
8629 fprintf (file
, _(" quad-word relocation fixups:\n"));
8630 evax_bfd_print_relocation_records (file
, buf
, eiaf_size
,
8633 if (lrelfixoff
!= 0)
8635 fprintf (file
, _(" long-word relocation fixups:\n"));
8636 evax_bfd_print_relocation_records (file
, buf
, eiaf_size
,
8639 if (qdotadroff
!= 0)
8641 fprintf (file
, _(" quad-word .address reference fixups:\n"));
8642 evax_bfd_print_address_fixups (file
, buf
, eiaf_size
, qdotadroff
);
8644 if (ldotadroff
!= 0)
8646 fprintf (file
, _(" long-word .address reference fixups:\n"));
8647 evax_bfd_print_address_fixups (file
, buf
, eiaf_size
, ldotadroff
);
8649 if (codeadroff
!= 0)
8651 fprintf (file
, _(" Code Address Reference Fixups:\n"));
8652 evax_bfd_print_reference_fixups (file
, buf
, eiaf_size
, codeadroff
);
8656 fprintf (file
, _(" Linkage Pairs Reference Fixups:\n"));
8657 evax_bfd_print_reference_fixups (file
, buf
, eiaf_size
, lpfixoff
);
8659 if (chgprtoff
&& chgprtoff
<= eiaf_size
- 4)
8661 unsigned int count
= (unsigned) bfd_getl32 (buf
+ chgprtoff
);
8664 fprintf (file
, _(" Change Protection (%u entries):\n"), count
);
8665 for (j
= 0, chgprtoff
+= 4;
8666 j
< count
&& chgprtoff
<= eiaf_size
- sizeof (struct vms_eicp
);
8667 j
++, chgprtoff
+= sizeof (struct vms_eicp
))
8669 struct vms_eicp
*eicp
= (struct vms_eicp
*) (buf
+ chgprtoff
);
8670 unsigned int prot
= bfd_getl32 (eicp
->newprt
);
8672 /* xgettext:c-format */
8673 _(" base: 0x%08x %08x, size: 0x%08x, prot: 0x%08x "),
8674 (unsigned) bfd_getl32 (eicp
->baseva
+ 4),
8675 (unsigned) bfd_getl32 (eicp
->baseva
+ 0),
8676 (unsigned) bfd_getl32 (eicp
->size
),
8677 (unsigned) bfd_getl32 (eicp
->newprt
));
8681 fprintf (file
, "NA");
8683 case PRT__C_RESERVED
:
8684 fprintf (file
, "RES");
8687 fprintf (file
, "KW");
8690 fprintf (file
, "KR");
8693 fprintf (file
, "UW");
8696 fprintf (file
, "EW");
8699 fprintf (file
, "ERKW");
8702 fprintf (file
, "ER");
8705 fprintf (file
, "SW");
8708 fprintf (file
, "SREW");
8711 fprintf (file
, "SRKW");
8714 fprintf (file
, "SR");
8717 fprintf (file
, "URSW");
8720 fprintf (file
, "UREW");
8723 fprintf (file
, "URKW");
8726 fprintf (file
, "UR");
8740 vms_bfd_print_private_bfd_data (bfd
*abfd
, void *ptr
)
8742 FILE *file
= (FILE *)ptr
;
8744 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
8745 evax_bfd_print_image (abfd
, file
);
8748 if (bfd_seek (abfd
, 0, SEEK_SET
))
8750 evax_bfd_print_eobj (abfd
, file
);
8757 /* Slurp ETIR/EDBG/ETBT VMS object records. */
8760 alpha_vms_read_sections_content (bfd
*abfd
, struct bfd_link_info
*info
)
8762 asection
*cur_section
;
8763 file_ptr cur_offset
;
8764 asection
*dst_section
;
8765 file_ptr dst_offset
;
8767 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
8773 dst_section
= PRIV (dst_section
);
8777 if (info
->strip
== strip_all
|| info
->strip
== strip_debugger
)
8779 /* Discard the DST section. */
8783 else if (dst_section
)
8785 dst_offset
= dst_section
->output_offset
;
8786 dst_section
= dst_section
->output_section
;
8795 type
= _bfd_vms_get_object_record (abfd
);
8798 vms_debug2 ((2, "next_record failed\n"));
8804 PRIV (image_section
) = cur_section
;
8805 PRIV (image_offset
) = cur_offset
;
8806 res
= _bfd_vms_slurp_etir (abfd
, info
);
8807 cur_section
= PRIV (image_section
);
8808 cur_offset
= PRIV (image_offset
);
8812 if (dst_section
== NULL
)
8814 PRIV (image_section
) = dst_section
;
8815 PRIV (image_offset
) = dst_offset
;
8816 res
= _bfd_vms_slurp_etir (abfd
, info
);
8817 dst_offset
= PRIV (image_offset
);
8826 vms_debug2 ((2, "slurp eobj type %d failed\n", type
));
8833 alpha_vms_sizeof_headers (bfd
*abfd ATTRIBUTE_UNUSED
,
8834 struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8839 /* Add a linkage pair fixup at address SECT + OFFSET to SHLIB. */
8842 alpha_vms_add_fixup_lp (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
8844 struct alpha_vms_shlib_el
*sl
;
8845 asection
*sect
= PRIV2 (src
, image_section
);
8846 file_ptr offset
= PRIV2 (src
, image_offset
);
8849 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8850 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8851 sl
->has_fixups
= true;
8852 p
= VEC_APPEND (sl
->lp
, bfd_vma
);
8855 *p
= sect
->output_section
->vma
+ sect
->output_offset
+ offset
;
8856 sect
->output_section
->flags
|= SEC_RELOC
;
8860 /* Add a code address fixup at address SECT + OFFSET to SHLIB. */
8863 alpha_vms_add_fixup_ca (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
8865 struct alpha_vms_shlib_el
*sl
;
8866 asection
*sect
= PRIV2 (src
, image_section
);
8867 file_ptr offset
= PRIV2 (src
, image_offset
);
8870 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8871 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8872 sl
->has_fixups
= true;
8873 p
= VEC_APPEND (sl
->ca
, bfd_vma
);
8876 *p
= sect
->output_section
->vma
+ sect
->output_offset
+ offset
;
8877 sect
->output_section
->flags
|= SEC_RELOC
;
8881 /* Add a quad word relocation fixup at address SECT + OFFSET to SHLIB. */
8884 alpha_vms_add_fixup_qr (struct bfd_link_info
*info
, bfd
*src
,
8885 bfd
*shlib
, bfd_vma vec
)
8887 struct alpha_vms_shlib_el
*sl
;
8888 struct alpha_vms_vma_ref
*r
;
8889 asection
*sect
= PRIV2 (src
, image_section
);
8890 file_ptr offset
= PRIV2 (src
, image_offset
);
8892 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8893 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8894 sl
->has_fixups
= true;
8895 r
= VEC_APPEND (sl
->qr
, struct alpha_vms_vma_ref
);
8898 r
->vma
= sect
->output_section
->vma
+ sect
->output_offset
+ offset
;
8900 sect
->output_section
->flags
|= SEC_RELOC
;
8905 alpha_vms_add_fixup_lr (struct bfd_link_info
*info ATTRIBUTE_UNUSED
,
8906 unsigned int shr ATTRIBUTE_UNUSED
,
8907 bfd_vma vec ATTRIBUTE_UNUSED
)
8909 /* Not yet supported. */
8913 /* Add relocation. FIXME: Not yet emitted. */
8916 alpha_vms_add_lw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8922 alpha_vms_add_qw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8927 static struct bfd_hash_entry
*
8928 alpha_vms_link_hash_newfunc (struct bfd_hash_entry
*entry
,
8929 struct bfd_hash_table
*table
,
8932 struct alpha_vms_link_hash_entry
*ret
=
8933 (struct alpha_vms_link_hash_entry
*) entry
;
8935 /* Allocate the structure if it has not already been allocated by a
8938 ret
= ((struct alpha_vms_link_hash_entry
*)
8939 bfd_hash_allocate (table
,
8940 sizeof (struct alpha_vms_link_hash_entry
)));
8944 /* Call the allocation method of the superclass. */
8945 ret
= ((struct alpha_vms_link_hash_entry
*)
8946 _bfd_link_hash_newfunc ((struct bfd_hash_entry
*) ret
,
8951 return (struct bfd_hash_entry
*) ret
;
8955 alpha_vms_bfd_link_hash_table_free (bfd
*abfd
)
8957 struct alpha_vms_link_hash_table
*t
;
8960 t
= (struct alpha_vms_link_hash_table
*) abfd
->link
.hash
;
8961 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8963 struct alpha_vms_shlib_el
*shlib
;
8965 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8966 free (&VEC_EL (shlib
->ca
, bfd_vma
, 0));
8967 free (&VEC_EL (shlib
->lp
, bfd_vma
, 0));
8968 free (&VEC_EL (shlib
->qr
, struct alpha_vms_vma_ref
, 0));
8970 free (&VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, 0));
8972 _bfd_generic_link_hash_table_free (abfd
);
8975 /* Create an Alpha/VMS link hash table. */
8977 static struct bfd_link_hash_table
*
8978 alpha_vms_bfd_link_hash_table_create (bfd
*abfd
)
8980 struct alpha_vms_link_hash_table
*ret
;
8981 size_t amt
= sizeof (struct alpha_vms_link_hash_table
);
8983 ret
= (struct alpha_vms_link_hash_table
*) bfd_malloc (amt
);
8986 if (!_bfd_link_hash_table_init (&ret
->root
, abfd
,
8987 alpha_vms_link_hash_newfunc
,
8988 sizeof (struct alpha_vms_link_hash_entry
)))
8994 VEC_INIT (ret
->shrlibs
);
8996 ret
->root
.hash_table_free
= alpha_vms_bfd_link_hash_table_free
;
9002 alpha_vms_link_add_object_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
9006 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
9008 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
9009 struct alpha_vms_link_hash_entry
*h
;
9010 struct bfd_link_hash_entry
*h_root
;
9013 if (!alpha_vms_convert_symbol (abfd
, e
, &sym
))
9016 if ((e
->flags
& EGSY__V_DEF
) && abfd
->selective_search
)
9018 /* In selective_search mode, only add definition that are
9020 h
= (struct alpha_vms_link_hash_entry
*)bfd_link_hash_lookup
9021 (info
->hash
, sym
.name
, false, false, false);
9022 if (h
== NULL
|| h
->root
.type
!= bfd_link_hash_undefined
)
9028 h_root
= (struct bfd_link_hash_entry
*) h
;
9029 if (!_bfd_generic_link_add_one_symbol (info
, abfd
, sym
.name
, sym
.flags
,
9030 sym
.section
, sym
.value
, NULL
,
9031 false, false, &h_root
))
9033 h
= (struct alpha_vms_link_hash_entry
*) h_root
;
9035 if ((e
->flags
& EGSY__V_DEF
)
9037 && abfd
->xvec
== info
->output_bfd
->xvec
)
9041 if (abfd
->flags
& DYNAMIC
)
9043 struct alpha_vms_shlib_el
*shlib
;
9045 /* We do not want to include any of the sections in a dynamic
9046 object in the output file. See comment in elflink.c. */
9047 bfd_section_list_clear (abfd
);
9049 shlib
= VEC_APPEND (alpha_vms_link_hash (info
)->shrlibs
,
9050 struct alpha_vms_shlib_el
);
9054 VEC_INIT (shlib
->ca
);
9055 VEC_INIT (shlib
->lp
);
9056 VEC_INIT (shlib
->qr
);
9057 PRIV (shr_index
) = VEC_COUNT (alpha_vms_link_hash (info
)->shrlibs
) - 1;
9064 alpha_vms_link_add_archive_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
9067 struct bfd_link_hash_entry
**pundef
;
9068 struct bfd_link_hash_entry
**next_pundef
;
9070 /* We only accept VMS libraries. */
9071 if (info
->output_bfd
->xvec
!= abfd
->xvec
)
9073 bfd_set_error (bfd_error_wrong_format
);
9077 /* The archive_pass field in the archive itself is used to
9078 initialize PASS, since we may search the same archive multiple
9080 pass
= ++abfd
->archive_pass
;
9082 /* Look through the list of undefined symbols. */
9083 for (pundef
= &info
->hash
->undefs
; *pundef
!= NULL
; pundef
= next_pundef
)
9085 struct bfd_link_hash_entry
*h
;
9091 next_pundef
= &(*pundef
)->u
.undef
.next
;
9093 /* When a symbol is defined, it is not necessarily removed from
9095 if (h
->type
!= bfd_link_hash_undefined
9096 && h
->type
!= bfd_link_hash_common
)
9098 /* Remove this entry from the list, for general cleanliness
9099 and because we are going to look through the list again
9100 if we search any more libraries. We can't remove the
9101 entry if it is the tail, because that would lose any
9102 entries we add to the list later on. */
9103 if (*pundef
!= info
->hash
->undefs_tail
)
9105 *pundef
= *next_pundef
;
9106 next_pundef
= pundef
;
9111 /* Look for this symbol in the archive hash table. */
9112 symidx
= _bfd_vms_lib_find_symbol (abfd
, h
->root
.string
);
9113 if (symidx
== BFD_NO_MORE_SYMBOLS
)
9115 /* Nothing in this slot. */
9119 element
= bfd_get_elt_at_index (abfd
, symidx
);
9120 if (element
== NULL
)
9123 if (element
->archive_pass
== -1 || element
->archive_pass
== pass
)
9125 /* Next symbol if this archive is wrong or already handled. */
9129 if (! bfd_check_format (element
, bfd_object
))
9131 element
->archive_pass
= -1;
9135 orig_element
= element
;
9136 if (bfd_is_thin_archive (abfd
))
9138 element
= _bfd_vms_lib_get_imagelib_file (element
);
9139 if (element
== NULL
|| !bfd_check_format (element
, bfd_object
))
9141 orig_element
->archive_pass
= -1;
9146 /* Unlike the generic linker, we know that this element provides
9147 a definition for an undefined symbol and we know that we want
9148 to include it. We don't need to check anything. */
9149 if (!(*info
->callbacks
9150 ->add_archive_element
) (info
, element
, h
->root
.string
, &element
))
9152 if (!alpha_vms_link_add_object_symbols (element
, info
))
9155 orig_element
->archive_pass
= pass
;
9162 alpha_vms_bfd_link_add_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
9164 switch (bfd_get_format (abfd
))
9167 vms_debug2 ((2, "vms_link_add_symbols for object %s\n",
9169 return alpha_vms_link_add_object_symbols (abfd
, info
);
9172 vms_debug2 ((2, "vms_link_add_symbols for archive %s\n",
9174 return alpha_vms_link_add_archive_symbols (abfd
, info
);
9177 bfd_set_error (bfd_error_wrong_format
);
9183 alpha_vms_build_fixups (struct bfd_link_info
*info
)
9185 struct alpha_vms_link_hash_table
*t
= alpha_vms_link_hash (info
);
9186 unsigned char *content
;
9188 unsigned int sz
= 0;
9189 unsigned int lp_sz
= 0;
9190 unsigned int ca_sz
= 0;
9191 unsigned int qr_sz
= 0;
9192 unsigned int shrimg_cnt
= 0;
9193 unsigned int chgprt_num
= 0;
9194 unsigned int chgprt_sz
= 0;
9195 struct vms_eiaf
*eiaf
;
9199 /* Shared libraries. */
9200 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
9202 struct alpha_vms_shlib_el
*shlib
;
9204 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
9206 if (!shlib
->has_fixups
)
9211 if (VEC_COUNT (shlib
->ca
) > 0)
9213 /* Header + entries. */
9215 ca_sz
+= VEC_COUNT (shlib
->ca
) * 4;
9217 if (VEC_COUNT (shlib
->lp
) > 0)
9219 /* Header + entries. */
9221 lp_sz
+= VEC_COUNT (shlib
->lp
) * 4;
9223 if (VEC_COUNT (shlib
->qr
) > 0)
9225 /* Header + entries. */
9227 qr_sz
+= VEC_COUNT (shlib
->qr
) * 8;
9238 /* Finish now if there is no content. */
9239 if (ca_sz
+ lp_sz
+ qr_sz
== 0)
9242 /* Add an eicp entry for the fixup itself. */
9244 for (sec
= info
->output_bfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
9246 /* This isect could be made RO or EXE after relocations are applied. */
9247 if ((sec
->flags
& SEC_RELOC
) != 0
9248 && (sec
->flags
& (SEC_CODE
| SEC_READONLY
)) != 0)
9251 chgprt_sz
= 4 + chgprt_num
* sizeof (struct vms_eicp
);
9253 /* Allocate section content (round-up size) */
9254 sz
= sizeof (struct vms_eiaf
) + shrimg_cnt
* sizeof (struct vms_shl
)
9255 + ca_sz
+ lp_sz
+ qr_sz
+ chgprt_sz
;
9256 sz
= (sz
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
9257 content
= bfd_zalloc (info
->output_bfd
, sz
);
9258 if (content
== NULL
)
9261 sec
= alpha_vms_link_hash (info
)->fixup
;
9262 sec
->contents
= content
;
9265 eiaf
= (struct vms_eiaf
*)content
;
9266 off
= sizeof (struct vms_eiaf
);
9267 bfd_putl32 (0, eiaf
->majorid
);
9268 bfd_putl32 (0, eiaf
->minorid
);
9269 bfd_putl32 (0, eiaf
->iaflink
);
9270 bfd_putl32 (0, eiaf
->fixuplnk
);
9271 bfd_putl32 (sizeof (struct vms_eiaf
), eiaf
->size
);
9272 bfd_putl32 (0, eiaf
->flags
);
9273 bfd_putl32 (0, eiaf
->qrelfixoff
);
9274 bfd_putl32 (0, eiaf
->lrelfixoff
);
9275 bfd_putl32 (0, eiaf
->qdotadroff
);
9276 bfd_putl32 (0, eiaf
->ldotadroff
);
9277 bfd_putl32 (0, eiaf
->codeadroff
);
9278 bfd_putl32 (0, eiaf
->lpfixoff
);
9279 bfd_putl32 (0, eiaf
->chgprtoff
);
9280 bfd_putl32 (shrimg_cnt
? off
: 0, eiaf
->shlstoff
);
9281 bfd_putl32 (shrimg_cnt
, eiaf
->shrimgcnt
);
9282 bfd_putl32 (0, eiaf
->shlextra
);
9283 bfd_putl32 (0, eiaf
->permctx
);
9284 bfd_putl32 (0, eiaf
->base_va
);
9285 bfd_putl32 (0, eiaf
->lppsbfixoff
);
9292 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
9294 struct alpha_vms_shlib_el
*shlib
;
9295 struct vms_shl
*shl
;
9297 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
9299 if (!shlib
->has_fixups
)
9302 /* Renumber shared images. */
9303 PRIV2 (shlib
->abfd
, shr_index
) = shrimg_cnt
++;
9305 shl
= (struct vms_shl
*)(content
+ off
);
9306 bfd_putl32 (0, shl
->baseva
);
9307 bfd_putl32 (0, shl
->shlptr
);
9308 bfd_putl32 (0, shl
->ident
);
9309 bfd_putl32 (0, shl
->permctx
);
9310 shl
->size
= sizeof (struct vms_shl
);
9311 bfd_putl16 (0, shl
->fill_1
);
9313 bfd_putl32 (0, shl
->icb
);
9314 shl
->imgnam
[0] = strlen (PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
));
9315 memcpy (shl
->imgnam
+ 1, PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
),
9318 off
+= sizeof (struct vms_shl
);
9324 bfd_putl32 (off
, eiaf
->codeadroff
);
9326 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
9328 struct alpha_vms_shlib_el
*shlib
;
9331 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
9333 if (VEC_COUNT (shlib
->ca
) == 0)
9336 bfd_putl32 (VEC_COUNT (shlib
->ca
), content
+ off
);
9337 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
9340 for (j
= 0; j
< VEC_COUNT (shlib
->ca
); j
++)
9342 bfd_putl32 (VEC_EL (shlib
->ca
, bfd_vma
, j
) - t
->base_addr
,
9348 bfd_putl32 (0, content
+ off
);
9349 bfd_putl32 (0, content
+ off
+ 4);
9356 bfd_putl32 (off
, eiaf
->lpfixoff
);
9358 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
9360 struct alpha_vms_shlib_el
*shlib
;
9363 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
9365 if (VEC_COUNT (shlib
->lp
) == 0)
9368 bfd_putl32 (VEC_COUNT (shlib
->lp
), content
+ off
);
9369 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
9372 for (j
= 0; j
< VEC_COUNT (shlib
->lp
); j
++)
9374 bfd_putl32 (VEC_EL (shlib
->lp
, bfd_vma
, j
) - t
->base_addr
,
9380 bfd_putl32 (0, content
+ off
);
9381 bfd_putl32 (0, content
+ off
+ 4);
9388 bfd_putl32 (off
, eiaf
->qdotadroff
);
9390 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
9392 struct alpha_vms_shlib_el
*shlib
;
9395 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
9397 if (VEC_COUNT (shlib
->qr
) == 0)
9400 bfd_putl32 (VEC_COUNT (shlib
->qr
), content
+ off
);
9401 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
9404 for (j
= 0; j
< VEC_COUNT (shlib
->qr
); j
++)
9406 struct alpha_vms_vma_ref
*r
;
9407 r
= &VEC_EL (shlib
->qr
, struct alpha_vms_vma_ref
, j
);
9408 bfd_putl32 (r
->vma
- t
->base_addr
, content
+ off
);
9409 bfd_putl32 (r
->ref
, content
+ off
+ 4);
9414 bfd_putl32 (0, content
+ off
);
9415 bfd_putl32 (0, content
+ off
+ 4);
9420 /* Write the change protection table. */
9421 bfd_putl32 (off
, eiaf
->chgprtoff
);
9422 bfd_putl32 (chgprt_num
, content
+ off
);
9425 for (sec
= info
->output_bfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
9427 struct vms_eicp
*eicp
;
9430 if ((sec
->flags
& SEC_LINKER_CREATED
) != 0 &&
9431 strcmp (sec
->name
, "$FIXUP$") == 0)
9433 else if ((sec
->flags
& SEC_RELOC
) != 0
9434 && (sec
->flags
& (SEC_CODE
| SEC_READONLY
)) != 0)
9439 eicp
= (struct vms_eicp
*)(content
+ off
);
9440 bfd_putl64 (sec
->vma
- t
->base_addr
, eicp
->baseva
);
9441 bfd_putl32 ((sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1),
9443 bfd_putl32 (prot
, eicp
->newprt
);
9444 off
+= sizeof (struct vms_eicp
);
9450 /* Called by bfd_hash_traverse to fill the symbol table.
9451 Return FALSE in case of failure. */
9454 alpha_vms_link_output_symbol (struct bfd_hash_entry
*bh
, void *infov
)
9456 struct bfd_link_hash_entry
*hc
= (struct bfd_link_hash_entry
*) bh
;
9457 struct bfd_link_info
*info
= (struct bfd_link_info
*)infov
;
9458 struct alpha_vms_link_hash_entry
*h
;
9459 struct vms_symbol_entry
*sym
;
9461 if (hc
->type
== bfd_link_hash_warning
)
9464 if (hc
->type
== bfd_link_hash_new
)
9467 h
= (struct alpha_vms_link_hash_entry
*) hc
;
9469 switch (h
->root
.type
)
9471 case bfd_link_hash_undefined
:
9473 case bfd_link_hash_new
:
9474 case bfd_link_hash_warning
:
9476 case bfd_link_hash_undefweak
:
9478 case bfd_link_hash_defined
:
9479 case bfd_link_hash_defweak
:
9481 asection
*sec
= h
->root
.u
.def
.section
;
9483 /* FIXME: this is certainly a symbol from a dynamic library. */
9484 if (bfd_is_abs_section (sec
))
9487 if (sec
->owner
->flags
& DYNAMIC
)
9491 case bfd_link_hash_common
:
9493 case bfd_link_hash_indirect
:
9497 /* Do not write not kept symbols. */
9498 if (info
->strip
== strip_some
9499 && bfd_hash_lookup (info
->keep_hash
, h
->root
.root
.string
,
9500 false, false) != NULL
)
9505 /* This symbol doesn't come from a VMS object. So we suppose it is
9507 int len
= strlen (h
->root
.root
.string
);
9509 sym
= (struct vms_symbol_entry
*)bfd_zalloc (info
->output_bfd
,
9510 sizeof (*sym
) + len
);
9514 memcpy (sym
->name
, h
->root
.root
.string
, len
);
9516 sym
->owner
= info
->output_bfd
;
9518 sym
->typ
= EGSD__C_SYMG
;
9520 sym
->flags
= EGSY__V_DEF
| EGSY__V_REL
;
9521 sym
->symbol_vector
= h
->root
.u
.def
.value
;
9522 sym
->section
= h
->root
.u
.def
.section
;
9523 sym
->value
= h
->root
.u
.def
.value
;
9528 if (!add_symbol_entry (info
->output_bfd
, sym
))
9535 alpha_vms_bfd_final_link (bfd
*abfd
, struct bfd_link_info
*info
)
9538 struct bfd_link_order
*p
;
9546 if (bfd_link_relocatable (info
))
9548 /* FIXME: we do not yet support relocatable link. It is not obvious
9549 how to do it for debug infos. */
9550 (*info
->callbacks
->einfo
)(_("%P: relocatable link is not supported\n"));
9554 abfd
->outsymbols
= NULL
;
9557 /* Mark all sections which will be included in the output file. */
9558 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9559 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
9560 if (p
->type
== bfd_indirect_link_order
)
9561 p
->u
.indirect
.section
->linker_mark
= true;
9564 /* Handle all the link order information for the sections. */
9565 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9567 printf ("For section %s (at 0x%08x, flags=0x%08x):\n",
9568 o
->name
, (unsigned)o
->vma
, (unsigned)o
->flags
);
9570 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
9572 printf (" at 0x%08x - 0x%08x: ",
9573 (unsigned)p
->offset
, (unsigned)(p
->offset
+ p
->size
- 1));
9576 case bfd_section_reloc_link_order
:
9577 case bfd_symbol_reloc_link_order
:
9578 printf (" section/symbol reloc\n");
9580 case bfd_indirect_link_order
:
9581 printf (" section %s of %s\n",
9582 p
->u
.indirect
.section
->name
,
9583 p
->u
.indirect
.section
->owner
->filename
);
9585 case bfd_data_link_order
:
9586 printf (" explicit data\n");
9589 printf (" *unknown* type %u\n", p
->type
);
9596 /* Generate the symbol table. */
9597 BFD_ASSERT (PRIV (syms
) == NULL
);
9598 if (info
->strip
!= strip_all
)
9599 bfd_hash_traverse (&info
->hash
->table
, alpha_vms_link_output_symbol
, info
);
9601 /* Find the entry point. */
9602 if (bfd_get_start_address (abfd
) == 0)
9604 bfd
*startbfd
= NULL
;
9606 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9608 /* Consider only VMS object files. */
9609 if (sub
->xvec
!= abfd
->xvec
)
9612 if (!PRIV2 (sub
, eom_data
).eom_has_transfer
)
9614 if ((PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
) && startbfd
)
9616 if (startbfd
!= NULL
9617 && !(PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
))
9619 (*info
->callbacks
->einfo
)
9620 /* xgettext:c-format */
9621 (_("%P: multiple entry points: in modules %pB and %pB\n"),
9630 unsigned int ps_idx
= PRIV2 (startbfd
, eom_data
).eom_l_psindx
;
9631 bfd_vma tfradr
= PRIV2 (startbfd
, eom_data
).eom_l_tfradr
;
9634 sec
= PRIV2 (startbfd
, sections
)[ps_idx
];
9636 bfd_set_start_address
9637 (abfd
, sec
->output_section
->vma
+ sec
->output_offset
+ tfradr
);
9641 /* Set transfer addresses. */
9644 struct bfd_link_hash_entry
*h
;
9647 PRIV (transfer_address
[i
++]) = 0xffffffff00000340ULL
; /* SYS$IMGACT */
9648 h
= bfd_link_hash_lookup (info
->hash
, "LIB$INITIALIZE", false, false, true);
9649 if (h
!= NULL
&& h
->type
== bfd_link_hash_defined
)
9650 PRIV (transfer_address
[i
++]) =
9651 alpha_vms_get_sym_value (h
->u
.def
.section
, h
->u
.def
.value
);
9652 PRIV (transfer_address
[i
++]) = bfd_get_start_address (abfd
);
9654 PRIV (transfer_address
[i
++]) = 0;
9657 /* Allocate contents.
9658 Also compute the virtual base address. */
9659 base_addr
= (bfd_vma
)-1;
9661 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9663 if (o
->flags
& SEC_HAS_CONTENTS
)
9665 o
->contents
= bfd_alloc (abfd
, o
->size
);
9666 if (o
->contents
== NULL
)
9669 if (o
->flags
& SEC_LOAD
)
9671 if (o
->vma
< base_addr
)
9673 if (o
->vma
+ o
->size
> last_addr
)
9674 last_addr
= o
->vma
+ o
->size
;
9676 /* Clear the RELOC flags. Currently we don't support incremental
9677 linking. We use the RELOC flag for computing the eicp entries. */
9678 o
->flags
&= ~SEC_RELOC
;
9681 /* Create the fixup section. */
9682 fixupsec
= bfd_make_section_anyway_with_flags
9683 (info
->output_bfd
, "$FIXUP$",
9684 SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
9685 if (fixupsec
== NULL
)
9687 last_addr
= (last_addr
+ 0xffff) & ~0xffff;
9688 fixupsec
->vma
= last_addr
;
9690 alpha_vms_link_hash (info
)->fixup
= fixupsec
;
9691 alpha_vms_link_hash (info
)->base_addr
= base_addr
;
9693 /* Create the DMT section, if necessary. */
9694 BFD_ASSERT (PRIV (dst_section
) == NULL
);
9695 dst
= bfd_get_section_by_name (abfd
, "$DST$");
9696 if (dst
!= NULL
&& dst
->size
== 0)
9700 PRIV (dst_section
) = dst
;
9701 dmt
= bfd_make_section_anyway_with_flags
9702 (info
->output_bfd
, "$DMT$",
9703 SEC_DEBUGGING
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
9710 /* Read all sections from the inputs. */
9711 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9713 if (sub
->flags
& DYNAMIC
)
9715 alpha_vms_create_eisd_for_shared (abfd
, sub
);
9719 if (!alpha_vms_read_sections_content (sub
, info
))
9723 /* Handle all the link order information for the sections.
9724 Note: past this point, it is not possible to create new sections. */
9725 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9727 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
9731 case bfd_section_reloc_link_order
:
9732 case bfd_symbol_reloc_link_order
:
9735 case bfd_indirect_link_order
:
9739 if (! _bfd_default_link_order (abfd
, info
, o
, p
))
9746 /* Compute fixups. */
9747 if (!alpha_vms_build_fixups (info
))
9750 /* Compute the DMT. */
9754 unsigned char *contents
= NULL
;
9756 /* In pass 1, compute the size. In pass 2, write the DMT contents. */
9757 for (pass
= 0; pass
< 2; pass
++)
9759 unsigned int off
= 0;
9761 /* For each object file (ie for each module). */
9762 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9765 struct vms_dmt_header
*dmth
= NULL
;
9766 unsigned int psect_count
;
9768 /* Skip this module if it has no DST. */
9769 sub_dst
= PRIV2 (sub
, dst_section
);
9770 if (sub_dst
== NULL
|| sub_dst
->size
== 0)
9775 /* Write the header. */
9776 dmth
= (struct vms_dmt_header
*)(contents
+ off
);
9777 bfd_putl32 (sub_dst
->output_offset
, dmth
->modbeg
);
9778 bfd_putl32 (sub_dst
->size
, dmth
->size
);
9781 off
+= sizeof (struct vms_dmt_header
);
9784 /* For each section (ie for each psect). */
9785 for (o
= sub
->sections
; o
!= NULL
; o
= o
->next
)
9787 /* Only consider interesting sections. */
9788 if (!(o
->flags
& SEC_ALLOC
))
9790 if (o
->flags
& SEC_LINKER_CREATED
)
9795 /* Write an entry. */
9796 struct vms_dmt_psect
*dmtp
;
9798 dmtp
= (struct vms_dmt_psect
*)(contents
+ off
);
9799 bfd_putl32 (o
->output_offset
+ o
->output_section
->vma
,
9801 bfd_putl32 (o
->size
, dmtp
->length
);
9804 off
+= sizeof (struct vms_dmt_psect
);
9807 bfd_putl32 (psect_count
, dmth
->psect_count
);
9812 contents
= bfd_zalloc (info
->output_bfd
, off
);
9813 if (contents
== NULL
)
9815 dmt
->contents
= contents
;
9820 BFD_ASSERT (off
== dmt
->size
);
9828 /* Read the contents of a section.
9829 buf points to a buffer of buf_size bytes to be filled with
9830 section data (starting at offset into section) */
9833 alpha_vms_get_section_contents (bfd
*abfd
, asection
*section
,
9834 void *buf
, file_ptr offset
,
9835 bfd_size_type count
)
9839 /* Image are easy. */
9840 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
9841 return _bfd_generic_get_section_contents (abfd
, section
,
9842 buf
, offset
, count
);
9845 if (offset
+ count
< count
9846 || offset
+ count
> section
->size
)
9848 bfd_set_error (bfd_error_invalid_operation
);
9852 /* If the section is already in memory, just copy it. */
9853 if (section
->flags
& SEC_IN_MEMORY
)
9855 BFD_ASSERT (section
->contents
!= NULL
);
9856 memcpy (buf
, section
->contents
+ offset
, count
);
9859 if (section
->size
== 0)
9862 /* Alloc in memory and read ETIRs. */
9863 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
9865 BFD_ASSERT (sec
->contents
== NULL
);
9867 if (sec
->size
!= 0 && (sec
->flags
& SEC_HAS_CONTENTS
))
9869 sec
->contents
= bfd_alloc (abfd
, sec
->size
);
9870 if (sec
->contents
== NULL
)
9874 if (!alpha_vms_read_sections_content (abfd
, NULL
))
9876 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
9878 sec
->flags
|= SEC_IN_MEMORY
;
9879 memcpy (buf
, section
->contents
+ offset
, count
);
9884 /* Set the format of a file being written. */
9887 alpha_vms_mkobject (bfd
* abfd
)
9889 const bfd_arch_info_type
*arch
;
9891 vms_debug2 ((1, "alpha_vms_mkobject (%p)\n", abfd
));
9893 if (!vms_initialize (abfd
))
9896 PRIV (recwr
.buf
) = bfd_alloc (abfd
, MAX_OUTREC_SIZE
);
9897 if (PRIV (recwr
.buf
) == NULL
)
9900 arch
= bfd_scan_arch ("alpha");
9904 bfd_set_error (bfd_error_wrong_format
);
9908 abfd
->arch_info
= arch
;
9915 /* Called when the BFD is being closed to do any necessary cleanup. */
9918 vms_close_and_cleanup (bfd
* abfd
)
9920 vms_debug2 ((1, "vms_close_and_cleanup (%p)\n", abfd
));
9922 if (abfd
== NULL
|| abfd
->tdata
.any
== NULL
)
9925 if (abfd
->format
== bfd_object
)
9927 alpha_vms_free_private (abfd
);
9930 if (abfd
->direction
== write_direction
)
9932 /* Last step on VMS is to convert the file to variable record length
9934 if (!bfd_cache_close (abfd
))
9936 if (!_bfd_vms_convert_to_var_unix_filename (abfd
->filename
))
9942 return _bfd_generic_close_and_cleanup (abfd
);
9945 /* Called when a new section is created. */
9948 vms_new_section_hook (bfd
* abfd
, asection
*section
)
9952 vms_debug2 ((1, "vms_new_section_hook (%p, [%u]%s)\n",
9953 abfd
, section
->index
, section
->name
));
9955 if (!bfd_set_section_alignment (section
, 0))
9958 vms_debug2 ((7, "%u: %s\n", section
->index
, section
->name
));
9960 amt
= sizeof (struct vms_section_data_struct
);
9961 section
->used_by_bfd
= bfd_zalloc (abfd
, amt
);
9962 if (section
->used_by_bfd
== NULL
)
9965 /* Create the section symbol. */
9966 return _bfd_generic_new_section_hook (abfd
, section
);
9969 /* Part 4.5, symbols. */
9971 /* Print symbol to file according to how. how is one of
9972 bfd_print_symbol_name just print the name
9973 bfd_print_symbol_more print more (???)
9974 bfd_print_symbol_all print all we know, which is not much right now :-). */
9977 vms_print_symbol (bfd
* abfd
,
9980 bfd_print_symbol_type how
)
9982 vms_debug2 ((1, "vms_print_symbol (%p, %p, %p, %d)\n",
9983 abfd
, file
, symbol
, how
));
9987 case bfd_print_symbol_name
:
9988 case bfd_print_symbol_more
:
9989 fprintf ((FILE *)file
," %s", symbol
->name
);
9992 case bfd_print_symbol_all
:
9994 const char *section_name
= symbol
->section
->name
;
9996 bfd_print_symbol_vandf (abfd
, file
, symbol
);
9998 fprintf ((FILE *) file
," %-8s %s", section_name
, symbol
->name
);
10004 /* Return information about symbol in ret.
10006 fill type, value and name
10009 B bss segment symbol
10011 D data segment symbol
10013 t a static function symbol
10014 T text segment symbol
10019 vms_get_symbol_info (bfd
* abfd ATTRIBUTE_UNUSED
,
10025 vms_debug2 ((1, "vms_get_symbol_info (%p, %p, %p)\n", abfd
, symbol
, ret
));
10027 sec
= symbol
->section
;
10034 else if (bfd_is_com_section (sec
))
10036 else if (bfd_is_abs_section (sec
))
10038 else if (bfd_is_und_section (sec
))
10040 else if (bfd_is_ind_section (sec
))
10042 else if ((symbol
->flags
& BSF_FUNCTION
)
10043 || (bfd_section_flags (sec
) & SEC_CODE
))
10045 else if (bfd_section_flags (sec
) & SEC_DATA
)
10047 else if (bfd_section_flags (sec
) & SEC_ALLOC
)
10052 if (ret
->type
!= 'U')
10053 ret
->value
= symbol
->value
+ symbol
->section
->vma
;
10056 ret
->name
= symbol
->name
;
10059 /* Return TRUE if the given symbol sym in the BFD abfd is
10060 a compiler generated local label, else return FALSE. */
10063 vms_bfd_is_local_label_name (bfd
* abfd ATTRIBUTE_UNUSED
,
10066 return name
[0] == '$';
10069 /* Part 4.7, writing an object file. */
10071 /* Sets the contents of the section section in BFD abfd to the data starting
10072 in memory at LOCATION. The data is written to the output section starting
10073 at offset offset for count bytes.
10075 Normally TRUE is returned, else FALSE. Possible error returns are:
10076 o bfd_error_no_contents - The output section does not have the
10077 SEC_HAS_CONTENTS attribute, so nothing can be written to it.
10078 o and some more too */
10081 _bfd_vms_set_section_contents (bfd
* abfd
,
10083 const void * location
,
10085 bfd_size_type count
)
10087 if (section
->contents
== NULL
)
10089 section
->contents
= bfd_alloc (abfd
, section
->size
);
10090 if (section
->contents
== NULL
)
10093 memcpy (section
->contents
+ offset
, location
, (size_t) count
);
10099 /* Set the architecture and machine type in BFD abfd to arch and mach.
10100 Find the correct pointer to a structure and insert it into the arch_info
10104 alpha_vms_set_arch_mach (bfd
*abfd
,
10105 enum bfd_architecture arch
, unsigned long mach
)
10107 if (arch
!= bfd_arch_alpha
10108 && arch
!= bfd_arch_unknown
)
10111 return bfd_default_set_arch_mach (abfd
, arch
, mach
);
10114 /* Set section VMS flags. Clear NO_FLAGS and set FLAGS. */
10117 bfd_vms_set_section_flags (bfd
*abfd ATTRIBUTE_UNUSED
,
10118 asection
*sec
, flagword no_flags
, flagword flags
)
10120 vms_section_data (sec
)->no_flags
= no_flags
;
10121 vms_section_data (sec
)->flags
= flags
;
10124 struct vms_private_data_struct
*
10125 bfd_vms_get_data (bfd
*abfd
)
10127 return (struct vms_private_data_struct
*)abfd
->tdata
.any
;
10130 #define vms_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
10131 #define vms_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
10132 #define vms_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data
10133 #define vms_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
10134 #define vms_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
10135 #define vms_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
10137 /* Symbols table. */
10138 #define alpha_vms_make_empty_symbol _bfd_generic_make_empty_symbol
10139 #define alpha_vms_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false
10140 #define alpha_vms_print_symbol vms_print_symbol
10141 #define alpha_vms_get_symbol_info vms_get_symbol_info
10142 #define alpha_vms_get_symbol_version_string \
10143 _bfd_nosymbols_get_symbol_version_string
10145 #define alpha_vms_read_minisymbols _bfd_generic_read_minisymbols
10146 #define alpha_vms_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
10147 #define alpha_vms_get_lineno _bfd_nosymbols_get_lineno
10148 #define alpha_vms_find_inliner_info _bfd_nosymbols_find_inliner_info
10149 #define alpha_vms_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
10150 #define alpha_vms_find_nearest_line _bfd_vms_find_nearest_line
10151 #define alpha_vms_find_nearest_line_with_alt \
10152 _bfd_nosymbols_find_nearest_line_with_alt
10153 #define alpha_vms_find_line _bfd_nosymbols_find_line
10154 #define alpha_vms_bfd_is_local_label_name vms_bfd_is_local_label_name
10156 /* Generic table. */
10157 #define alpha_vms_close_and_cleanup vms_close_and_cleanup
10158 #define alpha_vms_bfd_free_cached_info _bfd_bool_bfd_true
10159 #define alpha_vms_new_section_hook vms_new_section_hook
10160 #define alpha_vms_set_section_contents _bfd_vms_set_section_contents
10161 #define alpha_vms_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
10163 #define alpha_vms_bfd_get_relocated_section_contents \
10164 bfd_generic_get_relocated_section_contents
10166 #define alpha_vms_bfd_relax_section bfd_generic_relax_section
10167 #define alpha_vms_bfd_gc_sections bfd_generic_gc_sections
10168 #define alpha_vms_bfd_lookup_section_flags bfd_generic_lookup_section_flags
10169 #define alpha_vms_bfd_merge_sections bfd_generic_merge_sections
10170 #define alpha_vms_bfd_is_group_section bfd_generic_is_group_section
10171 #define alpha_vms_bfd_group_name bfd_generic_group_name
10172 #define alpha_vms_bfd_discard_group bfd_generic_discard_group
10173 #define alpha_vms_section_already_linked \
10174 _bfd_generic_section_already_linked
10176 #define alpha_vms_bfd_define_common_symbol bfd_generic_define_common_symbol
10177 #define alpha_vms_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
10178 #define alpha_vms_bfd_define_start_stop bfd_generic_define_start_stop
10179 #define alpha_vms_bfd_link_just_syms _bfd_generic_link_just_syms
10180 #define alpha_vms_bfd_copy_link_hash_symbol_type \
10181 _bfd_generic_copy_link_hash_symbol_type
10183 #define alpha_vms_bfd_link_split_section _bfd_generic_link_split_section
10185 #define alpha_vms_get_dynamic_symtab_upper_bound \
10186 _bfd_nodynamic_get_dynamic_symtab_upper_bound
10187 #define alpha_vms_canonicalize_dynamic_symtab \
10188 _bfd_nodynamic_canonicalize_dynamic_symtab
10189 #define alpha_vms_get_dynamic_reloc_upper_bound \
10190 _bfd_nodynamic_get_dynamic_reloc_upper_bound
10191 #define alpha_vms_canonicalize_dynamic_reloc \
10192 _bfd_nodynamic_canonicalize_dynamic_reloc
10193 #define alpha_vms_bfd_link_check_relocs _bfd_generic_link_check_relocs
10195 const bfd_target alpha_vms_vec
=
10197 "vms-alpha", /* Name. */
10198 bfd_target_evax_flavour
,
10199 BFD_ENDIAN_LITTLE
, /* Data byte order is little. */
10200 BFD_ENDIAN_LITTLE
, /* Header byte order is little. */
10202 (HAS_RELOC
| EXEC_P
| HAS_LINENO
| HAS_DEBUG
| HAS_SYMS
| HAS_LOCALS
10203 | WP_TEXT
| D_PAGED
), /* Object flags. */
10204 (SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
10205 | SEC_READONLY
| SEC_CODE
| SEC_DATA
10206 | SEC_HAS_CONTENTS
| SEC_IN_MEMORY
), /* Sect flags. */
10207 0, /* symbol_leading_char. */
10208 ' ', /* ar_pad_char. */
10209 15, /* ar_max_namelen. */
10210 0, /* match priority. */
10211 TARGET_KEEP_UNUSED_SECTION_SYMBOLS
, /* keep unused section symbols. */
10212 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
10213 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
10214 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
10215 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
10216 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
10217 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
10219 { /* bfd_check_format. */
10221 alpha_vms_object_p
,
10222 _bfd_vms_lib_alpha_archive_p
,
10225 { /* bfd_set_format. */
10226 _bfd_bool_bfd_false_error
,
10227 alpha_vms_mkobject
,
10228 _bfd_vms_lib_alpha_mkarchive
,
10229 _bfd_bool_bfd_false_error
10231 { /* bfd_write_contents. */
10232 _bfd_bool_bfd_false_error
,
10233 alpha_vms_write_object_contents
,
10234 _bfd_vms_lib_write_archive_contents
,
10235 _bfd_bool_bfd_false_error
10238 BFD_JUMP_TABLE_GENERIC (alpha_vms
),
10239 BFD_JUMP_TABLE_COPY (vms
),
10240 BFD_JUMP_TABLE_CORE (_bfd_nocore
),
10241 BFD_JUMP_TABLE_ARCHIVE (_bfd_vms_lib
),
10242 BFD_JUMP_TABLE_SYMBOLS (alpha_vms
),
10243 BFD_JUMP_TABLE_RELOCS (alpha_vms
),
10244 BFD_JUMP_TABLE_WRITE (alpha_vms
),
10245 BFD_JUMP_TABLE_LINK (alpha_vms
),
10246 BFD_JUMP_TABLE_DYNAMIC (alpha_vms
),