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_bread (PRIV (recrd
.buf
), 1, abfd
) != 1)
807 bfd_set_error (bfd_error_file_truncated
);
812 /* Read the record header */
813 if (bfd_bread (PRIV (recrd
.buf
), test_len
, abfd
) != test_len
)
815 bfd_set_error (bfd_error_file_truncated
);
819 /* Reset the record pointer. */
820 PRIV (recrd
.rec
) = PRIV (recrd
.buf
);
821 maybe_adjust_record_pointer_for_object (abfd
);
823 if (vms_get_remaining_object_record (abfd
, test_len
) <= 0)
826 type
= bfd_getl16 (PRIV (recrd
.rec
));
828 vms_debug2 ((8, "_bfd_vms_get_obj_record: rec %p, size %d, type %d\n",
829 PRIV (recrd
.rec
), PRIV (recrd
.rec_size
), type
));
834 /* Implement step #2 of the object record reading procedure.
835 Return the size of the record or 0 on failure. */
838 vms_get_remaining_object_record (bfd
*abfd
, unsigned int read_so_far
)
840 unsigned int to_read
;
842 vms_debug2 ((8, "vms_get_remaining_obj_record\n"));
844 /* Extract record size. */
845 PRIV (recrd
.rec_size
) = bfd_getl16 (PRIV (recrd
.rec
) + 2);
847 if (PRIV (recrd
.rec_size
) == 0)
849 bfd_set_error (bfd_error_file_truncated
);
853 /* That's what the linker manual says. */
854 if (PRIV (recrd
.rec_size
) > EOBJ__C_MAXRECSIZ
)
856 bfd_set_error (bfd_error_file_truncated
);
860 /* Take into account object adjustment. */
861 to_read
= PRIV (recrd
.rec_size
);
862 if (PRIV (recrd
.file_format
) == FF_FOREIGN
)
863 to_read
+= VMS_OBJECT_ADJUSTMENT
;
865 /* Adjust the buffer. */
866 if (to_read
> PRIV (recrd
.buf_size
))
869 = (unsigned char *) bfd_realloc_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_bread (PRIV (recrd
.buf
) + read_so_far
, to_read
, abfd
) != to_read
)
885 bfd_set_error (bfd_error_file_truncated
);
889 /* Reset the record pointer. */
890 PRIV (recrd
.rec
) = PRIV (recrd
.buf
);
891 maybe_adjust_record_pointer_for_object (abfd
);
893 vms_debug2 ((8, "vms_get_remaining_obj_record: size %d\n",
894 PRIV (recrd
.rec_size
)));
896 return PRIV (recrd
.rec_size
);
899 /* Read and process emh record.
900 Return TRUE on success, FALSE on error. */
903 _bfd_vms_slurp_ehdr (bfd
*abfd
)
906 unsigned char *vms_rec
;
910 vms_rec
= PRIV (recrd
.rec
);
911 /* PR 17512: file: 62736583. */
912 end
= PRIV (recrd
.buf
) + PRIV (recrd
.buf_size
);
914 vms_debug2 ((2, "HDR/EMH\n"));
916 subtype
= bfd_getl16 (vms_rec
+ 4);
918 vms_debug2 ((3, "subtype %d\n", subtype
));
924 if (vms_rec
+ 21 >= end
)
926 PRIV (hdr_data
).hdr_b_strlvl
= vms_rec
[6];
927 PRIV (hdr_data
).hdr_l_arch1
= bfd_getl32 (vms_rec
+ 8);
928 PRIV (hdr_data
).hdr_l_arch2
= bfd_getl32 (vms_rec
+ 12);
929 PRIV (hdr_data
).hdr_l_recsiz
= bfd_getl32 (vms_rec
+ 16);
930 if ((vms_rec
+ 20 + vms_rec
[20] + 1) >= end
)
932 PRIV (hdr_data
).hdr_t_name
933 = _bfd_vms_save_counted_string (abfd
, vms_rec
+ 20, vms_rec
[20]);
934 ptr
= vms_rec
+ 20 + vms_rec
[20] + 1;
935 if ((ptr
+ *ptr
+ 1) >= end
)
937 PRIV (hdr_data
).hdr_t_version
938 = _bfd_vms_save_counted_string (abfd
, ptr
, *ptr
);
942 PRIV (hdr_data
).hdr_t_date
943 = _bfd_vms_save_sized_string (abfd
, ptr
, 17);
947 if (vms_rec
+ PRIV (recrd
.rec_size
- 6) > end
)
949 PRIV (hdr_data
).hdr_c_lnm
950 = _bfd_vms_save_sized_string (abfd
, vms_rec
, PRIV (recrd
.rec_size
- 6));
954 if (vms_rec
+ PRIV (recrd
.rec_size
- 6) > end
)
956 PRIV (hdr_data
).hdr_c_src
957 = _bfd_vms_save_sized_string (abfd
, vms_rec
, PRIV (recrd
.rec_size
- 6));
961 if (vms_rec
+ PRIV (recrd
.rec_size
- 6) > end
)
963 PRIV (hdr_data
).hdr_c_ttl
964 = _bfd_vms_save_sized_string (abfd
, vms_rec
, PRIV (recrd
.rec_size
- 6));
974 bfd_set_error (bfd_error_wrong_format
);
981 /* Typical sections for evax object files. */
983 #define EVAX_ABS_NAME "$ABS$"
984 #define EVAX_CODE_NAME "$CODE$"
985 #define EVAX_LINK_NAME "$LINK$"
986 #define EVAX_DATA_NAME "$DATA$"
987 #define EVAX_BSS_NAME "$BSS$"
988 #define EVAX_READONLYADDR_NAME "$READONLY_ADDR$"
989 #define EVAX_READONLY_NAME "$READONLY$"
990 #define EVAX_LITERAL_NAME "$LITERAL$"
991 #define EVAX_LITERALS_NAME "$LITERALS"
992 #define EVAX_COMMON_NAME "$COMMON$"
993 #define EVAX_LOCAL_NAME "$LOCAL$"
995 struct sec_flags_struct
997 const char *name
; /* Name of section. */
999 flagword flags_always
; /* Flags we set always. */
1001 flagword flags_hassize
; /* Flags we set if the section has a size > 0. */
1004 /* These flags are deccrtl/vaxcrtl (openVMS 6.2 Alpha) compatible. */
1006 static const struct sec_flags_struct evax_section_flags
[] =
1014 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_EXE
,
1015 SEC_CODE
| SEC_READONLY
,
1016 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_EXE
,
1017 SEC_CODE
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1018 { EVAX_LITERAL_NAME
,
1019 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
| EGPS__V_NOMOD
,
1020 SEC_DATA
| SEC_READONLY
,
1021 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
,
1022 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1024 EGPS__V_REL
| EGPS__V_RD
,
1025 SEC_DATA
| SEC_READONLY
,
1026 EGPS__V_REL
| EGPS__V_RD
,
1027 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1029 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
,
1031 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1032 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1034 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
,
1036 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
,
1038 { EVAX_READONLYADDR_NAME
,
1039 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_RD
,
1040 SEC_DATA
| SEC_READONLY
,
1041 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_RD
,
1042 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1043 { EVAX_READONLY_NAME
,
1044 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
| EGPS__V_NOMOD
,
1045 SEC_DATA
| SEC_READONLY
,
1046 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
,
1047 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1049 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1051 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1052 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1053 { EVAX_LITERALS_NAME
,
1054 EGPS__V_PIC
| EGPS__V_OVR
,
1055 SEC_DATA
| SEC_READONLY
,
1056 EGPS__V_PIC
| EGPS__V_OVR
,
1057 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1059 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1061 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1062 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
}
1065 /* Retrieve BFD section flags by name and size. */
1068 vms_secflag_by_name (const struct sec_flags_struct
*section_flags
,
1074 while (section_flags
[i
].name
!= NULL
)
1076 if (strcmp (name
, section_flags
[i
].name
) == 0)
1079 return section_flags
[i
].flags_hassize
;
1081 return section_flags
[i
].flags_always
;
1086 return section_flags
[i
].flags_hassize
;
1087 return section_flags
[i
].flags_always
;
1090 /* Retrieve VMS section flags by name and size. */
1093 vms_esecflag_by_name (const struct sec_flags_struct
*section_flags
,
1099 while (section_flags
[i
].name
!= NULL
)
1101 if (strcmp (name
, section_flags
[i
].name
) == 0)
1104 return section_flags
[i
].vflags_hassize
;
1106 return section_flags
[i
].vflags_always
;
1111 return section_flags
[i
].vflags_hassize
;
1112 return section_flags
[i
].vflags_always
;
1115 /* Add SYM to the symbol table of ABFD.
1116 Return FALSE in case of error. */
1119 add_symbol_entry (bfd
*abfd
, struct vms_symbol_entry
*sym
)
1121 if (PRIV (gsd_sym_count
) >= PRIV (max_sym_count
))
1123 if (PRIV (max_sym_count
) == 0)
1125 PRIV (max_sym_count
) = 128;
1126 PRIV (syms
) = bfd_malloc
1127 (PRIV (max_sym_count
) * sizeof (struct vms_symbol_entry
*));
1131 PRIV (max_sym_count
) *= 2;
1132 PRIV (syms
) = bfd_realloc_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
, (file_ptr
) 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
, (file_ptr
) 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 _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 _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 _bfd_vms_output_end (abfd
, recwr
);
3016 vector_grow1 (struct vector_type
*vec
, size_t elsz
)
3018 if (vec
->nbr_el
>= vec
->max_el
)
3020 if (vec
->max_el
== 0)
3023 vec
->els
= bfd_malloc (vec
->max_el
* elsz
);
3028 if (vec
->max_el
> -1u / 2)
3030 bfd_set_error (bfd_error_file_too_big
);
3034 if (_bfd_mul_overflow (vec
->max_el
, elsz
, &amt
))
3036 bfd_set_error (bfd_error_file_too_big
);
3039 vec
->els
= bfd_realloc_or_free (vec
->els
, amt
);
3042 if (vec
->els
== NULL
)
3044 return (char *) vec
->els
+ elsz
* vec
->nbr_el
++;
3047 /* Bump ABFD file position to next block. */
3050 alpha_vms_file_position_block (bfd
*abfd
)
3053 PRIV (file_pos
) += VMS_BLOCK_SIZE
- 1;
3054 PRIV (file_pos
) -= (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
3057 /* Convert from internal structure SRC to external structure DST. */
3060 alpha_vms_swap_eisd_out (struct vms_internal_eisd_map
*src
,
3061 struct vms_eisd
*dst
)
3063 bfd_putl32 (src
->u
.eisd
.majorid
, dst
->majorid
);
3064 bfd_putl32 (src
->u
.eisd
.minorid
, dst
->minorid
);
3065 bfd_putl32 (src
->u
.eisd
.eisdsize
, dst
->eisdsize
);
3066 if (src
->u
.eisd
.eisdsize
<= EISD__K_LENEND
)
3068 bfd_putl32 (src
->u
.eisd
.secsize
, dst
->secsize
);
3069 bfd_putl64 (src
->u
.eisd
.virt_addr
, dst
->virt_addr
);
3070 bfd_putl32 (src
->u
.eisd
.flags
, dst
->flags
);
3071 bfd_putl32 (src
->u
.eisd
.vbn
, dst
->vbn
);
3072 dst
->pfc
= src
->u
.eisd
.pfc
;
3073 dst
->matchctl
= src
->u
.eisd
.matchctl
;
3074 dst
->type
= src
->u
.eisd
.type
;
3076 if (src
->u
.eisd
.flags
& EISD__M_GBL
)
3078 bfd_putl32 (src
->u
.gbl_eisd
.ident
, dst
->ident
);
3079 memcpy (dst
->gblnam
, src
->u
.gbl_eisd
.gblnam
,
3080 src
->u
.gbl_eisd
.gblnam
[0] + 1);
3084 /* Append EISD to the list of extra eisd for ABFD. */
3087 alpha_vms_append_extra_eisd (bfd
*abfd
, struct vms_internal_eisd_map
*eisd
)
3090 if (PRIV (gbl_eisd_head
) == NULL
)
3091 PRIV (gbl_eisd_head
) = eisd
;
3093 PRIV (gbl_eisd_tail
)->next
= eisd
;
3094 PRIV (gbl_eisd_tail
) = eisd
;
3097 /* Create an EISD for shared image SHRIMG.
3098 Return FALSE in case of error. */
3101 alpha_vms_create_eisd_for_shared (bfd
*abfd
, bfd
*shrimg
)
3103 struct vms_internal_eisd_map
*eisd
;
3106 namlen
= strlen (PRIV2 (shrimg
, hdr_data
.hdr_t_name
));
3107 if (namlen
+ 5 > EISD__K_GBLNAMLEN
)
3113 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
3117 /* Fill the fields. */
3118 eisd
->u
.gbl_eisd
.common
.majorid
= EISD__K_MAJORID
;
3119 eisd
->u
.gbl_eisd
.common
.minorid
= EISD__K_MINORID
;
3120 eisd
->u
.gbl_eisd
.common
.eisdsize
= (EISD__K_LEN
+ 4 + namlen
+ 5 + 3) & ~3;
3121 eisd
->u
.gbl_eisd
.common
.secsize
= VMS_BLOCK_SIZE
; /* Must not be 0. */
3122 eisd
->u
.gbl_eisd
.common
.virt_addr
= 0;
3123 eisd
->u
.gbl_eisd
.common
.flags
= EISD__M_GBL
;
3124 eisd
->u
.gbl_eisd
.common
.vbn
= 0;
3125 eisd
->u
.gbl_eisd
.common
.pfc
= 0;
3126 eisd
->u
.gbl_eisd
.common
.matchctl
= PRIV2 (shrimg
, matchctl
);
3127 eisd
->u
.gbl_eisd
.common
.type
= EISD__K_SHRPIC
;
3129 eisd
->u
.gbl_eisd
.ident
= PRIV2 (shrimg
, ident
);
3130 eisd
->u
.gbl_eisd
.gblnam
[0] = namlen
+ 4;
3131 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1, PRIV2 (shrimg
, hdr_data
.hdr_t_name
),
3133 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1 + namlen
, "_001", 4);
3135 /* Append it to the list. */
3136 alpha_vms_append_extra_eisd (abfd
, eisd
);
3141 /* Create an EISD for section SEC.
3142 Return FALSE in case of failure. */
3145 alpha_vms_create_eisd_for_section (bfd
*abfd
, asection
*sec
)
3147 struct vms_internal_eisd_map
*eisd
;
3149 /* Only for allocating section. */
3150 if (!(sec
->flags
& SEC_ALLOC
))
3153 BFD_ASSERT (vms_section_data (sec
)->eisd
== NULL
);
3154 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
3157 vms_section_data (sec
)->eisd
= eisd
;
3159 /* Fill the fields. */
3160 eisd
->u
.eisd
.majorid
= EISD__K_MAJORID
;
3161 eisd
->u
.eisd
.minorid
= EISD__K_MINORID
;
3162 eisd
->u
.eisd
.eisdsize
= EISD__K_LEN
;
3163 eisd
->u
.eisd
.secsize
=
3164 (sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
3165 eisd
->u
.eisd
.virt_addr
= sec
->vma
;
3166 eisd
->u
.eisd
.flags
= 0;
3167 eisd
->u
.eisd
.vbn
= 0; /* To be later defined. */
3168 eisd
->u
.eisd
.pfc
= 0; /* Default. */
3169 eisd
->u
.eisd
.matchctl
= EISD__K_MATALL
;
3170 eisd
->u
.eisd
.type
= EISD__K_NORMAL
;
3172 if (sec
->flags
& SEC_CODE
)
3173 eisd
->u
.eisd
.flags
|= EISD__M_EXE
;
3174 if (!(sec
->flags
& SEC_READONLY
))
3175 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
3177 /* If relocations or fixup will be applied, make this isect writeable. */
3178 if (sec
->flags
& SEC_RELOC
)
3179 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
3181 if (!(sec
->flags
& SEC_HAS_CONTENTS
))
3183 eisd
->u
.eisd
.flags
|= EISD__M_DZRO
;
3184 eisd
->u
.eisd
.flags
&= ~EISD__M_CRF
;
3186 if (sec
->flags
& SEC_LINKER_CREATED
)
3188 if (strcmp (sec
->name
, "$FIXUP$") == 0)
3189 eisd
->u
.eisd
.flags
|= EISD__M_FIXUPVEC
;
3192 /* Append it to the list. */
3194 if (PRIV (eisd_head
) == NULL
)
3195 PRIV (eisd_head
) = eisd
;
3197 PRIV (eisd_tail
)->next
= eisd
;
3198 PRIV (eisd_tail
) = eisd
;
3203 /* Layout executable ABFD and write it to the disk.
3204 Return FALSE in case of failure. */
3207 alpha_vms_write_exec (bfd
*abfd
)
3209 struct vms_eihd eihd
;
3210 struct vms_eiha
*eiha
;
3211 struct vms_eihi
*eihi
;
3212 struct vms_eihs
*eihs
= NULL
;
3214 struct vms_internal_eisd_map
*first_eisd
;
3215 struct vms_internal_eisd_map
*eisd
;
3218 file_ptr gst_filepos
= 0;
3219 unsigned int lnkflags
= 0;
3221 /* Build the EIHD. */
3222 PRIV (file_pos
) = EIHD__C_LENGTH
;
3224 memset (&eihd
, 0, sizeof (eihd
));
3225 memset (eihd
.fill_2
, 0xff, sizeof (eihd
.fill_2
));
3227 bfd_putl32 (EIHD__K_MAJORID
, eihd
.majorid
);
3228 bfd_putl32 (EIHD__K_MINORID
, eihd
.minorid
);
3230 bfd_putl32 (sizeof (eihd
), eihd
.size
);
3231 bfd_putl32 (0, eihd
.isdoff
);
3232 bfd_putl32 (0, eihd
.activoff
);
3233 bfd_putl32 (0, eihd
.symdbgoff
);
3234 bfd_putl32 (0, eihd
.imgidoff
);
3235 bfd_putl32 (0, eihd
.patchoff
);
3236 bfd_putl64 (0, eihd
.iafva
);
3237 bfd_putl32 (0, eihd
.version_array_off
);
3239 bfd_putl32 (EIHD__K_EXE
, eihd
.imgtype
);
3240 bfd_putl32 (0, eihd
.subtype
);
3242 bfd_putl32 (0, eihd
.imgiocnt
);
3243 bfd_putl32 (-1, eihd
.privreqs
);
3244 bfd_putl32 (-1, eihd
.privreqs
+ 4);
3246 bfd_putl32 ((sizeof (eihd
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
3248 bfd_putl32 (0, eihd
.ident
);
3249 bfd_putl32 (0, eihd
.sysver
);
3252 bfd_putl32 (0, eihd
.symvect_size
);
3253 bfd_putl32 (16, eihd
.virt_mem_block_size
);
3254 bfd_putl32 (0, eihd
.ext_fixup_off
);
3255 bfd_putl32 (0, eihd
.noopt_psect_off
);
3256 bfd_putl16 (-1, eihd
.alias
);
3259 eiha
= (struct vms_eiha
*)((char *) &eihd
+ PRIV (file_pos
));
3260 bfd_putl32 (PRIV (file_pos
), eihd
.activoff
);
3261 PRIV (file_pos
) += sizeof (struct vms_eiha
);
3263 bfd_putl32 (sizeof (struct vms_eiha
), eiha
->size
);
3264 bfd_putl32 (0, eiha
->spare
);
3265 bfd_putl64 (PRIV (transfer_address
[0]), eiha
->tfradr1
);
3266 bfd_putl64 (PRIV (transfer_address
[1]), eiha
->tfradr2
);
3267 bfd_putl64 (PRIV (transfer_address
[2]), eiha
->tfradr3
);
3268 bfd_putl64 (PRIV (transfer_address
[3]), eiha
->tfradr4
);
3269 bfd_putl64 (0, eiha
->inishr
);
3272 eihi
= (struct vms_eihi
*)((char *) &eihd
+ PRIV (file_pos
));
3273 bfd_putl32 (PRIV (file_pos
), eihd
.imgidoff
);
3274 PRIV (file_pos
) += sizeof (struct vms_eihi
);
3276 bfd_putl32 (EIHI__K_MAJORID
, eihi
->majorid
);
3277 bfd_putl32 (EIHI__K_MINORID
, eihi
->minorid
);
3282 /* Set module name. */
3283 module
= vms_get_module_name (bfd_get_filename (abfd
), true);
3284 len
= strlen (module
);
3285 if (len
> sizeof (eihi
->imgnam
) - 1)
3286 len
= sizeof (eihi
->imgnam
) - 1;
3287 eihi
->imgnam
[0] = len
;
3288 memcpy (eihi
->imgnam
+ 1, module
, len
);
3296 vms_get_time (&hi
, &lo
);
3297 bfd_putl32 (lo
, eihi
->linktime
+ 0);
3298 bfd_putl32 (hi
, eihi
->linktime
+ 4);
3301 eihi
->linkid
[0] = 0;
3302 eihi
->imgbid
[0] = 0;
3305 dst
= PRIV (dst_section
);
3306 dmt
= bfd_get_section_by_name (abfd
, "$DMT$");
3307 if (dst
!= NULL
&& dst
->size
!= 0)
3309 eihs
= (struct vms_eihs
*)((char *) &eihd
+ PRIV (file_pos
));
3310 bfd_putl32 (PRIV (file_pos
), eihd
.symdbgoff
);
3311 PRIV (file_pos
) += sizeof (struct vms_eihs
);
3313 bfd_putl32 (EIHS__K_MAJORID
, eihs
->majorid
);
3314 bfd_putl32 (EIHS__K_MINORID
, eihs
->minorid
);
3315 bfd_putl32 (0, eihs
->dstvbn
);
3316 bfd_putl32 (0, eihs
->dstsize
);
3317 bfd_putl32 (0, eihs
->gstvbn
);
3318 bfd_putl32 (0, eihs
->gstsize
);
3319 bfd_putl32 (0, eihs
->dmtvbn
);
3320 bfd_putl32 (0, eihs
->dmtsize
);
3323 /* One EISD per section. */
3324 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3326 if (!alpha_vms_create_eisd_for_section (abfd
, sec
))
3330 /* Merge section EIDS which extra ones. */
3331 if (PRIV (eisd_tail
))
3332 PRIV (eisd_tail
)->next
= PRIV (gbl_eisd_head
);
3334 PRIV (eisd_head
) = PRIV (gbl_eisd_head
);
3335 if (PRIV (gbl_eisd_tail
))
3336 PRIV (eisd_tail
) = PRIV (gbl_eisd_tail
);
3338 first_eisd
= PRIV (eisd_head
);
3340 /* Add end of eisd. */
3343 eisd
= bfd_zalloc (abfd
, sizeof (*eisd
));
3346 eisd
->u
.eisd
.majorid
= 0;
3347 eisd
->u
.eisd
.minorid
= 0;
3348 eisd
->u
.eisd
.eisdsize
= 0;
3349 alpha_vms_append_extra_eisd (abfd
, eisd
);
3352 /* Place EISD in the file. */
3353 for (eisd
= first_eisd
; eisd
; eisd
= eisd
->next
)
3355 file_ptr room
= VMS_BLOCK_SIZE
- (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
3357 /* First block is a little bit special: there is a word at the end. */
3358 if (PRIV (file_pos
) < VMS_BLOCK_SIZE
&& room
> 2)
3360 if (room
< eisd
->u
.eisd
.eisdsize
+ EISD__K_LENEND
)
3361 alpha_vms_file_position_block (abfd
);
3363 eisd
->file_pos
= PRIV (file_pos
);
3364 PRIV (file_pos
) += eisd
->u
.eisd
.eisdsize
;
3366 if (eisd
->u
.eisd
.flags
& EISD__M_FIXUPVEC
)
3367 bfd_putl64 (eisd
->u
.eisd
.virt_addr
, eihd
.iafva
);
3370 if (first_eisd
!= NULL
)
3372 bfd_putl32 (first_eisd
->file_pos
, eihd
.isdoff
);
3373 /* Real size of end of eisd marker. */
3374 PRIV (file_pos
) += EISD__K_LENEND
;
3377 bfd_putl32 (PRIV (file_pos
), eihd
.size
);
3378 bfd_putl32 ((PRIV (file_pos
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
3381 /* Place sections. */
3382 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3384 if (!(sec
->flags
& SEC_HAS_CONTENTS
)
3385 || sec
->contents
== NULL
)
3388 eisd
= vms_section_data (sec
)->eisd
;
3390 /* Align on a block. */
3391 alpha_vms_file_position_block (abfd
);
3392 sec
->filepos
= PRIV (file_pos
);
3395 eisd
->u
.eisd
.vbn
= (sec
->filepos
/ VMS_BLOCK_SIZE
) + 1;
3397 PRIV (file_pos
) += sec
->size
;
3401 if (eihs
!= NULL
&& dst
!= NULL
)
3403 bfd_putl32 ((dst
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dstvbn
);
3404 bfd_putl32 (dst
->size
, eihs
->dstsize
);
3408 lnkflags
|= EIHD__M_DBGDMT
;
3409 bfd_putl32 ((dmt
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dmtvbn
);
3410 bfd_putl32 (dmt
->size
, eihs
->dmtsize
);
3412 if (PRIV (gsd_sym_count
) != 0)
3414 alpha_vms_file_position_block (abfd
);
3415 gst_filepos
= PRIV (file_pos
);
3416 bfd_putl32 ((gst_filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->gstvbn
);
3417 bfd_putl32 ((PRIV (gsd_sym_count
) + 4) / 5 + 4, eihs
->gstsize
);
3421 /* Write EISD in hdr. */
3422 for (eisd
= first_eisd
; eisd
&& eisd
->file_pos
< VMS_BLOCK_SIZE
;
3424 alpha_vms_swap_eisd_out
3425 (eisd
, (struct vms_eisd
*)((char *)&eihd
+ eisd
->file_pos
));
3427 /* Write first block. */
3428 bfd_putl32 (lnkflags
, eihd
.lnkflags
);
3429 if (bfd_bwrite (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
3432 /* Write remaining eisd. */
3435 unsigned char blk
[VMS_BLOCK_SIZE
];
3436 struct vms_internal_eisd_map
*next_eisd
;
3438 memset (blk
, 0xff, sizeof (blk
));
3439 while (eisd
!= NULL
)
3441 alpha_vms_swap_eisd_out
3443 (struct vms_eisd
*)(blk
+ (eisd
->file_pos
% VMS_BLOCK_SIZE
)));
3445 next_eisd
= eisd
->next
;
3446 if (next_eisd
== NULL
3447 || (next_eisd
->file_pos
/ VMS_BLOCK_SIZE
3448 != eisd
->file_pos
/ VMS_BLOCK_SIZE
))
3450 if (bfd_bwrite (blk
, sizeof (blk
), abfd
) != sizeof (blk
))
3453 memset (blk
, 0xff, sizeof (blk
));
3459 /* Write sections. */
3460 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3462 unsigned char blk
[VMS_BLOCK_SIZE
];
3465 if (sec
->size
== 0 || !(sec
->flags
& SEC_HAS_CONTENTS
)
3466 || sec
->contents
== NULL
)
3468 if (bfd_bwrite (sec
->contents
, sec
->size
, abfd
) != sec
->size
)
3472 len
= VMS_BLOCK_SIZE
- sec
->size
% VMS_BLOCK_SIZE
;
3473 if (len
!= VMS_BLOCK_SIZE
)
3475 memset (blk
, 0, len
);
3476 if (bfd_bwrite (blk
, len
, abfd
) != len
)
3482 if (gst_filepos
!= 0)
3484 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3487 _bfd_vms_write_emh (abfd
);
3488 _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 _bfd_vms_output_end (abfd
, recwr
);
3501 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
3503 struct vms_symbol_entry
*sym
= PRIV (syms
)[i
];
3509 _bfd_vms_output_alignment (recwr
, 8);
3510 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3511 _bfd_vms_output_long (recwr
, 0);
3513 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYMG
);
3514 _bfd_vms_output_short (recwr
, 0); /* Data type, alignment. */
3515 _bfd_vms_output_short (recwr
, sym
->flags
);
3517 if (sym
->code_section
)
3518 ep
= alpha_vms_get_sym_value (sym
->code_section
, sym
->code_value
);
3521 BFD_ASSERT (sym
->code_value
== 0);
3524 val
= alpha_vms_get_sym_value (sym
->section
, sym
->value
);
3525 _bfd_vms_output_quad
3526 (recwr
, sym
->typ
== EGSD__C_SYMG
? sym
->symbol_vector
: val
);
3527 _bfd_vms_output_quad (recwr
, ep
);
3528 _bfd_vms_output_quad (recwr
, val
);
3529 _bfd_vms_output_long (recwr
, 0);
3530 _bfd_vms_output_counted (recwr
, sym
->name
);
3531 _bfd_vms_output_end_subrec (recwr
);
3533 _bfd_vms_output_end (abfd
, recwr
);
3536 _bfd_vms_output_end (abfd
, recwr
);
3538 if (!_bfd_vms_write_eeom (abfd
))
3546 /* Write section and symbol directory of bfd abfd. Return FALSE on error. */
3549 _bfd_vms_write_egsd (bfd
*abfd
)
3553 unsigned int symnum
;
3555 flagword new_flags
, old_flags
;
3556 int abs_section_index
= -1;
3557 unsigned int target_index
= 0;
3558 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3560 vms_debug2 ((2, "vms_write_egsd\n"));
3562 /* Egsd is quadword aligned. */
3563 _bfd_vms_output_alignment (recwr
, 8);
3565 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3566 _bfd_vms_output_long (recwr
, 0);
3568 /* Number sections. */
3569 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3571 if (section
->flags
& SEC_DEBUGGING
)
3573 if (!strcmp (section
->name
, ".vmsdebug"))
3575 section
->flags
|= SEC_DEBUGGING
;
3578 section
->target_index
= target_index
++;
3581 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3583 vms_debug2 ((3, "Section #%d %s, %d bytes\n",
3584 section
->target_index
, section
->name
, (int)section
->size
));
3586 /* Don't write out the VMS debug info section since it is in the
3587 ETBT and EDBG sections in etir. */
3588 if (section
->flags
& SEC_DEBUGGING
)
3591 /* 13 bytes egsd, max 31 chars name -> should be 44 bytes. */
3592 if (_bfd_vms_output_check (recwr
, 64) < 0)
3594 _bfd_vms_output_end (abfd
, recwr
);
3595 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3596 _bfd_vms_output_long (recwr
, 0);
3599 /* Don't know if this is necessary for the linker but for now it keeps
3600 vms_slurp_gsd happy. */
3601 sname
= section
->name
;
3604 /* Remove leading dot. */
3606 if ((*sname
== 't') && (strcmp (sname
, "text") == 0))
3607 sname
= EVAX_CODE_NAME
;
3608 else if ((*sname
== 'd') && (strcmp (sname
, "data") == 0))
3609 sname
= EVAX_DATA_NAME
;
3610 else if ((*sname
== 'b') && (strcmp (sname
, "bss") == 0))
3611 sname
= EVAX_BSS_NAME
;
3612 else if ((*sname
== 'l') && (strcmp (sname
, "link") == 0))
3613 sname
= EVAX_LINK_NAME
;
3614 else if ((*sname
== 'r') && (strcmp (sname
, "rdata") == 0))
3615 sname
= EVAX_READONLY_NAME
;
3616 else if ((*sname
== 'l') && (strcmp (sname
, "literal") == 0))
3617 sname
= EVAX_LITERAL_NAME
;
3618 else if ((*sname
== 'l') && (strcmp (sname
, "literals") == 0))
3619 sname
= EVAX_LITERALS_NAME
;
3620 else if ((*sname
== 'c') && (strcmp (sname
, "comm") == 0))
3621 sname
= EVAX_COMMON_NAME
;
3622 else if ((*sname
== 'l') && (strcmp (sname
, "lcomm") == 0))
3623 sname
= EVAX_LOCAL_NAME
;
3626 if (bfd_is_com_section (section
))
3627 new_flags
= (EGPS__V_OVR
| EGPS__V_REL
| EGPS__V_GBL
| EGPS__V_RD
3628 | EGPS__V_WRT
| EGPS__V_NOMOD
| EGPS__V_COM
);
3630 new_flags
= vms_esecflag_by_name (evax_section_flags
, sname
,
3633 /* Modify them as directed. */
3634 if (section
->flags
& SEC_READONLY
)
3635 new_flags
&= ~EGPS__V_WRT
;
3637 new_flags
&= ~vms_section_data (section
)->no_flags
;
3638 new_flags
|= vms_section_data (section
)->flags
;
3640 vms_debug2 ((3, "sec flags %x\n", section
->flags
));
3641 vms_debug2 ((3, "new_flags %x, _raw_size %lu\n",
3642 new_flags
, (unsigned long)section
->size
));
3644 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3645 _bfd_vms_output_short (recwr
, section
->alignment_power
& 0xff);
3646 _bfd_vms_output_short (recwr
, new_flags
);
3647 _bfd_vms_output_long (recwr
, (unsigned long) section
->size
);
3648 _bfd_vms_output_counted (recwr
, sname
);
3649 _bfd_vms_output_end_subrec (recwr
);
3651 /* If the section is an obsolute one, remind its index as it will be
3652 used later for absolute symbols. */
3653 if ((new_flags
& EGPS__V_REL
) == 0 && abs_section_index
< 0)
3654 abs_section_index
= section
->target_index
;
3657 /* Output symbols. */
3658 vms_debug2 ((3, "%d symbols found\n", abfd
->symcount
));
3660 bfd_set_start_address (abfd
, (bfd_vma
) -1);
3662 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3664 symbol
= abfd
->outsymbols
[symnum
];
3665 old_flags
= symbol
->flags
;
3667 /* Work-around a missing feature: consider __main as the main entry
3669 if (symbol
->name
[0] == '_' && strcmp (symbol
->name
, "__main") == 0)
3670 bfd_set_start_address (abfd
, (bfd_vma
)symbol
->value
);
3672 /* Only put in the GSD the global and the undefined symbols. */
3673 if (old_flags
& BSF_FILE
)
3676 if ((old_flags
& BSF_GLOBAL
) == 0 && !bfd_is_und_section (symbol
->section
))
3678 /* If the LIB$INITIIALIZE section is present, add a reference to
3679 LIB$INITIALIZE symbol. FIXME: this should be done explicitely
3680 in the assembly file. */
3681 if (!((old_flags
& BSF_SECTION_SYM
) != 0
3682 && strcmp (symbol
->section
->name
, "LIB$INITIALIZE") == 0))
3686 /* 13 bytes egsd, max 64 chars name -> should be 77 bytes. Add 16 more
3687 bytes for a possible ABS section. */
3688 if (_bfd_vms_output_check (recwr
, 80 + 16) < 0)
3690 _bfd_vms_output_end (abfd
, recwr
);
3691 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3692 _bfd_vms_output_long (recwr
, 0);
3695 if ((old_flags
& BSF_GLOBAL
) != 0
3696 && bfd_is_abs_section (symbol
->section
)
3697 && abs_section_index
<= 0)
3699 /* Create an absolute section if none was defined. It is highly
3700 unlikely that the name $ABS$ clashes with a user defined
3701 non-absolute section name. */
3702 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3703 _bfd_vms_output_short (recwr
, 4);
3704 _bfd_vms_output_short (recwr
, EGPS__V_SHR
);
3705 _bfd_vms_output_long (recwr
, 0);
3706 _bfd_vms_output_counted (recwr
, "$ABS$");
3707 _bfd_vms_output_end_subrec (recwr
);
3709 abs_section_index
= target_index
++;
3712 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYM
);
3714 /* Data type, alignment. */
3715 _bfd_vms_output_short (recwr
, 0);
3719 if (old_flags
& BSF_WEAK
)
3720 new_flags
|= EGSY__V_WEAK
;
3721 if (bfd_is_com_section (symbol
->section
)) /* .comm */
3722 new_flags
|= (EGSY__V_WEAK
| EGSY__V_COMM
);
3724 if (old_flags
& BSF_FUNCTION
)
3726 new_flags
|= EGSY__V_NORM
;
3727 new_flags
|= EGSY__V_REL
;
3729 if (old_flags
& BSF_GLOBAL
)
3731 new_flags
|= EGSY__V_DEF
;
3732 if (!bfd_is_abs_section (symbol
->section
))
3733 new_flags
|= EGSY__V_REL
;
3735 _bfd_vms_output_short (recwr
, new_flags
);
3737 if (old_flags
& BSF_GLOBAL
)
3739 /* Symbol definition. */
3740 bfd_vma code_address
= 0;
3741 unsigned long ca_psindx
= 0;
3742 unsigned long psindx
;
3744 if ((old_flags
& BSF_FUNCTION
) && symbol
->udata
.p
!= NULL
)
3749 ((struct evax_private_udata_struct
*)symbol
->udata
.p
)->enbsym
;
3750 code_address
= sym
->value
;
3751 ca_psindx
= sym
->section
->target_index
;
3753 if (bfd_is_abs_section (symbol
->section
))
3754 psindx
= abs_section_index
;
3756 psindx
= symbol
->section
->target_index
;
3758 _bfd_vms_output_quad (recwr
, symbol
->value
);
3759 _bfd_vms_output_quad (recwr
, code_address
);
3760 _bfd_vms_output_long (recwr
, ca_psindx
);
3761 _bfd_vms_output_long (recwr
, psindx
);
3763 _bfd_vms_output_counted (recwr
, symbol
->name
);
3765 _bfd_vms_output_end_subrec (recwr
);
3768 _bfd_vms_output_alignment (recwr
, 8);
3769 _bfd_vms_output_end (abfd
, recwr
);
3774 /* Write object header for bfd abfd. Return FALSE on error. */
3777 _bfd_vms_write_ehdr (bfd
*abfd
)
3780 unsigned int symnum
;
3781 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3783 vms_debug2 ((2, "vms_write_ehdr (%p)\n", abfd
));
3785 _bfd_vms_output_alignment (recwr
, 2);
3787 _bfd_vms_write_emh (abfd
);
3788 _bfd_vms_write_lmn (abfd
, "GNU AS");
3791 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3792 _bfd_vms_output_short (recwr
, EMH__C_SRC
);
3794 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3796 symbol
= abfd
->outsymbols
[symnum
];
3798 if (symbol
->flags
& BSF_FILE
)
3800 _bfd_vms_output_dump (recwr
, (unsigned char *) symbol
->name
,
3801 (int) strlen (symbol
->name
));
3806 if (symnum
== abfd
->symcount
)
3807 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("noname"));
3809 _bfd_vms_output_end (abfd
, recwr
);
3812 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3813 _bfd_vms_output_short (recwr
, EMH__C_TTL
);
3814 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("TTL"));
3815 _bfd_vms_output_end (abfd
, recwr
);
3818 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3819 _bfd_vms_output_short (recwr
, EMH__C_CPR
);
3820 _bfd_vms_output_dump (recwr
,
3821 (unsigned char *)"GNU BFD ported by Klaus Kämpf 1994-1996",
3823 _bfd_vms_output_end (abfd
, recwr
);
3828 /* Part 4.6, relocations. */
3831 /* WRITE ETIR SECTION
3833 This is still under construction and therefore not documented. */
3835 /* Close the etir/etbt record. */
3838 end_etir_record (bfd
* abfd
)
3840 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3842 _bfd_vms_output_end (abfd
, recwr
);
3846 start_etir_or_etbt_record (bfd
*abfd
, asection
*section
, bfd_vma offset
)
3848 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3850 if (section
->flags
& SEC_DEBUGGING
)
3852 _bfd_vms_output_begin (recwr
, EOBJ__C_ETBT
);
3856 /* Push start offset. */
3857 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3858 _bfd_vms_output_long (recwr
, (unsigned long) 0);
3859 _bfd_vms_output_end_subrec (recwr
);
3862 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_DFLOC
);
3863 _bfd_vms_output_end_subrec (recwr
);
3868 _bfd_vms_output_begin (recwr
, EOBJ__C_ETIR
);
3872 /* Push start offset. */
3873 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3874 _bfd_vms_output_long (recwr
, (unsigned long) section
->target_index
);
3875 _bfd_vms_output_quad (recwr
, offset
);
3876 _bfd_vms_output_end_subrec (recwr
);
3878 /* Start = pop (). */
3879 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_SETRB
);
3880 _bfd_vms_output_end_subrec (recwr
);
3885 /* Output a STO_IMM command for SSIZE bytes of data from CPR at virtual
3886 address VADDR in section specified by SEC_INDEX and NAME. */
3889 sto_imm (bfd
*abfd
, asection
*section
,
3890 bfd_size_type ssize
, unsigned char *cptr
, bfd_vma vaddr
)
3893 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3896 _bfd_vms_debug (8, "sto_imm %d bytes\n", (int) ssize
);
3897 _bfd_hexdump (9, cptr
, (int) ssize
, (int) vaddr
);
3902 /* Try all the rest. */
3905 if (_bfd_vms_output_check (recwr
, size
) < 0)
3907 /* Doesn't fit, split ! */
3908 end_etir_record (abfd
);
3910 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3912 size
= _bfd_vms_output_check (recwr
, 0); /* get max size */
3913 if (size
> ssize
) /* more than what's left ? */
3917 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_IMM
);
3918 _bfd_vms_output_long (recwr
, (unsigned long) (size
));
3919 _bfd_vms_output_dump (recwr
, cptr
, size
);
3920 _bfd_vms_output_end_subrec (recwr
);
3923 _bfd_vms_debug (10, "dumped %d bytes\n", (int) size
);
3924 _bfd_hexdump (10, cptr
, (int) size
, (int) vaddr
);
3934 etir_output_check (bfd
*abfd
, asection
*section
, bfd_vma vaddr
, int checklen
)
3936 if (_bfd_vms_output_check (&PRIV (recwr
), checklen
) < 0)
3938 /* Not enough room in this record. Close it and open a new one. */
3939 end_etir_record (abfd
);
3940 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3944 /* Return whether RELOC must be deferred till the end. */
3947 defer_reloc_p (arelent
*reloc
)
3949 switch (reloc
->howto
->type
)
3962 /* Write section contents for bfd abfd. Return FALSE on error. */
3965 _bfd_vms_write_etir (bfd
* abfd
, int objtype ATTRIBUTE_UNUSED
)
3968 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3970 vms_debug2 ((2, "vms_write_tir (%p, %d)\n", abfd
, objtype
));
3972 _bfd_vms_output_alignment (recwr
, 4);
3974 PRIV (vms_linkage_index
) = 0;
3976 for (section
= abfd
->sections
; section
; section
= section
->next
)
3978 vms_debug2 ((4, "writing %d. section '%s' (%d bytes)\n",
3979 section
->target_index
, section
->name
, (int) (section
->size
)));
3981 if (!(section
->flags
& SEC_HAS_CONTENTS
)
3982 || bfd_is_com_section (section
))
3985 if (!section
->contents
)
3987 bfd_set_error (bfd_error_no_contents
);
3991 start_etir_or_etbt_record (abfd
, section
, 0);
3993 if (section
->flags
& SEC_RELOC
)
3995 bfd_vma curr_addr
= 0;
3996 unsigned char *curr_data
= section
->contents
;
3998 int pass2_needed
= 0;
3999 int pass2_in_progress
= 0;
4002 if (section
->reloc_count
== 0)
4004 (_("SEC_RELOC with no relocs in section %pA"), section
);
4009 int i
= section
->reloc_count
;
4010 arelent
**rptr
= section
->orelocation
;
4011 _bfd_vms_debug (4, "%d relocations:\n", i
);
4014 _bfd_vms_debug (4, "sym %s in sec %s, value %08lx, "
4015 "addr %08lx, off %08lx, len %d: %s\n",
4016 (*(*rptr
)->sym_ptr_ptr
)->name
,
4017 (*(*rptr
)->sym_ptr_ptr
)->section
->name
,
4018 (long) (*(*rptr
)->sym_ptr_ptr
)->value
,
4019 (unsigned long)(*rptr
)->address
,
4020 (unsigned long)(*rptr
)->addend
,
4021 bfd_get_reloc_size ((*rptr
)->howto
),
4022 ( *rptr
)->howto
->name
);
4029 for (irel
= 0; irel
< section
->reloc_count
; irel
++)
4031 struct evax_private_udata_struct
*udata
;
4032 arelent
*rptr
= section
->orelocation
[irel
];
4033 bfd_vma addr
= rptr
->address
;
4034 asymbol
*sym
= *rptr
->sym_ptr_ptr
;
4035 asection
*sec
= sym
->section
;
4036 bool defer
= defer_reloc_p (rptr
);
4039 if (pass2_in_progress
)
4041 /* Non-deferred relocs have already been output. */
4047 /* Deferred relocs must be output at the very end. */
4054 /* Regular relocs are intertwined with binary data. */
4055 if (curr_addr
> addr
)
4056 _bfd_error_handler (_("size error in section %pA"),
4058 size
= addr
- curr_addr
;
4059 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
4064 size
= bfd_get_reloc_size (rptr
->howto
);
4066 switch (rptr
->howto
->type
)
4068 case ALPHA_R_IGNORE
:
4071 case ALPHA_R_REFLONG
:
4072 if (bfd_is_und_section (sym
->section
))
4074 bfd_vma addend
= rptr
->addend
;
4075 slen
= strlen ((char *) sym
->name
);
4076 etir_output_check (abfd
, section
, curr_addr
, slen
);
4079 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
4080 _bfd_vms_output_counted (recwr
, sym
->name
);
4081 _bfd_vms_output_end_subrec (recwr
);
4082 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
4083 _bfd_vms_output_long (recwr
, (unsigned long) addend
);
4084 _bfd_vms_output_end_subrec (recwr
);
4085 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
4086 _bfd_vms_output_end_subrec (recwr
);
4087 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
4088 _bfd_vms_output_end_subrec (recwr
);
4092 _bfd_vms_output_begin_subrec
4093 (recwr
, ETIR__C_STO_GBL_LW
);
4094 _bfd_vms_output_counted (recwr
, sym
->name
);
4095 _bfd_vms_output_end_subrec (recwr
);
4098 else if (bfd_is_abs_section (sym
->section
))
4100 etir_output_check (abfd
, section
, curr_addr
, 16);
4101 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
4102 _bfd_vms_output_long (recwr
, (unsigned long) sym
->value
);
4103 _bfd_vms_output_end_subrec (recwr
);
4104 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
4105 _bfd_vms_output_end_subrec (recwr
);
4109 etir_output_check (abfd
, section
, curr_addr
, 32);
4110 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
4111 _bfd_vms_output_long (recwr
,
4112 (unsigned long) sec
->target_index
);
4113 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
4114 _bfd_vms_output_end_subrec (recwr
);
4115 /* ??? Table B-8 of the OpenVMS Linker Utilily Manual
4116 says that we should have a ETIR__C_STO_OFF here.
4117 But the relocation would not be BFD_RELOC_32 then.
4118 This case is very likely unreachable. */
4119 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
4120 _bfd_vms_output_end_subrec (recwr
);
4124 case ALPHA_R_REFQUAD
:
4125 if (bfd_is_und_section (sym
->section
))
4127 bfd_vma addend
= rptr
->addend
;
4128 slen
= strlen ((char *) sym
->name
);
4129 etir_output_check (abfd
, section
, curr_addr
, slen
);
4132 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
4133 _bfd_vms_output_counted (recwr
, sym
->name
);
4134 _bfd_vms_output_end_subrec (recwr
);
4135 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
4136 _bfd_vms_output_quad (recwr
, addend
);
4137 _bfd_vms_output_end_subrec (recwr
);
4138 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
4139 _bfd_vms_output_end_subrec (recwr
);
4140 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
4141 _bfd_vms_output_end_subrec (recwr
);
4145 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_GBL
);
4146 _bfd_vms_output_counted (recwr
, sym
->name
);
4147 _bfd_vms_output_end_subrec (recwr
);
4150 else if (bfd_is_abs_section (sym
->section
))
4152 etir_output_check (abfd
, section
, curr_addr
, 16);
4153 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
4154 _bfd_vms_output_quad (recwr
, sym
->value
);
4155 _bfd_vms_output_end_subrec (recwr
);
4156 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
4157 _bfd_vms_output_end_subrec (recwr
);
4161 etir_output_check (abfd
, section
, curr_addr
, 32);
4162 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
4163 _bfd_vms_output_long (recwr
,
4164 (unsigned long) sec
->target_index
);
4165 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
4166 _bfd_vms_output_end_subrec (recwr
);
4167 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_OFF
);
4168 _bfd_vms_output_end_subrec (recwr
);
4173 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
4176 case ALPHA_R_LINKAGE
:
4178 etir_output_check (abfd
, section
, curr_addr
, 64);
4179 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LP_PSB
);
4180 _bfd_vms_output_long
4181 (recwr
, (unsigned long) rptr
->addend
);
4182 if (rptr
->addend
> PRIV (vms_linkage_index
))
4183 PRIV (vms_linkage_index
) = rptr
->addend
;
4184 _bfd_vms_output_counted (recwr
, sym
->name
);
4185 _bfd_vms_output_byte (recwr
, 0);
4186 _bfd_vms_output_end_subrec (recwr
);
4189 case ALPHA_R_CODEADDR
:
4190 slen
= strlen ((char *) sym
->name
);
4191 etir_output_check (abfd
, section
, curr_addr
, slen
);
4192 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_CA
);
4193 _bfd_vms_output_counted (recwr
, sym
->name
);
4194 _bfd_vms_output_end_subrec (recwr
);
4199 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4200 etir_output_check (abfd
, section
, curr_addr
,
4201 32 + 1 + strlen (udata
->origname
));
4202 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_NOP_GBL
);
4203 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
4204 _bfd_vms_output_long
4205 (recwr
, (unsigned long) section
->target_index
);
4206 _bfd_vms_output_quad (recwr
, rptr
->address
);
4207 _bfd_vms_output_long (recwr
, (unsigned long) 0x47ff041f);
4208 _bfd_vms_output_long
4209 (recwr
, (unsigned long) section
->target_index
);
4210 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4211 _bfd_vms_output_counted (recwr
, udata
->origname
);
4212 _bfd_vms_output_end_subrec (recwr
);
4216 _bfd_error_handler (_("spurious ALPHA_R_BSR reloc"));
4221 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4222 etir_output_check (abfd
, section
, curr_addr
,
4223 32 + 1 + strlen (udata
->origname
));
4224 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LDA_GBL
);
4225 _bfd_vms_output_long
4226 (recwr
, (unsigned long) udata
->lkindex
+ 1);
4227 _bfd_vms_output_long
4228 (recwr
, (unsigned long) section
->target_index
);
4229 _bfd_vms_output_quad (recwr
, rptr
->address
);
4230 _bfd_vms_output_long (recwr
, (unsigned long) 0x237B0000);
4231 _bfd_vms_output_long
4232 (recwr
, (unsigned long) udata
->bsym
->section
->target_index
);
4233 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4234 _bfd_vms_output_counted (recwr
, udata
->origname
);
4235 _bfd_vms_output_end_subrec (recwr
);
4240 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4241 etir_output_check (abfd
, section
, curr_addr
,
4242 32 + 1 + strlen (udata
->origname
));
4243 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_BOH_GBL
);
4244 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
4245 _bfd_vms_output_long
4246 (recwr
, (unsigned long) section
->target_index
);
4247 _bfd_vms_output_quad (recwr
, rptr
->address
);
4248 _bfd_vms_output_long (recwr
, (unsigned long) 0xD3400000);
4249 _bfd_vms_output_long
4250 (recwr
, (unsigned long) section
->target_index
);
4251 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4252 _bfd_vms_output_counted (recwr
, udata
->origname
);
4253 _bfd_vms_output_end_subrec (recwr
);
4257 _bfd_error_handler (_("unhandled relocation %s"),
4264 } /* End of relocs loop. */
4266 if (!pass2_in_progress
)
4268 /* Output rest of section. */
4269 if (curr_addr
> section
->size
)
4271 _bfd_error_handler (_("size error in section %pA"), section
);
4274 size
= section
->size
- curr_addr
;
4275 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
4281 pass2_in_progress
= 1;
4287 else /* (section->flags & SEC_RELOC) */
4288 sto_imm (abfd
, section
, section
->size
, section
->contents
, 0);
4290 end_etir_record (abfd
);
4293 _bfd_vms_output_alignment (recwr
, 2);
4297 /* Write cached information into a file being written, at bfd_close. */
4300 alpha_vms_write_object_contents (bfd
*abfd
)
4302 vms_debug2 ((1, "vms_write_object_contents (%p)\n", abfd
));
4304 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
4306 return alpha_vms_write_exec (abfd
);
4310 if (abfd
->section_count
> 0) /* we have sections */
4312 if (!_bfd_vms_write_ehdr (abfd
))
4314 if (!_bfd_vms_write_egsd (abfd
))
4316 if (!_bfd_vms_write_etir (abfd
, EOBJ__C_ETIR
))
4318 if (!_bfd_vms_write_eeom (abfd
))
4325 /* Debug stuff: nearest line. */
4327 #define SET_MODULE_PARSED(m) \
4328 do { if ((m)->name == NULL) (m)->name = ""; } while (0)
4329 #define IS_MODULE_PARSED(m) ((m)->name != NULL)
4331 /* Build a new module for the specified BFD. */
4333 static struct module
*
4334 new_module (bfd
*abfd
)
4336 struct module
*module
4337 = (struct module
*) bfd_zalloc (abfd
, sizeof (struct module
));
4338 module
->file_table_count
= 16; /* Arbitrary. */
4340 = bfd_zmalloc (module
->file_table_count
* sizeof (struct fileinfo
));
4344 /* Parse debug info for a module and internalize it. */
4347 parse_module (bfd
*abfd
, struct module
*module
, unsigned char *ptr
,
4348 bfd_size_type length
)
4350 unsigned char *maxptr
= ptr
+ length
;
4351 unsigned char *src_ptr
, *pcl_ptr
;
4352 unsigned int prev_linum
= 0, curr_linenum
= 0;
4353 bfd_vma prev_pc
= 0, curr_pc
= 0;
4354 struct srecinfo
*curr_srec
, *srec
;
4355 struct lineinfo
*curr_line
, *line
;
4356 struct funcinfo
*funcinfo
;
4358 /* Initialize tables with zero element. */
4359 curr_srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4362 module
->srec_table
= curr_srec
;
4364 curr_line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4367 module
->line_table
= curr_line
;
4369 while (ptr
+ 3 < maxptr
)
4371 /* The first byte is not counted in the recorded length. */
4372 int rec_length
= bfd_getl16 (ptr
) + 1;
4373 int rec_type
= bfd_getl16 (ptr
+ 2);
4375 vms_debug2 ((2, "DST record: leng %d, type %d\n", rec_length
, rec_type
));
4377 if (rec_length
> maxptr
- ptr
)
4379 if (rec_type
== DST__K_MODEND
)
4385 if (rec_length
<= DST_S_B_MODBEG_NAME
)
4388 = _bfd_vms_save_counted_string (abfd
, ptr
+ DST_S_B_MODBEG_NAME
,
4389 rec_length
- DST_S_B_MODBEG_NAME
);
4396 vms_debug2 ((3, "module: %s\n", module
->name
));
4403 if (rec_length
<= DST_S_B_RTNBEG_NAME
)
4405 funcinfo
= (struct funcinfo
*)
4406 bfd_zalloc (abfd
, sizeof (struct funcinfo
));
4410 = _bfd_vms_save_counted_string (abfd
, ptr
+ DST_S_B_RTNBEG_NAME
,
4411 rec_length
- DST_S_B_RTNBEG_NAME
);
4412 funcinfo
->low
= bfd_getl32 (ptr
+ DST_S_L_RTNBEG_ADDRESS
);
4413 funcinfo
->next
= module
->func_table
;
4414 module
->func_table
= funcinfo
;
4416 vms_debug2 ((3, "routine: %s at 0x%lx\n",
4417 funcinfo
->name
, (unsigned long) funcinfo
->low
));
4421 if (rec_length
< DST_S_L_RTNEND_SIZE
+ 4)
4423 if (!module
->func_table
)
4425 module
->func_table
->high
= module
->func_table
->low
4426 + bfd_getl32 (ptr
+ DST_S_L_RTNEND_SIZE
) - 1;
4428 if (module
->func_table
->high
> module
->high
)
4429 module
->high
= module
->func_table
->high
;
4431 vms_debug2 ((3, "end routine\n"));
4435 vms_debug2 ((3, "prologue\n"));
4439 vms_debug2 ((3, "epilog\n"));
4443 vms_debug2 ((3, "block\n"));
4447 vms_debug2 ((3, "end block\n"));
4451 src_ptr
= ptr
+ DST_S_C_SOURCE_HEADER_SIZE
;
4453 vms_debug2 ((3, "source info\n"));
4455 while (src_ptr
- ptr
< rec_length
)
4457 int cmd
= src_ptr
[0], cmd_length
, data
;
4461 case DST__K_SRC_DECLFILE
:
4462 if (src_ptr
- ptr
+ DST_S_B_SRC_DF_LENGTH
>= rec_length
)
4463 cmd_length
= 0x10000;
4465 cmd_length
= src_ptr
[DST_S_B_SRC_DF_LENGTH
] + 2;
4468 case DST__K_SRC_DEFLINES_B
:
4472 case DST__K_SRC_DEFLINES_W
:
4476 case DST__K_SRC_INCRLNUM_B
:
4480 case DST__K_SRC_SETFILE
:
4484 case DST__K_SRC_SETLNUM_L
:
4488 case DST__K_SRC_SETLNUM_W
:
4492 case DST__K_SRC_SETREC_L
:
4496 case DST__K_SRC_SETREC_W
:
4500 case DST__K_SRC_FORMFEED
:
4509 if (src_ptr
- ptr
+ cmd_length
> rec_length
)
4514 case DST__K_SRC_DECLFILE
:
4517 = bfd_getl16 (src_ptr
+ DST_S_W_SRC_DF_FILEID
);
4518 char *filename
= _bfd_vms_save_counted_string
4520 src_ptr
+ DST_S_B_SRC_DF_FILENAME
,
4521 ptr
+ rec_length
- (src_ptr
+ DST_S_B_SRC_DF_FILENAME
));
4523 if (fileid
>= module
->file_table_count
)
4525 unsigned int old_count
= module
->file_table_count
;
4526 module
->file_table_count
+= fileid
;
4528 = bfd_realloc_or_free (module
->file_table
,
4529 module
->file_table_count
4530 * sizeof (struct fileinfo
));
4531 if (module
->file_table
== NULL
)
4533 memset (module
->file_table
+ old_count
, 0,
4534 fileid
* sizeof (struct fileinfo
));
4537 module
->file_table
[fileid
].name
= filename
;
4538 module
->file_table
[fileid
].srec
= 1;
4539 vms_debug2 ((4, "DST_S_C_SRC_DECLFILE: %d, %s\n",
4540 fileid
, module
->file_table
[fileid
].name
));
4544 case DST__K_SRC_DEFLINES_B
:
4545 /* Perform the association and set the next higher index
4547 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4548 srec
= (struct srecinfo
*)
4549 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4550 srec
->line
= curr_srec
->line
+ data
;
4551 srec
->srec
= curr_srec
->srec
+ data
;
4552 srec
->sfile
= curr_srec
->sfile
;
4553 curr_srec
->next
= srec
;
4555 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_B: %d\n", data
));
4558 case DST__K_SRC_DEFLINES_W
:
4559 /* Perform the association and set the next higher index
4561 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4562 srec
= (struct srecinfo
*)
4563 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4564 srec
->line
= curr_srec
->line
+ data
;
4565 srec
->srec
= curr_srec
->srec
+ data
,
4566 srec
->sfile
= curr_srec
->sfile
;
4567 curr_srec
->next
= srec
;
4569 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_W: %d\n", data
));
4572 case DST__K_SRC_INCRLNUM_B
:
4573 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4574 curr_srec
->line
+= data
;
4575 vms_debug2 ((4, "DST_S_C_SRC_INCRLNUM_B: %d\n", data
));
4578 case DST__K_SRC_SETFILE
:
4579 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4580 if ((unsigned int) data
< module
->file_table_count
)
4582 curr_srec
->sfile
= data
;
4583 curr_srec
->srec
= module
->file_table
[data
].srec
;
4585 vms_debug2 ((4, "DST_S_C_SRC_SETFILE: %d\n", data
));
4588 case DST__K_SRC_SETLNUM_L
:
4589 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4590 curr_srec
->line
= data
;
4591 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_L: %d\n", data
));
4594 case DST__K_SRC_SETLNUM_W
:
4595 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4596 curr_srec
->line
= data
;
4597 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_W: %d\n", data
));
4600 case DST__K_SRC_SETREC_L
:
4601 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4602 curr_srec
->srec
= data
;
4603 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4604 vms_debug2 ((4, "DST_S_C_SRC_SETREC_L: %d\n", data
));
4607 case DST__K_SRC_SETREC_W
:
4608 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4609 curr_srec
->srec
= data
;
4610 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4611 vms_debug2 ((4, "DST_S_C_SRC_SETREC_W: %d\n", data
));
4614 case DST__K_SRC_FORMFEED
:
4615 vms_debug2 ((4, "DST_S_C_SRC_FORMFEED\n"));
4619 _bfd_error_handler (_("unknown source command %d"),
4624 src_ptr
+= cmd_length
;
4628 case DST__K_LINE_NUM
:
4629 pcl_ptr
= ptr
+ DST_S_C_LINE_NUM_HEADER_SIZE
;
4631 vms_debug2 ((3, "line info\n"));
4633 while (pcl_ptr
- ptr
< rec_length
)
4635 /* The command byte is signed so we must sign-extend it. */
4636 int cmd
= ((signed char *)pcl_ptr
)[0], cmd_length
, data
;
4640 case DST__K_DELTA_PC_W
:
4644 case DST__K_DELTA_PC_L
:
4648 case DST__K_INCR_LINUM
:
4652 case DST__K_INCR_LINUM_W
:
4656 case DST__K_INCR_LINUM_L
:
4660 case DST__K_SET_LINUM_INCR
:
4664 case DST__K_SET_LINUM_INCR_W
:
4668 case DST__K_RESET_LINUM_INCR
:
4672 case DST__K_BEG_STMT_MODE
:
4676 case DST__K_END_STMT_MODE
:
4680 case DST__K_SET_LINUM_B
:
4684 case DST__K_SET_LINUM
:
4688 case DST__K_SET_LINUM_L
:
4696 case DST__K_SET_PC_W
:
4700 case DST__K_SET_PC_L
:
4704 case DST__K_SET_STMTNUM
:
4720 case DST__K_SET_ABS_PC
:
4732 if (pcl_ptr
- ptr
+ cmd_length
> rec_length
)
4737 case DST__K_DELTA_PC_W
:
4738 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4741 vms_debug2 ((4, "DST__K_DELTA_PC_W: %d\n", data
));
4744 case DST__K_DELTA_PC_L
:
4745 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4748 vms_debug2 ((4, "DST__K_DELTA_PC_L: %d\n", data
));
4751 case DST__K_INCR_LINUM
:
4752 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4753 curr_linenum
+= data
;
4754 vms_debug2 ((4, "DST__K_INCR_LINUM: %d\n", data
));
4757 case DST__K_INCR_LINUM_W
:
4758 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4759 curr_linenum
+= data
;
4760 vms_debug2 ((4, "DST__K_INCR_LINUM_W: %d\n", data
));
4763 case DST__K_INCR_LINUM_L
:
4764 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4765 curr_linenum
+= data
;
4766 vms_debug2 ((4, "DST__K_INCR_LINUM_L: %d\n", data
));
4769 case DST__K_SET_LINUM_INCR
:
4771 (_("%s not implemented"), "DST__K_SET_LINUM_INCR");
4774 case DST__K_SET_LINUM_INCR_W
:
4776 (_("%s not implemented"), "DST__K_SET_LINUM_INCR_W");
4779 case DST__K_RESET_LINUM_INCR
:
4781 (_("%s not implemented"), "DST__K_RESET_LINUM_INCR");
4784 case DST__K_BEG_STMT_MODE
:
4786 (_("%s not implemented"), "DST__K_BEG_STMT_MODE");
4789 case DST__K_END_STMT_MODE
:
4791 (_("%s not implemented"), "DST__K_END_STMT_MODE");
4794 case DST__K_SET_LINUM_B
:
4795 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4796 curr_linenum
= data
;
4797 vms_debug2 ((4, "DST__K_SET_LINUM_B: %d\n", data
));
4800 case DST__K_SET_LINUM
:
4801 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4802 curr_linenum
= data
;
4803 vms_debug2 ((4, "DST__K_SET_LINE_NUM: %d\n", data
));
4806 case DST__K_SET_LINUM_L
:
4807 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4808 curr_linenum
= data
;
4809 vms_debug2 ((4, "DST__K_SET_LINUM_L: %d\n", data
));
4814 (_("%s not implemented"), "DST__K_SET_PC");
4817 case DST__K_SET_PC_W
:
4819 (_("%s not implemented"), "DST__K_SET_PC_W");
4822 case DST__K_SET_PC_L
:
4824 (_("%s not implemented"), "DST__K_SET_PC_L");
4827 case DST__K_SET_STMTNUM
:
4829 (_("%s not implemented"), "DST__K_SET_STMTNUM");
4833 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4835 vms_debug2 ((4, "DST__K_TERM: %d\n", data
));
4839 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4841 vms_debug2 ((4, "DST__K_TERM_W: %d\n", data
));
4845 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4847 vms_debug2 ((4, "DST__K_TERM_L: %d\n", data
));
4850 case DST__K_SET_ABS_PC
:
4851 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4853 vms_debug2 ((4, "DST__K_SET_ABS_PC: 0x%x\n", data
));
4861 vms_debug2 ((4, "bump pc to 0x%lx and line to %d\n",
4862 (unsigned long)curr_pc
, curr_linenum
));
4865 _bfd_error_handler (_("unknown line command %d"), cmd
);
4869 if ((curr_linenum
!= prev_linum
&& curr_pc
!= prev_pc
)
4871 || cmd
== DST__K_DELTA_PC_L
4872 || cmd
== DST__K_DELTA_PC_W
)
4874 line
= (struct lineinfo
*)
4875 bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4876 line
->address
= curr_pc
;
4877 line
->line
= curr_linenum
;
4879 curr_line
->next
= line
;
4882 prev_linum
= curr_linenum
;
4884 vms_debug2 ((4, "-> correlate pc 0x%lx with line %d\n",
4885 (unsigned long)curr_pc
, curr_linenum
));
4888 pcl_ptr
+= cmd_length
;
4892 case 0x17: /* Undocumented type used by DEC C to declare equates. */
4893 vms_debug2 ((3, "undocumented type 0x17\n"));
4897 vms_debug2 ((3, "ignoring record\n"));
4905 /* Finalize tables with EOL marker. */
4906 srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4907 srec
->line
= (unsigned int) -1;
4908 srec
->srec
= (unsigned int) -1;
4909 curr_srec
->next
= srec
;
4911 line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4912 line
->line
= (unsigned int) -1;
4913 line
->address
= (bfd_vma
) -1;
4914 curr_line
->next
= line
;
4916 /* Advertise that this module has been parsed. This is needed
4917 because parsing can be either performed at module creation
4918 or deferred until debug info is consumed. */
4919 SET_MODULE_PARSED (module
);
4923 /* Build the list of modules for the specified BFD. */
4925 static struct module
*
4926 build_module_list (bfd
*abfd
)
4928 struct module
*module
, *list
= NULL
;
4931 if ((dmt
= bfd_get_section_by_name (abfd
, "$DMT$")))
4933 /* We have a DMT section so this must be an image. Parse the
4934 section and build the list of modules. This is sufficient
4935 since we can compute the start address and the end address
4936 of every module from the section contents. */
4937 bfd_size_type size
= bfd_section_size (dmt
);
4938 unsigned char *buf
, *ptr
, *end
;
4940 if (! bfd_malloc_and_get_section (abfd
, dmt
, &buf
))
4943 vms_debug2 ((2, "DMT\n"));
4947 while (end
- ptr
>= DBG_S_C_DMT_HEADER_SIZE
)
4949 /* Each header declares a module with its start offset and size
4950 of debug info in the DST section, as well as the count of
4951 program sections (i.e. address spans) it contains. */
4952 unsigned int modbeg
= bfd_getl32 (ptr
+ DBG_S_L_DMT_MODBEG
);
4953 unsigned int msize
= bfd_getl32 (ptr
+ DBG_S_L_DST_SIZE
);
4954 int count
= bfd_getl16 (ptr
+ DBG_S_W_DMT_PSECT_COUNT
);
4955 ptr
+= DBG_S_C_DMT_HEADER_SIZE
;
4957 vms_debug2 ((3, "module: modbeg = %u, size = %u, count = %d\n",
4958 modbeg
, msize
, count
));
4960 /* We create a 'module' structure for each program section since
4961 we only support contiguous addresses in a 'module' structure.
4962 As a consequence, the actual debug info in the DST section is
4963 shared and can be parsed multiple times; that doesn't seem to
4964 cause problems in practice. */
4965 while (count
-- > 0 && end
- ptr
>= DBG_S_C_DMT_PSECT_SIZE
)
4967 unsigned int start
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_START
);
4968 unsigned int length
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_LENGTH
);
4969 module
= new_module (abfd
);
4970 module
->modbeg
= modbeg
;
4971 module
->size
= msize
;
4972 module
->low
= start
;
4973 module
->high
= start
+ length
;
4974 module
->next
= list
;
4976 ptr
+= DBG_S_C_DMT_PSECT_SIZE
;
4978 vms_debug2 ((4, "section: start = 0x%x, length = %u\n",
4986 /* We don't have a DMT section so this must be an object. Parse
4987 the module right now in order to compute its start address and
4989 void *dst
= PRIV (dst_section
)->contents
;
4994 module
= new_module (abfd
);
4995 if (!parse_module (abfd
, module
, PRIV (dst_section
)->contents
,
4996 PRIV (dst_section
)->size
))
5004 /* Calculate and return the name of the source file and the line nearest
5005 to the wanted location in the specified module. */
5008 module_find_nearest_line (bfd
*abfd
, struct module
*module
, bfd_vma addr
,
5009 const char **file
, const char **func
,
5012 struct funcinfo
*funcinfo
;
5013 struct lineinfo
*lineinfo
;
5014 struct srecinfo
*srecinfo
;
5017 /* Parse this module if that was not done at module creation. */
5018 if (! IS_MODULE_PARSED (module
))
5020 unsigned int size
= module
->size
;
5021 unsigned int modbeg
= PRIV (dst_section
)->filepos
+ module
->modbeg
;
5022 unsigned char *buffer
;
5024 if (bfd_seek (abfd
, modbeg
, SEEK_SET
) != 0
5025 || (buffer
= _bfd_malloc_and_read (abfd
, size
, size
)) == NULL
)
5027 bfd_set_error (bfd_error_no_debug_section
);
5031 ret
= parse_module (abfd
, module
, buffer
, size
);
5037 /* Find out the function (if any) that contains the address. */
5038 for (funcinfo
= module
->func_table
; funcinfo
; funcinfo
= funcinfo
->next
)
5039 if (addr
>= funcinfo
->low
&& addr
<= funcinfo
->high
)
5041 *func
= funcinfo
->name
;
5046 /* Find out the source file and the line nearest to the address. */
5047 for (lineinfo
= module
->line_table
; lineinfo
; lineinfo
= lineinfo
->next
)
5048 if (lineinfo
->next
&& addr
< lineinfo
->next
->address
)
5050 for (srecinfo
= module
->srec_table
; srecinfo
; srecinfo
= srecinfo
->next
)
5051 if (srecinfo
->next
&& lineinfo
->line
< srecinfo
->next
->line
)
5053 if (srecinfo
->sfile
> 0)
5055 *file
= module
->file_table
[srecinfo
->sfile
].name
;
5056 *line
= srecinfo
->srec
+ lineinfo
->line
- srecinfo
->line
;
5060 *file
= module
->name
;
5061 *line
= lineinfo
->line
;
5072 /* Provided a BFD, a section and an offset into the section, calculate and
5073 return the name of the source file and the line nearest to the wanted
5077 _bfd_vms_find_nearest_line (bfd
*abfd
,
5078 asymbol
**symbols ATTRIBUTE_UNUSED
,
5084 unsigned int *discriminator
)
5086 struct module
*module
;
5088 /* What address are we looking for? */
5089 bfd_vma addr
= section
->vma
+ offset
;
5097 /* We can't do anything if there is no DST (debug symbol table). */
5098 if (PRIV (dst_section
) == NULL
)
5101 /* Create the module list - if not already done. */
5102 if (PRIV (modules
) == NULL
)
5104 PRIV (modules
) = build_module_list (abfd
);
5105 if (PRIV (modules
) == NULL
)
5109 for (module
= PRIV (modules
); module
; module
= module
->next
)
5110 if (addr
>= module
->low
&& addr
<= module
->high
)
5111 return module_find_nearest_line (abfd
, module
, addr
, file
, func
, line
);
5116 /* Canonicalizations. */
5117 /* Set name, value, section and flags of SYM from E. */
5120 alpha_vms_convert_symbol (bfd
*abfd
, struct vms_symbol_entry
*e
, asymbol
*sym
)
5129 flags
= BSF_NO_FLAGS
;
5135 if (e
->flags
& EGSY__V_WEAK
)
5138 if (e
->flags
& EGSY__V_DEF
)
5140 /* Symbol definition. */
5141 flags
|= BSF_GLOBAL
;
5142 if (e
->flags
& EGSY__V_NORM
)
5143 flags
|= BSF_FUNCTION
;
5149 /* Symbol reference. */
5150 sec
= bfd_und_section_ptr
;
5155 /* A universal symbol is by definition global... */
5156 flags
|= BSF_GLOBAL
;
5158 /* ...and dynamic in shared libraries. */
5159 if (abfd
->flags
& DYNAMIC
)
5160 flags
|= BSF_DYNAMIC
;
5162 if (e
->flags
& EGSY__V_WEAK
)
5165 if (!(e
->flags
& EGSY__V_DEF
))
5168 if (e
->flags
& EGSY__V_NORM
)
5169 flags
|= BSF_FUNCTION
;
5172 /* sec = e->section; */
5173 sec
= bfd_abs_section_ptr
;
5188 /* Return the number of bytes required to store a vector of pointers
5189 to asymbols for all the symbols in the BFD abfd, including a
5190 terminal NULL pointer. If there are no symbols in the BFD,
5191 then return 0. If an error occurs, return -1. */
5194 alpha_vms_get_symtab_upper_bound (bfd
*abfd
)
5196 vms_debug2 ((1, "alpha_vms_get_symtab_upper_bound (%p), %d symbols\n",
5197 abfd
, PRIV (gsd_sym_count
)));
5199 return (PRIV (gsd_sym_count
) + 1) * sizeof (asymbol
*);
5202 /* Read the symbols from the BFD abfd, and fills in the vector
5203 location with pointers to the symbols and a trailing NULL.
5205 Return number of symbols read. */
5208 alpha_vms_canonicalize_symtab (bfd
*abfd
, asymbol
**symbols
)
5212 vms_debug2 ((1, "alpha_vms_canonicalize_symtab (%p, <ret>)\n", abfd
));
5214 if (PRIV (csymbols
) == NULL
)
5216 PRIV (csymbols
) = (asymbol
**) bfd_alloc
5217 (abfd
, PRIV (gsd_sym_count
) * sizeof (asymbol
*));
5219 /* Traverse table and fill symbols vector. */
5220 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
5222 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
5225 sym
= bfd_make_empty_symbol (abfd
);
5226 if (sym
== NULL
|| !alpha_vms_convert_symbol (abfd
, e
, sym
))
5228 bfd_release (abfd
, PRIV (csymbols
));
5229 PRIV (csymbols
) = NULL
;
5233 PRIV (csymbols
)[i
] = sym
;
5237 if (symbols
!= NULL
)
5239 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
5240 symbols
[i
] = PRIV (csymbols
)[i
];
5244 return PRIV (gsd_sym_count
);
5247 /* Read and convert relocations from ETIR. We do it once for all sections. */
5250 alpha_vms_slurp_relocs (bfd
*abfd
)
5254 vms_debug2 ((3, "alpha_vms_slurp_relocs\n"));
5256 /* We slurp relocs only once, for all sections. */
5257 if (PRIV (reloc_done
) != 0)
5258 return PRIV (reloc_done
) == 1;
5260 if (alpha_vms_canonicalize_symtab (abfd
, NULL
) < 0)
5263 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
5268 unsigned char *begin
;
5271 bfd_reloc_code_real_type reloc_code
;
5277 bfd_vma cur_address
;
5279 unsigned char *cur_sym
= NULL
;
5281 bfd_vma cur_addend
= 0;
5283 /* Skip non-ETIR records. */
5284 type
= _bfd_vms_get_object_record (abfd
);
5287 if (type
== EOBJ__C_EEOM
)
5289 if (type
!= EOBJ__C_ETIR
)
5292 begin
= PRIV (recrd
.rec
) + 4;
5293 end
= PRIV (recrd
.rec
) + PRIV (recrd
.rec_size
);
5295 for (ptr
= begin
; ptr
< end
; ptr
+= length
)
5299 cmd
= bfd_getl16 (ptr
);
5300 length
= bfd_getl16 (ptr
+ 2);
5302 cur_address
= vaddr
;
5304 vms_debug2 ((4, "alpha_vms_slurp_relocs: etir %s\n",
5305 _bfd_vms_etir_name (cmd
)));
5309 case ETIR__C_STA_GBL
: /* ALPHA_R_REFLONG und_section, step 1 */
5310 /* ALPHA_R_REFQUAD und_section, step 1 */
5315 case ETIR__C_STA_PQ
: /* ALPHA_R_REF{LONG|QUAD}, others part 1 */
5316 cur_psidx
= bfd_getl32 (ptr
+ 4);
5317 cur_addend
= bfd_getl64 (ptr
+ 8);
5321 case ETIR__C_CTL_SETRB
:
5322 if (prev_cmd
!= ETIR__C_STA_PQ
)
5325 /* xgettext:c-format */
5326 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (prev_cmd
),
5327 _bfd_vms_etir_name (cmd
));
5330 cur_psect
= cur_psidx
;
5336 case ETIR__C_STA_LW
: /* ALPHA_R_REFLONG abs_section, step 1 */
5337 /* ALPHA_R_REFLONG und_section, step 2 */
5340 if (prev_cmd
!= ETIR__C_STA_GBL
)
5343 /* xgettext:c-format */
5344 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
5345 _bfd_vms_etir_name (ETIR__C_STA_LW
));
5349 cur_addend
= bfd_getl32 (ptr
+ 4);
5353 case ETIR__C_STA_QW
: /* ALPHA_R_REFQUAD abs_section, step 1 */
5354 /* ALPHA_R_REFQUAD und_section, step 2 */
5355 if (prev_cmd
!= -1 && prev_cmd
!= ETIR__C_STA_GBL
)
5358 /* xgettext:c-format */
5359 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
5360 _bfd_vms_etir_name (ETIR__C_STA_QW
));
5363 cur_addend
= bfd_getl64 (ptr
+ 4);
5367 case ETIR__C_STO_LW
: /* ALPHA_R_REFLONG und_section, step 4 */
5368 /* ALPHA_R_REFLONG abs_section, step 2 */
5369 /* ALPHA_R_REFLONG others, step 2 */
5370 if (prev_cmd
!= ETIR__C_OPR_ADD
5371 && prev_cmd
!= ETIR__C_STA_LW
5372 && prev_cmd
!= ETIR__C_STA_PQ
)
5374 /* xgettext:c-format */
5375 _bfd_error_handler (_("unknown reloc %s + %s"),
5376 _bfd_vms_etir_name (prev_cmd
),
5377 _bfd_vms_etir_name (ETIR__C_STO_LW
));
5380 reloc_code
= BFD_RELOC_32
;
5383 case ETIR__C_STO_QW
: /* ALPHA_R_REFQUAD und_section, step 4 */
5384 /* ALPHA_R_REFQUAD abs_section, step 2 */
5385 if (prev_cmd
!= ETIR__C_OPR_ADD
&& prev_cmd
!= ETIR__C_STA_QW
)
5387 /* xgettext:c-format */
5388 _bfd_error_handler (_("unknown reloc %s + %s"),
5389 _bfd_vms_etir_name (prev_cmd
),
5390 _bfd_vms_etir_name (ETIR__C_STO_QW
));
5393 reloc_code
= BFD_RELOC_64
;
5396 case ETIR__C_STO_OFF
: /* ALPHA_R_REFQUAD others, step 2 */
5397 if (prev_cmd
!= ETIR__C_STA_PQ
)
5399 /* xgettext:c-format */
5400 _bfd_error_handler (_("unknown reloc %s + %s"),
5401 _bfd_vms_etir_name (prev_cmd
),
5402 _bfd_vms_etir_name (ETIR__C_STO_OFF
));
5405 reloc_code
= BFD_RELOC_64
;
5408 case ETIR__C_OPR_ADD
: /* ALPHA_R_REFLONG und_section, step 3 */
5409 /* ALPHA_R_REFQUAD und_section, step 3 */
5410 if (prev_cmd
!= ETIR__C_STA_LW
&& prev_cmd
!= ETIR__C_STA_QW
)
5412 /* xgettext:c-format */
5413 _bfd_error_handler (_("unknown reloc %s + %s"),
5414 _bfd_vms_etir_name (prev_cmd
),
5415 _bfd_vms_etir_name (ETIR__C_OPR_ADD
));
5418 prev_cmd
= ETIR__C_OPR_ADD
;
5421 case ETIR__C_STO_CA
: /* ALPHA_R_CODEADDR */
5422 reloc_code
= BFD_RELOC_ALPHA_CODEADDR
;
5426 case ETIR__C_STO_GBL
: /* ALPHA_R_REFQUAD und_section */
5427 reloc_code
= BFD_RELOC_64
;
5431 case ETIR__C_STO_GBL_LW
: /* ALPHA_R_REFLONG und_section */
5432 reloc_code
= BFD_RELOC_32
;
5436 case ETIR__C_STC_LP_PSB
: /* ALPHA_R_LINKAGE */
5437 reloc_code
= BFD_RELOC_ALPHA_LINKAGE
;
5441 case ETIR__C_STC_NOP_GBL
: /* ALPHA_R_NOP */
5442 reloc_code
= BFD_RELOC_ALPHA_NOP
;
5445 case ETIR__C_STC_BSR_GBL
: /* ALPHA_R_BSR */
5446 reloc_code
= BFD_RELOC_ALPHA_BSR
;
5449 case ETIR__C_STC_LDA_GBL
: /* ALPHA_R_LDA */
5450 reloc_code
= BFD_RELOC_ALPHA_LDA
;
5453 case ETIR__C_STC_BOH_GBL
: /* ALPHA_R_BOH */
5454 reloc_code
= BFD_RELOC_ALPHA_BOH
;
5458 cur_sym
= ptr
+ 4 + 32;
5459 cur_address
= bfd_getl64 (ptr
+ 4 + 8);
5460 cur_addend
= bfd_getl64 (ptr
+ 4 + 24);
5463 case ETIR__C_STO_IMM
:
5464 vaddr
+= bfd_getl32 (ptr
+ 4);
5468 _bfd_error_handler (_("unknown reloc %s"),
5469 _bfd_vms_etir_name (cmd
));
5475 struct vms_section_data_struct
*vms_sec
;
5479 /* Get section to which the relocation applies. */
5480 if (cur_psect
< 0 || cur_psect
> (int)PRIV (section_count
))
5482 _bfd_error_handler (_("invalid section index in ETIR"));
5486 if (PRIV (sections
) == NULL
)
5488 sec
= PRIV (sections
)[cur_psect
];
5489 if (sec
== bfd_abs_section_ptr
)
5491 _bfd_error_handler (_("relocation for non-REL psect"));
5495 vms_sec
= vms_section_data (sec
);
5497 /* Allocate a reloc entry. */
5498 if (sec
->reloc_count
>= vms_sec
->reloc_max
)
5500 if (vms_sec
->reloc_max
== 0)
5502 vms_sec
->reloc_max
= 64;
5503 sec
->relocation
= bfd_zmalloc
5504 (vms_sec
->reloc_max
* sizeof (arelent
));
5508 vms_sec
->reloc_max
*= 2;
5509 sec
->relocation
= bfd_realloc_or_free
5510 (sec
->relocation
, vms_sec
->reloc_max
* sizeof (arelent
));
5511 if (sec
->relocation
== NULL
)
5515 reloc
= &sec
->relocation
[sec
->reloc_count
];
5518 reloc
->howto
= bfd_reloc_type_lookup (abfd
, reloc_code
);
5520 if (cur_sym
!= NULL
)
5523 unsigned int symlen
= *cur_sym
;
5526 /* Linear search. */
5531 for (j
= 0; j
< PRIV (gsd_sym_count
); j
++)
5532 if (PRIV (syms
)[j
]->namelen
== symlen
5533 && memcmp (PRIV (syms
)[j
]->name
, cur_sym
, symlen
) == 0)
5535 sym
= &PRIV (csymbols
)[j
];
5540 _bfd_error_handler (_("unknown symbol in command %s"),
5541 _bfd_vms_etir_name (cmd
));
5542 reloc
->sym_ptr_ptr
= NULL
;
5545 reloc
->sym_ptr_ptr
= sym
;
5547 else if (cur_psidx
>= 0)
5549 if (PRIV (sections
) == NULL
|| cur_psidx
>= (int) PRIV (section_count
))
5551 reloc
->sym_ptr_ptr
=
5552 PRIV (sections
)[cur_psidx
]->symbol_ptr_ptr
;
5555 reloc
->sym_ptr_ptr
= NULL
;
5557 reloc
->address
= cur_address
;
5558 reloc
->addend
= cur_addend
;
5560 if (reloc_code
== ALPHA_R_LINKAGE
)
5563 size
= bfd_get_reloc_size (reloc
->howto
);
5573 vms_debug2 ((3, "alpha_vms_slurp_relocs: result = true\n"));
5574 PRIV (reloc_done
) = 1;
5578 PRIV (reloc_done
) = -1;
5582 /* Return the number of bytes required to store the relocation
5583 information associated with the given section. */
5586 alpha_vms_get_reloc_upper_bound (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*section
)
5588 if (!alpha_vms_slurp_relocs (abfd
))
5591 return (section
->reloc_count
+ 1L) * sizeof (arelent
*);
5594 /* Convert relocations from VMS (external) form into BFD internal
5595 form. Return the number of relocations. */
5598 alpha_vms_canonicalize_reloc (bfd
*abfd
, asection
*section
, arelent
**relptr
,
5599 asymbol
**symbols ATTRIBUTE_UNUSED
)
5604 if (!alpha_vms_slurp_relocs (abfd
))
5607 count
= section
->reloc_count
;
5608 tblptr
= section
->relocation
;
5611 *relptr
++ = tblptr
++;
5613 *relptr
= (arelent
*) NULL
;
5614 return section
->reloc_count
;
5617 /* Install a new set of internal relocs. */
5619 #define alpha_vms_set_reloc _bfd_generic_set_reloc
5622 /* This is just copied from ecoff-alpha, needs to be fixed probably. */
5624 /* How to process the various reloc types. */
5626 static bfd_reloc_status_type
5627 reloc_nil (bfd
* abfd ATTRIBUTE_UNUSED
,
5628 arelent
*reloc ATTRIBUTE_UNUSED
,
5629 asymbol
*sym ATTRIBUTE_UNUSED
,
5630 void * data ATTRIBUTE_UNUSED
,
5631 asection
*sec ATTRIBUTE_UNUSED
,
5632 bfd
*output_bfd ATTRIBUTE_UNUSED
,
5633 char **error_message ATTRIBUTE_UNUSED
)
5636 vms_debug (1, "reloc_nil (abfd %p, output_bfd %p)\n", abfd
, output_bfd
);
5637 vms_debug (2, "In section %s, symbol %s\n",
5638 sec
->name
, sym
->name
);
5639 vms_debug (2, "reloc sym %s, addr %08lx, addend %08lx, reloc is a %s\n",
5640 reloc
->sym_ptr_ptr
[0]->name
,
5641 (unsigned long)reloc
->address
,
5642 (unsigned long)reloc
->addend
, reloc
->howto
->name
);
5643 vms_debug (2, "data at %p\n", data
);
5644 /* _bfd_hexdump (2, data, bfd_get_reloc_size (reloc->howto), 0); */
5647 return bfd_reloc_ok
;
5650 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
5651 from smaller values. Start with zero, widen, *then* decrement. */
5652 #define MINUS_ONE (((bfd_vma)0) - 1)
5654 static reloc_howto_type alpha_howto_table
[] =
5656 HOWTO (ALPHA_R_IGNORE
, /* Type. */
5657 0, /* Rightshift. */
5660 true, /* PC relative. */
5662 complain_overflow_dont
,/* Complain_on_overflow. */
5663 reloc_nil
, /* Special_function. */
5664 "IGNORE", /* Name. */
5665 true, /* Partial_inplace. */
5666 0, /* Source mask */
5668 true), /* PC rel offset. */
5670 /* A 64 bit reference to a symbol. */
5671 HOWTO (ALPHA_R_REFQUAD
, /* Type. */
5672 0, /* Rightshift. */
5675 false, /* PC relative. */
5677 complain_overflow_bitfield
, /* Complain_on_overflow. */
5678 reloc_nil
, /* Special_function. */
5679 "REFQUAD", /* Name. */
5680 true, /* Partial_inplace. */
5681 MINUS_ONE
, /* Source mask. */
5682 MINUS_ONE
, /* Dest mask. */
5683 false), /* PC rel offset. */
5685 /* A 21 bit branch. The native assembler generates these for
5686 branches within the text segment, and also fills in the PC
5687 relative offset in the instruction. */
5688 HOWTO (ALPHA_R_BRADDR
, /* Type. */
5689 2, /* Rightshift. */
5692 true, /* PC relative. */
5694 complain_overflow_signed
, /* Complain_on_overflow. */
5695 reloc_nil
, /* Special_function. */
5696 "BRADDR", /* Name. */
5697 true, /* Partial_inplace. */
5698 0x1fffff, /* Source mask. */
5699 0x1fffff, /* Dest mask. */
5700 false), /* PC rel offset. */
5702 /* A hint for a jump to a register. */
5703 HOWTO (ALPHA_R_HINT
, /* Type. */
5704 2, /* Rightshift. */
5707 true, /* PC relative. */
5709 complain_overflow_dont
,/* Complain_on_overflow. */
5710 reloc_nil
, /* Special_function. */
5712 true, /* Partial_inplace. */
5713 0x3fff, /* Source mask. */
5714 0x3fff, /* Dest mask. */
5715 false), /* PC rel offset. */
5717 /* 16 bit PC relative offset. */
5718 HOWTO (ALPHA_R_SREL16
, /* Type. */
5719 0, /* Rightshift. */
5722 true, /* PC relative. */
5724 complain_overflow_signed
, /* Complain_on_overflow. */
5725 reloc_nil
, /* Special_function. */
5726 "SREL16", /* Name. */
5727 true, /* Partial_inplace. */
5728 0xffff, /* Source mask. */
5729 0xffff, /* Dest mask. */
5730 false), /* PC rel offset. */
5732 /* 32 bit PC relative offset. */
5733 HOWTO (ALPHA_R_SREL32
, /* Type. */
5734 0, /* Rightshift. */
5737 true, /* PC relative. */
5739 complain_overflow_signed
, /* Complain_on_overflow. */
5740 reloc_nil
, /* Special_function. */
5741 "SREL32", /* Name. */
5742 true, /* Partial_inplace. */
5743 0xffffffff, /* Source mask. */
5744 0xffffffff, /* Dest mask. */
5745 false), /* PC rel offset. */
5747 /* A 64 bit PC relative offset. */
5748 HOWTO (ALPHA_R_SREL64
, /* Type. */
5749 0, /* Rightshift. */
5752 true, /* PC relative. */
5754 complain_overflow_signed
, /* Complain_on_overflow. */
5755 reloc_nil
, /* Special_function. */
5756 "SREL64", /* Name. */
5757 true, /* Partial_inplace. */
5758 MINUS_ONE
, /* Source mask. */
5759 MINUS_ONE
, /* Dest mask. */
5760 false), /* PC rel offset. */
5762 /* Push a value on the reloc evaluation stack. */
5763 HOWTO (ALPHA_R_OP_PUSH
, /* Type. */
5764 0, /* Rightshift. */
5767 false, /* PC relative. */
5769 complain_overflow_dont
,/* Complain_on_overflow. */
5770 reloc_nil
, /* Special_function. */
5771 "OP_PUSH", /* Name. */
5772 false, /* Partial_inplace. */
5773 0, /* Source mask. */
5775 false), /* PC rel offset. */
5777 /* Store the value from the stack at the given address. Store it in
5778 a bitfield of size r_size starting at bit position r_offset. */
5779 HOWTO (ALPHA_R_OP_STORE
, /* Type. */
5780 0, /* Rightshift. */
5783 false, /* PC relative. */
5785 complain_overflow_dont
,/* Complain_on_overflow. */
5786 reloc_nil
, /* Special_function. */
5787 "OP_STORE", /* Name. */
5788 false, /* Partial_inplace. */
5789 0, /* Source mask. */
5790 MINUS_ONE
, /* Dest mask. */
5791 false), /* PC rel offset. */
5793 /* Subtract the reloc address from the value on the top of the
5794 relocation stack. */
5795 HOWTO (ALPHA_R_OP_PSUB
, /* Type. */
5796 0, /* Rightshift. */
5799 false, /* PC relative. */
5801 complain_overflow_dont
,/* Complain_on_overflow. */
5802 reloc_nil
, /* Special_function. */
5803 "OP_PSUB", /* Name. */
5804 false, /* Partial_inplace. */
5805 0, /* Source mask. */
5807 false), /* PC rel offset. */
5809 /* Shift the value on the top of the relocation stack right by the
5811 HOWTO (ALPHA_R_OP_PRSHIFT
, /* Type. */
5812 0, /* Rightshift. */
5815 false, /* PC relative. */
5817 complain_overflow_dont
,/* Complain_on_overflow. */
5818 reloc_nil
, /* Special_function. */
5819 "OP_PRSHIFT", /* Name. */
5820 false, /* Partial_inplace. */
5821 0, /* Source mask. */
5823 false), /* PC rel offset. */
5825 /* Hack. Linkage is done by linker. */
5826 HOWTO (ALPHA_R_LINKAGE
, /* Type. */
5827 0, /* Rightshift. */
5830 false, /* PC relative. */
5832 complain_overflow_dont
,/* Complain_on_overflow. */
5833 reloc_nil
, /* Special_function. */
5834 "LINKAGE", /* Name. */
5835 false, /* Partial_inplace. */
5836 0, /* Source mask. */
5838 false), /* PC rel offset. */
5840 /* A 32 bit reference to a symbol. */
5841 HOWTO (ALPHA_R_REFLONG
, /* Type. */
5842 0, /* Rightshift. */
5845 false, /* PC relative. */
5847 complain_overflow_bitfield
, /* Complain_on_overflow. */
5848 reloc_nil
, /* Special_function. */
5849 "REFLONG", /* Name. */
5850 true, /* Partial_inplace. */
5851 0xffffffff, /* Source mask. */
5852 0xffffffff, /* Dest mask. */
5853 false), /* PC rel offset. */
5855 /* A 64 bit reference to a procedure, written as 32 bit value. */
5856 HOWTO (ALPHA_R_CODEADDR
, /* Type. */
5857 0, /* Rightshift. */
5860 false, /* PC relative. */
5862 complain_overflow_signed
,/* Complain_on_overflow. */
5863 reloc_nil
, /* Special_function. */
5864 "CODEADDR", /* Name. */
5865 false, /* Partial_inplace. */
5866 0xffffffff, /* Source mask. */
5867 0xffffffff, /* Dest mask. */
5868 false), /* PC rel offset. */
5870 HOWTO (ALPHA_R_NOP
, /* Type. */
5871 0, /* Rightshift. */
5874 /* The following value must match that of ALPHA_R_BSR/ALPHA_R_BOH
5875 because the calculations for the 3 relocations are the same.
5876 See B.4.5.2 of the OpenVMS Linker Utility Manual. */
5877 true, /* PC relative. */
5879 complain_overflow_dont
,/* Complain_on_overflow. */
5880 reloc_nil
, /* Special_function. */
5882 false, /* Partial_inplace. */
5883 0xffffffff, /* Source mask. */
5884 0xffffffff, /* Dest mask. */
5885 false), /* PC rel offset. */
5887 HOWTO (ALPHA_R_BSR
, /* Type. */
5888 0, /* Rightshift. */
5891 true, /* PC relative. */
5893 complain_overflow_dont
,/* Complain_on_overflow. */
5894 reloc_nil
, /* Special_function. */
5896 false, /* Partial_inplace. */
5897 0xffffffff, /* Source mask. */
5898 0xffffffff, /* Dest mask. */
5899 false), /* PC rel offset. */
5901 HOWTO (ALPHA_R_LDA
, /* Type. */
5902 0, /* Rightshift. */
5905 false, /* PC relative. */
5907 complain_overflow_dont
,/* Complain_on_overflow. */
5908 reloc_nil
, /* Special_function. */
5910 false, /* Partial_inplace. */
5911 0xffffffff, /* Source mask. */
5912 0xffffffff, /* Dest mask. */
5913 false), /* PC rel offset. */
5915 HOWTO (ALPHA_R_BOH
, /* Type. */
5916 0, /* Rightshift. */
5919 true, /* PC relative. */
5921 complain_overflow_dont
,/* Complain_on_overflow. */
5922 reloc_nil
, /* Special_function. */
5924 false, /* Partial_inplace. */
5925 0xffffffff, /* Source mask. */
5926 0xffffffff, /* Dest mask. */
5927 false), /* PC rel offset. */
5930 /* Return a pointer to a howto structure which, when invoked, will perform
5931 the relocation code on data from the architecture noted. */
5933 static reloc_howto_type
*
5934 alpha_vms_bfd_reloc_type_lookup (bfd
* abfd ATTRIBUTE_UNUSED
,
5935 bfd_reloc_code_real_type code
)
5939 vms_debug2 ((1, "vms_bfd_reloc_type_lookup (%p, %d)\t", abfd
, code
));
5943 case BFD_RELOC_16
: alpha_type
= ALPHA_R_SREL16
; break;
5944 case BFD_RELOC_32
: alpha_type
= ALPHA_R_REFLONG
; break;
5945 case BFD_RELOC_64
: alpha_type
= ALPHA_R_REFQUAD
; break;
5946 case BFD_RELOC_CTOR
: alpha_type
= ALPHA_R_REFQUAD
; break;
5947 case BFD_RELOC_23_PCREL_S2
: alpha_type
= ALPHA_R_BRADDR
; break;
5948 case BFD_RELOC_ALPHA_HINT
: alpha_type
= ALPHA_R_HINT
; break;
5949 case BFD_RELOC_16_PCREL
: alpha_type
= ALPHA_R_SREL16
; break;
5950 case BFD_RELOC_32_PCREL
: alpha_type
= ALPHA_R_SREL32
; break;
5951 case BFD_RELOC_64_PCREL
: alpha_type
= ALPHA_R_SREL64
; break;
5952 case BFD_RELOC_ALPHA_LINKAGE
: alpha_type
= ALPHA_R_LINKAGE
; break;
5953 case BFD_RELOC_ALPHA_CODEADDR
: alpha_type
= ALPHA_R_CODEADDR
; break;
5954 case BFD_RELOC_ALPHA_NOP
: alpha_type
= ALPHA_R_NOP
; break;
5955 case BFD_RELOC_ALPHA_BSR
: alpha_type
= ALPHA_R_BSR
; break;
5956 case BFD_RELOC_ALPHA_LDA
: alpha_type
= ALPHA_R_LDA
; break;
5957 case BFD_RELOC_ALPHA_BOH
: alpha_type
= ALPHA_R_BOH
; break;
5959 _bfd_error_handler (_("reloc (%d) is *UNKNOWN*"), code
);
5962 vms_debug2 ((2, "reloc is %s\n", alpha_howto_table
[alpha_type
].name
));
5963 return & alpha_howto_table
[alpha_type
];
5966 static reloc_howto_type
*
5967 alpha_vms_bfd_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
5973 i
< sizeof (alpha_howto_table
) / sizeof (alpha_howto_table
[0]);
5975 if (alpha_howto_table
[i
].name
!= NULL
5976 && strcasecmp (alpha_howto_table
[i
].name
, r_name
) == 0)
5977 return &alpha_howto_table
[i
];
5983 alpha_vms_get_synthetic_symtab (bfd
*abfd
,
5984 long symcount ATTRIBUTE_UNUSED
,
5985 asymbol
**usyms ATTRIBUTE_UNUSED
,
5986 long dynsymcount ATTRIBUTE_UNUSED
,
5987 asymbol
**dynsyms ATTRIBUTE_UNUSED
,
5994 syms
= (asymbol
*) bfd_malloc (PRIV (norm_sym_count
) * sizeof (asymbol
));
5999 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
6001 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
6012 flags
= BSF_LOCAL
| BSF_SYNTHETIC
;
6019 if ((e
->flags
& EGSY__V_DEF
) && (e
->flags
& EGSY__V_NORM
))
6021 value
= e
->code_value
;
6022 sec
= e
->code_section
;
6033 sname
= bfd_alloc (abfd
, l
+ 5);
6036 memcpy (sname
, name
, l
);
6037 memcpy (sname
+ l
, "..en", 5);
6044 sym
->udata
.p
= NULL
;
6053 vms_time_to_str (unsigned char *buf
)
6055 time_t t
= vms_rawtime_to_time_t (buf
);
6056 char *res
= ctime (&t
);
6059 res
= "*invalid time*";
6066 evax_bfd_print_emh (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
6068 struct vms_emh_common
*emh
= (struct vms_emh_common
*)rec
;
6069 unsigned int subtype
;
6072 subtype
= (unsigned) bfd_getl16 (emh
->subtyp
);
6074 /* xgettext:c-format */
6075 fprintf (file
, _(" EMH %u (len=%u): "), subtype
, rec_len
);
6077 /* PR 21618: Check for invalid lengths. */
6078 if (rec_len
< sizeof (* emh
))
6080 fprintf (file
, _(" Error: The length is less than the length of an EMH record\n"));
6083 extra
= rec_len
- sizeof (struct vms_emh_common
);
6089 struct vms_emh_mhd
*mhd
= (struct vms_emh_mhd
*) rec
;
6090 unsigned char *name
;
6091 unsigned char *nextname
;
6092 unsigned char *maxname
;
6094 /* PR 21840: Check for invalid lengths. */
6095 if (rec_len
< sizeof (* mhd
))
6097 fprintf (file
, _(" Error: The record length is less than the size of an EMH_MHD record\n"));
6100 fprintf (file
, _("Module header\n"));
6101 fprintf (file
, _(" structure level: %u\n"), mhd
->strlvl
);
6102 fprintf (file
, _(" max record size: %u\n"),
6103 (unsigned) bfd_getl32 (mhd
->recsiz
));
6104 name
= (unsigned char *) (mhd
+ 1);
6105 maxname
= (unsigned char *) rec
+ rec_len
;
6106 if (name
> maxname
- 2)
6108 fprintf (file
, _(" Error: The module name is missing\n"));
6111 nextname
= name
+ name
[0] + 1;
6112 if (nextname
>= maxname
)
6114 fprintf (file
, _(" Error: The module name is too long\n"));
6117 fprintf (file
, _(" module name : %.*s\n"), name
[0], name
+ 1);
6119 if (name
> maxname
- 2)
6121 fprintf (file
, _(" Error: The module version is missing\n"));
6124 nextname
= name
+ name
[0] + 1;
6125 if (nextname
>= maxname
)
6127 fprintf (file
, _(" Error: The module version is too long\n"));
6130 fprintf (file
, _(" module version : %.*s\n"), name
[0], name
+ 1);
6132 if ((maxname
- name
) < 17 && maxname
[-1] != 0)
6133 fprintf (file
, _(" Error: The compile date is truncated\n"));
6135 fprintf (file
, _(" compile date : %.17s\n"), name
);
6140 fprintf (file
, _("Language Processor Name\n"));
6141 fprintf (file
, _(" language name: %.*s\n"), extra
, (char *)(emh
+ 1));
6145 fprintf (file
, _("Source Files Header\n"));
6146 fprintf (file
, _(" file: %.*s\n"), extra
, (char *)(emh
+ 1));
6150 fprintf (file
, _("Title Text Header\n"));
6151 fprintf (file
, _(" title: %.*s\n"), extra
, (char *)(emh
+ 1));
6155 fprintf (file
, _("Copyright Header\n"));
6156 fprintf (file
, _(" copyright: %.*s\n"), extra
, (char *)(emh
+ 1));
6160 fprintf (file
, _("unhandled emh subtype %u\n"), subtype
);
6166 evax_bfd_print_eeom (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
6168 struct vms_eeom
*eeom
= (struct vms_eeom
*)rec
;
6170 fprintf (file
, _(" EEOM (len=%u):\n"), rec_len
);
6172 /* PR 21618: Check for invalid lengths. */
6173 if (rec_len
< sizeof (* eeom
))
6175 fprintf (file
, _(" Error: The length is less than the length of an EEOM record\n"));
6179 fprintf (file
, _(" number of cond linkage pairs: %u\n"),
6180 (unsigned)bfd_getl32 (eeom
->total_lps
));
6181 fprintf (file
, _(" completion code: %u\n"),
6182 (unsigned)bfd_getl16 (eeom
->comcod
));
6185 fprintf (file
, _(" transfer addr flags: 0x%02x\n"), eeom
->tfrflg
);
6186 fprintf (file
, _(" transfer addr psect: %u\n"),
6187 (unsigned)bfd_getl32 (eeom
->psindx
));
6188 fprintf (file
, _(" transfer address : 0x%08x\n"),
6189 (unsigned)bfd_getl32 (eeom
->tfradr
));
6194 exav_bfd_print_egsy_flags (unsigned int flags
, FILE *file
)
6196 if (flags
& EGSY__V_WEAK
)
6197 fputs (_(" WEAK"), file
);
6198 if (flags
& EGSY__V_DEF
)
6199 fputs (_(" DEF"), file
);
6200 if (flags
& EGSY__V_UNI
)
6201 fputs (_(" UNI"), file
);
6202 if (flags
& EGSY__V_REL
)
6203 fputs (_(" REL"), file
);
6204 if (flags
& EGSY__V_COMM
)
6205 fputs (_(" COMM"), file
);
6206 if (flags
& EGSY__V_VECEP
)
6207 fputs (_(" VECEP"), file
);
6208 if (flags
& EGSY__V_NORM
)
6209 fputs (_(" NORM"), file
);
6210 if (flags
& EGSY__V_QUAD_VAL
)
6211 fputs (_(" QVAL"), file
);
6215 evax_bfd_print_egsd_flags (FILE *file
, unsigned int flags
)
6217 if (flags
& EGPS__V_PIC
)
6218 fputs (_(" PIC"), file
);
6219 if (flags
& EGPS__V_LIB
)
6220 fputs (_(" LIB"), file
);
6221 if (flags
& EGPS__V_OVR
)
6222 fputs (_(" OVR"), file
);
6223 if (flags
& EGPS__V_REL
)
6224 fputs (_(" REL"), file
);
6225 if (flags
& EGPS__V_GBL
)
6226 fputs (_(" GBL"), file
);
6227 if (flags
& EGPS__V_SHR
)
6228 fputs (_(" SHR"), file
);
6229 if (flags
& EGPS__V_EXE
)
6230 fputs (_(" EXE"), file
);
6231 if (flags
& EGPS__V_RD
)
6232 fputs (_(" RD"), file
);
6233 if (flags
& EGPS__V_WRT
)
6234 fputs (_(" WRT"), file
);
6235 if (flags
& EGPS__V_VEC
)
6236 fputs (_(" VEC"), file
);
6237 if (flags
& EGPS__V_NOMOD
)
6238 fputs (_(" NOMOD"), file
);
6239 if (flags
& EGPS__V_COM
)
6240 fputs (_(" COM"), file
);
6241 if (flags
& EGPS__V_ALLOC_64BIT
)
6242 fputs (_(" 64B"), file
);
6246 evax_bfd_print_egsd (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
6248 unsigned int off
= sizeof (struct vms_egsd
);
6251 fprintf (file
, _(" EGSD (len=%u):\n"), rec_len
);
6252 if (rec_len
< sizeof (struct vms_egsd
) + sizeof (struct vms_egsd_entry
))
6255 while (off
<= rec_len
- sizeof (struct vms_egsd_entry
))
6257 struct vms_egsd_entry
*e
= (struct vms_egsd_entry
*)(rec
+ off
);
6262 type
= (unsigned)bfd_getl16 (e
->gsdtyp
);
6263 len
= (unsigned)bfd_getl16 (e
->gsdsiz
);
6265 /* xgettext:c-format */
6266 fprintf (file
, _(" EGSD entry %2u (type: %u, len: %u): "),
6270 if (len
< sizeof (struct vms_egsd_entry
) || len
> rec_len
- off
)
6272 fprintf (file
, _(" Erroneous length\n"));
6279 if (len
>= offsetof (struct vms_egps
, name
))
6281 struct vms_egps
*egps
= (struct vms_egps
*) e
;
6282 unsigned int flags
= bfd_getl16 (egps
->flags
);
6285 fprintf (file
, _("PSC - Program section definition\n"));
6286 fprintf (file
, _(" alignment : 2**%u\n"), egps
->align
);
6287 fprintf (file
, _(" flags : 0x%04x"), flags
);
6288 evax_bfd_print_egsd_flags (file
, flags
);
6290 l
= bfd_getl32 (egps
->alloc
);
6291 fprintf (file
, _(" alloc (len): %u (0x%08x)\n"), l
, l
);
6292 rest
= len
- offsetof (struct vms_egps
, name
);
6293 fprintf (file
, _(" name : %.*s\n"),
6294 egps
->namlng
> rest
? rest
: egps
->namlng
,
6299 if (len
>= offsetof (struct vms_esgps
, name
))
6301 struct vms_esgps
*esgps
= (struct vms_esgps
*) e
;
6302 unsigned int flags
= bfd_getl16 (esgps
->flags
);
6305 fprintf (file
, _("SPSC - Shared Image Program section def\n"));
6306 fprintf (file
, _(" alignment : 2**%u\n"), esgps
->align
);
6307 fprintf (file
, _(" flags : 0x%04x"), flags
);
6308 evax_bfd_print_egsd_flags (file
, flags
);
6310 l
= bfd_getl32 (esgps
->alloc
);
6311 fprintf (file
, _(" alloc (len) : %u (0x%08x)\n"), l
, l
);
6312 fprintf (file
, _(" image offset : 0x%08x\n"),
6313 (unsigned int) bfd_getl32 (esgps
->base
));
6314 fprintf (file
, _(" symvec offset : 0x%08x\n"),
6315 (unsigned int) bfd_getl32 (esgps
->value
));
6316 rest
= len
- offsetof (struct vms_esgps
, name
);
6317 fprintf (file
, _(" name : %.*s\n"),
6318 esgps
->namlng
> rest
? rest
: esgps
->namlng
,
6323 if (len
>= sizeof (struct vms_egsy
))
6325 struct vms_egsy
*egsy
= (struct vms_egsy
*) e
;
6326 unsigned int flags
= bfd_getl16 (egsy
->flags
);
6328 if ((flags
& EGSY__V_DEF
) != 0
6329 && len
>= offsetof (struct vms_esdf
, name
))
6331 struct vms_esdf
*esdf
= (struct vms_esdf
*) e
;
6333 fprintf (file
, _("SYM - Global symbol definition\n"));
6334 fprintf (file
, _(" flags: 0x%04x"), flags
);
6335 exav_bfd_print_egsy_flags (flags
, file
);
6337 fprintf (file
, _(" psect offset: 0x%08x\n"),
6338 (unsigned) bfd_getl32 (esdf
->value
));
6339 if (flags
& EGSY__V_NORM
)
6341 fprintf (file
, _(" code address: 0x%08x\n"),
6342 (unsigned) bfd_getl32 (esdf
->code_address
));
6343 fprintf (file
, _(" psect index for entry point : %u\n"),
6344 (unsigned) bfd_getl32 (esdf
->ca_psindx
));
6346 fprintf (file
, _(" psect index : %u\n"),
6347 (unsigned) bfd_getl32 (esdf
->psindx
));
6348 rest
= len
- offsetof (struct vms_esdf
, name
);
6349 fprintf (file
, _(" name : %.*s\n"),
6350 esdf
->namlng
> rest
? rest
: esdf
->namlng
,
6353 else if (len
>= offsetof (struct vms_esrf
, name
))
6355 struct vms_esrf
*esrf
= (struct vms_esrf
*)e
;
6357 fprintf (file
, _("SYM - Global symbol reference\n"));
6358 rest
= len
- offsetof (struct vms_esrf
, name
);
6359 fprintf (file
, _(" name : %.*s\n"),
6360 esrf
->namlng
> rest
? rest
: esrf
->namlng
,
6366 if (len
>= sizeof (struct vms_eidc
))
6368 struct vms_eidc
*eidc
= (struct vms_eidc
*) e
;
6369 unsigned int flags
= bfd_getl32 (eidc
->flags
);
6372 fprintf (file
, _("IDC - Ident Consistency check\n"));
6373 fprintf (file
, _(" flags : 0x%08x"), flags
);
6374 if (flags
& EIDC__V_BINIDENT
)
6375 fputs (" BINDENT", file
);
6377 fprintf (file
, _(" id match : %x\n"),
6378 (flags
>> EIDC__V_IDMATCH_SH
) & EIDC__V_IDMATCH_MASK
);
6379 fprintf (file
, _(" error severity: %x\n"),
6380 (flags
>> EIDC__V_ERRSEV_SH
) & EIDC__V_ERRSEV_MASK
);
6382 rest
= len
- (p
- (unsigned char *) e
);
6383 fprintf (file
, _(" entity name : %.*s\n"),
6384 p
[0] > rest
- 1 ? rest
- 1 : p
[0], p
+ 1);
6385 if (rest
> 1u + p
[0])
6389 fprintf (file
, _(" object name : %.*s\n"),
6390 p
[0] > rest
- 1 ? rest
- 1 : p
[0], p
+ 1);
6391 if (rest
> 1u + p
[0])
6395 if (flags
& EIDC__V_BINIDENT
)
6398 fprintf (file
, _(" binary ident : 0x%08x\n"),
6399 (unsigned) bfd_getl32 (p
));
6402 fprintf (file
, _(" ascii ident : %.*s\n"),
6403 p
[0] > rest
- 1 ? rest
- 1 : p
[0], p
+ 1);
6409 if (len
>= offsetof (struct vms_egst
, name
))
6411 struct vms_egst
*egst
= (struct vms_egst
*) e
;
6412 unsigned int flags
= bfd_getl16 (egst
->header
.flags
);
6414 fprintf (file
, _("SYMG - Universal symbol definition\n"));
6415 fprintf (file
, _(" flags: 0x%04x"), flags
);
6416 exav_bfd_print_egsy_flags (flags
, file
);
6418 fprintf (file
, _(" symbol vector offset: 0x%08x\n"),
6419 (unsigned) bfd_getl32 (egst
->value
));
6420 fprintf (file
, _(" entry point: 0x%08x\n"),
6421 (unsigned) bfd_getl32 (egst
->lp_1
));
6422 fprintf (file
, _(" proc descr : 0x%08x\n"),
6423 (unsigned) bfd_getl32 (egst
->lp_2
));
6424 fprintf (file
, _(" psect index: %u\n"),
6425 (unsigned) bfd_getl32 (egst
->psindx
));
6426 rest
= len
- offsetof (struct vms_egst
, name
);
6427 fprintf (file
, _(" name : %.*s\n"),
6428 egst
->namlng
> rest
? rest
: egst
->namlng
,
6433 if (len
>= offsetof (struct vms_esdfv
, name
))
6435 struct vms_esdfv
*esdfv
= (struct vms_esdfv
*) e
;
6436 unsigned int flags
= bfd_getl16 (esdfv
->flags
);
6438 fprintf (file
, _("SYMV - Vectored symbol definition\n"));
6439 fprintf (file
, _(" flags: 0x%04x"), flags
);
6440 exav_bfd_print_egsy_flags (flags
, file
);
6442 fprintf (file
, _(" vector : 0x%08x\n"),
6443 (unsigned) bfd_getl32 (esdfv
->vector
));
6444 fprintf (file
, _(" psect offset: %u\n"),
6445 (unsigned) bfd_getl32 (esdfv
->value
));
6446 fprintf (file
, _(" psect index : %u\n"),
6447 (unsigned) bfd_getl32 (esdfv
->psindx
));
6448 rest
= len
- offsetof (struct vms_esdfv
, name
);
6449 fprintf (file
, _(" name : %.*s\n"),
6450 esdfv
->namlng
> rest
? rest
: esdfv
->namlng
,
6455 if (len
>= offsetof (struct vms_esdfm
, name
))
6457 struct vms_esdfm
*esdfm
= (struct vms_esdfm
*) e
;
6458 unsigned int flags
= bfd_getl16 (esdfm
->flags
);
6461 _("SYMM - Global symbol definition with version\n"));
6462 fprintf (file
, _(" flags: 0x%04x"), flags
);
6463 exav_bfd_print_egsy_flags (flags
, file
);
6465 fprintf (file
, _(" version mask: 0x%08x\n"),
6466 (unsigned)bfd_getl32 (esdfm
->version_mask
));
6467 fprintf (file
, _(" psect offset: %u\n"),
6468 (unsigned)bfd_getl32 (esdfm
->value
));
6469 fprintf (file
, _(" psect index : %u\n"),
6470 (unsigned)bfd_getl32 (esdfm
->psindx
));
6471 rest
= len
- offsetof (struct vms_esdfm
, name
);
6472 fprintf (file
, _(" name : %.*s\n"),
6473 esdfm
->namlng
> rest
? rest
: esdfm
->namlng
,
6478 fprintf (file
, _("unhandled egsd entry type %u\n"), type
);
6486 evax_bfd_print_hex (FILE *file
, const char *pfx
,
6487 const unsigned char *buf
, unsigned int len
)
6493 for (i
= 0; i
< len
; i
++)
6497 fprintf (file
, " %02x", buf
[i
]);
6510 evax_bfd_print_etir_stc_ir (FILE *file
, const unsigned char *buf
,
6511 unsigned int len
, int is_ps
)
6513 if (is_ps
? len
< 44 : len
< 33)
6516 /* xgettext:c-format */
6517 fprintf (file
, _(" linkage index: %u, replacement insn: 0x%08x\n"),
6518 (unsigned)bfd_getl32 (buf
),
6519 (unsigned)bfd_getl32 (buf
+ 16));
6520 /* xgettext:c-format */
6521 fprintf (file
, _(" psect idx 1: %u, offset 1: 0x%08x %08x\n"),
6522 (unsigned)bfd_getl32 (buf
+ 4),
6523 (unsigned)bfd_getl32 (buf
+ 12),
6524 (unsigned)bfd_getl32 (buf
+ 8));
6525 /* xgettext:c-format */
6526 fprintf (file
, _(" psect idx 2: %u, offset 2: 0x%08x %08x\n"),
6527 (unsigned)bfd_getl32 (buf
+ 20),
6528 (unsigned)bfd_getl32 (buf
+ 28),
6529 (unsigned)bfd_getl32 (buf
+ 24));
6531 /* xgettext:c-format */
6532 fprintf (file
, _(" psect idx 3: %u, offset 3: 0x%08x %08x\n"),
6533 (unsigned)bfd_getl32 (buf
+ 32),
6534 (unsigned)bfd_getl32 (buf
+ 40),
6535 (unsigned)bfd_getl32 (buf
+ 36));
6537 fprintf (file
, _(" global name: %.*s\n"),
6538 buf
[32] > len
- 33 ? len
- 33 : buf
[32],
6543 evax_bfd_print_etir (FILE *file
, const char *name
,
6544 unsigned char *rec
, unsigned int rec_len
)
6546 unsigned int off
= sizeof (struct vms_eobjrec
);
6548 /* xgettext:c-format */
6549 fprintf (file
, _(" %s (len=%u):\n"), name
, (unsigned) rec_len
);
6550 if (rec_len
< sizeof (struct vms_eobjrec
) + sizeof (struct vms_etir
))
6553 while (off
<= rec_len
- sizeof (struct vms_etir
))
6555 struct vms_etir
*etir
= (struct vms_etir
*)(rec
+ off
);
6561 type
= bfd_getl16 (etir
->rectyp
);
6562 size
= bfd_getl16 (etir
->size
);
6563 buf
= rec
+ off
+ sizeof (struct vms_etir
);
6565 if (size
< sizeof (struct vms_etir
) || size
> rec_len
- off
)
6567 fprintf (file
, _(" Erroneous length\n"));
6571 /* xgettext:c-format */
6572 fprintf (file
, _(" (type: %3u, size: %3u): "), type
, size
);
6573 rest
= size
- sizeof (struct vms_etir
);
6576 case ETIR__C_STA_GBL
:
6578 fprintf (file
, _("STA_GBL (stack global) %.*s\n"),
6579 buf
[0] > rest
- 1 ? rest
- 1 : buf
[0], buf
+ 1);
6581 case ETIR__C_STA_LW
:
6582 fprintf (file
, _("STA_LW (stack longword)"));
6584 fprintf (file
, " 0x%08x\n",
6585 (unsigned) bfd_getl32 (buf
));
6587 case ETIR__C_STA_QW
:
6588 fprintf (file
, _("STA_QW (stack quadword)"));
6590 fprintf (file
, " 0x%08x %08x\n",
6591 (unsigned) bfd_getl32 (buf
+ 4),
6592 (unsigned) bfd_getl32 (buf
+ 0));
6594 case ETIR__C_STA_PQ
:
6595 fprintf (file
, _("STA_PQ (stack psect base + offset)\n"));
6597 /* xgettext:c-format */
6598 fprintf (file
, _(" psect: %u, offset: 0x%08x %08x\n"),
6599 (unsigned) bfd_getl32 (buf
+ 0),
6600 (unsigned) bfd_getl32 (buf
+ 8),
6601 (unsigned) bfd_getl32 (buf
+ 4));
6603 case ETIR__C_STA_LI
:
6604 fprintf (file
, _("STA_LI (stack literal)\n"));
6606 case ETIR__C_STA_MOD
:
6607 fprintf (file
, _("STA_MOD (stack module)\n"));
6609 case ETIR__C_STA_CKARG
:
6610 fprintf (file
, _("STA_CKARG (compare procedure argument)\n"));
6614 fprintf (file
, _("STO_B (store byte)\n"));
6617 fprintf (file
, _("STO_W (store word)\n"));
6619 case ETIR__C_STO_LW
:
6620 fprintf (file
, _("STO_LW (store longword)\n"));
6622 case ETIR__C_STO_QW
:
6623 fprintf (file
, _("STO_QW (store quadword)\n"));
6625 case ETIR__C_STO_IMMR
:
6628 unsigned int rpt
= bfd_getl32 (buf
);
6630 _("STO_IMMR (store immediate repeat) %u bytes\n"),
6634 evax_bfd_print_hex (file
, " ", buf
+ 4, rpt
);
6637 case ETIR__C_STO_GBL
:
6639 fprintf (file
, _("STO_GBL (store global) %.*s\n"),
6640 buf
[0] > rest
- 1 ? rest
- 1 : buf
[0], buf
+ 1);
6642 case ETIR__C_STO_CA
:
6644 fprintf (file
, _("STO_CA (store code address) %.*s\n"),
6645 buf
[0] > rest
- 1 ? rest
- 1 : buf
[0], buf
+ 1);
6647 case ETIR__C_STO_RB
:
6648 fprintf (file
, _("STO_RB (store relative branch)\n"));
6650 case ETIR__C_STO_AB
:
6651 fprintf (file
, _("STO_AB (store absolute branch)\n"));
6653 case ETIR__C_STO_OFF
:
6654 fprintf (file
, _("STO_OFF (store offset to psect)\n"));
6656 case ETIR__C_STO_IMM
:
6659 unsigned int rpt
= bfd_getl32 (buf
);
6661 _("STO_IMM (store immediate) %u bytes\n"),
6665 evax_bfd_print_hex (file
, " ", buf
+ 4, rpt
);
6668 case ETIR__C_STO_GBL_LW
:
6670 fprintf (file
, _("STO_GBL_LW (store global longword) %.*s\n"),
6671 buf
[0] > rest
- 1 ? rest
- 1 : buf
[0], buf
+ 1);
6673 case ETIR__C_STO_LP_PSB
:
6674 fprintf (file
, _("STO_OFF (store LP with procedure signature)\n"));
6676 case ETIR__C_STO_HINT_GBL
:
6677 fprintf (file
, _("STO_BR_GBL (store branch global) *todo*\n"));
6679 case ETIR__C_STO_HINT_PS
:
6680 fprintf (file
, _("STO_BR_PS (store branch psect + offset) *todo*\n"));
6683 case ETIR__C_OPR_NOP
:
6684 fprintf (file
, _("OPR_NOP (no-operation)\n"));
6686 case ETIR__C_OPR_ADD
:
6687 fprintf (file
, _("OPR_ADD (add)\n"));
6689 case ETIR__C_OPR_SUB
:
6690 fprintf (file
, _("OPR_SUB (subtract)\n"));
6692 case ETIR__C_OPR_MUL
:
6693 fprintf (file
, _("OPR_MUL (multiply)\n"));
6695 case ETIR__C_OPR_DIV
:
6696 fprintf (file
, _("OPR_DIV (divide)\n"));
6698 case ETIR__C_OPR_AND
:
6699 fprintf (file
, _("OPR_AND (logical and)\n"));
6701 case ETIR__C_OPR_IOR
:
6702 fprintf (file
, _("OPR_IOR (logical inclusive or)\n"));
6704 case ETIR__C_OPR_EOR
:
6705 fprintf (file
, _("OPR_EOR (logical exclusive or)\n"));
6707 case ETIR__C_OPR_NEG
:
6708 fprintf (file
, _("OPR_NEG (negate)\n"));
6710 case ETIR__C_OPR_COM
:
6711 fprintf (file
, _("OPR_COM (complement)\n"));
6713 case ETIR__C_OPR_INSV
:
6714 fprintf (file
, _("OPR_INSV (insert field)\n"));
6716 case ETIR__C_OPR_ASH
:
6717 fprintf (file
, _("OPR_ASH (arithmetic shift)\n"));
6719 case ETIR__C_OPR_USH
:
6720 fprintf (file
, _("OPR_USH (unsigned shift)\n"));
6722 case ETIR__C_OPR_ROT
:
6723 fprintf (file
, _("OPR_ROT (rotate)\n"));
6725 case ETIR__C_OPR_SEL
:
6726 fprintf (file
, _("OPR_SEL (select)\n"));
6728 case ETIR__C_OPR_REDEF
:
6729 fprintf (file
, _("OPR_REDEF (redefine symbol to curr location)\n"));
6731 case ETIR__C_OPR_DFLIT
:
6732 fprintf (file
, _("OPR_REDEF (define a literal)\n"));
6735 case ETIR__C_STC_LP
:
6736 fprintf (file
, _("STC_LP (store cond linkage pair)\n"));
6738 case ETIR__C_STC_LP_PSB
:
6740 _("STC_LP_PSB (store cond linkage pair + signature)\n"));
6743 /* xgettext:c-format */
6744 fprintf (file
, _(" linkage index: %u, procedure: %.*s\n"),
6745 (unsigned) bfd_getl32 (buf
),
6746 buf
[4] > rest
- 5 ? rest
- 5 : buf
[4], buf
+ 5);
6747 if (rest
> 4 + 1u + buf
[4])
6749 rest
-= 4 + 1 + buf
[4];
6750 buf
+= 4 + 1 + buf
[4];
6751 fprintf (file
, _(" signature: %.*s\n"),
6752 buf
[0] > rest
- 1 ? rest
- 1: buf
[0], buf
+ 1);
6756 case ETIR__C_STC_GBL
:
6757 fprintf (file
, _("STC_GBL (store cond global)\n"));
6759 /* xgettext:c-format */
6760 fprintf (file
, _(" linkage index: %u, global: %.*s\n"),
6761 (unsigned) bfd_getl32 (buf
),
6762 buf
[4] > rest
- 5 ? rest
- 5 : buf
[4], buf
+ 5);
6764 case ETIR__C_STC_GCA
:
6765 fprintf (file
, _("STC_GCA (store cond code address)\n"));
6767 /* xgettext:c-format */
6768 fprintf (file
, _(" linkage index: %u, procedure name: %.*s\n"),
6769 (unsigned) bfd_getl32 (buf
),
6770 buf
[4] > rest
- 5 ? rest
- 5 : buf
[4], buf
+ 5);
6772 case ETIR__C_STC_PS
:
6773 fprintf (file
, _("STC_PS (store cond psect + offset)\n"));
6776 /* xgettext:c-format */
6777 _(" linkage index: %u, psect: %u, offset: 0x%08x %08x\n"),
6778 (unsigned)bfd_getl32 (buf
),
6779 (unsigned)bfd_getl32 (buf
+ 4),
6780 (unsigned)bfd_getl32 (buf
+ 12),
6781 (unsigned)bfd_getl32 (buf
+ 8));
6783 case ETIR__C_STC_NOP_GBL
:
6784 fprintf (file
, _("STC_NOP_GBL (store cond NOP at global addr)\n"));
6785 evax_bfd_print_etir_stc_ir (file
, buf
, rest
, 0);
6787 case ETIR__C_STC_NOP_PS
:
6788 fprintf (file
, _("STC_NOP_PS (store cond NOP at psect + offset)\n"));
6789 evax_bfd_print_etir_stc_ir (file
, buf
, rest
, 1);
6791 case ETIR__C_STC_BSR_GBL
:
6792 fprintf (file
, _("STC_BSR_GBL (store cond BSR at global addr)\n"));
6793 evax_bfd_print_etir_stc_ir (file
, buf
, rest
, 0);
6795 case ETIR__C_STC_BSR_PS
:
6796 fprintf (file
, _("STC_BSR_PS (store cond BSR at psect + offset)\n"));
6797 evax_bfd_print_etir_stc_ir (file
, buf
, rest
, 1);
6799 case ETIR__C_STC_LDA_GBL
:
6800 fprintf (file
, _("STC_LDA_GBL (store cond LDA at global addr)\n"));
6801 evax_bfd_print_etir_stc_ir (file
, buf
, rest
, 0);
6803 case ETIR__C_STC_LDA_PS
:
6804 fprintf (file
, _("STC_LDA_PS (store cond LDA at psect + offset)\n"));
6805 evax_bfd_print_etir_stc_ir (file
, buf
, rest
, 1);
6807 case ETIR__C_STC_BOH_GBL
:
6808 fprintf (file
, _("STC_BOH_GBL (store cond BOH at global addr)\n"));
6809 evax_bfd_print_etir_stc_ir (file
, buf
, rest
, 0);
6811 case ETIR__C_STC_BOH_PS
:
6812 fprintf (file
, _("STC_BOH_PS (store cond BOH at psect + offset)\n"));
6813 evax_bfd_print_etir_stc_ir (file
, buf
, rest
, 1);
6815 case ETIR__C_STC_NBH_GBL
:
6817 _("STC_NBH_GBL (store cond or hint at global addr)\n"));
6819 case ETIR__C_STC_NBH_PS
:
6821 _("STC_NBH_PS (store cond or hint at psect + offset)\n"));
6824 case ETIR__C_CTL_SETRB
:
6825 fprintf (file
, _("CTL_SETRB (set relocation base)\n"));
6827 case ETIR__C_CTL_AUGRB
:
6830 unsigned int val
= bfd_getl32 (buf
);
6831 fprintf (file
, _("CTL_AUGRB (augment relocation base) %u\n"),
6835 case ETIR__C_CTL_DFLOC
:
6836 fprintf (file
, _("CTL_DFLOC (define location)\n"));
6838 case ETIR__C_CTL_STLOC
:
6839 fprintf (file
, _("CTL_STLOC (set location)\n"));
6841 case ETIR__C_CTL_STKDL
:
6842 fprintf (file
, _("CTL_STKDL (stack defined location)\n"));
6845 fprintf (file
, _("*unhandled*\n"));
6853 evax_bfd_print_eobj (struct bfd
*abfd
, FILE *file
)
6855 bool is_first
= true;
6856 bool has_records
= true;
6860 unsigned int rec_len
;
6861 unsigned int pad_len
;
6863 unsigned int hdr_size
;
6865 unsigned char buf
[6];
6867 hdr_size
= has_records
? 6 : 4;
6868 if (bfd_bread (buf
, hdr_size
, abfd
) != hdr_size
)
6870 fprintf (file
, _("cannot read GST record header\n"));
6874 type
= bfd_getl16 (buf
);
6875 rec_len
= bfd_getl16 (buf
+ 2);
6879 unsigned int rec_len2
= bfd_getl16 (buf
+ 4);
6884 if (type
== rec_len2
&& rec_len
== EOBJ__C_EMH
)
6885 /* Matched a VMS record EMH. */
6889 has_records
= false;
6890 if (type
!= EOBJ__C_EMH
)
6893 fprintf (file
, _("cannot find EMH in first GST record\n"));
6901 /* VMS record format is: record-size, type, record-size.
6902 See maybe_adjust_record_pointer_for_object comment. */
6903 if (type
== rec_len2
)
6910 pad_len
= (rec_len
+ 1) & ~1U;
6915 if (rec_len
< hdr_size
)
6917 fprintf (file
, _("corrupted GST\n"));
6921 rec
= bfd_malloc (pad_len
);
6925 memcpy (rec
, buf
+ (has_records
? 2 : 0), hdr_size
);
6927 if (bfd_bread (rec
+ hdr_size
, pad_len
- hdr_size
, abfd
)
6928 != pad_len
- hdr_size
)
6930 fprintf (file
, _("cannot read GST record\n"));
6937 evax_bfd_print_emh (file
, rec
, rec_len
);
6940 evax_bfd_print_egsd (file
, rec
, rec_len
);
6943 evax_bfd_print_eeom (file
, rec
, rec_len
);
6948 evax_bfd_print_etir (file
, "ETIR", rec
, rec_len
);
6951 evax_bfd_print_etir (file
, "EDBG", rec
, rec_len
);
6954 evax_bfd_print_etir (file
, "ETBT", rec
, rec_len
);
6957 fprintf (file
, _(" unhandled EOBJ record type %u\n"), type
);
6965 evax_bfd_print_relocation_records (FILE *file
, const unsigned char *buf
,
6966 size_t buf_size
, size_t off
,
6967 unsigned int stride
)
6969 while (off
<= buf_size
- 8)
6975 count
= bfd_getl32 (buf
+ off
+ 0);
6979 base
= bfd_getl32 (buf
+ off
+ 4);
6981 /* xgettext:c-format */
6982 fprintf (file
, _(" bitcount: %u, base addr: 0x%08x\n"),
6986 for (j
= 0; count
> 0 && off
<= buf_size
- 4; j
+= 4, count
-= 32)
6992 val
= bfd_getl32 (buf
+ off
);
6995 /* xgettext:c-format */
6996 fprintf (file
, _(" bitmap: 0x%08x (count: %u):\n"), val
, count
);
6998 for (k
= 0; k
< 32; k
++)
6999 if (val
& (1u << k
))
7003 fprintf (file
, _(" %08x"), base
+ (j
* 8 + k
) * stride
);
7018 evax_bfd_print_address_fixups (FILE *file
, const unsigned char *buf
,
7019 size_t buf_size
, size_t off
)
7021 while (off
<= buf_size
- 8)
7026 count
= bfd_getl32 (buf
+ off
+ 0);
7029 /* xgettext:c-format */
7030 fprintf (file
, _(" image %u (%u entries)\n"),
7031 (unsigned) bfd_getl32 (buf
+ off
+ 4), count
);
7033 for (j
= 0; j
< count
&& off
<= buf_size
- 8; j
++)
7035 /* xgettext:c-format */
7036 fprintf (file
, _(" offset: 0x%08x, val: 0x%08x\n"),
7037 (unsigned) bfd_getl32 (buf
+ off
+ 0),
7038 (unsigned) bfd_getl32 (buf
+ off
+ 4));
7045 evax_bfd_print_reference_fixups (FILE *file
, const unsigned char *buf
,
7046 size_t buf_size
, size_t off
)
7050 while (off
<= buf_size
- 8)
7055 count
= bfd_getl32 (buf
+ off
+ 0);
7058 /* xgettext:c-format */
7059 fprintf (file
, _(" image %u (%u entries), offsets:\n"),
7060 (unsigned) bfd_getl32 (buf
+ off
+ 4), count
);
7062 for (j
= 0; j
< count
&& off
<= buf_size
- 4; j
++)
7066 fprintf (file
, _(" 0x%08x"), (unsigned) bfd_getl32 (buf
+ off
));
7081 evax_bfd_print_indent (int indent
, FILE *file
)
7083 for (; indent
; indent
--)
7088 evax_bfd_get_dsc_name (unsigned int v
)
7092 case DSC__K_DTYPE_Z
:
7093 return "Z (Unspecified)";
7094 case DSC__K_DTYPE_V
:
7096 case DSC__K_DTYPE_BU
:
7097 return "BU (Byte logical)";
7098 case DSC__K_DTYPE_WU
:
7099 return "WU (Word logical)";
7100 case DSC__K_DTYPE_LU
:
7101 return "LU (Longword logical)";
7102 case DSC__K_DTYPE_QU
:
7103 return "QU (Quadword logical)";
7104 case DSC__K_DTYPE_B
:
7105 return "B (Byte integer)";
7106 case DSC__K_DTYPE_W
:
7107 return "W (Word integer)";
7108 case DSC__K_DTYPE_L
:
7109 return "L (Longword integer)";
7110 case DSC__K_DTYPE_Q
:
7111 return "Q (Quadword integer)";
7112 case DSC__K_DTYPE_F
:
7113 return "F (Single-precision floating)";
7114 case DSC__K_DTYPE_D
:
7115 return "D (Double-precision floating)";
7116 case DSC__K_DTYPE_FC
:
7117 return "FC (Complex)";
7118 case DSC__K_DTYPE_DC
:
7119 return "DC (Double-precision Complex)";
7120 case DSC__K_DTYPE_T
:
7121 return "T (ASCII text string)";
7122 case DSC__K_DTYPE_NU
:
7123 return "NU (Numeric string, unsigned)";
7124 case DSC__K_DTYPE_NL
:
7125 return "NL (Numeric string, left separate sign)";
7126 case DSC__K_DTYPE_NLO
:
7127 return "NLO (Numeric string, left overpunched sign)";
7128 case DSC__K_DTYPE_NR
:
7129 return "NR (Numeric string, right separate sign)";
7130 case DSC__K_DTYPE_NRO
:
7131 return "NRO (Numeric string, right overpunched sig)";
7132 case DSC__K_DTYPE_NZ
:
7133 return "NZ (Numeric string, zoned sign)";
7134 case DSC__K_DTYPE_P
:
7135 return "P (Packed decimal string)";
7136 case DSC__K_DTYPE_ZI
:
7137 return "ZI (Sequence of instructions)";
7138 case DSC__K_DTYPE_ZEM
:
7139 return "ZEM (Procedure entry mask)";
7140 case DSC__K_DTYPE_DSC
:
7141 return "DSC (Descriptor, used for arrays of dyn strings)";
7142 case DSC__K_DTYPE_OU
:
7143 return "OU (Octaword logical)";
7144 case DSC__K_DTYPE_O
:
7145 return "O (Octaword integer)";
7146 case DSC__K_DTYPE_G
:
7147 return "G (Double precision G floating, 64 bit)";
7148 case DSC__K_DTYPE_H
:
7149 return "H (Quadruple precision floating, 128 bit)";
7150 case DSC__K_DTYPE_GC
:
7151 return "GC (Double precision complex, G floating)";
7152 case DSC__K_DTYPE_HC
:
7153 return "HC (Quadruple precision complex, H floating)";
7154 case DSC__K_DTYPE_CIT
:
7155 return "CIT (COBOL intermediate temporary)";
7156 case DSC__K_DTYPE_BPV
:
7157 return "BPV (Bound Procedure Value)";
7158 case DSC__K_DTYPE_BLV
:
7159 return "BLV (Bound Label Value)";
7160 case DSC__K_DTYPE_VU
:
7161 return "VU (Bit Unaligned)";
7162 case DSC__K_DTYPE_ADT
:
7163 return "ADT (Absolute Date-Time)";
7164 case DSC__K_DTYPE_VT
:
7165 return "VT (Varying Text)";
7166 case DSC__K_DTYPE_T2
:
7167 return "T2 (16-bit char)";
7168 case DSC__K_DTYPE_VT2
:
7169 return "VT2 (16-bit varying char)";
7171 return "?? (unknown)";
7176 evax_bfd_print_desc (const unsigned char *buf
, unsigned int bufsize
,
7177 int indent
, FILE *file
)
7182 unsigned char bclass
= buf
[3];
7183 unsigned char dtype
= buf
[2];
7184 unsigned int len
= (unsigned)bfd_getl16 (buf
);
7185 unsigned int pointer
= (unsigned)bfd_getl32 (buf
+ 4);
7187 evax_bfd_print_indent (indent
, file
);
7189 if (len
== 1 && pointer
== 0xffffffffUL
)
7192 fprintf (file
, _("64 bits *unhandled*\n"));
7196 /* xgettext:c-format */
7197 fprintf (file
, _("class: %u, dtype: %u, length: %u, pointer: 0x%08x\n"),
7198 bclass
, dtype
, len
, pointer
);
7201 case DSC__K_CLASS_NCA
:
7203 const struct vms_dsc_nca
*dsc
= (const void *)buf
;
7205 const unsigned char *b
;
7207 evax_bfd_print_indent (indent
, file
);
7208 fprintf (file
, _("non-contiguous array of %s\n"),
7209 evax_bfd_get_dsc_name (dsc
->dtype
));
7210 if (bufsize
>= sizeof (*dsc
))
7212 evax_bfd_print_indent (indent
+ 1, file
);
7214 /* xgettext:c-format */
7215 _("dimct: %u, aflags: 0x%02x, digits: %u, scale: %u\n"),
7216 dsc
->dimct
, dsc
->aflags
, dsc
->digits
, dsc
->scale
);
7217 evax_bfd_print_indent (indent
+ 1, file
);
7219 /* xgettext:c-format */
7220 _("arsize: %u, a0: 0x%08x\n"),
7221 (unsigned) bfd_getl32 (dsc
->arsize
),
7222 (unsigned) bfd_getl32 (dsc
->a0
));
7223 evax_bfd_print_indent (indent
+ 1, file
);
7224 fprintf (file
, _("Strides:\n"));
7225 b
= buf
+ sizeof (*dsc
);
7226 bufsize
-= sizeof (*dsc
);
7227 for (i
= 0; i
< dsc
->dimct
; i
++)
7231 evax_bfd_print_indent (indent
+ 2, file
);
7232 fprintf (file
, "[%u]: %u\n", i
+ 1,
7233 (unsigned) bfd_getl32 (b
));
7237 evax_bfd_print_indent (indent
+ 1, file
);
7238 fprintf (file
, _("Bounds:\n"));
7239 for (i
= 0; i
< dsc
->dimct
; i
++)
7243 evax_bfd_print_indent (indent
+ 2, file
);
7244 /* xgettext:c-format */
7245 fprintf (file
, _("[%u]: Lower: %u, upper: %u\n"), i
+ 1,
7246 (unsigned) bfd_getl32 (b
+ 0),
7247 (unsigned) bfd_getl32 (b
+ 4));
7254 case DSC__K_CLASS_UBS
:
7256 const struct vms_dsc_ubs
*ubs
= (const void *)buf
;
7258 evax_bfd_print_indent (indent
, file
);
7259 fprintf (file
, _("unaligned bit-string of %s\n"),
7260 evax_bfd_get_dsc_name (ubs
->dtype
));
7261 if (bufsize
>= sizeof (*ubs
))
7263 evax_bfd_print_indent (indent
+ 1, file
);
7265 /* xgettext:c-format */
7266 _("base: %u, pos: %u\n"),
7267 (unsigned) bfd_getl32 (ubs
->base
),
7268 (unsigned) bfd_getl32 (ubs
->pos
));
7273 fprintf (file
, _("*unhandled*\n"));
7280 evax_bfd_print_valspec (const unsigned char *buf
, unsigned int bufsize
,
7281 int indent
, FILE *file
)
7286 unsigned int vflags
= buf
[0];
7287 unsigned int value
= (unsigned) bfd_getl32 (buf
+ 1);
7288 unsigned int len
= 5;
7290 evax_bfd_print_indent (indent
, file
);
7291 /* xgettext:c-format */
7292 fprintf (file
, _("vflags: 0x%02x, value: 0x%08x "), vflags
, value
);
7298 case DST__K_VFLAGS_NOVAL
:
7299 fprintf (file
, _("(no value)\n"));
7301 case DST__K_VFLAGS_NOTACTIVE
:
7302 fprintf (file
, _("(not active)\n"));
7304 case DST__K_VFLAGS_UNALLOC
:
7305 fprintf (file
, _("(not allocated)\n"));
7307 case DST__K_VFLAGS_DSC
:
7308 fprintf (file
, _("(descriptor)\n"));
7309 if (value
<= bufsize
)
7310 evax_bfd_print_desc (buf
+ value
, bufsize
- value
, indent
+ 1, file
);
7312 case DST__K_VFLAGS_TVS
:
7313 fprintf (file
, _("(trailing value)\n"));
7315 case DST__K_VS_FOLLOWS
:
7316 fprintf (file
, _("(value spec follows)\n"));
7318 case DST__K_VFLAGS_BITOFFS
:
7319 fprintf (file
, _("(at bit offset %u)\n"), value
);
7322 /* xgettext:c-format */
7323 fprintf (file
, _("(reg: %u, disp: %u, indir: %u, kind: "),
7324 (vflags
& DST__K_REGNUM_MASK
) >> DST__K_REGNUM_SHIFT
,
7325 vflags
& DST__K_DISP
? 1 : 0,
7326 vflags
& DST__K_INDIR
? 1 : 0);
7327 switch (vflags
& DST__K_VALKIND_MASK
)
7329 case DST__K_VALKIND_LITERAL
:
7330 fputs (_("literal"), file
);
7332 case DST__K_VALKIND_ADDR
:
7333 fputs (_("address"), file
);
7335 case DST__K_VALKIND_DESC
:
7336 fputs (_("desc"), file
);
7338 case DST__K_VALKIND_REG
:
7339 fputs (_("reg"), file
);
7342 fputs (")\n", file
);
7349 evax_bfd_print_typspec (const unsigned char *buf
, unsigned int bufsize
,
7350 int indent
, FILE *file
)
7355 unsigned char kind
= buf
[2];
7356 unsigned int len
= (unsigned) bfd_getl16 (buf
);
7358 evax_bfd_print_indent (indent
, file
);
7359 /* xgettext:c-format */
7360 fprintf (file
, _("len: %2u, kind: %2u "), len
, kind
);
7365 case DST__K_TS_ATOM
:
7366 /* xgettext:c-format */
7368 fprintf (file
, _("atomic, type=0x%02x %s\n"),
7369 buf
[0], evax_bfd_get_dsc_name (buf
[0]));
7373 fprintf (file
, _("indirect, defined at 0x%08x\n"),
7374 (unsigned) bfd_getl32 (buf
));
7376 case DST__K_TS_TPTR
:
7377 fprintf (file
, _("typed pointer\n"));
7378 evax_bfd_print_typspec (buf
, bufsize
, indent
+ 1, file
);
7381 fprintf (file
, _("pointer\n"));
7383 case DST__K_TS_ARRAY
:
7385 const unsigned char *vs
;
7386 unsigned int vs_len
;
7387 unsigned int vec_len
;
7392 fprintf (file
, _("array, dim: %u, bitmap: "), buf
[0]);
7394 vec_len
= (buf
[0] + 1 + 7) / 8;
7395 for (i
= 0; i
< vec_len
; i
++)
7399 fprintf (file
, " %02x", buf
[i
+ 1]);
7405 vs
= buf
+ 1 + vec_len
;
7406 evax_bfd_print_indent (indent
, file
);
7407 fprintf (file
, _("array descriptor:\n"));
7408 vs_len
= evax_bfd_print_valspec (vs
, bufsize
, indent
+ 1, file
);
7410 if (bufsize
> vs_len
)
7413 for (i
= 0; i
< buf
[0] + 1U; i
++)
7414 if (buf
[1 + i
/ 8] & (1 << (i
% 8)))
7416 evax_bfd_print_indent (indent
, file
);
7418 fprintf (file
, _("type spec for element:\n"));
7420 fprintf (file
, _("type spec for subscript %u:\n"), i
);
7421 evax_bfd_print_typspec (vs
, bufsize
, indent
+ 1, file
);
7424 vs_len
= bfd_getl16 (vs
);
7425 if (bufsize
<= vs_len
)
7434 fprintf (file
, _("*unhandled*\n"));
7439 evax_bfd_print_dst (struct bfd
*abfd
, unsigned int dst_size
, FILE *file
)
7441 unsigned int off
= 0;
7442 unsigned int pc
= 0;
7443 unsigned int line
= 0;
7445 fprintf (file
, _("Debug symbol table:\n"));
7447 while (dst_size
> 0)
7449 struct vms_dst_header dsth
;
7454 if (bfd_bread (&dsth
, sizeof (dsth
), abfd
) != sizeof (dsth
))
7456 fprintf (file
, _("cannot read DST header\n"));
7459 len
= bfd_getl16 (dsth
.length
);
7460 type
= bfd_getl16 (dsth
.type
);
7461 /* xgettext:c-format */
7462 fprintf (file
, _(" type: %3u, len: %3u (at 0x%08x): "),
7464 if (len
< sizeof (dsth
))
7471 len
-= sizeof (dsth
);
7476 buf
= _bfd_malloc_and_read (abfd
, len
, len
);
7479 fprintf (file
, _("cannot read DST symbol\n"));
7485 case DSC__K_DTYPE_V
:
7486 case DSC__K_DTYPE_BU
:
7487 case DSC__K_DTYPE_WU
:
7488 case DSC__K_DTYPE_LU
:
7489 case DSC__K_DTYPE_QU
:
7490 case DSC__K_DTYPE_B
:
7491 case DSC__K_DTYPE_W
:
7492 case DSC__K_DTYPE_L
:
7493 case DSC__K_DTYPE_Q
:
7494 case DSC__K_DTYPE_F
:
7495 case DSC__K_DTYPE_D
:
7496 case DSC__K_DTYPE_FC
:
7497 case DSC__K_DTYPE_DC
:
7498 case DSC__K_DTYPE_T
:
7499 case DSC__K_DTYPE_NU
:
7500 case DSC__K_DTYPE_NL
:
7501 case DSC__K_DTYPE_NLO
:
7502 case DSC__K_DTYPE_NR
:
7503 case DSC__K_DTYPE_NRO
:
7504 case DSC__K_DTYPE_NZ
:
7505 case DSC__K_DTYPE_P
:
7506 case DSC__K_DTYPE_ZI
:
7507 case DSC__K_DTYPE_ZEM
:
7508 case DSC__K_DTYPE_DSC
:
7509 case DSC__K_DTYPE_OU
:
7510 case DSC__K_DTYPE_O
:
7511 case DSC__K_DTYPE_G
:
7512 case DSC__K_DTYPE_H
:
7513 case DSC__K_DTYPE_GC
:
7514 case DSC__K_DTYPE_HC
:
7515 case DSC__K_DTYPE_CIT
:
7516 case DSC__K_DTYPE_BPV
:
7517 case DSC__K_DTYPE_BLV
:
7518 case DSC__K_DTYPE_VU
:
7519 case DSC__K_DTYPE_ADT
:
7520 case DSC__K_DTYPE_VT
:
7521 case DSC__K_DTYPE_T2
:
7522 case DSC__K_DTYPE_VT2
:
7523 fprintf (file
, _("standard data: %s\n"),
7524 evax_bfd_get_dsc_name (type
));
7525 evax_bfd_print_valspec (buf
, len
, 4, file
);
7527 fprintf (file
, _(" name: %.*s\n"),
7528 buf
[5] > len
- 6 ? len
- 6 : buf
[5], buf
+ 6);
7532 struct vms_dst_modbeg
*dst
= (void *)buf
;
7533 unsigned char *name
= buf
+ sizeof (*dst
);
7535 fprintf (file
, _("modbeg\n"));
7536 if (len
< sizeof (*dst
))
7538 /* xgettext:c-format */
7539 fprintf (file
, _(" flags: %d, language: %u, "
7540 "major: %u, minor: %u\n"),
7542 (unsigned)bfd_getl32 (dst
->language
),
7543 (unsigned)bfd_getl16 (dst
->major
),
7544 (unsigned)bfd_getl16 (dst
->minor
));
7545 len
-= sizeof (*dst
);
7549 fprintf (file
, _(" module name: %.*s\n"),
7550 name
[0] > nlen
? nlen
: name
[0], name
+ 1);
7554 name
+= name
[0] + 1;
7556 fprintf (file
, _(" compiler : %.*s\n"),
7557 name
[0] > nlen
? nlen
: name
[0], name
+ 1);
7563 fprintf (file
, _("modend\n"));
7567 struct vms_dst_rtnbeg
*dst
= (void *)buf
;
7568 unsigned char *name
= buf
+ sizeof (*dst
);
7570 fputs (_("rtnbeg\n"), file
);
7571 if (len
>= sizeof (*dst
))
7573 /* xgettext:c-format */
7574 fprintf (file
, _(" flags: %u, address: 0x%08x, "
7575 "pd-address: 0x%08x\n"),
7577 (unsigned) bfd_getl32 (dst
->address
),
7578 (unsigned) bfd_getl32 (dst
->pd_address
));
7579 len
-= sizeof (*dst
);
7583 fprintf (file
, _(" routine name: %.*s\n"),
7584 name
[0] > nlen
? nlen
: name
[0], name
+ 1);
7591 struct vms_dst_rtnend
*dst
= (void *)buf
;
7593 if (len
>= sizeof (*dst
))
7594 fprintf (file
, _("rtnend: size 0x%08x\n"),
7595 (unsigned) bfd_getl32 (dst
->size
));
7600 struct vms_dst_prolog
*dst
= (void *)buf
;
7602 if (len
>= sizeof (*dst
))
7603 /* xgettext:c-format */
7604 fprintf (file
, _("prolog: bkpt address 0x%08x\n"),
7605 (unsigned) bfd_getl32 (dst
->bkpt_addr
));
7610 struct vms_dst_epilog
*dst
= (void *)buf
;
7612 if (len
>= sizeof (*dst
))
7613 /* xgettext:c-format */
7614 fprintf (file
, _("epilog: flags: %u, count: %u\n"),
7615 dst
->flags
, (unsigned) bfd_getl32 (dst
->count
));
7620 struct vms_dst_blkbeg
*dst
= (void *)buf
;
7621 unsigned char *name
= buf
+ sizeof (*dst
);
7623 if (len
> sizeof (*dst
))
7626 len
-= sizeof (*dst
);
7628 /* xgettext:c-format */
7629 fprintf (file
, _("blkbeg: address: 0x%08x, name: %.*s\n"),
7630 (unsigned) bfd_getl32 (dst
->address
),
7631 name
[0] > nlen
? nlen
: name
[0], name
+ 1);
7637 struct vms_dst_blkend
*dst
= (void *)buf
;
7639 if (len
>= sizeof (*dst
))
7640 /* xgettext:c-format */
7641 fprintf (file
, _("blkend: size: 0x%08x\n"),
7642 (unsigned) bfd_getl32 (dst
->size
));
7645 case DST__K_TYPSPEC
:
7647 fprintf (file
, _("typspec (len: %u)\n"), len
);
7651 fprintf (file
, _(" name: %.*s\n"),
7652 buf
[0] > nlen
? nlen
: buf
[0], buf
+ 1);
7654 evax_bfd_print_typspec (buf
+ 1 + buf
[0], len
- (1 + buf
[0]),
7663 fprintf (file
, _("septyp, name: %.*s\n"),
7664 buf
[5] > len
- 6 ? len
- 6 : buf
[5], buf
+ 6);
7665 evax_bfd_print_valspec (buf
, len
, 4, file
);
7671 struct vms_dst_recbeg
*recbeg
= (void *)buf
;
7672 unsigned char *name
= buf
+ sizeof (*recbeg
);
7674 if (len
> sizeof (*recbeg
))
7676 int nlen
= len
- sizeof (*recbeg
) - 1;
7679 fprintf (file
, _("recbeg: name: %.*s\n"), nlen
, name
+ 1);
7680 evax_bfd_print_valspec (buf
, len
, 4, file
);
7683 fprintf (file
, _(" len: %u bits\n"),
7684 (unsigned) bfd_getl32 (name
+ 1 + nlen
));
7689 fprintf (file
, _("recend\n"));
7691 case DST__K_ENUMBEG
:
7693 /* xgettext:c-format */
7694 fprintf (file
, _("enumbeg, len: %u, name: %.*s\n"),
7695 buf
[0], buf
[1] > len
- 2 ? len
- 2 : buf
[1], buf
+ 2);
7697 case DST__K_ENUMELT
:
7700 fprintf (file
, _("enumelt, name: %.*s\n"),
7701 buf
[5] > len
- 6 ? len
- 6 : buf
[5], buf
+ 6);
7702 evax_bfd_print_valspec (buf
, len
, 4, file
);
7705 case DST__K_ENUMEND
:
7706 fprintf (file
, _("enumend\n"));
7710 struct vms_dst_label
*lab
= (void *)buf
;
7711 if (len
>= sizeof (*lab
))
7713 fprintf (file
, _("label, name: %.*s\n"),
7714 lab
->name
[0] > len
- 1 ? len
- 1 : lab
->name
[0],
7716 fprintf (file
, _(" address: 0x%08x\n"),
7717 (unsigned) bfd_getl32 (lab
->value
));
7721 case DST__K_DIS_RANGE
:
7724 unsigned int cnt
= bfd_getl32 (buf
);
7725 unsigned char *rng
= buf
+ 4;
7728 fprintf (file
, _("discontiguous range (nbr: %u)\n"), cnt
);
7730 for (i
= 0; i
< cnt
; i
++, rng
+= 8)
7734 /* xgettext:c-format */
7735 fprintf (file
, _(" address: 0x%08x, size: %u\n"),
7736 (unsigned) bfd_getl32 (rng
),
7737 (unsigned) bfd_getl32 (rng
+ 4));
7742 case DST__K_LINE_NUM
:
7744 unsigned char *buf_orig
= buf
;
7746 fprintf (file
, _("line num (len: %u)\n"), len
);
7761 case DST__K_DELTA_PC_W
:
7764 val
= bfd_getl16 (buf
);
7765 fprintf (file
, _("delta_pc_w %u\n"), val
);
7770 case DST__K_INCR_LINUM
:
7774 fprintf (file
, _("incr_linum(b): +%u\n"), val
);
7778 case DST__K_INCR_LINUM_W
:
7781 val
= bfd_getl16 (buf
);
7782 fprintf (file
, _("incr_linum_w: +%u\n"), val
);
7786 case DST__K_INCR_LINUM_L
:
7789 val
= bfd_getl32 (buf
);
7790 fprintf (file
, _("incr_linum_l: +%u\n"), val
);
7794 case DST__K_SET_LINUM
:
7797 line
= bfd_getl16 (buf
);
7798 fprintf (file
, _("set_line_num(w) %u\n"), line
);
7801 case DST__K_SET_LINUM_B
:
7805 fprintf (file
, _("set_line_num_b %u\n"), line
);
7808 case DST__K_SET_LINUM_L
:
7811 line
= bfd_getl32 (buf
);
7812 fprintf (file
, _("set_line_num_l %u\n"), line
);
7815 case DST__K_SET_ABS_PC
:
7818 pc
= bfd_getl32 (buf
);
7819 fprintf (file
, _("set_abs_pc: 0x%08x\n"), pc
);
7822 case DST__K_DELTA_PC_L
:
7825 fprintf (file
, _("delta_pc_l: +0x%08x\n"),
7826 (unsigned) bfd_getl32 (buf
));
7832 fprintf (file
, _("term(b): 0x%02x"), *buf
);
7834 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7840 val
= bfd_getl16 (buf
);
7841 fprintf (file
, _("term_w: 0x%04x"), val
);
7843 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7849 fprintf (file
, _("delta pc +%-4d"), -cmd
);
7850 line
++; /* FIXME: curr increment. */
7852 /* xgettext:c-format */
7853 fprintf (file
, _(" pc: 0x%08x line: %5u\n"),
7858 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7871 unsigned char *buf_orig
= buf
;
7873 fprintf (file
, _("source (len: %u)\n"), len
);
7883 case DST__K_SRC_DECLFILE
:
7885 struct vms_dst_src_decl_src
*src
= (void *) buf
;
7886 unsigned char *name
;
7889 if (len
< sizeof (*src
))
7891 /* xgettext:c-format */
7892 fprintf (file
, _(" declfile: len: %u, flags: %u, "
7894 src
->length
, src
->flags
,
7895 (unsigned)bfd_getl16 (src
->fileid
));
7896 /* xgettext:c-format */
7897 fprintf (file
, _(" rms: cdt: 0x%08x %08x, "
7898 "ebk: 0x%08x, ffb: 0x%04x, "
7900 (unsigned)bfd_getl32 (src
->rms_cdt
+ 4),
7901 (unsigned)bfd_getl32 (src
->rms_cdt
+ 0),
7902 (unsigned)bfd_getl32 (src
->rms_ebk
),
7903 (unsigned)bfd_getl16 (src
->rms_ffb
),
7905 if (src
->length
> len
|| src
->length
<= sizeof (*src
))
7907 nlen
= src
->length
- sizeof (*src
) - 1;
7908 name
= buf
+ sizeof (*src
);
7909 fprintf (file
, _(" filename : %.*s\n"),
7910 name
[0] > nlen
? nlen
: name
[0], name
+ 1);
7911 if (name
[0] >= nlen
)
7913 nlen
-= name
[0] + 1;
7914 name
+= name
[0] + 1;
7915 fprintf (file
, _(" module name: %.*s\n"),
7916 name
[0] > nlen
? nlen
: name
[0], name
+ 1);
7919 cmdlen
= src
->length
;
7922 case DST__K_SRC_SETFILE
:
7925 fprintf (file
, _(" setfile %u\n"),
7926 (unsigned) bfd_getl16 (buf
));
7929 case DST__K_SRC_SETREC_W
:
7932 fprintf (file
, _(" setrec %u\n"),
7933 (unsigned) bfd_getl16 (buf
));
7936 case DST__K_SRC_SETREC_L
:
7939 fprintf (file
, _(" setrec %u\n"),
7940 (unsigned) bfd_getl32 (buf
));
7943 case DST__K_SRC_SETLNUM_W
:
7946 fprintf (file
, _(" setlnum %u\n"),
7947 (unsigned) bfd_getl16 (buf
));
7950 case DST__K_SRC_SETLNUM_L
:
7953 fprintf (file
, _(" setlnum %u\n"),
7954 (unsigned) bfd_getl32 (buf
));
7957 case DST__K_SRC_DEFLINES_W
:
7960 fprintf (file
, _(" deflines %u\n"),
7961 (unsigned) bfd_getl16 (buf
));
7964 case DST__K_SRC_DEFLINES_B
:
7967 fprintf (file
, _(" deflines %u\n"), *buf
);
7970 case DST__K_SRC_FORMFEED
:
7971 fprintf (file
, _(" formfeed\n"));
7975 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7987 fprintf (file
, _("*unhandled* dst type %u\n"), type
);
7995 evax_bfd_print_image (bfd
*abfd
, FILE *file
)
7997 struct vms_eihd eihd
;
8000 unsigned int eiha_off
;
8001 unsigned int eihi_off
;
8002 unsigned int eihs_off
;
8003 unsigned int eisd_off
;
8004 unsigned int eihef_off
= 0;
8005 unsigned int eihnp_off
= 0;
8006 unsigned int dmt_vbn
= 0;
8007 unsigned int dmt_size
= 0;
8008 unsigned int dst_vbn
= 0;
8009 unsigned int dst_size
= 0;
8010 unsigned int gst_vbn
= 0;
8011 unsigned int gst_size
= 0;
8012 unsigned int eiaf_vbn
= 0;
8013 unsigned int eiaf_size
= 0;
8014 unsigned int eihvn_off
;
8016 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
)
8017 || bfd_bread (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
8019 fprintf (file
, _("cannot read EIHD\n"));
8022 /* xgettext:c-format */
8023 fprintf (file
, _("EIHD: (size: %u, nbr blocks: %u)\n"),
8024 (unsigned)bfd_getl32 (eihd
.size
),
8025 (unsigned)bfd_getl32 (eihd
.hdrblkcnt
));
8026 /* xgettext:c-format */
8027 fprintf (file
, _(" majorid: %u, minorid: %u\n"),
8028 (unsigned)bfd_getl32 (eihd
.majorid
),
8029 (unsigned)bfd_getl32 (eihd
.minorid
));
8031 val
= (unsigned)bfd_getl32 (eihd
.imgtype
);
8035 name
= _("executable");
8038 name
= _("linkable image");
8041 name
= _("unknown");
8044 /* xgettext:c-format */
8045 fprintf (file
, _(" image type: %u (%s)"), val
, name
);
8047 val
= (unsigned)bfd_getl32 (eihd
.subtype
);
8050 case EIHD__C_NATIVE
:
8057 name
= _("unknown");
8060 /* xgettext:c-format */
8061 fprintf (file
, _(", subtype: %u (%s)\n"), val
, name
);
8063 eisd_off
= bfd_getl32 (eihd
.isdoff
);
8064 eiha_off
= bfd_getl32 (eihd
.activoff
);
8065 eihi_off
= bfd_getl32 (eihd
.imgidoff
);
8066 eihs_off
= bfd_getl32 (eihd
.symdbgoff
);
8067 /* xgettext:c-format */
8068 fprintf (file
, _(" offsets: isd: %u, activ: %u, symdbg: %u, "
8069 "imgid: %u, patch: %u\n"),
8070 eisd_off
, eiha_off
, eihs_off
, eihi_off
,
8071 (unsigned)bfd_getl32 (eihd
.patchoff
));
8072 fprintf (file
, _(" fixup info rva: "));
8073 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.iafva
));
8074 fprintf (file
, _(", symbol vector rva: "));
8075 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.symvva
));
8076 eihvn_off
= bfd_getl32 (eihd
.version_array_off
);
8077 fprintf (file
, _("\n"
8078 " version array off: %u\n"),
8081 /* xgettext:c-format */
8082 _(" img I/O count: %u, nbr channels: %u, req pri: %08x%08x\n"),
8083 (unsigned)bfd_getl32 (eihd
.imgiocnt
),
8084 (unsigned)bfd_getl32 (eihd
.iochancnt
),
8085 (unsigned)bfd_getl32 (eihd
.privreqs
+ 4),
8086 (unsigned)bfd_getl32 (eihd
.privreqs
+ 0));
8087 val
= (unsigned)bfd_getl32 (eihd
.lnkflags
);
8088 fprintf (file
, _(" linker flags: %08x:"), val
);
8089 if (val
& EIHD__M_LNKDEBUG
)
8090 fprintf (file
, " LNKDEBUG");
8091 if (val
& EIHD__M_LNKNOTFR
)
8092 fprintf (file
, " LNKNOTFR");
8093 if (val
& EIHD__M_NOP0BUFS
)
8094 fprintf (file
, " NOP0BUFS");
8095 if (val
& EIHD__M_PICIMG
)
8096 fprintf (file
, " PICIMG");
8097 if (val
& EIHD__M_P0IMAGE
)
8098 fprintf (file
, " P0IMAGE");
8099 if (val
& EIHD__M_DBGDMT
)
8100 fprintf (file
, " DBGDMT");
8101 if (val
& EIHD__M_INISHR
)
8102 fprintf (file
, " INISHR");
8103 if (val
& EIHD__M_XLATED
)
8104 fprintf (file
, " XLATED");
8105 if (val
& EIHD__M_BIND_CODE_SEC
)
8106 fprintf (file
, " BIND_CODE_SEC");
8107 if (val
& EIHD__M_BIND_DATA_SEC
)
8108 fprintf (file
, " BIND_DATA_SEC");
8109 if (val
& EIHD__M_MKTHREADS
)
8110 fprintf (file
, " MKTHREADS");
8111 if (val
& EIHD__M_UPCALLS
)
8112 fprintf (file
, " UPCALLS");
8113 if (val
& EIHD__M_OMV_READY
)
8114 fprintf (file
, " OMV_READY");
8115 if (val
& EIHD__M_EXT_BIND_SECT
)
8116 fprintf (file
, " EXT_BIND_SECT");
8117 fprintf (file
, "\n");
8118 /* xgettext:c-format */
8119 fprintf (file
, _(" ident: 0x%08x, sysver: 0x%08x, "
8120 "match ctrl: %u, symvect_size: %u\n"),
8121 (unsigned)bfd_getl32 (eihd
.ident
),
8122 (unsigned)bfd_getl32 (eihd
.sysver
),
8124 (unsigned)bfd_getl32 (eihd
.symvect_size
));
8125 fprintf (file
, _(" BPAGE: %u"),
8126 (unsigned)bfd_getl32 (eihd
.virt_mem_block_size
));
8127 if (val
& (EIHD__M_OMV_READY
| EIHD__M_EXT_BIND_SECT
))
8129 eihef_off
= bfd_getl32 (eihd
.ext_fixup_off
);
8130 eihnp_off
= bfd_getl32 (eihd
.noopt_psect_off
);
8131 /* xgettext:c-format */
8132 fprintf (file
, _(", ext fixup offset: %u, no_opt psect off: %u"),
8133 eihef_off
, eihnp_off
);
8135 fprintf (file
, _(", alias: %u\n"), (unsigned)bfd_getl16 (eihd
.alias
));
8139 struct vms_eihvn eihvn
;
8143 fprintf (file
, _("system version array information:\n"));
8144 if (bfd_seek (abfd
, (file_ptr
) eihvn_off
, SEEK_SET
)
8145 || bfd_bread (&eihvn
, sizeof (eihvn
), abfd
) != sizeof (eihvn
))
8147 fprintf (file
, _("cannot read EIHVN header\n"));
8150 mask
= bfd_getl32 (eihvn
.subsystem_mask
);
8151 for (j
= 0; j
< 32; j
++)
8152 if (mask
& (1u << j
))
8154 struct vms_eihvn_subversion ver
;
8155 if (bfd_bread (&ver
, sizeof (ver
), abfd
) != sizeof (ver
))
8157 fprintf (file
, _("cannot read EIHVN version\n"));
8160 fprintf (file
, _(" %02u "), j
);
8163 case EIHVN__BASE_IMAGE_BIT
:
8164 fputs (_("BASE_IMAGE "), file
);
8166 case EIHVN__MEMORY_MANAGEMENT_BIT
:
8167 fputs (_("MEMORY_MANAGEMENT"), file
);
8170 fputs (_("IO "), file
);
8172 case EIHVN__FILES_VOLUMES_BIT
:
8173 fputs (_("FILES_VOLUMES "), file
);
8175 case EIHVN__PROCESS_SCHED_BIT
:
8176 fputs (_("PROCESS_SCHED "), file
);
8178 case EIHVN__SYSGEN_BIT
:
8179 fputs (_("SYSGEN "), file
);
8181 case EIHVN__CLUSTERS_LOCKMGR_BIT
:
8182 fputs (_("CLUSTERS_LOCKMGR "), file
);
8184 case EIHVN__LOGICAL_NAMES_BIT
:
8185 fputs (_("LOGICAL_NAMES "), file
);
8187 case EIHVN__SECURITY_BIT
:
8188 fputs (_("SECURITY "), file
);
8190 case EIHVN__IMAGE_ACTIVATOR_BIT
:
8191 fputs (_("IMAGE_ACTIVATOR "), file
);
8193 case EIHVN__NETWORKS_BIT
:
8194 fputs (_("NETWORKS "), file
);
8196 case EIHVN__COUNTERS_BIT
:
8197 fputs (_("COUNTERS "), file
);
8199 case EIHVN__STABLE_BIT
:
8200 fputs (_("STABLE "), file
);
8202 case EIHVN__MISC_BIT
:
8203 fputs (_("MISC "), file
);
8205 case EIHVN__CPU_BIT
:
8206 fputs (_("CPU "), file
);
8208 case EIHVN__VOLATILE_BIT
:
8209 fputs (_("VOLATILE "), file
);
8211 case EIHVN__SHELL_BIT
:
8212 fputs (_("SHELL "), file
);
8214 case EIHVN__POSIX_BIT
:
8215 fputs (_("POSIX "), file
);
8217 case EIHVN__MULTI_PROCESSING_BIT
:
8218 fputs (_("MULTI_PROCESSING "), file
);
8220 case EIHVN__GALAXY_BIT
:
8221 fputs (_("GALAXY "), file
);
8224 fputs (_("*unknown* "), file
);
8227 fprintf (file
, ": %u.%u\n",
8228 (unsigned)bfd_getl16 (ver
.major
),
8229 (unsigned)bfd_getl16 (ver
.minor
));
8235 struct vms_eiha eiha
;
8237 if (bfd_seek (abfd
, (file_ptr
) eiha_off
, SEEK_SET
)
8238 || bfd_bread (&eiha
, sizeof (eiha
), abfd
) != sizeof (eiha
))
8240 fprintf (file
, _("cannot read EIHA\n"));
8243 fprintf (file
, _("Image activation: (size=%u)\n"),
8244 (unsigned)bfd_getl32 (eiha
.size
));
8245 /* xgettext:c-format */
8246 fprintf (file
, _(" First address : 0x%08x 0x%08x\n"),
8247 (unsigned)bfd_getl32 (eiha
.tfradr1_h
),
8248 (unsigned)bfd_getl32 (eiha
.tfradr1
));
8249 /* xgettext:c-format */
8250 fprintf (file
, _(" Second address: 0x%08x 0x%08x\n"),
8251 (unsigned)bfd_getl32 (eiha
.tfradr2_h
),
8252 (unsigned)bfd_getl32 (eiha
.tfradr2
));
8253 /* xgettext:c-format */
8254 fprintf (file
, _(" Third address : 0x%08x 0x%08x\n"),
8255 (unsigned)bfd_getl32 (eiha
.tfradr3_h
),
8256 (unsigned)bfd_getl32 (eiha
.tfradr3
));
8257 /* xgettext:c-format */
8258 fprintf (file
, _(" Fourth address: 0x%08x 0x%08x\n"),
8259 (unsigned)bfd_getl32 (eiha
.tfradr4_h
),
8260 (unsigned)bfd_getl32 (eiha
.tfradr4
));
8261 /* xgettext:c-format */
8262 fprintf (file
, _(" Shared image : 0x%08x 0x%08x\n"),
8263 (unsigned)bfd_getl32 (eiha
.inishr_h
),
8264 (unsigned)bfd_getl32 (eiha
.inishr
));
8268 struct vms_eihi eihi
;
8270 if (bfd_seek (abfd
, (file_ptr
) eihi_off
, SEEK_SET
)
8271 || bfd_bread (&eihi
, sizeof (eihi
), abfd
) != sizeof (eihi
))
8273 fprintf (file
, _("cannot read EIHI\n"));
8276 /* xgettext:c-format */
8277 fprintf (file
, _("Image identification: (major: %u, minor: %u)\n"),
8278 (unsigned)bfd_getl32 (eihi
.majorid
),
8279 (unsigned)bfd_getl32 (eihi
.minorid
));
8280 fprintf (file
, _(" image name : %.*s\n"),
8281 eihi
.imgnam
[0], eihi
.imgnam
+ 1);
8282 fprintf (file
, _(" link time : %s\n"),
8283 vms_time_to_str (eihi
.linktime
));
8284 fprintf (file
, _(" image ident : %.*s\n"),
8285 eihi
.imgid
[0], eihi
.imgid
+ 1);
8286 fprintf (file
, _(" linker ident : %.*s\n"),
8287 eihi
.linkid
[0], eihi
.linkid
+ 1);
8288 fprintf (file
, _(" image build ident: %.*s\n"),
8289 eihi
.imgbid
[0], eihi
.imgbid
+ 1);
8293 struct vms_eihs eihs
;
8295 if (bfd_seek (abfd
, (file_ptr
) eihs_off
, SEEK_SET
)
8296 || bfd_bread (&eihs
, sizeof (eihs
), abfd
) != sizeof (eihs
))
8298 fprintf (file
, _("cannot read EIHS\n"));
8301 /* xgettext:c-format */
8302 fprintf (file
, _("Image symbol & debug table: (major: %u, minor: %u)\n"),
8303 (unsigned)bfd_getl32 (eihs
.majorid
),
8304 (unsigned)bfd_getl32 (eihs
.minorid
));
8305 dst_vbn
= bfd_getl32 (eihs
.dstvbn
);
8306 dst_size
= bfd_getl32 (eihs
.dstsize
);
8307 /* xgettext:c-format */
8308 fprintf (file
, _(" debug symbol table : vbn: %u, size: %u (0x%x)\n"),
8309 dst_vbn
, dst_size
, dst_size
);
8310 gst_vbn
= bfd_getl32 (eihs
.gstvbn
);
8311 gst_size
= bfd_getl32 (eihs
.gstsize
);
8312 /* xgettext:c-format */
8313 fprintf (file
, _(" global symbol table: vbn: %u, records: %u\n"),
8315 dmt_vbn
= bfd_getl32 (eihs
.dmtvbn
);
8316 dmt_size
= bfd_getl32 (eihs
.dmtsize
);
8317 /* xgettext:c-format */
8318 fprintf (file
, _(" debug module table : vbn: %u, size: %u\n"),
8321 while (eisd_off
!= 0)
8323 struct vms_eisd eisd
;
8328 if (bfd_seek (abfd
, (file_ptr
) eisd_off
, SEEK_SET
)
8329 || bfd_bread (&eisd
, sizeof (eisd
), abfd
) != sizeof (eisd
))
8331 fprintf (file
, _("cannot read EISD\n"));
8334 len
= (unsigned)bfd_getl32 (eisd
.eisdsize
);
8335 if (len
!= (unsigned)-1)
8339 eisd_off
= (eisd_off
+ VMS_BLOCK_SIZE
) & ~(VMS_BLOCK_SIZE
- 1);
8341 /* xgettext:c-format */
8342 fprintf (file
, _("Image section descriptor: (major: %u, minor: %u, "
8343 "size: %u, offset: %u)\n"),
8344 (unsigned)bfd_getl32 (eisd
.majorid
),
8345 (unsigned)bfd_getl32 (eisd
.minorid
),
8349 /* xgettext:c-format */
8350 fprintf (file
, _(" section: base: 0x%08x%08x size: 0x%08x\n"),
8351 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 4),
8352 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 0),
8353 (unsigned)bfd_getl32 (eisd
.secsize
));
8354 val
= (unsigned)bfd_getl32 (eisd
.flags
);
8355 fprintf (file
, _(" flags: 0x%04x"), val
);
8356 if (val
& EISD__M_GBL
)
8357 fprintf (file
, " GBL");
8358 if (val
& EISD__M_CRF
)
8359 fprintf (file
, " CRF");
8360 if (val
& EISD__M_DZRO
)
8361 fprintf (file
, " DZRO");
8362 if (val
& EISD__M_WRT
)
8363 fprintf (file
, " WRT");
8364 if (val
& EISD__M_INITALCODE
)
8365 fprintf (file
, " INITALCODE");
8366 if (val
& EISD__M_BASED
)
8367 fprintf (file
, " BASED");
8368 if (val
& EISD__M_FIXUPVEC
)
8369 fprintf (file
, " FIXUPVEC");
8370 if (val
& EISD__M_RESIDENT
)
8371 fprintf (file
, " RESIDENT");
8372 if (val
& EISD__M_VECTOR
)
8373 fprintf (file
, " VECTOR");
8374 if (val
& EISD__M_PROTECT
)
8375 fprintf (file
, " PROTECT");
8376 if (val
& EISD__M_LASTCLU
)
8377 fprintf (file
, " LASTCLU");
8378 if (val
& EISD__M_EXE
)
8379 fprintf (file
, " EXE");
8380 if (val
& EISD__M_NONSHRADR
)
8381 fprintf (file
, " NONSHRADR");
8382 if (val
& EISD__M_QUAD_LENGTH
)
8383 fprintf (file
, " QUAD_LENGTH");
8384 if (val
& EISD__M_ALLOC_64BIT
)
8385 fprintf (file
, " ALLOC_64BIT");
8386 fprintf (file
, "\n");
8387 if (val
& EISD__M_FIXUPVEC
)
8389 eiaf_vbn
= bfd_getl32 (eisd
.vbn
);
8390 eiaf_size
= bfd_getl32 (eisd
.secsize
);
8392 /* xgettext:c-format */
8393 fprintf (file
, _(" vbn: %u, pfc: %u, matchctl: %u type: %u ("),
8394 (unsigned)bfd_getl32 (eisd
.vbn
),
8395 eisd
.pfc
, eisd
.matchctl
, eisd
.type
);
8398 case EISD__K_NORMAL
:
8399 fputs (_("NORMAL"), file
);
8401 case EISD__K_SHRFXD
:
8402 fputs (_("SHRFXD"), file
);
8404 case EISD__K_PRVFXD
:
8405 fputs (_("PRVFXD"), file
);
8407 case EISD__K_SHRPIC
:
8408 fputs (_("SHRPIC"), file
);
8410 case EISD__K_PRVPIC
:
8411 fputs (_("PRVPIC"), file
);
8413 case EISD__K_USRSTACK
:
8414 fputs (_("USRSTACK"), file
);
8417 fputs (_("*unknown*"), file
);
8420 fputs (_(")\n"), file
);
8421 if (val
& EISD__M_GBL
)
8422 /* xgettext:c-format */
8423 fprintf (file
, _(" ident: 0x%08x, name: %.*s\n"),
8424 (unsigned)bfd_getl32 (eisd
.ident
),
8425 eisd
.gblnam
[0], eisd
.gblnam
+ 1);
8431 if (bfd_seek (abfd
, (file_ptr
) (dmt_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
8433 fprintf (file
, _("cannot read DMT\n"));
8437 fprintf (file
, _("Debug module table:\n"));
8439 while (dmt_size
> 0)
8441 struct vms_dmt_header dmth
;
8444 if (bfd_bread (&dmth
, sizeof (dmth
), abfd
) != sizeof (dmth
))
8446 fprintf (file
, _("cannot read DMT header\n"));
8449 count
= bfd_getl16 (dmth
.psect_count
);
8451 /* xgettext:c-format */
8452 _(" module offset: 0x%08x, size: 0x%08x, (%u psects)\n"),
8453 (unsigned)bfd_getl32 (dmth
.modbeg
),
8454 (unsigned)bfd_getl32 (dmth
.size
), count
);
8455 dmt_size
-= sizeof (dmth
);
8458 struct vms_dmt_psect dmtp
;
8460 if (bfd_bread (&dmtp
, sizeof (dmtp
), abfd
) != sizeof (dmtp
))
8462 fprintf (file
, _("cannot read DMT psect\n"));
8465 /* xgettext:c-format */
8466 fprintf (file
, _(" psect start: 0x%08x, length: %u\n"),
8467 (unsigned)bfd_getl32 (dmtp
.start
),
8468 (unsigned)bfd_getl32 (dmtp
.length
));
8470 dmt_size
-= sizeof (dmtp
);
8477 if (bfd_seek (abfd
, (file_ptr
) (dst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
8479 fprintf (file
, _("cannot read DST\n"));
8483 evax_bfd_print_dst (abfd
, dst_size
, file
);
8487 if (bfd_seek (abfd
, (file_ptr
) (gst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
8489 fprintf (file
, _("cannot read GST\n"));
8493 fprintf (file
, _("Global symbol table:\n"));
8494 evax_bfd_print_eobj (abfd
, file
);
8496 if (eiaf_vbn
!= 0 && eiaf_size
>= sizeof (struct vms_eiaf
))
8499 struct vms_eiaf
*eiaf
;
8500 unsigned int qrelfixoff
;
8501 unsigned int lrelfixoff
;
8502 unsigned int qdotadroff
;
8503 unsigned int ldotadroff
;
8504 unsigned int shrimgcnt
;
8505 unsigned int shlstoff
;
8506 unsigned int codeadroff
;
8507 unsigned int lpfixoff
;
8508 unsigned int chgprtoff
;
8509 file_ptr f_off
= (file_ptr
) (eiaf_vbn
- 1) * VMS_BLOCK_SIZE
;
8511 if (bfd_seek (abfd
, f_off
, SEEK_SET
) != 0
8512 || (buf
= _bfd_malloc_and_read (abfd
, eiaf_size
, eiaf_size
)) == NULL
)
8514 fprintf (file
, _("cannot read EIHA\n"));
8517 eiaf
= (struct vms_eiaf
*)buf
;
8519 /* xgettext:c-format */
8520 _("Image activator fixup: (major: %u, minor: %u)\n"),
8521 (unsigned)bfd_getl32 (eiaf
->majorid
),
8522 (unsigned)bfd_getl32 (eiaf
->minorid
));
8523 /* xgettext:c-format */
8524 fprintf (file
, _(" iaflink : 0x%08x %08x\n"),
8525 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 0),
8526 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 4));
8527 /* xgettext:c-format */
8528 fprintf (file
, _(" fixuplnk: 0x%08x %08x\n"),
8529 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 0),
8530 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 4));
8531 fprintf (file
, _(" size : %u\n"),
8532 (unsigned)bfd_getl32 (eiaf
->size
));
8533 fprintf (file
, _(" flags: 0x%08x\n"),
8534 (unsigned)bfd_getl32 (eiaf
->flags
));
8535 qrelfixoff
= bfd_getl32 (eiaf
->qrelfixoff
);
8536 lrelfixoff
= bfd_getl32 (eiaf
->lrelfixoff
);
8537 /* xgettext:c-format */
8538 fprintf (file
, _(" qrelfixoff: %5u, lrelfixoff: %5u\n"),
8539 qrelfixoff
, lrelfixoff
);
8540 qdotadroff
= bfd_getl32 (eiaf
->qdotadroff
);
8541 ldotadroff
= bfd_getl32 (eiaf
->ldotadroff
);
8542 /* xgettext:c-format */
8543 fprintf (file
, _(" qdotadroff: %5u, ldotadroff: %5u\n"),
8544 qdotadroff
, ldotadroff
);
8545 codeadroff
= bfd_getl32 (eiaf
->codeadroff
);
8546 lpfixoff
= bfd_getl32 (eiaf
->lpfixoff
);
8547 /* xgettext:c-format */
8548 fprintf (file
, _(" codeadroff: %5u, lpfixoff : %5u\n"),
8549 codeadroff
, lpfixoff
);
8550 chgprtoff
= bfd_getl32 (eiaf
->chgprtoff
);
8551 fprintf (file
, _(" chgprtoff : %5u\n"), chgprtoff
);
8552 shrimgcnt
= bfd_getl32 (eiaf
->shrimgcnt
);
8553 shlstoff
= bfd_getl32 (eiaf
->shlstoff
);
8554 /* xgettext:c-format */
8555 fprintf (file
, _(" shlstoff : %5u, shrimgcnt : %5u\n"),
8556 shlstoff
, shrimgcnt
);
8557 /* xgettext:c-format */
8558 fprintf (file
, _(" shlextra : %5u, permctx : %5u\n"),
8559 (unsigned)bfd_getl32 (eiaf
->shlextra
),
8560 (unsigned)bfd_getl32 (eiaf
->permctx
));
8561 fprintf (file
, _(" base_va : 0x%08x\n"),
8562 (unsigned)bfd_getl32 (eiaf
->base_va
));
8563 fprintf (file
, _(" lppsbfixoff: %5u\n"),
8564 (unsigned)bfd_getl32 (eiaf
->lppsbfixoff
));
8570 fprintf (file
, _(" Shareable images:\n"));
8572 j
< shrimgcnt
&& shlstoff
<= eiaf_size
- sizeof (struct vms_shl
);
8573 j
++, shlstoff
+= sizeof (struct vms_shl
))
8575 struct vms_shl
*shl
= (struct vms_shl
*) (buf
+ shlstoff
);
8577 /* xgettext:c-format */
8578 _(" %u: size: %u, flags: 0x%02x, name: %.*s\n"),
8579 j
, shl
->size
, shl
->flags
,
8580 shl
->imgnam
[0], shl
->imgnam
+ 1);
8583 if (qrelfixoff
!= 0)
8585 fprintf (file
, _(" quad-word relocation fixups:\n"));
8586 evax_bfd_print_relocation_records (file
, buf
, eiaf_size
,
8589 if (lrelfixoff
!= 0)
8591 fprintf (file
, _(" long-word relocation fixups:\n"));
8592 evax_bfd_print_relocation_records (file
, buf
, eiaf_size
,
8595 if (qdotadroff
!= 0)
8597 fprintf (file
, _(" quad-word .address reference fixups:\n"));
8598 evax_bfd_print_address_fixups (file
, buf
, eiaf_size
, qdotadroff
);
8600 if (ldotadroff
!= 0)
8602 fprintf (file
, _(" long-word .address reference fixups:\n"));
8603 evax_bfd_print_address_fixups (file
, buf
, eiaf_size
, ldotadroff
);
8605 if (codeadroff
!= 0)
8607 fprintf (file
, _(" Code Address Reference Fixups:\n"));
8608 evax_bfd_print_reference_fixups (file
, buf
, eiaf_size
, codeadroff
);
8612 fprintf (file
, _(" Linkage Pairs Reference Fixups:\n"));
8613 evax_bfd_print_reference_fixups (file
, buf
, eiaf_size
, lpfixoff
);
8615 if (chgprtoff
&& chgprtoff
<= eiaf_size
- 4)
8617 unsigned int count
= (unsigned) bfd_getl32 (buf
+ chgprtoff
);
8620 fprintf (file
, _(" Change Protection (%u entries):\n"), count
);
8621 for (j
= 0, chgprtoff
+= 4;
8622 j
< count
&& chgprtoff
<= eiaf_size
- sizeof (struct vms_eicp
);
8623 j
++, chgprtoff
+= sizeof (struct vms_eicp
))
8625 struct vms_eicp
*eicp
= (struct vms_eicp
*) (buf
+ chgprtoff
);
8626 unsigned int prot
= bfd_getl32 (eicp
->newprt
);
8628 /* xgettext:c-format */
8629 _(" base: 0x%08x %08x, size: 0x%08x, prot: 0x%08x "),
8630 (unsigned) bfd_getl32 (eicp
->baseva
+ 4),
8631 (unsigned) bfd_getl32 (eicp
->baseva
+ 0),
8632 (unsigned) bfd_getl32 (eicp
->size
),
8633 (unsigned) bfd_getl32 (eicp
->newprt
));
8637 fprintf (file
, "NA");
8639 case PRT__C_RESERVED
:
8640 fprintf (file
, "RES");
8643 fprintf (file
, "KW");
8646 fprintf (file
, "KR");
8649 fprintf (file
, "UW");
8652 fprintf (file
, "EW");
8655 fprintf (file
, "ERKW");
8658 fprintf (file
, "ER");
8661 fprintf (file
, "SW");
8664 fprintf (file
, "SREW");
8667 fprintf (file
, "SRKW");
8670 fprintf (file
, "SR");
8673 fprintf (file
, "URSW");
8676 fprintf (file
, "UREW");
8679 fprintf (file
, "URKW");
8682 fprintf (file
, "UR");
8696 vms_bfd_print_private_bfd_data (bfd
*abfd
, void *ptr
)
8698 FILE *file
= (FILE *)ptr
;
8700 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
8701 evax_bfd_print_image (abfd
, file
);
8704 if (bfd_seek (abfd
, 0, SEEK_SET
))
8706 evax_bfd_print_eobj (abfd
, file
);
8713 /* Slurp ETIR/EDBG/ETBT VMS object records. */
8716 alpha_vms_read_sections_content (bfd
*abfd
, struct bfd_link_info
*info
)
8718 asection
*cur_section
;
8719 file_ptr cur_offset
;
8720 asection
*dst_section
;
8721 file_ptr dst_offset
;
8723 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
8729 dst_section
= PRIV (dst_section
);
8733 if (info
->strip
== strip_all
|| info
->strip
== strip_debugger
)
8735 /* Discard the DST section. */
8739 else if (dst_section
)
8741 dst_offset
= dst_section
->output_offset
;
8742 dst_section
= dst_section
->output_section
;
8751 type
= _bfd_vms_get_object_record (abfd
);
8754 vms_debug2 ((2, "next_record failed\n"));
8760 PRIV (image_section
) = cur_section
;
8761 PRIV (image_offset
) = cur_offset
;
8762 res
= _bfd_vms_slurp_etir (abfd
, info
);
8763 cur_section
= PRIV (image_section
);
8764 cur_offset
= PRIV (image_offset
);
8768 if (dst_section
== NULL
)
8770 PRIV (image_section
) = dst_section
;
8771 PRIV (image_offset
) = dst_offset
;
8772 res
= _bfd_vms_slurp_etir (abfd
, info
);
8773 dst_offset
= PRIV (image_offset
);
8782 vms_debug2 ((2, "slurp eobj type %d failed\n", type
));
8789 alpha_vms_sizeof_headers (bfd
*abfd ATTRIBUTE_UNUSED
,
8790 struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8795 /* Add a linkage pair fixup at address SECT + OFFSET to SHLIB. */
8798 alpha_vms_add_fixup_lp (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
8800 struct alpha_vms_shlib_el
*sl
;
8801 asection
*sect
= PRIV2 (src
, image_section
);
8802 file_ptr offset
= PRIV2 (src
, image_offset
);
8805 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8806 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8807 sl
->has_fixups
= true;
8808 p
= VEC_APPEND (sl
->lp
, bfd_vma
);
8811 *p
= sect
->output_section
->vma
+ sect
->output_offset
+ offset
;
8812 sect
->output_section
->flags
|= SEC_RELOC
;
8816 /* Add a code address fixup at address SECT + OFFSET to SHLIB. */
8819 alpha_vms_add_fixup_ca (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
8821 struct alpha_vms_shlib_el
*sl
;
8822 asection
*sect
= PRIV2 (src
, image_section
);
8823 file_ptr offset
= PRIV2 (src
, image_offset
);
8826 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8827 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8828 sl
->has_fixups
= true;
8829 p
= VEC_APPEND (sl
->ca
, bfd_vma
);
8832 *p
= sect
->output_section
->vma
+ sect
->output_offset
+ offset
;
8833 sect
->output_section
->flags
|= SEC_RELOC
;
8837 /* Add a quad word relocation fixup at address SECT + OFFSET to SHLIB. */
8840 alpha_vms_add_fixup_qr (struct bfd_link_info
*info
, bfd
*src
,
8841 bfd
*shlib
, bfd_vma vec
)
8843 struct alpha_vms_shlib_el
*sl
;
8844 struct alpha_vms_vma_ref
*r
;
8845 asection
*sect
= PRIV2 (src
, image_section
);
8846 file_ptr offset
= PRIV2 (src
, image_offset
);
8848 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8849 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8850 sl
->has_fixups
= true;
8851 r
= VEC_APPEND (sl
->qr
, struct alpha_vms_vma_ref
);
8854 r
->vma
= sect
->output_section
->vma
+ sect
->output_offset
+ offset
;
8856 sect
->output_section
->flags
|= SEC_RELOC
;
8861 alpha_vms_add_fixup_lr (struct bfd_link_info
*info ATTRIBUTE_UNUSED
,
8862 unsigned int shr ATTRIBUTE_UNUSED
,
8863 bfd_vma vec ATTRIBUTE_UNUSED
)
8865 /* Not yet supported. */
8869 /* Add relocation. FIXME: Not yet emitted. */
8872 alpha_vms_add_lw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8878 alpha_vms_add_qw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8883 static struct bfd_hash_entry
*
8884 alpha_vms_link_hash_newfunc (struct bfd_hash_entry
*entry
,
8885 struct bfd_hash_table
*table
,
8888 struct alpha_vms_link_hash_entry
*ret
=
8889 (struct alpha_vms_link_hash_entry
*) entry
;
8891 /* Allocate the structure if it has not already been allocated by a
8894 ret
= ((struct alpha_vms_link_hash_entry
*)
8895 bfd_hash_allocate (table
,
8896 sizeof (struct alpha_vms_link_hash_entry
)));
8900 /* Call the allocation method of the superclass. */
8901 ret
= ((struct alpha_vms_link_hash_entry
*)
8902 _bfd_link_hash_newfunc ((struct bfd_hash_entry
*) ret
,
8907 return (struct bfd_hash_entry
*) ret
;
8911 alpha_vms_bfd_link_hash_table_free (bfd
*abfd
)
8913 struct alpha_vms_link_hash_table
*t
;
8916 t
= (struct alpha_vms_link_hash_table
*) abfd
->link
.hash
;
8917 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8919 struct alpha_vms_shlib_el
*shlib
;
8921 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8922 free (&VEC_EL (shlib
->ca
, bfd_vma
, 0));
8923 free (&VEC_EL (shlib
->lp
, bfd_vma
, 0));
8924 free (&VEC_EL (shlib
->qr
, struct alpha_vms_vma_ref
, 0));
8926 free (&VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, 0));
8928 _bfd_generic_link_hash_table_free (abfd
);
8931 /* Create an Alpha/VMS link hash table. */
8933 static struct bfd_link_hash_table
*
8934 alpha_vms_bfd_link_hash_table_create (bfd
*abfd
)
8936 struct alpha_vms_link_hash_table
*ret
;
8937 size_t amt
= sizeof (struct alpha_vms_link_hash_table
);
8939 ret
= (struct alpha_vms_link_hash_table
*) bfd_malloc (amt
);
8942 if (!_bfd_link_hash_table_init (&ret
->root
, abfd
,
8943 alpha_vms_link_hash_newfunc
,
8944 sizeof (struct alpha_vms_link_hash_entry
)))
8950 VEC_INIT (ret
->shrlibs
);
8952 ret
->root
.hash_table_free
= alpha_vms_bfd_link_hash_table_free
;
8958 alpha_vms_link_add_object_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8962 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
8964 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
8965 struct alpha_vms_link_hash_entry
*h
;
8966 struct bfd_link_hash_entry
*h_root
;
8969 if (!alpha_vms_convert_symbol (abfd
, e
, &sym
))
8972 if ((e
->flags
& EGSY__V_DEF
) && abfd
->selective_search
)
8974 /* In selective_search mode, only add definition that are
8976 h
= (struct alpha_vms_link_hash_entry
*)bfd_link_hash_lookup
8977 (info
->hash
, sym
.name
, false, false, false);
8978 if (h
== NULL
|| h
->root
.type
!= bfd_link_hash_undefined
)
8984 h_root
= (struct bfd_link_hash_entry
*) h
;
8985 if (!_bfd_generic_link_add_one_symbol (info
, abfd
, sym
.name
, sym
.flags
,
8986 sym
.section
, sym
.value
, NULL
,
8987 false, false, &h_root
))
8989 h
= (struct alpha_vms_link_hash_entry
*) h_root
;
8991 if ((e
->flags
& EGSY__V_DEF
)
8993 && abfd
->xvec
== info
->output_bfd
->xvec
)
8997 if (abfd
->flags
& DYNAMIC
)
8999 struct alpha_vms_shlib_el
*shlib
;
9001 /* We do not want to include any of the sections in a dynamic
9002 object in the output file. See comment in elflink.c. */
9003 bfd_section_list_clear (abfd
);
9005 shlib
= VEC_APPEND (alpha_vms_link_hash (info
)->shrlibs
,
9006 struct alpha_vms_shlib_el
);
9010 VEC_INIT (shlib
->ca
);
9011 VEC_INIT (shlib
->lp
);
9012 VEC_INIT (shlib
->qr
);
9013 PRIV (shr_index
) = VEC_COUNT (alpha_vms_link_hash (info
)->shrlibs
) - 1;
9020 alpha_vms_link_add_archive_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
9023 struct bfd_link_hash_entry
**pundef
;
9024 struct bfd_link_hash_entry
**next_pundef
;
9026 /* We only accept VMS libraries. */
9027 if (info
->output_bfd
->xvec
!= abfd
->xvec
)
9029 bfd_set_error (bfd_error_wrong_format
);
9033 /* The archive_pass field in the archive itself is used to
9034 initialize PASS, since we may search the same archive multiple
9036 pass
= ++abfd
->archive_pass
;
9038 /* Look through the list of undefined symbols. */
9039 for (pundef
= &info
->hash
->undefs
; *pundef
!= NULL
; pundef
= next_pundef
)
9041 struct bfd_link_hash_entry
*h
;
9047 next_pundef
= &(*pundef
)->u
.undef
.next
;
9049 /* When a symbol is defined, it is not necessarily removed from
9051 if (h
->type
!= bfd_link_hash_undefined
9052 && h
->type
!= bfd_link_hash_common
)
9054 /* Remove this entry from the list, for general cleanliness
9055 and because we are going to look through the list again
9056 if we search any more libraries. We can't remove the
9057 entry if it is the tail, because that would lose any
9058 entries we add to the list later on. */
9059 if (*pundef
!= info
->hash
->undefs_tail
)
9061 *pundef
= *next_pundef
;
9062 next_pundef
= pundef
;
9067 /* Look for this symbol in the archive hash table. */
9068 symidx
= _bfd_vms_lib_find_symbol (abfd
, h
->root
.string
);
9069 if (symidx
== BFD_NO_MORE_SYMBOLS
)
9071 /* Nothing in this slot. */
9075 element
= bfd_get_elt_at_index (abfd
, symidx
);
9076 if (element
== NULL
)
9079 if (element
->archive_pass
== -1 || element
->archive_pass
== pass
)
9081 /* Next symbol if this archive is wrong or already handled. */
9085 if (! bfd_check_format (element
, bfd_object
))
9087 element
->archive_pass
= -1;
9091 orig_element
= element
;
9092 if (bfd_is_thin_archive (abfd
))
9094 element
= _bfd_vms_lib_get_imagelib_file (element
);
9095 if (element
== NULL
|| !bfd_check_format (element
, bfd_object
))
9097 orig_element
->archive_pass
= -1;
9102 /* Unlike the generic linker, we know that this element provides
9103 a definition for an undefined symbol and we know that we want
9104 to include it. We don't need to check anything. */
9105 if (!(*info
->callbacks
9106 ->add_archive_element
) (info
, element
, h
->root
.string
, &element
))
9108 if (!alpha_vms_link_add_object_symbols (element
, info
))
9111 orig_element
->archive_pass
= pass
;
9118 alpha_vms_bfd_link_add_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
9120 switch (bfd_get_format (abfd
))
9123 vms_debug2 ((2, "vms_link_add_symbols for object %s\n",
9125 return alpha_vms_link_add_object_symbols (abfd
, info
);
9128 vms_debug2 ((2, "vms_link_add_symbols for archive %s\n",
9130 return alpha_vms_link_add_archive_symbols (abfd
, info
);
9133 bfd_set_error (bfd_error_wrong_format
);
9139 alpha_vms_build_fixups (struct bfd_link_info
*info
)
9141 struct alpha_vms_link_hash_table
*t
= alpha_vms_link_hash (info
);
9142 unsigned char *content
;
9144 unsigned int sz
= 0;
9145 unsigned int lp_sz
= 0;
9146 unsigned int ca_sz
= 0;
9147 unsigned int qr_sz
= 0;
9148 unsigned int shrimg_cnt
= 0;
9149 unsigned int chgprt_num
= 0;
9150 unsigned int chgprt_sz
= 0;
9151 struct vms_eiaf
*eiaf
;
9155 /* Shared libraries. */
9156 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
9158 struct alpha_vms_shlib_el
*shlib
;
9160 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
9162 if (!shlib
->has_fixups
)
9167 if (VEC_COUNT (shlib
->ca
) > 0)
9169 /* Header + entries. */
9171 ca_sz
+= VEC_COUNT (shlib
->ca
) * 4;
9173 if (VEC_COUNT (shlib
->lp
) > 0)
9175 /* Header + entries. */
9177 lp_sz
+= VEC_COUNT (shlib
->lp
) * 4;
9179 if (VEC_COUNT (shlib
->qr
) > 0)
9181 /* Header + entries. */
9183 qr_sz
+= VEC_COUNT (shlib
->qr
) * 8;
9194 /* Finish now if there is no content. */
9195 if (ca_sz
+ lp_sz
+ qr_sz
== 0)
9198 /* Add an eicp entry for the fixup itself. */
9200 for (sec
= info
->output_bfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
9202 /* This isect could be made RO or EXE after relocations are applied. */
9203 if ((sec
->flags
& SEC_RELOC
) != 0
9204 && (sec
->flags
& (SEC_CODE
| SEC_READONLY
)) != 0)
9207 chgprt_sz
= 4 + chgprt_num
* sizeof (struct vms_eicp
);
9209 /* Allocate section content (round-up size) */
9210 sz
= sizeof (struct vms_eiaf
) + shrimg_cnt
* sizeof (struct vms_shl
)
9211 + ca_sz
+ lp_sz
+ qr_sz
+ chgprt_sz
;
9212 sz
= (sz
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
9213 content
= bfd_zalloc (info
->output_bfd
, sz
);
9214 if (content
== NULL
)
9217 sec
= alpha_vms_link_hash (info
)->fixup
;
9218 sec
->contents
= content
;
9221 eiaf
= (struct vms_eiaf
*)content
;
9222 off
= sizeof (struct vms_eiaf
);
9223 bfd_putl32 (0, eiaf
->majorid
);
9224 bfd_putl32 (0, eiaf
->minorid
);
9225 bfd_putl32 (0, eiaf
->iaflink
);
9226 bfd_putl32 (0, eiaf
->fixuplnk
);
9227 bfd_putl32 (sizeof (struct vms_eiaf
), eiaf
->size
);
9228 bfd_putl32 (0, eiaf
->flags
);
9229 bfd_putl32 (0, eiaf
->qrelfixoff
);
9230 bfd_putl32 (0, eiaf
->lrelfixoff
);
9231 bfd_putl32 (0, eiaf
->qdotadroff
);
9232 bfd_putl32 (0, eiaf
->ldotadroff
);
9233 bfd_putl32 (0, eiaf
->codeadroff
);
9234 bfd_putl32 (0, eiaf
->lpfixoff
);
9235 bfd_putl32 (0, eiaf
->chgprtoff
);
9236 bfd_putl32 (shrimg_cnt
? off
: 0, eiaf
->shlstoff
);
9237 bfd_putl32 (shrimg_cnt
, eiaf
->shrimgcnt
);
9238 bfd_putl32 (0, eiaf
->shlextra
);
9239 bfd_putl32 (0, eiaf
->permctx
);
9240 bfd_putl32 (0, eiaf
->base_va
);
9241 bfd_putl32 (0, eiaf
->lppsbfixoff
);
9248 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
9250 struct alpha_vms_shlib_el
*shlib
;
9251 struct vms_shl
*shl
;
9253 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
9255 if (!shlib
->has_fixups
)
9258 /* Renumber shared images. */
9259 PRIV2 (shlib
->abfd
, shr_index
) = shrimg_cnt
++;
9261 shl
= (struct vms_shl
*)(content
+ off
);
9262 bfd_putl32 (0, shl
->baseva
);
9263 bfd_putl32 (0, shl
->shlptr
);
9264 bfd_putl32 (0, shl
->ident
);
9265 bfd_putl32 (0, shl
->permctx
);
9266 shl
->size
= sizeof (struct vms_shl
);
9267 bfd_putl16 (0, shl
->fill_1
);
9269 bfd_putl32 (0, shl
->icb
);
9270 shl
->imgnam
[0] = strlen (PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
));
9271 memcpy (shl
->imgnam
+ 1, PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
),
9274 off
+= sizeof (struct vms_shl
);
9280 bfd_putl32 (off
, eiaf
->codeadroff
);
9282 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
9284 struct alpha_vms_shlib_el
*shlib
;
9287 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
9289 if (VEC_COUNT (shlib
->ca
) == 0)
9292 bfd_putl32 (VEC_COUNT (shlib
->ca
), content
+ off
);
9293 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
9296 for (j
= 0; j
< VEC_COUNT (shlib
->ca
); j
++)
9298 bfd_putl32 (VEC_EL (shlib
->ca
, bfd_vma
, j
) - t
->base_addr
,
9304 bfd_putl32 (0, content
+ off
);
9305 bfd_putl32 (0, content
+ off
+ 4);
9312 bfd_putl32 (off
, eiaf
->lpfixoff
);
9314 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
9316 struct alpha_vms_shlib_el
*shlib
;
9319 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
9321 if (VEC_COUNT (shlib
->lp
) == 0)
9324 bfd_putl32 (VEC_COUNT (shlib
->lp
), content
+ off
);
9325 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
9328 for (j
= 0; j
< VEC_COUNT (shlib
->lp
); j
++)
9330 bfd_putl32 (VEC_EL (shlib
->lp
, bfd_vma
, j
) - t
->base_addr
,
9336 bfd_putl32 (0, content
+ off
);
9337 bfd_putl32 (0, content
+ off
+ 4);
9344 bfd_putl32 (off
, eiaf
->qdotadroff
);
9346 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
9348 struct alpha_vms_shlib_el
*shlib
;
9351 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
9353 if (VEC_COUNT (shlib
->qr
) == 0)
9356 bfd_putl32 (VEC_COUNT (shlib
->qr
), content
+ off
);
9357 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
9360 for (j
= 0; j
< VEC_COUNT (shlib
->qr
); j
++)
9362 struct alpha_vms_vma_ref
*r
;
9363 r
= &VEC_EL (shlib
->qr
, struct alpha_vms_vma_ref
, j
);
9364 bfd_putl32 (r
->vma
- t
->base_addr
, content
+ off
);
9365 bfd_putl32 (r
->ref
, content
+ off
+ 4);
9370 bfd_putl32 (0, content
+ off
);
9371 bfd_putl32 (0, content
+ off
+ 4);
9376 /* Write the change protection table. */
9377 bfd_putl32 (off
, eiaf
->chgprtoff
);
9378 bfd_putl32 (chgprt_num
, content
+ off
);
9381 for (sec
= info
->output_bfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
9383 struct vms_eicp
*eicp
;
9386 if ((sec
->flags
& SEC_LINKER_CREATED
) != 0 &&
9387 strcmp (sec
->name
, "$FIXUP$") == 0)
9389 else if ((sec
->flags
& SEC_RELOC
) != 0
9390 && (sec
->flags
& (SEC_CODE
| SEC_READONLY
)) != 0)
9395 eicp
= (struct vms_eicp
*)(content
+ off
);
9396 bfd_putl64 (sec
->vma
- t
->base_addr
, eicp
->baseva
);
9397 bfd_putl32 ((sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1),
9399 bfd_putl32 (prot
, eicp
->newprt
);
9400 off
+= sizeof (struct vms_eicp
);
9406 /* Called by bfd_hash_traverse to fill the symbol table.
9407 Return FALSE in case of failure. */
9410 alpha_vms_link_output_symbol (struct bfd_hash_entry
*bh
, void *infov
)
9412 struct bfd_link_hash_entry
*hc
= (struct bfd_link_hash_entry
*) bh
;
9413 struct bfd_link_info
*info
= (struct bfd_link_info
*)infov
;
9414 struct alpha_vms_link_hash_entry
*h
;
9415 struct vms_symbol_entry
*sym
;
9417 if (hc
->type
== bfd_link_hash_warning
)
9420 if (hc
->type
== bfd_link_hash_new
)
9423 h
= (struct alpha_vms_link_hash_entry
*) hc
;
9425 switch (h
->root
.type
)
9427 case bfd_link_hash_undefined
:
9429 case bfd_link_hash_new
:
9430 case bfd_link_hash_warning
:
9432 case bfd_link_hash_undefweak
:
9434 case bfd_link_hash_defined
:
9435 case bfd_link_hash_defweak
:
9437 asection
*sec
= h
->root
.u
.def
.section
;
9439 /* FIXME: this is certainly a symbol from a dynamic library. */
9440 if (bfd_is_abs_section (sec
))
9443 if (sec
->owner
->flags
& DYNAMIC
)
9447 case bfd_link_hash_common
:
9449 case bfd_link_hash_indirect
:
9453 /* Do not write not kept symbols. */
9454 if (info
->strip
== strip_some
9455 && bfd_hash_lookup (info
->keep_hash
, h
->root
.root
.string
,
9456 false, false) != NULL
)
9461 /* This symbol doesn't come from a VMS object. So we suppose it is
9463 int len
= strlen (h
->root
.root
.string
);
9465 sym
= (struct vms_symbol_entry
*)bfd_zalloc (info
->output_bfd
,
9466 sizeof (*sym
) + len
);
9470 memcpy (sym
->name
, h
->root
.root
.string
, len
);
9472 sym
->owner
= info
->output_bfd
;
9474 sym
->typ
= EGSD__C_SYMG
;
9476 sym
->flags
= EGSY__V_DEF
| EGSY__V_REL
;
9477 sym
->symbol_vector
= h
->root
.u
.def
.value
;
9478 sym
->section
= h
->root
.u
.def
.section
;
9479 sym
->value
= h
->root
.u
.def
.value
;
9484 if (!add_symbol_entry (info
->output_bfd
, sym
))
9491 alpha_vms_bfd_final_link (bfd
*abfd
, struct bfd_link_info
*info
)
9494 struct bfd_link_order
*p
;
9502 if (bfd_link_relocatable (info
))
9504 /* FIXME: we do not yet support relocatable link. It is not obvious
9505 how to do it for debug infos. */
9506 (*info
->callbacks
->einfo
)(_("%P: relocatable link is not supported\n"));
9510 abfd
->outsymbols
= NULL
;
9513 /* Mark all sections which will be included in the output file. */
9514 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9515 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
9516 if (p
->type
== bfd_indirect_link_order
)
9517 p
->u
.indirect
.section
->linker_mark
= true;
9520 /* Handle all the link order information for the sections. */
9521 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9523 printf ("For section %s (at 0x%08x, flags=0x%08x):\n",
9524 o
->name
, (unsigned)o
->vma
, (unsigned)o
->flags
);
9526 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
9528 printf (" at 0x%08x - 0x%08x: ",
9529 (unsigned)p
->offset
, (unsigned)(p
->offset
+ p
->size
- 1));
9532 case bfd_section_reloc_link_order
:
9533 case bfd_symbol_reloc_link_order
:
9534 printf (" section/symbol reloc\n");
9536 case bfd_indirect_link_order
:
9537 printf (" section %s of %s\n",
9538 p
->u
.indirect
.section
->name
,
9539 p
->u
.indirect
.section
->owner
->filename
);
9541 case bfd_data_link_order
:
9542 printf (" explicit data\n");
9545 printf (" *unknown* type %u\n", p
->type
);
9552 /* Generate the symbol table. */
9553 BFD_ASSERT (PRIV (syms
) == NULL
);
9554 if (info
->strip
!= strip_all
)
9555 bfd_hash_traverse (&info
->hash
->table
, alpha_vms_link_output_symbol
, info
);
9557 /* Find the entry point. */
9558 if (bfd_get_start_address (abfd
) == 0)
9560 bfd
*startbfd
= NULL
;
9562 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9564 /* Consider only VMS object files. */
9565 if (sub
->xvec
!= abfd
->xvec
)
9568 if (!PRIV2 (sub
, eom_data
).eom_has_transfer
)
9570 if ((PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
) && startbfd
)
9572 if (startbfd
!= NULL
9573 && !(PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
))
9575 (*info
->callbacks
->einfo
)
9576 /* xgettext:c-format */
9577 (_("%P: multiple entry points: in modules %pB and %pB\n"),
9586 unsigned int ps_idx
= PRIV2 (startbfd
, eom_data
).eom_l_psindx
;
9587 bfd_vma tfradr
= PRIV2 (startbfd
, eom_data
).eom_l_tfradr
;
9590 sec
= PRIV2 (startbfd
, sections
)[ps_idx
];
9592 bfd_set_start_address
9593 (abfd
, sec
->output_section
->vma
+ sec
->output_offset
+ tfradr
);
9597 /* Set transfer addresses. */
9600 struct bfd_link_hash_entry
*h
;
9603 PRIV (transfer_address
[i
++]) = 0xffffffff00000340ULL
; /* SYS$IMGACT */
9604 h
= bfd_link_hash_lookup (info
->hash
, "LIB$INITIALIZE", false, false, true);
9605 if (h
!= NULL
&& h
->type
== bfd_link_hash_defined
)
9606 PRIV (transfer_address
[i
++]) =
9607 alpha_vms_get_sym_value (h
->u
.def
.section
, h
->u
.def
.value
);
9608 PRIV (transfer_address
[i
++]) = bfd_get_start_address (abfd
);
9610 PRIV (transfer_address
[i
++]) = 0;
9613 /* Allocate contents.
9614 Also compute the virtual base address. */
9615 base_addr
= (bfd_vma
)-1;
9617 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9619 if (o
->flags
& SEC_HAS_CONTENTS
)
9621 o
->contents
= bfd_alloc (abfd
, o
->size
);
9622 if (o
->contents
== NULL
)
9625 if (o
->flags
& SEC_LOAD
)
9627 if (o
->vma
< base_addr
)
9629 if (o
->vma
+ o
->size
> last_addr
)
9630 last_addr
= o
->vma
+ o
->size
;
9632 /* Clear the RELOC flags. Currently we don't support incremental
9633 linking. We use the RELOC flag for computing the eicp entries. */
9634 o
->flags
&= ~SEC_RELOC
;
9637 /* Create the fixup section. */
9638 fixupsec
= bfd_make_section_anyway_with_flags
9639 (info
->output_bfd
, "$FIXUP$",
9640 SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
9641 if (fixupsec
== NULL
)
9643 last_addr
= (last_addr
+ 0xffff) & ~0xffff;
9644 fixupsec
->vma
= last_addr
;
9646 alpha_vms_link_hash (info
)->fixup
= fixupsec
;
9647 alpha_vms_link_hash (info
)->base_addr
= base_addr
;
9649 /* Create the DMT section, if necessary. */
9650 BFD_ASSERT (PRIV (dst_section
) == NULL
);
9651 dst
= bfd_get_section_by_name (abfd
, "$DST$");
9652 if (dst
!= NULL
&& dst
->size
== 0)
9656 PRIV (dst_section
) = dst
;
9657 dmt
= bfd_make_section_anyway_with_flags
9658 (info
->output_bfd
, "$DMT$",
9659 SEC_DEBUGGING
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
9666 /* Read all sections from the inputs. */
9667 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9669 if (sub
->flags
& DYNAMIC
)
9671 alpha_vms_create_eisd_for_shared (abfd
, sub
);
9675 if (!alpha_vms_read_sections_content (sub
, info
))
9679 /* Handle all the link order information for the sections.
9680 Note: past this point, it is not possible to create new sections. */
9681 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9683 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
9687 case bfd_section_reloc_link_order
:
9688 case bfd_symbol_reloc_link_order
:
9691 case bfd_indirect_link_order
:
9695 if (! _bfd_default_link_order (abfd
, info
, o
, p
))
9702 /* Compute fixups. */
9703 if (!alpha_vms_build_fixups (info
))
9706 /* Compute the DMT. */
9710 unsigned char *contents
= NULL
;
9712 /* In pass 1, compute the size. In pass 2, write the DMT contents. */
9713 for (pass
= 0; pass
< 2; pass
++)
9715 unsigned int off
= 0;
9717 /* For each object file (ie for each module). */
9718 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9721 struct vms_dmt_header
*dmth
= NULL
;
9722 unsigned int psect_count
;
9724 /* Skip this module if it has no DST. */
9725 sub_dst
= PRIV2 (sub
, dst_section
);
9726 if (sub_dst
== NULL
|| sub_dst
->size
== 0)
9731 /* Write the header. */
9732 dmth
= (struct vms_dmt_header
*)(contents
+ off
);
9733 bfd_putl32 (sub_dst
->output_offset
, dmth
->modbeg
);
9734 bfd_putl32 (sub_dst
->size
, dmth
->size
);
9737 off
+= sizeof (struct vms_dmt_header
);
9740 /* For each section (ie for each psect). */
9741 for (o
= sub
->sections
; o
!= NULL
; o
= o
->next
)
9743 /* Only consider interesting sections. */
9744 if (!(o
->flags
& SEC_ALLOC
))
9746 if (o
->flags
& SEC_LINKER_CREATED
)
9751 /* Write an entry. */
9752 struct vms_dmt_psect
*dmtp
;
9754 dmtp
= (struct vms_dmt_psect
*)(contents
+ off
);
9755 bfd_putl32 (o
->output_offset
+ o
->output_section
->vma
,
9757 bfd_putl32 (o
->size
, dmtp
->length
);
9760 off
+= sizeof (struct vms_dmt_psect
);
9763 bfd_putl32 (psect_count
, dmth
->psect_count
);
9768 contents
= bfd_zalloc (info
->output_bfd
, off
);
9769 if (contents
== NULL
)
9771 dmt
->contents
= contents
;
9776 BFD_ASSERT (off
== dmt
->size
);
9784 /* Read the contents of a section.
9785 buf points to a buffer of buf_size bytes to be filled with
9786 section data (starting at offset into section) */
9789 alpha_vms_get_section_contents (bfd
*abfd
, asection
*section
,
9790 void *buf
, file_ptr offset
,
9791 bfd_size_type count
)
9795 /* Image are easy. */
9796 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
9797 return _bfd_generic_get_section_contents (abfd
, section
,
9798 buf
, offset
, count
);
9801 if (offset
+ count
< count
9802 || offset
+ count
> section
->size
)
9804 bfd_set_error (bfd_error_invalid_operation
);
9808 /* If the section is already in memory, just copy it. */
9809 if (section
->flags
& SEC_IN_MEMORY
)
9811 BFD_ASSERT (section
->contents
!= NULL
);
9812 memcpy (buf
, section
->contents
+ offset
, count
);
9815 if (section
->size
== 0)
9818 /* Alloc in memory and read ETIRs. */
9819 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
9821 BFD_ASSERT (sec
->contents
== NULL
);
9823 if (sec
->size
!= 0 && (sec
->flags
& SEC_HAS_CONTENTS
))
9825 sec
->contents
= bfd_alloc (abfd
, sec
->size
);
9826 if (sec
->contents
== NULL
)
9830 if (!alpha_vms_read_sections_content (abfd
, NULL
))
9832 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
9834 sec
->flags
|= SEC_IN_MEMORY
;
9835 memcpy (buf
, section
->contents
+ offset
, count
);
9840 /* Set the format of a file being written. */
9843 alpha_vms_mkobject (bfd
* abfd
)
9845 const bfd_arch_info_type
*arch
;
9847 vms_debug2 ((1, "alpha_vms_mkobject (%p)\n", abfd
));
9849 if (!vms_initialize (abfd
))
9852 PRIV (recwr
.buf
) = bfd_alloc (abfd
, MAX_OUTREC_SIZE
);
9853 if (PRIV (recwr
.buf
) == NULL
)
9856 arch
= bfd_scan_arch ("alpha");
9860 bfd_set_error (bfd_error_wrong_format
);
9864 abfd
->arch_info
= arch
;
9871 /* Called when the BFD is being closed to do any necessary cleanup. */
9874 vms_close_and_cleanup (bfd
* abfd
)
9876 vms_debug2 ((1, "vms_close_and_cleanup (%p)\n", abfd
));
9878 if (abfd
== NULL
|| abfd
->tdata
.any
== NULL
)
9881 if (abfd
->format
== bfd_object
)
9883 alpha_vms_free_private (abfd
);
9886 if (abfd
->direction
== write_direction
)
9888 /* Last step on VMS is to convert the file to variable record length
9890 if (!bfd_cache_close (abfd
))
9892 if (!_bfd_vms_convert_to_var_unix_filename (abfd
->filename
))
9898 return _bfd_generic_close_and_cleanup (abfd
);
9901 /* Called when a new section is created. */
9904 vms_new_section_hook (bfd
* abfd
, asection
*section
)
9908 vms_debug2 ((1, "vms_new_section_hook (%p, [%u]%s)\n",
9909 abfd
, section
->index
, section
->name
));
9911 if (!bfd_set_section_alignment (section
, 0))
9914 vms_debug2 ((7, "%u: %s\n", section
->index
, section
->name
));
9916 amt
= sizeof (struct vms_section_data_struct
);
9917 section
->used_by_bfd
= bfd_zalloc (abfd
, amt
);
9918 if (section
->used_by_bfd
== NULL
)
9921 /* Create the section symbol. */
9922 return _bfd_generic_new_section_hook (abfd
, section
);
9925 /* Part 4.5, symbols. */
9927 /* Print symbol to file according to how. how is one of
9928 bfd_print_symbol_name just print the name
9929 bfd_print_symbol_more print more (???)
9930 bfd_print_symbol_all print all we know, which is not much right now :-). */
9933 vms_print_symbol (bfd
* abfd
,
9936 bfd_print_symbol_type how
)
9938 vms_debug2 ((1, "vms_print_symbol (%p, %p, %p, %d)\n",
9939 abfd
, file
, symbol
, how
));
9943 case bfd_print_symbol_name
:
9944 case bfd_print_symbol_more
:
9945 fprintf ((FILE *)file
," %s", symbol
->name
);
9948 case bfd_print_symbol_all
:
9950 const char *section_name
= symbol
->section
->name
;
9952 bfd_print_symbol_vandf (abfd
, file
, symbol
);
9954 fprintf ((FILE *) file
," %-8s %s", section_name
, symbol
->name
);
9960 /* Return information about symbol in ret.
9962 fill type, value and name
9965 B bss segment symbol
9967 D data segment symbol
9969 t a static function symbol
9970 T text segment symbol
9975 vms_get_symbol_info (bfd
* abfd ATTRIBUTE_UNUSED
,
9981 vms_debug2 ((1, "vms_get_symbol_info (%p, %p, %p)\n", abfd
, symbol
, ret
));
9983 sec
= symbol
->section
;
9990 else if (bfd_is_com_section (sec
))
9992 else if (bfd_is_abs_section (sec
))
9994 else if (bfd_is_und_section (sec
))
9996 else if (bfd_is_ind_section (sec
))
9998 else if ((symbol
->flags
& BSF_FUNCTION
)
9999 || (bfd_section_flags (sec
) & SEC_CODE
))
10001 else if (bfd_section_flags (sec
) & SEC_DATA
)
10003 else if (bfd_section_flags (sec
) & SEC_ALLOC
)
10008 if (ret
->type
!= 'U')
10009 ret
->value
= symbol
->value
+ symbol
->section
->vma
;
10012 ret
->name
= symbol
->name
;
10015 /* Return TRUE if the given symbol sym in the BFD abfd is
10016 a compiler generated local label, else return FALSE. */
10019 vms_bfd_is_local_label_name (bfd
* abfd ATTRIBUTE_UNUSED
,
10022 return name
[0] == '$';
10025 /* Part 4.7, writing an object file. */
10027 /* Sets the contents of the section section in BFD abfd to the data starting
10028 in memory at LOCATION. The data is written to the output section starting
10029 at offset offset for count bytes.
10031 Normally TRUE is returned, else FALSE. Possible error returns are:
10032 o bfd_error_no_contents - The output section does not have the
10033 SEC_HAS_CONTENTS attribute, so nothing can be written to it.
10034 o and some more too */
10037 _bfd_vms_set_section_contents (bfd
* abfd
,
10039 const void * location
,
10041 bfd_size_type count
)
10043 if (section
->contents
== NULL
)
10045 section
->contents
= bfd_alloc (abfd
, section
->size
);
10046 if (section
->contents
== NULL
)
10049 memcpy (section
->contents
+ offset
, location
, (size_t) count
);
10055 /* Set the architecture and machine type in BFD abfd to arch and mach.
10056 Find the correct pointer to a structure and insert it into the arch_info
10060 alpha_vms_set_arch_mach (bfd
*abfd
,
10061 enum bfd_architecture arch
, unsigned long mach
)
10063 if (arch
!= bfd_arch_alpha
10064 && arch
!= bfd_arch_unknown
)
10067 return bfd_default_set_arch_mach (abfd
, arch
, mach
);
10070 /* Set section VMS flags. Clear NO_FLAGS and set FLAGS. */
10073 bfd_vms_set_section_flags (bfd
*abfd ATTRIBUTE_UNUSED
,
10074 asection
*sec
, flagword no_flags
, flagword flags
)
10076 vms_section_data (sec
)->no_flags
= no_flags
;
10077 vms_section_data (sec
)->flags
= flags
;
10080 struct vms_private_data_struct
*
10081 bfd_vms_get_data (bfd
*abfd
)
10083 return (struct vms_private_data_struct
*)abfd
->tdata
.any
;
10086 #define vms_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false
10087 #define vms_bfd_link_just_syms _bfd_generic_link_just_syms
10088 #define vms_bfd_copy_link_hash_symbol_type \
10089 _bfd_generic_copy_link_hash_symbol_type
10090 #define vms_bfd_is_group_section bfd_generic_is_group_section
10091 #define vms_bfd_group_name bfd_generic_group_name
10092 #define vms_bfd_discard_group bfd_generic_discard_group
10093 #define vms_section_already_linked _bfd_generic_section_already_linked
10094 #define vms_bfd_define_common_symbol bfd_generic_define_common_symbol
10095 #define vms_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
10096 #define vms_bfd_define_start_stop bfd_generic_define_start_stop
10097 #define vms_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
10099 #define vms_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
10100 #define vms_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
10101 #define vms_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data
10102 #define vms_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
10103 #define vms_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
10104 #define vms_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
10106 /* Symbols table. */
10107 #define alpha_vms_make_empty_symbol _bfd_generic_make_empty_symbol
10108 #define alpha_vms_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false
10109 #define alpha_vms_print_symbol vms_print_symbol
10110 #define alpha_vms_get_symbol_info vms_get_symbol_info
10111 #define alpha_vms_get_symbol_version_string \
10112 _bfd_nosymbols_get_symbol_version_string
10114 #define alpha_vms_read_minisymbols _bfd_generic_read_minisymbols
10115 #define alpha_vms_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
10116 #define alpha_vms_get_lineno _bfd_nosymbols_get_lineno
10117 #define alpha_vms_find_inliner_info _bfd_nosymbols_find_inliner_info
10118 #define alpha_vms_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
10119 #define alpha_vms_find_nearest_line _bfd_vms_find_nearest_line
10120 #define alpha_vms_find_nearest_line_with_alt \
10121 _bfd_nosymbols_find_nearest_line_with_alt
10122 #define alpha_vms_find_line _bfd_nosymbols_find_line
10123 #define alpha_vms_bfd_is_local_label_name vms_bfd_is_local_label_name
10125 /* Generic table. */
10126 #define alpha_vms_close_and_cleanup vms_close_and_cleanup
10127 #define alpha_vms_bfd_free_cached_info vms_bfd_free_cached_info
10128 #define alpha_vms_new_section_hook vms_new_section_hook
10129 #define alpha_vms_set_section_contents _bfd_vms_set_section_contents
10130 #define alpha_vms_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
10132 #define alpha_vms_bfd_get_relocated_section_contents \
10133 bfd_generic_get_relocated_section_contents
10135 #define alpha_vms_bfd_relax_section bfd_generic_relax_section
10136 #define alpha_vms_bfd_gc_sections bfd_generic_gc_sections
10137 #define alpha_vms_bfd_lookup_section_flags bfd_generic_lookup_section_flags
10138 #define alpha_vms_bfd_merge_sections bfd_generic_merge_sections
10139 #define alpha_vms_bfd_is_group_section bfd_generic_is_group_section
10140 #define alpha_vms_bfd_group_name bfd_generic_group_name
10141 #define alpha_vms_bfd_discard_group bfd_generic_discard_group
10142 #define alpha_vms_section_already_linked \
10143 _bfd_generic_section_already_linked
10145 #define alpha_vms_bfd_define_common_symbol bfd_generic_define_common_symbol
10146 #define alpha_vms_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
10147 #define alpha_vms_bfd_define_start_stop bfd_generic_define_start_stop
10148 #define alpha_vms_bfd_link_just_syms _bfd_generic_link_just_syms
10149 #define alpha_vms_bfd_copy_link_hash_symbol_type \
10150 _bfd_generic_copy_link_hash_symbol_type
10152 #define alpha_vms_bfd_link_split_section _bfd_generic_link_split_section
10154 #define alpha_vms_get_dynamic_symtab_upper_bound \
10155 _bfd_nodynamic_get_dynamic_symtab_upper_bound
10156 #define alpha_vms_canonicalize_dynamic_symtab \
10157 _bfd_nodynamic_canonicalize_dynamic_symtab
10158 #define alpha_vms_get_dynamic_reloc_upper_bound \
10159 _bfd_nodynamic_get_dynamic_reloc_upper_bound
10160 #define alpha_vms_canonicalize_dynamic_reloc \
10161 _bfd_nodynamic_canonicalize_dynamic_reloc
10162 #define alpha_vms_bfd_link_check_relocs _bfd_generic_link_check_relocs
10164 const bfd_target alpha_vms_vec
=
10166 "vms-alpha", /* Name. */
10167 bfd_target_evax_flavour
,
10168 BFD_ENDIAN_LITTLE
, /* Data byte order is little. */
10169 BFD_ENDIAN_LITTLE
, /* Header byte order is little. */
10171 (HAS_RELOC
| EXEC_P
| HAS_LINENO
| HAS_DEBUG
| HAS_SYMS
| HAS_LOCALS
10172 | WP_TEXT
| D_PAGED
), /* Object flags. */
10173 (SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
10174 | SEC_READONLY
| SEC_CODE
| SEC_DATA
10175 | SEC_HAS_CONTENTS
| SEC_IN_MEMORY
), /* Sect flags. */
10176 0, /* symbol_leading_char. */
10177 ' ', /* ar_pad_char. */
10178 15, /* ar_max_namelen. */
10179 0, /* match priority. */
10180 TARGET_KEEP_UNUSED_SECTION_SYMBOLS
, /* keep unused section symbols. */
10181 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
10182 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
10183 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
10184 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
10185 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
10186 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
10188 { /* bfd_check_format. */
10190 alpha_vms_object_p
,
10191 _bfd_vms_lib_alpha_archive_p
,
10194 { /* bfd_set_format. */
10195 _bfd_bool_bfd_false_error
,
10196 alpha_vms_mkobject
,
10197 _bfd_vms_lib_alpha_mkarchive
,
10198 _bfd_bool_bfd_false_error
10200 { /* bfd_write_contents. */
10201 _bfd_bool_bfd_false_error
,
10202 alpha_vms_write_object_contents
,
10203 _bfd_vms_lib_write_archive_contents
,
10204 _bfd_bool_bfd_false_error
10207 BFD_JUMP_TABLE_GENERIC (alpha_vms
),
10208 BFD_JUMP_TABLE_COPY (vms
),
10209 BFD_JUMP_TABLE_CORE (_bfd_nocore
),
10210 BFD_JUMP_TABLE_ARCHIVE (_bfd_vms_lib
),
10211 BFD_JUMP_TABLE_SYMBOLS (alpha_vms
),
10212 BFD_JUMP_TABLE_RELOCS (alpha_vms
),
10213 BFD_JUMP_TABLE_WRITE (alpha_vms
),
10214 BFD_JUMP_TABLE_LINK (alpha_vms
),
10215 BFD_JUMP_TABLE_DYNAMIC (alpha_vms
),