1 /* vms.c -- BFD back-end for EVAX (openVMS/Alpha) files.
2 Copyright (C) 1996-2022 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 true, relocs have been read. */
272 /* Record input buffer. */
273 struct vms_rec_rd recrd
;
274 struct vms_rec_wr recwr
;
276 struct hdr_struct hdr_data
; /* data from HDR/EMH record */
277 struct eom_struct eom_data
; /* data from EOM/EEOM record */
279 /* Transfer addresses (entry points). */
280 bfd_vma transfer_address
[4];
282 /* Array of GSD sections to get the correspond BFD one. */
283 unsigned int section_max
; /* Size of the sections array. */
284 unsigned int section_count
; /* Number of GSD sections. */
287 /* Array of raw symbols. */
288 struct vms_symbol_entry
**syms
;
290 /* Canonicalized symbols. */
293 /* Number of symbols. */
294 unsigned int gsd_sym_count
;
295 /* Size of the syms array. */
296 unsigned int max_sym_count
;
297 /* Number of procedure symbols. */
298 unsigned int norm_sym_count
;
300 /* Stack used to evaluate TIR/ETIR commands. */
301 struct stack_struct
*stack
;
304 /* Content reading. */
305 asection
*image_section
; /* section for image_ptr */
306 file_ptr image_offset
; /* Offset for image_ptr. */
308 struct module
*modules
; /* list of all compilation units */
310 /* The DST section. */
311 asection
*dst_section
;
313 unsigned int dst_ptr_offsets_count
; /* # of offsets in following array */
314 unsigned int *dst_ptr_offsets
; /* array of saved image_ptr offsets */
316 /* Shared library support */
317 bfd_vma symvva
; /* relative virtual address of symbol vector */
319 unsigned char matchctl
;
321 /* Shared library index. This is used for input bfd while linking. */
322 unsigned int shr_index
;
324 /* Used to place structures in the file. */
327 /* Simply linked list of eisd. */
328 struct vms_internal_eisd_map
*eisd_head
;
329 struct vms_internal_eisd_map
*eisd_tail
;
331 /* Simply linked list of eisd for shared libraries. */
332 struct vms_internal_eisd_map
*gbl_eisd_head
;
333 struct vms_internal_eisd_map
*gbl_eisd_tail
;
335 /* linkage index counter used by conditional store commands */
336 unsigned int vms_linkage_index
;
339 #define PRIV2(abfd, name) \
340 (((struct vms_private_data_struct *)(abfd)->tdata.any)->name)
341 #define PRIV(name) PRIV2(abfd,name)
344 /* Used to keep extra VMS specific information for a given section.
346 reloc_size holds the size of the relocation stream, note this
347 is very different from the number of relocations as VMS relocations
350 reloc_stream is the actual stream of relocation entries. */
352 struct vms_section_data_struct
354 /* Maximnum number of entries in sec->relocation. */
357 /* Corresponding eisd. Used only while generating executables. */
358 struct vms_internal_eisd_map
*eisd
;
360 /* PSC flags to be clear. */
363 /* PSC flags to be set. */
367 #define vms_section_data(sec) \
368 ((struct vms_section_data_struct *)sec->used_by_bfd)
370 /* To be called from the debugger. */
371 struct vms_private_data_struct
*bfd_vms_get_data (bfd
*);
373 static int vms_get_remaining_object_record (bfd
*, unsigned int);
374 static bool _bfd_vms_slurp_object_records (bfd
* abfd
);
375 static bool alpha_vms_add_fixup_lp (struct bfd_link_info
*, bfd
*, bfd
*);
376 static bool alpha_vms_add_fixup_ca (struct bfd_link_info
*, bfd
*, bfd
*);
377 static bool alpha_vms_add_fixup_qr (struct bfd_link_info
*, bfd
*, bfd
*,
379 static bool alpha_vms_add_fixup_lr (struct bfd_link_info
*, unsigned int,
381 static bool alpha_vms_add_lw_reloc (struct bfd_link_info
*);
382 static bool alpha_vms_add_qw_reloc (struct bfd_link_info
*);
391 /* Number of elements in VEC. */
393 #define VEC_COUNT(VEC) ((VEC).nbr_el)
395 /* Get the address of the Nth element. */
397 #define VEC_EL(VEC, TYPE, N) (((TYPE *)((VEC).els))[N])
399 #define VEC_INIT(VEC) \
406 /* Be sure there is room for a new element. */
408 static void *vector_grow1 (struct vector_type
*vec
, size_t elsz
);
410 /* Allocate room for a new element and return its address. */
412 #define VEC_APPEND(VEC, TYPE) \
413 ((TYPE *) vector_grow1 (&VEC, sizeof (TYPE)))
415 struct alpha_vms_vma_ref
417 bfd_vma vma
; /* Vma in the output. */
418 bfd_vma ref
; /* Reference in the input. */
421 struct alpha_vms_shlib_el
426 struct vector_type lp
; /* Vector of bfd_vma. */
427 struct vector_type ca
; /* Vector of bfd_vma. */
428 struct vector_type qr
; /* Vector of struct alpha_vms_vma_ref. */
431 /* Alpha VMS linker hash table. */
433 struct alpha_vms_link_hash_table
435 struct bfd_link_hash_table root
;
437 /* Vector of shared libraries. */
438 struct vector_type shrlibs
;
443 /* Base address. Used by fixups. */
447 #define alpha_vms_link_hash(INFO) \
448 ((struct alpha_vms_link_hash_table *)(INFO->hash))
450 /* Alpha VMS linker hash table entry. */
452 struct alpha_vms_link_hash_entry
454 struct bfd_link_hash_entry root
;
456 /* Pointer to the original vms symbol. */
457 struct vms_symbol_entry
*sym
;
462 /* Read & process EIHD record.
463 Return TRUE on success, FALSE on error. */
466 _bfd_vms_slurp_eihd (bfd
*abfd
, unsigned int *eisd_offset
,
467 unsigned int *eihs_offset
)
469 unsigned int imgtype
, size
;
471 struct vms_eihd
*eihd
= (struct vms_eihd
*)PRIV (recrd
.rec
);
473 vms_debug2 ((8, "_bfd_vms_slurp_eihd\n"));
475 /* PR 21813: Check for an undersized record. */
476 if (PRIV (recrd
.buf_size
) < sizeof (* eihd
))
478 _bfd_error_handler (_("corrupt EIHD record - size is too small"));
479 bfd_set_error (bfd_error_bad_value
);
483 size
= bfd_getl32 (eihd
->size
);
484 imgtype
= bfd_getl32 (eihd
->imgtype
);
486 if (imgtype
== EIHD__K_EXE
|| imgtype
== EIHD__K_LIM
)
487 abfd
->flags
|= EXEC_P
;
489 symvva
= bfd_getl64 (eihd
->symvva
);
492 PRIV (symvva
) = symvva
;
493 abfd
->flags
|= DYNAMIC
;
496 PRIV (ident
) = bfd_getl32 (eihd
->ident
);
497 PRIV (matchctl
) = eihd
->matchctl
;
499 *eisd_offset
= bfd_getl32 (eihd
->isdoff
);
500 *eihs_offset
= bfd_getl32 (eihd
->symdbgoff
);
502 vms_debug2 ((4, "EIHD size %d imgtype %d symvva 0x%lx eisd %d eihs %d\n",
503 size
, imgtype
, (unsigned long)symvva
,
504 *eisd_offset
, *eihs_offset
));
510 /* Read & process EISD record.
511 Return TRUE on success, FALSE on error. */
514 _bfd_vms_slurp_eisd (bfd
*abfd
, unsigned int offset
)
516 int section_count
= 0;
518 vms_debug2 ((8, "_bfd_vms_slurp_eisd\n"));
522 struct vms_eisd
*eisd
;
523 unsigned int rec_size
;
532 /* PR 17512: file: 3d9e9fe9. */
533 if (offset
> PRIV (recrd
.rec_size
)
534 || (PRIV (recrd
.rec_size
) - offset
535 < offsetof (struct vms_eisd
, eisdsize
) + 4))
537 eisd
= (struct vms_eisd
*) (PRIV (recrd
.rec
) + offset
);
538 rec_size
= bfd_getl32 (eisd
->eisdsize
);
542 /* Skip to next block if pad. */
543 if (rec_size
== 0xffffffff)
545 offset
= (offset
+ VMS_BLOCK_SIZE
) & ~(VMS_BLOCK_SIZE
- 1);
549 /* Make sure that there is enough data present in the record. */
550 if (rec_size
< offsetof (struct vms_eisd
, type
) + 1)
552 /* Make sure that the record is not too big either. */
553 if (rec_size
> PRIV (recrd
.rec_size
) - offset
)
558 size
= bfd_getl32 (eisd
->secsize
);
559 vaddr
= bfd_getl64 (eisd
->virt_addr
);
560 flags
= bfd_getl32 (eisd
->flags
);
561 vbn
= bfd_getl32 (eisd
->vbn
);
563 vms_debug2 ((4, "EISD at 0x%x size 0x%x addr 0x%lx flags 0x%x blk %d\n",
564 offset
, size
, (unsigned long)vaddr
, flags
, vbn
));
566 /* VMS combines psects from .obj files into isects in the .exe. This
567 process doesn't preserve enough information to reliably determine
568 what's in each section without examining the data. This is
569 especially true of DWARF debug sections. */
570 bfd_flags
= SEC_ALLOC
;
572 bfd_flags
|= SEC_HAS_CONTENTS
| SEC_LOAD
;
574 if (flags
& EISD__M_EXE
)
575 bfd_flags
|= SEC_CODE
;
577 if (flags
& EISD__M_NONSHRADR
)
578 bfd_flags
|= SEC_DATA
;
580 if (!(flags
& EISD__M_WRT
))
581 bfd_flags
|= SEC_READONLY
;
583 if (flags
& EISD__M_DZRO
)
584 bfd_flags
|= SEC_DATA
;
586 if (flags
& EISD__M_FIXUPVEC
)
587 bfd_flags
|= SEC_DATA
;
589 if (flags
& EISD__M_CRF
)
590 bfd_flags
|= SEC_DATA
;
592 if (flags
& EISD__M_GBL
)
594 if (rec_size
<= offsetof (struct vms_eisd
, gblnam
))
596 else if (rec_size
< sizeof (struct vms_eisd
))
597 name
= _bfd_vms_save_counted_string (abfd
, eisd
->gblnam
,
598 rec_size
- offsetof (struct vms_eisd
, gblnam
));
600 name
= _bfd_vms_save_counted_string (abfd
, eisd
->gblnam
,
602 if (name
== NULL
|| name
[0] == 0)
604 bfd_flags
|= SEC_COFF_SHARED_LIBRARY
;
605 bfd_flags
&= ~(SEC_ALLOC
| SEC_LOAD
);
607 else if (flags
& EISD__M_FIXUPVEC
)
609 else if (eisd
->type
== EISD__K_USRSTACK
)
615 name
= (char *) bfd_alloc (abfd
, 32);
618 if (flags
& EISD__M_DZRO
)
620 else if (flags
& EISD__M_EXE
)
622 else if (!(flags
& EISD__M_WRT
))
626 BFD_ASSERT (section_count
< 999);
627 sprintf (name
, "$%s_%03d$", pfx
, section_count
++);
630 section
= bfd_make_section (abfd
, name
);
635 section
->filepos
= vbn
? VMS_BLOCK_SIZE
* (vbn
- 1) : 0;
636 section
->size
= size
;
637 section
->vma
= vaddr
;
639 if (!bfd_set_section_flags (section
, bfd_flags
))
646 /* Read & process EIHS record.
647 Return TRUE on success, FALSE on error. */
650 _bfd_vms_slurp_eihs (bfd
*abfd
, unsigned int offset
)
652 unsigned char *p
= PRIV (recrd
.rec
) + offset
;
654 unsigned int gstsize ATTRIBUTE_UNUSED
;
656 unsigned int dstsize
;
658 unsigned int dmtbytes
;
661 /* PR 21611: Check that offset is valid. */
662 if (offset
> PRIV (recrd
.rec_size
) - (EIHS__L_DMTBYTES
+ 4))
664 _bfd_error_handler (_("unable to read EIHS record at offset %#x"),
666 bfd_set_error (bfd_error_file_truncated
);
670 gstvbn
= bfd_getl32 (p
+ EIHS__L_GSTVBN
);
671 gstsize
= bfd_getl32 (p
+ EIHS__L_GSTSIZE
);
672 dstvbn
= bfd_getl32 (p
+ EIHS__L_DSTVBN
);
673 dstsize
= bfd_getl32 (p
+ EIHS__L_DSTSIZE
);
674 dmtvbn
= bfd_getl32 (p
+ EIHS__L_DMTVBN
);
675 dmtbytes
= bfd_getl32 (p
+ EIHS__L_DMTBYTES
);
678 vms_debug (8, "_bfd_vms_slurp_ihs\n");
679 vms_debug (4, "EIHS record gstvbn %d gstsize %d dstvbn %d dstsize %d dmtvbn %d dmtbytes %d\n",
680 gstvbn
, gstsize
, dstvbn
, dstsize
, dmtvbn
, dmtbytes
);
685 flagword bfd_flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
;
687 section
= bfd_make_section (abfd
, "$DST$");
691 section
->size
= dstsize
;
692 section
->filepos
= VMS_BLOCK_SIZE
* (dstvbn
- 1);
694 if (!bfd_set_section_flags (section
, bfd_flags
))
697 PRIV (dst_section
) = section
;
698 abfd
->flags
|= (HAS_DEBUG
| HAS_LINENO
);
703 flagword bfd_flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
;
705 section
= bfd_make_section (abfd
, "$DMT$");
709 section
->size
= dmtbytes
;
710 section
->filepos
= VMS_BLOCK_SIZE
* (dmtvbn
- 1);
712 if (!bfd_set_section_flags (section
, bfd_flags
))
718 if (bfd_seek (abfd
, VMS_BLOCK_SIZE
* (gstvbn
- 1), SEEK_SET
))
720 bfd_set_error (bfd_error_file_truncated
);
724 if (!_bfd_vms_slurp_object_records (abfd
))
727 abfd
->flags
|= HAS_SYMS
;
733 /* Object file reading. */
735 /* Object file input functions. */
737 /* Get next record from object file to vms_buf.
738 Set PRIV(buf_size) and return it
740 This is a little tricky since it should be portable.
742 The openVMS object file has 'variable length' which means that
743 read() returns data in chunks of (hopefully) correct and expected
744 size. The linker (and other tools on VMS) depend on that. Unix
745 doesn't know about 'formatted' files, so reading and writing such
746 an object file in a Unix environment is not trivial.
748 With the tool 'file' (available on all VMS FTP sites), one
749 can view and change the attributes of a file. Changing from
750 'variable length' to 'fixed length, 512 bytes' reveals the
751 record size at the first 2 bytes of every record. The same
752 may happen during the transfer of object files from VMS to Unix,
753 at least with UCX, the DEC implementation of TCP/IP.
755 The VMS format repeats the size at bytes 2 & 3 of every record.
757 On the first call (file_format == FF_UNKNOWN) we check if
758 the first and the third byte pair (!) of the record match.
759 If they do it's an object file in an Unix environment or with
760 wrong attributes (FF_FOREIGN), else we should be in a VMS
761 environment where read() returns the record size (FF_NATIVE).
763 Reading is always done in 2 steps:
764 1. first just the record header is read and the size extracted,
765 2. then the read buffer is adjusted and the remaining bytes are
768 All file I/O is done on even file positions. */
770 #define VMS_OBJECT_ADJUSTMENT 2
773 maybe_adjust_record_pointer_for_object (bfd
*abfd
)
775 /* Set the file format once for all on the first invocation. */
776 if (PRIV (recrd
.file_format
) == FF_UNKNOWN
)
778 if (PRIV (recrd
.rec
)[0] == PRIV (recrd
.rec
)[4]
779 && PRIV (recrd
.rec
)[1] == PRIV (recrd
.rec
)[5])
780 PRIV (recrd
.file_format
) = FF_FOREIGN
;
782 PRIV (recrd
.file_format
) = FF_NATIVE
;
785 /* The adjustment is needed only in an Unix environment. */
786 if (PRIV (recrd
.file_format
) == FF_FOREIGN
)
787 PRIV (recrd
.rec
) += VMS_OBJECT_ADJUSTMENT
;
790 /* Implement step #1 of the object record reading procedure.
791 Return the record type or -1 on failure. */
794 _bfd_vms_get_object_record (bfd
*abfd
)
796 unsigned int test_len
= 6;
799 vms_debug2 ((8, "_bfd_vms_get_obj_record\n"));
801 /* Skip alignment byte if the current position is odd. */
802 if (PRIV (recrd
.file_format
) == FF_FOREIGN
&& (bfd_tell (abfd
) & 1))
804 if (bfd_bread (PRIV (recrd
.buf
), 1, abfd
) != 1)
806 bfd_set_error (bfd_error_file_truncated
);
811 /* Read the record header */
812 if (bfd_bread (PRIV (recrd
.buf
), test_len
, abfd
) != test_len
)
814 bfd_set_error (bfd_error_file_truncated
);
818 /* Reset the record pointer. */
819 PRIV (recrd
.rec
) = PRIV (recrd
.buf
);
820 maybe_adjust_record_pointer_for_object (abfd
);
822 if (vms_get_remaining_object_record (abfd
, test_len
) <= 0)
825 type
= bfd_getl16 (PRIV (recrd
.rec
));
827 vms_debug2 ((8, "_bfd_vms_get_obj_record: rec %p, size %d, type %d\n",
828 PRIV (recrd
.rec
), PRIV (recrd
.rec_size
), type
));
833 /* Implement step #2 of the object record reading procedure.
834 Return the size of the record or 0 on failure. */
837 vms_get_remaining_object_record (bfd
*abfd
, unsigned int read_so_far
)
839 unsigned int to_read
;
841 vms_debug2 ((8, "vms_get_remaining_obj_record\n"));
843 /* Extract record size. */
844 PRIV (recrd
.rec_size
) = bfd_getl16 (PRIV (recrd
.rec
) + 2);
846 if (PRIV (recrd
.rec_size
) == 0)
848 bfd_set_error (bfd_error_file_truncated
);
852 /* That's what the linker manual says. */
853 if (PRIV (recrd
.rec_size
) > EOBJ__C_MAXRECSIZ
)
855 bfd_set_error (bfd_error_file_truncated
);
859 /* Take into account object adjustment. */
860 to_read
= PRIV (recrd
.rec_size
);
861 if (PRIV (recrd
.file_format
) == FF_FOREIGN
)
862 to_read
+= VMS_OBJECT_ADJUSTMENT
;
864 /* Adjust the buffer. */
865 if (to_read
> PRIV (recrd
.buf_size
))
868 = (unsigned char *) bfd_realloc_or_free (PRIV (recrd
.buf
), to_read
);
869 if (PRIV (recrd
.buf
) == NULL
)
871 PRIV (recrd
.buf_size
) = to_read
;
873 /* PR 17512: file: 025-1974-0.004. */
874 else if (to_read
<= read_so_far
)
877 /* Read the remaining record. */
878 to_read
-= read_so_far
;
880 vms_debug2 ((8, "vms_get_remaining_obj_record: to_read %d\n", to_read
));
882 if (bfd_bread (PRIV (recrd
.buf
) + read_so_far
, to_read
, abfd
) != to_read
)
884 bfd_set_error (bfd_error_file_truncated
);
888 /* Reset the record pointer. */
889 PRIV (recrd
.rec
) = PRIV (recrd
.buf
);
890 maybe_adjust_record_pointer_for_object (abfd
);
892 vms_debug2 ((8, "vms_get_remaining_obj_record: size %d\n",
893 PRIV (recrd
.rec_size
)));
895 return PRIV (recrd
.rec_size
);
898 /* Read and process emh record.
899 Return TRUE on success, FALSE on error. */
902 _bfd_vms_slurp_ehdr (bfd
*abfd
)
905 unsigned char *vms_rec
;
909 vms_rec
= PRIV (recrd
.rec
);
910 /* PR 17512: file: 62736583. */
911 end
= PRIV (recrd
.buf
) + PRIV (recrd
.buf_size
);
913 vms_debug2 ((2, "HDR/EMH\n"));
915 subtype
= bfd_getl16 (vms_rec
+ 4);
917 vms_debug2 ((3, "subtype %d\n", subtype
));
923 if (vms_rec
+ 21 >= end
)
925 PRIV (hdr_data
).hdr_b_strlvl
= vms_rec
[6];
926 PRIV (hdr_data
).hdr_l_arch1
= bfd_getl32 (vms_rec
+ 8);
927 PRIV (hdr_data
).hdr_l_arch2
= bfd_getl32 (vms_rec
+ 12);
928 PRIV (hdr_data
).hdr_l_recsiz
= bfd_getl32 (vms_rec
+ 16);
929 if ((vms_rec
+ 20 + vms_rec
[20] + 1) >= end
)
931 PRIV (hdr_data
).hdr_t_name
932 = _bfd_vms_save_counted_string (abfd
, vms_rec
+ 20, vms_rec
[20]);
933 ptr
= vms_rec
+ 20 + vms_rec
[20] + 1;
934 if ((ptr
+ *ptr
+ 1) >= end
)
936 PRIV (hdr_data
).hdr_t_version
937 = _bfd_vms_save_counted_string (abfd
, ptr
, *ptr
);
941 PRIV (hdr_data
).hdr_t_date
942 = _bfd_vms_save_sized_string (abfd
, ptr
, 17);
946 if (vms_rec
+ PRIV (recrd
.rec_size
- 6) > end
)
948 PRIV (hdr_data
).hdr_c_lnm
949 = _bfd_vms_save_sized_string (abfd
, vms_rec
, PRIV (recrd
.rec_size
- 6));
953 if (vms_rec
+ PRIV (recrd
.rec_size
- 6) > end
)
955 PRIV (hdr_data
).hdr_c_src
956 = _bfd_vms_save_sized_string (abfd
, vms_rec
, PRIV (recrd
.rec_size
- 6));
960 if (vms_rec
+ PRIV (recrd
.rec_size
- 6) > end
)
962 PRIV (hdr_data
).hdr_c_ttl
963 = _bfd_vms_save_sized_string (abfd
, vms_rec
, PRIV (recrd
.rec_size
- 6));
973 bfd_set_error (bfd_error_wrong_format
);
980 /* Typical sections for evax object files. */
982 #define EVAX_ABS_NAME "$ABS$"
983 #define EVAX_CODE_NAME "$CODE$"
984 #define EVAX_LINK_NAME "$LINK$"
985 #define EVAX_DATA_NAME "$DATA$"
986 #define EVAX_BSS_NAME "$BSS$"
987 #define EVAX_READONLYADDR_NAME "$READONLY_ADDR$"
988 #define EVAX_READONLY_NAME "$READONLY$"
989 #define EVAX_LITERAL_NAME "$LITERAL$"
990 #define EVAX_LITERALS_NAME "$LITERALS"
991 #define EVAX_COMMON_NAME "$COMMON$"
992 #define EVAX_LOCAL_NAME "$LOCAL$"
994 struct sec_flags_struct
996 const char *name
; /* Name of section. */
998 flagword flags_always
; /* Flags we set always. */
1000 flagword flags_hassize
; /* Flags we set if the section has a size > 0. */
1003 /* These flags are deccrtl/vaxcrtl (openVMS 6.2 Alpha) compatible. */
1005 static const struct sec_flags_struct evax_section_flags
[] =
1013 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_EXE
,
1014 SEC_CODE
| SEC_READONLY
,
1015 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_EXE
,
1016 SEC_CODE
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1017 { EVAX_LITERAL_NAME
,
1018 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
| EGPS__V_NOMOD
,
1019 SEC_DATA
| SEC_READONLY
,
1020 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
,
1021 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1023 EGPS__V_REL
| EGPS__V_RD
,
1024 SEC_DATA
| SEC_READONLY
,
1025 EGPS__V_REL
| EGPS__V_RD
,
1026 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1028 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
,
1030 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1031 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1033 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
,
1035 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
,
1037 { EVAX_READONLYADDR_NAME
,
1038 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_RD
,
1039 SEC_DATA
| SEC_READONLY
,
1040 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_RD
,
1041 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1042 { EVAX_READONLY_NAME
,
1043 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
| EGPS__V_NOMOD
,
1044 SEC_DATA
| SEC_READONLY
,
1045 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
,
1046 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1048 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1050 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1051 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1052 { EVAX_LITERALS_NAME
,
1053 EGPS__V_PIC
| EGPS__V_OVR
,
1054 SEC_DATA
| SEC_READONLY
,
1055 EGPS__V_PIC
| EGPS__V_OVR
,
1056 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1058 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1060 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1061 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
}
1064 /* Retrieve BFD section flags by name and size. */
1067 vms_secflag_by_name (const struct sec_flags_struct
*section_flags
,
1073 while (section_flags
[i
].name
!= NULL
)
1075 if (strcmp (name
, section_flags
[i
].name
) == 0)
1078 return section_flags
[i
].flags_hassize
;
1080 return section_flags
[i
].flags_always
;
1085 return section_flags
[i
].flags_hassize
;
1086 return section_flags
[i
].flags_always
;
1089 /* Retrieve VMS section flags by name and size. */
1092 vms_esecflag_by_name (const struct sec_flags_struct
*section_flags
,
1098 while (section_flags
[i
].name
!= NULL
)
1100 if (strcmp (name
, section_flags
[i
].name
) == 0)
1103 return section_flags
[i
].vflags_hassize
;
1105 return section_flags
[i
].vflags_always
;
1110 return section_flags
[i
].vflags_hassize
;
1111 return section_flags
[i
].vflags_always
;
1114 /* Add SYM to the symbol table of ABFD.
1115 Return FALSE in case of error. */
1118 add_symbol_entry (bfd
*abfd
, struct vms_symbol_entry
*sym
)
1120 if (PRIV (gsd_sym_count
) >= PRIV (max_sym_count
))
1122 if (PRIV (max_sym_count
) == 0)
1124 PRIV (max_sym_count
) = 128;
1125 PRIV (syms
) = bfd_malloc
1126 (PRIV (max_sym_count
) * sizeof (struct vms_symbol_entry
*));
1130 PRIV (max_sym_count
) *= 2;
1131 PRIV (syms
) = bfd_realloc_or_free
1133 (PRIV (max_sym_count
) * sizeof (struct vms_symbol_entry
*)));
1135 if (PRIV (syms
) == NULL
)
1139 PRIV (syms
)[PRIV (gsd_sym_count
)++] = sym
;
1143 /* Create a symbol whose name is ASCIC and add it to ABFD.
1144 Return NULL in case of error. */
1146 static struct vms_symbol_entry
*
1147 add_symbol (bfd
*abfd
, const unsigned char *ascic
, unsigned int max
)
1149 struct vms_symbol_entry
*entry
;
1156 _bfd_error_handler (_("record is too small for symbol name length"));
1157 bfd_set_error (bfd_error_bad_value
);
1161 entry
= (struct vms_symbol_entry
*)bfd_zalloc (abfd
, sizeof (*entry
) + len
);
1164 entry
->namelen
= len
;
1165 memcpy (entry
->name
, ascic
, len
);
1166 entry
->name
[len
] = 0;
1167 entry
->owner
= abfd
;
1169 if (!add_symbol_entry (abfd
, entry
))
1174 /* Read and process EGSD. Return FALSE on failure. */
1177 _bfd_vms_slurp_egsd (bfd
*abfd
)
1180 unsigned int gsd_size
;
1181 unsigned char *vms_rec
;
1185 vms_debug2 ((2, "EGSD\n"));
1187 if (PRIV (recrd
.rec_size
) < 8)
1189 _bfd_error_handler (_("corrupt EGSD record: its size (%#x) is too small"),
1190 PRIV (recrd
.rec_size
));
1191 bfd_set_error (bfd_error_bad_value
);
1195 PRIV (recrd
.rec
) += 8; /* Skip type, size, align pad. */
1196 PRIV (recrd
.rec_size
) -= 8;
1198 /* Calculate base address for each section. */
1201 while (PRIV (recrd
.rec_size
) > 4)
1203 vms_rec
= PRIV (recrd
.rec
);
1205 gsd_type
= bfd_getl16 (vms_rec
);
1206 gsd_size
= bfd_getl16 (vms_rec
+ 2);
1208 vms_debug2 ((3, "egsd_type %d\n", gsd_type
));
1210 /* PR 21615: Check for size overflow. */
1211 if (PRIV (recrd
.rec_size
) < gsd_size
)
1213 _bfd_error_handler (_("corrupt EGSD record type %d: size (%#x) "
1214 "is larger than remaining space (%#x)"),
1215 gsd_type
, gsd_size
, PRIV (recrd
.rec_size
));
1216 bfd_set_error (bfd_error_bad_value
);
1223 _bfd_error_handler (_("corrupt EGSD record type %d: size (%#x) "
1225 gsd_type
, gsd_size
);
1226 bfd_set_error (bfd_error_bad_value
);
1233 /* Program section definition. */
1235 struct vms_egps
*egps
= (struct vms_egps
*) vms_rec
;
1236 flagword new_flags
, vms_flags
;
1239 if (offsetof (struct vms_egps
, flags
) + 2 > gsd_size
)
1241 vms_flags
= bfd_getl16 (egps
->flags
);
1243 if ((vms_flags
& EGPS__V_REL
) == 0)
1245 /* Use the global absolute section for all
1246 absolute sections. */
1247 section
= bfd_abs_section_ptr
;
1255 if (offsetof (struct vms_egps
, namlng
) >= gsd_size
)
1257 left
= gsd_size
- offsetof (struct vms_egps
, namlng
);
1258 name
= _bfd_vms_save_counted_string (abfd
, &egps
->namlng
, left
);
1259 if (name
== NULL
|| name
[0] == 0)
1262 section
= bfd_make_section (abfd
, name
);
1266 section
->filepos
= 0;
1267 section
->size
= bfd_getl32 (egps
->alloc
);
1268 section
->alignment_power
= egps
->align
& 31;
1270 vms_section_data (section
)->flags
= vms_flags
;
1271 vms_section_data (section
)->no_flags
= 0;
1273 new_flags
= vms_secflag_by_name (evax_section_flags
,
1276 if (section
->size
> 0)
1277 new_flags
|= SEC_LOAD
;
1278 if (!(vms_flags
& EGPS__V_NOMOD
) && section
->size
> 0)
1280 /* Set RELOC and HAS_CONTENTS if the section is not
1281 demand-zero and not empty. */
1282 new_flags
|= SEC_HAS_CONTENTS
;
1283 if (vms_flags
& EGPS__V_REL
)
1284 new_flags
|= SEC_RELOC
;
1286 if (vms_flags
& EGPS__V_EXE
)
1288 /* Set CODE if section is executable. */
1289 new_flags
|= SEC_CODE
;
1290 new_flags
&= ~SEC_DATA
;
1292 if (!bfd_set_section_flags (section
, new_flags
))
1295 /* Give a non-overlapping vma to non absolute sections. */
1296 align_addr
= (bfd_vma
) 1 << section
->alignment_power
;
1297 base_addr
= (base_addr
+ align_addr
- 1) & -align_addr
;
1298 section
->vma
= base_addr
;
1299 base_addr
+= section
->size
;
1302 /* Append it to the section array. */
1303 if (PRIV (section_count
) >= PRIV (section_max
))
1305 if (PRIV (section_max
) == 0)
1306 PRIV (section_max
) = 16;
1308 PRIV (section_max
) *= 2;
1309 PRIV (sections
) = bfd_realloc_or_free
1310 (PRIV (sections
), PRIV (section_max
) * sizeof (asection
*));
1311 if (PRIV (sections
) == NULL
)
1315 PRIV (sections
)[PRIV (section_count
)] = section
;
1316 PRIV (section_count
)++;
1322 unsigned int nameoff
;
1323 struct vms_symbol_entry
*entry
;
1324 struct vms_egsy
*egsy
= (struct vms_egsy
*) vms_rec
;
1327 if (offsetof (struct vms_egsy
, flags
) + 2 > gsd_size
)
1329 old_flags
= bfd_getl16 (egsy
->flags
);
1330 if (old_flags
& EGSY__V_DEF
)
1331 nameoff
= ESDF__B_NAMLNG
;
1333 nameoff
= ESRF__B_NAMLNG
;
1335 if (nameoff
>= gsd_size
)
1337 entry
= add_symbol (abfd
, vms_rec
+ nameoff
, gsd_size
- nameoff
);
1341 /* Allow only duplicate reference. */
1342 if ((entry
->flags
& EGSY__V_DEF
) && (old_flags
& EGSY__V_DEF
))
1345 if (entry
->typ
== 0)
1347 entry
->typ
= gsd_type
;
1348 entry
->data_type
= egsy
->datyp
;
1349 entry
->flags
= old_flags
;
1352 if (old_flags
& EGSY__V_DEF
)
1354 struct vms_esdf
*esdf
= (struct vms_esdf
*) vms_rec
;
1356 entry
->value
= bfd_getl64 (esdf
->value
);
1357 if (PRIV (sections
) == NULL
)
1360 psindx
= bfd_getl32 (esdf
->psindx
);
1361 /* PR 21813: Check for an out of range index. */
1362 if (psindx
< 0 || psindx
>= (int) PRIV (section_count
))
1365 _bfd_error_handler (_("corrupt EGSD record: its psindx "
1366 "field is too big (%#lx)"),
1368 bfd_set_error (bfd_error_bad_value
);
1371 entry
->section
= PRIV (sections
)[psindx
];
1373 if (old_flags
& EGSY__V_NORM
)
1375 PRIV (norm_sym_count
)++;
1377 entry
->code_value
= bfd_getl64 (esdf
->code_address
);
1378 psindx
= bfd_getl32 (esdf
->ca_psindx
);
1379 /* PR 21813: Check for an out of range index. */
1380 if (psindx
< 0 || psindx
>= (int) PRIV (section_count
))
1382 entry
->code_section
= PRIV (sections
)[psindx
];
1390 struct vms_symbol_entry
*entry
;
1391 struct vms_egst
*egst
= (struct vms_egst
*)vms_rec
;
1393 unsigned int nameoff
= offsetof (struct vms_egst
, namlng
);
1395 if (nameoff
>= gsd_size
)
1397 entry
= add_symbol (abfd
, &egst
->namlng
, gsd_size
- nameoff
);
1401 old_flags
= bfd_getl16 (egst
->header
.flags
);
1402 entry
->typ
= gsd_type
;
1403 entry
->data_type
= egst
->header
.datyp
;
1404 entry
->flags
= old_flags
;
1406 entry
->symbol_vector
= bfd_getl32 (egst
->value
);
1408 if (old_flags
& EGSY__V_REL
)
1410 if (PRIV (sections
) == NULL
)
1412 psindx
= bfd_getl32 (egst
->psindx
);
1413 /* PR 21813: Check for an out of range index. */
1414 if (psindx
< 0 || psindx
>= (int) PRIV (section_count
))
1416 entry
->section
= PRIV (sections
)[psindx
];
1419 entry
->section
= bfd_abs_section_ptr
;
1421 entry
->value
= bfd_getl64 (egst
->lp_2
);
1423 if (old_flags
& EGSY__V_NORM
)
1425 PRIV (norm_sym_count
)++;
1427 entry
->code_value
= bfd_getl64 (egst
->lp_1
);
1428 entry
->code_section
= bfd_abs_section_ptr
;
1435 /* Currently ignored. */
1440 _bfd_error_handler (_("unknown EGSD subtype %d"), gsd_type
);
1441 bfd_set_error (bfd_error_bad_value
);
1445 PRIV (recrd
.rec_size
) -= gsd_size
;
1446 PRIV (recrd
.rec
) += gsd_size
;
1449 /* FIXME: Should we complain if PRIV (recrd.rec_size) is not zero ? */
1451 if (PRIV (gsd_sym_count
) > 0)
1452 abfd
->flags
|= HAS_SYMS
;
1457 /* Stack routines for vms ETIR commands. */
1459 /* Push value and section index. */
1462 _bfd_vms_push (bfd
*abfd
, bfd_vma val
, unsigned int reloc
)
1464 vms_debug2 ((4, "<push %08lx (0x%08x) at %d>\n",
1465 (unsigned long)val
, reloc
, PRIV (stackptr
)));
1467 PRIV (stack
[PRIV (stackptr
)]).value
= val
;
1468 PRIV (stack
[PRIV (stackptr
)]).reloc
= reloc
;
1470 if (PRIV (stackptr
) >= STACKSIZE
)
1472 bfd_set_error (bfd_error_bad_value
);
1473 _bfd_error_handler (_("stack overflow (%d) in _bfd_vms_push"), PRIV (stackptr
));
1479 /* Pop value and section index. */
1482 _bfd_vms_pop (bfd
*abfd
, bfd_vma
*val
, unsigned int *rel
)
1484 if (PRIV (stackptr
) == 0)
1486 bfd_set_error (bfd_error_bad_value
);
1487 _bfd_error_handler (_("stack underflow in _bfd_vms_pop"));
1491 *val
= PRIV (stack
[PRIV (stackptr
)]).value
;
1492 *rel
= PRIV (stack
[PRIV (stackptr
)]).reloc
;
1494 vms_debug2 ((4, "<pop %08lx (0x%08x)>\n", (unsigned long)*val
, *rel
));
1498 /* Routines to fill sections contents during tir/etir read. */
1500 /* Initialize image buffer pointer to be filled. */
1503 image_set_ptr (bfd
*abfd
, bfd_vma vma
, int sect
, struct bfd_link_info
*info
)
1507 vms_debug2 ((4, "image_set_ptr (0x%08x, sect=%d)\n", (unsigned)vma
, sect
));
1509 if (PRIV (sections
) == NULL
)
1511 if (sect
< 0 || sect
>= (int) PRIV (section_count
))
1514 sec
= PRIV (sections
)[sect
];
1518 /* Reading contents to an output bfd. */
1520 if (sec
->output_section
== NULL
)
1522 /* Section discarded. */
1523 vms_debug2 ((5, " section %s discarded\n", sec
->name
));
1525 /* This is not used. */
1526 PRIV (image_section
) = NULL
;
1527 PRIV (image_offset
) = 0;
1530 PRIV (image_offset
) = sec
->output_offset
+ vma
;
1531 PRIV (image_section
) = sec
->output_section
;
1535 PRIV (image_offset
) = vma
;
1536 PRIV (image_section
) = sec
;
1540 /* Increment image buffer pointer by offset. */
1543 image_inc_ptr (bfd
*abfd
, bfd_vma offset
)
1545 vms_debug2 ((4, "image_inc_ptr (%u)\n", (unsigned)offset
));
1547 PRIV (image_offset
) += offset
;
1550 /* Save current DST location counter under specified index. */
1553 dst_define_location (bfd
*abfd
, unsigned int loc
)
1555 vms_debug2 ((4, "dst_define_location (%d)\n", (int)loc
));
1559 /* 16M entries ought to be plenty. */
1560 bfd_set_error (bfd_error_bad_value
);
1561 _bfd_error_handler (_("dst_define_location %u too large"), loc
);
1565 /* Grow the ptr offset table if necessary. */
1566 if (loc
+ 1 > PRIV (dst_ptr_offsets_count
))
1568 PRIV (dst_ptr_offsets
)
1569 = bfd_realloc_or_free (PRIV (dst_ptr_offsets
),
1570 (loc
+ 1) * sizeof (unsigned int));
1571 if (PRIV (dst_ptr_offsets
) == NULL
)
1573 PRIV (dst_ptr_offsets_count
) = loc
+ 1;
1576 PRIV (dst_ptr_offsets
)[loc
] = PRIV (image_offset
);
1580 /* Restore saved DST location counter from specified index. */
1583 dst_restore_location (bfd
*abfd
, unsigned int loc
)
1585 vms_debug2 ((4, "dst_restore_location (%d)\n", (int)loc
));
1587 if (loc
< PRIV (dst_ptr_offsets_count
))
1589 PRIV (image_offset
) = PRIV (dst_ptr_offsets
)[loc
];
1595 /* Retrieve saved DST location counter from specified index. */
1598 dst_retrieve_location (bfd
*abfd
, bfd_vma
*loc
)
1600 vms_debug2 ((4, "dst_retrieve_location (%d)\n", (int) *loc
));
1602 if (*loc
< PRIV (dst_ptr_offsets_count
))
1604 *loc
= PRIV (dst_ptr_offsets
)[*loc
];
1610 /* Write multiple bytes to section image. */
1613 image_write (bfd
*abfd
, unsigned char *ptr
, unsigned int size
)
1615 asection
*sec
= PRIV (image_section
);
1616 size_t off
= PRIV (image_offset
);
1620 || size
> sec
->size
- off
)
1622 bfd_set_error (bfd_error_bad_value
);
1627 _bfd_vms_debug (8, "image_write from (%p, %d) to (%ld)\n", ptr
, size
,
1631 if (PRIV (image_section
)->contents
!= NULL
)
1632 memcpy (sec
->contents
+ off
, ptr
, size
);
1636 for (i
= 0; i
< size
; i
++)
1639 bfd_set_error (bfd_error_bad_value
);
1645 _bfd_hexdump (9, ptr
, size
, 0);
1648 PRIV (image_offset
) += size
;
1652 /* Write byte to section image. */
1655 image_write_b (bfd
* abfd
, unsigned int value
)
1657 unsigned char data
[1];
1659 vms_debug2 ((6, "image_write_b (%02x)\n", (int) value
));
1663 return image_write (abfd
, data
, sizeof (data
));
1666 /* Write 2-byte word to image. */
1669 image_write_w (bfd
* abfd
, unsigned int value
)
1671 unsigned char data
[2];
1673 vms_debug2 ((6, "image_write_w (%04x)\n", (int) value
));
1675 bfd_putl16 (value
, data
);
1676 return image_write (abfd
, data
, sizeof (data
));
1679 /* Write 4-byte long to image. */
1682 image_write_l (bfd
* abfd
, unsigned long value
)
1684 unsigned char data
[4];
1686 vms_debug2 ((6, "image_write_l (%08lx)\n", value
));
1688 bfd_putl32 (value
, data
);
1689 return image_write (abfd
, data
, sizeof (data
));
1692 /* Write 8-byte quad to image. */
1695 image_write_q (bfd
* abfd
, bfd_vma value
)
1697 unsigned char data
[8];
1699 vms_debug2 ((6, "image_write_q (%08lx)\n", (unsigned long)value
));
1701 bfd_putl64 (value
, data
);
1702 return image_write (abfd
, data
, sizeof (data
));
1706 _bfd_vms_etir_name (int cmd
)
1710 case ETIR__C_STA_GBL
: return "ETIR__C_STA_GBL";
1711 case ETIR__C_STA_LW
: return "ETIR__C_STA_LW";
1712 case ETIR__C_STA_QW
: return "ETIR__C_STA_QW";
1713 case ETIR__C_STA_PQ
: return "ETIR__C_STA_PQ";
1714 case ETIR__C_STA_LI
: return "ETIR__C_STA_LI";
1715 case ETIR__C_STA_MOD
: return "ETIR__C_STA_MOD";
1716 case ETIR__C_STA_CKARG
: return "ETIR__C_STA_CKARG";
1717 case ETIR__C_STO_B
: return "ETIR__C_STO_B";
1718 case ETIR__C_STO_W
: return "ETIR__C_STO_W";
1719 case ETIR__C_STO_GBL
: return "ETIR__C_STO_GBL";
1720 case ETIR__C_STO_CA
: return "ETIR__C_STO_CA";
1721 case ETIR__C_STO_RB
: return "ETIR__C_STO_RB";
1722 case ETIR__C_STO_AB
: return "ETIR__C_STO_AB";
1723 case ETIR__C_STO_OFF
: return "ETIR__C_STO_OFF";
1724 case ETIR__C_STO_IMM
: return "ETIR__C_STO_IMM";
1725 case ETIR__C_STO_IMMR
: return "ETIR__C_STO_IMMR";
1726 case ETIR__C_STO_LW
: return "ETIR__C_STO_LW";
1727 case ETIR__C_STO_QW
: return "ETIR__C_STO_QW";
1728 case ETIR__C_STO_GBL_LW
: return "ETIR__C_STO_GBL_LW";
1729 case ETIR__C_STO_LP_PSB
: return "ETIR__C_STO_LP_PSB";
1730 case ETIR__C_STO_HINT_GBL
: return "ETIR__C_STO_HINT_GBL";
1731 case ETIR__C_STO_HINT_PS
: return "ETIR__C_STO_HINT_PS";
1732 case ETIR__C_OPR_ADD
: return "ETIR__C_OPR_ADD";
1733 case ETIR__C_OPR_SUB
: return "ETIR__C_OPR_SUB";
1734 case ETIR__C_OPR_INSV
: return "ETIR__C_OPR_INSV";
1735 case ETIR__C_OPR_USH
: return "ETIR__C_OPR_USH";
1736 case ETIR__C_OPR_ROT
: return "ETIR__C_OPR_ROT";
1737 case ETIR__C_OPR_REDEF
: return "ETIR__C_OPR_REDEF";
1738 case ETIR__C_OPR_DFLIT
: return "ETIR__C_OPR_DFLIT";
1739 case ETIR__C_STC_LP
: return "ETIR__C_STC_LP";
1740 case ETIR__C_STC_GBL
: return "ETIR__C_STC_GBL";
1741 case ETIR__C_STC_GCA
: return "ETIR__C_STC_GCA";
1742 case ETIR__C_STC_PS
: return "ETIR__C_STC_PS";
1743 case ETIR__C_STC_NBH_PS
: return "ETIR__C_STC_NBH_PS";
1744 case ETIR__C_STC_NOP_GBL
: return "ETIR__C_STC_NOP_GBL";
1745 case ETIR__C_STC_NOP_PS
: return "ETIR__C_STC_NOP_PS";
1746 case ETIR__C_STC_BSR_GBL
: return "ETIR__C_STC_BSR_GBL";
1747 case ETIR__C_STC_BSR_PS
: return "ETIR__C_STC_BSR_PS";
1748 case ETIR__C_STC_LDA_GBL
: return "ETIR__C_STC_LDA_GBL";
1749 case ETIR__C_STC_LDA_PS
: return "ETIR__C_STC_LDA_PS";
1750 case ETIR__C_STC_BOH_GBL
: return "ETIR__C_STC_BOH_GBL";
1751 case ETIR__C_STC_BOH_PS
: return "ETIR__C_STC_BOH_PS";
1752 case ETIR__C_STC_NBH_GBL
: return "ETIR__C_STC_NBH_GBL";
1753 case ETIR__C_STC_LP_PSB
: return "ETIR__C_STC_LP_PSB";
1754 case ETIR__C_CTL_SETRB
: return "ETIR__C_CTL_SETRB";
1755 case ETIR__C_CTL_AUGRB
: return "ETIR__C_CTL_AUGRB";
1756 case ETIR__C_CTL_DFLOC
: return "ETIR__C_CTL_DFLOC";
1757 case ETIR__C_CTL_STLOC
: return "ETIR__C_CTL_STLOC";
1758 case ETIR__C_CTL_STKDL
: return "ETIR__C_CTL_STKDL";
1761 /* These names have not yet been added to this switch statement. */
1762 _bfd_error_handler (_("unknown ETIR command %d"), cmd
);
1767 #define HIGHBIT(op) ((op & 0x80000000L) == 0x80000000L)
1770 _bfd_vms_get_value (bfd
*abfd
,
1771 const unsigned char *ascic
,
1772 const unsigned char *max_ascic
,
1773 struct bfd_link_info
*info
,
1775 struct alpha_vms_link_hash_entry
**hp
)
1780 struct alpha_vms_link_hash_entry
*h
;
1782 /* Not linking. Do not try to resolve the symbol. */
1791 if (ascic
+ len
>= max_ascic
)
1793 _bfd_error_handler (_("corrupt vms value"));
1799 for (i
= 0; i
< len
; i
++)
1800 name
[i
] = ascic
[i
+ 1];
1803 h
= (struct alpha_vms_link_hash_entry
*)
1804 bfd_link_hash_lookup (info
->hash
, name
, false, false, true);
1809 && (h
->root
.type
== bfd_link_hash_defined
1810 || h
->root
.type
== bfd_link_hash_defweak
))
1811 *vma
= h
->root
.u
.def
.value
1812 + h
->root
.u
.def
.section
->output_offset
1813 + h
->root
.u
.def
.section
->output_section
->vma
;
1814 else if (h
&& h
->root
.type
== bfd_link_hash_undefweak
)
1818 (*info
->callbacks
->undefined_symbol
)
1819 (info
, name
, abfd
, PRIV (image_section
), PRIV (image_offset
), true);
1826 #define RELC_SHR_BASE 0x10000
1827 #define RELC_SEC_BASE 0x20000
1828 #define RELC_MASK 0x0ffff
1831 alpha_vms_sym_to_ctxt (struct alpha_vms_link_hash_entry
*h
)
1833 /* Handle undefined symbols. */
1834 if (h
== NULL
|| h
->sym
== NULL
)
1837 if (h
->sym
->typ
== EGSD__C_SYMG
)
1839 if (h
->sym
->flags
& EGSY__V_REL
)
1840 return RELC_SHR_BASE
+ PRIV2 (h
->sym
->owner
, shr_index
);
1843 /* Can this happen (non-relocatable symg) ? I'd like to see
1848 if (h
->sym
->typ
== EGSD__C_SYM
)
1850 if (h
->sym
->flags
& EGSY__V_REL
)
1859 alpha_vms_get_sym_value (asection
*sect
, bfd_vma addr
)
1861 return sect
->output_section
->vma
+ sect
->output_offset
+ addr
;
1865 alpha_vms_fix_sec_rel (bfd
*abfd
, struct bfd_link_info
*info
,
1866 unsigned int rel
, bfd_vma vma
)
1870 if (PRIV (sections
) == NULL
)
1873 sec
= PRIV (sections
)[rel
& RELC_MASK
];
1877 if (sec
->output_section
== NULL
)
1879 return vma
+ sec
->output_section
->vma
+ sec
->output_offset
;
1882 return vma
+ sec
->vma
;
1885 /* Read an ETIR record from ABFD. If INFO is not null, put the content into
1886 the output section (used during linking).
1887 Return FALSE in case of error. */
1890 _bfd_vms_slurp_etir (bfd
*abfd
, struct bfd_link_info
*info
)
1893 unsigned int length
;
1894 unsigned char *maxptr
;
1897 unsigned int rel1
= RELC_NONE
;
1898 unsigned int rel2
= RELC_NONE
;
1899 struct alpha_vms_link_hash_entry
*h
;
1901 PRIV (recrd
.rec
) += ETIR__C_HEADER_SIZE
;
1902 PRIV (recrd
.rec_size
) -= ETIR__C_HEADER_SIZE
;
1904 ptr
= PRIV (recrd
.rec
);
1905 length
= PRIV (recrd
.rec_size
);
1906 maxptr
= ptr
+ length
;
1908 vms_debug2 ((2, "ETIR: %d bytes\n", length
));
1910 while (ptr
< maxptr
)
1912 int cmd
, cmd_length
;
1914 if (ptr
+ 4 > maxptr
)
1917 cmd
= bfd_getl16 (ptr
);
1918 cmd_length
= bfd_getl16 (ptr
+ 2);
1920 /* PR 21589 and 21579: Check for a corrupt ETIR record. */
1921 if (cmd_length
< 4 || ptr
+ cmd_length
> maxptr
)
1924 _bfd_error_handler (_("corrupt ETIR record encountered"));
1925 bfd_set_error (bfd_error_bad_value
);
1932 _bfd_vms_debug (4, "etir: %s(%d)\n",
1933 _bfd_vms_etir_name (cmd
), cmd
);
1934 _bfd_hexdump (8, ptr
, cmd_length
, 0);
1942 stack 32 bit value of symbol (high bits set to 0). */
1943 case ETIR__C_STA_GBL
:
1944 _bfd_vms_get_value (abfd
, ptr
, ptr
+ cmd_length
, info
, &op1
, &h
);
1945 if (!_bfd_vms_push (abfd
, op1
, alpha_vms_sym_to_ctxt (h
)))
1952 stack 32 bit value, sign extend to 64 bit. */
1953 case ETIR__C_STA_LW
:
1956 if (!_bfd_vms_push (abfd
, bfd_getl32 (ptr
), RELC_NONE
))
1963 stack 64 bit value of symbol. */
1964 case ETIR__C_STA_QW
:
1967 if (!_bfd_vms_push (abfd
, bfd_getl64 (ptr
), RELC_NONE
))
1971 /* Stack psect base plus quadword offset
1972 arg: lw section index
1973 qw signed quadword offset (low 32 bits)
1975 Stack qw argument and section index
1976 (see ETIR__C_STO_OFF, ETIR__C_CTL_SETRB). */
1977 case ETIR__C_STA_PQ
:
1981 if (cmd_length
< 12)
1983 psect
= bfd_getl32 (ptr
);
1984 if ((unsigned int) psect
>= PRIV (section_count
))
1986 _bfd_error_handler (_("bad section index in %s"),
1987 _bfd_vms_etir_name (cmd
));
1988 bfd_set_error (bfd_error_bad_value
);
1991 op1
= bfd_getl64 (ptr
+ 4);
1992 if (!_bfd_vms_push (abfd
, op1
, psect
| RELC_SEC_BASE
))
1997 case ETIR__C_STA_LI
:
1998 case ETIR__C_STA_MOD
:
1999 case ETIR__C_STA_CKARG
:
2000 _bfd_error_handler (_("unsupported STA cmd %s"),
2001 _bfd_vms_etir_name (cmd
));
2005 /* Store byte: pop stack, write byte
2008 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2010 if (rel1
!= RELC_NONE
)
2012 if (!image_write_b (abfd
, (unsigned int) op1
& 0xff))
2016 /* Store word: pop stack, write word
2019 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2021 if (rel1
!= RELC_NONE
)
2023 if (!image_write_w (abfd
, (unsigned int) op1
& 0xffff))
2027 /* Store longword: pop stack, write longword
2029 case ETIR__C_STO_LW
:
2030 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2032 if (rel1
& RELC_SEC_BASE
)
2034 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2037 else if (rel1
& RELC_SHR_BASE
)
2039 if (!alpha_vms_add_fixup_lr (info
, rel1
& RELC_MASK
, op1
))
2043 if (rel1
!= RELC_NONE
)
2045 if (rel1
!= RELC_REL
)
2047 if (!alpha_vms_add_lw_reloc (info
))
2050 if (!image_write_l (abfd
, op1
))
2054 /* Store quadword: pop stack, write quadword
2056 case ETIR__C_STO_QW
:
2057 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2059 if (rel1
& RELC_SEC_BASE
)
2061 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2064 else if (rel1
& RELC_SHR_BASE
)
2066 if (rel1
!= RELC_NONE
)
2068 if (rel1
!= RELC_REL
)
2070 if (!alpha_vms_add_qw_reloc (info
))
2073 if (!image_write_q (abfd
, op1
))
2077 /* Store immediate repeated: pop stack for repeat count
2080 case ETIR__C_STO_IMMR
:
2086 size
= bfd_getl32 (ptr
);
2087 if (size
> cmd_length
- 4)
2089 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2091 if (rel1
!= RELC_NONE
)
2097 if (!image_write (abfd
, ptr
+ 4, size
))
2102 /* Store global: write symbol value
2103 arg: cs global symbol name. */
2104 case ETIR__C_STO_GBL
:
2105 _bfd_vms_get_value (abfd
, ptr
, ptr
+ cmd_length
, info
, &op1
, &h
);
2108 if (h
->sym
->typ
== EGSD__C_SYMG
)
2110 if (!alpha_vms_add_fixup_qr (info
, abfd
, h
->sym
->owner
,
2111 h
->sym
->symbol_vector
))
2117 op1
= alpha_vms_get_sym_value (h
->sym
->section
,
2119 if (!alpha_vms_add_qw_reloc (info
))
2123 if (!image_write_q (abfd
, op1
))
2127 /* Store code address: write address of entry point
2128 arg: cs global symbol name (procedure). */
2129 case ETIR__C_STO_CA
:
2130 _bfd_vms_get_value (abfd
, ptr
, ptr
+ cmd_length
, info
, &op1
, &h
);
2133 if (h
->sym
->flags
& EGSY__V_NORM
)
2135 /* That's really a procedure. */
2136 if (h
->sym
->typ
== EGSD__C_SYMG
)
2138 if (!alpha_vms_add_fixup_ca (info
, abfd
, h
->sym
->owner
))
2140 op1
= h
->sym
->symbol_vector
;
2144 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
2145 h
->sym
->code_value
);
2146 if (!alpha_vms_add_qw_reloc (info
))
2152 /* Symbol is not a procedure. */
2156 if (!image_write_q (abfd
, op1
))
2160 /* Store offset to psect: pop stack, add low 32 bits to base of psect
2162 case ETIR__C_STO_OFF
:
2163 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2166 if (!(rel1
& RELC_SEC_BASE
))
2169 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2171 if (!image_write_q (abfd
, op1
))
2176 arg: lw count of bytes
2178 case ETIR__C_STO_IMM
:
2184 size
= bfd_getl32 (ptr
);
2185 if (!image_write (abfd
, ptr
+ 4, size
))
2190 /* This code is 'reserved to digital' according to the openVMS
2191 linker manual, however it is generated by the DEC C compiler
2192 and defined in the include file.
2193 FIXME, since the following is just a guess
2194 store global longword: store 32bit value of symbol
2195 arg: cs symbol name. */
2196 case ETIR__C_STO_GBL_LW
:
2197 _bfd_vms_get_value (abfd
, ptr
, ptr
+ cmd_length
, info
, &op1
, &h
);
2201 if (!image_write_l (abfd
, op1
))
2205 case ETIR__C_STO_RB
:
2206 case ETIR__C_STO_AB
:
2207 case ETIR__C_STO_LP_PSB
:
2208 _bfd_error_handler (_("%s: not supported"),
2209 _bfd_vms_etir_name (cmd
));
2212 case ETIR__C_STO_HINT_GBL
:
2213 case ETIR__C_STO_HINT_PS
:
2214 _bfd_error_handler (_("%s: not implemented"),
2215 _bfd_vms_etir_name (cmd
));
2219 /* 200 Store-conditional Linkage Pair
2221 case ETIR__C_STC_LP
:
2223 /* 202 Store-conditional Address at global address
2227 case ETIR__C_STC_GBL
:
2229 /* 203 Store-conditional Code Address at global address
2231 cs procedure name. */
2232 case ETIR__C_STC_GCA
:
2234 /* 204 Store-conditional Address at psect + offset
2238 case ETIR__C_STC_PS
:
2239 _bfd_error_handler (_("%s: not supported"),
2240 _bfd_vms_etir_name (cmd
));
2244 /* 201 Store-conditional Linkage Pair with Procedure Signature
2250 case ETIR__C_STC_LP_PSB
:
2253 _bfd_vms_get_value (abfd
, ptr
+ 4, ptr
+ cmd_length
, info
, &op1
, &h
);
2256 if (h
->sym
->typ
== EGSD__C_SYMG
)
2258 if (!alpha_vms_add_fixup_lp (info
, abfd
, h
->sym
->owner
))
2260 op1
= h
->sym
->symbol_vector
;
2265 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
2266 h
->sym
->code_value
);
2267 op2
= alpha_vms_get_sym_value (h
->sym
->section
,
2273 /* Undefined symbol. */
2277 if (!image_write_q (abfd
, op1
)
2278 || !image_write_q (abfd
, op2
))
2282 /* 205 Store-conditional NOP at address of global
2284 case ETIR__C_STC_NOP_GBL
:
2287 /* 207 Store-conditional BSR at global address
2290 case ETIR__C_STC_BSR_GBL
:
2293 /* 209 Store-conditional LDA at global address
2296 case ETIR__C_STC_LDA_GBL
:
2299 /* 211 Store-conditional BSR or Hint at global address
2302 case ETIR__C_STC_BOH_GBL
:
2303 /* Currentl ignored. */
2306 /* 213 Store-conditional NOP,BSR or HINT at global address
2309 case ETIR__C_STC_NBH_GBL
:
2311 /* 206 Store-conditional NOP at pect + offset
2314 case ETIR__C_STC_NOP_PS
:
2316 /* 208 Store-conditional BSR at pect + offset
2319 case ETIR__C_STC_BSR_PS
:
2321 /* 210 Store-conditional LDA at psect + offset
2324 case ETIR__C_STC_LDA_PS
:
2326 /* 212 Store-conditional BSR or Hint at pect + offset
2329 case ETIR__C_STC_BOH_PS
:
2331 /* 214 Store-conditional NOP, BSR or HINT at psect + offset
2333 case ETIR__C_STC_NBH_PS
:
2334 _bfd_error_handler (_("%s: not supported"),
2335 _bfd_vms_etir_name (cmd
));
2339 /* Det relocation base: pop stack, set image location counter
2341 case ETIR__C_CTL_SETRB
:
2342 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2344 if (!(rel1
& RELC_SEC_BASE
))
2346 image_set_ptr (abfd
, op1
, rel1
& RELC_MASK
, info
);
2349 /* Augment relocation base: increment image location counter by offset
2350 arg: lw offset value. */
2351 case ETIR__C_CTL_AUGRB
:
2354 op1
= bfd_getl32 (ptr
);
2355 image_inc_ptr (abfd
, op1
);
2358 /* Define location: pop index, save location counter under index
2360 case ETIR__C_CTL_DFLOC
:
2361 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2363 if (rel1
!= RELC_NONE
)
2365 if (!dst_define_location (abfd
, op1
))
2369 /* Set location: pop index, restore location counter from index
2371 case ETIR__C_CTL_STLOC
:
2372 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2374 if (rel1
!= RELC_NONE
)
2376 if (!dst_restore_location (abfd
, op1
))
2378 bfd_set_error (bfd_error_bad_value
);
2379 _bfd_error_handler (_("invalid %s"), "ETIR__C_CTL_STLOC");
2384 /* Stack defined location: pop index, push location counter from index
2386 case ETIR__C_CTL_STKDL
:
2387 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2389 if (rel1
!= RELC_NONE
)
2391 if (!dst_retrieve_location (abfd
, &op1
))
2393 bfd_set_error (bfd_error_bad_value
);
2394 _bfd_error_handler (_("invalid %s"), "ETIR__C_CTL_STKDL");
2397 if (!_bfd_vms_push (abfd
, op1
, RELC_NONE
))
2401 case ETIR__C_OPR_NOP
: /* No-op. */
2404 case ETIR__C_OPR_ADD
: /* Add. */
2405 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2406 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2408 if (rel1
== RELC_NONE
&& rel2
!= RELC_NONE
)
2410 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2412 if (!_bfd_vms_push (abfd
, op1
+ op2
, rel1
))
2416 case ETIR__C_OPR_SUB
: /* Subtract. */
2417 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2418 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2420 if (rel1
== RELC_NONE
&& rel2
!= RELC_NONE
)
2422 else if ((rel1
& RELC_SEC_BASE
) && (rel2
& RELC_SEC_BASE
))
2424 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2425 op2
= alpha_vms_fix_sec_rel (abfd
, info
, rel2
, op2
);
2428 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2430 if (!_bfd_vms_push (abfd
, op2
- op1
, rel1
))
2434 case ETIR__C_OPR_MUL
: /* Multiply. */
2435 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2436 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2438 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2440 if (!_bfd_vms_push (abfd
, op1
* op2
, RELC_NONE
))
2444 case ETIR__C_OPR_DIV
: /* Divide. */
2445 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2446 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2448 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2452 /* Divide by zero is supposed to give a result of zero,
2453 and a non-fatal warning message. */
2454 _bfd_error_handler (_("%s divide by zero"), "ETIR__C_OPR_DIV");
2455 if (!_bfd_vms_push (abfd
, 0, RELC_NONE
))
2460 if (!_bfd_vms_push (abfd
, op2
/ op1
, RELC_NONE
))
2465 case ETIR__C_OPR_AND
: /* Logical AND. */
2466 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2467 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2469 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2471 if (!_bfd_vms_push (abfd
, op1
& op2
, RELC_NONE
))
2475 case ETIR__C_OPR_IOR
: /* Logical inclusive OR. */
2476 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2477 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2479 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2481 if (!_bfd_vms_push (abfd
, op1
| op2
, RELC_NONE
))
2485 case ETIR__C_OPR_EOR
: /* Logical exclusive OR. */
2486 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2487 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2489 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2491 if (!_bfd_vms_push (abfd
, op1
^ op2
, RELC_NONE
))
2495 case ETIR__C_OPR_NEG
: /* Negate. */
2496 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2498 if (rel1
!= RELC_NONE
)
2500 if (!_bfd_vms_push (abfd
, -op1
, RELC_NONE
))
2504 case ETIR__C_OPR_COM
: /* Complement. */
2505 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2507 if (rel1
!= RELC_NONE
)
2509 if (!_bfd_vms_push (abfd
, ~op1
, RELC_NONE
))
2513 case ETIR__C_OPR_ASH
: /* Arithmetic shift. */
2514 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2515 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2517 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2520 _bfd_error_handler (_("invalid use of %s with contexts"),
2521 _bfd_vms_etir_name (cmd
));
2524 if ((bfd_signed_vma
) op2
< 0)
2529 if (op2
>= CHAR_BIT
* sizeof (op1
))
2530 op2
= CHAR_BIT
* sizeof (op1
) - 1;
2531 /* op1 = (bfd_signed_vma) op1 >> op2; */
2532 sign
= op1
& ((bfd_vma
) 1 << (CHAR_BIT
* sizeof (op1
) - 1));
2535 op1
= (op1
^ sign
) - sign
;
2540 if (op2
>= CHAR_BIT
* sizeof (op1
))
2545 if (!_bfd_vms_push (abfd
, op1
, RELC_NONE
)) /* FIXME: sym. */
2549 case ETIR__C_OPR_INSV
: /* Insert field. */
2550 case ETIR__C_OPR_USH
: /* Unsigned shift. */
2551 case ETIR__C_OPR_ROT
: /* Rotate. */
2552 case ETIR__C_OPR_REDEF
: /* Redefine symbol to current location. */
2553 case ETIR__C_OPR_DFLIT
: /* Define a literal. */
2554 _bfd_error_handler (_("%s: not supported"),
2555 _bfd_vms_etir_name (cmd
));
2559 case ETIR__C_OPR_SEL
: /* Select. */
2560 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2564 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2569 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2570 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2572 if (!_bfd_vms_push (abfd
, op1
, rel1
))
2578 _bfd_error_handler (_("reserved cmd %d"), cmd
);
2589 /* Process EDBG/ETBT record.
2590 Return TRUE on success, FALSE on error */
2593 vms_slurp_debug (bfd
*abfd
)
2595 asection
*section
= PRIV (dst_section
);
2597 if (section
== NULL
)
2599 /* We have no way to find out beforehand how much debug info there
2600 is in an object file, so pick an initial amount and grow it as
2602 flagword flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
| SEC_RELOC
2605 section
= bfd_make_section (abfd
, "$DST$");
2608 if (!bfd_set_section_flags (section
, flags
))
2610 PRIV (dst_section
) = section
;
2613 PRIV (image_section
) = section
;
2614 PRIV (image_offset
) = section
->size
;
2616 if (!_bfd_vms_slurp_etir (abfd
, NULL
))
2619 section
->size
= PRIV (image_offset
);
2623 /* Process EDBG record.
2624 Return TRUE on success, FALSE on error. */
2627 _bfd_vms_slurp_edbg (bfd
*abfd
)
2629 vms_debug2 ((2, "EDBG\n"));
2631 abfd
->flags
|= HAS_DEBUG
| HAS_LINENO
;
2633 return vms_slurp_debug (abfd
);
2636 /* Process ETBT record.
2637 Return TRUE on success, FALSE on error. */
2640 _bfd_vms_slurp_etbt (bfd
*abfd
)
2642 vms_debug2 ((2, "ETBT\n"));
2644 abfd
->flags
|= HAS_LINENO
;
2646 return vms_slurp_debug (abfd
);
2649 /* Process EEOM record.
2650 Return TRUE on success, FALSE on error. */
2653 _bfd_vms_slurp_eeom (bfd
*abfd
)
2655 struct vms_eeom
*eeom
= (struct vms_eeom
*) PRIV (recrd
.rec
);
2657 vms_debug2 ((2, "EEOM\n"));
2659 /* PR 21813: Check for an undersized record. */
2660 if (PRIV (recrd
.buf_size
) < sizeof (* eeom
))
2662 _bfd_error_handler (_("corrupt EEOM record - size is too small"));
2663 bfd_set_error (bfd_error_bad_value
);
2667 PRIV (eom_data
).eom_l_total_lps
= bfd_getl32 (eeom
->total_lps
);
2668 PRIV (eom_data
).eom_w_comcod
= bfd_getl16 (eeom
->comcod
);
2669 if (PRIV (eom_data
).eom_w_comcod
> 1)
2671 _bfd_error_handler (_("object module not error-free !"));
2672 bfd_set_error (bfd_error_bad_value
);
2676 PRIV (eom_data
).eom_has_transfer
= false;
2677 if (PRIV (recrd
.rec_size
) > 10)
2679 PRIV (eom_data
).eom_has_transfer
= true;
2680 PRIV (eom_data
).eom_b_tfrflg
= eeom
->tfrflg
;
2681 PRIV (eom_data
).eom_l_psindx
= bfd_getl32 (eeom
->psindx
);
2682 PRIV (eom_data
).eom_l_tfradr
= bfd_getl32 (eeom
->tfradr
);
2684 abfd
->start_address
= PRIV (eom_data
).eom_l_tfradr
;
2689 /* Slurp an ordered set of VMS object records. Return FALSE on error. */
2692 _bfd_vms_slurp_object_records (bfd
* abfd
)
2699 vms_debug2 ((7, "reading at %08lx\n", (unsigned long)bfd_tell (abfd
)));
2701 type
= _bfd_vms_get_object_record (abfd
);
2704 vms_debug2 ((2, "next_record failed\n"));
2711 ok
= _bfd_vms_slurp_ehdr (abfd
);
2714 ok
= _bfd_vms_slurp_eeom (abfd
);
2717 ok
= _bfd_vms_slurp_egsd (abfd
);
2720 ok
= true; /* _bfd_vms_slurp_etir (abfd); */
2723 ok
= _bfd_vms_slurp_edbg (abfd
);
2726 ok
= _bfd_vms_slurp_etbt (abfd
);
2733 vms_debug2 ((2, "slurp type %d failed\n", type
));
2737 while (type
!= EOBJ__C_EEOM
);
2742 /* Initialize private data */
2744 vms_initialize (bfd
* abfd
)
2748 amt
= sizeof (struct vms_private_data_struct
);
2749 abfd
->tdata
.any
= bfd_zalloc (abfd
, amt
);
2750 if (abfd
->tdata
.any
== NULL
)
2753 PRIV (recrd
.file_format
) = FF_UNKNOWN
;
2755 amt
= sizeof (struct stack_struct
) * STACKSIZE
;
2756 PRIV (stack
) = bfd_alloc (abfd
, amt
);
2757 if (PRIV (stack
) == NULL
)
2763 bfd_release (abfd
, abfd
->tdata
.any
);
2764 abfd
->tdata
.any
= NULL
;
2768 /* Free malloc'd memory. */
2771 alpha_vms_free_private (bfd
*abfd
)
2773 struct module
*module
;
2775 free (PRIV (recrd
.buf
));
2776 free (PRIV (sections
));
2778 free (PRIV (dst_ptr_offsets
));
2780 for (module
= PRIV (modules
); module
; module
= module
->next
)
2781 free (module
->file_table
);
2784 /* Check the format for a file being read.
2785 Return a (bfd_target *) if it's an object file or zero if not. */
2788 alpha_vms_object_p (bfd
*abfd
)
2790 void *tdata_save
= abfd
->tdata
.any
;
2791 unsigned int test_len
;
2794 vms_debug2 ((1, "vms_object_p(%p)\n", abfd
));
2796 /* Allocate alpha-vms specific data. */
2797 if (!vms_initialize (abfd
))
2799 abfd
->tdata
.any
= tdata_save
;
2803 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
))
2806 /* The first challenge with VMS is to discover the kind of the file.
2808 Image files (executable or shared images) are stored as a raw
2809 stream of bytes (like on UNIX), but there is no magic number.
2811 Object files are written with RMS (record management service), ie
2812 each records are preceeded by its length (on a word - 2 bytes), and
2813 padded for word-alignment. That would be simple but when files
2814 are transfered to a UNIX filesystem (using ftp), records are lost.
2815 Only the raw content of the records are transfered. Fortunately,
2816 the Alpha Object file format also store the length of the record
2817 in the records. Is that clear ? */
2819 /* Minimum is 6 bytes for objects (2 bytes size, 2 bytes record id,
2820 2 bytes size repeated) and 12 bytes for images (4 bytes major id,
2821 4 bytes minor id, 4 bytes length). */
2823 buf
= _bfd_malloc_and_read (abfd
, test_len
, test_len
);
2826 PRIV (recrd
.buf
) = buf
;
2827 PRIV (recrd
.buf_size
) = test_len
;
2828 PRIV (recrd
.rec
) = buf
;
2830 /* Is it an image? */
2831 if ((bfd_getl32 (buf
) == EIHD__K_MAJORID
)
2832 && (bfd_getl32 (buf
+ 4) == EIHD__K_MINORID
))
2834 unsigned int eisd_offset
, eihs_offset
;
2836 /* Extract the header size. */
2837 PRIV (recrd
.rec_size
) = bfd_getl32 (buf
+ EIHD__L_SIZE
);
2839 /* The header size is 0 for DSF files. */
2840 if (PRIV (recrd
.rec_size
) == 0)
2841 PRIV (recrd
.rec_size
) = sizeof (struct vms_eihd
);
2843 /* PR 21813: Check for a truncated record. */
2844 /* PR 17512: file: 7d7c57c2. */
2845 if (PRIV (recrd
.rec_size
) < sizeof (struct vms_eihd
))
2846 goto err_wrong_format
;
2848 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
))
2851 free (PRIV (recrd
.buf
));
2852 PRIV (recrd
.buf
) = NULL
;
2853 buf
= _bfd_malloc_and_read (abfd
, PRIV (recrd
.rec_size
),
2854 PRIV (recrd
.rec_size
));
2858 PRIV (recrd
.buf
) = buf
;
2859 PRIV (recrd
.buf_size
) = PRIV (recrd
.rec_size
);
2860 PRIV (recrd
.rec
) = buf
;
2862 vms_debug2 ((2, "file type is image\n"));
2864 if (!_bfd_vms_slurp_eihd (abfd
, &eisd_offset
, &eihs_offset
))
2865 goto err_wrong_format
;
2867 if (!_bfd_vms_slurp_eisd (abfd
, eisd_offset
))
2868 goto err_wrong_format
;
2870 /* EIHS is optional. */
2871 if (eihs_offset
!= 0 && !_bfd_vms_slurp_eihs (abfd
, eihs_offset
))
2872 goto err_wrong_format
;
2878 /* Assume it's a module and adjust record pointer if necessary. */
2879 maybe_adjust_record_pointer_for_object (abfd
);
2881 /* But is it really a module? */
2882 if (bfd_getl16 (PRIV (recrd
.rec
)) <= EOBJ__C_MAXRECTYP
2883 && bfd_getl16 (PRIV (recrd
.rec
) + 2) <= EOBJ__C_MAXRECSIZ
)
2885 if (vms_get_remaining_object_record (abfd
, test_len
) <= 0)
2886 goto err_wrong_format
;
2888 vms_debug2 ((2, "file type is module\n"));
2890 type
= bfd_getl16 (PRIV (recrd
.rec
));
2891 if (type
!= EOBJ__C_EMH
|| !_bfd_vms_slurp_ehdr (abfd
))
2892 goto err_wrong_format
;
2894 if (!_bfd_vms_slurp_object_records (abfd
))
2895 goto err_wrong_format
;
2898 goto err_wrong_format
;
2901 /* Set arch_info to alpha. */
2903 if (! bfd_default_set_arch_mach (abfd
, bfd_arch_alpha
, 0))
2904 goto err_wrong_format
;
2906 return alpha_vms_free_private
;
2909 bfd_set_error (bfd_error_wrong_format
);
2912 alpha_vms_free_private (abfd
);
2913 if (abfd
->tdata
.any
!= tdata_save
&& abfd
->tdata
.any
!= NULL
)
2914 bfd_release (abfd
, abfd
->tdata
.any
);
2915 abfd
->tdata
.any
= tdata_save
;
2921 /* Write an EMH/MHD record. */
2924 _bfd_vms_write_emh (bfd
*abfd
)
2926 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2927 unsigned char tbuf
[18];
2929 _bfd_vms_output_alignment (recwr
, 2);
2932 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
2933 _bfd_vms_output_short (recwr
, EMH__C_MHD
);
2934 _bfd_vms_output_short (recwr
, EOBJ__C_STRLVL
);
2935 _bfd_vms_output_long (recwr
, 0);
2936 _bfd_vms_output_long (recwr
, 0);
2937 _bfd_vms_output_long (recwr
, MAX_OUTREC_SIZE
);
2939 /* Create module name from filename. */
2940 if (bfd_get_filename (abfd
) != 0)
2942 char *module
= vms_get_module_name (bfd_get_filename (abfd
), true);
2943 _bfd_vms_output_counted (recwr
, module
);
2947 _bfd_vms_output_counted (recwr
, "NONAME");
2949 _bfd_vms_output_counted (recwr
, BFD_VERSION_STRING
);
2950 _bfd_vms_output_dump (recwr
, get_vms_time_string (tbuf
), EMH_DATE_LENGTH
);
2951 _bfd_vms_output_fill (recwr
, 0, EMH_DATE_LENGTH
);
2952 _bfd_vms_output_end (abfd
, recwr
);
2955 /* Write an EMH/LMN record. */
2958 _bfd_vms_write_lmn (bfd
*abfd
, const char *name
)
2961 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2962 unsigned int ver
= BFD_VERSION
/ 10000;
2965 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
2966 _bfd_vms_output_short (recwr
, EMH__C_LNM
);
2967 snprintf (version
, sizeof (version
), "%s %d.%d.%d", name
,
2968 ver
/ 10000, (ver
/ 100) % 100, ver
% 100);
2969 _bfd_vms_output_dump (recwr
, (unsigned char *)version
, strlen (version
));
2970 _bfd_vms_output_end (abfd
, recwr
);
2974 /* Write eom record for bfd abfd. Return FALSE on error. */
2977 _bfd_vms_write_eeom (bfd
*abfd
)
2979 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2981 vms_debug2 ((2, "vms_write_eeom\n"));
2983 _bfd_vms_output_alignment (recwr
, 2);
2985 _bfd_vms_output_begin (recwr
, EOBJ__C_EEOM
);
2986 _bfd_vms_output_long (recwr
, PRIV (vms_linkage_index
+ 1) >> 1);
2987 _bfd_vms_output_byte (recwr
, 0); /* Completion code. */
2988 _bfd_vms_output_byte (recwr
, 0); /* Fill byte. */
2990 if ((abfd
->flags
& EXEC_P
) == 0
2991 && bfd_get_start_address (abfd
) != (bfd_vma
)-1)
2995 section
= bfd_get_section_by_name (abfd
, ".link");
2998 bfd_set_error (bfd_error_nonrepresentable_section
);
3001 _bfd_vms_output_short (recwr
, 0);
3002 _bfd_vms_output_long (recwr
, (unsigned long) section
->target_index
);
3003 _bfd_vms_output_long (recwr
,
3004 (unsigned long) bfd_get_start_address (abfd
));
3005 _bfd_vms_output_long (recwr
, 0);
3008 _bfd_vms_output_end (abfd
, recwr
);
3013 vector_grow1 (struct vector_type
*vec
, size_t elsz
)
3015 if (vec
->nbr_el
>= vec
->max_el
)
3017 if (vec
->max_el
== 0)
3020 vec
->els
= bfd_malloc (vec
->max_el
* elsz
);
3025 if (vec
->max_el
> -1u / 2)
3027 bfd_set_error (bfd_error_file_too_big
);
3031 if (_bfd_mul_overflow (vec
->max_el
, elsz
, &amt
))
3033 bfd_set_error (bfd_error_file_too_big
);
3036 vec
->els
= bfd_realloc_or_free (vec
->els
, amt
);
3039 if (vec
->els
== NULL
)
3041 return (char *) vec
->els
+ elsz
* vec
->nbr_el
++;
3044 /* Bump ABFD file position to next block. */
3047 alpha_vms_file_position_block (bfd
*abfd
)
3050 PRIV (file_pos
) += VMS_BLOCK_SIZE
- 1;
3051 PRIV (file_pos
) -= (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
3054 /* Convert from internal structure SRC to external structure DST. */
3057 alpha_vms_swap_eisd_out (struct vms_internal_eisd_map
*src
,
3058 struct vms_eisd
*dst
)
3060 bfd_putl32 (src
->u
.eisd
.majorid
, dst
->majorid
);
3061 bfd_putl32 (src
->u
.eisd
.minorid
, dst
->minorid
);
3062 bfd_putl32 (src
->u
.eisd
.eisdsize
, dst
->eisdsize
);
3063 if (src
->u
.eisd
.eisdsize
<= EISD__K_LENEND
)
3065 bfd_putl32 (src
->u
.eisd
.secsize
, dst
->secsize
);
3066 bfd_putl64 (src
->u
.eisd
.virt_addr
, dst
->virt_addr
);
3067 bfd_putl32 (src
->u
.eisd
.flags
, dst
->flags
);
3068 bfd_putl32 (src
->u
.eisd
.vbn
, dst
->vbn
);
3069 dst
->pfc
= src
->u
.eisd
.pfc
;
3070 dst
->matchctl
= src
->u
.eisd
.matchctl
;
3071 dst
->type
= src
->u
.eisd
.type
;
3073 if (src
->u
.eisd
.flags
& EISD__M_GBL
)
3075 bfd_putl32 (src
->u
.gbl_eisd
.ident
, dst
->ident
);
3076 memcpy (dst
->gblnam
, src
->u
.gbl_eisd
.gblnam
,
3077 src
->u
.gbl_eisd
.gblnam
[0] + 1);
3081 /* Append EISD to the list of extra eisd for ABFD. */
3084 alpha_vms_append_extra_eisd (bfd
*abfd
, struct vms_internal_eisd_map
*eisd
)
3087 if (PRIV (gbl_eisd_head
) == NULL
)
3088 PRIV (gbl_eisd_head
) = eisd
;
3090 PRIV (gbl_eisd_tail
)->next
= eisd
;
3091 PRIV (gbl_eisd_tail
) = eisd
;
3094 /* Create an EISD for shared image SHRIMG.
3095 Return FALSE in case of error. */
3098 alpha_vms_create_eisd_for_shared (bfd
*abfd
, bfd
*shrimg
)
3100 struct vms_internal_eisd_map
*eisd
;
3103 namlen
= strlen (PRIV2 (shrimg
, hdr_data
.hdr_t_name
));
3104 if (namlen
+ 5 > EISD__K_GBLNAMLEN
)
3110 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
3114 /* Fill the fields. */
3115 eisd
->u
.gbl_eisd
.common
.majorid
= EISD__K_MAJORID
;
3116 eisd
->u
.gbl_eisd
.common
.minorid
= EISD__K_MINORID
;
3117 eisd
->u
.gbl_eisd
.common
.eisdsize
= (EISD__K_LEN
+ 4 + namlen
+ 5 + 3) & ~3;
3118 eisd
->u
.gbl_eisd
.common
.secsize
= VMS_BLOCK_SIZE
; /* Must not be 0. */
3119 eisd
->u
.gbl_eisd
.common
.virt_addr
= 0;
3120 eisd
->u
.gbl_eisd
.common
.flags
= EISD__M_GBL
;
3121 eisd
->u
.gbl_eisd
.common
.vbn
= 0;
3122 eisd
->u
.gbl_eisd
.common
.pfc
= 0;
3123 eisd
->u
.gbl_eisd
.common
.matchctl
= PRIV2 (shrimg
, matchctl
);
3124 eisd
->u
.gbl_eisd
.common
.type
= EISD__K_SHRPIC
;
3126 eisd
->u
.gbl_eisd
.ident
= PRIV2 (shrimg
, ident
);
3127 eisd
->u
.gbl_eisd
.gblnam
[0] = namlen
+ 4;
3128 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1, PRIV2 (shrimg
, hdr_data
.hdr_t_name
),
3130 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1 + namlen
, "_001", 4);
3132 /* Append it to the list. */
3133 alpha_vms_append_extra_eisd (abfd
, eisd
);
3138 /* Create an EISD for section SEC.
3139 Return FALSE in case of failure. */
3142 alpha_vms_create_eisd_for_section (bfd
*abfd
, asection
*sec
)
3144 struct vms_internal_eisd_map
*eisd
;
3146 /* Only for allocating section. */
3147 if (!(sec
->flags
& SEC_ALLOC
))
3150 BFD_ASSERT (vms_section_data (sec
)->eisd
== NULL
);
3151 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
3154 vms_section_data (sec
)->eisd
= eisd
;
3156 /* Fill the fields. */
3157 eisd
->u
.eisd
.majorid
= EISD__K_MAJORID
;
3158 eisd
->u
.eisd
.minorid
= EISD__K_MINORID
;
3159 eisd
->u
.eisd
.eisdsize
= EISD__K_LEN
;
3160 eisd
->u
.eisd
.secsize
=
3161 (sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
3162 eisd
->u
.eisd
.virt_addr
= sec
->vma
;
3163 eisd
->u
.eisd
.flags
= 0;
3164 eisd
->u
.eisd
.vbn
= 0; /* To be later defined. */
3165 eisd
->u
.eisd
.pfc
= 0; /* Default. */
3166 eisd
->u
.eisd
.matchctl
= EISD__K_MATALL
;
3167 eisd
->u
.eisd
.type
= EISD__K_NORMAL
;
3169 if (sec
->flags
& SEC_CODE
)
3170 eisd
->u
.eisd
.flags
|= EISD__M_EXE
;
3171 if (!(sec
->flags
& SEC_READONLY
))
3172 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
3174 /* If relocations or fixup will be applied, make this isect writeable. */
3175 if (sec
->flags
& SEC_RELOC
)
3176 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
3178 if (!(sec
->flags
& SEC_HAS_CONTENTS
))
3180 eisd
->u
.eisd
.flags
|= EISD__M_DZRO
;
3181 eisd
->u
.eisd
.flags
&= ~EISD__M_CRF
;
3183 if (sec
->flags
& SEC_LINKER_CREATED
)
3185 if (strcmp (sec
->name
, "$FIXUP$") == 0)
3186 eisd
->u
.eisd
.flags
|= EISD__M_FIXUPVEC
;
3189 /* Append it to the list. */
3191 if (PRIV (eisd_head
) == NULL
)
3192 PRIV (eisd_head
) = eisd
;
3194 PRIV (eisd_tail
)->next
= eisd
;
3195 PRIV (eisd_tail
) = eisd
;
3200 /* Layout executable ABFD and write it to the disk.
3201 Return FALSE in case of failure. */
3204 alpha_vms_write_exec (bfd
*abfd
)
3206 struct vms_eihd eihd
;
3207 struct vms_eiha
*eiha
;
3208 struct vms_eihi
*eihi
;
3209 struct vms_eihs
*eihs
= NULL
;
3211 struct vms_internal_eisd_map
*first_eisd
;
3212 struct vms_internal_eisd_map
*eisd
;
3215 file_ptr gst_filepos
= 0;
3216 unsigned int lnkflags
= 0;
3218 /* Build the EIHD. */
3219 PRIV (file_pos
) = EIHD__C_LENGTH
;
3221 memset (&eihd
, 0, sizeof (eihd
));
3222 memset (eihd
.fill_2
, 0xff, sizeof (eihd
.fill_2
));
3224 bfd_putl32 (EIHD__K_MAJORID
, eihd
.majorid
);
3225 bfd_putl32 (EIHD__K_MINORID
, eihd
.minorid
);
3227 bfd_putl32 (sizeof (eihd
), eihd
.size
);
3228 bfd_putl32 (0, eihd
.isdoff
);
3229 bfd_putl32 (0, eihd
.activoff
);
3230 bfd_putl32 (0, eihd
.symdbgoff
);
3231 bfd_putl32 (0, eihd
.imgidoff
);
3232 bfd_putl32 (0, eihd
.patchoff
);
3233 bfd_putl64 (0, eihd
.iafva
);
3234 bfd_putl32 (0, eihd
.version_array_off
);
3236 bfd_putl32 (EIHD__K_EXE
, eihd
.imgtype
);
3237 bfd_putl32 (0, eihd
.subtype
);
3239 bfd_putl32 (0, eihd
.imgiocnt
);
3240 bfd_putl32 (-1, eihd
.privreqs
);
3241 bfd_putl32 (-1, eihd
.privreqs
+ 4);
3243 bfd_putl32 ((sizeof (eihd
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
3245 bfd_putl32 (0, eihd
.ident
);
3246 bfd_putl32 (0, eihd
.sysver
);
3249 bfd_putl32 (0, eihd
.symvect_size
);
3250 bfd_putl32 (16, eihd
.virt_mem_block_size
);
3251 bfd_putl32 (0, eihd
.ext_fixup_off
);
3252 bfd_putl32 (0, eihd
.noopt_psect_off
);
3253 bfd_putl16 (-1, eihd
.alias
);
3256 eiha
= (struct vms_eiha
*)((char *) &eihd
+ PRIV (file_pos
));
3257 bfd_putl32 (PRIV (file_pos
), eihd
.activoff
);
3258 PRIV (file_pos
) += sizeof (struct vms_eiha
);
3260 bfd_putl32 (sizeof (struct vms_eiha
), eiha
->size
);
3261 bfd_putl32 (0, eiha
->spare
);
3262 bfd_putl64 (PRIV (transfer_address
[0]), eiha
->tfradr1
);
3263 bfd_putl64 (PRIV (transfer_address
[1]), eiha
->tfradr2
);
3264 bfd_putl64 (PRIV (transfer_address
[2]), eiha
->tfradr3
);
3265 bfd_putl64 (PRIV (transfer_address
[3]), eiha
->tfradr4
);
3266 bfd_putl64 (0, eiha
->inishr
);
3269 eihi
= (struct vms_eihi
*)((char *) &eihd
+ PRIV (file_pos
));
3270 bfd_putl32 (PRIV (file_pos
), eihd
.imgidoff
);
3271 PRIV (file_pos
) += sizeof (struct vms_eihi
);
3273 bfd_putl32 (EIHI__K_MAJORID
, eihi
->majorid
);
3274 bfd_putl32 (EIHI__K_MINORID
, eihi
->minorid
);
3279 /* Set module name. */
3280 module
= vms_get_module_name (bfd_get_filename (abfd
), true);
3281 len
= strlen (module
);
3282 if (len
> sizeof (eihi
->imgnam
) - 1)
3283 len
= sizeof (eihi
->imgnam
) - 1;
3284 eihi
->imgnam
[0] = len
;
3285 memcpy (eihi
->imgnam
+ 1, module
, len
);
3293 vms_get_time (&hi
, &lo
);
3294 bfd_putl32 (lo
, eihi
->linktime
+ 0);
3295 bfd_putl32 (hi
, eihi
->linktime
+ 4);
3298 eihi
->linkid
[0] = 0;
3299 eihi
->imgbid
[0] = 0;
3302 dst
= PRIV (dst_section
);
3303 dmt
= bfd_get_section_by_name (abfd
, "$DMT$");
3304 if (dst
!= NULL
&& dst
->size
!= 0)
3306 eihs
= (struct vms_eihs
*)((char *) &eihd
+ PRIV (file_pos
));
3307 bfd_putl32 (PRIV (file_pos
), eihd
.symdbgoff
);
3308 PRIV (file_pos
) += sizeof (struct vms_eihs
);
3310 bfd_putl32 (EIHS__K_MAJORID
, eihs
->majorid
);
3311 bfd_putl32 (EIHS__K_MINORID
, eihs
->minorid
);
3312 bfd_putl32 (0, eihs
->dstvbn
);
3313 bfd_putl32 (0, eihs
->dstsize
);
3314 bfd_putl32 (0, eihs
->gstvbn
);
3315 bfd_putl32 (0, eihs
->gstsize
);
3316 bfd_putl32 (0, eihs
->dmtvbn
);
3317 bfd_putl32 (0, eihs
->dmtsize
);
3320 /* One EISD per section. */
3321 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3323 if (!alpha_vms_create_eisd_for_section (abfd
, sec
))
3327 /* Merge section EIDS which extra ones. */
3328 if (PRIV (eisd_tail
))
3329 PRIV (eisd_tail
)->next
= PRIV (gbl_eisd_head
);
3331 PRIV (eisd_head
) = PRIV (gbl_eisd_head
);
3332 if (PRIV (gbl_eisd_tail
))
3333 PRIV (eisd_tail
) = PRIV (gbl_eisd_tail
);
3335 first_eisd
= PRIV (eisd_head
);
3337 /* Add end of eisd. */
3340 eisd
= bfd_zalloc (abfd
, sizeof (*eisd
));
3343 eisd
->u
.eisd
.majorid
= 0;
3344 eisd
->u
.eisd
.minorid
= 0;
3345 eisd
->u
.eisd
.eisdsize
= 0;
3346 alpha_vms_append_extra_eisd (abfd
, eisd
);
3349 /* Place EISD in the file. */
3350 for (eisd
= first_eisd
; eisd
; eisd
= eisd
->next
)
3352 file_ptr room
= VMS_BLOCK_SIZE
- (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
3354 /* First block is a little bit special: there is a word at the end. */
3355 if (PRIV (file_pos
) < VMS_BLOCK_SIZE
&& room
> 2)
3357 if (room
< eisd
->u
.eisd
.eisdsize
+ EISD__K_LENEND
)
3358 alpha_vms_file_position_block (abfd
);
3360 eisd
->file_pos
= PRIV (file_pos
);
3361 PRIV (file_pos
) += eisd
->u
.eisd
.eisdsize
;
3363 if (eisd
->u
.eisd
.flags
& EISD__M_FIXUPVEC
)
3364 bfd_putl64 (eisd
->u
.eisd
.virt_addr
, eihd
.iafva
);
3367 if (first_eisd
!= NULL
)
3369 bfd_putl32 (first_eisd
->file_pos
, eihd
.isdoff
);
3370 /* Real size of end of eisd marker. */
3371 PRIV (file_pos
) += EISD__K_LENEND
;
3374 bfd_putl32 (PRIV (file_pos
), eihd
.size
);
3375 bfd_putl32 ((PRIV (file_pos
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
3378 /* Place sections. */
3379 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3381 if (!(sec
->flags
& SEC_HAS_CONTENTS
))
3384 eisd
= vms_section_data (sec
)->eisd
;
3386 /* Align on a block. */
3387 alpha_vms_file_position_block (abfd
);
3388 sec
->filepos
= PRIV (file_pos
);
3391 eisd
->u
.eisd
.vbn
= (sec
->filepos
/ VMS_BLOCK_SIZE
) + 1;
3393 PRIV (file_pos
) += sec
->size
;
3397 if (eihs
!= NULL
&& dst
!= NULL
)
3399 bfd_putl32 ((dst
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dstvbn
);
3400 bfd_putl32 (dst
->size
, eihs
->dstsize
);
3404 lnkflags
|= EIHD__M_DBGDMT
;
3405 bfd_putl32 ((dmt
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dmtvbn
);
3406 bfd_putl32 (dmt
->size
, eihs
->dmtsize
);
3408 if (PRIV (gsd_sym_count
) != 0)
3410 alpha_vms_file_position_block (abfd
);
3411 gst_filepos
= PRIV (file_pos
);
3412 bfd_putl32 ((gst_filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->gstvbn
);
3413 bfd_putl32 ((PRIV (gsd_sym_count
) + 4) / 5 + 4, eihs
->gstsize
);
3417 /* Write EISD in hdr. */
3418 for (eisd
= first_eisd
; eisd
&& eisd
->file_pos
< VMS_BLOCK_SIZE
;
3420 alpha_vms_swap_eisd_out
3421 (eisd
, (struct vms_eisd
*)((char *)&eihd
+ eisd
->file_pos
));
3423 /* Write first block. */
3424 bfd_putl32 (lnkflags
, eihd
.lnkflags
);
3425 if (bfd_bwrite (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
3428 /* Write remaining eisd. */
3431 unsigned char blk
[VMS_BLOCK_SIZE
];
3432 struct vms_internal_eisd_map
*next_eisd
;
3434 memset (blk
, 0xff, sizeof (blk
));
3435 while (eisd
!= NULL
)
3437 alpha_vms_swap_eisd_out
3439 (struct vms_eisd
*)(blk
+ (eisd
->file_pos
% VMS_BLOCK_SIZE
)));
3441 next_eisd
= eisd
->next
;
3442 if (next_eisd
== NULL
3443 || (next_eisd
->file_pos
/ VMS_BLOCK_SIZE
3444 != eisd
->file_pos
/ VMS_BLOCK_SIZE
))
3446 if (bfd_bwrite (blk
, sizeof (blk
), abfd
) != sizeof (blk
))
3449 memset (blk
, 0xff, sizeof (blk
));
3455 /* Write sections. */
3456 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3458 unsigned char blk
[VMS_BLOCK_SIZE
];
3461 if (sec
->size
== 0 || !(sec
->flags
& SEC_HAS_CONTENTS
))
3463 if (bfd_bwrite (sec
->contents
, sec
->size
, abfd
) != sec
->size
)
3467 len
= VMS_BLOCK_SIZE
- sec
->size
% VMS_BLOCK_SIZE
;
3468 if (len
!= VMS_BLOCK_SIZE
)
3470 memset (blk
, 0, len
);
3471 if (bfd_bwrite (blk
, len
, abfd
) != len
)
3477 if (gst_filepos
!= 0)
3479 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3482 _bfd_vms_write_emh (abfd
);
3483 _bfd_vms_write_lmn (abfd
, "GNU LD");
3485 /* PSC for the absolute section. */
3486 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3487 _bfd_vms_output_long (recwr
, 0);
3488 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3489 _bfd_vms_output_short (recwr
, 0);
3490 _bfd_vms_output_short (recwr
, EGPS__V_PIC
| EGPS__V_LIB
| EGPS__V_RD
);
3491 _bfd_vms_output_long (recwr
, 0);
3492 _bfd_vms_output_counted (recwr
, ".$$ABS$$.");
3493 _bfd_vms_output_end_subrec (recwr
);
3494 _bfd_vms_output_end (abfd
, recwr
);
3496 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
3498 struct vms_symbol_entry
*sym
= PRIV (syms
)[i
];
3504 _bfd_vms_output_alignment (recwr
, 8);
3505 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3506 _bfd_vms_output_long (recwr
, 0);
3508 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYMG
);
3509 _bfd_vms_output_short (recwr
, 0); /* Data type, alignment. */
3510 _bfd_vms_output_short (recwr
, sym
->flags
);
3512 if (sym
->code_section
)
3513 ep
= alpha_vms_get_sym_value (sym
->code_section
, sym
->code_value
);
3516 BFD_ASSERT (sym
->code_value
== 0);
3519 val
= alpha_vms_get_sym_value (sym
->section
, sym
->value
);
3520 _bfd_vms_output_quad
3521 (recwr
, sym
->typ
== EGSD__C_SYMG
? sym
->symbol_vector
: val
);
3522 _bfd_vms_output_quad (recwr
, ep
);
3523 _bfd_vms_output_quad (recwr
, val
);
3524 _bfd_vms_output_long (recwr
, 0);
3525 _bfd_vms_output_counted (recwr
, sym
->name
);
3526 _bfd_vms_output_end_subrec (recwr
);
3528 _bfd_vms_output_end (abfd
, recwr
);
3531 _bfd_vms_output_end (abfd
, recwr
);
3533 if (!_bfd_vms_write_eeom (abfd
))
3541 /* Write section and symbol directory of bfd abfd. Return FALSE on error. */
3544 _bfd_vms_write_egsd (bfd
*abfd
)
3548 unsigned int symnum
;
3550 flagword new_flags
, old_flags
;
3551 int abs_section_index
= -1;
3552 unsigned int target_index
= 0;
3553 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3555 vms_debug2 ((2, "vms_write_egsd\n"));
3557 /* Egsd is quadword aligned. */
3558 _bfd_vms_output_alignment (recwr
, 8);
3560 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3561 _bfd_vms_output_long (recwr
, 0);
3563 /* Number sections. */
3564 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3566 if (section
->flags
& SEC_DEBUGGING
)
3568 if (!strcmp (section
->name
, ".vmsdebug"))
3570 section
->flags
|= SEC_DEBUGGING
;
3573 section
->target_index
= target_index
++;
3576 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3578 vms_debug2 ((3, "Section #%d %s, %d bytes\n",
3579 section
->target_index
, section
->name
, (int)section
->size
));
3581 /* Don't write out the VMS debug info section since it is in the
3582 ETBT and EDBG sections in etir. */
3583 if (section
->flags
& SEC_DEBUGGING
)
3586 /* 13 bytes egsd, max 31 chars name -> should be 44 bytes. */
3587 if (_bfd_vms_output_check (recwr
, 64) < 0)
3589 _bfd_vms_output_end (abfd
, recwr
);
3590 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3591 _bfd_vms_output_long (recwr
, 0);
3594 /* Don't know if this is necessary for the linker but for now it keeps
3595 vms_slurp_gsd happy. */
3596 sname
= section
->name
;
3599 /* Remove leading dot. */
3601 if ((*sname
== 't') && (strcmp (sname
, "text") == 0))
3602 sname
= EVAX_CODE_NAME
;
3603 else if ((*sname
== 'd') && (strcmp (sname
, "data") == 0))
3604 sname
= EVAX_DATA_NAME
;
3605 else if ((*sname
== 'b') && (strcmp (sname
, "bss") == 0))
3606 sname
= EVAX_BSS_NAME
;
3607 else if ((*sname
== 'l') && (strcmp (sname
, "link") == 0))
3608 sname
= EVAX_LINK_NAME
;
3609 else if ((*sname
== 'r') && (strcmp (sname
, "rdata") == 0))
3610 sname
= EVAX_READONLY_NAME
;
3611 else if ((*sname
== 'l') && (strcmp (sname
, "literal") == 0))
3612 sname
= EVAX_LITERAL_NAME
;
3613 else if ((*sname
== 'l') && (strcmp (sname
, "literals") == 0))
3614 sname
= EVAX_LITERALS_NAME
;
3615 else if ((*sname
== 'c') && (strcmp (sname
, "comm") == 0))
3616 sname
= EVAX_COMMON_NAME
;
3617 else if ((*sname
== 'l') && (strcmp (sname
, "lcomm") == 0))
3618 sname
= EVAX_LOCAL_NAME
;
3621 if (bfd_is_com_section (section
))
3622 new_flags
= (EGPS__V_OVR
| EGPS__V_REL
| EGPS__V_GBL
| EGPS__V_RD
3623 | EGPS__V_WRT
| EGPS__V_NOMOD
| EGPS__V_COM
);
3625 new_flags
= vms_esecflag_by_name (evax_section_flags
, sname
,
3628 /* Modify them as directed. */
3629 if (section
->flags
& SEC_READONLY
)
3630 new_flags
&= ~EGPS__V_WRT
;
3632 new_flags
&= ~vms_section_data (section
)->no_flags
;
3633 new_flags
|= vms_section_data (section
)->flags
;
3635 vms_debug2 ((3, "sec flags %x\n", section
->flags
));
3636 vms_debug2 ((3, "new_flags %x, _raw_size %lu\n",
3637 new_flags
, (unsigned long)section
->size
));
3639 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3640 _bfd_vms_output_short (recwr
, section
->alignment_power
& 0xff);
3641 _bfd_vms_output_short (recwr
, new_flags
);
3642 _bfd_vms_output_long (recwr
, (unsigned long) section
->size
);
3643 _bfd_vms_output_counted (recwr
, sname
);
3644 _bfd_vms_output_end_subrec (recwr
);
3646 /* If the section is an obsolute one, remind its index as it will be
3647 used later for absolute symbols. */
3648 if ((new_flags
& EGPS__V_REL
) == 0 && abs_section_index
< 0)
3649 abs_section_index
= section
->target_index
;
3652 /* Output symbols. */
3653 vms_debug2 ((3, "%d symbols found\n", abfd
->symcount
));
3655 bfd_set_start_address (abfd
, (bfd_vma
) -1);
3657 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3659 symbol
= abfd
->outsymbols
[symnum
];
3660 old_flags
= symbol
->flags
;
3662 /* Work-around a missing feature: consider __main as the main entry
3664 if (symbol
->name
[0] == '_' && strcmp (symbol
->name
, "__main") == 0)
3665 bfd_set_start_address (abfd
, (bfd_vma
)symbol
->value
);
3667 /* Only put in the GSD the global and the undefined symbols. */
3668 if (old_flags
& BSF_FILE
)
3671 if ((old_flags
& BSF_GLOBAL
) == 0 && !bfd_is_und_section (symbol
->section
))
3673 /* If the LIB$INITIIALIZE section is present, add a reference to
3674 LIB$INITIALIZE symbol. FIXME: this should be done explicitely
3675 in the assembly file. */
3676 if (!((old_flags
& BSF_SECTION_SYM
) != 0
3677 && strcmp (symbol
->section
->name
, "LIB$INITIALIZE") == 0))
3681 /* 13 bytes egsd, max 64 chars name -> should be 77 bytes. Add 16 more
3682 bytes for a possible ABS section. */
3683 if (_bfd_vms_output_check (recwr
, 80 + 16) < 0)
3685 _bfd_vms_output_end (abfd
, recwr
);
3686 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3687 _bfd_vms_output_long (recwr
, 0);
3690 if ((old_flags
& BSF_GLOBAL
) != 0
3691 && bfd_is_abs_section (symbol
->section
)
3692 && abs_section_index
<= 0)
3694 /* Create an absolute section if none was defined. It is highly
3695 unlikely that the name $ABS$ clashes with a user defined
3696 non-absolute section name. */
3697 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3698 _bfd_vms_output_short (recwr
, 4);
3699 _bfd_vms_output_short (recwr
, EGPS__V_SHR
);
3700 _bfd_vms_output_long (recwr
, 0);
3701 _bfd_vms_output_counted (recwr
, "$ABS$");
3702 _bfd_vms_output_end_subrec (recwr
);
3704 abs_section_index
= target_index
++;
3707 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYM
);
3709 /* Data type, alignment. */
3710 _bfd_vms_output_short (recwr
, 0);
3714 if (old_flags
& BSF_WEAK
)
3715 new_flags
|= EGSY__V_WEAK
;
3716 if (bfd_is_com_section (symbol
->section
)) /* .comm */
3717 new_flags
|= (EGSY__V_WEAK
| EGSY__V_COMM
);
3719 if (old_flags
& BSF_FUNCTION
)
3721 new_flags
|= EGSY__V_NORM
;
3722 new_flags
|= EGSY__V_REL
;
3724 if (old_flags
& BSF_GLOBAL
)
3726 new_flags
|= EGSY__V_DEF
;
3727 if (!bfd_is_abs_section (symbol
->section
))
3728 new_flags
|= EGSY__V_REL
;
3730 _bfd_vms_output_short (recwr
, new_flags
);
3732 if (old_flags
& BSF_GLOBAL
)
3734 /* Symbol definition. */
3735 bfd_vma code_address
= 0;
3736 unsigned long ca_psindx
= 0;
3737 unsigned long psindx
;
3739 if ((old_flags
& BSF_FUNCTION
) && symbol
->udata
.p
!= NULL
)
3744 ((struct evax_private_udata_struct
*)symbol
->udata
.p
)->enbsym
;
3745 code_address
= sym
->value
;
3746 ca_psindx
= sym
->section
->target_index
;
3748 if (bfd_is_abs_section (symbol
->section
))
3749 psindx
= abs_section_index
;
3751 psindx
= symbol
->section
->target_index
;
3753 _bfd_vms_output_quad (recwr
, symbol
->value
);
3754 _bfd_vms_output_quad (recwr
, code_address
);
3755 _bfd_vms_output_long (recwr
, ca_psindx
);
3756 _bfd_vms_output_long (recwr
, psindx
);
3758 _bfd_vms_output_counted (recwr
, symbol
->name
);
3760 _bfd_vms_output_end_subrec (recwr
);
3763 _bfd_vms_output_alignment (recwr
, 8);
3764 _bfd_vms_output_end (abfd
, recwr
);
3769 /* Write object header for bfd abfd. Return FALSE on error. */
3772 _bfd_vms_write_ehdr (bfd
*abfd
)
3775 unsigned int symnum
;
3776 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3778 vms_debug2 ((2, "vms_write_ehdr (%p)\n", abfd
));
3780 _bfd_vms_output_alignment (recwr
, 2);
3782 _bfd_vms_write_emh (abfd
);
3783 _bfd_vms_write_lmn (abfd
, "GNU AS");
3786 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3787 _bfd_vms_output_short (recwr
, EMH__C_SRC
);
3789 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3791 symbol
= abfd
->outsymbols
[symnum
];
3793 if (symbol
->flags
& BSF_FILE
)
3795 _bfd_vms_output_dump (recwr
, (unsigned char *) symbol
->name
,
3796 (int) strlen (symbol
->name
));
3801 if (symnum
== abfd
->symcount
)
3802 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("noname"));
3804 _bfd_vms_output_end (abfd
, recwr
);
3807 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3808 _bfd_vms_output_short (recwr
, EMH__C_TTL
);
3809 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("TTL"));
3810 _bfd_vms_output_end (abfd
, recwr
);
3813 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3814 _bfd_vms_output_short (recwr
, EMH__C_CPR
);
3815 _bfd_vms_output_dump (recwr
,
3816 (unsigned char *)"GNU BFD ported by Klaus Kämpf 1994-1996",
3818 _bfd_vms_output_end (abfd
, recwr
);
3823 /* Part 4.6, relocations. */
3826 /* WRITE ETIR SECTION
3828 This is still under construction and therefore not documented. */
3830 /* Close the etir/etbt record. */
3833 end_etir_record (bfd
* abfd
)
3835 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3837 _bfd_vms_output_end (abfd
, recwr
);
3841 start_etir_or_etbt_record (bfd
*abfd
, asection
*section
, bfd_vma offset
)
3843 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3845 if (section
->flags
& SEC_DEBUGGING
)
3847 _bfd_vms_output_begin (recwr
, EOBJ__C_ETBT
);
3851 /* Push start offset. */
3852 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3853 _bfd_vms_output_long (recwr
, (unsigned long) 0);
3854 _bfd_vms_output_end_subrec (recwr
);
3857 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_DFLOC
);
3858 _bfd_vms_output_end_subrec (recwr
);
3863 _bfd_vms_output_begin (recwr
, EOBJ__C_ETIR
);
3867 /* Push start offset. */
3868 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3869 _bfd_vms_output_long (recwr
, (unsigned long) section
->target_index
);
3870 _bfd_vms_output_quad (recwr
, offset
);
3871 _bfd_vms_output_end_subrec (recwr
);
3873 /* Start = pop (). */
3874 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_SETRB
);
3875 _bfd_vms_output_end_subrec (recwr
);
3880 /* Output a STO_IMM command for SSIZE bytes of data from CPR at virtual
3881 address VADDR in section specified by SEC_INDEX and NAME. */
3884 sto_imm (bfd
*abfd
, asection
*section
,
3885 bfd_size_type ssize
, unsigned char *cptr
, bfd_vma vaddr
)
3888 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3891 _bfd_vms_debug (8, "sto_imm %d bytes\n", (int) ssize
);
3892 _bfd_hexdump (9, cptr
, (int) ssize
, (int) vaddr
);
3897 /* Try all the rest. */
3900 if (_bfd_vms_output_check (recwr
, size
) < 0)
3902 /* Doesn't fit, split ! */
3903 end_etir_record (abfd
);
3905 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3907 size
= _bfd_vms_output_check (recwr
, 0); /* get max size */
3908 if (size
> ssize
) /* more than what's left ? */
3912 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_IMM
);
3913 _bfd_vms_output_long (recwr
, (unsigned long) (size
));
3914 _bfd_vms_output_dump (recwr
, cptr
, size
);
3915 _bfd_vms_output_end_subrec (recwr
);
3918 _bfd_vms_debug (10, "dumped %d bytes\n", (int) size
);
3919 _bfd_hexdump (10, cptr
, (int) size
, (int) vaddr
);
3929 etir_output_check (bfd
*abfd
, asection
*section
, bfd_vma vaddr
, int checklen
)
3931 if (_bfd_vms_output_check (&PRIV (recwr
), checklen
) < 0)
3933 /* Not enough room in this record. Close it and open a new one. */
3934 end_etir_record (abfd
);
3935 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3939 /* Return whether RELOC must be deferred till the end. */
3942 defer_reloc_p (arelent
*reloc
)
3944 switch (reloc
->howto
->type
)
3957 /* Write section contents for bfd abfd. Return FALSE on error. */
3960 _bfd_vms_write_etir (bfd
* abfd
, int objtype ATTRIBUTE_UNUSED
)
3963 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3965 vms_debug2 ((2, "vms_write_tir (%p, %d)\n", abfd
, objtype
));
3967 _bfd_vms_output_alignment (recwr
, 4);
3969 PRIV (vms_linkage_index
) = 0;
3971 for (section
= abfd
->sections
; section
; section
= section
->next
)
3973 vms_debug2 ((4, "writing %d. section '%s' (%d bytes)\n",
3974 section
->target_index
, section
->name
, (int) (section
->size
)));
3976 if (!(section
->flags
& SEC_HAS_CONTENTS
)
3977 || bfd_is_com_section (section
))
3980 if (!section
->contents
)
3982 bfd_set_error (bfd_error_no_contents
);
3986 start_etir_or_etbt_record (abfd
, section
, 0);
3988 if (section
->flags
& SEC_RELOC
)
3990 bfd_vma curr_addr
= 0;
3991 unsigned char *curr_data
= section
->contents
;
3993 int pass2_needed
= 0;
3994 int pass2_in_progress
= 0;
3997 if (section
->reloc_count
== 0)
3999 (_("SEC_RELOC with no relocs in section %pA"), section
);
4004 int i
= section
->reloc_count
;
4005 arelent
**rptr
= section
->orelocation
;
4006 _bfd_vms_debug (4, "%d relocations:\n", i
);
4009 _bfd_vms_debug (4, "sym %s in sec %s, value %08lx, "
4010 "addr %08lx, off %08lx, len %d: %s\n",
4011 (*(*rptr
)->sym_ptr_ptr
)->name
,
4012 (*(*rptr
)->sym_ptr_ptr
)->section
->name
,
4013 (long) (*(*rptr
)->sym_ptr_ptr
)->value
,
4014 (unsigned long)(*rptr
)->address
,
4015 (unsigned long)(*rptr
)->addend
,
4016 bfd_get_reloc_size ((*rptr
)->howto
),
4017 ( *rptr
)->howto
->name
);
4024 for (irel
= 0; irel
< section
->reloc_count
; irel
++)
4026 struct evax_private_udata_struct
*udata
;
4027 arelent
*rptr
= section
->orelocation
[irel
];
4028 bfd_vma addr
= rptr
->address
;
4029 asymbol
*sym
= *rptr
->sym_ptr_ptr
;
4030 asection
*sec
= sym
->section
;
4031 bool defer
= defer_reloc_p (rptr
);
4034 if (pass2_in_progress
)
4036 /* Non-deferred relocs have already been output. */
4042 /* Deferred relocs must be output at the very end. */
4049 /* Regular relocs are intertwined with binary data. */
4050 if (curr_addr
> addr
)
4051 _bfd_error_handler (_("size error in section %pA"),
4053 size
= addr
- curr_addr
;
4054 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
4059 size
= bfd_get_reloc_size (rptr
->howto
);
4061 switch (rptr
->howto
->type
)
4063 case ALPHA_R_IGNORE
:
4066 case ALPHA_R_REFLONG
:
4067 if (bfd_is_und_section (sym
->section
))
4069 bfd_vma addend
= rptr
->addend
;
4070 slen
= strlen ((char *) sym
->name
);
4071 etir_output_check (abfd
, section
, curr_addr
, slen
);
4074 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
4075 _bfd_vms_output_counted (recwr
, sym
->name
);
4076 _bfd_vms_output_end_subrec (recwr
);
4077 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
4078 _bfd_vms_output_long (recwr
, (unsigned long) addend
);
4079 _bfd_vms_output_end_subrec (recwr
);
4080 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
4081 _bfd_vms_output_end_subrec (recwr
);
4082 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
4083 _bfd_vms_output_end_subrec (recwr
);
4087 _bfd_vms_output_begin_subrec
4088 (recwr
, ETIR__C_STO_GBL_LW
);
4089 _bfd_vms_output_counted (recwr
, sym
->name
);
4090 _bfd_vms_output_end_subrec (recwr
);
4093 else if (bfd_is_abs_section (sym
->section
))
4095 etir_output_check (abfd
, section
, curr_addr
, 16);
4096 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
4097 _bfd_vms_output_long (recwr
, (unsigned long) sym
->value
);
4098 _bfd_vms_output_end_subrec (recwr
);
4099 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
4100 _bfd_vms_output_end_subrec (recwr
);
4104 etir_output_check (abfd
, section
, curr_addr
, 32);
4105 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
4106 _bfd_vms_output_long (recwr
,
4107 (unsigned long) sec
->target_index
);
4108 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
4109 _bfd_vms_output_end_subrec (recwr
);
4110 /* ??? Table B-8 of the OpenVMS Linker Utilily Manual
4111 says that we should have a ETIR__C_STO_OFF here.
4112 But the relocation would not be BFD_RELOC_32 then.
4113 This case is very likely unreachable. */
4114 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
4115 _bfd_vms_output_end_subrec (recwr
);
4119 case ALPHA_R_REFQUAD
:
4120 if (bfd_is_und_section (sym
->section
))
4122 bfd_vma addend
= rptr
->addend
;
4123 slen
= strlen ((char *) sym
->name
);
4124 etir_output_check (abfd
, section
, curr_addr
, slen
);
4127 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
4128 _bfd_vms_output_counted (recwr
, sym
->name
);
4129 _bfd_vms_output_end_subrec (recwr
);
4130 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
4131 _bfd_vms_output_quad (recwr
, addend
);
4132 _bfd_vms_output_end_subrec (recwr
);
4133 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
4134 _bfd_vms_output_end_subrec (recwr
);
4135 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
4136 _bfd_vms_output_end_subrec (recwr
);
4140 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_GBL
);
4141 _bfd_vms_output_counted (recwr
, sym
->name
);
4142 _bfd_vms_output_end_subrec (recwr
);
4145 else if (bfd_is_abs_section (sym
->section
))
4147 etir_output_check (abfd
, section
, curr_addr
, 16);
4148 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
4149 _bfd_vms_output_quad (recwr
, sym
->value
);
4150 _bfd_vms_output_end_subrec (recwr
);
4151 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
4152 _bfd_vms_output_end_subrec (recwr
);
4156 etir_output_check (abfd
, section
, curr_addr
, 32);
4157 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
4158 _bfd_vms_output_long (recwr
,
4159 (unsigned long) sec
->target_index
);
4160 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
4161 _bfd_vms_output_end_subrec (recwr
);
4162 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_OFF
);
4163 _bfd_vms_output_end_subrec (recwr
);
4168 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
4171 case ALPHA_R_LINKAGE
:
4173 etir_output_check (abfd
, section
, curr_addr
, 64);
4174 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LP_PSB
);
4175 _bfd_vms_output_long
4176 (recwr
, (unsigned long) rptr
->addend
);
4177 if (rptr
->addend
> PRIV (vms_linkage_index
))
4178 PRIV (vms_linkage_index
) = rptr
->addend
;
4179 _bfd_vms_output_counted (recwr
, sym
->name
);
4180 _bfd_vms_output_byte (recwr
, 0);
4181 _bfd_vms_output_end_subrec (recwr
);
4184 case ALPHA_R_CODEADDR
:
4185 slen
= strlen ((char *) sym
->name
);
4186 etir_output_check (abfd
, section
, curr_addr
, slen
);
4187 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_CA
);
4188 _bfd_vms_output_counted (recwr
, sym
->name
);
4189 _bfd_vms_output_end_subrec (recwr
);
4194 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4195 etir_output_check (abfd
, section
, curr_addr
,
4196 32 + 1 + strlen (udata
->origname
));
4197 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_NOP_GBL
);
4198 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
4199 _bfd_vms_output_long
4200 (recwr
, (unsigned long) section
->target_index
);
4201 _bfd_vms_output_quad (recwr
, rptr
->address
);
4202 _bfd_vms_output_long (recwr
, (unsigned long) 0x47ff041f);
4203 _bfd_vms_output_long
4204 (recwr
, (unsigned long) section
->target_index
);
4205 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4206 _bfd_vms_output_counted (recwr
, udata
->origname
);
4207 _bfd_vms_output_end_subrec (recwr
);
4211 _bfd_error_handler (_("spurious ALPHA_R_BSR reloc"));
4216 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4217 etir_output_check (abfd
, section
, curr_addr
,
4218 32 + 1 + strlen (udata
->origname
));
4219 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LDA_GBL
);
4220 _bfd_vms_output_long
4221 (recwr
, (unsigned long) udata
->lkindex
+ 1);
4222 _bfd_vms_output_long
4223 (recwr
, (unsigned long) section
->target_index
);
4224 _bfd_vms_output_quad (recwr
, rptr
->address
);
4225 _bfd_vms_output_long (recwr
, (unsigned long) 0x237B0000);
4226 _bfd_vms_output_long
4227 (recwr
, (unsigned long) udata
->bsym
->section
->target_index
);
4228 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4229 _bfd_vms_output_counted (recwr
, udata
->origname
);
4230 _bfd_vms_output_end_subrec (recwr
);
4235 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4236 etir_output_check (abfd
, section
, curr_addr
,
4237 32 + 1 + strlen (udata
->origname
));
4238 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_BOH_GBL
);
4239 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
4240 _bfd_vms_output_long
4241 (recwr
, (unsigned long) section
->target_index
);
4242 _bfd_vms_output_quad (recwr
, rptr
->address
);
4243 _bfd_vms_output_long (recwr
, (unsigned long) 0xD3400000);
4244 _bfd_vms_output_long
4245 (recwr
, (unsigned long) section
->target_index
);
4246 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4247 _bfd_vms_output_counted (recwr
, udata
->origname
);
4248 _bfd_vms_output_end_subrec (recwr
);
4252 _bfd_error_handler (_("unhandled relocation %s"),
4259 } /* End of relocs loop. */
4261 if (!pass2_in_progress
)
4263 /* Output rest of section. */
4264 if (curr_addr
> section
->size
)
4266 _bfd_error_handler (_("size error in section %pA"), section
);
4269 size
= section
->size
- curr_addr
;
4270 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
4276 pass2_in_progress
= 1;
4282 else /* (section->flags & SEC_RELOC) */
4283 sto_imm (abfd
, section
, section
->size
, section
->contents
, 0);
4285 end_etir_record (abfd
);
4288 _bfd_vms_output_alignment (recwr
, 2);
4292 /* Write cached information into a file being written, at bfd_close. */
4295 alpha_vms_write_object_contents (bfd
*abfd
)
4297 vms_debug2 ((1, "vms_write_object_contents (%p)\n", abfd
));
4299 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
4301 return alpha_vms_write_exec (abfd
);
4305 if (abfd
->section_count
> 0) /* we have sections */
4307 if (!_bfd_vms_write_ehdr (abfd
))
4309 if (!_bfd_vms_write_egsd (abfd
))
4311 if (!_bfd_vms_write_etir (abfd
, EOBJ__C_ETIR
))
4313 if (!_bfd_vms_write_eeom (abfd
))
4320 /* Debug stuff: nearest line. */
4322 #define SET_MODULE_PARSED(m) \
4323 do { if ((m)->name == NULL) (m)->name = ""; } while (0)
4324 #define IS_MODULE_PARSED(m) ((m)->name != NULL)
4326 /* Build a new module for the specified BFD. */
4328 static struct module
*
4329 new_module (bfd
*abfd
)
4331 struct module
*module
4332 = (struct module
*) bfd_zalloc (abfd
, sizeof (struct module
));
4333 module
->file_table_count
= 16; /* Arbitrary. */
4335 = bfd_malloc (module
->file_table_count
* sizeof (struct fileinfo
));
4339 /* Parse debug info for a module and internalize it. */
4342 parse_module (bfd
*abfd
, struct module
*module
, unsigned char *ptr
,
4345 unsigned char *maxptr
= ptr
+ length
;
4346 unsigned char *src_ptr
, *pcl_ptr
;
4347 unsigned int prev_linum
= 0, curr_linenum
= 0;
4348 bfd_vma prev_pc
= 0, curr_pc
= 0;
4349 struct srecinfo
*curr_srec
, *srec
;
4350 struct lineinfo
*curr_line
, *line
;
4351 struct funcinfo
*funcinfo
;
4353 /* Initialize tables with zero element. */
4354 curr_srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4355 module
->srec_table
= curr_srec
;
4357 curr_line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4358 module
->line_table
= curr_line
;
4360 while (length
== -1 || ptr
< maxptr
)
4362 /* The first byte is not counted in the recorded length. */
4363 int rec_length
= bfd_getl16 (ptr
) + 1;
4364 int rec_type
= bfd_getl16 (ptr
+ 2);
4366 vms_debug2 ((2, "DST record: leng %d, type %d\n", rec_length
, rec_type
));
4368 if (length
== -1 && rec_type
== DST__K_MODEND
)
4375 = _bfd_vms_save_counted_string (abfd
, ptr
+ DST_S_B_MODBEG_NAME
,
4376 maxptr
- (ptr
+ DST_S_B_MODBEG_NAME
));
4383 vms_debug2 ((3, "module: %s\n", module
->name
));
4390 funcinfo
= (struct funcinfo
*)
4391 bfd_zalloc (abfd
, sizeof (struct funcinfo
));
4393 = _bfd_vms_save_counted_string (abfd
, ptr
+ DST_S_B_RTNBEG_NAME
,
4394 maxptr
- (ptr
+ DST_S_B_RTNBEG_NAME
));
4395 funcinfo
->low
= bfd_getl32 (ptr
+ DST_S_L_RTNBEG_ADDRESS
);
4396 funcinfo
->next
= module
->func_table
;
4397 module
->func_table
= funcinfo
;
4399 vms_debug2 ((3, "routine: %s at 0x%lx\n",
4400 funcinfo
->name
, (unsigned long) funcinfo
->low
));
4404 module
->func_table
->high
= module
->func_table
->low
4405 + bfd_getl32 (ptr
+ DST_S_L_RTNEND_SIZE
) - 1;
4407 if (module
->func_table
->high
> module
->high
)
4408 module
->high
= module
->func_table
->high
;
4410 vms_debug2 ((3, "end routine\n"));
4414 vms_debug2 ((3, "prologue\n"));
4418 vms_debug2 ((3, "epilog\n"));
4422 vms_debug2 ((3, "block\n"));
4426 vms_debug2 ((3, "end block\n"));
4430 src_ptr
= ptr
+ DST_S_C_SOURCE_HEADER_SIZE
;
4432 vms_debug2 ((3, "source info\n"));
4434 while (src_ptr
< ptr
+ rec_length
)
4436 int cmd
= src_ptr
[0], cmd_length
, data
;
4440 case DST__K_SRC_DECLFILE
:
4443 = bfd_getl16 (src_ptr
+ DST_S_W_SRC_DF_FILEID
);
4444 char *filename
= _bfd_vms_save_counted_string
4446 src_ptr
+ DST_S_B_SRC_DF_FILENAME
,
4447 ptr
+ rec_length
- (src_ptr
+ DST_S_B_SRC_DF_FILENAME
));
4449 while (fileid
>= module
->file_table_count
)
4451 module
->file_table_count
*= 2;
4453 = bfd_realloc_or_free (module
->file_table
,
4454 module
->file_table_count
4455 * sizeof (struct fileinfo
));
4456 if (module
->file_table
== NULL
)
4460 module
->file_table
[fileid
].name
= filename
;
4461 module
->file_table
[fileid
].srec
= 1;
4462 cmd_length
= src_ptr
[DST_S_B_SRC_DF_LENGTH
] + 2;
4463 vms_debug2 ((4, "DST_S_C_SRC_DECLFILE: %d, %s\n",
4464 fileid
, module
->file_table
[fileid
].name
));
4468 case DST__K_SRC_DEFLINES_B
:
4469 /* Perform the association and set the next higher index
4471 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4472 srec
= (struct srecinfo
*)
4473 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4474 srec
->line
= curr_srec
->line
+ data
;
4475 srec
->srec
= curr_srec
->srec
+ data
;
4476 srec
->sfile
= curr_srec
->sfile
;
4477 curr_srec
->next
= srec
;
4480 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_B: %d\n", data
));
4483 case DST__K_SRC_DEFLINES_W
:
4484 /* Perform the association and set the next higher index
4486 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4487 srec
= (struct srecinfo
*)
4488 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4489 srec
->line
= curr_srec
->line
+ data
;
4490 srec
->srec
= curr_srec
->srec
+ data
,
4491 srec
->sfile
= curr_srec
->sfile
;
4492 curr_srec
->next
= srec
;
4495 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_W: %d\n", data
));
4498 case DST__K_SRC_INCRLNUM_B
:
4499 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4500 curr_srec
->line
+= data
;
4502 vms_debug2 ((4, "DST_S_C_SRC_INCRLNUM_B: %d\n", data
));
4505 case DST__K_SRC_SETFILE
:
4506 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4507 curr_srec
->sfile
= data
;
4508 curr_srec
->srec
= module
->file_table
[data
].srec
;
4510 vms_debug2 ((4, "DST_S_C_SRC_SETFILE: %d\n", data
));
4513 case DST__K_SRC_SETLNUM_L
:
4514 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4515 curr_srec
->line
= data
;
4517 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_L: %d\n", data
));
4520 case DST__K_SRC_SETLNUM_W
:
4521 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4522 curr_srec
->line
= data
;
4524 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_W: %d\n", data
));
4527 case DST__K_SRC_SETREC_L
:
4528 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4529 curr_srec
->srec
= data
;
4530 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4532 vms_debug2 ((4, "DST_S_C_SRC_SETREC_L: %d\n", data
));
4535 case DST__K_SRC_SETREC_W
:
4536 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4537 curr_srec
->srec
= data
;
4538 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4540 vms_debug2 ((4, "DST_S_C_SRC_SETREC_W: %d\n", data
));
4543 case DST__K_SRC_FORMFEED
:
4545 vms_debug2 ((4, "DST_S_C_SRC_FORMFEED\n"));
4549 _bfd_error_handler (_("unknown source command %d"),
4555 src_ptr
+= cmd_length
;
4559 case DST__K_LINE_NUM
:
4560 pcl_ptr
= ptr
+ DST_S_C_LINE_NUM_HEADER_SIZE
;
4562 vms_debug2 ((3, "line info\n"));
4564 while (pcl_ptr
< ptr
+ rec_length
)
4566 /* The command byte is signed so we must sign-extend it. */
4567 int cmd
= ((signed char *)pcl_ptr
)[0], cmd_length
, data
;
4571 case DST__K_DELTA_PC_W
:
4572 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4576 vms_debug2 ((4, "DST__K_DELTA_PC_W: %d\n", data
));
4579 case DST__K_DELTA_PC_L
:
4580 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4584 vms_debug2 ((4, "DST__K_DELTA_PC_L: %d\n", data
));
4587 case DST__K_INCR_LINUM
:
4588 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4589 curr_linenum
+= data
;
4591 vms_debug2 ((4, "DST__K_INCR_LINUM: %d\n", data
));
4594 case DST__K_INCR_LINUM_W
:
4595 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4596 curr_linenum
+= data
;
4598 vms_debug2 ((4, "DST__K_INCR_LINUM_W: %d\n", data
));
4601 case DST__K_INCR_LINUM_L
:
4602 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4603 curr_linenum
+= data
;
4605 vms_debug2 ((4, "DST__K_INCR_LINUM_L: %d\n", data
));
4608 case DST__K_SET_LINUM_INCR
:
4610 (_("%s not implemented"), "DST__K_SET_LINUM_INCR");
4614 case DST__K_SET_LINUM_INCR_W
:
4616 (_("%s not implemented"), "DST__K_SET_LINUM_INCR_W");
4620 case DST__K_RESET_LINUM_INCR
:
4622 (_("%s not implemented"), "DST__K_RESET_LINUM_INCR");
4626 case DST__K_BEG_STMT_MODE
:
4628 (_("%s not implemented"), "DST__K_BEG_STMT_MODE");
4632 case DST__K_END_STMT_MODE
:
4634 (_("%s not implemented"), "DST__K_END_STMT_MODE");
4638 case DST__K_SET_LINUM_B
:
4639 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4640 curr_linenum
= data
;
4642 vms_debug2 ((4, "DST__K_SET_LINUM_B: %d\n", data
));
4645 case DST__K_SET_LINUM
:
4646 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4647 curr_linenum
= data
;
4649 vms_debug2 ((4, "DST__K_SET_LINE_NUM: %d\n", data
));
4652 case DST__K_SET_LINUM_L
:
4653 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4654 curr_linenum
= data
;
4656 vms_debug2 ((4, "DST__K_SET_LINUM_L: %d\n", data
));
4661 (_("%s not implemented"), "DST__K_SET_PC");
4665 case DST__K_SET_PC_W
:
4667 (_("%s not implemented"), "DST__K_SET_PC_W");
4671 case DST__K_SET_PC_L
:
4673 (_("%s not implemented"), "DST__K_SET_PC_L");
4677 case DST__K_SET_STMTNUM
:
4679 (_("%s not implemented"), "DST__K_SET_STMTNUM");
4684 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4687 vms_debug2 ((4, "DST__K_TERM: %d\n", data
));
4691 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4694 vms_debug2 ((4, "DST__K_TERM_W: %d\n", data
));
4698 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4701 vms_debug2 ((4, "DST__K_TERM_L: %d\n", data
));
4704 case DST__K_SET_ABS_PC
:
4705 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4708 vms_debug2 ((4, "DST__K_SET_ABS_PC: 0x%x\n", data
));
4717 vms_debug2 ((4, "bump pc to 0x%lx and line to %d\n",
4718 (unsigned long)curr_pc
, curr_linenum
));
4722 _bfd_error_handler (_("unknown line command %d"), cmd
);
4728 if ((curr_linenum
!= prev_linum
&& curr_pc
!= prev_pc
)
4730 || cmd
== DST__K_DELTA_PC_L
4731 || cmd
== DST__K_DELTA_PC_W
)
4733 line
= (struct lineinfo
*)
4734 bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4735 line
->address
= curr_pc
;
4736 line
->line
= curr_linenum
;
4738 curr_line
->next
= line
;
4741 prev_linum
= curr_linenum
;
4743 vms_debug2 ((4, "-> correlate pc 0x%lx with line %d\n",
4744 (unsigned long)curr_pc
, curr_linenum
));
4747 pcl_ptr
+= cmd_length
;
4751 case 0x17: /* Undocumented type used by DEC C to declare equates. */
4752 vms_debug2 ((3, "undocumented type 0x17\n"));
4756 vms_debug2 ((3, "ignoring record\n"));
4764 /* Finalize tables with EOL marker. */
4765 srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4766 srec
->line
= (unsigned int) -1;
4767 srec
->srec
= (unsigned int) -1;
4768 curr_srec
->next
= srec
;
4770 line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4771 line
->line
= (unsigned int) -1;
4772 line
->address
= (bfd_vma
) -1;
4773 curr_line
->next
= line
;
4775 /* Advertise that this module has been parsed. This is needed
4776 because parsing can be either performed at module creation
4777 or deferred until debug info is consumed. */
4778 SET_MODULE_PARSED (module
);
4782 /* Build the list of modules for the specified BFD. */
4784 static struct module
*
4785 build_module_list (bfd
*abfd
)
4787 struct module
*module
, *list
= NULL
;
4790 if ((dmt
= bfd_get_section_by_name (abfd
, "$DMT$")))
4792 /* We have a DMT section so this must be an image. Parse the
4793 section and build the list of modules. This is sufficient
4794 since we can compute the start address and the end address
4795 of every module from the section contents. */
4796 bfd_size_type size
= bfd_section_size (dmt
);
4797 unsigned char *buf
, *ptr
, *end
;
4799 if (! bfd_malloc_and_get_section (abfd
, dmt
, &buf
))
4802 vms_debug2 ((2, "DMT\n"));
4806 while (end
- ptr
>= DBG_S_C_DMT_HEADER_SIZE
)
4808 /* Each header declares a module with its start offset and size
4809 of debug info in the DST section, as well as the count of
4810 program sections (i.e. address spans) it contains. */
4811 unsigned int modbeg
= bfd_getl32 (ptr
+ DBG_S_L_DMT_MODBEG
);
4812 unsigned int msize
= bfd_getl32 (ptr
+ DBG_S_L_DST_SIZE
);
4813 int count
= bfd_getl16 (ptr
+ DBG_S_W_DMT_PSECT_COUNT
);
4814 ptr
+= DBG_S_C_DMT_HEADER_SIZE
;
4816 vms_debug2 ((3, "module: modbeg = %u, size = %u, count = %d\n",
4817 modbeg
, msize
, count
));
4819 /* We create a 'module' structure for each program section since
4820 we only support contiguous addresses in a 'module' structure.
4821 As a consequence, the actual debug info in the DST section is
4822 shared and can be parsed multiple times; that doesn't seem to
4823 cause problems in practice. */
4824 while (count
-- > 0 && end
- ptr
>= DBG_S_C_DMT_PSECT_SIZE
)
4826 unsigned int start
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_START
);
4827 unsigned int length
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_LENGTH
);
4828 module
= new_module (abfd
);
4829 module
->modbeg
= modbeg
;
4830 module
->size
= msize
;
4831 module
->low
= start
;
4832 module
->high
= start
+ length
;
4833 module
->next
= list
;
4835 ptr
+= DBG_S_C_DMT_PSECT_SIZE
;
4837 vms_debug2 ((4, "section: start = 0x%x, length = %u\n",
4845 /* We don't have a DMT section so this must be an object. Parse
4846 the module right now in order to compute its start address and
4848 void *dst
= PRIV (dst_section
)->contents
;
4853 module
= new_module (abfd
);
4854 if (!parse_module (abfd
, module
, PRIV (dst_section
)->contents
, -1))
4862 /* Calculate and return the name of the source file and the line nearest
4863 to the wanted location in the specified module. */
4866 module_find_nearest_line (bfd
*abfd
, struct module
*module
, bfd_vma addr
,
4867 const char **file
, const char **func
,
4870 struct funcinfo
*funcinfo
;
4871 struct lineinfo
*lineinfo
;
4872 struct srecinfo
*srecinfo
;
4875 /* Parse this module if that was not done at module creation. */
4876 if (! IS_MODULE_PARSED (module
))
4878 unsigned int size
= module
->size
;
4879 unsigned int modbeg
= PRIV (dst_section
)->filepos
+ module
->modbeg
;
4880 unsigned char *buffer
;
4882 if (bfd_seek (abfd
, modbeg
, SEEK_SET
) != 0
4883 || (buffer
= _bfd_malloc_and_read (abfd
, size
, size
)) == NULL
)
4885 bfd_set_error (bfd_error_no_debug_section
);
4889 ret
= parse_module (abfd
, module
, buffer
, size
);
4895 /* Find out the function (if any) that contains the address. */
4896 for (funcinfo
= module
->func_table
; funcinfo
; funcinfo
= funcinfo
->next
)
4897 if (addr
>= funcinfo
->low
&& addr
<= funcinfo
->high
)
4899 *func
= funcinfo
->name
;
4904 /* Find out the source file and the line nearest to the address. */
4905 for (lineinfo
= module
->line_table
; lineinfo
; lineinfo
= lineinfo
->next
)
4906 if (lineinfo
->next
&& addr
< lineinfo
->next
->address
)
4908 for (srecinfo
= module
->srec_table
; srecinfo
; srecinfo
= srecinfo
->next
)
4909 if (srecinfo
->next
&& lineinfo
->line
< srecinfo
->next
->line
)
4911 if (srecinfo
->sfile
> 0)
4913 *file
= module
->file_table
[srecinfo
->sfile
].name
;
4914 *line
= srecinfo
->srec
+ lineinfo
->line
- srecinfo
->line
;
4918 *file
= module
->name
;
4919 *line
= lineinfo
->line
;
4930 /* Provided a BFD, a section and an offset into the section, calculate and
4931 return the name of the source file and the line nearest to the wanted
4935 _bfd_vms_find_nearest_line (bfd
*abfd
,
4936 asymbol
**symbols ATTRIBUTE_UNUSED
,
4942 unsigned int *discriminator
)
4944 struct module
*module
;
4946 /* What address are we looking for? */
4947 bfd_vma addr
= section
->vma
+ offset
;
4955 /* We can't do anything if there is no DST (debug symbol table). */
4956 if (PRIV (dst_section
) == NULL
)
4959 /* Create the module list - if not already done. */
4960 if (PRIV (modules
) == NULL
)
4962 PRIV (modules
) = build_module_list (abfd
);
4963 if (PRIV (modules
) == NULL
)
4967 for (module
= PRIV (modules
); module
; module
= module
->next
)
4968 if (addr
>= module
->low
&& addr
<= module
->high
)
4969 return module_find_nearest_line (abfd
, module
, addr
, file
, func
, line
);
4974 /* Canonicalizations. */
4975 /* Set name, value, section and flags of SYM from E. */
4978 alpha_vms_convert_symbol (bfd
*abfd
, struct vms_symbol_entry
*e
, asymbol
*sym
)
4987 flags
= BSF_NO_FLAGS
;
4993 if (e
->flags
& EGSY__V_WEAK
)
4996 if (e
->flags
& EGSY__V_DEF
)
4998 /* Symbol definition. */
4999 flags
|= BSF_GLOBAL
;
5000 if (e
->flags
& EGSY__V_NORM
)
5001 flags
|= BSF_FUNCTION
;
5007 /* Symbol reference. */
5008 sec
= bfd_und_section_ptr
;
5013 /* A universal symbol is by definition global... */
5014 flags
|= BSF_GLOBAL
;
5016 /* ...and dynamic in shared libraries. */
5017 if (abfd
->flags
& DYNAMIC
)
5018 flags
|= BSF_DYNAMIC
;
5020 if (e
->flags
& EGSY__V_WEAK
)
5023 if (!(e
->flags
& EGSY__V_DEF
))
5026 if (e
->flags
& EGSY__V_NORM
)
5027 flags
|= BSF_FUNCTION
;
5030 /* sec = e->section; */
5031 sec
= bfd_abs_section_ptr
;
5046 /* Return the number of bytes required to store a vector of pointers
5047 to asymbols for all the symbols in the BFD abfd, including a
5048 terminal NULL pointer. If there are no symbols in the BFD,
5049 then return 0. If an error occurs, return -1. */
5052 alpha_vms_get_symtab_upper_bound (bfd
*abfd
)
5054 vms_debug2 ((1, "alpha_vms_get_symtab_upper_bound (%p), %d symbols\n",
5055 abfd
, PRIV (gsd_sym_count
)));
5057 return (PRIV (gsd_sym_count
) + 1) * sizeof (asymbol
*);
5060 /* Read the symbols from the BFD abfd, and fills in the vector
5061 location with pointers to the symbols and a trailing NULL.
5063 Return number of symbols read. */
5066 alpha_vms_canonicalize_symtab (bfd
*abfd
, asymbol
**symbols
)
5070 vms_debug2 ((1, "alpha_vms_canonicalize_symtab (%p, <ret>)\n", abfd
));
5072 if (PRIV (csymbols
) == NULL
)
5074 PRIV (csymbols
) = (asymbol
**) bfd_alloc
5075 (abfd
, PRIV (gsd_sym_count
) * sizeof (asymbol
*));
5077 /* Traverse table and fill symbols vector. */
5078 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
5080 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
5083 sym
= bfd_make_empty_symbol (abfd
);
5084 if (sym
== NULL
|| !alpha_vms_convert_symbol (abfd
, e
, sym
))
5086 bfd_release (abfd
, PRIV (csymbols
));
5087 PRIV (csymbols
) = NULL
;
5091 PRIV (csymbols
)[i
] = sym
;
5095 if (symbols
!= NULL
)
5097 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
5098 symbols
[i
] = PRIV (csymbols
)[i
];
5102 return PRIV (gsd_sym_count
);
5105 /* Read and convert relocations from ETIR. We do it once for all sections. */
5108 alpha_vms_slurp_relocs (bfd
*abfd
)
5112 vms_debug2 ((3, "alpha_vms_slurp_relocs\n"));
5114 /* We slurp relocs only once, for all sections. */
5115 if (PRIV (reloc_done
))
5117 PRIV (reloc_done
) = true;
5119 if (alpha_vms_canonicalize_symtab (abfd
, NULL
) < 0)
5122 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
5127 unsigned char *begin
;
5130 bfd_reloc_code_real_type reloc_code
;
5136 bfd_vma cur_address
;
5138 unsigned char *cur_sym
= NULL
;
5140 bfd_vma cur_addend
= 0;
5142 /* Skip non-ETIR records. */
5143 type
= _bfd_vms_get_object_record (abfd
);
5144 if (type
== EOBJ__C_EEOM
)
5146 if (type
!= EOBJ__C_ETIR
)
5149 begin
= PRIV (recrd
.rec
) + 4;
5150 end
= PRIV (recrd
.rec
) + PRIV (recrd
.rec_size
);
5152 for (ptr
= begin
; ptr
< end
; ptr
+= length
)
5156 cmd
= bfd_getl16 (ptr
);
5157 length
= bfd_getl16 (ptr
+ 2);
5159 cur_address
= vaddr
;
5161 vms_debug2 ((4, "alpha_vms_slurp_relocs: etir %s\n",
5162 _bfd_vms_etir_name (cmd
)));
5166 case ETIR__C_STA_GBL
: /* ALPHA_R_REFLONG und_section, step 1 */
5167 /* ALPHA_R_REFQUAD und_section, step 1 */
5172 case ETIR__C_STA_PQ
: /* ALPHA_R_REF{LONG|QUAD}, others part 1 */
5173 cur_psidx
= bfd_getl32 (ptr
+ 4);
5174 cur_addend
= bfd_getl64 (ptr
+ 8);
5178 case ETIR__C_CTL_SETRB
:
5179 if (prev_cmd
!= ETIR__C_STA_PQ
)
5182 /* xgettext:c-format */
5183 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (prev_cmd
),
5184 _bfd_vms_etir_name (cmd
));
5187 cur_psect
= cur_psidx
;
5193 case ETIR__C_STA_LW
: /* ALPHA_R_REFLONG abs_section, step 1 */
5194 /* ALPHA_R_REFLONG und_section, step 2 */
5197 if (prev_cmd
!= ETIR__C_STA_GBL
)
5200 /* xgettext:c-format */
5201 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
5202 _bfd_vms_etir_name (ETIR__C_STA_LW
));
5206 cur_addend
= bfd_getl32 (ptr
+ 4);
5210 case ETIR__C_STA_QW
: /* ALPHA_R_REFQUAD abs_section, step 1 */
5211 /* ALPHA_R_REFQUAD und_section, step 2 */
5212 if (prev_cmd
!= -1 && prev_cmd
!= ETIR__C_STA_GBL
)
5215 /* xgettext:c-format */
5216 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
5217 _bfd_vms_etir_name (ETIR__C_STA_QW
));
5220 cur_addend
= bfd_getl64 (ptr
+ 4);
5224 case ETIR__C_STO_LW
: /* ALPHA_R_REFLONG und_section, step 4 */
5225 /* ALPHA_R_REFLONG abs_section, step 2 */
5226 /* ALPHA_R_REFLONG others, step 2 */
5227 if (prev_cmd
!= ETIR__C_OPR_ADD
5228 && prev_cmd
!= ETIR__C_STA_LW
5229 && prev_cmd
!= ETIR__C_STA_PQ
)
5231 /* xgettext:c-format */
5232 _bfd_error_handler (_("unknown reloc %s + %s"),
5233 _bfd_vms_etir_name (prev_cmd
),
5234 _bfd_vms_etir_name (ETIR__C_STO_LW
));
5237 reloc_code
= BFD_RELOC_32
;
5240 case ETIR__C_STO_QW
: /* ALPHA_R_REFQUAD und_section, step 4 */
5241 /* ALPHA_R_REFQUAD abs_section, step 2 */
5242 if (prev_cmd
!= ETIR__C_OPR_ADD
&& prev_cmd
!= ETIR__C_STA_QW
)
5244 /* xgettext:c-format */
5245 _bfd_error_handler (_("unknown reloc %s + %s"),
5246 _bfd_vms_etir_name (prev_cmd
),
5247 _bfd_vms_etir_name (ETIR__C_STO_QW
));
5250 reloc_code
= BFD_RELOC_64
;
5253 case ETIR__C_STO_OFF
: /* ALPHA_R_REFQUAD others, step 2 */
5254 if (prev_cmd
!= ETIR__C_STA_PQ
)
5256 /* xgettext:c-format */
5257 _bfd_error_handler (_("unknown reloc %s + %s"),
5258 _bfd_vms_etir_name (prev_cmd
),
5259 _bfd_vms_etir_name (ETIR__C_STO_OFF
));
5262 reloc_code
= BFD_RELOC_64
;
5265 case ETIR__C_OPR_ADD
: /* ALPHA_R_REFLONG und_section, step 3 */
5266 /* ALPHA_R_REFQUAD und_section, step 3 */
5267 if (prev_cmd
!= ETIR__C_STA_LW
&& prev_cmd
!= ETIR__C_STA_QW
)
5269 /* xgettext:c-format */
5270 _bfd_error_handler (_("unknown reloc %s + %s"),
5271 _bfd_vms_etir_name (prev_cmd
),
5272 _bfd_vms_etir_name (ETIR__C_OPR_ADD
));
5275 prev_cmd
= ETIR__C_OPR_ADD
;
5278 case ETIR__C_STO_CA
: /* ALPHA_R_CODEADDR */
5279 reloc_code
= BFD_RELOC_ALPHA_CODEADDR
;
5283 case ETIR__C_STO_GBL
: /* ALPHA_R_REFQUAD und_section */
5284 reloc_code
= BFD_RELOC_64
;
5288 case ETIR__C_STO_GBL_LW
: /* ALPHA_R_REFLONG und_section */
5289 reloc_code
= BFD_RELOC_32
;
5293 case ETIR__C_STC_LP_PSB
: /* ALPHA_R_LINKAGE */
5294 reloc_code
= BFD_RELOC_ALPHA_LINKAGE
;
5298 case ETIR__C_STC_NOP_GBL
: /* ALPHA_R_NOP */
5299 reloc_code
= BFD_RELOC_ALPHA_NOP
;
5302 case ETIR__C_STC_BSR_GBL
: /* ALPHA_R_BSR */
5303 reloc_code
= BFD_RELOC_ALPHA_BSR
;
5306 case ETIR__C_STC_LDA_GBL
: /* ALPHA_R_LDA */
5307 reloc_code
= BFD_RELOC_ALPHA_LDA
;
5310 case ETIR__C_STC_BOH_GBL
: /* ALPHA_R_BOH */
5311 reloc_code
= BFD_RELOC_ALPHA_BOH
;
5315 cur_sym
= ptr
+ 4 + 32;
5316 cur_address
= bfd_getl64 (ptr
+ 4 + 8);
5317 cur_addend
= bfd_getl64 (ptr
+ 4 + 24);
5320 case ETIR__C_STO_IMM
:
5321 vaddr
+= bfd_getl32 (ptr
+ 4);
5325 _bfd_error_handler (_("unknown reloc %s"),
5326 _bfd_vms_etir_name (cmd
));
5332 struct vms_section_data_struct
*vms_sec
;
5336 /* Get section to which the relocation applies. */
5337 if (cur_psect
< 0 || cur_psect
> (int)PRIV (section_count
))
5339 _bfd_error_handler (_("invalid section index in ETIR"));
5343 if (PRIV (sections
) == NULL
)
5345 sec
= PRIV (sections
)[cur_psect
];
5346 if (sec
== bfd_abs_section_ptr
)
5348 _bfd_error_handler (_("relocation for non-REL psect"));
5352 vms_sec
= vms_section_data (sec
);
5354 /* Allocate a reloc entry. */
5355 if (sec
->reloc_count
>= vms_sec
->reloc_max
)
5357 if (vms_sec
->reloc_max
== 0)
5359 vms_sec
->reloc_max
= 64;
5360 sec
->relocation
= bfd_zmalloc
5361 (vms_sec
->reloc_max
* sizeof (arelent
));
5365 vms_sec
->reloc_max
*= 2;
5366 sec
->relocation
= bfd_realloc_or_free
5367 (sec
->relocation
, vms_sec
->reloc_max
* sizeof (arelent
));
5368 if (sec
->relocation
== NULL
)
5372 reloc
= &sec
->relocation
[sec
->reloc_count
];
5375 reloc
->howto
= bfd_reloc_type_lookup (abfd
, reloc_code
);
5377 if (cur_sym
!= NULL
)
5380 unsigned int symlen
= *cur_sym
;
5383 /* Linear search. */
5388 for (j
= 0; j
< PRIV (gsd_sym_count
); j
++)
5389 if (PRIV (syms
)[j
]->namelen
== symlen
5390 && memcmp (PRIV (syms
)[j
]->name
, cur_sym
, symlen
) == 0)
5392 sym
= &PRIV (csymbols
)[j
];
5397 _bfd_error_handler (_("unknown symbol in command %s"),
5398 _bfd_vms_etir_name (cmd
));
5399 reloc
->sym_ptr_ptr
= NULL
;
5402 reloc
->sym_ptr_ptr
= sym
;
5404 else if (cur_psidx
>= 0)
5406 if (PRIV (sections
) == NULL
|| cur_psidx
>= (int) PRIV (section_count
))
5408 reloc
->sym_ptr_ptr
=
5409 PRIV (sections
)[cur_psidx
]->symbol_ptr_ptr
;
5412 reloc
->sym_ptr_ptr
= NULL
;
5414 reloc
->address
= cur_address
;
5415 reloc
->addend
= cur_addend
;
5417 if (reloc_code
== ALPHA_R_LINKAGE
)
5420 size
= bfd_get_reloc_size (reloc
->howto
);
5430 vms_debug2 ((3, "alpha_vms_slurp_relocs: result = true\n"));
5435 /* Return the number of bytes required to store the relocation
5436 information associated with the given section. */
5439 alpha_vms_get_reloc_upper_bound (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*section
)
5441 alpha_vms_slurp_relocs (abfd
);
5443 return (section
->reloc_count
+ 1L) * sizeof (arelent
*);
5446 /* Convert relocations from VMS (external) form into BFD internal
5447 form. Return the number of relocations. */
5450 alpha_vms_canonicalize_reloc (bfd
*abfd
, asection
*section
, arelent
**relptr
,
5451 asymbol
**symbols ATTRIBUTE_UNUSED
)
5456 if (!alpha_vms_slurp_relocs (abfd
))
5459 count
= section
->reloc_count
;
5460 tblptr
= section
->relocation
;
5463 *relptr
++ = tblptr
++;
5465 *relptr
= (arelent
*) NULL
;
5466 return section
->reloc_count
;
5469 /* Install a new set of internal relocs. */
5471 #define alpha_vms_set_reloc _bfd_generic_set_reloc
5474 /* This is just copied from ecoff-alpha, needs to be fixed probably. */
5476 /* How to process the various reloc types. */
5478 static bfd_reloc_status_type
5479 reloc_nil (bfd
* abfd ATTRIBUTE_UNUSED
,
5480 arelent
*reloc ATTRIBUTE_UNUSED
,
5481 asymbol
*sym ATTRIBUTE_UNUSED
,
5482 void * data ATTRIBUTE_UNUSED
,
5483 asection
*sec ATTRIBUTE_UNUSED
,
5484 bfd
*output_bfd ATTRIBUTE_UNUSED
,
5485 char **error_message ATTRIBUTE_UNUSED
)
5488 vms_debug (1, "reloc_nil (abfd %p, output_bfd %p)\n", abfd
, output_bfd
);
5489 vms_debug (2, "In section %s, symbol %s\n",
5490 sec
->name
, sym
->name
);
5491 vms_debug (2, "reloc sym %s, addr %08lx, addend %08lx, reloc is a %s\n",
5492 reloc
->sym_ptr_ptr
[0]->name
,
5493 (unsigned long)reloc
->address
,
5494 (unsigned long)reloc
->addend
, reloc
->howto
->name
);
5495 vms_debug (2, "data at %p\n", data
);
5496 /* _bfd_hexdump (2, data, bfd_get_reloc_size (reloc->howto), 0); */
5499 return bfd_reloc_ok
;
5502 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
5503 from smaller values. Start with zero, widen, *then* decrement. */
5504 #define MINUS_ONE (((bfd_vma)0) - 1)
5506 static reloc_howto_type alpha_howto_table
[] =
5508 HOWTO (ALPHA_R_IGNORE
, /* Type. */
5509 0, /* Rightshift. */
5510 0, /* Size (0 = byte, 1 = short, 2 = long). */
5512 true, /* PC relative. */
5514 complain_overflow_dont
,/* Complain_on_overflow. */
5515 reloc_nil
, /* Special_function. */
5516 "IGNORE", /* Name. */
5517 true, /* Partial_inplace. */
5518 0, /* Source mask */
5520 true), /* PC rel offset. */
5522 /* A 64 bit reference to a symbol. */
5523 HOWTO (ALPHA_R_REFQUAD
, /* Type. */
5524 0, /* Rightshift. */
5525 4, /* Size (0 = byte, 1 = short, 2 = long). */
5527 false, /* PC relative. */
5529 complain_overflow_bitfield
, /* Complain_on_overflow. */
5530 reloc_nil
, /* Special_function. */
5531 "REFQUAD", /* Name. */
5532 true, /* Partial_inplace. */
5533 MINUS_ONE
, /* Source mask. */
5534 MINUS_ONE
, /* Dest mask. */
5535 false), /* PC rel offset. */
5537 /* A 21 bit branch. The native assembler generates these for
5538 branches within the text segment, and also fills in the PC
5539 relative offset in the instruction. */
5540 HOWTO (ALPHA_R_BRADDR
, /* Type. */
5541 2, /* Rightshift. */
5542 2, /* Size (0 = byte, 1 = short, 2 = long). */
5544 true, /* PC relative. */
5546 complain_overflow_signed
, /* Complain_on_overflow. */
5547 reloc_nil
, /* Special_function. */
5548 "BRADDR", /* Name. */
5549 true, /* Partial_inplace. */
5550 0x1fffff, /* Source mask. */
5551 0x1fffff, /* Dest mask. */
5552 false), /* PC rel offset. */
5554 /* A hint for a jump to a register. */
5555 HOWTO (ALPHA_R_HINT
, /* Type. */
5556 2, /* Rightshift. */
5557 1, /* Size (0 = byte, 1 = short, 2 = long). */
5559 true, /* PC relative. */
5561 complain_overflow_dont
,/* Complain_on_overflow. */
5562 reloc_nil
, /* Special_function. */
5564 true, /* Partial_inplace. */
5565 0x3fff, /* Source mask. */
5566 0x3fff, /* Dest mask. */
5567 false), /* PC rel offset. */
5569 /* 16 bit PC relative offset. */
5570 HOWTO (ALPHA_R_SREL16
, /* Type. */
5571 0, /* Rightshift. */
5572 1, /* Size (0 = byte, 1 = short, 2 = long). */
5574 true, /* PC relative. */
5576 complain_overflow_signed
, /* Complain_on_overflow. */
5577 reloc_nil
, /* Special_function. */
5578 "SREL16", /* Name. */
5579 true, /* Partial_inplace. */
5580 0xffff, /* Source mask. */
5581 0xffff, /* Dest mask. */
5582 false), /* PC rel offset. */
5584 /* 32 bit PC relative offset. */
5585 HOWTO (ALPHA_R_SREL32
, /* Type. */
5586 0, /* Rightshift. */
5587 2, /* Size (0 = byte, 1 = short, 2 = long). */
5589 true, /* PC relative. */
5591 complain_overflow_signed
, /* Complain_on_overflow. */
5592 reloc_nil
, /* Special_function. */
5593 "SREL32", /* Name. */
5594 true, /* Partial_inplace. */
5595 0xffffffff, /* Source mask. */
5596 0xffffffff, /* Dest mask. */
5597 false), /* PC rel offset. */
5599 /* A 64 bit PC relative offset. */
5600 HOWTO (ALPHA_R_SREL64
, /* Type. */
5601 0, /* Rightshift. */
5602 4, /* Size (0 = byte, 1 = short, 2 = long). */
5604 true, /* PC relative. */
5606 complain_overflow_signed
, /* Complain_on_overflow. */
5607 reloc_nil
, /* Special_function. */
5608 "SREL64", /* Name. */
5609 true, /* Partial_inplace. */
5610 MINUS_ONE
, /* Source mask. */
5611 MINUS_ONE
, /* Dest mask. */
5612 false), /* PC rel offset. */
5614 /* Push a value on the reloc evaluation stack. */
5615 HOWTO (ALPHA_R_OP_PUSH
, /* Type. */
5616 0, /* Rightshift. */
5617 0, /* Size (0 = byte, 1 = short, 2 = long). */
5619 false, /* PC relative. */
5621 complain_overflow_dont
,/* Complain_on_overflow. */
5622 reloc_nil
, /* Special_function. */
5623 "OP_PUSH", /* Name. */
5624 false, /* Partial_inplace. */
5625 0, /* Source mask. */
5627 false), /* PC rel offset. */
5629 /* Store the value from the stack at the given address. Store it in
5630 a bitfield of size r_size starting at bit position r_offset. */
5631 HOWTO (ALPHA_R_OP_STORE
, /* Type. */
5632 0, /* Rightshift. */
5633 4, /* Size (0 = byte, 1 = short, 2 = long). */
5635 false, /* PC relative. */
5637 complain_overflow_dont
,/* Complain_on_overflow. */
5638 reloc_nil
, /* Special_function. */
5639 "OP_STORE", /* Name. */
5640 false, /* Partial_inplace. */
5641 0, /* Source mask. */
5642 MINUS_ONE
, /* Dest mask. */
5643 false), /* PC rel offset. */
5645 /* Subtract the reloc address from the value on the top of the
5646 relocation stack. */
5647 HOWTO (ALPHA_R_OP_PSUB
, /* Type. */
5648 0, /* Rightshift. */
5649 0, /* Size (0 = byte, 1 = short, 2 = long). */
5651 false, /* PC relative. */
5653 complain_overflow_dont
,/* Complain_on_overflow. */
5654 reloc_nil
, /* Special_function. */
5655 "OP_PSUB", /* Name. */
5656 false, /* Partial_inplace. */
5657 0, /* Source mask. */
5659 false), /* PC rel offset. */
5661 /* Shift the value on the top of the relocation stack right by the
5663 HOWTO (ALPHA_R_OP_PRSHIFT
, /* Type. */
5664 0, /* Rightshift. */
5665 0, /* Size (0 = byte, 1 = short, 2 = long). */
5667 false, /* PC relative. */
5669 complain_overflow_dont
,/* Complain_on_overflow. */
5670 reloc_nil
, /* Special_function. */
5671 "OP_PRSHIFT", /* Name. */
5672 false, /* Partial_inplace. */
5673 0, /* Source mask. */
5675 false), /* PC rel offset. */
5677 /* Hack. Linkage is done by linker. */
5678 HOWTO (ALPHA_R_LINKAGE
, /* Type. */
5679 0, /* Rightshift. */
5680 0, /* Size (0 = byte, 1 = short, 2 = long). */
5682 false, /* PC relative. */
5684 complain_overflow_dont
,/* Complain_on_overflow. */
5685 reloc_nil
, /* Special_function. */
5686 "LINKAGE", /* Name. */
5687 false, /* Partial_inplace. */
5688 0, /* Source mask. */
5690 false), /* PC rel offset. */
5692 /* A 32 bit reference to a symbol. */
5693 HOWTO (ALPHA_R_REFLONG
, /* Type. */
5694 0, /* Rightshift. */
5695 2, /* Size (0 = byte, 1 = short, 2 = long). */
5697 false, /* PC relative. */
5699 complain_overflow_bitfield
, /* Complain_on_overflow. */
5700 reloc_nil
, /* Special_function. */
5701 "REFLONG", /* Name. */
5702 true, /* Partial_inplace. */
5703 0xffffffff, /* Source mask. */
5704 0xffffffff, /* Dest mask. */
5705 false), /* PC rel offset. */
5707 /* A 64 bit reference to a procedure, written as 32 bit value. */
5708 HOWTO (ALPHA_R_CODEADDR
, /* Type. */
5709 0, /* Rightshift. */
5710 4, /* Size (0 = byte, 1 = short, 2 = long). */
5712 false, /* PC relative. */
5714 complain_overflow_signed
,/* Complain_on_overflow. */
5715 reloc_nil
, /* Special_function. */
5716 "CODEADDR", /* Name. */
5717 false, /* Partial_inplace. */
5718 0xffffffff, /* Source mask. */
5719 0xffffffff, /* Dest mask. */
5720 false), /* PC rel offset. */
5722 HOWTO (ALPHA_R_NOP
, /* Type. */
5723 0, /* Rightshift. */
5724 3, /* Size (0 = byte, 1 = short, 2 = long). */
5726 /* The following value must match that of ALPHA_R_BSR/ALPHA_R_BOH
5727 because the calculations for the 3 relocations are the same.
5728 See B.4.5.2 of the OpenVMS Linker Utility Manual. */
5729 true, /* PC relative. */
5731 complain_overflow_dont
,/* Complain_on_overflow. */
5732 reloc_nil
, /* Special_function. */
5734 false, /* Partial_inplace. */
5735 0xffffffff, /* Source mask. */
5736 0xffffffff, /* Dest mask. */
5737 false), /* PC rel offset. */
5739 HOWTO (ALPHA_R_BSR
, /* Type. */
5740 0, /* Rightshift. */
5741 3, /* Size (0 = byte, 1 = short, 2 = long). */
5743 true, /* PC relative. */
5745 complain_overflow_dont
,/* Complain_on_overflow. */
5746 reloc_nil
, /* Special_function. */
5748 false, /* Partial_inplace. */
5749 0xffffffff, /* Source mask. */
5750 0xffffffff, /* Dest mask. */
5751 false), /* PC rel offset. */
5753 HOWTO (ALPHA_R_LDA
, /* Type. */
5754 0, /* Rightshift. */
5755 3, /* Size (0 = byte, 1 = short, 2 = long). */
5757 false, /* PC relative. */
5759 complain_overflow_dont
,/* Complain_on_overflow. */
5760 reloc_nil
, /* Special_function. */
5762 false, /* Partial_inplace. */
5763 0xffffffff, /* Source mask. */
5764 0xffffffff, /* Dest mask. */
5765 false), /* PC rel offset. */
5767 HOWTO (ALPHA_R_BOH
, /* Type. */
5768 0, /* Rightshift. */
5769 3, /* Size (0 = byte, 1 = short, 2 = long, 3 = nil). */
5771 true, /* PC relative. */
5773 complain_overflow_dont
,/* Complain_on_overflow. */
5774 reloc_nil
, /* Special_function. */
5776 false, /* Partial_inplace. */
5777 0xffffffff, /* Source mask. */
5778 0xffffffff, /* Dest mask. */
5779 false), /* PC rel offset. */
5782 /* Return a pointer to a howto structure which, when invoked, will perform
5783 the relocation code on data from the architecture noted. */
5785 static reloc_howto_type
*
5786 alpha_vms_bfd_reloc_type_lookup (bfd
* abfd ATTRIBUTE_UNUSED
,
5787 bfd_reloc_code_real_type code
)
5791 vms_debug2 ((1, "vms_bfd_reloc_type_lookup (%p, %d)\t", abfd
, code
));
5795 case BFD_RELOC_16
: alpha_type
= ALPHA_R_SREL16
; break;
5796 case BFD_RELOC_32
: alpha_type
= ALPHA_R_REFLONG
; break;
5797 case BFD_RELOC_64
: alpha_type
= ALPHA_R_REFQUAD
; break;
5798 case BFD_RELOC_CTOR
: alpha_type
= ALPHA_R_REFQUAD
; break;
5799 case BFD_RELOC_23_PCREL_S2
: alpha_type
= ALPHA_R_BRADDR
; break;
5800 case BFD_RELOC_ALPHA_HINT
: alpha_type
= ALPHA_R_HINT
; break;
5801 case BFD_RELOC_16_PCREL
: alpha_type
= ALPHA_R_SREL16
; break;
5802 case BFD_RELOC_32_PCREL
: alpha_type
= ALPHA_R_SREL32
; break;
5803 case BFD_RELOC_64_PCREL
: alpha_type
= ALPHA_R_SREL64
; break;
5804 case BFD_RELOC_ALPHA_LINKAGE
: alpha_type
= ALPHA_R_LINKAGE
; break;
5805 case BFD_RELOC_ALPHA_CODEADDR
: alpha_type
= ALPHA_R_CODEADDR
; break;
5806 case BFD_RELOC_ALPHA_NOP
: alpha_type
= ALPHA_R_NOP
; break;
5807 case BFD_RELOC_ALPHA_BSR
: alpha_type
= ALPHA_R_BSR
; break;
5808 case BFD_RELOC_ALPHA_LDA
: alpha_type
= ALPHA_R_LDA
; break;
5809 case BFD_RELOC_ALPHA_BOH
: alpha_type
= ALPHA_R_BOH
; break;
5811 _bfd_error_handler (_("reloc (%d) is *UNKNOWN*"), code
);
5814 vms_debug2 ((2, "reloc is %s\n", alpha_howto_table
[alpha_type
].name
));
5815 return & alpha_howto_table
[alpha_type
];
5818 static reloc_howto_type
*
5819 alpha_vms_bfd_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
5825 i
< sizeof (alpha_howto_table
) / sizeof (alpha_howto_table
[0]);
5827 if (alpha_howto_table
[i
].name
!= NULL
5828 && strcasecmp (alpha_howto_table
[i
].name
, r_name
) == 0)
5829 return &alpha_howto_table
[i
];
5835 alpha_vms_get_synthetic_symtab (bfd
*abfd
,
5836 long symcount ATTRIBUTE_UNUSED
,
5837 asymbol
**usyms ATTRIBUTE_UNUSED
,
5838 long dynsymcount ATTRIBUTE_UNUSED
,
5839 asymbol
**dynsyms ATTRIBUTE_UNUSED
,
5846 syms
= (asymbol
*) bfd_malloc (PRIV (norm_sym_count
) * sizeof (asymbol
));
5851 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
5853 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
5864 flags
= BSF_LOCAL
| BSF_SYNTHETIC
;
5871 if ((e
->flags
& EGSY__V_DEF
) && (e
->flags
& EGSY__V_NORM
))
5873 value
= e
->code_value
;
5874 sec
= e
->code_section
;
5885 sname
= bfd_alloc (abfd
, l
+ 5);
5888 memcpy (sname
, name
, l
);
5889 memcpy (sname
+ l
, "..en", 5);
5896 sym
->udata
.p
= NULL
;
5905 vms_time_to_str (unsigned char *buf
)
5907 time_t t
= vms_rawtime_to_time_t (buf
);
5908 char *res
= ctime (&t
);
5911 res
= "*invalid time*";
5918 evax_bfd_print_emh (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5920 struct vms_emh_common
*emh
= (struct vms_emh_common
*)rec
;
5921 unsigned int subtype
;
5924 subtype
= (unsigned) bfd_getl16 (emh
->subtyp
);
5926 /* xgettext:c-format */
5927 fprintf (file
, _(" EMH %u (len=%u): "), subtype
, rec_len
);
5929 /* PR 21618: Check for invalid lengths. */
5930 if (rec_len
< sizeof (* emh
))
5932 fprintf (file
, _(" Error: The length is less than the length of an EMH record\n"));
5935 extra
= rec_len
- sizeof (struct vms_emh_common
);
5941 struct vms_emh_mhd
*mhd
= (struct vms_emh_mhd
*) rec
;
5943 const char * nextname
;
5944 const char * maxname
;
5946 /* PR 21840: Check for invalid lengths. */
5947 if (rec_len
< sizeof (* mhd
))
5949 fprintf (file
, _(" Error: The record length is less than the size of an EMH_MHD record\n"));
5952 fprintf (file
, _("Module header\n"));
5953 fprintf (file
, _(" structure level: %u\n"), mhd
->strlvl
);
5954 fprintf (file
, _(" max record size: %u\n"),
5955 (unsigned) bfd_getl32 (mhd
->recsiz
));
5956 name
= (char *)(mhd
+ 1);
5957 maxname
= (char *) rec
+ rec_len
;
5958 if (name
> maxname
- 2)
5960 fprintf (file
, _(" Error: The module name is missing\n"));
5963 nextname
= name
+ name
[0] + 1;
5964 if (nextname
>= maxname
)
5966 fprintf (file
, _(" Error: The module name is too long\n"));
5969 fprintf (file
, _(" module name : %.*s\n"), name
[0], name
+ 1);
5971 if (name
> maxname
- 2)
5973 fprintf (file
, _(" Error: The module version is missing\n"));
5976 nextname
= name
+ name
[0] + 1;
5977 if (nextname
>= maxname
)
5979 fprintf (file
, _(" Error: The module version is too long\n"));
5982 fprintf (file
, _(" module version : %.*s\n"), name
[0], name
+ 1);
5984 if ((maxname
- name
) < 17 && maxname
[-1] != 0)
5985 fprintf (file
, _(" Error: The compile date is truncated\n"));
5987 fprintf (file
, _(" compile date : %.17s\n"), name
);
5992 fprintf (file
, _("Language Processor Name\n"));
5993 fprintf (file
, _(" language name: %.*s\n"), extra
, (char *)(emh
+ 1));
5997 fprintf (file
, _("Source Files Header\n"));
5998 fprintf (file
, _(" file: %.*s\n"), extra
, (char *)(emh
+ 1));
6002 fprintf (file
, _("Title Text Header\n"));
6003 fprintf (file
, _(" title: %.*s\n"), extra
, (char *)(emh
+ 1));
6007 fprintf (file
, _("Copyright Header\n"));
6008 fprintf (file
, _(" copyright: %.*s\n"), extra
, (char *)(emh
+ 1));
6012 fprintf (file
, _("unhandled emh subtype %u\n"), subtype
);
6018 evax_bfd_print_eeom (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
6020 struct vms_eeom
*eeom
= (struct vms_eeom
*)rec
;
6022 fprintf (file
, _(" EEOM (len=%u):\n"), rec_len
);
6024 /* PR 21618: Check for invalid lengths. */
6025 if (rec_len
< sizeof (* eeom
))
6027 fprintf (file
, _(" Error: The length is less than the length of an EEOM record\n"));
6031 fprintf (file
, _(" number of cond linkage pairs: %u\n"),
6032 (unsigned)bfd_getl32 (eeom
->total_lps
));
6033 fprintf (file
, _(" completion code: %u\n"),
6034 (unsigned)bfd_getl16 (eeom
->comcod
));
6037 fprintf (file
, _(" transfer addr flags: 0x%02x\n"), eeom
->tfrflg
);
6038 fprintf (file
, _(" transfer addr psect: %u\n"),
6039 (unsigned)bfd_getl32 (eeom
->psindx
));
6040 fprintf (file
, _(" transfer address : 0x%08x\n"),
6041 (unsigned)bfd_getl32 (eeom
->tfradr
));
6046 exav_bfd_print_egsy_flags (unsigned int flags
, FILE *file
)
6048 if (flags
& EGSY__V_WEAK
)
6049 fputs (_(" WEAK"), file
);
6050 if (flags
& EGSY__V_DEF
)
6051 fputs (_(" DEF"), file
);
6052 if (flags
& EGSY__V_UNI
)
6053 fputs (_(" UNI"), file
);
6054 if (flags
& EGSY__V_REL
)
6055 fputs (_(" REL"), file
);
6056 if (flags
& EGSY__V_COMM
)
6057 fputs (_(" COMM"), file
);
6058 if (flags
& EGSY__V_VECEP
)
6059 fputs (_(" VECEP"), file
);
6060 if (flags
& EGSY__V_NORM
)
6061 fputs (_(" NORM"), file
);
6062 if (flags
& EGSY__V_QUAD_VAL
)
6063 fputs (_(" QVAL"), file
);
6067 evax_bfd_print_egsd_flags (FILE *file
, unsigned int flags
)
6069 if (flags
& EGPS__V_PIC
)
6070 fputs (_(" PIC"), file
);
6071 if (flags
& EGPS__V_LIB
)
6072 fputs (_(" LIB"), file
);
6073 if (flags
& EGPS__V_OVR
)
6074 fputs (_(" OVR"), file
);
6075 if (flags
& EGPS__V_REL
)
6076 fputs (_(" REL"), file
);
6077 if (flags
& EGPS__V_GBL
)
6078 fputs (_(" GBL"), file
);
6079 if (flags
& EGPS__V_SHR
)
6080 fputs (_(" SHR"), file
);
6081 if (flags
& EGPS__V_EXE
)
6082 fputs (_(" EXE"), file
);
6083 if (flags
& EGPS__V_RD
)
6084 fputs (_(" RD"), file
);
6085 if (flags
& EGPS__V_WRT
)
6086 fputs (_(" WRT"), file
);
6087 if (flags
& EGPS__V_VEC
)
6088 fputs (_(" VEC"), file
);
6089 if (flags
& EGPS__V_NOMOD
)
6090 fputs (_(" NOMOD"), file
);
6091 if (flags
& EGPS__V_COM
)
6092 fputs (_(" COM"), file
);
6093 if (flags
& EGPS__V_ALLOC_64BIT
)
6094 fputs (_(" 64B"), file
);
6098 evax_bfd_print_egsd (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
6100 unsigned int off
= sizeof (struct vms_egsd
);
6103 fprintf (file
, _(" EGSD (len=%u):\n"), rec_len
);
6104 if (rec_len
< sizeof (struct vms_egsd
) + sizeof (struct vms_egsd_entry
))
6107 while (off
<= rec_len
- sizeof (struct vms_egsd_entry
))
6109 struct vms_egsd_entry
*e
= (struct vms_egsd_entry
*)(rec
+ off
);
6114 type
= (unsigned)bfd_getl16 (e
->gsdtyp
);
6115 len
= (unsigned)bfd_getl16 (e
->gsdsiz
);
6117 /* xgettext:c-format */
6118 fprintf (file
, _(" EGSD entry %2u (type: %u, len: %u): "),
6122 if (len
< sizeof (struct vms_egsd_entry
) || len
> rec_len
- off
)
6124 fprintf (file
, _(" Erroneous length\n"));
6131 if (len
>= offsetof (struct vms_egps
, name
))
6133 struct vms_egps
*egps
= (struct vms_egps
*) e
;
6134 unsigned int flags
= bfd_getl16 (egps
->flags
);
6137 fprintf (file
, _("PSC - Program section definition\n"));
6138 fprintf (file
, _(" alignment : 2**%u\n"), egps
->align
);
6139 fprintf (file
, _(" flags : 0x%04x"), flags
);
6140 evax_bfd_print_egsd_flags (file
, flags
);
6142 l
= bfd_getl32 (egps
->alloc
);
6143 fprintf (file
, _(" alloc (len): %u (0x%08x)\n"), l
, l
);
6144 rest
= len
- offsetof (struct vms_egps
, name
);
6145 fprintf (file
, _(" name : %.*s\n"),
6146 egps
->namlng
> rest
? rest
: egps
->namlng
,
6151 if (len
>= offsetof (struct vms_esgps
, name
))
6153 struct vms_esgps
*esgps
= (struct vms_esgps
*) e
;
6154 unsigned int flags
= bfd_getl16 (esgps
->flags
);
6157 fprintf (file
, _("SPSC - Shared Image Program section def\n"));
6158 fprintf (file
, _(" alignment : 2**%u\n"), esgps
->align
);
6159 fprintf (file
, _(" flags : 0x%04x"), flags
);
6160 evax_bfd_print_egsd_flags (file
, flags
);
6162 l
= bfd_getl32 (esgps
->alloc
);
6163 fprintf (file
, _(" alloc (len) : %u (0x%08x)\n"), l
, l
);
6164 fprintf (file
, _(" image offset : 0x%08x\n"),
6165 (unsigned int) bfd_getl32 (esgps
->base
));
6166 fprintf (file
, _(" symvec offset : 0x%08x\n"),
6167 (unsigned int) bfd_getl32 (esgps
->value
));
6168 rest
= len
- offsetof (struct vms_esgps
, name
);
6169 fprintf (file
, _(" name : %.*s\n"),
6170 esgps
->namlng
> rest
? rest
: esgps
->namlng
,
6175 if (len
>= sizeof (struct vms_egsy
))
6177 struct vms_egsy
*egsy
= (struct vms_egsy
*) e
;
6178 unsigned int flags
= bfd_getl16 (egsy
->flags
);
6180 if ((flags
& EGSY__V_DEF
) != 0
6181 && len
>= offsetof (struct vms_esdf
, name
))
6183 struct vms_esdf
*esdf
= (struct vms_esdf
*) e
;
6185 fprintf (file
, _("SYM - Global symbol definition\n"));
6186 fprintf (file
, _(" flags: 0x%04x"), flags
);
6187 exav_bfd_print_egsy_flags (flags
, file
);
6189 fprintf (file
, _(" psect offset: 0x%08x\n"),
6190 (unsigned) bfd_getl32 (esdf
->value
));
6191 if (flags
& EGSY__V_NORM
)
6193 fprintf (file
, _(" code address: 0x%08x\n"),
6194 (unsigned) bfd_getl32 (esdf
->code_address
));
6195 fprintf (file
, _(" psect index for entry point : %u\n"),
6196 (unsigned) bfd_getl32 (esdf
->ca_psindx
));
6198 fprintf (file
, _(" psect index : %u\n"),
6199 (unsigned) bfd_getl32 (esdf
->psindx
));
6200 rest
= len
- offsetof (struct vms_esdf
, name
);
6201 fprintf (file
, _(" name : %.*s\n"),
6202 esdf
->namlng
> rest
? rest
: esdf
->namlng
,
6205 else if (len
>= offsetof (struct vms_esrf
, name
))
6207 struct vms_esrf
*esrf
= (struct vms_esrf
*)e
;
6209 fprintf (file
, _("SYM - Global symbol reference\n"));
6210 rest
= len
- offsetof (struct vms_esrf
, name
);
6211 fprintf (file
, _(" name : %.*s\n"),
6212 esrf
->namlng
> rest
? rest
: esrf
->namlng
,
6218 if (len
>= sizeof (struct vms_eidc
))
6220 struct vms_eidc
*eidc
= (struct vms_eidc
*) e
;
6221 unsigned int flags
= bfd_getl32 (eidc
->flags
);
6224 fprintf (file
, _("IDC - Ident Consistency check\n"));
6225 fprintf (file
, _(" flags : 0x%08x"), flags
);
6226 if (flags
& EIDC__V_BINIDENT
)
6227 fputs (" BINDENT", file
);
6229 fprintf (file
, _(" id match : %x\n"),
6230 (flags
>> EIDC__V_IDMATCH_SH
) & EIDC__V_IDMATCH_MASK
);
6231 fprintf (file
, _(" error severity: %x\n"),
6232 (flags
>> EIDC__V_ERRSEV_SH
) & EIDC__V_ERRSEV_MASK
);
6234 rest
= len
- (p
- (unsigned char *) e
);
6235 fprintf (file
, _(" entity name : %.*s\n"),
6236 p
[0] > rest
- 1 ? rest
- 1 : p
[0], p
+ 1);
6237 if (rest
> 1u + p
[0])
6241 fprintf (file
, _(" object name : %.*s\n"),
6242 p
[0] > rest
- 1 ? rest
- 1 : p
[0], p
+ 1);
6243 if (rest
> 1u + p
[0])
6247 if (flags
& EIDC__V_BINIDENT
)
6250 fprintf (file
, _(" binary ident : 0x%08x\n"),
6251 (unsigned) bfd_getl32 (p
));
6254 fprintf (file
, _(" ascii ident : %.*s\n"),
6255 p
[0] > rest
- 1 ? rest
- 1 : p
[0], p
+ 1);
6261 if (len
>= offsetof (struct vms_egst
, name
))
6263 struct vms_egst
*egst
= (struct vms_egst
*) e
;
6264 unsigned int flags
= bfd_getl16 (egst
->header
.flags
);
6266 fprintf (file
, _("SYMG - Universal symbol definition\n"));
6267 fprintf (file
, _(" flags: 0x%04x"), flags
);
6268 exav_bfd_print_egsy_flags (flags
, file
);
6270 fprintf (file
, _(" symbol vector offset: 0x%08x\n"),
6271 (unsigned) bfd_getl32 (egst
->value
));
6272 fprintf (file
, _(" entry point: 0x%08x\n"),
6273 (unsigned) bfd_getl32 (egst
->lp_1
));
6274 fprintf (file
, _(" proc descr : 0x%08x\n"),
6275 (unsigned) bfd_getl32 (egst
->lp_2
));
6276 fprintf (file
, _(" psect index: %u\n"),
6277 (unsigned) bfd_getl32 (egst
->psindx
));
6278 rest
= len
- offsetof (struct vms_egst
, name
);
6279 fprintf (file
, _(" name : %.*s\n"),
6280 egst
->namlng
> rest
? rest
: egst
->namlng
,
6285 if (len
>= offsetof (struct vms_esdfv
, name
))
6287 struct vms_esdfv
*esdfv
= (struct vms_esdfv
*) e
;
6288 unsigned int flags
= bfd_getl16 (esdfv
->flags
);
6290 fprintf (file
, _("SYMV - Vectored symbol definition\n"));
6291 fprintf (file
, _(" flags: 0x%04x"), flags
);
6292 exav_bfd_print_egsy_flags (flags
, file
);
6294 fprintf (file
, _(" vector : 0x%08x\n"),
6295 (unsigned) bfd_getl32 (esdfv
->vector
));
6296 fprintf (file
, _(" psect offset: %u\n"),
6297 (unsigned) bfd_getl32 (esdfv
->value
));
6298 fprintf (file
, _(" psect index : %u\n"),
6299 (unsigned) bfd_getl32 (esdfv
->psindx
));
6300 rest
= len
- offsetof (struct vms_esdfv
, name
);
6301 fprintf (file
, _(" name : %.*s\n"),
6302 esdfv
->namlng
> rest
? rest
: esdfv
->namlng
,
6307 if (len
>= offsetof (struct vms_esdfm
, name
))
6309 struct vms_esdfm
*esdfm
= (struct vms_esdfm
*) e
;
6310 unsigned int flags
= bfd_getl16 (esdfm
->flags
);
6313 _("SYMM - Global symbol definition with version\n"));
6314 fprintf (file
, _(" flags: 0x%04x"), flags
);
6315 exav_bfd_print_egsy_flags (flags
, file
);
6317 fprintf (file
, _(" version mask: 0x%08x\n"),
6318 (unsigned)bfd_getl32 (esdfm
->version_mask
));
6319 fprintf (file
, _(" psect offset: %u\n"),
6320 (unsigned)bfd_getl32 (esdfm
->value
));
6321 fprintf (file
, _(" psect index : %u\n"),
6322 (unsigned)bfd_getl32 (esdfm
->psindx
));
6323 rest
= len
- offsetof (struct vms_esdfm
, name
);
6324 fprintf (file
, _(" name : %.*s\n"),
6325 esdfm
->namlng
> rest
? rest
: esdfm
->namlng
,
6330 fprintf (file
, _("unhandled egsd entry type %u\n"), type
);
6338 evax_bfd_print_hex (FILE *file
, const char *pfx
,
6339 const unsigned char *buf
, unsigned int len
)
6345 for (i
= 0; i
< len
; i
++)
6349 fprintf (file
, " %02x", buf
[i
]);
6362 evax_bfd_print_etir_stc_ir (FILE *file
, const unsigned char *buf
,
6363 unsigned int len
, int is_ps
)
6365 if (is_ps
? len
< 44 : len
< 33)
6368 /* xgettext:c-format */
6369 fprintf (file
, _(" linkage index: %u, replacement insn: 0x%08x\n"),
6370 (unsigned)bfd_getl32 (buf
),
6371 (unsigned)bfd_getl32 (buf
+ 16));
6372 /* xgettext:c-format */
6373 fprintf (file
, _(" psect idx 1: %u, offset 1: 0x%08x %08x\n"),
6374 (unsigned)bfd_getl32 (buf
+ 4),
6375 (unsigned)bfd_getl32 (buf
+ 12),
6376 (unsigned)bfd_getl32 (buf
+ 8));
6377 /* xgettext:c-format */
6378 fprintf (file
, _(" psect idx 2: %u, offset 2: 0x%08x %08x\n"),
6379 (unsigned)bfd_getl32 (buf
+ 20),
6380 (unsigned)bfd_getl32 (buf
+ 28),
6381 (unsigned)bfd_getl32 (buf
+ 24));
6383 /* xgettext:c-format */
6384 fprintf (file
, _(" psect idx 3: %u, offset 3: 0x%08x %08x\n"),
6385 (unsigned)bfd_getl32 (buf
+ 32),
6386 (unsigned)bfd_getl32 (buf
+ 40),
6387 (unsigned)bfd_getl32 (buf
+ 36));
6389 fprintf (file
, _(" global name: %.*s\n"),
6390 buf
[32] > len
- 33 ? len
- 33 : buf
[32],
6395 evax_bfd_print_etir (FILE *file
, const char *name
,
6396 unsigned char *rec
, unsigned int rec_len
)
6398 unsigned int off
= sizeof (struct vms_eobjrec
);
6400 /* xgettext:c-format */
6401 fprintf (file
, _(" %s (len=%u):\n"), name
, (unsigned) rec_len
);
6402 if (rec_len
< sizeof (struct vms_eobjrec
) + sizeof (struct vms_etir
))
6405 while (off
<= rec_len
- sizeof (struct vms_etir
))
6407 struct vms_etir
*etir
= (struct vms_etir
*)(rec
+ off
);
6413 type
= bfd_getl16 (etir
->rectyp
);
6414 size
= bfd_getl16 (etir
->size
);
6415 buf
= rec
+ off
+ sizeof (struct vms_etir
);
6417 if (size
< sizeof (struct vms_etir
) || size
> rec_len
- off
)
6419 fprintf (file
, _(" Erroneous length\n"));
6423 /* xgettext:c-format */
6424 fprintf (file
, _(" (type: %3u, size: %3u): "), type
, size
);
6425 rest
= size
- sizeof (struct vms_etir
);
6428 case ETIR__C_STA_GBL
:
6430 fprintf (file
, _("STA_GBL (stack global) %.*s\n"),
6431 buf
[0] > rest
- 1 ? rest
- 1 : buf
[0], buf
+ 1);
6433 case ETIR__C_STA_LW
:
6434 fprintf (file
, _("STA_LW (stack longword)"));
6436 fprintf (file
, " 0x%08x\n",
6437 (unsigned) bfd_getl32 (buf
));
6439 case ETIR__C_STA_QW
:
6440 fprintf (file
, _("STA_QW (stack quadword)"));
6442 fprintf (file
, " 0x%08x %08x\n",
6443 (unsigned) bfd_getl32 (buf
+ 4),
6444 (unsigned) bfd_getl32 (buf
+ 0));
6446 case ETIR__C_STA_PQ
:
6447 fprintf (file
, _("STA_PQ (stack psect base + offset)\n"));
6449 /* xgettext:c-format */
6450 fprintf (file
, _(" psect: %u, offset: 0x%08x %08x\n"),
6451 (unsigned) bfd_getl32 (buf
+ 0),
6452 (unsigned) bfd_getl32 (buf
+ 8),
6453 (unsigned) bfd_getl32 (buf
+ 4));
6455 case ETIR__C_STA_LI
:
6456 fprintf (file
, _("STA_LI (stack literal)\n"));
6458 case ETIR__C_STA_MOD
:
6459 fprintf (file
, _("STA_MOD (stack module)\n"));
6461 case ETIR__C_STA_CKARG
:
6462 fprintf (file
, _("STA_CKARG (compare procedure argument)\n"));
6466 fprintf (file
, _("STO_B (store byte)\n"));
6469 fprintf (file
, _("STO_W (store word)\n"));
6471 case ETIR__C_STO_LW
:
6472 fprintf (file
, _("STO_LW (store longword)\n"));
6474 case ETIR__C_STO_QW
:
6475 fprintf (file
, _("STO_QW (store quadword)\n"));
6477 case ETIR__C_STO_IMMR
:
6480 unsigned int rpt
= bfd_getl32 (buf
);
6482 _("STO_IMMR (store immediate repeat) %u bytes\n"),
6486 evax_bfd_print_hex (file
, " ", buf
+ 4, rpt
);
6489 case ETIR__C_STO_GBL
:
6491 fprintf (file
, _("STO_GBL (store global) %.*s\n"),
6492 buf
[0] > rest
- 1 ? rest
- 1 : buf
[0], buf
+ 1);
6494 case ETIR__C_STO_CA
:
6496 fprintf (file
, _("STO_CA (store code address) %.*s\n"),
6497 buf
[0] > rest
- 1 ? rest
- 1 : buf
[0], buf
+ 1);
6499 case ETIR__C_STO_RB
:
6500 fprintf (file
, _("STO_RB (store relative branch)\n"));
6502 case ETIR__C_STO_AB
:
6503 fprintf (file
, _("STO_AB (store absolute branch)\n"));
6505 case ETIR__C_STO_OFF
:
6506 fprintf (file
, _("STO_OFF (store offset to psect)\n"));
6508 case ETIR__C_STO_IMM
:
6511 unsigned int rpt
= bfd_getl32 (buf
);
6513 _("STO_IMM (store immediate) %u bytes\n"),
6517 evax_bfd_print_hex (file
, " ", buf
+ 4, rpt
);
6520 case ETIR__C_STO_GBL_LW
:
6522 fprintf (file
, _("STO_GBL_LW (store global longword) %.*s\n"),
6523 buf
[0] > rest
- 1 ? rest
- 1 : buf
[0], buf
+ 1);
6525 case ETIR__C_STO_LP_PSB
:
6526 fprintf (file
, _("STO_OFF (store LP with procedure signature)\n"));
6528 case ETIR__C_STO_HINT_GBL
:
6529 fprintf (file
, _("STO_BR_GBL (store branch global) *todo*\n"));
6531 case ETIR__C_STO_HINT_PS
:
6532 fprintf (file
, _("STO_BR_PS (store branch psect + offset) *todo*\n"));
6535 case ETIR__C_OPR_NOP
:
6536 fprintf (file
, _("OPR_NOP (no-operation)\n"));
6538 case ETIR__C_OPR_ADD
:
6539 fprintf (file
, _("OPR_ADD (add)\n"));
6541 case ETIR__C_OPR_SUB
:
6542 fprintf (file
, _("OPR_SUB (subtract)\n"));
6544 case ETIR__C_OPR_MUL
:
6545 fprintf (file
, _("OPR_MUL (multiply)\n"));
6547 case ETIR__C_OPR_DIV
:
6548 fprintf (file
, _("OPR_DIV (divide)\n"));
6550 case ETIR__C_OPR_AND
:
6551 fprintf (file
, _("OPR_AND (logical and)\n"));
6553 case ETIR__C_OPR_IOR
:
6554 fprintf (file
, _("OPR_IOR (logical inclusive or)\n"));
6556 case ETIR__C_OPR_EOR
:
6557 fprintf (file
, _("OPR_EOR (logical exclusive or)\n"));
6559 case ETIR__C_OPR_NEG
:
6560 fprintf (file
, _("OPR_NEG (negate)\n"));
6562 case ETIR__C_OPR_COM
:
6563 fprintf (file
, _("OPR_COM (complement)\n"));
6565 case ETIR__C_OPR_INSV
:
6566 fprintf (file
, _("OPR_INSV (insert field)\n"));
6568 case ETIR__C_OPR_ASH
:
6569 fprintf (file
, _("OPR_ASH (arithmetic shift)\n"));
6571 case ETIR__C_OPR_USH
:
6572 fprintf (file
, _("OPR_USH (unsigned shift)\n"));
6574 case ETIR__C_OPR_ROT
:
6575 fprintf (file
, _("OPR_ROT (rotate)\n"));
6577 case ETIR__C_OPR_SEL
:
6578 fprintf (file
, _("OPR_SEL (select)\n"));
6580 case ETIR__C_OPR_REDEF
:
6581 fprintf (file
, _("OPR_REDEF (redefine symbol to curr location)\n"));
6583 case ETIR__C_OPR_DFLIT
:
6584 fprintf (file
, _("OPR_REDEF (define a literal)\n"));
6587 case ETIR__C_STC_LP
:
6588 fprintf (file
, _("STC_LP (store cond linkage pair)\n"));
6590 case ETIR__C_STC_LP_PSB
:
6592 _("STC_LP_PSB (store cond linkage pair + signature)\n"));
6595 /* xgettext:c-format */
6596 fprintf (file
, _(" linkage index: %u, procedure: %.*s\n"),
6597 (unsigned) bfd_getl32 (buf
),
6598 buf
[4] > rest
- 5 ? rest
- 5 : buf
[4], buf
+ 5);
6599 if (rest
> 4 + 1u + buf
[4])
6601 rest
-= 4 + 1 + buf
[4];
6602 buf
+= 4 + 1 + buf
[4];
6603 fprintf (file
, _(" signature: %.*s\n"),
6604 buf
[0] > rest
- 1 ? rest
- 1: buf
[0], buf
+ 1);
6608 case ETIR__C_STC_GBL
:
6609 fprintf (file
, _("STC_GBL (store cond global)\n"));
6611 /* xgettext:c-format */
6612 fprintf (file
, _(" linkage index: %u, global: %.*s\n"),
6613 (unsigned) bfd_getl32 (buf
),
6614 buf
[4] > rest
- 5 ? rest
- 5 : buf
[4], buf
+ 5);
6616 case ETIR__C_STC_GCA
:
6617 fprintf (file
, _("STC_GCA (store cond code address)\n"));
6619 /* xgettext:c-format */
6620 fprintf (file
, _(" linkage index: %u, procedure name: %.*s\n"),
6621 (unsigned) bfd_getl32 (buf
),
6622 buf
[4] > rest
- 5 ? rest
- 5 : buf
[4], buf
+ 5);
6624 case ETIR__C_STC_PS
:
6625 fprintf (file
, _("STC_PS (store cond psect + offset)\n"));
6628 /* xgettext:c-format */
6629 _(" linkage index: %u, psect: %u, offset: 0x%08x %08x\n"),
6630 (unsigned)bfd_getl32 (buf
),
6631 (unsigned)bfd_getl32 (buf
+ 4),
6632 (unsigned)bfd_getl32 (buf
+ 12),
6633 (unsigned)bfd_getl32 (buf
+ 8));
6635 case ETIR__C_STC_NOP_GBL
:
6636 fprintf (file
, _("STC_NOP_GBL (store cond NOP at global addr)\n"));
6637 evax_bfd_print_etir_stc_ir (file
, buf
, rest
, 0);
6639 case ETIR__C_STC_NOP_PS
:
6640 fprintf (file
, _("STC_NOP_PS (store cond NOP at psect + offset)\n"));
6641 evax_bfd_print_etir_stc_ir (file
, buf
, rest
, 1);
6643 case ETIR__C_STC_BSR_GBL
:
6644 fprintf (file
, _("STC_BSR_GBL (store cond BSR at global addr)\n"));
6645 evax_bfd_print_etir_stc_ir (file
, buf
, rest
, 0);
6647 case ETIR__C_STC_BSR_PS
:
6648 fprintf (file
, _("STC_BSR_PS (store cond BSR at psect + offset)\n"));
6649 evax_bfd_print_etir_stc_ir (file
, buf
, rest
, 1);
6651 case ETIR__C_STC_LDA_GBL
:
6652 fprintf (file
, _("STC_LDA_GBL (store cond LDA at global addr)\n"));
6653 evax_bfd_print_etir_stc_ir (file
, buf
, rest
, 0);
6655 case ETIR__C_STC_LDA_PS
:
6656 fprintf (file
, _("STC_LDA_PS (store cond LDA at psect + offset)\n"));
6657 evax_bfd_print_etir_stc_ir (file
, buf
, rest
, 1);
6659 case ETIR__C_STC_BOH_GBL
:
6660 fprintf (file
, _("STC_BOH_GBL (store cond BOH at global addr)\n"));
6661 evax_bfd_print_etir_stc_ir (file
, buf
, rest
, 0);
6663 case ETIR__C_STC_BOH_PS
:
6664 fprintf (file
, _("STC_BOH_PS (store cond BOH at psect + offset)\n"));
6665 evax_bfd_print_etir_stc_ir (file
, buf
, rest
, 1);
6667 case ETIR__C_STC_NBH_GBL
:
6669 _("STC_NBH_GBL (store cond or hint at global addr)\n"));
6671 case ETIR__C_STC_NBH_PS
:
6673 _("STC_NBH_PS (store cond or hint at psect + offset)\n"));
6676 case ETIR__C_CTL_SETRB
:
6677 fprintf (file
, _("CTL_SETRB (set relocation base)\n"));
6679 case ETIR__C_CTL_AUGRB
:
6682 unsigned int val
= bfd_getl32 (buf
);
6683 fprintf (file
, _("CTL_AUGRB (augment relocation base) %u\n"),
6687 case ETIR__C_CTL_DFLOC
:
6688 fprintf (file
, _("CTL_DFLOC (define location)\n"));
6690 case ETIR__C_CTL_STLOC
:
6691 fprintf (file
, _("CTL_STLOC (set location)\n"));
6693 case ETIR__C_CTL_STKDL
:
6694 fprintf (file
, _("CTL_STKDL (stack defined location)\n"));
6697 fprintf (file
, _("*unhandled*\n"));
6705 evax_bfd_print_eobj (struct bfd
*abfd
, FILE *file
)
6707 bool is_first
= true;
6708 bool has_records
= false;
6712 unsigned int rec_len
;
6713 unsigned int pad_len
;
6715 unsigned int hdr_size
;
6720 unsigned char buf
[6];
6725 if (bfd_bread (buf
, sizeof (buf
), abfd
) != sizeof (buf
))
6727 fprintf (file
, _("cannot read GST record length\n"));
6730 rec_len
= bfd_getl16 (buf
+ 0);
6731 if (rec_len
== bfd_getl16 (buf
+ 4)
6732 && bfd_getl16 (buf
+ 2) == EOBJ__C_EMH
)
6734 /* The format is raw: record-size, type, record-size. */
6736 pad_len
= (rec_len
+ 1) & ~1U;
6739 else if (rec_len
== EOBJ__C_EMH
)
6741 has_records
= false;
6742 pad_len
= bfd_getl16 (buf
+ 2);
6748 fprintf (file
, _("cannot find EMH in first GST record\n"));
6751 rec
= bfd_malloc (pad_len
);
6752 memcpy (rec
, buf
+ sizeof (buf
) - hdr_size
, hdr_size
);
6756 unsigned int rec_len2
= 0;
6757 unsigned char hdr
[4];
6761 unsigned char buf_len
[2];
6763 if (bfd_bread (buf_len
, sizeof (buf_len
), abfd
)
6764 != sizeof (buf_len
))
6766 fprintf (file
, _("cannot read GST record length\n"));
6769 rec_len2
= (unsigned)bfd_getl16 (buf_len
);
6772 if (bfd_bread (hdr
, sizeof (hdr
), abfd
) != sizeof (hdr
))
6774 fprintf (file
, _("cannot read GST record header\n"));
6777 rec_len
= (unsigned)bfd_getl16 (hdr
+ 2);
6779 pad_len
= (rec_len
+ 1) & ~1U;
6782 rec
= bfd_malloc (pad_len
);
6783 memcpy (rec
, hdr
, sizeof (hdr
));
6784 hdr_size
= sizeof (hdr
);
6785 if (has_records
&& rec_len2
!= rec_len
)
6787 fprintf (file
, _(" corrupted GST\n"));
6792 if (bfd_bread (rec
+ hdr_size
, pad_len
- hdr_size
, abfd
)
6793 != pad_len
- hdr_size
)
6795 fprintf (file
, _("cannot read GST record\n"));
6799 type
= (unsigned)bfd_getl16 (rec
);
6804 evax_bfd_print_emh (file
, rec
, rec_len
);
6807 evax_bfd_print_egsd (file
, rec
, rec_len
);
6810 evax_bfd_print_eeom (file
, rec
, rec_len
);
6815 evax_bfd_print_etir (file
, "ETIR", rec
, rec_len
);
6818 evax_bfd_print_etir (file
, "EDBG", rec
, rec_len
);
6821 evax_bfd_print_etir (file
, "ETBT", rec
, rec_len
);
6824 fprintf (file
, _(" unhandled EOBJ record type %u\n"), type
);
6832 evax_bfd_print_relocation_records (FILE *file
, const unsigned char *buf
,
6833 size_t buf_size
, size_t off
,
6834 unsigned int stride
)
6836 while (off
<= buf_size
- 8)
6842 count
= bfd_getl32 (buf
+ off
+ 0);
6846 base
= bfd_getl32 (buf
+ off
+ 4);
6848 /* xgettext:c-format */
6849 fprintf (file
, _(" bitcount: %u, base addr: 0x%08x\n"),
6853 for (j
= 0; count
> 0 && off
<= buf_size
- 4; j
+= 4, count
-= 32)
6859 val
= bfd_getl32 (buf
+ off
);
6862 /* xgettext:c-format */
6863 fprintf (file
, _(" bitmap: 0x%08x (count: %u):\n"), val
, count
);
6865 for (k
= 0; k
< 32; k
++)
6866 if (val
& (1u << k
))
6870 fprintf (file
, _(" %08x"), base
+ (j
* 8 + k
) * stride
);
6885 evax_bfd_print_address_fixups (FILE *file
, const unsigned char *buf
,
6886 size_t buf_size
, size_t off
)
6888 while (off
<= buf_size
- 8)
6893 count
= bfd_getl32 (buf
+ off
+ 0);
6896 /* xgettext:c-format */
6897 fprintf (file
, _(" image %u (%u entries)\n"),
6898 (unsigned) bfd_getl32 (buf
+ off
+ 4), count
);
6900 for (j
= 0; j
< count
&& off
<= buf_size
- 8; j
++)
6902 /* xgettext:c-format */
6903 fprintf (file
, _(" offset: 0x%08x, val: 0x%08x\n"),
6904 (unsigned) bfd_getl32 (buf
+ off
+ 0),
6905 (unsigned) bfd_getl32 (buf
+ off
+ 4));
6912 evax_bfd_print_reference_fixups (FILE *file
, const unsigned char *buf
,
6913 size_t buf_size
, size_t off
)
6917 while (off
<= buf_size
- 8)
6922 count
= bfd_getl32 (buf
+ off
+ 0);
6925 /* xgettext:c-format */
6926 fprintf (file
, _(" image %u (%u entries), offsets:\n"),
6927 (unsigned) bfd_getl32 (buf
+ off
+ 4), count
);
6929 for (j
= 0; j
< count
&& off
<= buf_size
- 4; j
++)
6933 fprintf (file
, _(" 0x%08x"), (unsigned) bfd_getl32 (buf
+ off
));
6948 evax_bfd_print_indent (int indent
, FILE *file
)
6950 for (; indent
; indent
--)
6955 evax_bfd_get_dsc_name (unsigned int v
)
6959 case DSC__K_DTYPE_Z
:
6960 return "Z (Unspecified)";
6961 case DSC__K_DTYPE_V
:
6963 case DSC__K_DTYPE_BU
:
6964 return "BU (Byte logical)";
6965 case DSC__K_DTYPE_WU
:
6966 return "WU (Word logical)";
6967 case DSC__K_DTYPE_LU
:
6968 return "LU (Longword logical)";
6969 case DSC__K_DTYPE_QU
:
6970 return "QU (Quadword logical)";
6971 case DSC__K_DTYPE_B
:
6972 return "B (Byte integer)";
6973 case DSC__K_DTYPE_W
:
6974 return "W (Word integer)";
6975 case DSC__K_DTYPE_L
:
6976 return "L (Longword integer)";
6977 case DSC__K_DTYPE_Q
:
6978 return "Q (Quadword integer)";
6979 case DSC__K_DTYPE_F
:
6980 return "F (Single-precision floating)";
6981 case DSC__K_DTYPE_D
:
6982 return "D (Double-precision floating)";
6983 case DSC__K_DTYPE_FC
:
6984 return "FC (Complex)";
6985 case DSC__K_DTYPE_DC
:
6986 return "DC (Double-precision Complex)";
6987 case DSC__K_DTYPE_T
:
6988 return "T (ASCII text string)";
6989 case DSC__K_DTYPE_NU
:
6990 return "NU (Numeric string, unsigned)";
6991 case DSC__K_DTYPE_NL
:
6992 return "NL (Numeric string, left separate sign)";
6993 case DSC__K_DTYPE_NLO
:
6994 return "NLO (Numeric string, left overpunched sign)";
6995 case DSC__K_DTYPE_NR
:
6996 return "NR (Numeric string, right separate sign)";
6997 case DSC__K_DTYPE_NRO
:
6998 return "NRO (Numeric string, right overpunched sig)";
6999 case DSC__K_DTYPE_NZ
:
7000 return "NZ (Numeric string, zoned sign)";
7001 case DSC__K_DTYPE_P
:
7002 return "P (Packed decimal string)";
7003 case DSC__K_DTYPE_ZI
:
7004 return "ZI (Sequence of instructions)";
7005 case DSC__K_DTYPE_ZEM
:
7006 return "ZEM (Procedure entry mask)";
7007 case DSC__K_DTYPE_DSC
:
7008 return "DSC (Descriptor, used for arrays of dyn strings)";
7009 case DSC__K_DTYPE_OU
:
7010 return "OU (Octaword logical)";
7011 case DSC__K_DTYPE_O
:
7012 return "O (Octaword integer)";
7013 case DSC__K_DTYPE_G
:
7014 return "G (Double precision G floating, 64 bit)";
7015 case DSC__K_DTYPE_H
:
7016 return "H (Quadruple precision floating, 128 bit)";
7017 case DSC__K_DTYPE_GC
:
7018 return "GC (Double precision complex, G floating)";
7019 case DSC__K_DTYPE_HC
:
7020 return "HC (Quadruple precision complex, H floating)";
7021 case DSC__K_DTYPE_CIT
:
7022 return "CIT (COBOL intermediate temporary)";
7023 case DSC__K_DTYPE_BPV
:
7024 return "BPV (Bound Procedure Value)";
7025 case DSC__K_DTYPE_BLV
:
7026 return "BLV (Bound Label Value)";
7027 case DSC__K_DTYPE_VU
:
7028 return "VU (Bit Unaligned)";
7029 case DSC__K_DTYPE_ADT
:
7030 return "ADT (Absolute Date-Time)";
7031 case DSC__K_DTYPE_VT
:
7032 return "VT (Varying Text)";
7033 case DSC__K_DTYPE_T2
:
7034 return "T2 (16-bit char)";
7035 case DSC__K_DTYPE_VT2
:
7036 return "VT2 (16-bit varying char)";
7038 return "?? (unknown)";
7043 evax_bfd_print_desc (const unsigned char *buf
, unsigned int bufsize
,
7044 int indent
, FILE *file
)
7049 unsigned char bclass
= buf
[3];
7050 unsigned char dtype
= buf
[2];
7051 unsigned int len
= (unsigned)bfd_getl16 (buf
);
7052 unsigned int pointer
= (unsigned)bfd_getl32 (buf
+ 4);
7054 evax_bfd_print_indent (indent
, file
);
7056 if (len
== 1 && pointer
== 0xffffffffUL
)
7059 fprintf (file
, _("64 bits *unhandled*\n"));
7063 /* xgettext:c-format */
7064 fprintf (file
, _("class: %u, dtype: %u, length: %u, pointer: 0x%08x\n"),
7065 bclass
, dtype
, len
, pointer
);
7068 case DSC__K_CLASS_NCA
:
7070 const struct vms_dsc_nca
*dsc
= (const void *)buf
;
7072 const unsigned char *b
;
7074 evax_bfd_print_indent (indent
, file
);
7075 fprintf (file
, _("non-contiguous array of %s\n"),
7076 evax_bfd_get_dsc_name (dsc
->dtype
));
7077 if (bufsize
>= sizeof (*dsc
))
7079 evax_bfd_print_indent (indent
+ 1, file
);
7081 /* xgettext:c-format */
7082 _("dimct: %u, aflags: 0x%02x, digits: %u, scale: %u\n"),
7083 dsc
->dimct
, dsc
->aflags
, dsc
->digits
, dsc
->scale
);
7084 evax_bfd_print_indent (indent
+ 1, file
);
7086 /* xgettext:c-format */
7087 _("arsize: %u, a0: 0x%08x\n"),
7088 (unsigned) bfd_getl32 (dsc
->arsize
),
7089 (unsigned) bfd_getl32 (dsc
->a0
));
7090 evax_bfd_print_indent (indent
+ 1, file
);
7091 fprintf (file
, _("Strides:\n"));
7092 b
= buf
+ sizeof (*dsc
);
7093 bufsize
-= sizeof (*dsc
);
7094 for (i
= 0; i
< dsc
->dimct
; i
++)
7098 evax_bfd_print_indent (indent
+ 2, file
);
7099 fprintf (file
, "[%u]: %u\n", i
+ 1,
7100 (unsigned) bfd_getl32 (b
));
7104 evax_bfd_print_indent (indent
+ 1, file
);
7105 fprintf (file
, _("Bounds:\n"));
7106 for (i
= 0; i
< dsc
->dimct
; i
++)
7110 evax_bfd_print_indent (indent
+ 2, file
);
7111 /* xgettext:c-format */
7112 fprintf (file
, _("[%u]: Lower: %u, upper: %u\n"), i
+ 1,
7113 (unsigned) bfd_getl32 (b
+ 0),
7114 (unsigned) bfd_getl32 (b
+ 4));
7121 case DSC__K_CLASS_UBS
:
7123 const struct vms_dsc_ubs
*ubs
= (const void *)buf
;
7125 evax_bfd_print_indent (indent
, file
);
7126 fprintf (file
, _("unaligned bit-string of %s\n"),
7127 evax_bfd_get_dsc_name (ubs
->dtype
));
7128 if (bufsize
>= sizeof (*ubs
))
7130 evax_bfd_print_indent (indent
+ 1, file
);
7132 /* xgettext:c-format */
7133 _("base: %u, pos: %u\n"),
7134 (unsigned) bfd_getl32 (ubs
->base
),
7135 (unsigned) bfd_getl32 (ubs
->pos
));
7140 fprintf (file
, _("*unhandled*\n"));
7147 evax_bfd_print_valspec (const unsigned char *buf
, unsigned int bufsize
,
7148 int indent
, FILE *file
)
7153 unsigned int vflags
= buf
[0];
7154 unsigned int value
= (unsigned) bfd_getl32 (buf
+ 1);
7155 unsigned int len
= 5;
7157 evax_bfd_print_indent (indent
, file
);
7158 /* xgettext:c-format */
7159 fprintf (file
, _("vflags: 0x%02x, value: 0x%08x "), vflags
, value
);
7165 case DST__K_VFLAGS_NOVAL
:
7166 fprintf (file
, _("(no value)\n"));
7168 case DST__K_VFLAGS_NOTACTIVE
:
7169 fprintf (file
, _("(not active)\n"));
7171 case DST__K_VFLAGS_UNALLOC
:
7172 fprintf (file
, _("(not allocated)\n"));
7174 case DST__K_VFLAGS_DSC
:
7175 fprintf (file
, _("(descriptor)\n"));
7176 if (value
<= bufsize
)
7177 evax_bfd_print_desc (buf
+ value
, bufsize
- value
, indent
+ 1, file
);
7179 case DST__K_VFLAGS_TVS
:
7180 fprintf (file
, _("(trailing value)\n"));
7182 case DST__K_VS_FOLLOWS
:
7183 fprintf (file
, _("(value spec follows)\n"));
7185 case DST__K_VFLAGS_BITOFFS
:
7186 fprintf (file
, _("(at bit offset %u)\n"), value
);
7189 /* xgettext:c-format */
7190 fprintf (file
, _("(reg: %u, disp: %u, indir: %u, kind: "),
7191 (vflags
& DST__K_REGNUM_MASK
) >> DST__K_REGNUM_SHIFT
,
7192 vflags
& DST__K_DISP
? 1 : 0,
7193 vflags
& DST__K_INDIR
? 1 : 0);
7194 switch (vflags
& DST__K_VALKIND_MASK
)
7196 case DST__K_VALKIND_LITERAL
:
7197 fputs (_("literal"), file
);
7199 case DST__K_VALKIND_ADDR
:
7200 fputs (_("address"), file
);
7202 case DST__K_VALKIND_DESC
:
7203 fputs (_("desc"), file
);
7205 case DST__K_VALKIND_REG
:
7206 fputs (_("reg"), file
);
7209 fputs (")\n", file
);
7216 evax_bfd_print_typspec (const unsigned char *buf
, unsigned int bufsize
,
7217 int indent
, FILE *file
)
7222 unsigned char kind
= buf
[2];
7223 unsigned int len
= (unsigned) bfd_getl16 (buf
);
7225 evax_bfd_print_indent (indent
, file
);
7226 /* xgettext:c-format */
7227 fprintf (file
, _("len: %2u, kind: %2u "), len
, kind
);
7232 case DST__K_TS_ATOM
:
7233 /* xgettext:c-format */
7235 fprintf (file
, _("atomic, type=0x%02x %s\n"),
7236 buf
[0], evax_bfd_get_dsc_name (buf
[0]));
7240 fprintf (file
, _("indirect, defined at 0x%08x\n"),
7241 (unsigned) bfd_getl32 (buf
));
7243 case DST__K_TS_TPTR
:
7244 fprintf (file
, _("typed pointer\n"));
7245 evax_bfd_print_typspec (buf
, bufsize
, indent
+ 1, file
);
7248 fprintf (file
, _("pointer\n"));
7250 case DST__K_TS_ARRAY
:
7252 const unsigned char *vs
;
7253 unsigned int vs_len
;
7254 unsigned int vec_len
;
7259 fprintf (file
, _("array, dim: %u, bitmap: "), buf
[0]);
7261 vec_len
= (buf
[0] + 1 + 7) / 8;
7262 for (i
= 0; i
< vec_len
; i
++)
7266 fprintf (file
, " %02x", buf
[i
+ 1]);
7272 vs
= buf
+ 1 + vec_len
;
7273 evax_bfd_print_indent (indent
, file
);
7274 fprintf (file
, _("array descriptor:\n"));
7275 vs_len
= evax_bfd_print_valspec (vs
, bufsize
, indent
+ 1, file
);
7277 if (bufsize
> vs_len
)
7280 for (i
= 0; i
< buf
[0] + 1U; i
++)
7281 if (buf
[1 + i
/ 8] & (1 << (i
% 8)))
7283 evax_bfd_print_indent (indent
, file
);
7285 fprintf (file
, _("type spec for element:\n"));
7287 fprintf (file
, _("type spec for subscript %u:\n"), i
);
7288 evax_bfd_print_typspec (vs
, bufsize
, indent
+ 1, file
);
7291 vs_len
= bfd_getl16 (vs
);
7292 if (bufsize
<= vs_len
)
7301 fprintf (file
, _("*unhandled*\n"));
7306 evax_bfd_print_dst (struct bfd
*abfd
, unsigned int dst_size
, FILE *file
)
7308 unsigned int off
= 0;
7309 unsigned int pc
= 0;
7310 unsigned int line
= 0;
7312 fprintf (file
, _("Debug symbol table:\n"));
7314 while (dst_size
> 0)
7316 struct vms_dst_header dsth
;
7321 if (bfd_bread (&dsth
, sizeof (dsth
), abfd
) != sizeof (dsth
))
7323 fprintf (file
, _("cannot read DST header\n"));
7326 len
= bfd_getl16 (dsth
.length
);
7327 type
= bfd_getl16 (dsth
.type
);
7328 /* xgettext:c-format */
7329 fprintf (file
, _(" type: %3u, len: %3u (at 0x%08x): "),
7331 if (len
< sizeof (dsth
))
7338 len
-= sizeof (dsth
);
7343 buf
= _bfd_malloc_and_read (abfd
, len
, len
);
7346 fprintf (file
, _("cannot read DST symbol\n"));
7352 case DSC__K_DTYPE_V
:
7353 case DSC__K_DTYPE_BU
:
7354 case DSC__K_DTYPE_WU
:
7355 case DSC__K_DTYPE_LU
:
7356 case DSC__K_DTYPE_QU
:
7357 case DSC__K_DTYPE_B
:
7358 case DSC__K_DTYPE_W
:
7359 case DSC__K_DTYPE_L
:
7360 case DSC__K_DTYPE_Q
:
7361 case DSC__K_DTYPE_F
:
7362 case DSC__K_DTYPE_D
:
7363 case DSC__K_DTYPE_FC
:
7364 case DSC__K_DTYPE_DC
:
7365 case DSC__K_DTYPE_T
:
7366 case DSC__K_DTYPE_NU
:
7367 case DSC__K_DTYPE_NL
:
7368 case DSC__K_DTYPE_NLO
:
7369 case DSC__K_DTYPE_NR
:
7370 case DSC__K_DTYPE_NRO
:
7371 case DSC__K_DTYPE_NZ
:
7372 case DSC__K_DTYPE_P
:
7373 case DSC__K_DTYPE_ZI
:
7374 case DSC__K_DTYPE_ZEM
:
7375 case DSC__K_DTYPE_DSC
:
7376 case DSC__K_DTYPE_OU
:
7377 case DSC__K_DTYPE_O
:
7378 case DSC__K_DTYPE_G
:
7379 case DSC__K_DTYPE_H
:
7380 case DSC__K_DTYPE_GC
:
7381 case DSC__K_DTYPE_HC
:
7382 case DSC__K_DTYPE_CIT
:
7383 case DSC__K_DTYPE_BPV
:
7384 case DSC__K_DTYPE_BLV
:
7385 case DSC__K_DTYPE_VU
:
7386 case DSC__K_DTYPE_ADT
:
7387 case DSC__K_DTYPE_VT
:
7388 case DSC__K_DTYPE_T2
:
7389 case DSC__K_DTYPE_VT2
:
7390 fprintf (file
, _("standard data: %s\n"),
7391 evax_bfd_get_dsc_name (type
));
7392 evax_bfd_print_valspec (buf
, len
, 4, file
);
7394 fprintf (file
, _(" name: %.*s\n"),
7395 buf
[5] > len
- 6 ? len
- 6 : buf
[5], buf
+ 6);
7399 struct vms_dst_modbeg
*dst
= (void *)buf
;
7400 const char *name
= (const char *)buf
+ sizeof (*dst
);
7402 fprintf (file
, _("modbeg\n"));
7403 if (len
< sizeof (*dst
))
7405 /* xgettext:c-format */
7406 fprintf (file
, _(" flags: %d, language: %u, "
7407 "major: %u, minor: %u\n"),
7409 (unsigned)bfd_getl32 (dst
->language
),
7410 (unsigned)bfd_getl16 (dst
->major
),
7411 (unsigned)bfd_getl16 (dst
->minor
));
7412 len
-= sizeof (*dst
);
7416 fprintf (file
, _(" module name: %.*s\n"),
7417 name
[0] > nlen
? nlen
: name
[0], name
+ 1);
7421 name
+= name
[0] + 1;
7423 fprintf (file
, _(" compiler : %.*s\n"),
7424 name
[0] > nlen
? nlen
: name
[0], name
+ 1);
7430 fprintf (file
, _("modend\n"));
7434 struct vms_dst_rtnbeg
*dst
= (void *)buf
;
7435 const char *name
= (const char *)buf
+ sizeof (*dst
);
7437 fputs (_("rtnbeg\n"), file
);
7438 if (len
>= sizeof (*dst
))
7440 /* xgettext:c-format */
7441 fprintf (file
, _(" flags: %u, address: 0x%08x, "
7442 "pd-address: 0x%08x\n"),
7444 (unsigned) bfd_getl32 (dst
->address
),
7445 (unsigned) bfd_getl32 (dst
->pd_address
));
7446 len
-= sizeof (*dst
);
7450 fprintf (file
, _(" routine name: %.*s\n"),
7451 name
[0] > nlen
? nlen
: name
[0], name
+ 1);
7458 struct vms_dst_rtnend
*dst
= (void *)buf
;
7460 if (len
>= sizeof (*dst
))
7461 fprintf (file
, _("rtnend: size 0x%08x\n"),
7462 (unsigned) bfd_getl32 (dst
->size
));
7467 struct vms_dst_prolog
*dst
= (void *)buf
;
7469 if (len
>= sizeof (*dst
))
7470 /* xgettext:c-format */
7471 fprintf (file
, _("prolog: bkpt address 0x%08x\n"),
7472 (unsigned) bfd_getl32 (dst
->bkpt_addr
));
7477 struct vms_dst_epilog
*dst
= (void *)buf
;
7479 if (len
>= sizeof (*dst
))
7480 /* xgettext:c-format */
7481 fprintf (file
, _("epilog: flags: %u, count: %u\n"),
7482 dst
->flags
, (unsigned) bfd_getl32 (dst
->count
));
7487 struct vms_dst_blkbeg
*dst
= (void *)buf
;
7488 const char *name
= (const char *)buf
+ sizeof (*dst
);
7490 if (len
> sizeof (*dst
))
7493 len
-= sizeof (*dst
);
7495 /* xgettext:c-format */
7496 fprintf (file
, _("blkbeg: address: 0x%08x, name: %.*s\n"),
7497 (unsigned) bfd_getl32 (dst
->address
),
7498 name
[0] > nlen
? nlen
: name
[0], name
+ 1);
7504 struct vms_dst_blkend
*dst
= (void *)buf
;
7506 if (len
>= sizeof (*dst
))
7507 /* xgettext:c-format */
7508 fprintf (file
, _("blkend: size: 0x%08x\n"),
7509 (unsigned) bfd_getl32 (dst
->size
));
7512 case DST__K_TYPSPEC
:
7514 fprintf (file
, _("typspec (len: %u)\n"), len
);
7518 fprintf (file
, _(" name: %.*s\n"),
7519 buf
[0] > nlen
? nlen
: buf
[0], buf
+ 1);
7521 evax_bfd_print_typspec (buf
+ 1 + buf
[0], len
- (1 + buf
[0]),
7530 fprintf (file
, _("septyp, name: %.*s\n"),
7531 buf
[5] > len
- 6 ? len
- 6 : buf
[5], buf
+ 6);
7532 evax_bfd_print_valspec (buf
, len
, 4, file
);
7538 struct vms_dst_recbeg
*recbeg
= (void *)buf
;
7539 const char *name
= (const char *)buf
+ sizeof (*recbeg
);
7541 if (len
> sizeof (*recbeg
))
7543 int nlen
= len
- sizeof (*recbeg
) - 1;
7546 fprintf (file
, _("recbeg: name: %.*s\n"), nlen
, name
+ 1);
7547 evax_bfd_print_valspec (buf
, len
, 4, file
);
7550 fprintf (file
, _(" len: %u bits\n"),
7551 (unsigned) bfd_getl32 (name
+ 1 + nlen
));
7556 fprintf (file
, _("recend\n"));
7558 case DST__K_ENUMBEG
:
7560 /* xgettext:c-format */
7561 fprintf (file
, _("enumbeg, len: %u, name: %.*s\n"),
7562 buf
[0], buf
[1] > len
- 2 ? len
- 2 : buf
[1], buf
+ 2);
7564 case DST__K_ENUMELT
:
7567 fprintf (file
, _("enumelt, name: %.*s\n"),
7568 buf
[5] > len
- 6 ? len
- 6 : buf
[5], buf
+ 6);
7569 evax_bfd_print_valspec (buf
, len
, 4, file
);
7572 case DST__K_ENUMEND
:
7573 fprintf (file
, _("enumend\n"));
7577 struct vms_dst_label
*lab
= (void *)buf
;
7578 if (len
>= sizeof (*lab
))
7580 fprintf (file
, _("label, name: %.*s\n"),
7581 lab
->name
[0] > len
- 1 ? len
- 1 : lab
->name
[0],
7583 fprintf (file
, _(" address: 0x%08x\n"),
7584 (unsigned) bfd_getl32 (lab
->value
));
7588 case DST__K_DIS_RANGE
:
7591 unsigned int cnt
= bfd_getl32 (buf
);
7592 unsigned char *rng
= buf
+ 4;
7595 fprintf (file
, _("discontiguous range (nbr: %u)\n"), cnt
);
7597 for (i
= 0; i
< cnt
; i
++, rng
+= 8)
7601 /* xgettext:c-format */
7602 fprintf (file
, _(" address: 0x%08x, size: %u\n"),
7603 (unsigned) bfd_getl32 (rng
),
7604 (unsigned) bfd_getl32 (rng
+ 4));
7609 case DST__K_LINE_NUM
:
7611 unsigned char *buf_orig
= buf
;
7613 fprintf (file
, _("line num (len: %u)\n"), len
);
7628 case DST__K_DELTA_PC_W
:
7631 val
= bfd_getl16 (buf
);
7632 fprintf (file
, _("delta_pc_w %u\n"), val
);
7637 case DST__K_INCR_LINUM
:
7641 fprintf (file
, _("incr_linum(b): +%u\n"), val
);
7645 case DST__K_INCR_LINUM_W
:
7648 val
= bfd_getl16 (buf
);
7649 fprintf (file
, _("incr_linum_w: +%u\n"), val
);
7653 case DST__K_INCR_LINUM_L
:
7656 val
= bfd_getl32 (buf
);
7657 fprintf (file
, _("incr_linum_l: +%u\n"), val
);
7661 case DST__K_SET_LINUM
:
7664 line
= bfd_getl16 (buf
);
7665 fprintf (file
, _("set_line_num(w) %u\n"), line
);
7668 case DST__K_SET_LINUM_B
:
7672 fprintf (file
, _("set_line_num_b %u\n"), line
);
7675 case DST__K_SET_LINUM_L
:
7678 line
= bfd_getl32 (buf
);
7679 fprintf (file
, _("set_line_num_l %u\n"), line
);
7682 case DST__K_SET_ABS_PC
:
7685 pc
= bfd_getl32 (buf
);
7686 fprintf (file
, _("set_abs_pc: 0x%08x\n"), pc
);
7689 case DST__K_DELTA_PC_L
:
7692 fprintf (file
, _("delta_pc_l: +0x%08x\n"),
7693 (unsigned) bfd_getl32 (buf
));
7699 fprintf (file
, _("term(b): 0x%02x"), *buf
);
7701 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7707 val
= bfd_getl16 (buf
);
7708 fprintf (file
, _("term_w: 0x%04x"), val
);
7710 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7716 fprintf (file
, _("delta pc +%-4d"), -cmd
);
7717 line
++; /* FIXME: curr increment. */
7719 /* xgettext:c-format */
7720 fprintf (file
, _(" pc: 0x%08x line: %5u\n"),
7725 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7738 unsigned char *buf_orig
= buf
;
7740 fprintf (file
, _("source (len: %u)\n"), len
);
7750 case DST__K_SRC_DECLFILE
:
7752 struct vms_dst_src_decl_src
*src
= (void *) buf
;
7756 if (len
< sizeof (*src
))
7758 /* xgettext:c-format */
7759 fprintf (file
, _(" declfile: len: %u, flags: %u, "
7761 src
->length
, src
->flags
,
7762 (unsigned)bfd_getl16 (src
->fileid
));
7763 /* xgettext:c-format */
7764 fprintf (file
, _(" rms: cdt: 0x%08x %08x, "
7765 "ebk: 0x%08x, ffb: 0x%04x, "
7767 (unsigned)bfd_getl32 (src
->rms_cdt
+ 4),
7768 (unsigned)bfd_getl32 (src
->rms_cdt
+ 0),
7769 (unsigned)bfd_getl32 (src
->rms_ebk
),
7770 (unsigned)bfd_getl16 (src
->rms_ffb
),
7772 if (src
->length
> len
|| src
->length
<= sizeof (*src
))
7774 nlen
= src
->length
- sizeof (*src
) - 1;
7775 name
= (const char *) buf
+ sizeof (*src
);
7776 fprintf (file
, _(" filename : %.*s\n"),
7777 name
[0] > nlen
? nlen
: name
[0], name
+ 1);
7778 if (name
[0] >= nlen
)
7780 nlen
-= name
[0] + 1;
7781 name
+= name
[0] + 1;
7782 fprintf (file
, _(" module name: %.*s\n"),
7783 name
[0] > nlen
? nlen
: name
[0], name
+ 1);
7786 cmdlen
= src
->length
;
7789 case DST__K_SRC_SETFILE
:
7792 fprintf (file
, _(" setfile %u\n"),
7793 (unsigned) bfd_getl16 (buf
));
7796 case DST__K_SRC_SETREC_W
:
7799 fprintf (file
, _(" setrec %u\n"),
7800 (unsigned) bfd_getl16 (buf
));
7803 case DST__K_SRC_SETREC_L
:
7806 fprintf (file
, _(" setrec %u\n"),
7807 (unsigned) bfd_getl32 (buf
));
7810 case DST__K_SRC_SETLNUM_W
:
7813 fprintf (file
, _(" setlnum %u\n"),
7814 (unsigned) bfd_getl16 (buf
));
7817 case DST__K_SRC_SETLNUM_L
:
7820 fprintf (file
, _(" setlnum %u\n"),
7821 (unsigned) bfd_getl32 (buf
));
7824 case DST__K_SRC_DEFLINES_W
:
7827 fprintf (file
, _(" deflines %u\n"),
7828 (unsigned) bfd_getl16 (buf
));
7831 case DST__K_SRC_DEFLINES_B
:
7834 fprintf (file
, _(" deflines %u\n"), *buf
);
7837 case DST__K_SRC_FORMFEED
:
7838 fprintf (file
, _(" formfeed\n"));
7842 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7854 fprintf (file
, _("*unhandled* dst type %u\n"), type
);
7862 evax_bfd_print_image (bfd
*abfd
, FILE *file
)
7864 struct vms_eihd eihd
;
7867 unsigned int eiha_off
;
7868 unsigned int eihi_off
;
7869 unsigned int eihs_off
;
7870 unsigned int eisd_off
;
7871 unsigned int eihef_off
= 0;
7872 unsigned int eihnp_off
= 0;
7873 unsigned int dmt_vbn
= 0;
7874 unsigned int dmt_size
= 0;
7875 unsigned int dst_vbn
= 0;
7876 unsigned int dst_size
= 0;
7877 unsigned int gst_vbn
= 0;
7878 unsigned int gst_size
= 0;
7879 unsigned int eiaf_vbn
= 0;
7880 unsigned int eiaf_size
= 0;
7881 unsigned int eihvn_off
;
7883 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
)
7884 || bfd_bread (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
7886 fprintf (file
, _("cannot read EIHD\n"));
7889 /* xgettext:c-format */
7890 fprintf (file
, _("EIHD: (size: %u, nbr blocks: %u)\n"),
7891 (unsigned)bfd_getl32 (eihd
.size
),
7892 (unsigned)bfd_getl32 (eihd
.hdrblkcnt
));
7893 /* xgettext:c-format */
7894 fprintf (file
, _(" majorid: %u, minorid: %u\n"),
7895 (unsigned)bfd_getl32 (eihd
.majorid
),
7896 (unsigned)bfd_getl32 (eihd
.minorid
));
7898 val
= (unsigned)bfd_getl32 (eihd
.imgtype
);
7902 name
= _("executable");
7905 name
= _("linkable image");
7908 name
= _("unknown");
7911 /* xgettext:c-format */
7912 fprintf (file
, _(" image type: %u (%s)"), val
, name
);
7914 val
= (unsigned)bfd_getl32 (eihd
.subtype
);
7917 case EIHD__C_NATIVE
:
7924 name
= _("unknown");
7927 /* xgettext:c-format */
7928 fprintf (file
, _(", subtype: %u (%s)\n"), val
, name
);
7930 eisd_off
= bfd_getl32 (eihd
.isdoff
);
7931 eiha_off
= bfd_getl32 (eihd
.activoff
);
7932 eihi_off
= bfd_getl32 (eihd
.imgidoff
);
7933 eihs_off
= bfd_getl32 (eihd
.symdbgoff
);
7934 /* xgettext:c-format */
7935 fprintf (file
, _(" offsets: isd: %u, activ: %u, symdbg: %u, "
7936 "imgid: %u, patch: %u\n"),
7937 eisd_off
, eiha_off
, eihs_off
, eihi_off
,
7938 (unsigned)bfd_getl32 (eihd
.patchoff
));
7939 fprintf (file
, _(" fixup info rva: "));
7940 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.iafva
));
7941 fprintf (file
, _(", symbol vector rva: "));
7942 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.symvva
));
7943 eihvn_off
= bfd_getl32 (eihd
.version_array_off
);
7944 fprintf (file
, _("\n"
7945 " version array off: %u\n"),
7948 /* xgettext:c-format */
7949 _(" img I/O count: %u, nbr channels: %u, req pri: %08x%08x\n"),
7950 (unsigned)bfd_getl32 (eihd
.imgiocnt
),
7951 (unsigned)bfd_getl32 (eihd
.iochancnt
),
7952 (unsigned)bfd_getl32 (eihd
.privreqs
+ 4),
7953 (unsigned)bfd_getl32 (eihd
.privreqs
+ 0));
7954 val
= (unsigned)bfd_getl32 (eihd
.lnkflags
);
7955 fprintf (file
, _(" linker flags: %08x:"), val
);
7956 if (val
& EIHD__M_LNKDEBUG
)
7957 fprintf (file
, " LNKDEBUG");
7958 if (val
& EIHD__M_LNKNOTFR
)
7959 fprintf (file
, " LNKNOTFR");
7960 if (val
& EIHD__M_NOP0BUFS
)
7961 fprintf (file
, " NOP0BUFS");
7962 if (val
& EIHD__M_PICIMG
)
7963 fprintf (file
, " PICIMG");
7964 if (val
& EIHD__M_P0IMAGE
)
7965 fprintf (file
, " P0IMAGE");
7966 if (val
& EIHD__M_DBGDMT
)
7967 fprintf (file
, " DBGDMT");
7968 if (val
& EIHD__M_INISHR
)
7969 fprintf (file
, " INISHR");
7970 if (val
& EIHD__M_XLATED
)
7971 fprintf (file
, " XLATED");
7972 if (val
& EIHD__M_BIND_CODE_SEC
)
7973 fprintf (file
, " BIND_CODE_SEC");
7974 if (val
& EIHD__M_BIND_DATA_SEC
)
7975 fprintf (file
, " BIND_DATA_SEC");
7976 if (val
& EIHD__M_MKTHREADS
)
7977 fprintf (file
, " MKTHREADS");
7978 if (val
& EIHD__M_UPCALLS
)
7979 fprintf (file
, " UPCALLS");
7980 if (val
& EIHD__M_OMV_READY
)
7981 fprintf (file
, " OMV_READY");
7982 if (val
& EIHD__M_EXT_BIND_SECT
)
7983 fprintf (file
, " EXT_BIND_SECT");
7984 fprintf (file
, "\n");
7985 /* xgettext:c-format */
7986 fprintf (file
, _(" ident: 0x%08x, sysver: 0x%08x, "
7987 "match ctrl: %u, symvect_size: %u\n"),
7988 (unsigned)bfd_getl32 (eihd
.ident
),
7989 (unsigned)bfd_getl32 (eihd
.sysver
),
7991 (unsigned)bfd_getl32 (eihd
.symvect_size
));
7992 fprintf (file
, _(" BPAGE: %u"),
7993 (unsigned)bfd_getl32 (eihd
.virt_mem_block_size
));
7994 if (val
& (EIHD__M_OMV_READY
| EIHD__M_EXT_BIND_SECT
))
7996 eihef_off
= bfd_getl32 (eihd
.ext_fixup_off
);
7997 eihnp_off
= bfd_getl32 (eihd
.noopt_psect_off
);
7998 /* xgettext:c-format */
7999 fprintf (file
, _(", ext fixup offset: %u, no_opt psect off: %u"),
8000 eihef_off
, eihnp_off
);
8002 fprintf (file
, _(", alias: %u\n"), (unsigned)bfd_getl16 (eihd
.alias
));
8006 struct vms_eihvn eihvn
;
8010 fprintf (file
, _("system version array information:\n"));
8011 if (bfd_seek (abfd
, (file_ptr
) eihvn_off
, SEEK_SET
)
8012 || bfd_bread (&eihvn
, sizeof (eihvn
), abfd
) != sizeof (eihvn
))
8014 fprintf (file
, _("cannot read EIHVN header\n"));
8017 mask
= bfd_getl32 (eihvn
.subsystem_mask
);
8018 for (j
= 0; j
< 32; j
++)
8019 if (mask
& (1u << j
))
8021 struct vms_eihvn_subversion ver
;
8022 if (bfd_bread (&ver
, sizeof (ver
), abfd
) != sizeof (ver
))
8024 fprintf (file
, _("cannot read EIHVN version\n"));
8027 fprintf (file
, _(" %02u "), j
);
8030 case EIHVN__BASE_IMAGE_BIT
:
8031 fputs (_("BASE_IMAGE "), file
);
8033 case EIHVN__MEMORY_MANAGEMENT_BIT
:
8034 fputs (_("MEMORY_MANAGEMENT"), file
);
8037 fputs (_("IO "), file
);
8039 case EIHVN__FILES_VOLUMES_BIT
:
8040 fputs (_("FILES_VOLUMES "), file
);
8042 case EIHVN__PROCESS_SCHED_BIT
:
8043 fputs (_("PROCESS_SCHED "), file
);
8045 case EIHVN__SYSGEN_BIT
:
8046 fputs (_("SYSGEN "), file
);
8048 case EIHVN__CLUSTERS_LOCKMGR_BIT
:
8049 fputs (_("CLUSTERS_LOCKMGR "), file
);
8051 case EIHVN__LOGICAL_NAMES_BIT
:
8052 fputs (_("LOGICAL_NAMES "), file
);
8054 case EIHVN__SECURITY_BIT
:
8055 fputs (_("SECURITY "), file
);
8057 case EIHVN__IMAGE_ACTIVATOR_BIT
:
8058 fputs (_("IMAGE_ACTIVATOR "), file
);
8060 case EIHVN__NETWORKS_BIT
:
8061 fputs (_("NETWORKS "), file
);
8063 case EIHVN__COUNTERS_BIT
:
8064 fputs (_("COUNTERS "), file
);
8066 case EIHVN__STABLE_BIT
:
8067 fputs (_("STABLE "), file
);
8069 case EIHVN__MISC_BIT
:
8070 fputs (_("MISC "), file
);
8072 case EIHVN__CPU_BIT
:
8073 fputs (_("CPU "), file
);
8075 case EIHVN__VOLATILE_BIT
:
8076 fputs (_("VOLATILE "), file
);
8078 case EIHVN__SHELL_BIT
:
8079 fputs (_("SHELL "), file
);
8081 case EIHVN__POSIX_BIT
:
8082 fputs (_("POSIX "), file
);
8084 case EIHVN__MULTI_PROCESSING_BIT
:
8085 fputs (_("MULTI_PROCESSING "), file
);
8087 case EIHVN__GALAXY_BIT
:
8088 fputs (_("GALAXY "), file
);
8091 fputs (_("*unknown* "), file
);
8094 fprintf (file
, ": %u.%u\n",
8095 (unsigned)bfd_getl16 (ver
.major
),
8096 (unsigned)bfd_getl16 (ver
.minor
));
8102 struct vms_eiha eiha
;
8104 if (bfd_seek (abfd
, (file_ptr
) eiha_off
, SEEK_SET
)
8105 || bfd_bread (&eiha
, sizeof (eiha
), abfd
) != sizeof (eiha
))
8107 fprintf (file
, _("cannot read EIHA\n"));
8110 fprintf (file
, _("Image activation: (size=%u)\n"),
8111 (unsigned)bfd_getl32 (eiha
.size
));
8112 /* xgettext:c-format */
8113 fprintf (file
, _(" First address : 0x%08x 0x%08x\n"),
8114 (unsigned)bfd_getl32 (eiha
.tfradr1_h
),
8115 (unsigned)bfd_getl32 (eiha
.tfradr1
));
8116 /* xgettext:c-format */
8117 fprintf (file
, _(" Second address: 0x%08x 0x%08x\n"),
8118 (unsigned)bfd_getl32 (eiha
.tfradr2_h
),
8119 (unsigned)bfd_getl32 (eiha
.tfradr2
));
8120 /* xgettext:c-format */
8121 fprintf (file
, _(" Third address : 0x%08x 0x%08x\n"),
8122 (unsigned)bfd_getl32 (eiha
.tfradr3_h
),
8123 (unsigned)bfd_getl32 (eiha
.tfradr3
));
8124 /* xgettext:c-format */
8125 fprintf (file
, _(" Fourth address: 0x%08x 0x%08x\n"),
8126 (unsigned)bfd_getl32 (eiha
.tfradr4_h
),
8127 (unsigned)bfd_getl32 (eiha
.tfradr4
));
8128 /* xgettext:c-format */
8129 fprintf (file
, _(" Shared image : 0x%08x 0x%08x\n"),
8130 (unsigned)bfd_getl32 (eiha
.inishr_h
),
8131 (unsigned)bfd_getl32 (eiha
.inishr
));
8135 struct vms_eihi eihi
;
8137 if (bfd_seek (abfd
, (file_ptr
) eihi_off
, SEEK_SET
)
8138 || bfd_bread (&eihi
, sizeof (eihi
), abfd
) != sizeof (eihi
))
8140 fprintf (file
, _("cannot read EIHI\n"));
8143 /* xgettext:c-format */
8144 fprintf (file
, _("Image identification: (major: %u, minor: %u)\n"),
8145 (unsigned)bfd_getl32 (eihi
.majorid
),
8146 (unsigned)bfd_getl32 (eihi
.minorid
));
8147 fprintf (file
, _(" image name : %.*s\n"),
8148 eihi
.imgnam
[0], eihi
.imgnam
+ 1);
8149 fprintf (file
, _(" link time : %s\n"),
8150 vms_time_to_str (eihi
.linktime
));
8151 fprintf (file
, _(" image ident : %.*s\n"),
8152 eihi
.imgid
[0], eihi
.imgid
+ 1);
8153 fprintf (file
, _(" linker ident : %.*s\n"),
8154 eihi
.linkid
[0], eihi
.linkid
+ 1);
8155 fprintf (file
, _(" image build ident: %.*s\n"),
8156 eihi
.imgbid
[0], eihi
.imgbid
+ 1);
8160 struct vms_eihs eihs
;
8162 if (bfd_seek (abfd
, (file_ptr
) eihs_off
, SEEK_SET
)
8163 || bfd_bread (&eihs
, sizeof (eihs
), abfd
) != sizeof (eihs
))
8165 fprintf (file
, _("cannot read EIHS\n"));
8168 /* xgettext:c-format */
8169 fprintf (file
, _("Image symbol & debug table: (major: %u, minor: %u)\n"),
8170 (unsigned)bfd_getl32 (eihs
.majorid
),
8171 (unsigned)bfd_getl32 (eihs
.minorid
));
8172 dst_vbn
= bfd_getl32 (eihs
.dstvbn
);
8173 dst_size
= bfd_getl32 (eihs
.dstsize
);
8174 /* xgettext:c-format */
8175 fprintf (file
, _(" debug symbol table : vbn: %u, size: %u (0x%x)\n"),
8176 dst_vbn
, dst_size
, dst_size
);
8177 gst_vbn
= bfd_getl32 (eihs
.gstvbn
);
8178 gst_size
= bfd_getl32 (eihs
.gstsize
);
8179 /* xgettext:c-format */
8180 fprintf (file
, _(" global symbol table: vbn: %u, records: %u\n"),
8182 dmt_vbn
= bfd_getl32 (eihs
.dmtvbn
);
8183 dmt_size
= bfd_getl32 (eihs
.dmtsize
);
8184 /* xgettext:c-format */
8185 fprintf (file
, _(" debug module table : vbn: %u, size: %u\n"),
8188 while (eisd_off
!= 0)
8190 struct vms_eisd eisd
;
8195 if (bfd_seek (abfd
, (file_ptr
) eisd_off
, SEEK_SET
)
8196 || bfd_bread (&eisd
, sizeof (eisd
), abfd
) != sizeof (eisd
))
8198 fprintf (file
, _("cannot read EISD\n"));
8201 len
= (unsigned)bfd_getl32 (eisd
.eisdsize
);
8202 if (len
!= (unsigned)-1)
8206 eisd_off
= (eisd_off
+ VMS_BLOCK_SIZE
) & ~(VMS_BLOCK_SIZE
- 1);
8208 /* xgettext:c-format */
8209 fprintf (file
, _("Image section descriptor: (major: %u, minor: %u, "
8210 "size: %u, offset: %u)\n"),
8211 (unsigned)bfd_getl32 (eisd
.majorid
),
8212 (unsigned)bfd_getl32 (eisd
.minorid
),
8216 /* xgettext:c-format */
8217 fprintf (file
, _(" section: base: 0x%08x%08x size: 0x%08x\n"),
8218 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 4),
8219 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 0),
8220 (unsigned)bfd_getl32 (eisd
.secsize
));
8221 val
= (unsigned)bfd_getl32 (eisd
.flags
);
8222 fprintf (file
, _(" flags: 0x%04x"), val
);
8223 if (val
& EISD__M_GBL
)
8224 fprintf (file
, " GBL");
8225 if (val
& EISD__M_CRF
)
8226 fprintf (file
, " CRF");
8227 if (val
& EISD__M_DZRO
)
8228 fprintf (file
, " DZRO");
8229 if (val
& EISD__M_WRT
)
8230 fprintf (file
, " WRT");
8231 if (val
& EISD__M_INITALCODE
)
8232 fprintf (file
, " INITALCODE");
8233 if (val
& EISD__M_BASED
)
8234 fprintf (file
, " BASED");
8235 if (val
& EISD__M_FIXUPVEC
)
8236 fprintf (file
, " FIXUPVEC");
8237 if (val
& EISD__M_RESIDENT
)
8238 fprintf (file
, " RESIDENT");
8239 if (val
& EISD__M_VECTOR
)
8240 fprintf (file
, " VECTOR");
8241 if (val
& EISD__M_PROTECT
)
8242 fprintf (file
, " PROTECT");
8243 if (val
& EISD__M_LASTCLU
)
8244 fprintf (file
, " LASTCLU");
8245 if (val
& EISD__M_EXE
)
8246 fprintf (file
, " EXE");
8247 if (val
& EISD__M_NONSHRADR
)
8248 fprintf (file
, " NONSHRADR");
8249 if (val
& EISD__M_QUAD_LENGTH
)
8250 fprintf (file
, " QUAD_LENGTH");
8251 if (val
& EISD__M_ALLOC_64BIT
)
8252 fprintf (file
, " ALLOC_64BIT");
8253 fprintf (file
, "\n");
8254 if (val
& EISD__M_FIXUPVEC
)
8256 eiaf_vbn
= bfd_getl32 (eisd
.vbn
);
8257 eiaf_size
= bfd_getl32 (eisd
.secsize
);
8259 /* xgettext:c-format */
8260 fprintf (file
, _(" vbn: %u, pfc: %u, matchctl: %u type: %u ("),
8261 (unsigned)bfd_getl32 (eisd
.vbn
),
8262 eisd
.pfc
, eisd
.matchctl
, eisd
.type
);
8265 case EISD__K_NORMAL
:
8266 fputs (_("NORMAL"), file
);
8268 case EISD__K_SHRFXD
:
8269 fputs (_("SHRFXD"), file
);
8271 case EISD__K_PRVFXD
:
8272 fputs (_("PRVFXD"), file
);
8274 case EISD__K_SHRPIC
:
8275 fputs (_("SHRPIC"), file
);
8277 case EISD__K_PRVPIC
:
8278 fputs (_("PRVPIC"), file
);
8280 case EISD__K_USRSTACK
:
8281 fputs (_("USRSTACK"), file
);
8284 fputs (_("*unknown*"), file
);
8287 fputs (_(")\n"), file
);
8288 if (val
& EISD__M_GBL
)
8289 /* xgettext:c-format */
8290 fprintf (file
, _(" ident: 0x%08x, name: %.*s\n"),
8291 (unsigned)bfd_getl32 (eisd
.ident
),
8292 eisd
.gblnam
[0], eisd
.gblnam
+ 1);
8298 if (bfd_seek (abfd
, (file_ptr
) (dmt_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
8300 fprintf (file
, _("cannot read DMT\n"));
8304 fprintf (file
, _("Debug module table:\n"));
8306 while (dmt_size
> 0)
8308 struct vms_dmt_header dmth
;
8311 if (bfd_bread (&dmth
, sizeof (dmth
), abfd
) != sizeof (dmth
))
8313 fprintf (file
, _("cannot read DMT header\n"));
8316 count
= bfd_getl16 (dmth
.psect_count
);
8318 /* xgettext:c-format */
8319 _(" module offset: 0x%08x, size: 0x%08x, (%u psects)\n"),
8320 (unsigned)bfd_getl32 (dmth
.modbeg
),
8321 (unsigned)bfd_getl32 (dmth
.size
), count
);
8322 dmt_size
-= sizeof (dmth
);
8325 struct vms_dmt_psect dmtp
;
8327 if (bfd_bread (&dmtp
, sizeof (dmtp
), abfd
) != sizeof (dmtp
))
8329 fprintf (file
, _("cannot read DMT psect\n"));
8332 /* xgettext:c-format */
8333 fprintf (file
, _(" psect start: 0x%08x, length: %u\n"),
8334 (unsigned)bfd_getl32 (dmtp
.start
),
8335 (unsigned)bfd_getl32 (dmtp
.length
));
8337 dmt_size
-= sizeof (dmtp
);
8344 if (bfd_seek (abfd
, (file_ptr
) (dst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
8346 fprintf (file
, _("cannot read DST\n"));
8350 evax_bfd_print_dst (abfd
, dst_size
, file
);
8354 if (bfd_seek (abfd
, (file_ptr
) (gst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
8356 fprintf (file
, _("cannot read GST\n"));
8360 fprintf (file
, _("Global symbol table:\n"));
8361 evax_bfd_print_eobj (abfd
, file
);
8363 if (eiaf_vbn
!= 0 && eiaf_size
>= sizeof (struct vms_eiaf
))
8366 struct vms_eiaf
*eiaf
;
8367 unsigned int qrelfixoff
;
8368 unsigned int lrelfixoff
;
8369 unsigned int qdotadroff
;
8370 unsigned int ldotadroff
;
8371 unsigned int shrimgcnt
;
8372 unsigned int shlstoff
;
8373 unsigned int codeadroff
;
8374 unsigned int lpfixoff
;
8375 unsigned int chgprtoff
;
8376 file_ptr f_off
= (file_ptr
) (eiaf_vbn
- 1) * VMS_BLOCK_SIZE
;
8378 if (bfd_seek (abfd
, f_off
, SEEK_SET
) != 0
8379 || (buf
= _bfd_malloc_and_read (abfd
, eiaf_size
, eiaf_size
)) == NULL
)
8381 fprintf (file
, _("cannot read EIHA\n"));
8384 eiaf
= (struct vms_eiaf
*)buf
;
8386 /* xgettext:c-format */
8387 _("Image activator fixup: (major: %u, minor: %u)\n"),
8388 (unsigned)bfd_getl32 (eiaf
->majorid
),
8389 (unsigned)bfd_getl32 (eiaf
->minorid
));
8390 /* xgettext:c-format */
8391 fprintf (file
, _(" iaflink : 0x%08x %08x\n"),
8392 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 0),
8393 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 4));
8394 /* xgettext:c-format */
8395 fprintf (file
, _(" fixuplnk: 0x%08x %08x\n"),
8396 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 0),
8397 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 4));
8398 fprintf (file
, _(" size : %u\n"),
8399 (unsigned)bfd_getl32 (eiaf
->size
));
8400 fprintf (file
, _(" flags: 0x%08x\n"),
8401 (unsigned)bfd_getl32 (eiaf
->flags
));
8402 qrelfixoff
= bfd_getl32 (eiaf
->qrelfixoff
);
8403 lrelfixoff
= bfd_getl32 (eiaf
->lrelfixoff
);
8404 /* xgettext:c-format */
8405 fprintf (file
, _(" qrelfixoff: %5u, lrelfixoff: %5u\n"),
8406 qrelfixoff
, lrelfixoff
);
8407 qdotadroff
= bfd_getl32 (eiaf
->qdotadroff
);
8408 ldotadroff
= bfd_getl32 (eiaf
->ldotadroff
);
8409 /* xgettext:c-format */
8410 fprintf (file
, _(" qdotadroff: %5u, ldotadroff: %5u\n"),
8411 qdotadroff
, ldotadroff
);
8412 codeadroff
= bfd_getl32 (eiaf
->codeadroff
);
8413 lpfixoff
= bfd_getl32 (eiaf
->lpfixoff
);
8414 /* xgettext:c-format */
8415 fprintf (file
, _(" codeadroff: %5u, lpfixoff : %5u\n"),
8416 codeadroff
, lpfixoff
);
8417 chgprtoff
= bfd_getl32 (eiaf
->chgprtoff
);
8418 fprintf (file
, _(" chgprtoff : %5u\n"), chgprtoff
);
8419 shrimgcnt
= bfd_getl32 (eiaf
->shrimgcnt
);
8420 shlstoff
= bfd_getl32 (eiaf
->shlstoff
);
8421 /* xgettext:c-format */
8422 fprintf (file
, _(" shlstoff : %5u, shrimgcnt : %5u\n"),
8423 shlstoff
, shrimgcnt
);
8424 /* xgettext:c-format */
8425 fprintf (file
, _(" shlextra : %5u, permctx : %5u\n"),
8426 (unsigned)bfd_getl32 (eiaf
->shlextra
),
8427 (unsigned)bfd_getl32 (eiaf
->permctx
));
8428 fprintf (file
, _(" base_va : 0x%08x\n"),
8429 (unsigned)bfd_getl32 (eiaf
->base_va
));
8430 fprintf (file
, _(" lppsbfixoff: %5u\n"),
8431 (unsigned)bfd_getl32 (eiaf
->lppsbfixoff
));
8437 fprintf (file
, _(" Shareable images:\n"));
8439 j
< shrimgcnt
&& shlstoff
<= eiaf_size
- sizeof (struct vms_shl
);
8440 j
++, shlstoff
+= sizeof (struct vms_shl
))
8442 struct vms_shl
*shl
= (struct vms_shl
*) (buf
+ shlstoff
);
8444 /* xgettext:c-format */
8445 _(" %u: size: %u, flags: 0x%02x, name: %.*s\n"),
8446 j
, shl
->size
, shl
->flags
,
8447 shl
->imgnam
[0], shl
->imgnam
+ 1);
8450 if (qrelfixoff
!= 0)
8452 fprintf (file
, _(" quad-word relocation fixups:\n"));
8453 evax_bfd_print_relocation_records (file
, buf
, eiaf_size
,
8456 if (lrelfixoff
!= 0)
8458 fprintf (file
, _(" long-word relocation fixups:\n"));
8459 evax_bfd_print_relocation_records (file
, buf
, eiaf_size
,
8462 if (qdotadroff
!= 0)
8464 fprintf (file
, _(" quad-word .address reference fixups:\n"));
8465 evax_bfd_print_address_fixups (file
, buf
, eiaf_size
, qdotadroff
);
8467 if (ldotadroff
!= 0)
8469 fprintf (file
, _(" long-word .address reference fixups:\n"));
8470 evax_bfd_print_address_fixups (file
, buf
, eiaf_size
, ldotadroff
);
8472 if (codeadroff
!= 0)
8474 fprintf (file
, _(" Code Address Reference Fixups:\n"));
8475 evax_bfd_print_reference_fixups (file
, buf
, eiaf_size
, codeadroff
);
8479 fprintf (file
, _(" Linkage Pairs Reference Fixups:\n"));
8480 evax_bfd_print_reference_fixups (file
, buf
, eiaf_size
, lpfixoff
);
8482 if (chgprtoff
&& chgprtoff
<= eiaf_size
- 4)
8484 unsigned int count
= (unsigned) bfd_getl32 (buf
+ chgprtoff
);
8487 fprintf (file
, _(" Change Protection (%u entries):\n"), count
);
8488 for (j
= 0, chgprtoff
+= 4;
8489 j
< count
&& chgprtoff
<= eiaf_size
- sizeof (struct vms_eicp
);
8490 j
++, chgprtoff
+= sizeof (struct vms_eicp
))
8492 struct vms_eicp
*eicp
= (struct vms_eicp
*) (buf
+ chgprtoff
);
8493 unsigned int prot
= bfd_getl32 (eicp
->newprt
);
8495 /* xgettext:c-format */
8496 _(" base: 0x%08x %08x, size: 0x%08x, prot: 0x%08x "),
8497 (unsigned) bfd_getl32 (eicp
->baseva
+ 4),
8498 (unsigned) bfd_getl32 (eicp
->baseva
+ 0),
8499 (unsigned) bfd_getl32 (eicp
->size
),
8500 (unsigned) bfd_getl32 (eicp
->newprt
));
8504 fprintf (file
, "NA");
8506 case PRT__C_RESERVED
:
8507 fprintf (file
, "RES");
8510 fprintf (file
, "KW");
8513 fprintf (file
, "KR");
8516 fprintf (file
, "UW");
8519 fprintf (file
, "EW");
8522 fprintf (file
, "ERKW");
8525 fprintf (file
, "ER");
8528 fprintf (file
, "SW");
8531 fprintf (file
, "SREW");
8534 fprintf (file
, "SRKW");
8537 fprintf (file
, "SR");
8540 fprintf (file
, "URSW");
8543 fprintf (file
, "UREW");
8546 fprintf (file
, "URKW");
8549 fprintf (file
, "UR");
8563 vms_bfd_print_private_bfd_data (bfd
*abfd
, void *ptr
)
8565 FILE *file
= (FILE *)ptr
;
8567 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
8568 evax_bfd_print_image (abfd
, file
);
8571 if (bfd_seek (abfd
, 0, SEEK_SET
))
8573 evax_bfd_print_eobj (abfd
, file
);
8580 /* Slurp ETIR/EDBG/ETBT VMS object records. */
8583 alpha_vms_read_sections_content (bfd
*abfd
, struct bfd_link_info
*info
)
8585 asection
*cur_section
;
8586 file_ptr cur_offset
;
8587 asection
*dst_section
;
8588 file_ptr dst_offset
;
8590 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
8596 dst_section
= PRIV (dst_section
);
8600 if (info
->strip
== strip_all
|| info
->strip
== strip_debugger
)
8602 /* Discard the DST section. */
8606 else if (dst_section
)
8608 dst_offset
= dst_section
->output_offset
;
8609 dst_section
= dst_section
->output_section
;
8618 type
= _bfd_vms_get_object_record (abfd
);
8621 vms_debug2 ((2, "next_record failed\n"));
8627 PRIV (image_section
) = cur_section
;
8628 PRIV (image_offset
) = cur_offset
;
8629 res
= _bfd_vms_slurp_etir (abfd
, info
);
8630 cur_section
= PRIV (image_section
);
8631 cur_offset
= PRIV (image_offset
);
8635 if (dst_section
== NULL
)
8637 PRIV (image_section
) = dst_section
;
8638 PRIV (image_offset
) = dst_offset
;
8639 res
= _bfd_vms_slurp_etir (abfd
, info
);
8640 dst_offset
= PRIV (image_offset
);
8649 vms_debug2 ((2, "slurp eobj type %d failed\n", type
));
8656 alpha_vms_sizeof_headers (bfd
*abfd ATTRIBUTE_UNUSED
,
8657 struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8662 /* Add a linkage pair fixup at address SECT + OFFSET to SHLIB. */
8665 alpha_vms_add_fixup_lp (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
8667 struct alpha_vms_shlib_el
*sl
;
8668 asection
*sect
= PRIV2 (src
, image_section
);
8669 file_ptr offset
= PRIV2 (src
, image_offset
);
8672 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8673 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8674 sl
->has_fixups
= true;
8675 p
= VEC_APPEND (sl
->lp
, bfd_vma
);
8678 *p
= sect
->output_section
->vma
+ sect
->output_offset
+ offset
;
8679 sect
->output_section
->flags
|= SEC_RELOC
;
8683 /* Add a code address fixup at address SECT + OFFSET to SHLIB. */
8686 alpha_vms_add_fixup_ca (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
8688 struct alpha_vms_shlib_el
*sl
;
8689 asection
*sect
= PRIV2 (src
, image_section
);
8690 file_ptr offset
= PRIV2 (src
, image_offset
);
8693 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8694 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8695 sl
->has_fixups
= true;
8696 p
= VEC_APPEND (sl
->ca
, bfd_vma
);
8699 *p
= sect
->output_section
->vma
+ sect
->output_offset
+ offset
;
8700 sect
->output_section
->flags
|= SEC_RELOC
;
8704 /* Add a quad word relocation fixup at address SECT + OFFSET to SHLIB. */
8707 alpha_vms_add_fixup_qr (struct bfd_link_info
*info
, bfd
*src
,
8708 bfd
*shlib
, bfd_vma vec
)
8710 struct alpha_vms_shlib_el
*sl
;
8711 struct alpha_vms_vma_ref
*r
;
8712 asection
*sect
= PRIV2 (src
, image_section
);
8713 file_ptr offset
= PRIV2 (src
, image_offset
);
8715 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8716 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8717 sl
->has_fixups
= true;
8718 r
= VEC_APPEND (sl
->qr
, struct alpha_vms_vma_ref
);
8721 r
->vma
= sect
->output_section
->vma
+ sect
->output_offset
+ offset
;
8723 sect
->output_section
->flags
|= SEC_RELOC
;
8728 alpha_vms_add_fixup_lr (struct bfd_link_info
*info ATTRIBUTE_UNUSED
,
8729 unsigned int shr ATTRIBUTE_UNUSED
,
8730 bfd_vma vec ATTRIBUTE_UNUSED
)
8732 /* Not yet supported. */
8736 /* Add relocation. FIXME: Not yet emitted. */
8739 alpha_vms_add_lw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8745 alpha_vms_add_qw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8750 static struct bfd_hash_entry
*
8751 alpha_vms_link_hash_newfunc (struct bfd_hash_entry
*entry
,
8752 struct bfd_hash_table
*table
,
8755 struct alpha_vms_link_hash_entry
*ret
=
8756 (struct alpha_vms_link_hash_entry
*) entry
;
8758 /* Allocate the structure if it has not already been allocated by a
8761 ret
= ((struct alpha_vms_link_hash_entry
*)
8762 bfd_hash_allocate (table
,
8763 sizeof (struct alpha_vms_link_hash_entry
)));
8767 /* Call the allocation method of the superclass. */
8768 ret
= ((struct alpha_vms_link_hash_entry
*)
8769 _bfd_link_hash_newfunc ((struct bfd_hash_entry
*) ret
,
8774 return (struct bfd_hash_entry
*) ret
;
8778 alpha_vms_bfd_link_hash_table_free (bfd
*abfd
)
8780 struct alpha_vms_link_hash_table
*t
;
8783 t
= (struct alpha_vms_link_hash_table
*) abfd
->link
.hash
;
8784 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8786 struct alpha_vms_shlib_el
*shlib
;
8788 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8789 free (&VEC_EL (shlib
->ca
, bfd_vma
, 0));
8790 free (&VEC_EL (shlib
->lp
, bfd_vma
, 0));
8791 free (&VEC_EL (shlib
->qr
, struct alpha_vms_vma_ref
, 0));
8793 free (&VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, 0));
8795 _bfd_generic_link_hash_table_free (abfd
);
8798 /* Create an Alpha/VMS link hash table. */
8800 static struct bfd_link_hash_table
*
8801 alpha_vms_bfd_link_hash_table_create (bfd
*abfd
)
8803 struct alpha_vms_link_hash_table
*ret
;
8804 size_t amt
= sizeof (struct alpha_vms_link_hash_table
);
8806 ret
= (struct alpha_vms_link_hash_table
*) bfd_malloc (amt
);
8809 if (!_bfd_link_hash_table_init (&ret
->root
, abfd
,
8810 alpha_vms_link_hash_newfunc
,
8811 sizeof (struct alpha_vms_link_hash_entry
)))
8817 VEC_INIT (ret
->shrlibs
);
8819 ret
->root
.hash_table_free
= alpha_vms_bfd_link_hash_table_free
;
8825 alpha_vms_link_add_object_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8829 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
8831 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
8832 struct alpha_vms_link_hash_entry
*h
;
8833 struct bfd_link_hash_entry
*h_root
;
8836 if (!alpha_vms_convert_symbol (abfd
, e
, &sym
))
8839 if ((e
->flags
& EGSY__V_DEF
) && abfd
->selective_search
)
8841 /* In selective_search mode, only add definition that are
8843 h
= (struct alpha_vms_link_hash_entry
*)bfd_link_hash_lookup
8844 (info
->hash
, sym
.name
, false, false, false);
8845 if (h
== NULL
|| h
->root
.type
!= bfd_link_hash_undefined
)
8851 h_root
= (struct bfd_link_hash_entry
*) h
;
8852 if (!_bfd_generic_link_add_one_symbol (info
, abfd
, sym
.name
, sym
.flags
,
8853 sym
.section
, sym
.value
, NULL
,
8854 false, false, &h_root
))
8856 h
= (struct alpha_vms_link_hash_entry
*) h_root
;
8858 if ((e
->flags
& EGSY__V_DEF
)
8860 && abfd
->xvec
== info
->output_bfd
->xvec
)
8864 if (abfd
->flags
& DYNAMIC
)
8866 struct alpha_vms_shlib_el
*shlib
;
8868 /* We do not want to include any of the sections in a dynamic
8869 object in the output file. See comment in elflink.c. */
8870 bfd_section_list_clear (abfd
);
8872 shlib
= VEC_APPEND (alpha_vms_link_hash (info
)->shrlibs
,
8873 struct alpha_vms_shlib_el
);
8877 VEC_INIT (shlib
->ca
);
8878 VEC_INIT (shlib
->lp
);
8879 VEC_INIT (shlib
->qr
);
8880 PRIV (shr_index
) = VEC_COUNT (alpha_vms_link_hash (info
)->shrlibs
) - 1;
8887 alpha_vms_link_add_archive_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8890 struct bfd_link_hash_entry
**pundef
;
8891 struct bfd_link_hash_entry
**next_pundef
;
8893 /* We only accept VMS libraries. */
8894 if (info
->output_bfd
->xvec
!= abfd
->xvec
)
8896 bfd_set_error (bfd_error_wrong_format
);
8900 /* The archive_pass field in the archive itself is used to
8901 initialize PASS, since we may search the same archive multiple
8903 pass
= ++abfd
->archive_pass
;
8905 /* Look through the list of undefined symbols. */
8906 for (pundef
= &info
->hash
->undefs
; *pundef
!= NULL
; pundef
= next_pundef
)
8908 struct bfd_link_hash_entry
*h
;
8914 next_pundef
= &(*pundef
)->u
.undef
.next
;
8916 /* When a symbol is defined, it is not necessarily removed from
8918 if (h
->type
!= bfd_link_hash_undefined
8919 && h
->type
!= bfd_link_hash_common
)
8921 /* Remove this entry from the list, for general cleanliness
8922 and because we are going to look through the list again
8923 if we search any more libraries. We can't remove the
8924 entry if it is the tail, because that would lose any
8925 entries we add to the list later on. */
8926 if (*pundef
!= info
->hash
->undefs_tail
)
8928 *pundef
= *next_pundef
;
8929 next_pundef
= pundef
;
8934 /* Look for this symbol in the archive hash table. */
8935 symidx
= _bfd_vms_lib_find_symbol (abfd
, h
->root
.string
);
8936 if (symidx
== BFD_NO_MORE_SYMBOLS
)
8938 /* Nothing in this slot. */
8942 element
= bfd_get_elt_at_index (abfd
, symidx
);
8943 if (element
== NULL
)
8946 if (element
->archive_pass
== -1 || element
->archive_pass
== pass
)
8948 /* Next symbol if this archive is wrong or already handled. */
8952 if (! bfd_check_format (element
, bfd_object
))
8954 element
->archive_pass
= -1;
8958 orig_element
= element
;
8959 if (bfd_is_thin_archive (abfd
))
8961 element
= _bfd_vms_lib_get_imagelib_file (element
);
8962 if (element
== NULL
|| !bfd_check_format (element
, bfd_object
))
8964 orig_element
->archive_pass
= -1;
8969 /* Unlike the generic linker, we know that this element provides
8970 a definition for an undefined symbol and we know that we want
8971 to include it. We don't need to check anything. */
8972 if (!(*info
->callbacks
8973 ->add_archive_element
) (info
, element
, h
->root
.string
, &element
))
8975 if (!alpha_vms_link_add_object_symbols (element
, info
))
8978 orig_element
->archive_pass
= pass
;
8985 alpha_vms_bfd_link_add_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8987 switch (bfd_get_format (abfd
))
8990 vms_debug2 ((2, "vms_link_add_symbols for object %s\n",
8992 return alpha_vms_link_add_object_symbols (abfd
, info
);
8995 vms_debug2 ((2, "vms_link_add_symbols for archive %s\n",
8997 return alpha_vms_link_add_archive_symbols (abfd
, info
);
9000 bfd_set_error (bfd_error_wrong_format
);
9006 alpha_vms_build_fixups (struct bfd_link_info
*info
)
9008 struct alpha_vms_link_hash_table
*t
= alpha_vms_link_hash (info
);
9009 unsigned char *content
;
9011 unsigned int sz
= 0;
9012 unsigned int lp_sz
= 0;
9013 unsigned int ca_sz
= 0;
9014 unsigned int qr_sz
= 0;
9015 unsigned int shrimg_cnt
= 0;
9016 unsigned int chgprt_num
= 0;
9017 unsigned int chgprt_sz
= 0;
9018 struct vms_eiaf
*eiaf
;
9022 /* Shared libraries. */
9023 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
9025 struct alpha_vms_shlib_el
*shlib
;
9027 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
9029 if (!shlib
->has_fixups
)
9034 if (VEC_COUNT (shlib
->ca
) > 0)
9036 /* Header + entries. */
9038 ca_sz
+= VEC_COUNT (shlib
->ca
) * 4;
9040 if (VEC_COUNT (shlib
->lp
) > 0)
9042 /* Header + entries. */
9044 lp_sz
+= VEC_COUNT (shlib
->lp
) * 4;
9046 if (VEC_COUNT (shlib
->qr
) > 0)
9048 /* Header + entries. */
9050 qr_sz
+= VEC_COUNT (shlib
->qr
) * 8;
9061 /* Finish now if there is no content. */
9062 if (ca_sz
+ lp_sz
+ qr_sz
== 0)
9065 /* Add an eicp entry for the fixup itself. */
9067 for (sec
= info
->output_bfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
9069 /* This isect could be made RO or EXE after relocations are applied. */
9070 if ((sec
->flags
& SEC_RELOC
) != 0
9071 && (sec
->flags
& (SEC_CODE
| SEC_READONLY
)) != 0)
9074 chgprt_sz
= 4 + chgprt_num
* sizeof (struct vms_eicp
);
9076 /* Allocate section content (round-up size) */
9077 sz
= sizeof (struct vms_eiaf
) + shrimg_cnt
* sizeof (struct vms_shl
)
9078 + ca_sz
+ lp_sz
+ qr_sz
+ chgprt_sz
;
9079 sz
= (sz
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
9080 content
= bfd_zalloc (info
->output_bfd
, sz
);
9081 if (content
== NULL
)
9084 sec
= alpha_vms_link_hash (info
)->fixup
;
9085 sec
->contents
= content
;
9088 eiaf
= (struct vms_eiaf
*)content
;
9089 off
= sizeof (struct vms_eiaf
);
9090 bfd_putl32 (0, eiaf
->majorid
);
9091 bfd_putl32 (0, eiaf
->minorid
);
9092 bfd_putl32 (0, eiaf
->iaflink
);
9093 bfd_putl32 (0, eiaf
->fixuplnk
);
9094 bfd_putl32 (sizeof (struct vms_eiaf
), eiaf
->size
);
9095 bfd_putl32 (0, eiaf
->flags
);
9096 bfd_putl32 (0, eiaf
->qrelfixoff
);
9097 bfd_putl32 (0, eiaf
->lrelfixoff
);
9098 bfd_putl32 (0, eiaf
->qdotadroff
);
9099 bfd_putl32 (0, eiaf
->ldotadroff
);
9100 bfd_putl32 (0, eiaf
->codeadroff
);
9101 bfd_putl32 (0, eiaf
->lpfixoff
);
9102 bfd_putl32 (0, eiaf
->chgprtoff
);
9103 bfd_putl32 (shrimg_cnt
? off
: 0, eiaf
->shlstoff
);
9104 bfd_putl32 (shrimg_cnt
, eiaf
->shrimgcnt
);
9105 bfd_putl32 (0, eiaf
->shlextra
);
9106 bfd_putl32 (0, eiaf
->permctx
);
9107 bfd_putl32 (0, eiaf
->base_va
);
9108 bfd_putl32 (0, eiaf
->lppsbfixoff
);
9115 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
9117 struct alpha_vms_shlib_el
*shlib
;
9118 struct vms_shl
*shl
;
9120 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
9122 if (!shlib
->has_fixups
)
9125 /* Renumber shared images. */
9126 PRIV2 (shlib
->abfd
, shr_index
) = shrimg_cnt
++;
9128 shl
= (struct vms_shl
*)(content
+ off
);
9129 bfd_putl32 (0, shl
->baseva
);
9130 bfd_putl32 (0, shl
->shlptr
);
9131 bfd_putl32 (0, shl
->ident
);
9132 bfd_putl32 (0, shl
->permctx
);
9133 shl
->size
= sizeof (struct vms_shl
);
9134 bfd_putl16 (0, shl
->fill_1
);
9136 bfd_putl32 (0, shl
->icb
);
9137 shl
->imgnam
[0] = strlen (PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
));
9138 memcpy (shl
->imgnam
+ 1, PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
),
9141 off
+= sizeof (struct vms_shl
);
9147 bfd_putl32 (off
, eiaf
->codeadroff
);
9149 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
9151 struct alpha_vms_shlib_el
*shlib
;
9154 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
9156 if (VEC_COUNT (shlib
->ca
) == 0)
9159 bfd_putl32 (VEC_COUNT (shlib
->ca
), content
+ off
);
9160 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
9163 for (j
= 0; j
< VEC_COUNT (shlib
->ca
); j
++)
9165 bfd_putl32 (VEC_EL (shlib
->ca
, bfd_vma
, j
) - t
->base_addr
,
9171 bfd_putl32 (0, content
+ off
);
9172 bfd_putl32 (0, content
+ off
+ 4);
9179 bfd_putl32 (off
, eiaf
->lpfixoff
);
9181 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
9183 struct alpha_vms_shlib_el
*shlib
;
9186 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
9188 if (VEC_COUNT (shlib
->lp
) == 0)
9191 bfd_putl32 (VEC_COUNT (shlib
->lp
), content
+ off
);
9192 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
9195 for (j
= 0; j
< VEC_COUNT (shlib
->lp
); j
++)
9197 bfd_putl32 (VEC_EL (shlib
->lp
, bfd_vma
, j
) - t
->base_addr
,
9203 bfd_putl32 (0, content
+ off
);
9204 bfd_putl32 (0, content
+ off
+ 4);
9211 bfd_putl32 (off
, eiaf
->qdotadroff
);
9213 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
9215 struct alpha_vms_shlib_el
*shlib
;
9218 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
9220 if (VEC_COUNT (shlib
->qr
) == 0)
9223 bfd_putl32 (VEC_COUNT (shlib
->qr
), content
+ off
);
9224 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
9227 for (j
= 0; j
< VEC_COUNT (shlib
->qr
); j
++)
9229 struct alpha_vms_vma_ref
*r
;
9230 r
= &VEC_EL (shlib
->qr
, struct alpha_vms_vma_ref
, j
);
9231 bfd_putl32 (r
->vma
- t
->base_addr
, content
+ off
);
9232 bfd_putl32 (r
->ref
, content
+ off
+ 4);
9237 bfd_putl32 (0, content
+ off
);
9238 bfd_putl32 (0, content
+ off
+ 4);
9243 /* Write the change protection table. */
9244 bfd_putl32 (off
, eiaf
->chgprtoff
);
9245 bfd_putl32 (chgprt_num
, content
+ off
);
9248 for (sec
= info
->output_bfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
9250 struct vms_eicp
*eicp
;
9253 if ((sec
->flags
& SEC_LINKER_CREATED
) != 0 &&
9254 strcmp (sec
->name
, "$FIXUP$") == 0)
9256 else if ((sec
->flags
& SEC_RELOC
) != 0
9257 && (sec
->flags
& (SEC_CODE
| SEC_READONLY
)) != 0)
9262 eicp
= (struct vms_eicp
*)(content
+ off
);
9263 bfd_putl64 (sec
->vma
- t
->base_addr
, eicp
->baseva
);
9264 bfd_putl32 ((sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1),
9266 bfd_putl32 (prot
, eicp
->newprt
);
9267 off
+= sizeof (struct vms_eicp
);
9273 /* Called by bfd_hash_traverse to fill the symbol table.
9274 Return FALSE in case of failure. */
9277 alpha_vms_link_output_symbol (struct bfd_hash_entry
*bh
, void *infov
)
9279 struct bfd_link_hash_entry
*hc
= (struct bfd_link_hash_entry
*) bh
;
9280 struct bfd_link_info
*info
= (struct bfd_link_info
*)infov
;
9281 struct alpha_vms_link_hash_entry
*h
;
9282 struct vms_symbol_entry
*sym
;
9284 if (hc
->type
== bfd_link_hash_warning
)
9287 if (hc
->type
== bfd_link_hash_new
)
9290 h
= (struct alpha_vms_link_hash_entry
*) hc
;
9292 switch (h
->root
.type
)
9294 case bfd_link_hash_undefined
:
9296 case bfd_link_hash_new
:
9297 case bfd_link_hash_warning
:
9299 case bfd_link_hash_undefweak
:
9301 case bfd_link_hash_defined
:
9302 case bfd_link_hash_defweak
:
9304 asection
*sec
= h
->root
.u
.def
.section
;
9306 /* FIXME: this is certainly a symbol from a dynamic library. */
9307 if (bfd_is_abs_section (sec
))
9310 if (sec
->owner
->flags
& DYNAMIC
)
9314 case bfd_link_hash_common
:
9316 case bfd_link_hash_indirect
:
9320 /* Do not write not kept symbols. */
9321 if (info
->strip
== strip_some
9322 && bfd_hash_lookup (info
->keep_hash
, h
->root
.root
.string
,
9323 false, false) != NULL
)
9328 /* This symbol doesn't come from a VMS object. So we suppose it is
9330 int len
= strlen (h
->root
.root
.string
);
9332 sym
= (struct vms_symbol_entry
*)bfd_zalloc (info
->output_bfd
,
9333 sizeof (*sym
) + len
);
9337 memcpy (sym
->name
, h
->root
.root
.string
, len
);
9339 sym
->owner
= info
->output_bfd
;
9341 sym
->typ
= EGSD__C_SYMG
;
9343 sym
->flags
= EGSY__V_DEF
| EGSY__V_REL
;
9344 sym
->symbol_vector
= h
->root
.u
.def
.value
;
9345 sym
->section
= h
->root
.u
.def
.section
;
9346 sym
->value
= h
->root
.u
.def
.value
;
9351 if (!add_symbol_entry (info
->output_bfd
, sym
))
9358 alpha_vms_bfd_final_link (bfd
*abfd
, struct bfd_link_info
*info
)
9361 struct bfd_link_order
*p
;
9369 if (bfd_link_relocatable (info
))
9371 /* FIXME: we do not yet support relocatable link. It is not obvious
9372 how to do it for debug infos. */
9373 (*info
->callbacks
->einfo
)(_("%P: relocatable link is not supported\n"));
9377 abfd
->outsymbols
= NULL
;
9380 /* Mark all sections which will be included in the output file. */
9381 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9382 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
9383 if (p
->type
== bfd_indirect_link_order
)
9384 p
->u
.indirect
.section
->linker_mark
= true;
9387 /* Handle all the link order information for the sections. */
9388 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9390 printf ("For section %s (at 0x%08x, flags=0x%08x):\n",
9391 o
->name
, (unsigned)o
->vma
, (unsigned)o
->flags
);
9393 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
9395 printf (" at 0x%08x - 0x%08x: ",
9396 (unsigned)p
->offset
, (unsigned)(p
->offset
+ p
->size
- 1));
9399 case bfd_section_reloc_link_order
:
9400 case bfd_symbol_reloc_link_order
:
9401 printf (" section/symbol reloc\n");
9403 case bfd_indirect_link_order
:
9404 printf (" section %s of %s\n",
9405 p
->u
.indirect
.section
->name
,
9406 p
->u
.indirect
.section
->owner
->filename
);
9408 case bfd_data_link_order
:
9409 printf (" explicit data\n");
9412 printf (" *unknown* type %u\n", p
->type
);
9419 /* Generate the symbol table. */
9420 BFD_ASSERT (PRIV (syms
) == NULL
);
9421 if (info
->strip
!= strip_all
)
9422 bfd_hash_traverse (&info
->hash
->table
, alpha_vms_link_output_symbol
, info
);
9424 /* Find the entry point. */
9425 if (bfd_get_start_address (abfd
) == 0)
9427 bfd
*startbfd
= NULL
;
9429 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9431 /* Consider only VMS object files. */
9432 if (sub
->xvec
!= abfd
->xvec
)
9435 if (!PRIV2 (sub
, eom_data
).eom_has_transfer
)
9437 if ((PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
) && startbfd
)
9439 if (startbfd
!= NULL
9440 && !(PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
))
9442 (*info
->callbacks
->einfo
)
9443 /* xgettext:c-format */
9444 (_("%P: multiple entry points: in modules %pB and %pB\n"),
9453 unsigned int ps_idx
= PRIV2 (startbfd
, eom_data
).eom_l_psindx
;
9454 bfd_vma tfradr
= PRIV2 (startbfd
, eom_data
).eom_l_tfradr
;
9457 sec
= PRIV2 (startbfd
, sections
)[ps_idx
];
9459 bfd_set_start_address
9460 (abfd
, sec
->output_section
->vma
+ sec
->output_offset
+ tfradr
);
9464 /* Set transfer addresses. */
9467 struct bfd_link_hash_entry
*h
;
9470 PRIV (transfer_address
[i
++]) = 0xffffffff00000340ULL
; /* SYS$IMGACT */
9471 h
= bfd_link_hash_lookup (info
->hash
, "LIB$INITIALIZE", false, false, true);
9472 if (h
!= NULL
&& h
->type
== bfd_link_hash_defined
)
9473 PRIV (transfer_address
[i
++]) =
9474 alpha_vms_get_sym_value (h
->u
.def
.section
, h
->u
.def
.value
);
9475 PRIV (transfer_address
[i
++]) = bfd_get_start_address (abfd
);
9477 PRIV (transfer_address
[i
++]) = 0;
9480 /* Allocate contents.
9481 Also compute the virtual base address. */
9482 base_addr
= (bfd_vma
)-1;
9484 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9486 if (o
->flags
& SEC_HAS_CONTENTS
)
9488 o
->contents
= bfd_alloc (abfd
, o
->size
);
9489 if (o
->contents
== NULL
)
9492 if (o
->flags
& SEC_LOAD
)
9494 if (o
->vma
< base_addr
)
9496 if (o
->vma
+ o
->size
> last_addr
)
9497 last_addr
= o
->vma
+ o
->size
;
9499 /* Clear the RELOC flags. Currently we don't support incremental
9500 linking. We use the RELOC flag for computing the eicp entries. */
9501 o
->flags
&= ~SEC_RELOC
;
9504 /* Create the fixup section. */
9505 fixupsec
= bfd_make_section_anyway_with_flags
9506 (info
->output_bfd
, "$FIXUP$",
9507 SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
9508 if (fixupsec
== NULL
)
9510 last_addr
= (last_addr
+ 0xffff) & ~0xffff;
9511 fixupsec
->vma
= last_addr
;
9513 alpha_vms_link_hash (info
)->fixup
= fixupsec
;
9514 alpha_vms_link_hash (info
)->base_addr
= base_addr
;
9516 /* Create the DMT section, if necessary. */
9517 BFD_ASSERT (PRIV (dst_section
) == NULL
);
9518 dst
= bfd_get_section_by_name (abfd
, "$DST$");
9519 if (dst
!= NULL
&& dst
->size
== 0)
9523 PRIV (dst_section
) = dst
;
9524 dmt
= bfd_make_section_anyway_with_flags
9525 (info
->output_bfd
, "$DMT$",
9526 SEC_DEBUGGING
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
9533 /* Read all sections from the inputs. */
9534 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9536 if (sub
->flags
& DYNAMIC
)
9538 alpha_vms_create_eisd_for_shared (abfd
, sub
);
9542 if (!alpha_vms_read_sections_content (sub
, info
))
9546 /* Handle all the link order information for the sections.
9547 Note: past this point, it is not possible to create new sections. */
9548 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9550 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
9554 case bfd_section_reloc_link_order
:
9555 case bfd_symbol_reloc_link_order
:
9558 case bfd_indirect_link_order
:
9562 if (! _bfd_default_link_order (abfd
, info
, o
, p
))
9569 /* Compute fixups. */
9570 if (!alpha_vms_build_fixups (info
))
9573 /* Compute the DMT. */
9577 unsigned char *contents
= NULL
;
9579 /* In pass 1, compute the size. In pass 2, write the DMT contents. */
9580 for (pass
= 0; pass
< 2; pass
++)
9582 unsigned int off
= 0;
9584 /* For each object file (ie for each module). */
9585 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9588 struct vms_dmt_header
*dmth
= NULL
;
9589 unsigned int psect_count
;
9591 /* Skip this module if it has no DST. */
9592 sub_dst
= PRIV2 (sub
, dst_section
);
9593 if (sub_dst
== NULL
|| sub_dst
->size
== 0)
9598 /* Write the header. */
9599 dmth
= (struct vms_dmt_header
*)(contents
+ off
);
9600 bfd_putl32 (sub_dst
->output_offset
, dmth
->modbeg
);
9601 bfd_putl32 (sub_dst
->size
, dmth
->size
);
9604 off
+= sizeof (struct vms_dmt_header
);
9607 /* For each section (ie for each psect). */
9608 for (o
= sub
->sections
; o
!= NULL
; o
= o
->next
)
9610 /* Only consider interesting sections. */
9611 if (!(o
->flags
& SEC_ALLOC
))
9613 if (o
->flags
& SEC_LINKER_CREATED
)
9618 /* Write an entry. */
9619 struct vms_dmt_psect
*dmtp
;
9621 dmtp
= (struct vms_dmt_psect
*)(contents
+ off
);
9622 bfd_putl32 (o
->output_offset
+ o
->output_section
->vma
,
9624 bfd_putl32 (o
->size
, dmtp
->length
);
9627 off
+= sizeof (struct vms_dmt_psect
);
9630 bfd_putl32 (psect_count
, dmth
->psect_count
);
9635 contents
= bfd_zalloc (info
->output_bfd
, off
);
9636 if (contents
== NULL
)
9638 dmt
->contents
= contents
;
9643 BFD_ASSERT (off
== dmt
->size
);
9651 /* Read the contents of a section.
9652 buf points to a buffer of buf_size bytes to be filled with
9653 section data (starting at offset into section) */
9656 alpha_vms_get_section_contents (bfd
*abfd
, asection
*section
,
9657 void *buf
, file_ptr offset
,
9658 bfd_size_type count
)
9662 /* Image are easy. */
9663 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
9664 return _bfd_generic_get_section_contents (abfd
, section
,
9665 buf
, offset
, count
);
9668 if (offset
+ count
< count
9669 || offset
+ count
> section
->size
)
9671 bfd_set_error (bfd_error_invalid_operation
);
9675 /* If the section is already in memory, just copy it. */
9676 if (section
->flags
& SEC_IN_MEMORY
)
9678 BFD_ASSERT (section
->contents
!= NULL
);
9679 memcpy (buf
, section
->contents
+ offset
, count
);
9682 if (section
->size
== 0)
9685 /* Alloc in memory and read ETIRs. */
9686 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
9688 BFD_ASSERT (sec
->contents
== NULL
);
9690 if (sec
->size
!= 0 && (sec
->flags
& SEC_HAS_CONTENTS
))
9692 sec
->contents
= bfd_alloc (abfd
, sec
->size
);
9693 if (sec
->contents
== NULL
)
9697 if (!alpha_vms_read_sections_content (abfd
, NULL
))
9699 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
9701 sec
->flags
|= SEC_IN_MEMORY
;
9702 memcpy (buf
, section
->contents
+ offset
, count
);
9707 /* Set the format of a file being written. */
9710 alpha_vms_mkobject (bfd
* abfd
)
9712 const bfd_arch_info_type
*arch
;
9714 vms_debug2 ((1, "alpha_vms_mkobject (%p)\n", abfd
));
9716 if (!vms_initialize (abfd
))
9719 PRIV (recwr
.buf
) = bfd_alloc (abfd
, MAX_OUTREC_SIZE
);
9720 if (PRIV (recwr
.buf
) == NULL
)
9723 arch
= bfd_scan_arch ("alpha");
9727 bfd_set_error (bfd_error_wrong_format
);
9731 abfd
->arch_info
= arch
;
9738 /* Called when the BFD is being closed to do any necessary cleanup. */
9741 vms_close_and_cleanup (bfd
* abfd
)
9743 vms_debug2 ((1, "vms_close_and_cleanup (%p)\n", abfd
));
9745 if (abfd
== NULL
|| abfd
->tdata
.any
== NULL
)
9748 if (abfd
->format
== bfd_object
)
9750 alpha_vms_free_private (abfd
);
9753 if (abfd
->direction
== write_direction
)
9755 /* Last step on VMS is to convert the file to variable record length
9757 if (!bfd_cache_close (abfd
))
9759 if (!_bfd_vms_convert_to_var_unix_filename (abfd
->filename
))
9765 return _bfd_generic_close_and_cleanup (abfd
);
9768 /* Called when a new section is created. */
9771 vms_new_section_hook (bfd
* abfd
, asection
*section
)
9775 vms_debug2 ((1, "vms_new_section_hook (%p, [%u]%s)\n",
9776 abfd
, section
->index
, section
->name
));
9778 if (!bfd_set_section_alignment (section
, 0))
9781 vms_debug2 ((7, "%u: %s\n", section
->index
, section
->name
));
9783 amt
= sizeof (struct vms_section_data_struct
);
9784 section
->used_by_bfd
= bfd_zalloc (abfd
, amt
);
9785 if (section
->used_by_bfd
== NULL
)
9788 /* Create the section symbol. */
9789 return _bfd_generic_new_section_hook (abfd
, section
);
9792 /* Part 4.5, symbols. */
9794 /* Print symbol to file according to how. how is one of
9795 bfd_print_symbol_name just print the name
9796 bfd_print_symbol_more print more (???)
9797 bfd_print_symbol_all print all we know, which is not much right now :-). */
9800 vms_print_symbol (bfd
* abfd
,
9803 bfd_print_symbol_type how
)
9805 vms_debug2 ((1, "vms_print_symbol (%p, %p, %p, %d)\n",
9806 abfd
, file
, symbol
, how
));
9810 case bfd_print_symbol_name
:
9811 case bfd_print_symbol_more
:
9812 fprintf ((FILE *)file
," %s", symbol
->name
);
9815 case bfd_print_symbol_all
:
9817 const char *section_name
= symbol
->section
->name
;
9819 bfd_print_symbol_vandf (abfd
, file
, symbol
);
9821 fprintf ((FILE *) file
," %-8s %s", section_name
, symbol
->name
);
9827 /* Return information about symbol in ret.
9829 fill type, value and name
9832 B bss segment symbol
9834 D data segment symbol
9836 t a static function symbol
9837 T text segment symbol
9842 vms_get_symbol_info (bfd
* abfd ATTRIBUTE_UNUSED
,
9848 vms_debug2 ((1, "vms_get_symbol_info (%p, %p, %p)\n", abfd
, symbol
, ret
));
9850 sec
= symbol
->section
;
9857 else if (bfd_is_com_section (sec
))
9859 else if (bfd_is_abs_section (sec
))
9861 else if (bfd_is_und_section (sec
))
9863 else if (bfd_is_ind_section (sec
))
9865 else if ((symbol
->flags
& BSF_FUNCTION
)
9866 || (bfd_section_flags (sec
) & SEC_CODE
))
9868 else if (bfd_section_flags (sec
) & SEC_DATA
)
9870 else if (bfd_section_flags (sec
) & SEC_ALLOC
)
9875 if (ret
->type
!= 'U')
9876 ret
->value
= symbol
->value
+ symbol
->section
->vma
;
9879 ret
->name
= symbol
->name
;
9882 /* Return TRUE if the given symbol sym in the BFD abfd is
9883 a compiler generated local label, else return FALSE. */
9886 vms_bfd_is_local_label_name (bfd
* abfd ATTRIBUTE_UNUSED
,
9889 return name
[0] == '$';
9892 /* Part 4.7, writing an object file. */
9894 /* Sets the contents of the section section in BFD abfd to the data starting
9895 in memory at LOCATION. The data is written to the output section starting
9896 at offset offset for count bytes.
9898 Normally TRUE is returned, else FALSE. Possible error returns are:
9899 o bfd_error_no_contents - The output section does not have the
9900 SEC_HAS_CONTENTS attribute, so nothing can be written to it.
9901 o and some more too */
9904 _bfd_vms_set_section_contents (bfd
* abfd
,
9906 const void * location
,
9908 bfd_size_type count
)
9910 if (section
->contents
== NULL
)
9912 section
->contents
= bfd_alloc (abfd
, section
->size
);
9913 if (section
->contents
== NULL
)
9916 memcpy (section
->contents
+ offset
, location
, (size_t) count
);
9922 /* Set the architecture and machine type in BFD abfd to arch and mach.
9923 Find the correct pointer to a structure and insert it into the arch_info
9927 alpha_vms_set_arch_mach (bfd
*abfd
,
9928 enum bfd_architecture arch
, unsigned long mach
)
9930 if (arch
!= bfd_arch_alpha
9931 && arch
!= bfd_arch_unknown
)
9934 return bfd_default_set_arch_mach (abfd
, arch
, mach
);
9937 /* Set section VMS flags. Clear NO_FLAGS and set FLAGS. */
9940 bfd_vms_set_section_flags (bfd
*abfd ATTRIBUTE_UNUSED
,
9941 asection
*sec
, flagword no_flags
, flagword flags
)
9943 vms_section_data (sec
)->no_flags
= no_flags
;
9944 vms_section_data (sec
)->flags
= flags
;
9947 struct vms_private_data_struct
*
9948 bfd_vms_get_data (bfd
*abfd
)
9950 return (struct vms_private_data_struct
*)abfd
->tdata
.any
;
9953 #define vms_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false
9954 #define vms_bfd_link_just_syms _bfd_generic_link_just_syms
9955 #define vms_bfd_copy_link_hash_symbol_type \
9956 _bfd_generic_copy_link_hash_symbol_type
9957 #define vms_bfd_is_group_section bfd_generic_is_group_section
9958 #define vms_bfd_group_name bfd_generic_group_name
9959 #define vms_bfd_discard_group bfd_generic_discard_group
9960 #define vms_section_already_linked _bfd_generic_section_already_linked
9961 #define vms_bfd_define_common_symbol bfd_generic_define_common_symbol
9962 #define vms_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
9963 #define vms_bfd_define_start_stop bfd_generic_define_start_stop
9964 #define vms_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
9966 #define vms_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
9967 #define vms_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
9968 #define vms_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data
9969 #define vms_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
9970 #define vms_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
9971 #define vms_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
9973 /* Symbols table. */
9974 #define alpha_vms_make_empty_symbol _bfd_generic_make_empty_symbol
9975 #define alpha_vms_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false
9976 #define alpha_vms_print_symbol vms_print_symbol
9977 #define alpha_vms_get_symbol_info vms_get_symbol_info
9978 #define alpha_vms_get_symbol_version_string \
9979 _bfd_nosymbols_get_symbol_version_string
9981 #define alpha_vms_read_minisymbols _bfd_generic_read_minisymbols
9982 #define alpha_vms_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
9983 #define alpha_vms_get_lineno _bfd_nosymbols_get_lineno
9984 #define alpha_vms_find_inliner_info _bfd_nosymbols_find_inliner_info
9985 #define alpha_vms_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
9986 #define alpha_vms_find_nearest_line _bfd_vms_find_nearest_line
9987 #define alpha_vms_find_line _bfd_nosymbols_find_line
9988 #define alpha_vms_bfd_is_local_label_name vms_bfd_is_local_label_name
9990 /* Generic table. */
9991 #define alpha_vms_close_and_cleanup vms_close_and_cleanup
9992 #define alpha_vms_bfd_free_cached_info vms_bfd_free_cached_info
9993 #define alpha_vms_new_section_hook vms_new_section_hook
9994 #define alpha_vms_set_section_contents _bfd_vms_set_section_contents
9995 #define alpha_vms_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
9997 #define alpha_vms_bfd_get_relocated_section_contents \
9998 bfd_generic_get_relocated_section_contents
10000 #define alpha_vms_bfd_relax_section bfd_generic_relax_section
10001 #define alpha_vms_bfd_gc_sections bfd_generic_gc_sections
10002 #define alpha_vms_bfd_lookup_section_flags bfd_generic_lookup_section_flags
10003 #define alpha_vms_bfd_merge_sections bfd_generic_merge_sections
10004 #define alpha_vms_bfd_is_group_section bfd_generic_is_group_section
10005 #define alpha_vms_bfd_group_name bfd_generic_group_name
10006 #define alpha_vms_bfd_discard_group bfd_generic_discard_group
10007 #define alpha_vms_section_already_linked \
10008 _bfd_generic_section_already_linked
10010 #define alpha_vms_bfd_define_common_symbol bfd_generic_define_common_symbol
10011 #define alpha_vms_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
10012 #define alpha_vms_bfd_define_start_stop bfd_generic_define_start_stop
10013 #define alpha_vms_bfd_link_just_syms _bfd_generic_link_just_syms
10014 #define alpha_vms_bfd_copy_link_hash_symbol_type \
10015 _bfd_generic_copy_link_hash_symbol_type
10017 #define alpha_vms_bfd_link_split_section _bfd_generic_link_split_section
10019 #define alpha_vms_get_dynamic_symtab_upper_bound \
10020 _bfd_nodynamic_get_dynamic_symtab_upper_bound
10021 #define alpha_vms_canonicalize_dynamic_symtab \
10022 _bfd_nodynamic_canonicalize_dynamic_symtab
10023 #define alpha_vms_get_dynamic_reloc_upper_bound \
10024 _bfd_nodynamic_get_dynamic_reloc_upper_bound
10025 #define alpha_vms_canonicalize_dynamic_reloc \
10026 _bfd_nodynamic_canonicalize_dynamic_reloc
10027 #define alpha_vms_bfd_link_check_relocs _bfd_generic_link_check_relocs
10029 const bfd_target alpha_vms_vec
=
10031 "vms-alpha", /* Name. */
10032 bfd_target_evax_flavour
,
10033 BFD_ENDIAN_LITTLE
, /* Data byte order is little. */
10034 BFD_ENDIAN_LITTLE
, /* Header byte order is little. */
10036 (HAS_RELOC
| EXEC_P
| HAS_LINENO
| HAS_DEBUG
| HAS_SYMS
| HAS_LOCALS
10037 | WP_TEXT
| D_PAGED
), /* Object flags. */
10038 (SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
10039 | SEC_READONLY
| SEC_CODE
| SEC_DATA
10040 | SEC_HAS_CONTENTS
| SEC_IN_MEMORY
), /* Sect flags. */
10041 0, /* symbol_leading_char. */
10042 ' ', /* ar_pad_char. */
10043 15, /* ar_max_namelen. */
10044 0, /* match priority. */
10045 TARGET_KEEP_UNUSED_SECTION_SYMBOLS
, /* keep unused section symbols. */
10046 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
10047 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
10048 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
10049 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
10050 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
10051 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
10053 { /* bfd_check_format. */
10055 alpha_vms_object_p
,
10056 _bfd_vms_lib_alpha_archive_p
,
10059 { /* bfd_set_format. */
10060 _bfd_bool_bfd_false_error
,
10061 alpha_vms_mkobject
,
10062 _bfd_vms_lib_alpha_mkarchive
,
10063 _bfd_bool_bfd_false_error
10065 { /* bfd_write_contents. */
10066 _bfd_bool_bfd_false_error
,
10067 alpha_vms_write_object_contents
,
10068 _bfd_vms_lib_write_archive_contents
,
10069 _bfd_bool_bfd_false_error
10072 BFD_JUMP_TABLE_GENERIC (alpha_vms
),
10073 BFD_JUMP_TABLE_COPY (vms
),
10074 BFD_JUMP_TABLE_CORE (_bfd_nocore
),
10075 BFD_JUMP_TABLE_ARCHIVE (_bfd_vms_lib
),
10076 BFD_JUMP_TABLE_SYMBOLS (alpha_vms
),
10077 BFD_JUMP_TABLE_RELOCS (alpha_vms
),
10078 BFD_JUMP_TABLE_WRITE (alpha_vms
),
10079 BFD_JUMP_TABLE_LINK (alpha_vms
),
10080 BFD_JUMP_TABLE_DYNAMIC (alpha_vms
),