1 /* vms.c -- BFD back-end for EVAX (openVMS/Alpha) files.
2 Copyright (C) 1996-2020 Free Software Foundation, Inc.
4 Initial version written by Klaus Kaempf (kkaempf@rmi.de)
5 Major rewrite by Adacore.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20 MA 02110-1301, USA. */
25 o Generation of shared image
26 o Relocation optimizations
32 o protected sections (for messages)
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 bfd_boolean 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. */
270 bfd_boolean reloc_done
;
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 bfd_boolean
_bfd_vms_slurp_object_records (bfd
* abfd
);
375 static bfd_boolean
alpha_vms_add_fixup_lp (struct bfd_link_info
*,
377 static bfd_boolean
alpha_vms_add_fixup_ca (struct bfd_link_info
*,
379 static bfd_boolean
alpha_vms_add_fixup_qr (struct bfd_link_info
*,
380 bfd
*, bfd
*, bfd_vma
);
381 static bfd_boolean
alpha_vms_add_fixup_lr (struct bfd_link_info
*,
382 unsigned int, bfd_vma
);
383 static bfd_boolean
alpha_vms_add_lw_reloc (struct bfd_link_info
*);
384 static bfd_boolean
alpha_vms_add_qw_reloc (struct bfd_link_info
*);
393 /* Number of elements in VEC. */
395 #define VEC_COUNT(VEC) ((VEC).nbr_el)
397 /* Get the address of the Nth element. */
399 #define VEC_EL(VEC, TYPE, N) (((TYPE *)((VEC).els))[N])
401 #define VEC_INIT(VEC) \
408 /* Be sure there is room for a new element. */
410 static void *vector_grow1 (struct vector_type
*vec
, size_t elsz
);
412 /* Allocate room for a new element and return its address. */
414 #define VEC_APPEND(VEC, TYPE) \
415 ((TYPE *) vector_grow1 (&VEC, sizeof (TYPE)))
417 struct alpha_vms_vma_ref
419 bfd_vma vma
; /* Vma in the output. */
420 bfd_vma ref
; /* Reference in the input. */
423 struct alpha_vms_shlib_el
426 bfd_boolean has_fixups
;
428 struct vector_type lp
; /* Vector of bfd_vma. */
429 struct vector_type ca
; /* Vector of bfd_vma. */
430 struct vector_type qr
; /* Vector of struct alpha_vms_vma_ref. */
433 /* Alpha VMS linker hash table. */
435 struct alpha_vms_link_hash_table
437 struct bfd_link_hash_table root
;
439 /* Vector of shared libraries. */
440 struct vector_type shrlibs
;
445 /* Base address. Used by fixups. */
449 #define alpha_vms_link_hash(INFO) \
450 ((struct alpha_vms_link_hash_table *)(INFO->hash))
452 /* Alpha VMS linker hash table entry. */
454 struct alpha_vms_link_hash_entry
456 struct bfd_link_hash_entry root
;
458 /* Pointer to the original vms symbol. */
459 struct vms_symbol_entry
*sym
;
464 /* Read & process EIHD record.
465 Return TRUE on success, FALSE on error. */
468 _bfd_vms_slurp_eihd (bfd
*abfd
, unsigned int *eisd_offset
,
469 unsigned int *eihs_offset
)
471 unsigned int imgtype
, size
;
473 struct vms_eihd
*eihd
= (struct vms_eihd
*)PRIV (recrd
.rec
);
475 vms_debug2 ((8, "_bfd_vms_slurp_eihd\n"));
477 /* PR 21813: Check for an undersized record. */
478 if (PRIV (recrd
.buf_size
) < sizeof (* eihd
))
480 _bfd_error_handler (_("corrupt EIHD record - size is too small"));
481 bfd_set_error (bfd_error_bad_value
);
485 size
= bfd_getl32 (eihd
->size
);
486 imgtype
= bfd_getl32 (eihd
->imgtype
);
488 if (imgtype
== EIHD__K_EXE
|| imgtype
== EIHD__K_LIM
)
489 abfd
->flags
|= EXEC_P
;
491 symvva
= bfd_getl64 (eihd
->symvva
);
494 PRIV (symvva
) = symvva
;
495 abfd
->flags
|= DYNAMIC
;
498 PRIV (ident
) = bfd_getl32 (eihd
->ident
);
499 PRIV (matchctl
) = eihd
->matchctl
;
501 *eisd_offset
= bfd_getl32 (eihd
->isdoff
);
502 *eihs_offset
= bfd_getl32 (eihd
->symdbgoff
);
504 vms_debug2 ((4, "EIHD size %d imgtype %d symvva 0x%lx eisd %d eihs %d\n",
505 size
, imgtype
, (unsigned long)symvva
,
506 *eisd_offset
, *eihs_offset
));
512 /* Read & process EISD record.
513 Return TRUE on success, FALSE on error. */
516 _bfd_vms_slurp_eisd (bfd
*abfd
, unsigned int offset
)
518 int section_count
= 0;
520 vms_debug2 ((8, "_bfd_vms_slurp_eisd\n"));
524 struct vms_eisd
*eisd
;
525 unsigned int rec_size
;
534 /* PR 17512: file: 3d9e9fe9. */
535 if (offset
> PRIV (recrd
.rec_size
)
536 || (PRIV (recrd
.rec_size
) - offset
537 < offsetof (struct vms_eisd
, eisdsize
) + 4))
539 eisd
= (struct vms_eisd
*) (PRIV (recrd
.rec
) + offset
);
540 rec_size
= bfd_getl32 (eisd
->eisdsize
);
544 /* Skip to next block if pad. */
545 if (rec_size
== 0xffffffff)
547 offset
= (offset
+ VMS_BLOCK_SIZE
) & ~(VMS_BLOCK_SIZE
- 1);
551 /* Make sure that there is enough data present in the record. */
552 if (rec_size
< offsetof (struct vms_eisd
, type
) + 1)
554 /* Make sure that the record is not too big either. */
555 if (rec_size
> PRIV (recrd
.rec_size
) - offset
)
560 size
= bfd_getl32 (eisd
->secsize
);
561 vaddr
= bfd_getl64 (eisd
->virt_addr
);
562 flags
= bfd_getl32 (eisd
->flags
);
563 vbn
= bfd_getl32 (eisd
->vbn
);
565 vms_debug2 ((4, "EISD at 0x%x size 0x%x addr 0x%lx flags 0x%x blk %d\n",
566 offset
, size
, (unsigned long)vaddr
, flags
, vbn
));
568 /* VMS combines psects from .obj files into isects in the .exe. This
569 process doesn't preserve enough information to reliably determine
570 what's in each section without examining the data. This is
571 especially true of DWARF debug sections. */
572 bfd_flags
= SEC_ALLOC
;
574 bfd_flags
|= SEC_HAS_CONTENTS
| SEC_LOAD
;
576 if (flags
& EISD__M_EXE
)
577 bfd_flags
|= SEC_CODE
;
579 if (flags
& EISD__M_NONSHRADR
)
580 bfd_flags
|= SEC_DATA
;
582 if (!(flags
& EISD__M_WRT
))
583 bfd_flags
|= SEC_READONLY
;
585 if (flags
& EISD__M_DZRO
)
586 bfd_flags
|= SEC_DATA
;
588 if (flags
& EISD__M_FIXUPVEC
)
589 bfd_flags
|= SEC_DATA
;
591 if (flags
& EISD__M_CRF
)
592 bfd_flags
|= SEC_DATA
;
594 if (flags
& EISD__M_GBL
)
596 if (rec_size
<= offsetof (struct vms_eisd
, gblnam
))
598 else if (rec_size
< sizeof (struct vms_eisd
))
599 name
= _bfd_vms_save_counted_string (abfd
, eisd
->gblnam
,
600 rec_size
- offsetof (struct vms_eisd
, gblnam
));
602 name
= _bfd_vms_save_counted_string (abfd
, eisd
->gblnam
,
604 if (name
== NULL
|| name
[0] == 0)
606 bfd_flags
|= SEC_COFF_SHARED_LIBRARY
;
607 bfd_flags
&= ~(SEC_ALLOC
| SEC_LOAD
);
609 else if (flags
& EISD__M_FIXUPVEC
)
611 else if (eisd
->type
== EISD__K_USRSTACK
)
617 name
= (char *) bfd_alloc (abfd
, 32);
620 if (flags
& EISD__M_DZRO
)
622 else if (flags
& EISD__M_EXE
)
624 else if (!(flags
& EISD__M_WRT
))
628 BFD_ASSERT (section_count
< 999);
629 sprintf (name
, "$%s_%03d$", pfx
, section_count
++);
632 section
= bfd_make_section (abfd
, name
);
637 section
->filepos
= vbn
? VMS_BLOCK_SIZE
* (vbn
- 1) : 0;
638 section
->size
= size
;
639 section
->vma
= vaddr
;
641 if (!bfd_set_section_flags (section
, bfd_flags
))
648 /* Read & process EIHS record.
649 Return TRUE on success, FALSE on error. */
652 _bfd_vms_slurp_eihs (bfd
*abfd
, unsigned int offset
)
654 unsigned char *p
= PRIV (recrd
.rec
) + offset
;
656 unsigned int gstsize ATTRIBUTE_UNUSED
;
658 unsigned int dstsize
;
660 unsigned int dmtbytes
;
663 /* PR 21611: Check that offset is valid. */
664 if (offset
> PRIV (recrd
.rec_size
) - (EIHS__L_DMTBYTES
+ 4))
666 _bfd_error_handler (_("unable to read EIHS record at offset %#x"),
668 bfd_set_error (bfd_error_file_truncated
);
672 gstvbn
= bfd_getl32 (p
+ EIHS__L_GSTVBN
);
673 gstsize
= bfd_getl32 (p
+ EIHS__L_GSTSIZE
);
674 dstvbn
= bfd_getl32 (p
+ EIHS__L_DSTVBN
);
675 dstsize
= bfd_getl32 (p
+ EIHS__L_DSTSIZE
);
676 dmtvbn
= bfd_getl32 (p
+ EIHS__L_DMTVBN
);
677 dmtbytes
= bfd_getl32 (p
+ EIHS__L_DMTBYTES
);
680 vms_debug (8, "_bfd_vms_slurp_ihs\n");
681 vms_debug (4, "EIHS record gstvbn %d gstsize %d dstvbn %d dstsize %d dmtvbn %d dmtbytes %d\n",
682 gstvbn
, gstsize
, dstvbn
, dstsize
, dmtvbn
, dmtbytes
);
687 flagword bfd_flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
;
689 section
= bfd_make_section (abfd
, "$DST$");
693 section
->size
= dstsize
;
694 section
->filepos
= VMS_BLOCK_SIZE
* (dstvbn
- 1);
696 if (!bfd_set_section_flags (section
, bfd_flags
))
699 PRIV (dst_section
) = section
;
700 abfd
->flags
|= (HAS_DEBUG
| HAS_LINENO
);
705 flagword bfd_flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
;
707 section
= bfd_make_section (abfd
, "$DMT$");
711 section
->size
= dmtbytes
;
712 section
->filepos
= VMS_BLOCK_SIZE
* (dmtvbn
- 1);
714 if (!bfd_set_section_flags (section
, bfd_flags
))
720 if (bfd_seek (abfd
, VMS_BLOCK_SIZE
* (gstvbn
- 1), SEEK_SET
))
722 bfd_set_error (bfd_error_file_truncated
);
726 if (!_bfd_vms_slurp_object_records (abfd
))
729 abfd
->flags
|= HAS_SYMS
;
735 /* Object file reading. */
737 /* Object file input functions. */
739 /* Get next record from object file to vms_buf.
740 Set PRIV(buf_size) and return it
742 This is a little tricky since it should be portable.
744 The openVMS object file has 'variable length' which means that
745 read() returns data in chunks of (hopefully) correct and expected
746 size. The linker (and other tools on VMS) depend on that. Unix
747 doesn't know about 'formatted' files, so reading and writing such
748 an object file in a Unix environment is not trivial.
750 With the tool 'file' (available on all VMS FTP sites), one
751 can view and change the attributes of a file. Changing from
752 'variable length' to 'fixed length, 512 bytes' reveals the
753 record size at the first 2 bytes of every record. The same
754 may happen during the transfer of object files from VMS to Unix,
755 at least with UCX, the DEC implementation of TCP/IP.
757 The VMS format repeats the size at bytes 2 & 3 of every record.
759 On the first call (file_format == FF_UNKNOWN) we check if
760 the first and the third byte pair (!) of the record match.
761 If they do it's an object file in an Unix environment or with
762 wrong attributes (FF_FOREIGN), else we should be in a VMS
763 environment where read() returns the record size (FF_NATIVE).
765 Reading is always done in 2 steps:
766 1. first just the record header is read and the size extracted,
767 2. then the read buffer is adjusted and the remaining bytes are
770 All file I/O is done on even file positions. */
772 #define VMS_OBJECT_ADJUSTMENT 2
775 maybe_adjust_record_pointer_for_object (bfd
*abfd
)
777 /* Set the file format once for all on the first invocation. */
778 if (PRIV (recrd
.file_format
) == FF_UNKNOWN
)
780 if (PRIV (recrd
.rec
)[0] == PRIV (recrd
.rec
)[4]
781 && PRIV (recrd
.rec
)[1] == PRIV (recrd
.rec
)[5])
782 PRIV (recrd
.file_format
) = FF_FOREIGN
;
784 PRIV (recrd
.file_format
) = FF_NATIVE
;
787 /* The adjustment is needed only in an Unix environment. */
788 if (PRIV (recrd
.file_format
) == FF_FOREIGN
)
789 PRIV (recrd
.rec
) += VMS_OBJECT_ADJUSTMENT
;
792 /* Implement step #1 of the object record reading procedure.
793 Return the record type or -1 on failure. */
796 _bfd_vms_get_object_record (bfd
*abfd
)
798 unsigned int test_len
= 6;
801 vms_debug2 ((8, "_bfd_vms_get_obj_record\n"));
803 /* Skip alignment byte if the current position is odd. */
804 if (PRIV (recrd
.file_format
) == FF_FOREIGN
&& (bfd_tell (abfd
) & 1))
806 if (bfd_bread (PRIV (recrd
.buf
), 1, abfd
) != 1)
808 bfd_set_error (bfd_error_file_truncated
);
813 /* Read the record header */
814 if (bfd_bread (PRIV (recrd
.buf
), test_len
, abfd
) != test_len
)
816 bfd_set_error (bfd_error_file_truncated
);
820 /* Reset the record pointer. */
821 PRIV (recrd
.rec
) = PRIV (recrd
.buf
);
822 maybe_adjust_record_pointer_for_object (abfd
);
824 if (vms_get_remaining_object_record (abfd
, test_len
) <= 0)
827 type
= bfd_getl16 (PRIV (recrd
.rec
));
829 vms_debug2 ((8, "_bfd_vms_get_obj_record: rec %p, size %d, type %d\n",
830 PRIV (recrd
.rec
), PRIV (recrd
.rec_size
), type
));
835 /* Implement step #2 of the object record reading procedure.
836 Return the size of the record or 0 on failure. */
839 vms_get_remaining_object_record (bfd
*abfd
, unsigned int read_so_far
)
841 unsigned int to_read
;
843 vms_debug2 ((8, "vms_get_remaining_obj_record\n"));
845 /* Extract record size. */
846 PRIV (recrd
.rec_size
) = bfd_getl16 (PRIV (recrd
.rec
) + 2);
848 if (PRIV (recrd
.rec_size
) == 0)
850 bfd_set_error (bfd_error_file_truncated
);
854 /* That's what the linker manual says. */
855 if (PRIV (recrd
.rec_size
) > EOBJ__C_MAXRECSIZ
)
857 bfd_set_error (bfd_error_file_truncated
);
861 /* Take into account object adjustment. */
862 to_read
= PRIV (recrd
.rec_size
);
863 if (PRIV (recrd
.file_format
) == FF_FOREIGN
)
864 to_read
+= VMS_OBJECT_ADJUSTMENT
;
866 /* Adjust the buffer. */
867 if (to_read
> PRIV (recrd
.buf_size
))
870 = (unsigned char *) bfd_realloc_or_free (PRIV (recrd
.buf
), to_read
);
871 if (PRIV (recrd
.buf
) == NULL
)
873 PRIV (recrd
.buf_size
) = to_read
;
875 /* PR 17512: file: 025-1974-0.004. */
876 else if (to_read
<= read_so_far
)
879 /* Read the remaining record. */
880 to_read
-= read_so_far
;
882 vms_debug2 ((8, "vms_get_remaining_obj_record: to_read %d\n", to_read
));
884 if (bfd_bread (PRIV (recrd
.buf
) + read_so_far
, to_read
, abfd
) != to_read
)
886 bfd_set_error (bfd_error_file_truncated
);
890 /* Reset the record pointer. */
891 PRIV (recrd
.rec
) = PRIV (recrd
.buf
);
892 maybe_adjust_record_pointer_for_object (abfd
);
894 vms_debug2 ((8, "vms_get_remaining_obj_record: size %d\n",
895 PRIV (recrd
.rec_size
)));
897 return PRIV (recrd
.rec_size
);
900 /* Read and process emh record.
901 Return TRUE on success, FALSE on error. */
904 _bfd_vms_slurp_ehdr (bfd
*abfd
)
907 unsigned char *vms_rec
;
911 vms_rec
= PRIV (recrd
.rec
);
912 /* PR 17512: file: 62736583. */
913 end
= PRIV (recrd
.buf
) + PRIV (recrd
.buf_size
);
915 vms_debug2 ((2, "HDR/EMH\n"));
917 subtype
= bfd_getl16 (vms_rec
+ 4);
919 vms_debug2 ((3, "subtype %d\n", subtype
));
925 if (vms_rec
+ 21 >= end
)
927 PRIV (hdr_data
).hdr_b_strlvl
= vms_rec
[6];
928 PRIV (hdr_data
).hdr_l_arch1
= bfd_getl32 (vms_rec
+ 8);
929 PRIV (hdr_data
).hdr_l_arch2
= bfd_getl32 (vms_rec
+ 12);
930 PRIV (hdr_data
).hdr_l_recsiz
= bfd_getl32 (vms_rec
+ 16);
931 if ((vms_rec
+ 20 + vms_rec
[20] + 1) >= end
)
933 PRIV (hdr_data
).hdr_t_name
934 = _bfd_vms_save_counted_string (abfd
, vms_rec
+ 20, vms_rec
[20]);
935 ptr
= vms_rec
+ 20 + vms_rec
[20] + 1;
936 if ((ptr
+ *ptr
+ 1) >= end
)
938 PRIV (hdr_data
).hdr_t_version
939 = _bfd_vms_save_counted_string (abfd
, ptr
, *ptr
);
943 PRIV (hdr_data
).hdr_t_date
944 = _bfd_vms_save_sized_string (abfd
, ptr
, 17);
948 if (vms_rec
+ PRIV (recrd
.rec_size
- 6) > end
)
950 PRIV (hdr_data
).hdr_c_lnm
951 = _bfd_vms_save_sized_string (abfd
, vms_rec
, PRIV (recrd
.rec_size
- 6));
955 if (vms_rec
+ PRIV (recrd
.rec_size
- 6) > end
)
957 PRIV (hdr_data
).hdr_c_src
958 = _bfd_vms_save_sized_string (abfd
, vms_rec
, PRIV (recrd
.rec_size
- 6));
962 if (vms_rec
+ PRIV (recrd
.rec_size
- 6) > end
)
964 PRIV (hdr_data
).hdr_c_ttl
965 = _bfd_vms_save_sized_string (abfd
, vms_rec
, PRIV (recrd
.rec_size
- 6));
975 bfd_set_error (bfd_error_wrong_format
);
982 /* Typical sections for evax object files. */
984 #define EVAX_ABS_NAME "$ABS$"
985 #define EVAX_CODE_NAME "$CODE$"
986 #define EVAX_LINK_NAME "$LINK$"
987 #define EVAX_DATA_NAME "$DATA$"
988 #define EVAX_BSS_NAME "$BSS$"
989 #define EVAX_READONLYADDR_NAME "$READONLY_ADDR$"
990 #define EVAX_READONLY_NAME "$READONLY$"
991 #define EVAX_LITERAL_NAME "$LITERAL$"
992 #define EVAX_LITERALS_NAME "$LITERALS"
993 #define EVAX_COMMON_NAME "$COMMON$"
994 #define EVAX_LOCAL_NAME "$LOCAL$"
996 struct sec_flags_struct
998 const char *name
; /* Name of section. */
1000 flagword flags_always
; /* Flags we set always. */
1002 flagword flags_hassize
; /* Flags we set if the section has a size > 0. */
1005 /* These flags are deccrtl/vaxcrtl (openVMS 6.2 Alpha) compatible. */
1007 static const struct sec_flags_struct evax_section_flags
[] =
1015 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_EXE
,
1016 SEC_CODE
| SEC_READONLY
,
1017 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_EXE
,
1018 SEC_CODE
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1019 { EVAX_LITERAL_NAME
,
1020 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
| EGPS__V_NOMOD
,
1021 SEC_DATA
| SEC_READONLY
,
1022 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
,
1023 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1025 EGPS__V_REL
| EGPS__V_RD
,
1026 SEC_DATA
| SEC_READONLY
,
1027 EGPS__V_REL
| EGPS__V_RD
,
1028 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1030 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
,
1032 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1033 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1035 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
,
1037 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
,
1039 { EVAX_READONLYADDR_NAME
,
1040 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_RD
,
1041 SEC_DATA
| SEC_READONLY
,
1042 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_RD
,
1043 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1044 { EVAX_READONLY_NAME
,
1045 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
| EGPS__V_NOMOD
,
1046 SEC_DATA
| SEC_READONLY
,
1047 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
,
1048 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1050 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1052 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1053 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1054 { EVAX_LITERALS_NAME
,
1055 EGPS__V_PIC
| EGPS__V_OVR
,
1056 SEC_DATA
| SEC_READONLY
,
1057 EGPS__V_PIC
| EGPS__V_OVR
,
1058 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1060 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1062 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1063 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
}
1066 /* Retrieve BFD section flags by name and size. */
1069 vms_secflag_by_name (const struct sec_flags_struct
*section_flags
,
1075 while (section_flags
[i
].name
!= NULL
)
1077 if (strcmp (name
, section_flags
[i
].name
) == 0)
1080 return section_flags
[i
].flags_hassize
;
1082 return section_flags
[i
].flags_always
;
1087 return section_flags
[i
].flags_hassize
;
1088 return section_flags
[i
].flags_always
;
1091 /* Retrieve VMS section flags by name and size. */
1094 vms_esecflag_by_name (const struct sec_flags_struct
*section_flags
,
1100 while (section_flags
[i
].name
!= NULL
)
1102 if (strcmp (name
, section_flags
[i
].name
) == 0)
1105 return section_flags
[i
].vflags_hassize
;
1107 return section_flags
[i
].vflags_always
;
1112 return section_flags
[i
].vflags_hassize
;
1113 return section_flags
[i
].vflags_always
;
1116 /* Add SYM to the symbol table of ABFD.
1117 Return FALSE in case of error. */
1120 add_symbol_entry (bfd
*abfd
, struct vms_symbol_entry
*sym
)
1122 if (PRIV (gsd_sym_count
) >= PRIV (max_sym_count
))
1124 if (PRIV (max_sym_count
) == 0)
1126 PRIV (max_sym_count
) = 128;
1127 PRIV (syms
) = bfd_malloc
1128 (PRIV (max_sym_count
) * sizeof (struct vms_symbol_entry
*));
1132 PRIV (max_sym_count
) *= 2;
1133 PRIV (syms
) = bfd_realloc_or_free
1135 (PRIV (max_sym_count
) * sizeof (struct vms_symbol_entry
*)));
1137 if (PRIV (syms
) == NULL
)
1141 PRIV (syms
)[PRIV (gsd_sym_count
)++] = sym
;
1145 /* Create a symbol whose name is ASCIC and add it to ABFD.
1146 Return NULL in case of error. */
1148 static struct vms_symbol_entry
*
1149 add_symbol (bfd
*abfd
, const unsigned char *ascic
, unsigned int max
)
1151 struct vms_symbol_entry
*entry
;
1158 _bfd_error_handler (_("record is too small for symbol name length"));
1159 bfd_set_error (bfd_error_bad_value
);
1163 entry
= (struct vms_symbol_entry
*)bfd_zalloc (abfd
, sizeof (*entry
) + len
);
1166 entry
->namelen
= len
;
1167 memcpy (entry
->name
, ascic
, len
);
1168 entry
->name
[len
] = 0;
1169 entry
->owner
= abfd
;
1171 if (!add_symbol_entry (abfd
, entry
))
1176 /* Read and process EGSD. Return FALSE on failure. */
1179 _bfd_vms_slurp_egsd (bfd
*abfd
)
1182 unsigned int gsd_size
;
1183 unsigned char *vms_rec
;
1187 vms_debug2 ((2, "EGSD\n"));
1189 if (PRIV (recrd
.rec_size
) < 8)
1191 _bfd_error_handler (_("corrupt EGSD record: its size (%#x) is too small"),
1192 PRIV (recrd
.rec_size
));
1193 bfd_set_error (bfd_error_bad_value
);
1197 PRIV (recrd
.rec
) += 8; /* Skip type, size, align pad. */
1198 PRIV (recrd
.rec_size
) -= 8;
1200 /* Calculate base address for each section. */
1203 while (PRIV (recrd
.rec_size
) > 4)
1205 vms_rec
= PRIV (recrd
.rec
);
1207 gsd_type
= bfd_getl16 (vms_rec
);
1208 gsd_size
= bfd_getl16 (vms_rec
+ 2);
1210 vms_debug2 ((3, "egsd_type %d\n", gsd_type
));
1212 /* PR 21615: Check for size overflow. */
1213 if (PRIV (recrd
.rec_size
) < gsd_size
)
1215 _bfd_error_handler (_("corrupt EGSD record type %d: size (%#x) "
1216 "is larger than remaining space (%#x)"),
1217 gsd_type
, gsd_size
, PRIV (recrd
.rec_size
));
1218 bfd_set_error (bfd_error_bad_value
);
1225 _bfd_error_handler (_("corrupt EGSD record type %d: size (%#x) "
1227 gsd_type
, gsd_size
);
1228 bfd_set_error (bfd_error_bad_value
);
1235 /* Program section definition. */
1237 struct vms_egps
*egps
= (struct vms_egps
*) vms_rec
;
1238 flagword new_flags
, vms_flags
;
1241 if (offsetof (struct vms_egps
, flags
) + 2 > gsd_size
)
1243 vms_flags
= bfd_getl16 (egps
->flags
);
1245 if ((vms_flags
& EGPS__V_REL
) == 0)
1247 /* Use the global absolute section for all
1248 absolute sections. */
1249 section
= bfd_abs_section_ptr
;
1257 if (offsetof (struct vms_egps
, namlng
) >= gsd_size
)
1259 left
= gsd_size
- offsetof (struct vms_egps
, namlng
);
1260 name
= _bfd_vms_save_counted_string (abfd
, &egps
->namlng
, left
);
1261 if (name
== NULL
|| name
[0] == 0)
1264 section
= bfd_make_section (abfd
, name
);
1268 section
->filepos
= 0;
1269 section
->size
= bfd_getl32 (egps
->alloc
);
1270 section
->alignment_power
= egps
->align
& 31;
1272 vms_section_data (section
)->flags
= vms_flags
;
1273 vms_section_data (section
)->no_flags
= 0;
1275 new_flags
= vms_secflag_by_name (evax_section_flags
,
1278 if (section
->size
> 0)
1279 new_flags
|= SEC_LOAD
;
1280 if (!(vms_flags
& EGPS__V_NOMOD
) && section
->size
> 0)
1282 /* Set RELOC and HAS_CONTENTS if the section is not
1283 demand-zero and not empty. */
1284 new_flags
|= SEC_HAS_CONTENTS
;
1285 if (vms_flags
& EGPS__V_REL
)
1286 new_flags
|= SEC_RELOC
;
1288 if (vms_flags
& EGPS__V_EXE
)
1290 /* Set CODE if section is executable. */
1291 new_flags
|= SEC_CODE
;
1292 new_flags
&= ~SEC_DATA
;
1294 if (!bfd_set_section_flags (section
, new_flags
))
1297 /* Give a non-overlapping vma to non absolute sections. */
1298 align_addr
= (bfd_vma
) 1 << section
->alignment_power
;
1299 base_addr
= (base_addr
+ align_addr
- 1) & -align_addr
;
1300 section
->vma
= base_addr
;
1301 base_addr
+= section
->size
;
1304 /* Append it to the section array. */
1305 if (PRIV (section_count
) >= PRIV (section_max
))
1307 if (PRIV (section_max
) == 0)
1308 PRIV (section_max
) = 16;
1310 PRIV (section_max
) *= 2;
1311 PRIV (sections
) = bfd_realloc_or_free
1312 (PRIV (sections
), PRIV (section_max
) * sizeof (asection
*));
1313 if (PRIV (sections
) == NULL
)
1317 PRIV (sections
)[PRIV (section_count
)] = section
;
1318 PRIV (section_count
)++;
1324 unsigned int nameoff
;
1325 struct vms_symbol_entry
*entry
;
1326 struct vms_egsy
*egsy
= (struct vms_egsy
*) vms_rec
;
1329 if (offsetof (struct vms_egsy
, flags
) + 2 > gsd_size
)
1331 old_flags
= bfd_getl16 (egsy
->flags
);
1332 if (old_flags
& EGSY__V_DEF
)
1333 nameoff
= ESDF__B_NAMLNG
;
1335 nameoff
= ESRF__B_NAMLNG
;
1337 if (nameoff
>= gsd_size
)
1339 entry
= add_symbol (abfd
, vms_rec
+ nameoff
, gsd_size
- nameoff
);
1343 /* Allow only duplicate reference. */
1344 if ((entry
->flags
& EGSY__V_DEF
) && (old_flags
& EGSY__V_DEF
))
1347 if (entry
->typ
== 0)
1349 entry
->typ
= gsd_type
;
1350 entry
->data_type
= egsy
->datyp
;
1351 entry
->flags
= old_flags
;
1354 if (old_flags
& EGSY__V_DEF
)
1356 struct vms_esdf
*esdf
= (struct vms_esdf
*) vms_rec
;
1358 entry
->value
= bfd_getl64 (esdf
->value
);
1359 if (PRIV (sections
) == NULL
)
1362 psindx
= bfd_getl32 (esdf
->psindx
);
1363 /* PR 21813: Check for an out of range index. */
1364 if (psindx
< 0 || psindx
>= (int) PRIV (section_count
))
1367 _bfd_error_handler (_("corrupt EGSD record: its psindx "
1368 "field is too big (%#lx)"),
1370 bfd_set_error (bfd_error_bad_value
);
1373 entry
->section
= PRIV (sections
)[psindx
];
1375 if (old_flags
& EGSY__V_NORM
)
1377 PRIV (norm_sym_count
)++;
1379 entry
->code_value
= bfd_getl64 (esdf
->code_address
);
1380 psindx
= bfd_getl32 (esdf
->ca_psindx
);
1381 /* PR 21813: Check for an out of range index. */
1382 if (psindx
< 0 || psindx
>= (int) PRIV (section_count
))
1384 entry
->code_section
= PRIV (sections
)[psindx
];
1392 struct vms_symbol_entry
*entry
;
1393 struct vms_egst
*egst
= (struct vms_egst
*)vms_rec
;
1395 unsigned int nameoff
= offsetof (struct vms_egst
, namlng
);
1397 old_flags
= bfd_getl16 (egst
->header
.flags
);
1399 if (nameoff
>= gsd_size
)
1401 entry
= add_symbol (abfd
, &egst
->namlng
, gsd_size
- nameoff
);
1405 entry
->typ
= gsd_type
;
1406 entry
->data_type
= egst
->header
.datyp
;
1407 entry
->flags
= old_flags
;
1409 entry
->symbol_vector
= bfd_getl32 (egst
->value
);
1411 if (old_flags
& EGSY__V_REL
)
1413 if (PRIV (sections
) == NULL
)
1415 psindx
= bfd_getl32 (egst
->psindx
);
1416 /* PR 21813: Check for an out of range index. */
1417 if (psindx
< 0 || psindx
>= (int) PRIV (section_count
))
1419 entry
->section
= PRIV (sections
)[psindx
];
1422 entry
->section
= bfd_abs_section_ptr
;
1424 entry
->value
= bfd_getl64 (egst
->lp_2
);
1426 if (old_flags
& EGSY__V_NORM
)
1428 PRIV (norm_sym_count
)++;
1430 entry
->code_value
= bfd_getl64 (egst
->lp_1
);
1431 entry
->code_section
= bfd_abs_section_ptr
;
1438 /* Currently ignored. */
1443 _bfd_error_handler (_("unknown EGSD subtype %d"), gsd_type
);
1444 bfd_set_error (bfd_error_bad_value
);
1448 PRIV (recrd
.rec_size
) -= gsd_size
;
1449 PRIV (recrd
.rec
) += gsd_size
;
1452 /* FIXME: Should we complain if PRIV (recrd.rec_size) is not zero ? */
1454 if (PRIV (gsd_sym_count
) > 0)
1455 abfd
->flags
|= HAS_SYMS
;
1460 /* Stack routines for vms ETIR commands. */
1462 /* Push value and section index. */
1465 _bfd_vms_push (bfd
*abfd
, bfd_vma val
, unsigned int reloc
)
1467 vms_debug2 ((4, "<push %08lx (0x%08x) at %d>\n",
1468 (unsigned long)val
, reloc
, PRIV (stackptr
)));
1470 PRIV (stack
[PRIV (stackptr
)]).value
= val
;
1471 PRIV (stack
[PRIV (stackptr
)]).reloc
= reloc
;
1473 if (PRIV (stackptr
) >= STACKSIZE
)
1475 bfd_set_error (bfd_error_bad_value
);
1476 _bfd_error_handler (_("stack overflow (%d) in _bfd_vms_push"), PRIV (stackptr
));
1482 /* Pop value and section index. */
1485 _bfd_vms_pop (bfd
*abfd
, bfd_vma
*val
, unsigned int *rel
)
1487 if (PRIV (stackptr
) == 0)
1489 bfd_set_error (bfd_error_bad_value
);
1490 _bfd_error_handler (_("stack underflow in _bfd_vms_pop"));
1494 *val
= PRIV (stack
[PRIV (stackptr
)]).value
;
1495 *rel
= PRIV (stack
[PRIV (stackptr
)]).reloc
;
1497 vms_debug2 ((4, "<pop %08lx (0x%08x)>\n", (unsigned long)*val
, *rel
));
1501 /* Routines to fill sections contents during tir/etir read. */
1503 /* Initialize image buffer pointer to be filled. */
1506 image_set_ptr (bfd
*abfd
, bfd_vma vma
, int sect
, struct bfd_link_info
*info
)
1510 vms_debug2 ((4, "image_set_ptr (0x%08x, sect=%d)\n", (unsigned)vma
, sect
));
1512 if (PRIV (sections
) == NULL
)
1514 if (sect
< 0 || sect
>= (int) PRIV (section_count
))
1517 sec
= PRIV (sections
)[sect
];
1521 /* Reading contents to an output bfd. */
1523 if (sec
->output_section
== NULL
)
1525 /* Section discarded. */
1526 vms_debug2 ((5, " section %s discarded\n", sec
->name
));
1528 /* This is not used. */
1529 PRIV (image_section
) = NULL
;
1530 PRIV (image_offset
) = 0;
1533 PRIV (image_offset
) = sec
->output_offset
+ vma
;
1534 PRIV (image_section
) = sec
->output_section
;
1538 PRIV (image_offset
) = vma
;
1539 PRIV (image_section
) = sec
;
1543 /* Increment image buffer pointer by offset. */
1546 image_inc_ptr (bfd
*abfd
, bfd_vma offset
)
1548 vms_debug2 ((4, "image_inc_ptr (%u)\n", (unsigned)offset
));
1550 PRIV (image_offset
) += offset
;
1553 /* Save current DST location counter under specified index. */
1556 dst_define_location (bfd
*abfd
, unsigned int loc
)
1558 vms_debug2 ((4, "dst_define_location (%d)\n", (int)loc
));
1562 /* 16M entries ought to be plenty. */
1563 bfd_set_error (bfd_error_bad_value
);
1564 _bfd_error_handler (_("dst_define_location %u too large"), loc
);
1568 /* Grow the ptr offset table if necessary. */
1569 if (loc
+ 1 > PRIV (dst_ptr_offsets_count
))
1571 PRIV (dst_ptr_offsets
)
1572 = bfd_realloc_or_free (PRIV (dst_ptr_offsets
),
1573 (loc
+ 1) * sizeof (unsigned int));
1574 if (PRIV (dst_ptr_offsets
) == NULL
)
1576 PRIV (dst_ptr_offsets_count
) = loc
+ 1;
1579 PRIV (dst_ptr_offsets
)[loc
] = PRIV (image_offset
);
1583 /* Restore saved DST location counter from specified index. */
1586 dst_restore_location (bfd
*abfd
, unsigned int loc
)
1588 vms_debug2 ((4, "dst_restore_location (%d)\n", (int)loc
));
1590 if (loc
< PRIV (dst_ptr_offsets_count
))
1592 PRIV (image_offset
) = PRIV (dst_ptr_offsets
)[loc
];
1598 /* Retrieve saved DST location counter from specified index. */
1601 dst_retrieve_location (bfd
*abfd
, bfd_vma
*loc
)
1603 vms_debug2 ((4, "dst_retrieve_location (%d)\n", (int) *loc
));
1605 if (*loc
< PRIV (dst_ptr_offsets_count
))
1607 *loc
= PRIV (dst_ptr_offsets
)[*loc
];
1613 /* Write multiple bytes to section image. */
1616 image_write (bfd
*abfd
, unsigned char *ptr
, unsigned int size
)
1618 asection
*sec
= PRIV (image_section
);
1619 size_t off
= PRIV (image_offset
);
1623 || size
> sec
->size
- off
)
1625 bfd_set_error (bfd_error_bad_value
);
1630 _bfd_vms_debug (8, "image_write from (%p, %d) to (%ld)\n", ptr
, size
,
1634 if (PRIV (image_section
)->contents
!= NULL
)
1635 memcpy (sec
->contents
+ off
, ptr
, size
);
1639 for (i
= 0; i
< size
; i
++)
1642 bfd_set_error (bfd_error_bad_value
);
1648 _bfd_hexdump (9, ptr
, size
, 0);
1651 PRIV (image_offset
) += size
;
1655 /* Write byte to section image. */
1658 image_write_b (bfd
* abfd
, unsigned int value
)
1660 unsigned char data
[1];
1662 vms_debug2 ((6, "image_write_b (%02x)\n", (int) value
));
1666 return image_write (abfd
, data
, sizeof (data
));
1669 /* Write 2-byte word to image. */
1672 image_write_w (bfd
* abfd
, unsigned int value
)
1674 unsigned char data
[2];
1676 vms_debug2 ((6, "image_write_w (%04x)\n", (int) value
));
1678 bfd_putl16 (value
, data
);
1679 return image_write (abfd
, data
, sizeof (data
));
1682 /* Write 4-byte long to image. */
1685 image_write_l (bfd
* abfd
, unsigned long value
)
1687 unsigned char data
[4];
1689 vms_debug2 ((6, "image_write_l (%08lx)\n", value
));
1691 bfd_putl32 (value
, data
);
1692 return image_write (abfd
, data
, sizeof (data
));
1695 /* Write 8-byte quad to image. */
1698 image_write_q (bfd
* abfd
, bfd_vma value
)
1700 unsigned char data
[8];
1702 vms_debug2 ((6, "image_write_q (%08lx)\n", (unsigned long)value
));
1704 bfd_putl64 (value
, data
);
1705 return image_write (abfd
, data
, sizeof (data
));
1709 _bfd_vms_etir_name (int cmd
)
1713 case ETIR__C_STA_GBL
: return "ETIR__C_STA_GBL";
1714 case ETIR__C_STA_LW
: return "ETIR__C_STA_LW";
1715 case ETIR__C_STA_QW
: return "ETIR__C_STA_QW";
1716 case ETIR__C_STA_PQ
: return "ETIR__C_STA_PQ";
1717 case ETIR__C_STA_LI
: return "ETIR__C_STA_LI";
1718 case ETIR__C_STA_MOD
: return "ETIR__C_STA_MOD";
1719 case ETIR__C_STA_CKARG
: return "ETIR__C_STA_CKARG";
1720 case ETIR__C_STO_B
: return "ETIR__C_STO_B";
1721 case ETIR__C_STO_W
: return "ETIR__C_STO_W";
1722 case ETIR__C_STO_GBL
: return "ETIR__C_STO_GBL";
1723 case ETIR__C_STO_CA
: return "ETIR__C_STO_CA";
1724 case ETIR__C_STO_RB
: return "ETIR__C_STO_RB";
1725 case ETIR__C_STO_AB
: return "ETIR__C_STO_AB";
1726 case ETIR__C_STO_OFF
: return "ETIR__C_STO_OFF";
1727 case ETIR__C_STO_IMM
: return "ETIR__C_STO_IMM";
1728 case ETIR__C_STO_IMMR
: return "ETIR__C_STO_IMMR";
1729 case ETIR__C_STO_LW
: return "ETIR__C_STO_LW";
1730 case ETIR__C_STO_QW
: return "ETIR__C_STO_QW";
1731 case ETIR__C_STO_GBL_LW
: return "ETIR__C_STO_GBL_LW";
1732 case ETIR__C_STO_LP_PSB
: return "ETIR__C_STO_LP_PSB";
1733 case ETIR__C_STO_HINT_GBL
: return "ETIR__C_STO_HINT_GBL";
1734 case ETIR__C_STO_HINT_PS
: return "ETIR__C_STO_HINT_PS";
1735 case ETIR__C_OPR_ADD
: return "ETIR__C_OPR_ADD";
1736 case ETIR__C_OPR_SUB
: return "ETIR__C_OPR_SUB";
1737 case ETIR__C_OPR_INSV
: return "ETIR__C_OPR_INSV";
1738 case ETIR__C_OPR_USH
: return "ETIR__C_OPR_USH";
1739 case ETIR__C_OPR_ROT
: return "ETIR__C_OPR_ROT";
1740 case ETIR__C_OPR_REDEF
: return "ETIR__C_OPR_REDEF";
1741 case ETIR__C_OPR_DFLIT
: return "ETIR__C_OPR_DFLIT";
1742 case ETIR__C_STC_LP
: return "ETIR__C_STC_LP";
1743 case ETIR__C_STC_GBL
: return "ETIR__C_STC_GBL";
1744 case ETIR__C_STC_GCA
: return "ETIR__C_STC_GCA";
1745 case ETIR__C_STC_PS
: return "ETIR__C_STC_PS";
1746 case ETIR__C_STC_NBH_PS
: return "ETIR__C_STC_NBH_PS";
1747 case ETIR__C_STC_NOP_GBL
: return "ETIR__C_STC_NOP_GBL";
1748 case ETIR__C_STC_NOP_PS
: return "ETIR__C_STC_NOP_PS";
1749 case ETIR__C_STC_BSR_GBL
: return "ETIR__C_STC_BSR_GBL";
1750 case ETIR__C_STC_BSR_PS
: return "ETIR__C_STC_BSR_PS";
1751 case ETIR__C_STC_LDA_GBL
: return "ETIR__C_STC_LDA_GBL";
1752 case ETIR__C_STC_LDA_PS
: return "ETIR__C_STC_LDA_PS";
1753 case ETIR__C_STC_BOH_GBL
: return "ETIR__C_STC_BOH_GBL";
1754 case ETIR__C_STC_BOH_PS
: return "ETIR__C_STC_BOH_PS";
1755 case ETIR__C_STC_NBH_GBL
: return "ETIR__C_STC_NBH_GBL";
1756 case ETIR__C_STC_LP_PSB
: return "ETIR__C_STC_LP_PSB";
1757 case ETIR__C_CTL_SETRB
: return "ETIR__C_CTL_SETRB";
1758 case ETIR__C_CTL_AUGRB
: return "ETIR__C_CTL_AUGRB";
1759 case ETIR__C_CTL_DFLOC
: return "ETIR__C_CTL_DFLOC";
1760 case ETIR__C_CTL_STLOC
: return "ETIR__C_CTL_STLOC";
1761 case ETIR__C_CTL_STKDL
: return "ETIR__C_CTL_STKDL";
1764 /* These names have not yet been added to this switch statement. */
1765 _bfd_error_handler (_("unknown ETIR command %d"), cmd
);
1770 #define HIGHBIT(op) ((op & 0x80000000L) == 0x80000000L)
1773 _bfd_vms_get_value (bfd
*abfd
,
1774 const unsigned char *ascic
,
1775 const unsigned char *max_ascic
,
1776 struct bfd_link_info
*info
,
1778 struct alpha_vms_link_hash_entry
**hp
)
1783 struct alpha_vms_link_hash_entry
*h
;
1785 /* Not linking. Do not try to resolve the symbol. */
1794 if (ascic
+ len
>= max_ascic
)
1796 _bfd_error_handler (_("corrupt vms value"));
1802 for (i
= 0; i
< len
; i
++)
1803 name
[i
] = ascic
[i
+ 1];
1806 h
= (struct alpha_vms_link_hash_entry
*)
1807 bfd_link_hash_lookup (info
->hash
, name
, FALSE
, FALSE
, TRUE
);
1812 && (h
->root
.type
== bfd_link_hash_defined
1813 || h
->root
.type
== bfd_link_hash_defweak
))
1814 *vma
= h
->root
.u
.def
.value
1815 + h
->root
.u
.def
.section
->output_offset
1816 + h
->root
.u
.def
.section
->output_section
->vma
;
1817 else if (h
&& h
->root
.type
== bfd_link_hash_undefweak
)
1821 (*info
->callbacks
->undefined_symbol
)
1822 (info
, name
, abfd
, PRIV (image_section
), PRIV (image_offset
), TRUE
);
1829 #define RELC_SHR_BASE 0x10000
1830 #define RELC_SEC_BASE 0x20000
1831 #define RELC_MASK 0x0ffff
1834 alpha_vms_sym_to_ctxt (struct alpha_vms_link_hash_entry
*h
)
1836 /* Handle undefined symbols. */
1837 if (h
== NULL
|| h
->sym
== NULL
)
1840 if (h
->sym
->typ
== EGSD__C_SYMG
)
1842 if (h
->sym
->flags
& EGSY__V_REL
)
1843 return RELC_SHR_BASE
+ PRIV2 (h
->sym
->owner
, shr_index
);
1846 /* Can this happen (non-relocatable symg) ? I'd like to see
1851 if (h
->sym
->typ
== EGSD__C_SYM
)
1853 if (h
->sym
->flags
& EGSY__V_REL
)
1862 alpha_vms_get_sym_value (asection
*sect
, bfd_vma addr
)
1864 return sect
->output_section
->vma
+ sect
->output_offset
+ addr
;
1868 alpha_vms_fix_sec_rel (bfd
*abfd
, struct bfd_link_info
*info
,
1869 unsigned int rel
, bfd_vma vma
)
1873 if (PRIV (sections
) == NULL
)
1876 sec
= PRIV (sections
)[rel
& RELC_MASK
];
1880 if (sec
->output_section
== NULL
)
1882 return vma
+ sec
->output_section
->vma
+ sec
->output_offset
;
1885 return vma
+ sec
->vma
;
1888 /* Read an ETIR record from ABFD. If INFO is not null, put the content into
1889 the output section (used during linking).
1890 Return FALSE in case of error. */
1893 _bfd_vms_slurp_etir (bfd
*abfd
, struct bfd_link_info
*info
)
1896 unsigned int length
;
1897 unsigned char *maxptr
;
1900 unsigned int rel1
= RELC_NONE
;
1901 unsigned int rel2
= RELC_NONE
;
1902 struct alpha_vms_link_hash_entry
*h
;
1904 PRIV (recrd
.rec
) += ETIR__C_HEADER_SIZE
;
1905 PRIV (recrd
.rec_size
) -= ETIR__C_HEADER_SIZE
;
1907 ptr
= PRIV (recrd
.rec
);
1908 length
= PRIV (recrd
.rec_size
);
1909 maxptr
= ptr
+ length
;
1911 vms_debug2 ((2, "ETIR: %d bytes\n", length
));
1913 while (ptr
< maxptr
)
1915 int cmd
, cmd_length
;
1917 if (ptr
+ 4 > maxptr
)
1920 cmd
= bfd_getl16 (ptr
);
1921 cmd_length
= bfd_getl16 (ptr
+ 2);
1923 /* PR 21589 and 21579: Check for a corrupt ETIR record. */
1924 if (cmd_length
< 4 || ptr
+ cmd_length
> maxptr
)
1927 _bfd_error_handler (_("corrupt ETIR record encountered"));
1928 bfd_set_error (bfd_error_bad_value
);
1935 _bfd_vms_debug (4, "etir: %s(%d)\n",
1936 _bfd_vms_etir_name (cmd
), cmd
);
1937 _bfd_hexdump (8, ptr
, cmd_length
, 0);
1945 stack 32 bit value of symbol (high bits set to 0). */
1946 case ETIR__C_STA_GBL
:
1947 _bfd_vms_get_value (abfd
, ptr
, ptr
+ cmd_length
, info
, &op1
, &h
);
1948 if (!_bfd_vms_push (abfd
, op1
, alpha_vms_sym_to_ctxt (h
)))
1955 stack 32 bit value, sign extend to 64 bit. */
1956 case ETIR__C_STA_LW
:
1959 if (!_bfd_vms_push (abfd
, bfd_getl32 (ptr
), RELC_NONE
))
1966 stack 64 bit value of symbol. */
1967 case ETIR__C_STA_QW
:
1970 if (!_bfd_vms_push (abfd
, bfd_getl64 (ptr
), RELC_NONE
))
1974 /* Stack psect base plus quadword offset
1975 arg: lw section index
1976 qw signed quadword offset (low 32 bits)
1978 Stack qw argument and section index
1979 (see ETIR__C_STO_OFF, ETIR__C_CTL_SETRB). */
1980 case ETIR__C_STA_PQ
:
1984 if (cmd_length
< 12)
1986 psect
= bfd_getl32 (ptr
);
1987 if ((unsigned int) psect
>= PRIV (section_count
))
1989 _bfd_error_handler (_("bad section index in %s"),
1990 _bfd_vms_etir_name (cmd
));
1991 bfd_set_error (bfd_error_bad_value
);
1994 op1
= bfd_getl64 (ptr
+ 4);
1995 if (!_bfd_vms_push (abfd
, op1
, psect
| RELC_SEC_BASE
))
2000 case ETIR__C_STA_LI
:
2001 case ETIR__C_STA_MOD
:
2002 case ETIR__C_STA_CKARG
:
2003 _bfd_error_handler (_("unsupported STA cmd %s"),
2004 _bfd_vms_etir_name (cmd
));
2008 /* Store byte: pop stack, write byte
2011 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2013 if (rel1
!= RELC_NONE
)
2015 if (!image_write_b (abfd
, (unsigned int) op1
& 0xff))
2019 /* Store word: pop stack, write word
2022 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2024 if (rel1
!= RELC_NONE
)
2026 if (!image_write_w (abfd
, (unsigned int) op1
& 0xffff))
2030 /* Store longword: pop stack, write longword
2032 case ETIR__C_STO_LW
:
2033 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2035 if (rel1
& RELC_SEC_BASE
)
2037 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2040 else if (rel1
& RELC_SHR_BASE
)
2042 if (!alpha_vms_add_fixup_lr (info
, rel1
& RELC_MASK
, op1
))
2046 if (rel1
!= RELC_NONE
)
2048 if (rel1
!= RELC_REL
)
2050 if (!alpha_vms_add_lw_reloc (info
))
2053 if (!image_write_l (abfd
, op1
))
2057 /* Store quadword: pop stack, write quadword
2059 case ETIR__C_STO_QW
:
2060 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2062 if (rel1
& RELC_SEC_BASE
)
2064 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2067 else if (rel1
& RELC_SHR_BASE
)
2069 if (rel1
!= RELC_NONE
)
2071 if (rel1
!= RELC_REL
)
2073 if (!alpha_vms_add_qw_reloc (info
))
2076 if (!image_write_q (abfd
, op1
))
2080 /* Store immediate repeated: pop stack for repeat count
2083 case ETIR__C_STO_IMMR
:
2089 size
= bfd_getl32 (ptr
);
2090 if (size
> cmd_length
- 4)
2092 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2094 if (rel1
!= RELC_NONE
)
2100 if (!image_write (abfd
, ptr
+ 4, size
))
2105 /* Store global: write symbol value
2106 arg: cs global symbol name. */
2107 case ETIR__C_STO_GBL
:
2108 _bfd_vms_get_value (abfd
, ptr
, ptr
+ cmd_length
, info
, &op1
, &h
);
2111 if (h
->sym
->typ
== EGSD__C_SYMG
)
2113 if (!alpha_vms_add_fixup_qr (info
, abfd
, h
->sym
->owner
,
2114 h
->sym
->symbol_vector
))
2120 op1
= alpha_vms_get_sym_value (h
->sym
->section
,
2122 if (!alpha_vms_add_qw_reloc (info
))
2126 if (!image_write_q (abfd
, op1
))
2130 /* Store code address: write address of entry point
2131 arg: cs global symbol name (procedure). */
2132 case ETIR__C_STO_CA
:
2133 _bfd_vms_get_value (abfd
, ptr
, ptr
+ cmd_length
, info
, &op1
, &h
);
2136 if (h
->sym
->flags
& EGSY__V_NORM
)
2138 /* That's really a procedure. */
2139 if (h
->sym
->typ
== EGSD__C_SYMG
)
2141 if (!alpha_vms_add_fixup_ca (info
, abfd
, h
->sym
->owner
))
2143 op1
= h
->sym
->symbol_vector
;
2147 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
2148 h
->sym
->code_value
);
2149 if (!alpha_vms_add_qw_reloc (info
))
2155 /* Symbol is not a procedure. */
2159 if (!image_write_q (abfd
, op1
))
2163 /* Store offset to psect: pop stack, add low 32 bits to base of psect
2165 case ETIR__C_STO_OFF
:
2166 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2169 if (!(rel1
& RELC_SEC_BASE
))
2172 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2174 if (!image_write_q (abfd
, op1
))
2179 arg: lw count of bytes
2181 case ETIR__C_STO_IMM
:
2187 size
= bfd_getl32 (ptr
);
2188 if (!image_write (abfd
, ptr
+ 4, size
))
2193 /* This code is 'reserved to digital' according to the openVMS
2194 linker manual, however it is generated by the DEC C compiler
2195 and defined in the include file.
2196 FIXME, since the following is just a guess
2197 store global longword: store 32bit value of symbol
2198 arg: cs symbol name. */
2199 case ETIR__C_STO_GBL_LW
:
2200 _bfd_vms_get_value (abfd
, ptr
, ptr
+ cmd_length
, info
, &op1
, &h
);
2204 if (!image_write_l (abfd
, op1
))
2208 case ETIR__C_STO_RB
:
2209 case ETIR__C_STO_AB
:
2210 case ETIR__C_STO_LP_PSB
:
2211 _bfd_error_handler (_("%s: not supported"),
2212 _bfd_vms_etir_name (cmd
));
2215 case ETIR__C_STO_HINT_GBL
:
2216 case ETIR__C_STO_HINT_PS
:
2217 _bfd_error_handler (_("%s: not implemented"),
2218 _bfd_vms_etir_name (cmd
));
2222 /* 200 Store-conditional Linkage Pair
2224 case ETIR__C_STC_LP
:
2226 /* 202 Store-conditional Address at global address
2230 case ETIR__C_STC_GBL
:
2232 /* 203 Store-conditional Code Address at global address
2234 cs procedure name. */
2235 case ETIR__C_STC_GCA
:
2237 /* 204 Store-conditional Address at psect + offset
2241 case ETIR__C_STC_PS
:
2242 _bfd_error_handler (_("%s: not supported"),
2243 _bfd_vms_etir_name (cmd
));
2247 /* 201 Store-conditional Linkage Pair with Procedure Signature
2253 case ETIR__C_STC_LP_PSB
:
2256 _bfd_vms_get_value (abfd
, ptr
+ 4, ptr
+ cmd_length
, info
, &op1
, &h
);
2259 if (h
->sym
->typ
== EGSD__C_SYMG
)
2261 if (!alpha_vms_add_fixup_lp (info
, abfd
, h
->sym
->owner
))
2263 op1
= h
->sym
->symbol_vector
;
2268 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
2269 h
->sym
->code_value
);
2270 op2
= alpha_vms_get_sym_value (h
->sym
->section
,
2276 /* Undefined symbol. */
2280 if (!image_write_q (abfd
, op1
)
2281 || !image_write_q (abfd
, op2
))
2285 /* 205 Store-conditional NOP at address of global
2287 case ETIR__C_STC_NOP_GBL
:
2290 /* 207 Store-conditional BSR at global address
2293 case ETIR__C_STC_BSR_GBL
:
2296 /* 209 Store-conditional LDA at global address
2299 case ETIR__C_STC_LDA_GBL
:
2302 /* 211 Store-conditional BSR or Hint at global address
2305 case ETIR__C_STC_BOH_GBL
:
2306 /* Currentl ignored. */
2309 /* 213 Store-conditional NOP,BSR or HINT at global address
2312 case ETIR__C_STC_NBH_GBL
:
2314 /* 206 Store-conditional NOP at pect + offset
2317 case ETIR__C_STC_NOP_PS
:
2319 /* 208 Store-conditional BSR at pect + offset
2322 case ETIR__C_STC_BSR_PS
:
2324 /* 210 Store-conditional LDA at psect + offset
2327 case ETIR__C_STC_LDA_PS
:
2329 /* 212 Store-conditional BSR or Hint at pect + offset
2332 case ETIR__C_STC_BOH_PS
:
2334 /* 214 Store-conditional NOP, BSR or HINT at psect + offset
2336 case ETIR__C_STC_NBH_PS
:
2337 _bfd_error_handler (_("%s: not supported"),
2338 _bfd_vms_etir_name (cmd
));
2342 /* Det relocation base: pop stack, set image location counter
2344 case ETIR__C_CTL_SETRB
:
2345 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2347 if (!(rel1
& RELC_SEC_BASE
))
2349 image_set_ptr (abfd
, op1
, rel1
& RELC_MASK
, info
);
2352 /* Augment relocation base: increment image location counter by offset
2353 arg: lw offset value. */
2354 case ETIR__C_CTL_AUGRB
:
2357 op1
= bfd_getl32 (ptr
);
2358 image_inc_ptr (abfd
, op1
);
2361 /* Define location: pop index, save location counter under index
2363 case ETIR__C_CTL_DFLOC
:
2364 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2366 if (rel1
!= RELC_NONE
)
2368 if (!dst_define_location (abfd
, op1
))
2372 /* Set location: pop index, restore location counter from index
2374 case ETIR__C_CTL_STLOC
:
2375 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2377 if (rel1
!= RELC_NONE
)
2379 if (!dst_restore_location (abfd
, op1
))
2381 bfd_set_error (bfd_error_bad_value
);
2382 _bfd_error_handler (_("invalid %s"), "ETIR__C_CTL_STLOC");
2387 /* Stack defined location: pop index, push location counter from index
2389 case ETIR__C_CTL_STKDL
:
2390 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2392 if (rel1
!= RELC_NONE
)
2394 if (!dst_retrieve_location (abfd
, &op1
))
2396 bfd_set_error (bfd_error_bad_value
);
2397 _bfd_error_handler (_("invalid %s"), "ETIR__C_CTL_STKDL");
2400 if (!_bfd_vms_push (abfd
, op1
, RELC_NONE
))
2404 case ETIR__C_OPR_NOP
: /* No-op. */
2407 case ETIR__C_OPR_ADD
: /* Add. */
2408 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2409 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2411 if (rel1
== RELC_NONE
&& rel2
!= RELC_NONE
)
2413 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2415 if (!_bfd_vms_push (abfd
, op1
+ op2
, rel1
))
2419 case ETIR__C_OPR_SUB
: /* Subtract. */
2420 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2421 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2423 if (rel1
== RELC_NONE
&& rel2
!= RELC_NONE
)
2425 else if ((rel1
& RELC_SEC_BASE
) && (rel2
& RELC_SEC_BASE
))
2427 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2428 op2
= alpha_vms_fix_sec_rel (abfd
, info
, rel2
, op2
);
2431 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2433 if (!_bfd_vms_push (abfd
, op2
- op1
, rel1
))
2437 case ETIR__C_OPR_MUL
: /* Multiply. */
2438 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2439 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2441 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2443 if (!_bfd_vms_push (abfd
, op1
* op2
, RELC_NONE
))
2447 case ETIR__C_OPR_DIV
: /* Divide. */
2448 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2449 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2451 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2455 /* Divide by zero is supposed to give a result of zero,
2456 and a non-fatal warning message. */
2457 _bfd_error_handler (_("%s divide by zero"), "ETIR__C_OPR_DIV");
2458 if (!_bfd_vms_push (abfd
, 0, RELC_NONE
))
2463 if (!_bfd_vms_push (abfd
, op2
/ op1
, RELC_NONE
))
2468 case ETIR__C_OPR_AND
: /* Logical AND. */
2469 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2470 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2472 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2474 if (!_bfd_vms_push (abfd
, op1
& op2
, RELC_NONE
))
2478 case ETIR__C_OPR_IOR
: /* Logical inclusive OR. */
2479 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2480 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2482 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2484 if (!_bfd_vms_push (abfd
, op1
| op2
, RELC_NONE
))
2488 case ETIR__C_OPR_EOR
: /* Logical exclusive OR. */
2489 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2490 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2492 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2494 if (!_bfd_vms_push (abfd
, op1
^ op2
, RELC_NONE
))
2498 case ETIR__C_OPR_NEG
: /* Negate. */
2499 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2501 if (rel1
!= RELC_NONE
)
2503 if (!_bfd_vms_push (abfd
, -op1
, RELC_NONE
))
2507 case ETIR__C_OPR_COM
: /* Complement. */
2508 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2510 if (rel1
!= RELC_NONE
)
2512 if (!_bfd_vms_push (abfd
, ~op1
, RELC_NONE
))
2516 case ETIR__C_OPR_ASH
: /* Arithmetic shift. */
2517 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2518 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2520 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2523 _bfd_error_handler (_("invalid use of %s with contexts"),
2524 _bfd_vms_etir_name (cmd
));
2527 if ((bfd_signed_vma
) op2
< 0)
2532 if (op2
>= CHAR_BIT
* sizeof (op1
))
2533 op2
= CHAR_BIT
* sizeof (op1
) - 1;
2534 /* op1 = (bfd_signed_vma) op1 >> op2; */
2535 sign
= op1
& ((bfd_vma
) 1 << (CHAR_BIT
* sizeof (op1
) - 1));
2538 op1
= (op1
^ sign
) - sign
;
2543 if (op2
>= CHAR_BIT
* sizeof (op1
))
2548 if (!_bfd_vms_push (abfd
, op1
, RELC_NONE
)) /* FIXME: sym. */
2552 case ETIR__C_OPR_INSV
: /* Insert field. */
2553 case ETIR__C_OPR_USH
: /* Unsigned shift. */
2554 case ETIR__C_OPR_ROT
: /* Rotate. */
2555 case ETIR__C_OPR_REDEF
: /* Redefine symbol to current location. */
2556 case ETIR__C_OPR_DFLIT
: /* Define a literal. */
2557 _bfd_error_handler (_("%s: not supported"),
2558 _bfd_vms_etir_name (cmd
));
2562 case ETIR__C_OPR_SEL
: /* Select. */
2563 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2567 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2572 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2573 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2575 if (!_bfd_vms_push (abfd
, op1
, rel1
))
2581 _bfd_error_handler (_("reserved cmd %d"), cmd
);
2592 /* Process EDBG/ETBT record.
2593 Return TRUE on success, FALSE on error */
2596 vms_slurp_debug (bfd
*abfd
)
2598 asection
*section
= PRIV (dst_section
);
2600 if (section
== NULL
)
2602 /* We have no way to find out beforehand how much debug info there
2603 is in an object file, so pick an initial amount and grow it as
2605 flagword flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
| SEC_RELOC
2608 section
= bfd_make_section (abfd
, "$DST$");
2611 if (!bfd_set_section_flags (section
, flags
))
2613 PRIV (dst_section
) = section
;
2616 PRIV (image_section
) = section
;
2617 PRIV (image_offset
) = section
->size
;
2619 if (!_bfd_vms_slurp_etir (abfd
, NULL
))
2622 section
->size
= PRIV (image_offset
);
2626 /* Process EDBG record.
2627 Return TRUE on success, FALSE on error. */
2630 _bfd_vms_slurp_edbg (bfd
*abfd
)
2632 vms_debug2 ((2, "EDBG\n"));
2634 abfd
->flags
|= HAS_DEBUG
| HAS_LINENO
;
2636 return vms_slurp_debug (abfd
);
2639 /* Process ETBT record.
2640 Return TRUE on success, FALSE on error. */
2643 _bfd_vms_slurp_etbt (bfd
*abfd
)
2645 vms_debug2 ((2, "ETBT\n"));
2647 abfd
->flags
|= HAS_LINENO
;
2649 return vms_slurp_debug (abfd
);
2652 /* Process EEOM record.
2653 Return TRUE on success, FALSE on error. */
2656 _bfd_vms_slurp_eeom (bfd
*abfd
)
2658 struct vms_eeom
*eeom
= (struct vms_eeom
*) PRIV (recrd
.rec
);
2660 vms_debug2 ((2, "EEOM\n"));
2662 /* PR 21813: Check for an undersized record. */
2663 if (PRIV (recrd
.buf_size
) < sizeof (* eeom
))
2665 _bfd_error_handler (_("corrupt EEOM record - size is too small"));
2666 bfd_set_error (bfd_error_bad_value
);
2670 PRIV (eom_data
).eom_l_total_lps
= bfd_getl32 (eeom
->total_lps
);
2671 PRIV (eom_data
).eom_w_comcod
= bfd_getl16 (eeom
->comcod
);
2672 if (PRIV (eom_data
).eom_w_comcod
> 1)
2674 _bfd_error_handler (_("object module not error-free !"));
2675 bfd_set_error (bfd_error_bad_value
);
2679 PRIV (eom_data
).eom_has_transfer
= FALSE
;
2680 if (PRIV (recrd
.rec_size
) > 10)
2682 PRIV (eom_data
).eom_has_transfer
= TRUE
;
2683 PRIV (eom_data
).eom_b_tfrflg
= eeom
->tfrflg
;
2684 PRIV (eom_data
).eom_l_psindx
= bfd_getl32 (eeom
->psindx
);
2685 PRIV (eom_data
).eom_l_tfradr
= bfd_getl32 (eeom
->tfradr
);
2687 abfd
->start_address
= PRIV (eom_data
).eom_l_tfradr
;
2692 /* Slurp an ordered set of VMS object records. Return FALSE on error. */
2695 _bfd_vms_slurp_object_records (bfd
* abfd
)
2702 vms_debug2 ((7, "reading at %08lx\n", (unsigned long)bfd_tell (abfd
)));
2704 type
= _bfd_vms_get_object_record (abfd
);
2707 vms_debug2 ((2, "next_record failed\n"));
2714 ok
= _bfd_vms_slurp_ehdr (abfd
);
2717 ok
= _bfd_vms_slurp_eeom (abfd
);
2720 ok
= _bfd_vms_slurp_egsd (abfd
);
2723 ok
= TRUE
; /* _bfd_vms_slurp_etir (abfd); */
2726 ok
= _bfd_vms_slurp_edbg (abfd
);
2729 ok
= _bfd_vms_slurp_etbt (abfd
);
2736 vms_debug2 ((2, "slurp type %d failed\n", type
));
2740 while (type
!= EOBJ__C_EEOM
);
2745 /* Initialize private data */
2747 vms_initialize (bfd
* abfd
)
2751 amt
= sizeof (struct vms_private_data_struct
);
2752 abfd
->tdata
.any
= bfd_zalloc (abfd
, amt
);
2753 if (abfd
->tdata
.any
== NULL
)
2756 PRIV (recrd
.file_format
) = FF_UNKNOWN
;
2758 amt
= sizeof (struct stack_struct
) * STACKSIZE
;
2759 PRIV (stack
) = bfd_alloc (abfd
, amt
);
2760 if (PRIV (stack
) == NULL
)
2766 bfd_release (abfd
, abfd
->tdata
.any
);
2767 abfd
->tdata
.any
= NULL
;
2771 /* Free malloc'd memory. */
2774 alpha_vms_free_private (bfd
*abfd
)
2776 struct module
*module
;
2778 free (PRIV (recrd
.buf
));
2779 free (PRIV (sections
));
2781 free (PRIV (dst_ptr_offsets
));
2783 for (module
= PRIV (modules
); module
; module
= module
->next
)
2784 free (module
->file_table
);
2787 /* Check the format for a file being read.
2788 Return a (bfd_target *) if it's an object file or zero if not. */
2791 alpha_vms_object_p (bfd
*abfd
)
2793 void *tdata_save
= abfd
->tdata
.any
;
2794 unsigned int test_len
;
2797 vms_debug2 ((1, "vms_object_p(%p)\n", abfd
));
2799 /* Allocate alpha-vms specific data. */
2800 if (!vms_initialize (abfd
))
2802 abfd
->tdata
.any
= tdata_save
;
2806 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
))
2809 /* The first challenge with VMS is to discover the kind of the file.
2811 Image files (executable or shared images) are stored as a raw
2812 stream of bytes (like on UNIX), but there is no magic number.
2814 Object files are written with RMS (record management service), ie
2815 each records are preceeded by its length (on a word - 2 bytes), and
2816 padded for word-alignment. That would be simple but when files
2817 are transfered to a UNIX filesystem (using ftp), records are lost.
2818 Only the raw content of the records are transfered. Fortunately,
2819 the Alpha Object file format also store the length of the record
2820 in the records. Is that clear ? */
2822 /* Minimum is 6 bytes for objects (2 bytes size, 2 bytes record id,
2823 2 bytes size repeated) and 12 bytes for images (4 bytes major id,
2824 4 bytes minor id, 4 bytes length). */
2826 buf
= _bfd_malloc_and_read (abfd
, test_len
, test_len
);
2829 PRIV (recrd
.buf
) = buf
;
2830 PRIV (recrd
.buf_size
) = test_len
;
2831 PRIV (recrd
.rec
) = buf
;
2833 /* Is it an image? */
2834 if ((bfd_getl32 (buf
) == EIHD__K_MAJORID
)
2835 && (bfd_getl32 (buf
+ 4) == EIHD__K_MINORID
))
2837 unsigned int eisd_offset
, eihs_offset
;
2839 /* Extract the header size. */
2840 PRIV (recrd
.rec_size
) = bfd_getl32 (buf
+ EIHD__L_SIZE
);
2842 /* The header size is 0 for DSF files. */
2843 if (PRIV (recrd
.rec_size
) == 0)
2844 PRIV (recrd
.rec_size
) = sizeof (struct vms_eihd
);
2846 /* PR 21813: Check for a truncated record. */
2847 /* PR 17512: file: 7d7c57c2. */
2848 if (PRIV (recrd
.rec_size
) < sizeof (struct vms_eihd
))
2849 goto err_wrong_format
;
2851 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
))
2854 free (PRIV (recrd
.buf
));
2855 PRIV (recrd
.buf
) = NULL
;
2856 buf
= _bfd_malloc_and_read (abfd
, PRIV (recrd
.rec_size
),
2857 PRIV (recrd
.rec_size
));
2861 PRIV (recrd
.buf
) = buf
;
2862 PRIV (recrd
.buf_size
) = PRIV (recrd
.rec_size
);
2863 PRIV (recrd
.rec
) = buf
;
2865 vms_debug2 ((2, "file type is image\n"));
2867 if (!_bfd_vms_slurp_eihd (abfd
, &eisd_offset
, &eihs_offset
))
2868 goto err_wrong_format
;
2870 if (!_bfd_vms_slurp_eisd (abfd
, eisd_offset
))
2871 goto err_wrong_format
;
2873 /* EIHS is optional. */
2874 if (eihs_offset
!= 0 && !_bfd_vms_slurp_eihs (abfd
, eihs_offset
))
2875 goto err_wrong_format
;
2881 /* Assume it's a module and adjust record pointer if necessary. */
2882 maybe_adjust_record_pointer_for_object (abfd
);
2884 /* But is it really a module? */
2885 if (bfd_getl16 (PRIV (recrd
.rec
)) <= EOBJ__C_MAXRECTYP
2886 && bfd_getl16 (PRIV (recrd
.rec
) + 2) <= EOBJ__C_MAXRECSIZ
)
2888 if (vms_get_remaining_object_record (abfd
, test_len
) <= 0)
2889 goto err_wrong_format
;
2891 vms_debug2 ((2, "file type is module\n"));
2893 type
= bfd_getl16 (PRIV (recrd
.rec
));
2894 if (type
!= EOBJ__C_EMH
|| !_bfd_vms_slurp_ehdr (abfd
))
2895 goto err_wrong_format
;
2897 if (!_bfd_vms_slurp_object_records (abfd
))
2898 goto err_wrong_format
;
2901 goto err_wrong_format
;
2904 /* Set arch_info to alpha. */
2906 if (! bfd_default_set_arch_mach (abfd
, bfd_arch_alpha
, 0))
2907 goto err_wrong_format
;
2909 return alpha_vms_free_private
;
2912 bfd_set_error (bfd_error_wrong_format
);
2915 alpha_vms_free_private (abfd
);
2916 if (abfd
->tdata
.any
!= tdata_save
&& abfd
->tdata
.any
!= NULL
)
2917 bfd_release (abfd
, abfd
->tdata
.any
);
2918 abfd
->tdata
.any
= tdata_save
;
2924 /* Write an EMH/MHD record. */
2927 _bfd_vms_write_emh (bfd
*abfd
)
2929 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2930 unsigned char tbuf
[18];
2932 _bfd_vms_output_alignment (recwr
, 2);
2935 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
2936 _bfd_vms_output_short (recwr
, EMH__C_MHD
);
2937 _bfd_vms_output_short (recwr
, EOBJ__C_STRLVL
);
2938 _bfd_vms_output_long (recwr
, 0);
2939 _bfd_vms_output_long (recwr
, 0);
2940 _bfd_vms_output_long (recwr
, MAX_OUTREC_SIZE
);
2942 /* Create module name from filename. */
2943 if (bfd_get_filename (abfd
) != 0)
2945 char *module
= vms_get_module_name (bfd_get_filename (abfd
), TRUE
);
2946 _bfd_vms_output_counted (recwr
, module
);
2950 _bfd_vms_output_counted (recwr
, "NONAME");
2952 _bfd_vms_output_counted (recwr
, BFD_VERSION_STRING
);
2953 _bfd_vms_output_dump (recwr
, get_vms_time_string (tbuf
), EMH_DATE_LENGTH
);
2954 _bfd_vms_output_fill (recwr
, 0, EMH_DATE_LENGTH
);
2955 _bfd_vms_output_end (abfd
, recwr
);
2958 /* Write an EMH/LMN record. */
2961 _bfd_vms_write_lmn (bfd
*abfd
, const char *name
)
2964 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2965 unsigned int ver
= BFD_VERSION
/ 10000;
2968 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
2969 _bfd_vms_output_short (recwr
, EMH__C_LNM
);
2970 snprintf (version
, sizeof (version
), "%s %d.%d.%d", name
,
2971 ver
/ 10000, (ver
/ 100) % 100, ver
% 100);
2972 _bfd_vms_output_dump (recwr
, (unsigned char *)version
, strlen (version
));
2973 _bfd_vms_output_end (abfd
, recwr
);
2977 /* Write eom record for bfd abfd. Return FALSE on error. */
2980 _bfd_vms_write_eeom (bfd
*abfd
)
2982 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2984 vms_debug2 ((2, "vms_write_eeom\n"));
2986 _bfd_vms_output_alignment (recwr
, 2);
2988 _bfd_vms_output_begin (recwr
, EOBJ__C_EEOM
);
2989 _bfd_vms_output_long (recwr
, PRIV (vms_linkage_index
+ 1) >> 1);
2990 _bfd_vms_output_byte (recwr
, 0); /* Completion code. */
2991 _bfd_vms_output_byte (recwr
, 0); /* Fill byte. */
2993 if ((abfd
->flags
& EXEC_P
) == 0
2994 && bfd_get_start_address (abfd
) != (bfd_vma
)-1)
2998 section
= bfd_get_section_by_name (abfd
, ".link");
3001 bfd_set_error (bfd_error_nonrepresentable_section
);
3004 _bfd_vms_output_short (recwr
, 0);
3005 _bfd_vms_output_long (recwr
, (unsigned long) section
->target_index
);
3006 _bfd_vms_output_long (recwr
,
3007 (unsigned long) bfd_get_start_address (abfd
));
3008 _bfd_vms_output_long (recwr
, 0);
3011 _bfd_vms_output_end (abfd
, recwr
);
3016 vector_grow1 (struct vector_type
*vec
, size_t elsz
)
3018 if (vec
->nbr_el
>= vec
->max_el
)
3020 if (vec
->max_el
== 0)
3023 vec
->els
= bfd_malloc (vec
->max_el
* elsz
);
3028 if (vec
->max_el
> -1u / 2)
3030 bfd_set_error (bfd_error_file_too_big
);
3034 if (_bfd_mul_overflow (vec
->max_el
, elsz
, &amt
))
3036 bfd_set_error (bfd_error_file_too_big
);
3039 vec
->els
= bfd_realloc_or_free (vec
->els
, amt
);
3042 if (vec
->els
== NULL
)
3044 return (char *) vec
->els
+ elsz
* vec
->nbr_el
++;
3047 /* Bump ABFD file position to next block. */
3050 alpha_vms_file_position_block (bfd
*abfd
)
3053 PRIV (file_pos
) += VMS_BLOCK_SIZE
- 1;
3054 PRIV (file_pos
) -= (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
3057 /* Convert from internal structure SRC to external structure DST. */
3060 alpha_vms_swap_eisd_out (struct vms_internal_eisd_map
*src
,
3061 struct vms_eisd
*dst
)
3063 bfd_putl32 (src
->u
.eisd
.majorid
, dst
->majorid
);
3064 bfd_putl32 (src
->u
.eisd
.minorid
, dst
->minorid
);
3065 bfd_putl32 (src
->u
.eisd
.eisdsize
, dst
->eisdsize
);
3066 if (src
->u
.eisd
.eisdsize
<= EISD__K_LENEND
)
3068 bfd_putl32 (src
->u
.eisd
.secsize
, dst
->secsize
);
3069 bfd_putl64 (src
->u
.eisd
.virt_addr
, dst
->virt_addr
);
3070 bfd_putl32 (src
->u
.eisd
.flags
, dst
->flags
);
3071 bfd_putl32 (src
->u
.eisd
.vbn
, dst
->vbn
);
3072 dst
->pfc
= src
->u
.eisd
.pfc
;
3073 dst
->matchctl
= src
->u
.eisd
.matchctl
;
3074 dst
->type
= src
->u
.eisd
.type
;
3076 if (src
->u
.eisd
.flags
& EISD__M_GBL
)
3078 bfd_putl32 (src
->u
.gbl_eisd
.ident
, dst
->ident
);
3079 memcpy (dst
->gblnam
, src
->u
.gbl_eisd
.gblnam
,
3080 src
->u
.gbl_eisd
.gblnam
[0] + 1);
3084 /* Append EISD to the list of extra eisd for ABFD. */
3087 alpha_vms_append_extra_eisd (bfd
*abfd
, struct vms_internal_eisd_map
*eisd
)
3090 if (PRIV (gbl_eisd_head
) == NULL
)
3091 PRIV (gbl_eisd_head
) = eisd
;
3093 PRIV (gbl_eisd_tail
)->next
= eisd
;
3094 PRIV (gbl_eisd_tail
) = eisd
;
3097 /* Create an EISD for shared image SHRIMG.
3098 Return FALSE in case of error. */
3101 alpha_vms_create_eisd_for_shared (bfd
*abfd
, bfd
*shrimg
)
3103 struct vms_internal_eisd_map
*eisd
;
3106 namlen
= strlen (PRIV2 (shrimg
, hdr_data
.hdr_t_name
));
3107 if (namlen
+ 5 > EISD__K_GBLNAMLEN
)
3113 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
3117 /* Fill the fields. */
3118 eisd
->u
.gbl_eisd
.common
.majorid
= EISD__K_MAJORID
;
3119 eisd
->u
.gbl_eisd
.common
.minorid
= EISD__K_MINORID
;
3120 eisd
->u
.gbl_eisd
.common
.eisdsize
= (EISD__K_LEN
+ 4 + namlen
+ 5 + 3) & ~3;
3121 eisd
->u
.gbl_eisd
.common
.secsize
= VMS_BLOCK_SIZE
; /* Must not be 0. */
3122 eisd
->u
.gbl_eisd
.common
.virt_addr
= 0;
3123 eisd
->u
.gbl_eisd
.common
.flags
= EISD__M_GBL
;
3124 eisd
->u
.gbl_eisd
.common
.vbn
= 0;
3125 eisd
->u
.gbl_eisd
.common
.pfc
= 0;
3126 eisd
->u
.gbl_eisd
.common
.matchctl
= PRIV2 (shrimg
, matchctl
);
3127 eisd
->u
.gbl_eisd
.common
.type
= EISD__K_SHRPIC
;
3129 eisd
->u
.gbl_eisd
.ident
= PRIV2 (shrimg
, ident
);
3130 eisd
->u
.gbl_eisd
.gblnam
[0] = namlen
+ 4;
3131 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1, PRIV2 (shrimg
, hdr_data
.hdr_t_name
),
3133 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1 + namlen
, "_001", 4);
3135 /* Append it to the list. */
3136 alpha_vms_append_extra_eisd (abfd
, eisd
);
3141 /* Create an EISD for section SEC.
3142 Return FALSE in case of failure. */
3145 alpha_vms_create_eisd_for_section (bfd
*abfd
, asection
*sec
)
3147 struct vms_internal_eisd_map
*eisd
;
3149 /* Only for allocating section. */
3150 if (!(sec
->flags
& SEC_ALLOC
))
3153 BFD_ASSERT (vms_section_data (sec
)->eisd
== NULL
);
3154 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
3157 vms_section_data (sec
)->eisd
= eisd
;
3159 /* Fill the fields. */
3160 eisd
->u
.eisd
.majorid
= EISD__K_MAJORID
;
3161 eisd
->u
.eisd
.minorid
= EISD__K_MINORID
;
3162 eisd
->u
.eisd
.eisdsize
= EISD__K_LEN
;
3163 eisd
->u
.eisd
.secsize
=
3164 (sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
3165 eisd
->u
.eisd
.virt_addr
= sec
->vma
;
3166 eisd
->u
.eisd
.flags
= 0;
3167 eisd
->u
.eisd
.vbn
= 0; /* To be later defined. */
3168 eisd
->u
.eisd
.pfc
= 0; /* Default. */
3169 eisd
->u
.eisd
.matchctl
= EISD__K_MATALL
;
3170 eisd
->u
.eisd
.type
= EISD__K_NORMAL
;
3172 if (sec
->flags
& SEC_CODE
)
3173 eisd
->u
.eisd
.flags
|= EISD__M_EXE
;
3174 if (!(sec
->flags
& SEC_READONLY
))
3175 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
3177 /* If relocations or fixup will be applied, make this isect writeable. */
3178 if (sec
->flags
& SEC_RELOC
)
3179 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
3181 if (!(sec
->flags
& SEC_HAS_CONTENTS
))
3183 eisd
->u
.eisd
.flags
|= EISD__M_DZRO
;
3184 eisd
->u
.eisd
.flags
&= ~EISD__M_CRF
;
3186 if (sec
->flags
& SEC_LINKER_CREATED
)
3188 if (strcmp (sec
->name
, "$FIXUP$") == 0)
3189 eisd
->u
.eisd
.flags
|= EISD__M_FIXUPVEC
;
3192 /* Append it to the list. */
3194 if (PRIV (eisd_head
) == NULL
)
3195 PRIV (eisd_head
) = eisd
;
3197 PRIV (eisd_tail
)->next
= eisd
;
3198 PRIV (eisd_tail
) = eisd
;
3203 /* Layout executable ABFD and write it to the disk.
3204 Return FALSE in case of failure. */
3207 alpha_vms_write_exec (bfd
*abfd
)
3209 struct vms_eihd eihd
;
3210 struct vms_eiha
*eiha
;
3211 struct vms_eihi
*eihi
;
3212 struct vms_eihs
*eihs
= NULL
;
3214 struct vms_internal_eisd_map
*first_eisd
;
3215 struct vms_internal_eisd_map
*eisd
;
3218 file_ptr gst_filepos
= 0;
3219 unsigned int lnkflags
= 0;
3221 /* Build the EIHD. */
3222 PRIV (file_pos
) = EIHD__C_LENGTH
;
3224 memset (&eihd
, 0, sizeof (eihd
));
3225 memset (eihd
.fill_2
, 0xff, sizeof (eihd
.fill_2
));
3227 bfd_putl32 (EIHD__K_MAJORID
, eihd
.majorid
);
3228 bfd_putl32 (EIHD__K_MINORID
, eihd
.minorid
);
3230 bfd_putl32 (sizeof (eihd
), eihd
.size
);
3231 bfd_putl32 (0, eihd
.isdoff
);
3232 bfd_putl32 (0, eihd
.activoff
);
3233 bfd_putl32 (0, eihd
.symdbgoff
);
3234 bfd_putl32 (0, eihd
.imgidoff
);
3235 bfd_putl32 (0, eihd
.patchoff
);
3236 bfd_putl64 (0, eihd
.iafva
);
3237 bfd_putl32 (0, eihd
.version_array_off
);
3239 bfd_putl32 (EIHD__K_EXE
, eihd
.imgtype
);
3240 bfd_putl32 (0, eihd
.subtype
);
3242 bfd_putl32 (0, eihd
.imgiocnt
);
3243 bfd_putl32 (-1, eihd
.privreqs
);
3244 bfd_putl32 (-1, eihd
.privreqs
+ 4);
3246 bfd_putl32 ((sizeof (eihd
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
3248 bfd_putl32 (0, eihd
.ident
);
3249 bfd_putl32 (0, eihd
.sysver
);
3252 bfd_putl32 (0, eihd
.symvect_size
);
3253 bfd_putl32 (16, eihd
.virt_mem_block_size
);
3254 bfd_putl32 (0, eihd
.ext_fixup_off
);
3255 bfd_putl32 (0, eihd
.noopt_psect_off
);
3256 bfd_putl16 (-1, eihd
.alias
);
3259 eiha
= (struct vms_eiha
*)((char *) &eihd
+ PRIV (file_pos
));
3260 bfd_putl32 (PRIV (file_pos
), eihd
.activoff
);
3261 PRIV (file_pos
) += sizeof (struct vms_eiha
);
3263 bfd_putl32 (sizeof (struct vms_eiha
), eiha
->size
);
3264 bfd_putl32 (0, eiha
->spare
);
3265 bfd_putl64 (PRIV (transfer_address
[0]), eiha
->tfradr1
);
3266 bfd_putl64 (PRIV (transfer_address
[1]), eiha
->tfradr2
);
3267 bfd_putl64 (PRIV (transfer_address
[2]), eiha
->tfradr3
);
3268 bfd_putl64 (PRIV (transfer_address
[3]), eiha
->tfradr4
);
3269 bfd_putl64 (0, eiha
->inishr
);
3272 eihi
= (struct vms_eihi
*)((char *) &eihd
+ PRIV (file_pos
));
3273 bfd_putl32 (PRIV (file_pos
), eihd
.imgidoff
);
3274 PRIV (file_pos
) += sizeof (struct vms_eihi
);
3276 bfd_putl32 (EIHI__K_MAJORID
, eihi
->majorid
);
3277 bfd_putl32 (EIHI__K_MINORID
, eihi
->minorid
);
3282 /* Set module name. */
3283 module
= vms_get_module_name (bfd_get_filename (abfd
), TRUE
);
3284 len
= strlen (module
);
3285 if (len
> sizeof (eihi
->imgnam
) - 1)
3286 len
= sizeof (eihi
->imgnam
) - 1;
3287 eihi
->imgnam
[0] = len
;
3288 memcpy (eihi
->imgnam
+ 1, module
, len
);
3296 vms_get_time (&hi
, &lo
);
3297 bfd_putl32 (lo
, eihi
->linktime
+ 0);
3298 bfd_putl32 (hi
, eihi
->linktime
+ 4);
3301 eihi
->linkid
[0] = 0;
3302 eihi
->imgbid
[0] = 0;
3305 dst
= PRIV (dst_section
);
3306 dmt
= bfd_get_section_by_name (abfd
, "$DMT$");
3307 if (dst
!= NULL
&& dst
->size
!= 0)
3309 eihs
= (struct vms_eihs
*)((char *) &eihd
+ PRIV (file_pos
));
3310 bfd_putl32 (PRIV (file_pos
), eihd
.symdbgoff
);
3311 PRIV (file_pos
) += sizeof (struct vms_eihs
);
3313 bfd_putl32 (EIHS__K_MAJORID
, eihs
->majorid
);
3314 bfd_putl32 (EIHS__K_MINORID
, eihs
->minorid
);
3315 bfd_putl32 (0, eihs
->dstvbn
);
3316 bfd_putl32 (0, eihs
->dstsize
);
3317 bfd_putl32 (0, eihs
->gstvbn
);
3318 bfd_putl32 (0, eihs
->gstsize
);
3319 bfd_putl32 (0, eihs
->dmtvbn
);
3320 bfd_putl32 (0, eihs
->dmtsize
);
3323 /* One EISD per section. */
3324 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3326 if (!alpha_vms_create_eisd_for_section (abfd
, sec
))
3330 /* Merge section EIDS which extra ones. */
3331 if (PRIV (eisd_tail
))
3332 PRIV (eisd_tail
)->next
= PRIV (gbl_eisd_head
);
3334 PRIV (eisd_head
) = PRIV (gbl_eisd_head
);
3335 if (PRIV (gbl_eisd_tail
))
3336 PRIV (eisd_tail
) = PRIV (gbl_eisd_tail
);
3338 first_eisd
= PRIV (eisd_head
);
3340 /* Add end of eisd. */
3343 eisd
= bfd_zalloc (abfd
, sizeof (*eisd
));
3346 eisd
->u
.eisd
.majorid
= 0;
3347 eisd
->u
.eisd
.minorid
= 0;
3348 eisd
->u
.eisd
.eisdsize
= 0;
3349 alpha_vms_append_extra_eisd (abfd
, eisd
);
3352 /* Place EISD in the file. */
3353 for (eisd
= first_eisd
; eisd
; eisd
= eisd
->next
)
3355 file_ptr room
= VMS_BLOCK_SIZE
- (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
3357 /* First block is a little bit special: there is a word at the end. */
3358 if (PRIV (file_pos
) < VMS_BLOCK_SIZE
&& room
> 2)
3360 if (room
< eisd
->u
.eisd
.eisdsize
+ EISD__K_LENEND
)
3361 alpha_vms_file_position_block (abfd
);
3363 eisd
->file_pos
= PRIV (file_pos
);
3364 PRIV (file_pos
) += eisd
->u
.eisd
.eisdsize
;
3366 if (eisd
->u
.eisd
.flags
& EISD__M_FIXUPVEC
)
3367 bfd_putl64 (eisd
->u
.eisd
.virt_addr
, eihd
.iafva
);
3370 if (first_eisd
!= NULL
)
3372 bfd_putl32 (first_eisd
->file_pos
, eihd
.isdoff
);
3373 /* Real size of end of eisd marker. */
3374 PRIV (file_pos
) += EISD__K_LENEND
;
3377 bfd_putl32 (PRIV (file_pos
), eihd
.size
);
3378 bfd_putl32 ((PRIV (file_pos
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
3381 /* Place sections. */
3382 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3384 if (!(sec
->flags
& SEC_HAS_CONTENTS
))
3387 eisd
= vms_section_data (sec
)->eisd
;
3389 /* Align on a block. */
3390 alpha_vms_file_position_block (abfd
);
3391 sec
->filepos
= PRIV (file_pos
);
3394 eisd
->u
.eisd
.vbn
= (sec
->filepos
/ VMS_BLOCK_SIZE
) + 1;
3396 PRIV (file_pos
) += sec
->size
;
3400 if (eihs
!= NULL
&& dst
!= NULL
)
3402 bfd_putl32 ((dst
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dstvbn
);
3403 bfd_putl32 (dst
->size
, eihs
->dstsize
);
3407 lnkflags
|= EIHD__M_DBGDMT
;
3408 bfd_putl32 ((dmt
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dmtvbn
);
3409 bfd_putl32 (dmt
->size
, eihs
->dmtsize
);
3411 if (PRIV (gsd_sym_count
) != 0)
3413 alpha_vms_file_position_block (abfd
);
3414 gst_filepos
= PRIV (file_pos
);
3415 bfd_putl32 ((gst_filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->gstvbn
);
3416 bfd_putl32 ((PRIV (gsd_sym_count
) + 4) / 5 + 4, eihs
->gstsize
);
3420 /* Write EISD in hdr. */
3421 for (eisd
= first_eisd
; eisd
&& eisd
->file_pos
< VMS_BLOCK_SIZE
;
3423 alpha_vms_swap_eisd_out
3424 (eisd
, (struct vms_eisd
*)((char *)&eihd
+ eisd
->file_pos
));
3426 /* Write first block. */
3427 bfd_putl32 (lnkflags
, eihd
.lnkflags
);
3428 if (bfd_bwrite (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
3431 /* Write remaining eisd. */
3434 unsigned char blk
[VMS_BLOCK_SIZE
];
3435 struct vms_internal_eisd_map
*next_eisd
;
3437 memset (blk
, 0xff, sizeof (blk
));
3438 while (eisd
!= NULL
)
3440 alpha_vms_swap_eisd_out
3442 (struct vms_eisd
*)(blk
+ (eisd
->file_pos
% VMS_BLOCK_SIZE
)));
3444 next_eisd
= eisd
->next
;
3445 if (next_eisd
== NULL
3446 || (next_eisd
->file_pos
/ VMS_BLOCK_SIZE
3447 != eisd
->file_pos
/ VMS_BLOCK_SIZE
))
3449 if (bfd_bwrite (blk
, sizeof (blk
), abfd
) != sizeof (blk
))
3452 memset (blk
, 0xff, sizeof (blk
));
3458 /* Write sections. */
3459 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3461 unsigned char blk
[VMS_BLOCK_SIZE
];
3464 if (sec
->size
== 0 || !(sec
->flags
& SEC_HAS_CONTENTS
))
3466 if (bfd_bwrite (sec
->contents
, sec
->size
, abfd
) != sec
->size
)
3470 len
= VMS_BLOCK_SIZE
- sec
->size
% VMS_BLOCK_SIZE
;
3471 if (len
!= VMS_BLOCK_SIZE
)
3473 memset (blk
, 0, len
);
3474 if (bfd_bwrite (blk
, len
, abfd
) != len
)
3480 if (gst_filepos
!= 0)
3482 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3485 _bfd_vms_write_emh (abfd
);
3486 _bfd_vms_write_lmn (abfd
, "GNU LD");
3488 /* PSC for the absolute section. */
3489 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3490 _bfd_vms_output_long (recwr
, 0);
3491 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3492 _bfd_vms_output_short (recwr
, 0);
3493 _bfd_vms_output_short (recwr
, EGPS__V_PIC
| EGPS__V_LIB
| EGPS__V_RD
);
3494 _bfd_vms_output_long (recwr
, 0);
3495 _bfd_vms_output_counted (recwr
, ".$$ABS$$.");
3496 _bfd_vms_output_end_subrec (recwr
);
3497 _bfd_vms_output_end (abfd
, recwr
);
3499 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
3501 struct vms_symbol_entry
*sym
= PRIV (syms
)[i
];
3507 _bfd_vms_output_alignment (recwr
, 8);
3508 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3509 _bfd_vms_output_long (recwr
, 0);
3511 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYMG
);
3512 _bfd_vms_output_short (recwr
, 0); /* Data type, alignment. */
3513 _bfd_vms_output_short (recwr
, sym
->flags
);
3515 if (sym
->code_section
)
3516 ep
= alpha_vms_get_sym_value (sym
->code_section
, sym
->code_value
);
3519 BFD_ASSERT (sym
->code_value
== 0);
3522 val
= alpha_vms_get_sym_value (sym
->section
, sym
->value
);
3523 _bfd_vms_output_quad
3524 (recwr
, sym
->typ
== EGSD__C_SYMG
? sym
->symbol_vector
: val
);
3525 _bfd_vms_output_quad (recwr
, ep
);
3526 _bfd_vms_output_quad (recwr
, val
);
3527 _bfd_vms_output_long (recwr
, 0);
3528 _bfd_vms_output_counted (recwr
, sym
->name
);
3529 _bfd_vms_output_end_subrec (recwr
);
3531 _bfd_vms_output_end (abfd
, recwr
);
3534 _bfd_vms_output_end (abfd
, recwr
);
3536 if (!_bfd_vms_write_eeom (abfd
))
3544 /* Write section and symbol directory of bfd abfd. Return FALSE on error. */
3547 _bfd_vms_write_egsd (bfd
*abfd
)
3551 unsigned int symnum
;
3553 flagword new_flags
, old_flags
;
3554 int abs_section_index
= -1;
3555 unsigned int target_index
= 0;
3556 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3558 vms_debug2 ((2, "vms_write_egsd\n"));
3560 /* Egsd is quadword aligned. */
3561 _bfd_vms_output_alignment (recwr
, 8);
3563 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3564 _bfd_vms_output_long (recwr
, 0);
3566 /* Number sections. */
3567 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3569 if (section
->flags
& SEC_DEBUGGING
)
3571 if (!strcmp (section
->name
, ".vmsdebug"))
3573 section
->flags
|= SEC_DEBUGGING
;
3576 section
->target_index
= target_index
++;
3579 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3581 vms_debug2 ((3, "Section #%d %s, %d bytes\n",
3582 section
->target_index
, section
->name
, (int)section
->size
));
3584 /* Don't write out the VMS debug info section since it is in the
3585 ETBT and EDBG sections in etir. */
3586 if (section
->flags
& SEC_DEBUGGING
)
3589 /* 13 bytes egsd, max 31 chars name -> should be 44 bytes. */
3590 if (_bfd_vms_output_check (recwr
, 64) < 0)
3592 _bfd_vms_output_end (abfd
, recwr
);
3593 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3594 _bfd_vms_output_long (recwr
, 0);
3597 /* Don't know if this is necessary for the linker but for now it keeps
3598 vms_slurp_gsd happy. */
3599 sname
= section
->name
;
3602 /* Remove leading dot. */
3604 if ((*sname
== 't') && (strcmp (sname
, "text") == 0))
3605 sname
= EVAX_CODE_NAME
;
3606 else if ((*sname
== 'd') && (strcmp (sname
, "data") == 0))
3607 sname
= EVAX_DATA_NAME
;
3608 else if ((*sname
== 'b') && (strcmp (sname
, "bss") == 0))
3609 sname
= EVAX_BSS_NAME
;
3610 else if ((*sname
== 'l') && (strcmp (sname
, "link") == 0))
3611 sname
= EVAX_LINK_NAME
;
3612 else if ((*sname
== 'r') && (strcmp (sname
, "rdata") == 0))
3613 sname
= EVAX_READONLY_NAME
;
3614 else if ((*sname
== 'l') && (strcmp (sname
, "literal") == 0))
3615 sname
= EVAX_LITERAL_NAME
;
3616 else if ((*sname
== 'l') && (strcmp (sname
, "literals") == 0))
3617 sname
= EVAX_LITERALS_NAME
;
3618 else if ((*sname
== 'c') && (strcmp (sname
, "comm") == 0))
3619 sname
= EVAX_COMMON_NAME
;
3620 else if ((*sname
== 'l') && (strcmp (sname
, "lcomm") == 0))
3621 sname
= EVAX_LOCAL_NAME
;
3624 if (bfd_is_com_section (section
))
3625 new_flags
= (EGPS__V_OVR
| EGPS__V_REL
| EGPS__V_GBL
| EGPS__V_RD
3626 | EGPS__V_WRT
| EGPS__V_NOMOD
| EGPS__V_COM
);
3628 new_flags
= vms_esecflag_by_name (evax_section_flags
, sname
,
3631 /* Modify them as directed. */
3632 if (section
->flags
& SEC_READONLY
)
3633 new_flags
&= ~EGPS__V_WRT
;
3635 new_flags
&= ~vms_section_data (section
)->no_flags
;
3636 new_flags
|= vms_section_data (section
)->flags
;
3638 vms_debug2 ((3, "sec flags %x\n", section
->flags
));
3639 vms_debug2 ((3, "new_flags %x, _raw_size %lu\n",
3640 new_flags
, (unsigned long)section
->size
));
3642 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3643 _bfd_vms_output_short (recwr
, section
->alignment_power
& 0xff);
3644 _bfd_vms_output_short (recwr
, new_flags
);
3645 _bfd_vms_output_long (recwr
, (unsigned long) section
->size
);
3646 _bfd_vms_output_counted (recwr
, sname
);
3647 _bfd_vms_output_end_subrec (recwr
);
3649 /* If the section is an obsolute one, remind its index as it will be
3650 used later for absolute symbols. */
3651 if ((new_flags
& EGPS__V_REL
) == 0 && abs_section_index
< 0)
3652 abs_section_index
= section
->target_index
;
3655 /* Output symbols. */
3656 vms_debug2 ((3, "%d symbols found\n", abfd
->symcount
));
3658 bfd_set_start_address (abfd
, (bfd_vma
) -1);
3660 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3662 symbol
= abfd
->outsymbols
[symnum
];
3663 old_flags
= symbol
->flags
;
3665 /* Work-around a missing feature: consider __main as the main entry
3667 if (symbol
->name
[0] == '_' && strcmp (symbol
->name
, "__main") == 0)
3668 bfd_set_start_address (abfd
, (bfd_vma
)symbol
->value
);
3670 /* Only put in the GSD the global and the undefined symbols. */
3671 if (old_flags
& BSF_FILE
)
3674 if ((old_flags
& BSF_GLOBAL
) == 0 && !bfd_is_und_section (symbol
->section
))
3676 /* If the LIB$INITIIALIZE section is present, add a reference to
3677 LIB$INITIALIZE symbol. FIXME: this should be done explicitely
3678 in the assembly file. */
3679 if (!((old_flags
& BSF_SECTION_SYM
) != 0
3680 && strcmp (symbol
->section
->name
, "LIB$INITIALIZE") == 0))
3684 /* 13 bytes egsd, max 64 chars name -> should be 77 bytes. Add 16 more
3685 bytes for a possible ABS section. */
3686 if (_bfd_vms_output_check (recwr
, 80 + 16) < 0)
3688 _bfd_vms_output_end (abfd
, recwr
);
3689 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3690 _bfd_vms_output_long (recwr
, 0);
3693 if ((old_flags
& BSF_GLOBAL
) != 0
3694 && bfd_is_abs_section (symbol
->section
)
3695 && abs_section_index
<= 0)
3697 /* Create an absolute section if none was defined. It is highly
3698 unlikely that the name $ABS$ clashes with a user defined
3699 non-absolute section name. */
3700 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3701 _bfd_vms_output_short (recwr
, 4);
3702 _bfd_vms_output_short (recwr
, EGPS__V_SHR
);
3703 _bfd_vms_output_long (recwr
, 0);
3704 _bfd_vms_output_counted (recwr
, "$ABS$");
3705 _bfd_vms_output_end_subrec (recwr
);
3707 abs_section_index
= target_index
++;
3710 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYM
);
3712 /* Data type, alignment. */
3713 _bfd_vms_output_short (recwr
, 0);
3717 if (old_flags
& BSF_WEAK
)
3718 new_flags
|= EGSY__V_WEAK
;
3719 if (bfd_is_com_section (symbol
->section
)) /* .comm */
3720 new_flags
|= (EGSY__V_WEAK
| EGSY__V_COMM
);
3722 if (old_flags
& BSF_FUNCTION
)
3724 new_flags
|= EGSY__V_NORM
;
3725 new_flags
|= EGSY__V_REL
;
3727 if (old_flags
& BSF_GLOBAL
)
3729 new_flags
|= EGSY__V_DEF
;
3730 if (!bfd_is_abs_section (symbol
->section
))
3731 new_flags
|= EGSY__V_REL
;
3733 _bfd_vms_output_short (recwr
, new_flags
);
3735 if (old_flags
& BSF_GLOBAL
)
3737 /* Symbol definition. */
3738 bfd_vma code_address
= 0;
3739 unsigned long ca_psindx
= 0;
3740 unsigned long psindx
;
3742 if ((old_flags
& BSF_FUNCTION
) && symbol
->udata
.p
!= NULL
)
3747 ((struct evax_private_udata_struct
*)symbol
->udata
.p
)->enbsym
;
3748 code_address
= sym
->value
;
3749 ca_psindx
= sym
->section
->target_index
;
3751 if (bfd_is_abs_section (symbol
->section
))
3752 psindx
= abs_section_index
;
3754 psindx
= symbol
->section
->target_index
;
3756 _bfd_vms_output_quad (recwr
, symbol
->value
);
3757 _bfd_vms_output_quad (recwr
, code_address
);
3758 _bfd_vms_output_long (recwr
, ca_psindx
);
3759 _bfd_vms_output_long (recwr
, psindx
);
3761 _bfd_vms_output_counted (recwr
, symbol
->name
);
3763 _bfd_vms_output_end_subrec (recwr
);
3766 _bfd_vms_output_alignment (recwr
, 8);
3767 _bfd_vms_output_end (abfd
, recwr
);
3772 /* Write object header for bfd abfd. Return FALSE on error. */
3775 _bfd_vms_write_ehdr (bfd
*abfd
)
3778 unsigned int symnum
;
3779 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3781 vms_debug2 ((2, "vms_write_ehdr (%p)\n", abfd
));
3783 _bfd_vms_output_alignment (recwr
, 2);
3785 _bfd_vms_write_emh (abfd
);
3786 _bfd_vms_write_lmn (abfd
, "GNU AS");
3789 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3790 _bfd_vms_output_short (recwr
, EMH__C_SRC
);
3792 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3794 symbol
= abfd
->outsymbols
[symnum
];
3796 if (symbol
->flags
& BSF_FILE
)
3798 _bfd_vms_output_dump (recwr
, (unsigned char *) symbol
->name
,
3799 (int) strlen (symbol
->name
));
3804 if (symnum
== abfd
->symcount
)
3805 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("noname"));
3807 _bfd_vms_output_end (abfd
, recwr
);
3810 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3811 _bfd_vms_output_short (recwr
, EMH__C_TTL
);
3812 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("TTL"));
3813 _bfd_vms_output_end (abfd
, recwr
);
3816 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3817 _bfd_vms_output_short (recwr
, EMH__C_CPR
);
3818 _bfd_vms_output_dump (recwr
,
3819 (unsigned char *)"GNU BFD ported by Klaus Kämpf 1994-1996",
3821 _bfd_vms_output_end (abfd
, recwr
);
3826 /* Part 4.6, relocations. */
3829 /* WRITE ETIR SECTION
3831 This is still under construction and therefore not documented. */
3833 /* Close the etir/etbt record. */
3836 end_etir_record (bfd
* abfd
)
3838 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3840 _bfd_vms_output_end (abfd
, recwr
);
3844 start_etir_or_etbt_record (bfd
*abfd
, asection
*section
, bfd_vma offset
)
3846 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3848 if (section
->flags
& SEC_DEBUGGING
)
3850 _bfd_vms_output_begin (recwr
, EOBJ__C_ETBT
);
3854 /* Push start offset. */
3855 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3856 _bfd_vms_output_long (recwr
, (unsigned long) 0);
3857 _bfd_vms_output_end_subrec (recwr
);
3860 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_DFLOC
);
3861 _bfd_vms_output_end_subrec (recwr
);
3866 _bfd_vms_output_begin (recwr
, EOBJ__C_ETIR
);
3870 /* Push start offset. */
3871 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3872 _bfd_vms_output_long (recwr
, (unsigned long) section
->target_index
);
3873 _bfd_vms_output_quad (recwr
, offset
);
3874 _bfd_vms_output_end_subrec (recwr
);
3876 /* Start = pop (). */
3877 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_SETRB
);
3878 _bfd_vms_output_end_subrec (recwr
);
3883 /* Output a STO_IMM command for SSIZE bytes of data from CPR at virtual
3884 address VADDR in section specified by SEC_INDEX and NAME. */
3887 sto_imm (bfd
*abfd
, asection
*section
,
3888 bfd_size_type ssize
, unsigned char *cptr
, bfd_vma vaddr
)
3891 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3894 _bfd_vms_debug (8, "sto_imm %d bytes\n", (int) ssize
);
3895 _bfd_hexdump (9, cptr
, (int) ssize
, (int) vaddr
);
3900 /* Try all the rest. */
3903 if (_bfd_vms_output_check (recwr
, size
) < 0)
3905 /* Doesn't fit, split ! */
3906 end_etir_record (abfd
);
3908 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3910 size
= _bfd_vms_output_check (recwr
, 0); /* get max size */
3911 if (size
> ssize
) /* more than what's left ? */
3915 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_IMM
);
3916 _bfd_vms_output_long (recwr
, (unsigned long) (size
));
3917 _bfd_vms_output_dump (recwr
, cptr
, size
);
3918 _bfd_vms_output_end_subrec (recwr
);
3921 _bfd_vms_debug (10, "dumped %d bytes\n", (int) size
);
3922 _bfd_hexdump (10, cptr
, (int) size
, (int) vaddr
);
3932 etir_output_check (bfd
*abfd
, asection
*section
, bfd_vma vaddr
, int checklen
)
3934 if (_bfd_vms_output_check (&PRIV (recwr
), checklen
) < 0)
3936 /* Not enough room in this record. Close it and open a new one. */
3937 end_etir_record (abfd
);
3938 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3942 /* Return whether RELOC must be deferred till the end. */
3945 defer_reloc_p (arelent
*reloc
)
3947 switch (reloc
->howto
->type
)
3960 /* Write section contents for bfd abfd. Return FALSE on error. */
3963 _bfd_vms_write_etir (bfd
* abfd
, int objtype ATTRIBUTE_UNUSED
)
3966 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3968 vms_debug2 ((2, "vms_write_tir (%p, %d)\n", abfd
, objtype
));
3970 _bfd_vms_output_alignment (recwr
, 4);
3972 PRIV (vms_linkage_index
) = 0;
3974 for (section
= abfd
->sections
; section
; section
= section
->next
)
3976 vms_debug2 ((4, "writing %d. section '%s' (%d bytes)\n",
3977 section
->target_index
, section
->name
, (int) (section
->size
)));
3979 if (!(section
->flags
& SEC_HAS_CONTENTS
)
3980 || bfd_is_com_section (section
))
3983 if (!section
->contents
)
3985 bfd_set_error (bfd_error_no_contents
);
3989 start_etir_or_etbt_record (abfd
, section
, 0);
3991 if (section
->flags
& SEC_RELOC
)
3993 bfd_vma curr_addr
= 0;
3994 unsigned char *curr_data
= section
->contents
;
3996 int pass2_needed
= 0;
3997 int pass2_in_progress
= 0;
4000 if (section
->reloc_count
== 0)
4002 (_("SEC_RELOC with no relocs in section %pA"), section
);
4007 int i
= section
->reloc_count
;
4008 arelent
**rptr
= section
->orelocation
;
4009 _bfd_vms_debug (4, "%d relocations:\n", i
);
4012 _bfd_vms_debug (4, "sym %s in sec %s, value %08lx, "
4013 "addr %08lx, off %08lx, len %d: %s\n",
4014 (*(*rptr
)->sym_ptr_ptr
)->name
,
4015 (*(*rptr
)->sym_ptr_ptr
)->section
->name
,
4016 (long) (*(*rptr
)->sym_ptr_ptr
)->value
,
4017 (unsigned long)(*rptr
)->address
,
4018 (unsigned long)(*rptr
)->addend
,
4019 bfd_get_reloc_size ((*rptr
)->howto
),
4020 ( *rptr
)->howto
->name
);
4027 for (irel
= 0; irel
< section
->reloc_count
; irel
++)
4029 struct evax_private_udata_struct
*udata
;
4030 arelent
*rptr
= section
->orelocation
[irel
];
4031 bfd_vma addr
= rptr
->address
;
4032 asymbol
*sym
= *rptr
->sym_ptr_ptr
;
4033 asection
*sec
= sym
->section
;
4034 bfd_boolean defer
= defer_reloc_p (rptr
);
4037 if (pass2_in_progress
)
4039 /* Non-deferred relocs have already been output. */
4045 /* Deferred relocs must be output at the very end. */
4052 /* Regular relocs are intertwined with binary data. */
4053 if (curr_addr
> addr
)
4054 _bfd_error_handler (_("size error in section %pA"),
4056 size
= addr
- curr_addr
;
4057 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
4062 size
= bfd_get_reloc_size (rptr
->howto
);
4064 switch (rptr
->howto
->type
)
4066 case ALPHA_R_IGNORE
:
4069 case ALPHA_R_REFLONG
:
4070 if (bfd_is_und_section (sym
->section
))
4072 bfd_vma addend
= rptr
->addend
;
4073 slen
= strlen ((char *) sym
->name
);
4074 etir_output_check (abfd
, section
, curr_addr
, slen
);
4077 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
4078 _bfd_vms_output_counted (recwr
, sym
->name
);
4079 _bfd_vms_output_end_subrec (recwr
);
4080 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
4081 _bfd_vms_output_long (recwr
, (unsigned long) addend
);
4082 _bfd_vms_output_end_subrec (recwr
);
4083 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
4084 _bfd_vms_output_end_subrec (recwr
);
4085 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
4086 _bfd_vms_output_end_subrec (recwr
);
4090 _bfd_vms_output_begin_subrec
4091 (recwr
, ETIR__C_STO_GBL_LW
);
4092 _bfd_vms_output_counted (recwr
, sym
->name
);
4093 _bfd_vms_output_end_subrec (recwr
);
4096 else if (bfd_is_abs_section (sym
->section
))
4098 etir_output_check (abfd
, section
, curr_addr
, 16);
4099 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
4100 _bfd_vms_output_long (recwr
, (unsigned long) sym
->value
);
4101 _bfd_vms_output_end_subrec (recwr
);
4102 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
4103 _bfd_vms_output_end_subrec (recwr
);
4107 etir_output_check (abfd
, section
, curr_addr
, 32);
4108 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
4109 _bfd_vms_output_long (recwr
,
4110 (unsigned long) sec
->target_index
);
4111 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
4112 _bfd_vms_output_end_subrec (recwr
);
4113 /* ??? Table B-8 of the OpenVMS Linker Utilily Manual
4114 says that we should have a ETIR__C_STO_OFF here.
4115 But the relocation would not be BFD_RELOC_32 then.
4116 This case is very likely unreachable. */
4117 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
4118 _bfd_vms_output_end_subrec (recwr
);
4122 case ALPHA_R_REFQUAD
:
4123 if (bfd_is_und_section (sym
->section
))
4125 bfd_vma addend
= rptr
->addend
;
4126 slen
= strlen ((char *) sym
->name
);
4127 etir_output_check (abfd
, section
, curr_addr
, slen
);
4130 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
4131 _bfd_vms_output_counted (recwr
, sym
->name
);
4132 _bfd_vms_output_end_subrec (recwr
);
4133 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
4134 _bfd_vms_output_quad (recwr
, addend
);
4135 _bfd_vms_output_end_subrec (recwr
);
4136 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
4137 _bfd_vms_output_end_subrec (recwr
);
4138 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
4139 _bfd_vms_output_end_subrec (recwr
);
4143 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_GBL
);
4144 _bfd_vms_output_counted (recwr
, sym
->name
);
4145 _bfd_vms_output_end_subrec (recwr
);
4148 else if (bfd_is_abs_section (sym
->section
))
4150 etir_output_check (abfd
, section
, curr_addr
, 16);
4151 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
4152 _bfd_vms_output_quad (recwr
, sym
->value
);
4153 _bfd_vms_output_end_subrec (recwr
);
4154 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
4155 _bfd_vms_output_end_subrec (recwr
);
4159 etir_output_check (abfd
, section
, curr_addr
, 32);
4160 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
4161 _bfd_vms_output_long (recwr
,
4162 (unsigned long) sec
->target_index
);
4163 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
4164 _bfd_vms_output_end_subrec (recwr
);
4165 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_OFF
);
4166 _bfd_vms_output_end_subrec (recwr
);
4171 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
4174 case ALPHA_R_LINKAGE
:
4176 etir_output_check (abfd
, section
, curr_addr
, 64);
4177 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LP_PSB
);
4178 _bfd_vms_output_long
4179 (recwr
, (unsigned long) rptr
->addend
);
4180 if (rptr
->addend
> PRIV (vms_linkage_index
))
4181 PRIV (vms_linkage_index
) = rptr
->addend
;
4182 _bfd_vms_output_counted (recwr
, sym
->name
);
4183 _bfd_vms_output_byte (recwr
, 0);
4184 _bfd_vms_output_end_subrec (recwr
);
4187 case ALPHA_R_CODEADDR
:
4188 slen
= strlen ((char *) sym
->name
);
4189 etir_output_check (abfd
, section
, curr_addr
, slen
);
4190 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_CA
);
4191 _bfd_vms_output_counted (recwr
, sym
->name
);
4192 _bfd_vms_output_end_subrec (recwr
);
4197 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4198 etir_output_check (abfd
, section
, curr_addr
,
4199 32 + 1 + strlen (udata
->origname
));
4200 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_NOP_GBL
);
4201 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
4202 _bfd_vms_output_long
4203 (recwr
, (unsigned long) section
->target_index
);
4204 _bfd_vms_output_quad (recwr
, rptr
->address
);
4205 _bfd_vms_output_long (recwr
, (unsigned long) 0x47ff041f);
4206 _bfd_vms_output_long
4207 (recwr
, (unsigned long) section
->target_index
);
4208 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4209 _bfd_vms_output_counted (recwr
, udata
->origname
);
4210 _bfd_vms_output_end_subrec (recwr
);
4214 _bfd_error_handler (_("spurious ALPHA_R_BSR reloc"));
4219 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4220 etir_output_check (abfd
, section
, curr_addr
,
4221 32 + 1 + strlen (udata
->origname
));
4222 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LDA_GBL
);
4223 _bfd_vms_output_long
4224 (recwr
, (unsigned long) udata
->lkindex
+ 1);
4225 _bfd_vms_output_long
4226 (recwr
, (unsigned long) section
->target_index
);
4227 _bfd_vms_output_quad (recwr
, rptr
->address
);
4228 _bfd_vms_output_long (recwr
, (unsigned long) 0x237B0000);
4229 _bfd_vms_output_long
4230 (recwr
, (unsigned long) udata
->bsym
->section
->target_index
);
4231 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4232 _bfd_vms_output_counted (recwr
, udata
->origname
);
4233 _bfd_vms_output_end_subrec (recwr
);
4238 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4239 etir_output_check (abfd
, section
, curr_addr
,
4240 32 + 1 + strlen (udata
->origname
));
4241 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_BOH_GBL
);
4242 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
4243 _bfd_vms_output_long
4244 (recwr
, (unsigned long) section
->target_index
);
4245 _bfd_vms_output_quad (recwr
, rptr
->address
);
4246 _bfd_vms_output_long (recwr
, (unsigned long) 0xD3400000);
4247 _bfd_vms_output_long
4248 (recwr
, (unsigned long) section
->target_index
);
4249 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4250 _bfd_vms_output_counted (recwr
, udata
->origname
);
4251 _bfd_vms_output_end_subrec (recwr
);
4255 _bfd_error_handler (_("unhandled relocation %s"),
4262 } /* End of relocs loop. */
4264 if (!pass2_in_progress
)
4266 /* Output rest of section. */
4267 if (curr_addr
> section
->size
)
4269 _bfd_error_handler (_("size error in section %pA"), section
);
4272 size
= section
->size
- curr_addr
;
4273 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
4279 pass2_in_progress
= 1;
4285 else /* (section->flags & SEC_RELOC) */
4286 sto_imm (abfd
, section
, section
->size
, section
->contents
, 0);
4288 end_etir_record (abfd
);
4291 _bfd_vms_output_alignment (recwr
, 2);
4295 /* Write cached information into a file being written, at bfd_close. */
4298 alpha_vms_write_object_contents (bfd
*abfd
)
4300 vms_debug2 ((1, "vms_write_object_contents (%p)\n", abfd
));
4302 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
4304 return alpha_vms_write_exec (abfd
);
4308 if (abfd
->section_count
> 0) /* we have sections */
4310 if (!_bfd_vms_write_ehdr (abfd
))
4312 if (!_bfd_vms_write_egsd (abfd
))
4314 if (!_bfd_vms_write_etir (abfd
, EOBJ__C_ETIR
))
4316 if (!_bfd_vms_write_eeom (abfd
))
4323 /* Debug stuff: nearest line. */
4325 #define SET_MODULE_PARSED(m) \
4326 do { if ((m)->name == NULL) (m)->name = ""; } while (0)
4327 #define IS_MODULE_PARSED(m) ((m)->name != NULL)
4329 /* Build a new module for the specified BFD. */
4331 static struct module
*
4332 new_module (bfd
*abfd
)
4334 struct module
*module
4335 = (struct module
*) bfd_zalloc (abfd
, sizeof (struct module
));
4336 module
->file_table_count
= 16; /* Arbitrary. */
4338 = bfd_malloc (module
->file_table_count
* sizeof (struct fileinfo
));
4342 /* Parse debug info for a module and internalize it. */
4345 parse_module (bfd
*abfd
, struct module
*module
, unsigned char *ptr
,
4348 unsigned char *maxptr
= ptr
+ length
;
4349 unsigned char *src_ptr
, *pcl_ptr
;
4350 unsigned int prev_linum
= 0, curr_linenum
= 0;
4351 bfd_vma prev_pc
= 0, curr_pc
= 0;
4352 struct srecinfo
*curr_srec
, *srec
;
4353 struct lineinfo
*curr_line
, *line
;
4354 struct funcinfo
*funcinfo
;
4356 /* Initialize tables with zero element. */
4357 curr_srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4358 module
->srec_table
= curr_srec
;
4360 curr_line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4361 module
->line_table
= curr_line
;
4363 while (length
== -1 || ptr
< maxptr
)
4365 /* The first byte is not counted in the recorded length. */
4366 int rec_length
= bfd_getl16 (ptr
) + 1;
4367 int rec_type
= bfd_getl16 (ptr
+ 2);
4369 vms_debug2 ((2, "DST record: leng %d, type %d\n", rec_length
, rec_type
));
4371 if (length
== -1 && rec_type
== DST__K_MODEND
)
4378 = _bfd_vms_save_counted_string (abfd
, ptr
+ DST_S_B_MODBEG_NAME
,
4379 maxptr
- (ptr
+ DST_S_B_MODBEG_NAME
));
4386 vms_debug2 ((3, "module: %s\n", module
->name
));
4393 funcinfo
= (struct funcinfo
*)
4394 bfd_zalloc (abfd
, sizeof (struct funcinfo
));
4396 = _bfd_vms_save_counted_string (abfd
, ptr
+ DST_S_B_RTNBEG_NAME
,
4397 maxptr
- (ptr
+ DST_S_B_RTNBEG_NAME
));
4398 funcinfo
->low
= bfd_getl32 (ptr
+ DST_S_L_RTNBEG_ADDRESS
);
4399 funcinfo
->next
= module
->func_table
;
4400 module
->func_table
= funcinfo
;
4402 vms_debug2 ((3, "routine: %s at 0x%lx\n",
4403 funcinfo
->name
, (unsigned long) funcinfo
->low
));
4407 module
->func_table
->high
= module
->func_table
->low
4408 + bfd_getl32 (ptr
+ DST_S_L_RTNEND_SIZE
) - 1;
4410 if (module
->func_table
->high
> module
->high
)
4411 module
->high
= module
->func_table
->high
;
4413 vms_debug2 ((3, "end routine\n"));
4417 vms_debug2 ((3, "prologue\n"));
4421 vms_debug2 ((3, "epilog\n"));
4425 vms_debug2 ((3, "block\n"));
4429 vms_debug2 ((3, "end block\n"));
4433 src_ptr
= ptr
+ DST_S_C_SOURCE_HEADER_SIZE
;
4435 vms_debug2 ((3, "source info\n"));
4437 while (src_ptr
< ptr
+ rec_length
)
4439 int cmd
= src_ptr
[0], cmd_length
, data
;
4443 case DST__K_SRC_DECLFILE
:
4446 = bfd_getl16 (src_ptr
+ DST_S_W_SRC_DF_FILEID
);
4447 char *filename
= _bfd_vms_save_counted_string
4449 src_ptr
+ DST_S_B_SRC_DF_FILENAME
,
4450 ptr
+ rec_length
- (src_ptr
+ DST_S_B_SRC_DF_FILENAME
));
4452 while (fileid
>= module
->file_table_count
)
4454 module
->file_table_count
*= 2;
4456 = bfd_realloc_or_free (module
->file_table
,
4457 module
->file_table_count
4458 * sizeof (struct fileinfo
));
4459 if (module
->file_table
== NULL
)
4463 module
->file_table
[fileid
].name
= filename
;
4464 module
->file_table
[fileid
].srec
= 1;
4465 cmd_length
= src_ptr
[DST_S_B_SRC_DF_LENGTH
] + 2;
4466 vms_debug2 ((4, "DST_S_C_SRC_DECLFILE: %d, %s\n",
4467 fileid
, module
->file_table
[fileid
].name
));
4471 case DST__K_SRC_DEFLINES_B
:
4472 /* Perform the association and set the next higher index
4474 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4475 srec
= (struct srecinfo
*)
4476 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4477 srec
->line
= curr_srec
->line
+ data
;
4478 srec
->srec
= curr_srec
->srec
+ data
;
4479 srec
->sfile
= curr_srec
->sfile
;
4480 curr_srec
->next
= srec
;
4483 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_B: %d\n", data
));
4486 case DST__K_SRC_DEFLINES_W
:
4487 /* Perform the association and set the next higher index
4489 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4490 srec
= (struct srecinfo
*)
4491 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4492 srec
->line
= curr_srec
->line
+ data
;
4493 srec
->srec
= curr_srec
->srec
+ data
,
4494 srec
->sfile
= curr_srec
->sfile
;
4495 curr_srec
->next
= srec
;
4498 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_W: %d\n", data
));
4501 case DST__K_SRC_INCRLNUM_B
:
4502 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4503 curr_srec
->line
+= data
;
4505 vms_debug2 ((4, "DST_S_C_SRC_INCRLNUM_B: %d\n", data
));
4508 case DST__K_SRC_SETFILE
:
4509 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4510 curr_srec
->sfile
= data
;
4511 curr_srec
->srec
= module
->file_table
[data
].srec
;
4513 vms_debug2 ((4, "DST_S_C_SRC_SETFILE: %d\n", data
));
4516 case DST__K_SRC_SETLNUM_L
:
4517 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4518 curr_srec
->line
= data
;
4520 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_L: %d\n", data
));
4523 case DST__K_SRC_SETLNUM_W
:
4524 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4525 curr_srec
->line
= data
;
4527 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_W: %d\n", data
));
4530 case DST__K_SRC_SETREC_L
:
4531 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4532 curr_srec
->srec
= data
;
4533 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4535 vms_debug2 ((4, "DST_S_C_SRC_SETREC_L: %d\n", data
));
4538 case DST__K_SRC_SETREC_W
:
4539 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4540 curr_srec
->srec
= data
;
4541 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4543 vms_debug2 ((4, "DST_S_C_SRC_SETREC_W: %d\n", data
));
4546 case DST__K_SRC_FORMFEED
:
4548 vms_debug2 ((4, "DST_S_C_SRC_FORMFEED\n"));
4552 _bfd_error_handler (_("unknown source command %d"),
4558 src_ptr
+= cmd_length
;
4562 case DST__K_LINE_NUM
:
4563 pcl_ptr
= ptr
+ DST_S_C_LINE_NUM_HEADER_SIZE
;
4565 vms_debug2 ((3, "line info\n"));
4567 while (pcl_ptr
< ptr
+ rec_length
)
4569 /* The command byte is signed so we must sign-extend it. */
4570 int cmd
= ((signed char *)pcl_ptr
)[0], cmd_length
, data
;
4574 case DST__K_DELTA_PC_W
:
4575 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4579 vms_debug2 ((4, "DST__K_DELTA_PC_W: %d\n", data
));
4582 case DST__K_DELTA_PC_L
:
4583 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4587 vms_debug2 ((4, "DST__K_DELTA_PC_L: %d\n", data
));
4590 case DST__K_INCR_LINUM
:
4591 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4592 curr_linenum
+= data
;
4594 vms_debug2 ((4, "DST__K_INCR_LINUM: %d\n", data
));
4597 case DST__K_INCR_LINUM_W
:
4598 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4599 curr_linenum
+= data
;
4601 vms_debug2 ((4, "DST__K_INCR_LINUM_W: %d\n", data
));
4604 case DST__K_INCR_LINUM_L
:
4605 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4606 curr_linenum
+= data
;
4608 vms_debug2 ((4, "DST__K_INCR_LINUM_L: %d\n", data
));
4611 case DST__K_SET_LINUM_INCR
:
4613 (_("%s not implemented"), "DST__K_SET_LINUM_INCR");
4617 case DST__K_SET_LINUM_INCR_W
:
4619 (_("%s not implemented"), "DST__K_SET_LINUM_INCR_W");
4623 case DST__K_RESET_LINUM_INCR
:
4625 (_("%s not implemented"), "DST__K_RESET_LINUM_INCR");
4629 case DST__K_BEG_STMT_MODE
:
4631 (_("%s not implemented"), "DST__K_BEG_STMT_MODE");
4635 case DST__K_END_STMT_MODE
:
4637 (_("%s not implemented"), "DST__K_END_STMT_MODE");
4641 case DST__K_SET_LINUM_B
:
4642 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4643 curr_linenum
= data
;
4645 vms_debug2 ((4, "DST__K_SET_LINUM_B: %d\n", data
));
4648 case DST__K_SET_LINUM
:
4649 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4650 curr_linenum
= data
;
4652 vms_debug2 ((4, "DST__K_SET_LINE_NUM: %d\n", data
));
4655 case DST__K_SET_LINUM_L
:
4656 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4657 curr_linenum
= data
;
4659 vms_debug2 ((4, "DST__K_SET_LINUM_L: %d\n", data
));
4664 (_("%s not implemented"), "DST__K_SET_PC");
4668 case DST__K_SET_PC_W
:
4670 (_("%s not implemented"), "DST__K_SET_PC_W");
4674 case DST__K_SET_PC_L
:
4676 (_("%s not implemented"), "DST__K_SET_PC_L");
4680 case DST__K_SET_STMTNUM
:
4682 (_("%s not implemented"), "DST__K_SET_STMTNUM");
4687 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4690 vms_debug2 ((4, "DST__K_TERM: %d\n", data
));
4694 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4697 vms_debug2 ((4, "DST__K_TERM_W: %d\n", data
));
4701 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4704 vms_debug2 ((4, "DST__K_TERM_L: %d\n", data
));
4707 case DST__K_SET_ABS_PC
:
4708 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4711 vms_debug2 ((4, "DST__K_SET_ABS_PC: 0x%x\n", data
));
4720 vms_debug2 ((4, "bump pc to 0x%lx and line to %d\n",
4721 (unsigned long)curr_pc
, curr_linenum
));
4725 _bfd_error_handler (_("unknown line command %d"), cmd
);
4731 if ((curr_linenum
!= prev_linum
&& curr_pc
!= prev_pc
)
4733 || cmd
== DST__K_DELTA_PC_L
4734 || cmd
== DST__K_DELTA_PC_W
)
4736 line
= (struct lineinfo
*)
4737 bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4738 line
->address
= curr_pc
;
4739 line
->line
= curr_linenum
;
4741 curr_line
->next
= line
;
4744 prev_linum
= curr_linenum
;
4746 vms_debug2 ((4, "-> correlate pc 0x%lx with line %d\n",
4747 (unsigned long)curr_pc
, curr_linenum
));
4750 pcl_ptr
+= cmd_length
;
4754 case 0x17: /* Undocumented type used by DEC C to declare equates. */
4755 vms_debug2 ((3, "undocumented type 0x17\n"));
4759 vms_debug2 ((3, "ignoring record\n"));
4767 /* Finalize tables with EOL marker. */
4768 srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4769 srec
->line
= (unsigned int) -1;
4770 srec
->srec
= (unsigned int) -1;
4771 curr_srec
->next
= srec
;
4773 line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4774 line
->line
= (unsigned int) -1;
4775 line
->address
= (bfd_vma
) -1;
4776 curr_line
->next
= line
;
4778 /* Advertise that this module has been parsed. This is needed
4779 because parsing can be either performed at module creation
4780 or deferred until debug info is consumed. */
4781 SET_MODULE_PARSED (module
);
4785 /* Build the list of modules for the specified BFD. */
4787 static struct module
*
4788 build_module_list (bfd
*abfd
)
4790 struct module
*module
, *list
= NULL
;
4793 if ((dmt
= bfd_get_section_by_name (abfd
, "$DMT$")))
4795 /* We have a DMT section so this must be an image. Parse the
4796 section and build the list of modules. This is sufficient
4797 since we can compute the start address and the end address
4798 of every module from the section contents. */
4799 bfd_size_type size
= bfd_section_size (dmt
);
4800 unsigned char *ptr
, *end
;
4802 ptr
= (unsigned char *) bfd_alloc (abfd
, size
);
4806 if (! bfd_get_section_contents (abfd
, dmt
, ptr
, 0, size
))
4809 vms_debug2 ((2, "DMT\n"));
4815 /* Each header declares a module with its start offset and size
4816 of debug info in the DST section, as well as the count of
4817 program sections (i.e. address spans) it contains. */
4818 int modbeg
= bfd_getl32 (ptr
+ DBG_S_L_DMT_MODBEG
);
4819 int msize
= bfd_getl32 (ptr
+ DBG_S_L_DST_SIZE
);
4820 int count
= bfd_getl16 (ptr
+ DBG_S_W_DMT_PSECT_COUNT
);
4821 ptr
+= DBG_S_C_DMT_HEADER_SIZE
;
4823 vms_debug2 ((3, "module: modbeg = %d, size = %d, count = %d\n",
4824 modbeg
, msize
, count
));
4826 /* We create a 'module' structure for each program section since
4827 we only support contiguous addresses in a 'module' structure.
4828 As a consequence, the actual debug info in the DST section is
4829 shared and can be parsed multiple times; that doesn't seem to
4830 cause problems in practice. */
4833 int start
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_START
);
4834 int length
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_LENGTH
);
4835 module
= new_module (abfd
);
4836 module
->modbeg
= modbeg
;
4837 module
->size
= msize
;
4838 module
->low
= start
;
4839 module
->high
= start
+ length
;
4840 module
->next
= list
;
4842 ptr
+= DBG_S_C_DMT_PSECT_SIZE
;
4844 vms_debug2 ((4, "section: start = 0x%x, length = %d\n",
4851 /* We don't have a DMT section so this must be an object. Parse
4852 the module right now in order to compute its start address and
4854 void *dst
= PRIV (dst_section
)->contents
;
4859 module
= new_module (abfd
);
4860 if (!parse_module (abfd
, module
, PRIV (dst_section
)->contents
, -1))
4868 /* Calculate and return the name of the source file and the line nearest
4869 to the wanted location in the specified module. */
4872 module_find_nearest_line (bfd
*abfd
, struct module
*module
, bfd_vma addr
,
4873 const char **file
, const char **func
,
4876 struct funcinfo
*funcinfo
;
4877 struct lineinfo
*lineinfo
;
4878 struct srecinfo
*srecinfo
;
4879 bfd_boolean ret
= FALSE
;
4881 /* Parse this module if that was not done at module creation. */
4882 if (! IS_MODULE_PARSED (module
))
4884 unsigned int size
= module
->size
;
4885 unsigned int modbeg
= PRIV (dst_section
)->filepos
+ module
->modbeg
;
4886 unsigned char *buffer
;
4888 if (bfd_seek (abfd
, modbeg
, SEEK_SET
) != 0
4889 || (buffer
= _bfd_malloc_and_read (abfd
, size
, size
)) == NULL
)
4891 bfd_set_error (bfd_error_no_debug_section
);
4895 ret
= parse_module (abfd
, module
, buffer
, size
);
4901 /* Find out the function (if any) that contains the address. */
4902 for (funcinfo
= module
->func_table
; funcinfo
; funcinfo
= funcinfo
->next
)
4903 if (addr
>= funcinfo
->low
&& addr
<= funcinfo
->high
)
4905 *func
= funcinfo
->name
;
4910 /* Find out the source file and the line nearest to the address. */
4911 for (lineinfo
= module
->line_table
; lineinfo
; lineinfo
= lineinfo
->next
)
4912 if (lineinfo
->next
&& addr
< lineinfo
->next
->address
)
4914 for (srecinfo
= module
->srec_table
; srecinfo
; srecinfo
= srecinfo
->next
)
4915 if (srecinfo
->next
&& lineinfo
->line
< srecinfo
->next
->line
)
4917 if (srecinfo
->sfile
> 0)
4919 *file
= module
->file_table
[srecinfo
->sfile
].name
;
4920 *line
= srecinfo
->srec
+ lineinfo
->line
- srecinfo
->line
;
4924 *file
= module
->name
;
4925 *line
= lineinfo
->line
;
4936 /* Provided a BFD, a section and an offset into the section, calculate and
4937 return the name of the source file and the line nearest to the wanted
4941 _bfd_vms_find_nearest_line (bfd
*abfd
,
4942 asymbol
**symbols ATTRIBUTE_UNUSED
,
4948 unsigned int *discriminator
)
4950 struct module
*module
;
4952 /* What address are we looking for? */
4953 bfd_vma addr
= section
->vma
+ offset
;
4961 /* We can't do anything if there is no DST (debug symbol table). */
4962 if (PRIV (dst_section
) == NULL
)
4965 /* Create the module list - if not already done. */
4966 if (PRIV (modules
) == NULL
)
4968 PRIV (modules
) = build_module_list (abfd
);
4969 if (PRIV (modules
) == NULL
)
4973 for (module
= PRIV (modules
); module
; module
= module
->next
)
4974 if (addr
>= module
->low
&& addr
<= module
->high
)
4975 return module_find_nearest_line (abfd
, module
, addr
, file
, func
, line
);
4980 /* Canonicalizations. */
4981 /* Set name, value, section and flags of SYM from E. */
4984 alpha_vms_convert_symbol (bfd
*abfd
, struct vms_symbol_entry
*e
, asymbol
*sym
)
4993 flags
= BSF_NO_FLAGS
;
4999 if (e
->flags
& EGSY__V_WEAK
)
5002 if (e
->flags
& EGSY__V_DEF
)
5004 /* Symbol definition. */
5005 flags
|= BSF_GLOBAL
;
5006 if (e
->flags
& EGSY__V_NORM
)
5007 flags
|= BSF_FUNCTION
;
5013 /* Symbol reference. */
5014 sec
= bfd_und_section_ptr
;
5019 /* A universal symbol is by definition global... */
5020 flags
|= BSF_GLOBAL
;
5022 /* ...and dynamic in shared libraries. */
5023 if (abfd
->flags
& DYNAMIC
)
5024 flags
|= BSF_DYNAMIC
;
5026 if (e
->flags
& EGSY__V_WEAK
)
5029 if (!(e
->flags
& EGSY__V_DEF
))
5032 if (e
->flags
& EGSY__V_NORM
)
5033 flags
|= BSF_FUNCTION
;
5036 /* sec = e->section; */
5037 sec
= bfd_abs_section_ptr
;
5052 /* Return the number of bytes required to store a vector of pointers
5053 to asymbols for all the symbols in the BFD abfd, including a
5054 terminal NULL pointer. If there are no symbols in the BFD,
5055 then return 0. If an error occurs, return -1. */
5058 alpha_vms_get_symtab_upper_bound (bfd
*abfd
)
5060 vms_debug2 ((1, "alpha_vms_get_symtab_upper_bound (%p), %d symbols\n",
5061 abfd
, PRIV (gsd_sym_count
)));
5063 return (PRIV (gsd_sym_count
) + 1) * sizeof (asymbol
*);
5066 /* Read the symbols from the BFD abfd, and fills in the vector
5067 location with pointers to the symbols and a trailing NULL.
5069 Return number of symbols read. */
5072 alpha_vms_canonicalize_symtab (bfd
*abfd
, asymbol
**symbols
)
5076 vms_debug2 ((1, "alpha_vms_canonicalize_symtab (%p, <ret>)\n", abfd
));
5078 if (PRIV (csymbols
) == NULL
)
5080 PRIV (csymbols
) = (asymbol
**) bfd_alloc
5081 (abfd
, PRIV (gsd_sym_count
) * sizeof (asymbol
*));
5083 /* Traverse table and fill symbols vector. */
5084 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
5086 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
5089 sym
= bfd_make_empty_symbol (abfd
);
5090 if (sym
== NULL
|| !alpha_vms_convert_symbol (abfd
, e
, sym
))
5092 bfd_release (abfd
, PRIV (csymbols
));
5093 PRIV (csymbols
) = NULL
;
5097 PRIV (csymbols
)[i
] = sym
;
5101 if (symbols
!= NULL
)
5103 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
5104 symbols
[i
] = PRIV (csymbols
)[i
];
5108 return PRIV (gsd_sym_count
);
5111 /* Read and convert relocations from ETIR. We do it once for all sections. */
5114 alpha_vms_slurp_relocs (bfd
*abfd
)
5118 vms_debug2 ((3, "alpha_vms_slurp_relocs\n"));
5120 /* We slurp relocs only once, for all sections. */
5121 if (PRIV (reloc_done
))
5123 PRIV (reloc_done
) = TRUE
;
5125 if (alpha_vms_canonicalize_symtab (abfd
, NULL
) < 0)
5128 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
5133 unsigned char *begin
;
5136 bfd_reloc_code_real_type reloc_code
;
5142 bfd_vma cur_address
;
5144 unsigned char *cur_sym
= NULL
;
5146 bfd_vma cur_addend
= 0;
5148 /* Skip non-ETIR records. */
5149 type
= _bfd_vms_get_object_record (abfd
);
5150 if (type
== EOBJ__C_EEOM
)
5152 if (type
!= EOBJ__C_ETIR
)
5155 begin
= PRIV (recrd
.rec
) + 4;
5156 end
= PRIV (recrd
.rec
) + PRIV (recrd
.rec_size
);
5158 for (ptr
= begin
; ptr
< end
; ptr
+= length
)
5162 cmd
= bfd_getl16 (ptr
);
5163 length
= bfd_getl16 (ptr
+ 2);
5165 cur_address
= vaddr
;
5167 vms_debug2 ((4, "alpha_vms_slurp_relocs: etir %s\n",
5168 _bfd_vms_etir_name (cmd
)));
5172 case ETIR__C_STA_GBL
: /* ALPHA_R_REFLONG und_section, step 1 */
5173 /* ALPHA_R_REFQUAD und_section, step 1 */
5178 case ETIR__C_STA_PQ
: /* ALPHA_R_REF{LONG|QUAD}, others part 1 */
5179 cur_psidx
= bfd_getl32 (ptr
+ 4);
5180 cur_addend
= bfd_getl64 (ptr
+ 8);
5184 case ETIR__C_CTL_SETRB
:
5185 if (prev_cmd
!= ETIR__C_STA_PQ
)
5188 /* xgettext:c-format */
5189 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (prev_cmd
),
5190 _bfd_vms_etir_name (cmd
));
5193 cur_psect
= cur_psidx
;
5199 case ETIR__C_STA_LW
: /* ALPHA_R_REFLONG abs_section, step 1 */
5200 /* ALPHA_R_REFLONG und_section, step 2 */
5203 if (prev_cmd
!= ETIR__C_STA_GBL
)
5206 /* xgettext:c-format */
5207 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
5208 _bfd_vms_etir_name (ETIR__C_STA_LW
));
5212 cur_addend
= bfd_getl32 (ptr
+ 4);
5216 case ETIR__C_STA_QW
: /* ALPHA_R_REFQUAD abs_section, step 1 */
5217 /* ALPHA_R_REFQUAD und_section, step 2 */
5218 if (prev_cmd
!= -1 && prev_cmd
!= ETIR__C_STA_GBL
)
5221 /* xgettext:c-format */
5222 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
5223 _bfd_vms_etir_name (ETIR__C_STA_QW
));
5226 cur_addend
= bfd_getl64 (ptr
+ 4);
5230 case ETIR__C_STO_LW
: /* ALPHA_R_REFLONG und_section, step 4 */
5231 /* ALPHA_R_REFLONG abs_section, step 2 */
5232 /* ALPHA_R_REFLONG others, step 2 */
5233 if (prev_cmd
!= ETIR__C_OPR_ADD
5234 && prev_cmd
!= ETIR__C_STA_LW
5235 && prev_cmd
!= ETIR__C_STA_PQ
)
5237 /* xgettext:c-format */
5238 _bfd_error_handler (_("unknown reloc %s + %s"),
5239 _bfd_vms_etir_name (prev_cmd
),
5240 _bfd_vms_etir_name (ETIR__C_STO_LW
));
5243 reloc_code
= BFD_RELOC_32
;
5246 case ETIR__C_STO_QW
: /* ALPHA_R_REFQUAD und_section, step 4 */
5247 /* ALPHA_R_REFQUAD abs_section, step 2 */
5248 if (prev_cmd
!= ETIR__C_OPR_ADD
&& prev_cmd
!= ETIR__C_STA_QW
)
5250 /* xgettext:c-format */
5251 _bfd_error_handler (_("unknown reloc %s + %s"),
5252 _bfd_vms_etir_name (prev_cmd
),
5253 _bfd_vms_etir_name (ETIR__C_STO_QW
));
5256 reloc_code
= BFD_RELOC_64
;
5259 case ETIR__C_STO_OFF
: /* ALPHA_R_REFQUAD others, step 2 */
5260 if (prev_cmd
!= ETIR__C_STA_PQ
)
5262 /* xgettext:c-format */
5263 _bfd_error_handler (_("unknown reloc %s + %s"),
5264 _bfd_vms_etir_name (prev_cmd
),
5265 _bfd_vms_etir_name (ETIR__C_STO_OFF
));
5268 reloc_code
= BFD_RELOC_64
;
5271 case ETIR__C_OPR_ADD
: /* ALPHA_R_REFLONG und_section, step 3 */
5272 /* ALPHA_R_REFQUAD und_section, step 3 */
5273 if (prev_cmd
!= ETIR__C_STA_LW
&& prev_cmd
!= ETIR__C_STA_QW
)
5275 /* xgettext:c-format */
5276 _bfd_error_handler (_("unknown reloc %s + %s"),
5277 _bfd_vms_etir_name (prev_cmd
),
5278 _bfd_vms_etir_name (ETIR__C_OPR_ADD
));
5281 prev_cmd
= ETIR__C_OPR_ADD
;
5284 case ETIR__C_STO_CA
: /* ALPHA_R_CODEADDR */
5285 reloc_code
= BFD_RELOC_ALPHA_CODEADDR
;
5289 case ETIR__C_STO_GBL
: /* ALPHA_R_REFQUAD und_section */
5290 reloc_code
= BFD_RELOC_64
;
5294 case ETIR__C_STO_GBL_LW
: /* ALPHA_R_REFLONG und_section */
5295 reloc_code
= BFD_RELOC_32
;
5299 case ETIR__C_STC_LP_PSB
: /* ALPHA_R_LINKAGE */
5300 reloc_code
= BFD_RELOC_ALPHA_LINKAGE
;
5304 case ETIR__C_STC_NOP_GBL
: /* ALPHA_R_NOP */
5305 reloc_code
= BFD_RELOC_ALPHA_NOP
;
5308 case ETIR__C_STC_BSR_GBL
: /* ALPHA_R_BSR */
5309 reloc_code
= BFD_RELOC_ALPHA_BSR
;
5312 case ETIR__C_STC_LDA_GBL
: /* ALPHA_R_LDA */
5313 reloc_code
= BFD_RELOC_ALPHA_LDA
;
5316 case ETIR__C_STC_BOH_GBL
: /* ALPHA_R_BOH */
5317 reloc_code
= BFD_RELOC_ALPHA_BOH
;
5321 cur_sym
= ptr
+ 4 + 32;
5322 cur_address
= bfd_getl64 (ptr
+ 4 + 8);
5323 cur_addend
= bfd_getl64 (ptr
+ 4 + 24);
5326 case ETIR__C_STO_IMM
:
5327 vaddr
+= bfd_getl32 (ptr
+ 4);
5331 _bfd_error_handler (_("unknown reloc %s"),
5332 _bfd_vms_etir_name (cmd
));
5338 struct vms_section_data_struct
*vms_sec
;
5342 /* Get section to which the relocation applies. */
5343 if (cur_psect
< 0 || cur_psect
> (int)PRIV (section_count
))
5345 _bfd_error_handler (_("invalid section index in ETIR"));
5349 if (PRIV (sections
) == NULL
)
5351 sec
= PRIV (sections
)[cur_psect
];
5352 if (sec
== bfd_abs_section_ptr
)
5354 _bfd_error_handler (_("relocation for non-REL psect"));
5358 vms_sec
= vms_section_data (sec
);
5360 /* Allocate a reloc entry. */
5361 if (sec
->reloc_count
>= vms_sec
->reloc_max
)
5363 if (vms_sec
->reloc_max
== 0)
5365 vms_sec
->reloc_max
= 64;
5366 sec
->relocation
= bfd_zmalloc
5367 (vms_sec
->reloc_max
* sizeof (arelent
));
5371 vms_sec
->reloc_max
*= 2;
5372 sec
->relocation
= bfd_realloc_or_free
5373 (sec
->relocation
, vms_sec
->reloc_max
* sizeof (arelent
));
5374 if (sec
->relocation
== NULL
)
5378 reloc
= &sec
->relocation
[sec
->reloc_count
];
5381 reloc
->howto
= bfd_reloc_type_lookup (abfd
, reloc_code
);
5383 if (cur_sym
!= NULL
)
5386 unsigned int symlen
= *cur_sym
;
5389 /* Linear search. */
5394 for (j
= 0; j
< PRIV (gsd_sym_count
); j
++)
5395 if (PRIV (syms
)[j
]->namelen
== symlen
5396 && memcmp (PRIV (syms
)[j
]->name
, cur_sym
, symlen
) == 0)
5398 sym
= &PRIV (csymbols
)[j
];
5403 _bfd_error_handler (_("unknown symbol in command %s"),
5404 _bfd_vms_etir_name (cmd
));
5405 reloc
->sym_ptr_ptr
= NULL
;
5408 reloc
->sym_ptr_ptr
= sym
;
5410 else if (cur_psidx
>= 0)
5412 if (PRIV (sections
) == NULL
|| cur_psidx
>= (int) PRIV (section_count
))
5414 reloc
->sym_ptr_ptr
=
5415 PRIV (sections
)[cur_psidx
]->symbol_ptr_ptr
;
5418 reloc
->sym_ptr_ptr
= NULL
;
5420 reloc
->address
= cur_address
;
5421 reloc
->addend
= cur_addend
;
5423 if (reloc_code
== ALPHA_R_LINKAGE
)
5426 size
= bfd_get_reloc_size (reloc
->howto
);
5436 vms_debug2 ((3, "alpha_vms_slurp_relocs: result = TRUE\n"));
5441 /* Return the number of bytes required to store the relocation
5442 information associated with the given section. */
5445 alpha_vms_get_reloc_upper_bound (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*section
)
5447 alpha_vms_slurp_relocs (abfd
);
5449 return (section
->reloc_count
+ 1) * sizeof (arelent
*);
5452 /* Convert relocations from VMS (external) form into BFD internal
5453 form. Return the number of relocations. */
5456 alpha_vms_canonicalize_reloc (bfd
*abfd
, asection
*section
, arelent
**relptr
,
5457 asymbol
**symbols ATTRIBUTE_UNUSED
)
5462 if (!alpha_vms_slurp_relocs (abfd
))
5465 count
= section
->reloc_count
;
5466 tblptr
= section
->relocation
;
5469 *relptr
++ = tblptr
++;
5471 *relptr
= (arelent
*) NULL
;
5472 return section
->reloc_count
;
5475 /* Install a new set of internal relocs. */
5477 #define alpha_vms_set_reloc _bfd_generic_set_reloc
5480 /* This is just copied from ecoff-alpha, needs to be fixed probably. */
5482 /* How to process the various reloc types. */
5484 static bfd_reloc_status_type
5485 reloc_nil (bfd
* abfd ATTRIBUTE_UNUSED
,
5486 arelent
*reloc ATTRIBUTE_UNUSED
,
5487 asymbol
*sym ATTRIBUTE_UNUSED
,
5488 void * data ATTRIBUTE_UNUSED
,
5489 asection
*sec ATTRIBUTE_UNUSED
,
5490 bfd
*output_bfd ATTRIBUTE_UNUSED
,
5491 char **error_message ATTRIBUTE_UNUSED
)
5494 vms_debug (1, "reloc_nil (abfd %p, output_bfd %p)\n", abfd
, output_bfd
);
5495 vms_debug (2, "In section %s, symbol %s\n",
5496 sec
->name
, sym
->name
);
5497 vms_debug (2, "reloc sym %s, addr %08lx, addend %08lx, reloc is a %s\n",
5498 reloc
->sym_ptr_ptr
[0]->name
,
5499 (unsigned long)reloc
->address
,
5500 (unsigned long)reloc
->addend
, reloc
->howto
->name
);
5501 vms_debug (2, "data at %p\n", data
);
5502 /* _bfd_hexdump (2, data, bfd_get_reloc_size (reloc->howto), 0); */
5505 return bfd_reloc_ok
;
5508 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
5509 from smaller values. Start with zero, widen, *then* decrement. */
5510 #define MINUS_ONE (((bfd_vma)0) - 1)
5512 static reloc_howto_type alpha_howto_table
[] =
5514 HOWTO (ALPHA_R_IGNORE
, /* Type. */
5515 0, /* Rightshift. */
5516 0, /* Size (0 = byte, 1 = short, 2 = long). */
5518 TRUE
, /* PC relative. */
5520 complain_overflow_dont
,/* Complain_on_overflow. */
5521 reloc_nil
, /* Special_function. */
5522 "IGNORE", /* Name. */
5523 TRUE
, /* Partial_inplace. */
5524 0, /* Source mask */
5526 TRUE
), /* PC rel offset. */
5528 /* A 64 bit reference to a symbol. */
5529 HOWTO (ALPHA_R_REFQUAD
, /* Type. */
5530 0, /* Rightshift. */
5531 4, /* Size (0 = byte, 1 = short, 2 = long). */
5533 FALSE
, /* PC relative. */
5535 complain_overflow_bitfield
, /* Complain_on_overflow. */
5536 reloc_nil
, /* Special_function. */
5537 "REFQUAD", /* Name. */
5538 TRUE
, /* Partial_inplace. */
5539 MINUS_ONE
, /* Source mask. */
5540 MINUS_ONE
, /* Dest mask. */
5541 FALSE
), /* PC rel offset. */
5543 /* A 21 bit branch. The native assembler generates these for
5544 branches within the text segment, and also fills in the PC
5545 relative offset in the instruction. */
5546 HOWTO (ALPHA_R_BRADDR
, /* Type. */
5547 2, /* Rightshift. */
5548 2, /* Size (0 = byte, 1 = short, 2 = long). */
5550 TRUE
, /* PC relative. */
5552 complain_overflow_signed
, /* Complain_on_overflow. */
5553 reloc_nil
, /* Special_function. */
5554 "BRADDR", /* Name. */
5555 TRUE
, /* Partial_inplace. */
5556 0x1fffff, /* Source mask. */
5557 0x1fffff, /* Dest mask. */
5558 FALSE
), /* PC rel offset. */
5560 /* A hint for a jump to a register. */
5561 HOWTO (ALPHA_R_HINT
, /* Type. */
5562 2, /* Rightshift. */
5563 1, /* Size (0 = byte, 1 = short, 2 = long). */
5565 TRUE
, /* PC relative. */
5567 complain_overflow_dont
,/* Complain_on_overflow. */
5568 reloc_nil
, /* Special_function. */
5570 TRUE
, /* Partial_inplace. */
5571 0x3fff, /* Source mask. */
5572 0x3fff, /* Dest mask. */
5573 FALSE
), /* PC rel offset. */
5575 /* 16 bit PC relative offset. */
5576 HOWTO (ALPHA_R_SREL16
, /* Type. */
5577 0, /* Rightshift. */
5578 1, /* Size (0 = byte, 1 = short, 2 = long). */
5580 TRUE
, /* PC relative. */
5582 complain_overflow_signed
, /* Complain_on_overflow. */
5583 reloc_nil
, /* Special_function. */
5584 "SREL16", /* Name. */
5585 TRUE
, /* Partial_inplace. */
5586 0xffff, /* Source mask. */
5587 0xffff, /* Dest mask. */
5588 FALSE
), /* PC rel offset. */
5590 /* 32 bit PC relative offset. */
5591 HOWTO (ALPHA_R_SREL32
, /* Type. */
5592 0, /* Rightshift. */
5593 2, /* Size (0 = byte, 1 = short, 2 = long). */
5595 TRUE
, /* PC relative. */
5597 complain_overflow_signed
, /* Complain_on_overflow. */
5598 reloc_nil
, /* Special_function. */
5599 "SREL32", /* Name. */
5600 TRUE
, /* Partial_inplace. */
5601 0xffffffff, /* Source mask. */
5602 0xffffffff, /* Dest mask. */
5603 FALSE
), /* PC rel offset. */
5605 /* A 64 bit PC relative offset. */
5606 HOWTO (ALPHA_R_SREL64
, /* Type. */
5607 0, /* Rightshift. */
5608 4, /* Size (0 = byte, 1 = short, 2 = long). */
5610 TRUE
, /* PC relative. */
5612 complain_overflow_signed
, /* Complain_on_overflow. */
5613 reloc_nil
, /* Special_function. */
5614 "SREL64", /* Name. */
5615 TRUE
, /* Partial_inplace. */
5616 MINUS_ONE
, /* Source mask. */
5617 MINUS_ONE
, /* Dest mask. */
5618 FALSE
), /* PC rel offset. */
5620 /* Push a value on the reloc evaluation stack. */
5621 HOWTO (ALPHA_R_OP_PUSH
, /* Type. */
5622 0, /* Rightshift. */
5623 0, /* Size (0 = byte, 1 = short, 2 = long). */
5625 FALSE
, /* PC relative. */
5627 complain_overflow_dont
,/* Complain_on_overflow. */
5628 reloc_nil
, /* Special_function. */
5629 "OP_PUSH", /* Name. */
5630 FALSE
, /* Partial_inplace. */
5631 0, /* Source mask. */
5633 FALSE
), /* PC rel offset. */
5635 /* Store the value from the stack at the given address. Store it in
5636 a bitfield of size r_size starting at bit position r_offset. */
5637 HOWTO (ALPHA_R_OP_STORE
, /* Type. */
5638 0, /* Rightshift. */
5639 4, /* Size (0 = byte, 1 = short, 2 = long). */
5641 FALSE
, /* PC relative. */
5643 complain_overflow_dont
,/* Complain_on_overflow. */
5644 reloc_nil
, /* Special_function. */
5645 "OP_STORE", /* Name. */
5646 FALSE
, /* Partial_inplace. */
5647 0, /* Source mask. */
5648 MINUS_ONE
, /* Dest mask. */
5649 FALSE
), /* PC rel offset. */
5651 /* Subtract the reloc address from the value on the top of the
5652 relocation stack. */
5653 HOWTO (ALPHA_R_OP_PSUB
, /* Type. */
5654 0, /* Rightshift. */
5655 0, /* Size (0 = byte, 1 = short, 2 = long). */
5657 FALSE
, /* PC relative. */
5659 complain_overflow_dont
,/* Complain_on_overflow. */
5660 reloc_nil
, /* Special_function. */
5661 "OP_PSUB", /* Name. */
5662 FALSE
, /* Partial_inplace. */
5663 0, /* Source mask. */
5665 FALSE
), /* PC rel offset. */
5667 /* Shift the value on the top of the relocation stack right by the
5669 HOWTO (ALPHA_R_OP_PRSHIFT
, /* Type. */
5670 0, /* Rightshift. */
5671 0, /* Size (0 = byte, 1 = short, 2 = long). */
5673 FALSE
, /* PC relative. */
5675 complain_overflow_dont
,/* Complain_on_overflow. */
5676 reloc_nil
, /* Special_function. */
5677 "OP_PRSHIFT", /* Name. */
5678 FALSE
, /* Partial_inplace. */
5679 0, /* Source mask. */
5681 FALSE
), /* PC rel offset. */
5683 /* Hack. Linkage is done by linker. */
5684 HOWTO (ALPHA_R_LINKAGE
, /* Type. */
5685 0, /* Rightshift. */
5686 0, /* Size (0 = byte, 1 = short, 2 = long). */
5688 FALSE
, /* PC relative. */
5690 complain_overflow_dont
,/* Complain_on_overflow. */
5691 reloc_nil
, /* Special_function. */
5692 "LINKAGE", /* Name. */
5693 FALSE
, /* Partial_inplace. */
5694 0, /* Source mask. */
5696 FALSE
), /* PC rel offset. */
5698 /* A 32 bit reference to a symbol. */
5699 HOWTO (ALPHA_R_REFLONG
, /* Type. */
5700 0, /* Rightshift. */
5701 2, /* Size (0 = byte, 1 = short, 2 = long). */
5703 FALSE
, /* PC relative. */
5705 complain_overflow_bitfield
, /* Complain_on_overflow. */
5706 reloc_nil
, /* Special_function. */
5707 "REFLONG", /* Name. */
5708 TRUE
, /* Partial_inplace. */
5709 0xffffffff, /* Source mask. */
5710 0xffffffff, /* Dest mask. */
5711 FALSE
), /* PC rel offset. */
5713 /* A 64 bit reference to a procedure, written as 32 bit value. */
5714 HOWTO (ALPHA_R_CODEADDR
, /* Type. */
5715 0, /* Rightshift. */
5716 4, /* Size (0 = byte, 1 = short, 2 = long). */
5718 FALSE
, /* PC relative. */
5720 complain_overflow_signed
,/* Complain_on_overflow. */
5721 reloc_nil
, /* Special_function. */
5722 "CODEADDR", /* Name. */
5723 FALSE
, /* Partial_inplace. */
5724 0xffffffff, /* Source mask. */
5725 0xffffffff, /* Dest mask. */
5726 FALSE
), /* PC rel offset. */
5728 HOWTO (ALPHA_R_NOP
, /* Type. */
5729 0, /* Rightshift. */
5730 3, /* Size (0 = byte, 1 = short, 2 = long). */
5732 /* The following value must match that of ALPHA_R_BSR/ALPHA_R_BOH
5733 because the calculations for the 3 relocations are the same.
5734 See B.4.5.2 of the OpenVMS Linker Utility Manual. */
5735 TRUE
, /* PC relative. */
5737 complain_overflow_dont
,/* Complain_on_overflow. */
5738 reloc_nil
, /* Special_function. */
5740 FALSE
, /* Partial_inplace. */
5741 0xffffffff, /* Source mask. */
5742 0xffffffff, /* Dest mask. */
5743 FALSE
), /* PC rel offset. */
5745 HOWTO (ALPHA_R_BSR
, /* Type. */
5746 0, /* Rightshift. */
5747 3, /* Size (0 = byte, 1 = short, 2 = long). */
5749 TRUE
, /* PC relative. */
5751 complain_overflow_dont
,/* Complain_on_overflow. */
5752 reloc_nil
, /* Special_function. */
5754 FALSE
, /* Partial_inplace. */
5755 0xffffffff, /* Source mask. */
5756 0xffffffff, /* Dest mask. */
5757 FALSE
), /* PC rel offset. */
5759 HOWTO (ALPHA_R_LDA
, /* Type. */
5760 0, /* Rightshift. */
5761 3, /* Size (0 = byte, 1 = short, 2 = long). */
5763 FALSE
, /* PC relative. */
5765 complain_overflow_dont
,/* Complain_on_overflow. */
5766 reloc_nil
, /* Special_function. */
5768 FALSE
, /* Partial_inplace. */
5769 0xffffffff, /* Source mask. */
5770 0xffffffff, /* Dest mask. */
5771 FALSE
), /* PC rel offset. */
5773 HOWTO (ALPHA_R_BOH
, /* Type. */
5774 0, /* Rightshift. */
5775 3, /* Size (0 = byte, 1 = short, 2 = long, 3 = nil). */
5777 TRUE
, /* PC relative. */
5779 complain_overflow_dont
,/* Complain_on_overflow. */
5780 reloc_nil
, /* Special_function. */
5782 FALSE
, /* Partial_inplace. */
5783 0xffffffff, /* Source mask. */
5784 0xffffffff, /* Dest mask. */
5785 FALSE
), /* PC rel offset. */
5788 /* Return a pointer to a howto structure which, when invoked, will perform
5789 the relocation code on data from the architecture noted. */
5791 static reloc_howto_type
*
5792 alpha_vms_bfd_reloc_type_lookup (bfd
* abfd ATTRIBUTE_UNUSED
,
5793 bfd_reloc_code_real_type code
)
5797 vms_debug2 ((1, "vms_bfd_reloc_type_lookup (%p, %d)\t", abfd
, code
));
5801 case BFD_RELOC_16
: alpha_type
= ALPHA_R_SREL16
; break;
5802 case BFD_RELOC_32
: alpha_type
= ALPHA_R_REFLONG
; break;
5803 case BFD_RELOC_64
: alpha_type
= ALPHA_R_REFQUAD
; break;
5804 case BFD_RELOC_CTOR
: alpha_type
= ALPHA_R_REFQUAD
; break;
5805 case BFD_RELOC_23_PCREL_S2
: alpha_type
= ALPHA_R_BRADDR
; break;
5806 case BFD_RELOC_ALPHA_HINT
: alpha_type
= ALPHA_R_HINT
; break;
5807 case BFD_RELOC_16_PCREL
: alpha_type
= ALPHA_R_SREL16
; break;
5808 case BFD_RELOC_32_PCREL
: alpha_type
= ALPHA_R_SREL32
; break;
5809 case BFD_RELOC_64_PCREL
: alpha_type
= ALPHA_R_SREL64
; break;
5810 case BFD_RELOC_ALPHA_LINKAGE
: alpha_type
= ALPHA_R_LINKAGE
; break;
5811 case BFD_RELOC_ALPHA_CODEADDR
: alpha_type
= ALPHA_R_CODEADDR
; break;
5812 case BFD_RELOC_ALPHA_NOP
: alpha_type
= ALPHA_R_NOP
; break;
5813 case BFD_RELOC_ALPHA_BSR
: alpha_type
= ALPHA_R_BSR
; break;
5814 case BFD_RELOC_ALPHA_LDA
: alpha_type
= ALPHA_R_LDA
; break;
5815 case BFD_RELOC_ALPHA_BOH
: alpha_type
= ALPHA_R_BOH
; break;
5817 _bfd_error_handler (_("reloc (%d) is *UNKNOWN*"), code
);
5820 vms_debug2 ((2, "reloc is %s\n", alpha_howto_table
[alpha_type
].name
));
5821 return & alpha_howto_table
[alpha_type
];
5824 static reloc_howto_type
*
5825 alpha_vms_bfd_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
5831 i
< sizeof (alpha_howto_table
) / sizeof (alpha_howto_table
[0]);
5833 if (alpha_howto_table
[i
].name
!= NULL
5834 && strcasecmp (alpha_howto_table
[i
].name
, r_name
) == 0)
5835 return &alpha_howto_table
[i
];
5841 alpha_vms_get_synthetic_symtab (bfd
*abfd
,
5842 long symcount ATTRIBUTE_UNUSED
,
5843 asymbol
**usyms ATTRIBUTE_UNUSED
,
5844 long dynsymcount ATTRIBUTE_UNUSED
,
5845 asymbol
**dynsyms ATTRIBUTE_UNUSED
,
5852 syms
= (asymbol
*) bfd_malloc (PRIV (norm_sym_count
) * sizeof (asymbol
));
5857 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
5859 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
5870 flags
= BSF_LOCAL
| BSF_SYNTHETIC
;
5877 if ((e
->flags
& EGSY__V_DEF
) && (e
->flags
& EGSY__V_NORM
))
5879 value
= e
->code_value
;
5880 sec
= e
->code_section
;
5891 sname
= bfd_alloc (abfd
, l
+ 5);
5894 memcpy (sname
, name
, l
);
5895 memcpy (sname
+ l
, "..en", 5);
5902 sym
->udata
.p
= NULL
;
5911 vms_time_to_str (unsigned char *buf
)
5913 time_t t
= vms_rawtime_to_time_t (buf
);
5914 char *res
= ctime (&t
);
5917 res
= "*invalid time*";
5924 evax_bfd_print_emh (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5926 struct vms_emh_common
*emh
= (struct vms_emh_common
*)rec
;
5927 unsigned int subtype
;
5930 subtype
= (unsigned) bfd_getl16 (emh
->subtyp
);
5932 /* xgettext:c-format */
5933 fprintf (file
, _(" EMH %u (len=%u): "), subtype
, rec_len
);
5935 /* PR 21618: Check for invalid lengths. */
5936 if (rec_len
< sizeof (* emh
))
5938 fprintf (file
, _(" Error: The length is less than the length of an EMH record\n"));
5941 extra
= rec_len
- sizeof (struct vms_emh_common
);
5947 struct vms_emh_mhd
*mhd
= (struct vms_emh_mhd
*) rec
;
5949 const char * nextname
;
5950 const char * maxname
;
5952 /* PR 21840: Check for invalid lengths. */
5953 if (rec_len
< sizeof (* mhd
))
5955 fprintf (file
, _(" Error: The record length is less than the size of an EMH_MHD record\n"));
5958 fprintf (file
, _("Module header\n"));
5959 fprintf (file
, _(" structure level: %u\n"), mhd
->strlvl
);
5960 fprintf (file
, _(" max record size: %u\n"),
5961 (unsigned) bfd_getl32 (mhd
->recsiz
));
5962 name
= (char *)(mhd
+ 1);
5963 maxname
= (char *) rec
+ rec_len
;
5964 if (name
> maxname
- 2)
5966 fprintf (file
, _(" Error: The module name is missing\n"));
5969 nextname
= name
+ name
[0] + 1;
5970 if (nextname
>= maxname
)
5972 fprintf (file
, _(" Error: The module name is too long\n"));
5975 fprintf (file
, _(" module name : %.*s\n"), name
[0], name
+ 1);
5977 if (name
> maxname
- 2)
5979 fprintf (file
, _(" Error: The module version is missing\n"));
5982 nextname
= name
+ name
[0] + 1;
5983 if (nextname
>= maxname
)
5985 fprintf (file
, _(" Error: The module version is too long\n"));
5988 fprintf (file
, _(" module version : %.*s\n"), name
[0], name
+ 1);
5990 if ((maxname
- name
) < 17 && maxname
[-1] != 0)
5991 fprintf (file
, _(" Error: The compile date is truncated\n"));
5993 fprintf (file
, _(" compile date : %.17s\n"), name
);
5998 fprintf (file
, _("Language Processor Name\n"));
5999 fprintf (file
, _(" language name: %.*s\n"), extra
, (char *)(emh
+ 1));
6003 fprintf (file
, _("Source Files Header\n"));
6004 fprintf (file
, _(" file: %.*s\n"), extra
, (char *)(emh
+ 1));
6008 fprintf (file
, _("Title Text Header\n"));
6009 fprintf (file
, _(" title: %.*s\n"), extra
, (char *)(emh
+ 1));
6013 fprintf (file
, _("Copyright Header\n"));
6014 fprintf (file
, _(" copyright: %.*s\n"), extra
, (char *)(emh
+ 1));
6018 fprintf (file
, _("unhandled emh subtype %u\n"), subtype
);
6024 evax_bfd_print_eeom (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
6026 struct vms_eeom
*eeom
= (struct vms_eeom
*)rec
;
6028 fprintf (file
, _(" EEOM (len=%u):\n"), rec_len
);
6030 /* PR 21618: Check for invalid lengths. */
6031 if (rec_len
< sizeof (* eeom
))
6033 fprintf (file
, _(" Error: The length is less than the length of an EEOM record\n"));
6037 fprintf (file
, _(" number of cond linkage pairs: %u\n"),
6038 (unsigned)bfd_getl32 (eeom
->total_lps
));
6039 fprintf (file
, _(" completion code: %u\n"),
6040 (unsigned)bfd_getl16 (eeom
->comcod
));
6043 fprintf (file
, _(" transfer addr flags: 0x%02x\n"), eeom
->tfrflg
);
6044 fprintf (file
, _(" transfer addr psect: %u\n"),
6045 (unsigned)bfd_getl32 (eeom
->psindx
));
6046 fprintf (file
, _(" transfer address : 0x%08x\n"),
6047 (unsigned)bfd_getl32 (eeom
->tfradr
));
6052 exav_bfd_print_egsy_flags (unsigned int flags
, FILE *file
)
6054 if (flags
& EGSY__V_WEAK
)
6055 fputs (_(" WEAK"), file
);
6056 if (flags
& EGSY__V_DEF
)
6057 fputs (_(" DEF"), file
);
6058 if (flags
& EGSY__V_UNI
)
6059 fputs (_(" UNI"), file
);
6060 if (flags
& EGSY__V_REL
)
6061 fputs (_(" REL"), file
);
6062 if (flags
& EGSY__V_COMM
)
6063 fputs (_(" COMM"), file
);
6064 if (flags
& EGSY__V_VECEP
)
6065 fputs (_(" VECEP"), file
);
6066 if (flags
& EGSY__V_NORM
)
6067 fputs (_(" NORM"), file
);
6068 if (flags
& EGSY__V_QUAD_VAL
)
6069 fputs (_(" QVAL"), file
);
6073 evax_bfd_print_egsd_flags (FILE *file
, unsigned int flags
)
6075 if (flags
& EGPS__V_PIC
)
6076 fputs (_(" PIC"), file
);
6077 if (flags
& EGPS__V_LIB
)
6078 fputs (_(" LIB"), file
);
6079 if (flags
& EGPS__V_OVR
)
6080 fputs (_(" OVR"), file
);
6081 if (flags
& EGPS__V_REL
)
6082 fputs (_(" REL"), file
);
6083 if (flags
& EGPS__V_GBL
)
6084 fputs (_(" GBL"), file
);
6085 if (flags
& EGPS__V_SHR
)
6086 fputs (_(" SHR"), file
);
6087 if (flags
& EGPS__V_EXE
)
6088 fputs (_(" EXE"), file
);
6089 if (flags
& EGPS__V_RD
)
6090 fputs (_(" RD"), file
);
6091 if (flags
& EGPS__V_WRT
)
6092 fputs (_(" WRT"), file
);
6093 if (flags
& EGPS__V_VEC
)
6094 fputs (_(" VEC"), file
);
6095 if (flags
& EGPS__V_NOMOD
)
6096 fputs (_(" NOMOD"), file
);
6097 if (flags
& EGPS__V_COM
)
6098 fputs (_(" COM"), file
);
6099 if (flags
& EGPS__V_ALLOC_64BIT
)
6100 fputs (_(" 64B"), file
);
6104 evax_bfd_print_egsd (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
6106 unsigned int off
= sizeof (struct vms_egsd
);
6109 fprintf (file
, _(" EGSD (len=%u):\n"), rec_len
);
6112 for (off
= sizeof (struct vms_egsd
); off
< rec_len
; )
6114 struct vms_egsd_entry
*e
= (struct vms_egsd_entry
*)(rec
+ off
);
6118 type
= (unsigned)bfd_getl16 (e
->gsdtyp
);
6119 len
= (unsigned)bfd_getl16 (e
->gsdsiz
);
6121 /* xgettext:c-format */
6122 fprintf (file
, _(" EGSD entry %2u (type: %u, len: %u): "),
6126 if (off
+ len
> rec_len
|| off
+ len
< off
)
6128 fprintf (file
, _(" Error: length larger than remaining space in record\n"));
6136 struct vms_egps
*egps
= (struct vms_egps
*)e
;
6137 unsigned int flags
= bfd_getl16 (egps
->flags
);
6140 fprintf (file
, _("PSC - Program section definition\n"));
6141 fprintf (file
, _(" alignment : 2**%u\n"), egps
->align
);
6142 fprintf (file
, _(" flags : 0x%04x"), flags
);
6143 evax_bfd_print_egsd_flags (file
, flags
);
6145 l
= bfd_getl32 (egps
->alloc
);
6146 fprintf (file
, _(" alloc (len): %u (0x%08x)\n"), l
, l
);
6147 fprintf (file
, _(" name : %.*s\n"),
6148 egps
->namlng
, egps
->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 fprintf (file
, _(" name : %.*s\n"),
6169 esgps
->namlng
, esgps
->name
);
6174 struct vms_egsy
*egsy
= (struct vms_egsy
*)e
;
6175 unsigned int flags
= bfd_getl16 (egsy
->flags
);
6177 if (flags
& EGSY__V_DEF
)
6179 struct vms_esdf
*esdf
= (struct vms_esdf
*)e
;
6181 fprintf (file
, _("SYM - Global symbol definition\n"));
6182 fprintf (file
, _(" flags: 0x%04x"), flags
);
6183 exav_bfd_print_egsy_flags (flags
, file
);
6185 fprintf (file
, _(" psect offset: 0x%08x\n"),
6186 (unsigned)bfd_getl32 (esdf
->value
));
6187 if (flags
& EGSY__V_NORM
)
6189 fprintf (file
, _(" code address: 0x%08x\n"),
6190 (unsigned)bfd_getl32 (esdf
->code_address
));
6191 fprintf (file
, _(" psect index for entry point : %u\n"),
6192 (unsigned)bfd_getl32 (esdf
->ca_psindx
));
6194 fprintf (file
, _(" psect index : %u\n"),
6195 (unsigned)bfd_getl32 (esdf
->psindx
));
6196 fprintf (file
, _(" name : %.*s\n"),
6197 esdf
->namlng
, esdf
->name
);
6201 struct vms_esrf
*esrf
= (struct vms_esrf
*)e
;
6203 fprintf (file
, _("SYM - Global symbol reference\n"));
6204 fprintf (file
, _(" name : %.*s\n"),
6205 esrf
->namlng
, esrf
->name
);
6211 struct vms_eidc
*eidc
= (struct vms_eidc
*)e
;
6212 unsigned int flags
= bfd_getl32 (eidc
->flags
);
6215 fprintf (file
, _("IDC - Ident Consistency check\n"));
6216 fprintf (file
, _(" flags : 0x%08x"), flags
);
6217 if (flags
& EIDC__V_BINIDENT
)
6218 fputs (" BINDENT", file
);
6220 fprintf (file
, _(" id match : %x\n"),
6221 (flags
>> EIDC__V_IDMATCH_SH
) & EIDC__V_IDMATCH_MASK
);
6222 fprintf (file
, _(" error severity: %x\n"),
6223 (flags
>> EIDC__V_ERRSEV_SH
) & EIDC__V_ERRSEV_MASK
);
6225 fprintf (file
, _(" entity name : %.*s\n"), p
[0], p
+ 1);
6227 fprintf (file
, _(" object name : %.*s\n"), p
[0], p
+ 1);
6229 if (flags
& EIDC__V_BINIDENT
)
6230 fprintf (file
, _(" binary ident : 0x%08x\n"),
6231 (unsigned)bfd_getl32 (p
+ 1));
6233 fprintf (file
, _(" ascii ident : %.*s\n"), p
[0], p
+ 1);
6238 struct vms_egst
*egst
= (struct vms_egst
*)e
;
6239 unsigned int flags
= bfd_getl16 (egst
->header
.flags
);
6241 fprintf (file
, _("SYMG - Universal symbol definition\n"));
6242 fprintf (file
, _(" flags: 0x%04x"), flags
);
6243 exav_bfd_print_egsy_flags (flags
, file
);
6245 fprintf (file
, _(" symbol vector offset: 0x%08x\n"),
6246 (unsigned)bfd_getl32 (egst
->value
));
6247 fprintf (file
, _(" entry point: 0x%08x\n"),
6248 (unsigned)bfd_getl32 (egst
->lp_1
));
6249 fprintf (file
, _(" proc descr : 0x%08x\n"),
6250 (unsigned)bfd_getl32 (egst
->lp_2
));
6251 fprintf (file
, _(" psect index: %u\n"),
6252 (unsigned)bfd_getl32 (egst
->psindx
));
6253 fprintf (file
, _(" name : %.*s\n"),
6254 egst
->namlng
, egst
->name
);
6259 struct vms_esdfv
*esdfv
= (struct vms_esdfv
*)e
;
6260 unsigned int flags
= bfd_getl16 (esdfv
->flags
);
6262 fprintf (file
, _("SYMV - Vectored symbol definition\n"));
6263 fprintf (file
, _(" flags: 0x%04x"), flags
);
6264 exav_bfd_print_egsy_flags (flags
, file
);
6266 fprintf (file
, _(" vector : 0x%08x\n"),
6267 (unsigned)bfd_getl32 (esdfv
->vector
));
6268 fprintf (file
, _(" psect offset: %u\n"),
6269 (unsigned)bfd_getl32 (esdfv
->value
));
6270 fprintf (file
, _(" psect index : %u\n"),
6271 (unsigned)bfd_getl32 (esdfv
->psindx
));
6272 fprintf (file
, _(" name : %.*s\n"),
6273 esdfv
->namlng
, esdfv
->name
);
6278 struct vms_esdfm
*esdfm
= (struct vms_esdfm
*)e
;
6279 unsigned int flags
= bfd_getl16 (esdfm
->flags
);
6281 fprintf (file
, _("SYMM - Global symbol definition with version\n"));
6282 fprintf (file
, _(" flags: 0x%04x"), flags
);
6283 exav_bfd_print_egsy_flags (flags
, file
);
6285 fprintf (file
, _(" version mask: 0x%08x\n"),
6286 (unsigned)bfd_getl32 (esdfm
->version_mask
));
6287 fprintf (file
, _(" psect offset: %u\n"),
6288 (unsigned)bfd_getl32 (esdfm
->value
));
6289 fprintf (file
, _(" psect index : %u\n"),
6290 (unsigned)bfd_getl32 (esdfm
->psindx
));
6291 fprintf (file
, _(" name : %.*s\n"),
6292 esdfm
->namlng
, esdfm
->name
);
6296 fprintf (file
, _("unhandled egsd entry type %u\n"), type
);
6304 evax_bfd_print_hex (FILE *file
, const char *pfx
,
6305 const unsigned char *buf
, unsigned int len
)
6311 for (i
= 0; i
< len
; i
++)
6315 fprintf (file
, " %02x", buf
[i
]);
6328 evax_bfd_print_etir_stc_ir (FILE *file
, const unsigned char *buf
, int is_ps
)
6330 /* xgettext:c-format */
6331 fprintf (file
, _(" linkage index: %u, replacement insn: 0x%08x\n"),
6332 (unsigned)bfd_getl32 (buf
),
6333 (unsigned)bfd_getl32 (buf
+ 16));
6334 /* xgettext:c-format */
6335 fprintf (file
, _(" psect idx 1: %u, offset 1: 0x%08x %08x\n"),
6336 (unsigned)bfd_getl32 (buf
+ 4),
6337 (unsigned)bfd_getl32 (buf
+ 12),
6338 (unsigned)bfd_getl32 (buf
+ 8));
6339 /* xgettext:c-format */
6340 fprintf (file
, _(" psect idx 2: %u, offset 2: 0x%08x %08x\n"),
6341 (unsigned)bfd_getl32 (buf
+ 20),
6342 (unsigned)bfd_getl32 (buf
+ 28),
6343 (unsigned)bfd_getl32 (buf
+ 24));
6345 /* xgettext:c-format */
6346 fprintf (file
, _(" psect idx 3: %u, offset 3: 0x%08x %08x\n"),
6347 (unsigned)bfd_getl32 (buf
+ 32),
6348 (unsigned)bfd_getl32 (buf
+ 40),
6349 (unsigned)bfd_getl32 (buf
+ 36));
6351 fprintf (file
, _(" global name: %.*s\n"), buf
[32], buf
+ 33);
6355 evax_bfd_print_etir (FILE *file
, const char *name
,
6356 unsigned char *rec
, unsigned int rec_len
)
6358 unsigned int off
= sizeof (struct vms_egsd
);
6359 unsigned int sec_len
= 0;
6361 /* xgettext:c-format */
6362 fprintf (file
, _(" %s (len=%u+%u):\n"), name
,
6363 (unsigned)(rec_len
- sizeof (struct vms_eobjrec
)),
6364 (unsigned)sizeof (struct vms_eobjrec
));
6366 for (off
= sizeof (struct vms_eobjrec
); off
< rec_len
; )
6368 struct vms_etir
*etir
= (struct vms_etir
*)(rec
+ off
);
6373 type
= bfd_getl16 (etir
->rectyp
);
6374 size
= bfd_getl16 (etir
->size
);
6375 buf
= rec
+ off
+ sizeof (struct vms_etir
);
6377 if (off
+ size
> rec_len
|| off
+ size
< off
)
6379 fprintf (file
, _(" Error: length larger than remaining space in record\n"));
6383 /* xgettext:c-format */
6384 fprintf (file
, _(" (type: %3u, size: 4+%3u): "), type
, size
- 4);
6387 case ETIR__C_STA_GBL
:
6388 fprintf (file
, _("STA_GBL (stack global) %.*s\n"),
6391 case ETIR__C_STA_LW
:
6392 fprintf (file
, _("STA_LW (stack longword) 0x%08x\n"),
6393 (unsigned)bfd_getl32 (buf
));
6395 case ETIR__C_STA_QW
:
6396 fprintf (file
, _("STA_QW (stack quadword) 0x%08x %08x\n"),
6397 (unsigned)bfd_getl32 (buf
+ 4),
6398 (unsigned)bfd_getl32 (buf
+ 0));
6400 case ETIR__C_STA_PQ
:
6401 fprintf (file
, _("STA_PQ (stack psect base + offset)\n"));
6402 /* xgettext:c-format */
6403 fprintf (file
, _(" psect: %u, offset: 0x%08x %08x\n"),
6404 (unsigned)bfd_getl32 (buf
+ 0),
6405 (unsigned)bfd_getl32 (buf
+ 8),
6406 (unsigned)bfd_getl32 (buf
+ 4));
6408 case ETIR__C_STA_LI
:
6409 fprintf (file
, _("STA_LI (stack literal)\n"));
6411 case ETIR__C_STA_MOD
:
6412 fprintf (file
, _("STA_MOD (stack module)\n"));
6414 case ETIR__C_STA_CKARG
:
6415 fprintf (file
, _("STA_CKARG (compare procedure argument)\n"));
6419 fprintf (file
, _("STO_B (store byte)\n"));
6422 fprintf (file
, _("STO_W (store word)\n"));
6424 case ETIR__C_STO_LW
:
6425 fprintf (file
, _("STO_LW (store longword)\n"));
6427 case ETIR__C_STO_QW
:
6428 fprintf (file
, _("STO_QW (store quadword)\n"));
6430 case ETIR__C_STO_IMMR
:
6432 unsigned int len
= bfd_getl32 (buf
);
6434 _("STO_IMMR (store immediate repeat) %u bytes\n"),
6436 evax_bfd_print_hex (file
, " ", buf
+ 4, len
);
6440 case ETIR__C_STO_GBL
:
6441 fprintf (file
, _("STO_GBL (store global) %.*s\n"),
6444 case ETIR__C_STO_CA
:
6445 fprintf (file
, _("STO_CA (store code address) %.*s\n"),
6448 case ETIR__C_STO_RB
:
6449 fprintf (file
, _("STO_RB (store relative branch)\n"));
6451 case ETIR__C_STO_AB
:
6452 fprintf (file
, _("STO_AB (store absolute branch)\n"));
6454 case ETIR__C_STO_OFF
:
6455 fprintf (file
, _("STO_OFF (store offset to psect)\n"));
6457 case ETIR__C_STO_IMM
:
6459 unsigned int len
= bfd_getl32 (buf
);
6461 _("STO_IMM (store immediate) %u bytes\n"),
6463 evax_bfd_print_hex (file
, " ", buf
+ 4, len
);
6467 case ETIR__C_STO_GBL_LW
:
6468 fprintf (file
, _("STO_GBL_LW (store global longword) %.*s\n"),
6471 case ETIR__C_STO_LP_PSB
:
6472 fprintf (file
, _("STO_OFF (store LP with procedure signature)\n"));
6474 case ETIR__C_STO_HINT_GBL
:
6475 fprintf (file
, _("STO_BR_GBL (store branch global) *todo*\n"));
6477 case ETIR__C_STO_HINT_PS
:
6478 fprintf (file
, _("STO_BR_PS (store branch psect + offset) *todo*\n"));
6481 case ETIR__C_OPR_NOP
:
6482 fprintf (file
, _("OPR_NOP (no-operation)\n"));
6484 case ETIR__C_OPR_ADD
:
6485 fprintf (file
, _("OPR_ADD (add)\n"));
6487 case ETIR__C_OPR_SUB
:
6488 fprintf (file
, _("OPR_SUB (subtract)\n"));
6490 case ETIR__C_OPR_MUL
:
6491 fprintf (file
, _("OPR_MUL (multiply)\n"));
6493 case ETIR__C_OPR_DIV
:
6494 fprintf (file
, _("OPR_DIV (divide)\n"));
6496 case ETIR__C_OPR_AND
:
6497 fprintf (file
, _("OPR_AND (logical and)\n"));
6499 case ETIR__C_OPR_IOR
:
6500 fprintf (file
, _("OPR_IOR (logical inclusive or)\n"));
6502 case ETIR__C_OPR_EOR
:
6503 fprintf (file
, _("OPR_EOR (logical exclusive or)\n"));
6505 case ETIR__C_OPR_NEG
:
6506 fprintf (file
, _("OPR_NEG (negate)\n"));
6508 case ETIR__C_OPR_COM
:
6509 fprintf (file
, _("OPR_COM (complement)\n"));
6511 case ETIR__C_OPR_INSV
:
6512 fprintf (file
, _("OPR_INSV (insert field)\n"));
6514 case ETIR__C_OPR_ASH
:
6515 fprintf (file
, _("OPR_ASH (arithmetic shift)\n"));
6517 case ETIR__C_OPR_USH
:
6518 fprintf (file
, _("OPR_USH (unsigned shift)\n"));
6520 case ETIR__C_OPR_ROT
:
6521 fprintf (file
, _("OPR_ROT (rotate)\n"));
6523 case ETIR__C_OPR_SEL
:
6524 fprintf (file
, _("OPR_SEL (select)\n"));
6526 case ETIR__C_OPR_REDEF
:
6527 fprintf (file
, _("OPR_REDEF (redefine symbol to curr location)\n"));
6529 case ETIR__C_OPR_DFLIT
:
6530 fprintf (file
, _("OPR_REDEF (define a literal)\n"));
6533 case ETIR__C_STC_LP
:
6534 fprintf (file
, _("STC_LP (store cond linkage pair)\n"));
6536 case ETIR__C_STC_LP_PSB
:
6538 _("STC_LP_PSB (store cond linkage pair + signature)\n"));
6539 /* xgettext:c-format */
6540 fprintf (file
, _(" linkage index: %u, procedure: %.*s\n"),
6541 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6542 buf
+= 4 + 1 + buf
[4];
6543 fprintf (file
, _(" signature: %.*s\n"), buf
[0], buf
+ 1);
6545 case ETIR__C_STC_GBL
:
6546 fprintf (file
, _("STC_GBL (store cond global)\n"));
6547 /* xgettext:c-format */
6548 fprintf (file
, _(" linkage index: %u, global: %.*s\n"),
6549 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6551 case ETIR__C_STC_GCA
:
6552 fprintf (file
, _("STC_GCA (store cond code address)\n"));
6553 /* xgettext:c-format */
6554 fprintf (file
, _(" linkage index: %u, procedure name: %.*s\n"),
6555 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6557 case ETIR__C_STC_PS
:
6558 fprintf (file
, _("STC_PS (store cond psect + offset)\n"));
6560 /* xgettext:c-format */
6561 _(" linkage index: %u, psect: %u, offset: 0x%08x %08x\n"),
6562 (unsigned)bfd_getl32 (buf
),
6563 (unsigned)bfd_getl32 (buf
+ 4),
6564 (unsigned)bfd_getl32 (buf
+ 12),
6565 (unsigned)bfd_getl32 (buf
+ 8));
6567 case ETIR__C_STC_NOP_GBL
:
6568 fprintf (file
, _("STC_NOP_GBL (store cond NOP at global addr)\n"));
6569 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6571 case ETIR__C_STC_NOP_PS
:
6572 fprintf (file
, _("STC_NOP_PS (store cond NOP at psect + offset)\n"));
6573 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6575 case ETIR__C_STC_BSR_GBL
:
6576 fprintf (file
, _("STC_BSR_GBL (store cond BSR at global addr)\n"));
6577 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6579 case ETIR__C_STC_BSR_PS
:
6580 fprintf (file
, _("STC_BSR_PS (store cond BSR at psect + offset)\n"));
6581 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6583 case ETIR__C_STC_LDA_GBL
:
6584 fprintf (file
, _("STC_LDA_GBL (store cond LDA at global addr)\n"));
6585 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6587 case ETIR__C_STC_LDA_PS
:
6588 fprintf (file
, _("STC_LDA_PS (store cond LDA at psect + offset)\n"));
6589 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6591 case ETIR__C_STC_BOH_GBL
:
6592 fprintf (file
, _("STC_BOH_GBL (store cond BOH at global addr)\n"));
6593 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6595 case ETIR__C_STC_BOH_PS
:
6596 fprintf (file
, _("STC_BOH_PS (store cond BOH at psect + offset)\n"));
6597 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6599 case ETIR__C_STC_NBH_GBL
:
6601 _("STC_NBH_GBL (store cond or hint at global addr)\n"));
6603 case ETIR__C_STC_NBH_PS
:
6605 _("STC_NBH_PS (store cond or hint at psect + offset)\n"));
6608 case ETIR__C_CTL_SETRB
:
6609 fprintf (file
, _("CTL_SETRB (set relocation base)\n"));
6612 case ETIR__C_CTL_AUGRB
:
6614 unsigned int val
= bfd_getl32 (buf
);
6615 fprintf (file
, _("CTL_AUGRB (augment relocation base) %u\n"), val
);
6618 case ETIR__C_CTL_DFLOC
:
6619 fprintf (file
, _("CTL_DFLOC (define location)\n"));
6621 case ETIR__C_CTL_STLOC
:
6622 fprintf (file
, _("CTL_STLOC (set location)\n"));
6624 case ETIR__C_CTL_STKDL
:
6625 fprintf (file
, _("CTL_STKDL (stack defined location)\n"));
6628 fprintf (file
, _("*unhandled*\n"));
6636 evax_bfd_print_eobj (struct bfd
*abfd
, FILE *file
)
6638 bfd_boolean is_first
= TRUE
;
6639 bfd_boolean has_records
= FALSE
;
6643 unsigned int rec_len
;
6644 unsigned int pad_len
;
6646 unsigned int hdr_size
;
6651 unsigned char buf
[6];
6656 if (bfd_bread (buf
, sizeof (buf
), abfd
) != sizeof (buf
))
6658 fprintf (file
, _("cannot read GST record length\n"));
6661 rec_len
= bfd_getl16 (buf
+ 0);
6662 if (rec_len
== bfd_getl16 (buf
+ 4)
6663 && bfd_getl16 (buf
+ 2) == EOBJ__C_EMH
)
6665 /* The format is raw: record-size, type, record-size. */
6667 pad_len
= (rec_len
+ 1) & ~1U;
6670 else if (rec_len
== EOBJ__C_EMH
)
6672 has_records
= FALSE
;
6673 pad_len
= bfd_getl16 (buf
+ 2);
6679 fprintf (file
, _("cannot find EMH in first GST record\n"));
6682 rec
= bfd_malloc (pad_len
);
6683 memcpy (rec
, buf
+ sizeof (buf
) - hdr_size
, hdr_size
);
6687 unsigned int rec_len2
= 0;
6688 unsigned char hdr
[4];
6692 unsigned char buf_len
[2];
6694 if (bfd_bread (buf_len
, sizeof (buf_len
), abfd
)
6695 != sizeof (buf_len
))
6697 fprintf (file
, _("cannot read GST record length\n"));
6700 rec_len2
= (unsigned)bfd_getl16 (buf_len
);
6703 if (bfd_bread (hdr
, sizeof (hdr
), abfd
) != sizeof (hdr
))
6705 fprintf (file
, _("cannot read GST record header\n"));
6708 rec_len
= (unsigned)bfd_getl16 (hdr
+ 2);
6710 pad_len
= (rec_len
+ 1) & ~1U;
6713 rec
= bfd_malloc (pad_len
);
6714 memcpy (rec
, hdr
, sizeof (hdr
));
6715 hdr_size
= sizeof (hdr
);
6716 if (has_records
&& rec_len2
!= rec_len
)
6718 fprintf (file
, _(" corrupted GST\n"));
6723 if (bfd_bread (rec
+ hdr_size
, pad_len
- hdr_size
, abfd
)
6724 != pad_len
- hdr_size
)
6726 fprintf (file
, _("cannot read GST record\n"));
6730 type
= (unsigned)bfd_getl16 (rec
);
6735 evax_bfd_print_emh (file
, rec
, rec_len
);
6738 evax_bfd_print_egsd (file
, rec
, rec_len
);
6741 evax_bfd_print_eeom (file
, rec
, rec_len
);
6746 evax_bfd_print_etir (file
, "ETIR", rec
, rec_len
);
6749 evax_bfd_print_etir (file
, "EDBG", rec
, rec_len
);
6752 evax_bfd_print_etir (file
, "ETBT", rec
, rec_len
);
6755 fprintf (file
, _(" unhandled EOBJ record type %u\n"), type
);
6763 evax_bfd_print_relocation_records (FILE *file
, const unsigned char *rel
,
6764 unsigned int stride
)
6772 count
= bfd_getl32 (rel
+ 0);
6776 base
= bfd_getl32 (rel
+ 4);
6778 /* xgettext:c-format */
6779 fprintf (file
, _(" bitcount: %u, base addr: 0x%08x\n"),
6783 for (j
= 0; count
> 0; j
+= 4, count
-= 32)
6789 val
= bfd_getl32 (rel
);
6792 /* xgettext:c-format */
6793 fprintf (file
, _(" bitmap: 0x%08x (count: %u):\n"), val
, count
);
6795 for (k
= 0; k
< 32; k
++)
6796 if (val
& (1u << k
))
6800 fprintf (file
, _(" %08x"), base
+ (j
* 8 + k
) * stride
);
6815 evax_bfd_print_address_fixups (FILE *file
, const unsigned char *rel
)
6822 count
= bfd_getl32 (rel
+ 0);
6825 /* xgettext:c-format */
6826 fprintf (file
, _(" image %u (%u entries)\n"),
6827 (unsigned)bfd_getl32 (rel
+ 4), count
);
6829 for (j
= 0; j
< count
; j
++)
6831 /* xgettext:c-format */
6832 fprintf (file
, _(" offset: 0x%08x, val: 0x%08x\n"),
6833 (unsigned)bfd_getl32 (rel
+ 0),
6834 (unsigned)bfd_getl32 (rel
+ 4));
6841 evax_bfd_print_reference_fixups (FILE *file
, const unsigned char *rel
)
6850 count
= bfd_getl32 (rel
+ 0);
6853 /* xgettext:c-format */
6854 fprintf (file
, _(" image %u (%u entries), offsets:\n"),
6855 (unsigned)bfd_getl32 (rel
+ 4), count
);
6857 for (j
= 0; j
< count
; j
++)
6861 fprintf (file
, _(" 0x%08x"), (unsigned)bfd_getl32 (rel
));
6876 evax_bfd_print_indent (int indent
, FILE *file
)
6878 for (; indent
; indent
--)
6883 evax_bfd_get_dsc_name (unsigned int v
)
6887 case DSC__K_DTYPE_Z
:
6888 return "Z (Unspecified)";
6889 case DSC__K_DTYPE_V
:
6891 case DSC__K_DTYPE_BU
:
6892 return "BU (Byte logical)";
6893 case DSC__K_DTYPE_WU
:
6894 return "WU (Word logical)";
6895 case DSC__K_DTYPE_LU
:
6896 return "LU (Longword logical)";
6897 case DSC__K_DTYPE_QU
:
6898 return "QU (Quadword logical)";
6899 case DSC__K_DTYPE_B
:
6900 return "B (Byte integer)";
6901 case DSC__K_DTYPE_W
:
6902 return "W (Word integer)";
6903 case DSC__K_DTYPE_L
:
6904 return "L (Longword integer)";
6905 case DSC__K_DTYPE_Q
:
6906 return "Q (Quadword integer)";
6907 case DSC__K_DTYPE_F
:
6908 return "F (Single-precision floating)";
6909 case DSC__K_DTYPE_D
:
6910 return "D (Double-precision floating)";
6911 case DSC__K_DTYPE_FC
:
6912 return "FC (Complex)";
6913 case DSC__K_DTYPE_DC
:
6914 return "DC (Double-precision Complex)";
6915 case DSC__K_DTYPE_T
:
6916 return "T (ASCII text string)";
6917 case DSC__K_DTYPE_NU
:
6918 return "NU (Numeric string, unsigned)";
6919 case DSC__K_DTYPE_NL
:
6920 return "NL (Numeric string, left separate sign)";
6921 case DSC__K_DTYPE_NLO
:
6922 return "NLO (Numeric string, left overpunched sign)";
6923 case DSC__K_DTYPE_NR
:
6924 return "NR (Numeric string, right separate sign)";
6925 case DSC__K_DTYPE_NRO
:
6926 return "NRO (Numeric string, right overpunched sig)";
6927 case DSC__K_DTYPE_NZ
:
6928 return "NZ (Numeric string, zoned sign)";
6929 case DSC__K_DTYPE_P
:
6930 return "P (Packed decimal string)";
6931 case DSC__K_DTYPE_ZI
:
6932 return "ZI (Sequence of instructions)";
6933 case DSC__K_DTYPE_ZEM
:
6934 return "ZEM (Procedure entry mask)";
6935 case DSC__K_DTYPE_DSC
:
6936 return "DSC (Descriptor, used for arrays of dyn strings)";
6937 case DSC__K_DTYPE_OU
:
6938 return "OU (Octaword logical)";
6939 case DSC__K_DTYPE_O
:
6940 return "O (Octaword integer)";
6941 case DSC__K_DTYPE_G
:
6942 return "G (Double precision G floating, 64 bit)";
6943 case DSC__K_DTYPE_H
:
6944 return "H (Quadruple precision floating, 128 bit)";
6945 case DSC__K_DTYPE_GC
:
6946 return "GC (Double precision complex, G floating)";
6947 case DSC__K_DTYPE_HC
:
6948 return "HC (Quadruple precision complex, H floating)";
6949 case DSC__K_DTYPE_CIT
:
6950 return "CIT (COBOL intermediate temporary)";
6951 case DSC__K_DTYPE_BPV
:
6952 return "BPV (Bound Procedure Value)";
6953 case DSC__K_DTYPE_BLV
:
6954 return "BLV (Bound Label Value)";
6955 case DSC__K_DTYPE_VU
:
6956 return "VU (Bit Unaligned)";
6957 case DSC__K_DTYPE_ADT
:
6958 return "ADT (Absolute Date-Time)";
6959 case DSC__K_DTYPE_VT
:
6960 return "VT (Varying Text)";
6961 case DSC__K_DTYPE_T2
:
6962 return "T2 (16-bit char)";
6963 case DSC__K_DTYPE_VT2
:
6964 return "VT2 (16-bit varying char)";
6966 return "?? (unknown)";
6971 evax_bfd_print_desc (const unsigned char *buf
, int indent
, FILE *file
)
6973 unsigned char bclass
= buf
[3];
6974 unsigned char dtype
= buf
[2];
6975 unsigned int len
= (unsigned)bfd_getl16 (buf
);
6976 unsigned int pointer
= (unsigned)bfd_getl32 (buf
+ 4);
6978 evax_bfd_print_indent (indent
, file
);
6980 if (len
== 1 && pointer
== 0xffffffffUL
)
6983 fprintf (file
, _("64 bits *unhandled*\n"));
6987 /* xgettext:c-format */
6988 fprintf (file
, _("class: %u, dtype: %u, length: %u, pointer: 0x%08x\n"),
6989 bclass
, dtype
, len
, pointer
);
6992 case DSC__K_CLASS_NCA
:
6994 const struct vms_dsc_nca
*dsc
= (const void *)buf
;
6996 const unsigned char *b
;
6998 evax_bfd_print_indent (indent
, file
);
6999 fprintf (file
, _("non-contiguous array of %s\n"),
7000 evax_bfd_get_dsc_name (dsc
->dtype
));
7001 evax_bfd_print_indent (indent
+ 1, file
);
7003 /* xgettext:c-format */
7004 _("dimct: %u, aflags: 0x%02x, digits: %u, scale: %u\n"),
7005 dsc
->dimct
, dsc
->aflags
, dsc
->digits
, dsc
->scale
);
7006 evax_bfd_print_indent (indent
+ 1, file
);
7008 /* xgettext:c-format */
7009 _("arsize: %u, a0: 0x%08x\n"),
7010 (unsigned)bfd_getl32 (dsc
->arsize
),
7011 (unsigned)bfd_getl32 (dsc
->a0
));
7012 evax_bfd_print_indent (indent
+ 1, file
);
7013 fprintf (file
, _("Strides:\n"));
7014 b
= buf
+ sizeof (*dsc
);
7015 for (i
= 0; i
< dsc
->dimct
; i
++)
7017 evax_bfd_print_indent (indent
+ 2, file
);
7018 fprintf (file
, "[%u]: %u\n", i
+ 1,
7019 (unsigned)bfd_getl32 (b
));
7022 evax_bfd_print_indent (indent
+ 1, file
);
7023 fprintf (file
, _("Bounds:\n"));
7024 b
= buf
+ sizeof (*dsc
);
7025 for (i
= 0; i
< dsc
->dimct
; i
++)
7027 evax_bfd_print_indent (indent
+ 2, file
);
7028 /* xgettext:c-format */
7029 fprintf (file
, _("[%u]: Lower: %u, upper: %u\n"), i
+ 1,
7030 (unsigned)bfd_getl32 (b
+ 0),
7031 (unsigned)bfd_getl32 (b
+ 4));
7036 case DSC__K_CLASS_UBS
:
7038 const struct vms_dsc_ubs
*ubs
= (const void *)buf
;
7040 evax_bfd_print_indent (indent
, file
);
7041 fprintf (file
, _("unaligned bit-string of %s\n"),
7042 evax_bfd_get_dsc_name (ubs
->dtype
));
7043 evax_bfd_print_indent (indent
+ 1, file
);
7045 /* xgettext:c-format */
7046 _("base: %u, pos: %u\n"),
7047 (unsigned)bfd_getl32 (ubs
->base
),
7048 (unsigned)bfd_getl32 (ubs
->pos
));
7052 fprintf (file
, _("*unhandled*\n"));
7059 evax_bfd_print_valspec (const unsigned char *buf
, int indent
, FILE *file
)
7061 unsigned int vflags
= buf
[0];
7062 unsigned int value
= (unsigned)bfd_getl32 (buf
+ 1);
7063 unsigned int len
= 5;
7065 evax_bfd_print_indent (indent
, file
);
7066 /* xgettext:c-format */
7067 fprintf (file
, _("vflags: 0x%02x, value: 0x%08x "), vflags
, value
);
7072 case DST__K_VFLAGS_NOVAL
:
7073 fprintf (file
, _("(no value)\n"));
7075 case DST__K_VFLAGS_NOTACTIVE
:
7076 fprintf (file
, _("(not active)\n"));
7078 case DST__K_VFLAGS_UNALLOC
:
7079 fprintf (file
, _("(not allocated)\n"));
7081 case DST__K_VFLAGS_DSC
:
7082 fprintf (file
, _("(descriptor)\n"));
7083 evax_bfd_print_desc (buf
+ value
, indent
+ 1, file
);
7085 case DST__K_VFLAGS_TVS
:
7086 fprintf (file
, _("(trailing value)\n"));
7088 case DST__K_VS_FOLLOWS
:
7089 fprintf (file
, _("(value spec follows)\n"));
7091 case DST__K_VFLAGS_BITOFFS
:
7092 fprintf (file
, _("(at bit offset %u)\n"), value
);
7095 /* xgettext:c-format */
7096 fprintf (file
, _("(reg: %u, disp: %u, indir: %u, kind: "),
7097 (vflags
& DST__K_REGNUM_MASK
) >> DST__K_REGNUM_SHIFT
,
7098 vflags
& DST__K_DISP
? 1 : 0,
7099 vflags
& DST__K_INDIR
? 1 : 0);
7100 switch (vflags
& DST__K_VALKIND_MASK
)
7102 case DST__K_VALKIND_LITERAL
:
7103 fputs (_("literal"), file
);
7105 case DST__K_VALKIND_ADDR
:
7106 fputs (_("address"), file
);
7108 case DST__K_VALKIND_DESC
:
7109 fputs (_("desc"), file
);
7111 case DST__K_VALKIND_REG
:
7112 fputs (_("reg"), file
);
7115 fputs (")\n", file
);
7122 evax_bfd_print_typspec (const unsigned char *buf
, int indent
, FILE *file
)
7124 unsigned char kind
= buf
[2];
7125 unsigned int len
= (unsigned)bfd_getl16 (buf
);
7127 evax_bfd_print_indent (indent
, file
);
7128 /* xgettext:c-format */
7129 fprintf (file
, _("len: %2u, kind: %2u "), len
, kind
);
7133 case DST__K_TS_ATOM
:
7134 /* xgettext:c-format */
7135 fprintf (file
, _("atomic, type=0x%02x %s\n"),
7136 buf
[0], evax_bfd_get_dsc_name (buf
[0]));
7139 fprintf (file
, _("indirect, defined at 0x%08x\n"),
7140 (unsigned)bfd_getl32 (buf
));
7142 case DST__K_TS_TPTR
:
7143 fprintf (file
, _("typed pointer\n"));
7144 evax_bfd_print_typspec (buf
, indent
+ 1, file
);
7147 fprintf (file
, _("pointer\n"));
7149 case DST__K_TS_ARRAY
:
7151 const unsigned char *vs
;
7152 unsigned int vec_len
;
7155 fprintf (file
, _("array, dim: %u, bitmap: "), buf
[0]);
7156 vec_len
= (buf
[0] + 1 + 7) / 8;
7157 for (i
= 0; i
< vec_len
; i
++)
7158 fprintf (file
, " %02x", buf
[i
+ 1]);
7160 vs
= buf
+ 1 + vec_len
;
7161 evax_bfd_print_indent (indent
, file
);
7162 fprintf (file
, _("array descriptor:\n"));
7163 vs
+= evax_bfd_print_valspec (vs
, indent
+ 1, file
);
7164 for (i
= 0; i
< buf
[0] + 1U; i
++)
7165 if (buf
[1 + i
/ 8] & (1 << (i
% 8)))
7167 evax_bfd_print_indent (indent
, file
);
7169 fprintf (file
, _("type spec for element:\n"));
7171 fprintf (file
, _("type spec for subscript %u:\n"), i
);
7172 evax_bfd_print_typspec (vs
, indent
+ 1, file
);
7173 vs
+= bfd_getl16 (vs
);
7178 fprintf (file
, _("*unhandled*\n"));
7183 evax_bfd_print_dst (struct bfd
*abfd
, unsigned int dst_size
, FILE *file
)
7185 unsigned int off
= 0;
7186 unsigned int pc
= 0;
7187 unsigned int line
= 0;
7189 fprintf (file
, _("Debug symbol table:\n"));
7191 while (dst_size
> 0)
7193 struct vms_dst_header dsth
;
7198 if (bfd_bread (&dsth
, sizeof (dsth
), abfd
) != sizeof (dsth
))
7200 fprintf (file
, _("cannot read DST header\n"));
7203 len
= bfd_getl16 (dsth
.length
);
7204 type
= bfd_getl16 (dsth
.type
);
7205 /* xgettext:c-format */
7206 fprintf (file
, _(" type: %3u, len: %3u (at 0x%08x): "),
7216 len
-= sizeof (dsth
);
7217 buf
= _bfd_malloc_and_read (abfd
, len
, len
);
7220 fprintf (file
, _("cannot read DST symbol\n"));
7225 case DSC__K_DTYPE_V
:
7226 case DSC__K_DTYPE_BU
:
7227 case DSC__K_DTYPE_WU
:
7228 case DSC__K_DTYPE_LU
:
7229 case DSC__K_DTYPE_QU
:
7230 case DSC__K_DTYPE_B
:
7231 case DSC__K_DTYPE_W
:
7232 case DSC__K_DTYPE_L
:
7233 case DSC__K_DTYPE_Q
:
7234 case DSC__K_DTYPE_F
:
7235 case DSC__K_DTYPE_D
:
7236 case DSC__K_DTYPE_FC
:
7237 case DSC__K_DTYPE_DC
:
7238 case DSC__K_DTYPE_T
:
7239 case DSC__K_DTYPE_NU
:
7240 case DSC__K_DTYPE_NL
:
7241 case DSC__K_DTYPE_NLO
:
7242 case DSC__K_DTYPE_NR
:
7243 case DSC__K_DTYPE_NRO
:
7244 case DSC__K_DTYPE_NZ
:
7245 case DSC__K_DTYPE_P
:
7246 case DSC__K_DTYPE_ZI
:
7247 case DSC__K_DTYPE_ZEM
:
7248 case DSC__K_DTYPE_DSC
:
7249 case DSC__K_DTYPE_OU
:
7250 case DSC__K_DTYPE_O
:
7251 case DSC__K_DTYPE_G
:
7252 case DSC__K_DTYPE_H
:
7253 case DSC__K_DTYPE_GC
:
7254 case DSC__K_DTYPE_HC
:
7255 case DSC__K_DTYPE_CIT
:
7256 case DSC__K_DTYPE_BPV
:
7257 case DSC__K_DTYPE_BLV
:
7258 case DSC__K_DTYPE_VU
:
7259 case DSC__K_DTYPE_ADT
:
7260 case DSC__K_DTYPE_VT
:
7261 case DSC__K_DTYPE_T2
:
7262 case DSC__K_DTYPE_VT2
:
7263 fprintf (file
, _("standard data: %s\n"),
7264 evax_bfd_get_dsc_name (type
));
7265 evax_bfd_print_valspec (buf
, 4, file
);
7266 fprintf (file
, _(" name: %.*s\n"), buf
[5], buf
+ 6);
7270 struct vms_dst_modbeg
*dst
= (void *)buf
;
7271 const char *name
= (const char *)buf
+ sizeof (*dst
);
7273 fprintf (file
, _("modbeg\n"));
7274 /* xgettext:c-format */
7275 fprintf (file
, _(" flags: %d, language: %u, "
7276 "major: %u, minor: %u\n"),
7278 (unsigned)bfd_getl32 (dst
->language
),
7279 (unsigned)bfd_getl16 (dst
->major
),
7280 (unsigned)bfd_getl16 (dst
->minor
));
7281 fprintf (file
, _(" module name: %.*s\n"),
7283 name
+= name
[0] + 1;
7284 fprintf (file
, _(" compiler : %.*s\n"),
7289 fprintf (file
, _("modend\n"));
7293 struct vms_dst_rtnbeg
*dst
= (void *)buf
;
7294 const char *name
= (const char *)buf
+ sizeof (*dst
);
7296 fputs (_("rtnbeg\n"), file
);
7297 /* xgettext:c-format */
7298 fprintf (file
, _(" flags: %u, address: 0x%08x, "
7299 "pd-address: 0x%08x\n"),
7301 (unsigned)bfd_getl32 (dst
->address
),
7302 (unsigned)bfd_getl32 (dst
->pd_address
));
7303 fprintf (file
, _(" routine name: %.*s\n"),
7309 struct vms_dst_rtnend
*dst
= (void *)buf
;
7311 fprintf (file
, _("rtnend: size 0x%08x\n"),
7312 (unsigned)bfd_getl32 (dst
->size
));
7317 struct vms_dst_prolog
*dst
= (void *)buf
;
7319 fprintf (file
, _("prolog: bkpt address 0x%08x\n"),
7320 (unsigned)bfd_getl32 (dst
->bkpt_addr
));
7325 struct vms_dst_epilog
*dst
= (void *)buf
;
7327 /* xgettext:c-format */
7328 fprintf (file
, _("epilog: flags: %u, count: %u\n"),
7329 dst
->flags
, (unsigned)bfd_getl32 (dst
->count
));
7334 struct vms_dst_blkbeg
*dst
= (void *)buf
;
7335 const char *name
= (const char *)buf
+ sizeof (*dst
);
7337 /* xgettext:c-format */
7338 fprintf (file
, _("blkbeg: address: 0x%08x, name: %.*s\n"),
7339 (unsigned)bfd_getl32 (dst
->address
),
7345 struct vms_dst_blkend
*dst
= (void *)buf
;
7347 fprintf (file
, _("blkend: size: 0x%08x\n"),
7348 (unsigned)bfd_getl32 (dst
->size
));
7351 case DST__K_TYPSPEC
:
7353 fprintf (file
, _("typspec (len: %u)\n"), len
);
7354 fprintf (file
, _(" name: %.*s\n"), buf
[0], buf
+ 1);
7355 evax_bfd_print_typspec (buf
+ 1 + buf
[0], 5, file
);
7360 fprintf (file
, _("septyp, name: %.*s\n"), buf
[5], buf
+ 6);
7361 evax_bfd_print_valspec (buf
, 4, file
);
7366 struct vms_dst_recbeg
*recbeg
= (void *)buf
;
7367 const char *name
= (const char *)buf
+ sizeof (*recbeg
);
7369 fprintf (file
, _("recbeg: name: %.*s\n"), name
[0], name
+ 1);
7370 evax_bfd_print_valspec (buf
, 4, file
);
7371 fprintf (file
, _(" len: %u bits\n"),
7372 (unsigned)bfd_getl32 (name
+ 1 + name
[0]));
7376 fprintf (file
, _("recend\n"));
7378 case DST__K_ENUMBEG
:
7379 /* xgettext:c-format */
7380 fprintf (file
, _("enumbeg, len: %u, name: %.*s\n"),
7381 buf
[0], buf
[1], buf
+ 2);
7383 case DST__K_ENUMELT
:
7384 fprintf (file
, _("enumelt, name: %.*s\n"), buf
[5], buf
+ 6);
7385 evax_bfd_print_valspec (buf
, 4, file
);
7387 case DST__K_ENUMEND
:
7388 fprintf (file
, _("enumend\n"));
7392 struct vms_dst_label
*lab
= (void *)buf
;
7393 fprintf (file
, _("label, name: %.*s\n"),
7394 lab
->name
[0], lab
->name
+ 1);
7395 fprintf (file
, _(" address: 0x%08x\n"),
7396 (unsigned)bfd_getl32 (lab
->value
));
7399 case DST__K_DIS_RANGE
:
7401 unsigned int cnt
= bfd_getl32 (buf
);
7402 unsigned char *rng
= buf
+ 4;
7405 fprintf (file
, _("discontiguous range (nbr: %u)\n"), cnt
);
7406 for (i
= 0; i
< cnt
; i
++, rng
+= 8)
7407 /* xgettext:c-format */
7408 fprintf (file
, _(" address: 0x%08x, size: %u\n"),
7409 (unsigned)bfd_getl32 (rng
),
7410 (unsigned)bfd_getl32 (rng
+ 4));
7414 case DST__K_LINE_NUM
:
7416 unsigned char *buf_orig
= buf
;
7418 fprintf (file
, _("line num (len: %u)\n"), len
);
7423 unsigned char cmdlen
;
7433 case DST__K_DELTA_PC_W
:
7434 val
= bfd_getl16 (buf
+ 1);
7435 fprintf (file
, _("delta_pc_w %u\n"), val
);
7440 case DST__K_INCR_LINUM
:
7442 fprintf (file
, _("incr_linum(b): +%u\n"), val
);
7446 case DST__K_INCR_LINUM_W
:
7447 val
= bfd_getl16 (buf
+ 1);
7448 fprintf (file
, _("incr_linum_w: +%u\n"), val
);
7452 case DST__K_INCR_LINUM_L
:
7453 val
= bfd_getl32 (buf
+ 1);
7454 fprintf (file
, _("incr_linum_l: +%u\n"), val
);
7458 case DST__K_SET_LINUM
:
7459 line
= bfd_getl16 (buf
+ 1);
7460 fprintf (file
, _("set_line_num(w) %u\n"), line
);
7463 case DST__K_SET_LINUM_B
:
7465 fprintf (file
, _("set_line_num_b %u\n"), line
);
7468 case DST__K_SET_LINUM_L
:
7469 line
= bfd_getl32 (buf
+ 1);
7470 fprintf (file
, _("set_line_num_l %u\n"), line
);
7473 case DST__K_SET_ABS_PC
:
7474 pc
= bfd_getl32 (buf
+ 1);
7475 fprintf (file
, _("set_abs_pc: 0x%08x\n"), pc
);
7478 case DST__K_DELTA_PC_L
:
7479 fprintf (file
, _("delta_pc_l: +0x%08x\n"),
7480 (unsigned)bfd_getl32 (buf
+ 1));
7484 fprintf (file
, _("term(b): 0x%02x"), buf
[1]);
7486 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7490 val
= bfd_getl16 (buf
+ 1);
7491 fprintf (file
, _("term_w: 0x%04x"), val
);
7493 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7499 fprintf (file
, _("delta pc +%-4d"), -cmd
);
7500 line
++; /* FIXME: curr increment. */
7502 /* xgettext:c-format */
7503 fprintf (file
, _(" pc: 0x%08x line: %5u\n"),
7508 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7521 unsigned char *buf_orig
= buf
;
7523 fprintf (file
, _("source (len: %u)\n"), len
);
7527 signed char cmd
= buf
[0];
7528 unsigned char cmdlen
= 0;
7532 case DST__K_SRC_DECLFILE
:
7534 struct vms_dst_src_decl_src
*src
= (void *)(buf
+ 1);
7537 /* xgettext:c-format */
7538 fprintf (file
, _(" declfile: len: %u, flags: %u, "
7540 src
->length
, src
->flags
,
7541 (unsigned)bfd_getl16 (src
->fileid
));
7542 /* xgettext:c-format */
7543 fprintf (file
, _(" rms: cdt: 0x%08x %08x, "
7544 "ebk: 0x%08x, ffb: 0x%04x, "
7546 (unsigned)bfd_getl32 (src
->rms_cdt
+ 4),
7547 (unsigned)bfd_getl32 (src
->rms_cdt
+ 0),
7548 (unsigned)bfd_getl32 (src
->rms_ebk
),
7549 (unsigned)bfd_getl16 (src
->rms_ffb
),
7551 name
= (const char *)buf
+ 1 + sizeof (*src
);
7552 fprintf (file
, _(" filename : %.*s\n"),
7554 name
+= name
[0] + 1;
7555 fprintf (file
, _(" module name: %.*s\n"),
7557 cmdlen
= 2 + src
->length
;
7560 case DST__K_SRC_SETFILE
:
7561 fprintf (file
, _(" setfile %u\n"),
7562 (unsigned)bfd_getl16 (buf
+ 1));
7565 case DST__K_SRC_SETREC_W
:
7566 fprintf (file
, _(" setrec %u\n"),
7567 (unsigned)bfd_getl16 (buf
+ 1));
7570 case DST__K_SRC_SETREC_L
:
7571 fprintf (file
, _(" setrec %u\n"),
7572 (unsigned)bfd_getl32 (buf
+ 1));
7575 case DST__K_SRC_SETLNUM_W
:
7576 fprintf (file
, _(" setlnum %u\n"),
7577 (unsigned)bfd_getl16 (buf
+ 1));
7580 case DST__K_SRC_SETLNUM_L
:
7581 fprintf (file
, _(" setlnum %u\n"),
7582 (unsigned)bfd_getl32 (buf
+ 1));
7585 case DST__K_SRC_DEFLINES_W
:
7586 fprintf (file
, _(" deflines %u\n"),
7587 (unsigned)bfd_getl16 (buf
+ 1));
7590 case DST__K_SRC_DEFLINES_B
:
7591 fprintf (file
, _(" deflines %u\n"), buf
[1]);
7594 case DST__K_SRC_FORMFEED
:
7595 fprintf (file
, _(" formfeed\n"));
7599 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7611 fprintf (file
, _("*unhandled* dst type %u\n"), type
);
7619 evax_bfd_print_image (bfd
*abfd
, FILE *file
)
7621 struct vms_eihd eihd
;
7624 unsigned int eiha_off
;
7625 unsigned int eihi_off
;
7626 unsigned int eihs_off
;
7627 unsigned int eisd_off
;
7628 unsigned int eihef_off
= 0;
7629 unsigned int eihnp_off
= 0;
7630 unsigned int dmt_vbn
= 0;
7631 unsigned int dmt_size
= 0;
7632 unsigned int dst_vbn
= 0;
7633 unsigned int dst_size
= 0;
7634 unsigned int gst_vbn
= 0;
7635 unsigned int gst_size
= 0;
7636 unsigned int eiaf_vbn
= 0;
7637 unsigned int eiaf_size
= 0;
7638 unsigned int eihvn_off
;
7640 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
)
7641 || bfd_bread (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
7643 fprintf (file
, _("cannot read EIHD\n"));
7646 /* xgettext:c-format */
7647 fprintf (file
, _("EIHD: (size: %u, nbr blocks: %u)\n"),
7648 (unsigned)bfd_getl32 (eihd
.size
),
7649 (unsigned)bfd_getl32 (eihd
.hdrblkcnt
));
7650 /* xgettext:c-format */
7651 fprintf (file
, _(" majorid: %u, minorid: %u\n"),
7652 (unsigned)bfd_getl32 (eihd
.majorid
),
7653 (unsigned)bfd_getl32 (eihd
.minorid
));
7655 val
= (unsigned)bfd_getl32 (eihd
.imgtype
);
7659 name
= _("executable");
7662 name
= _("linkable image");
7665 name
= _("unknown");
7668 /* xgettext:c-format */
7669 fprintf (file
, _(" image type: %u (%s)"), val
, name
);
7671 val
= (unsigned)bfd_getl32 (eihd
.subtype
);
7674 case EIHD__C_NATIVE
:
7681 name
= _("unknown");
7684 /* xgettext:c-format */
7685 fprintf (file
, _(", subtype: %u (%s)\n"), val
, name
);
7687 eisd_off
= bfd_getl32 (eihd
.isdoff
);
7688 eiha_off
= bfd_getl32 (eihd
.activoff
);
7689 eihi_off
= bfd_getl32 (eihd
.imgidoff
);
7690 eihs_off
= bfd_getl32 (eihd
.symdbgoff
);
7691 /* xgettext:c-format */
7692 fprintf (file
, _(" offsets: isd: %u, activ: %u, symdbg: %u, "
7693 "imgid: %u, patch: %u\n"),
7694 eisd_off
, eiha_off
, eihs_off
, eihi_off
,
7695 (unsigned)bfd_getl32 (eihd
.patchoff
));
7696 fprintf (file
, _(" fixup info rva: "));
7697 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.iafva
));
7698 fprintf (file
, _(", symbol vector rva: "));
7699 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.symvva
));
7700 eihvn_off
= bfd_getl32 (eihd
.version_array_off
);
7701 fprintf (file
, _("\n"
7702 " version array off: %u\n"),
7705 /* xgettext:c-format */
7706 _(" img I/O count: %u, nbr channels: %u, req pri: %08x%08x\n"),
7707 (unsigned)bfd_getl32 (eihd
.imgiocnt
),
7708 (unsigned)bfd_getl32 (eihd
.iochancnt
),
7709 (unsigned)bfd_getl32 (eihd
.privreqs
+ 4),
7710 (unsigned)bfd_getl32 (eihd
.privreqs
+ 0));
7711 val
= (unsigned)bfd_getl32 (eihd
.lnkflags
);
7712 fprintf (file
, _(" linker flags: %08x:"), val
);
7713 if (val
& EIHD__M_LNKDEBUG
)
7714 fprintf (file
, " LNKDEBUG");
7715 if (val
& EIHD__M_LNKNOTFR
)
7716 fprintf (file
, " LNKNOTFR");
7717 if (val
& EIHD__M_NOP0BUFS
)
7718 fprintf (file
, " NOP0BUFS");
7719 if (val
& EIHD__M_PICIMG
)
7720 fprintf (file
, " PICIMG");
7721 if (val
& EIHD__M_P0IMAGE
)
7722 fprintf (file
, " P0IMAGE");
7723 if (val
& EIHD__M_DBGDMT
)
7724 fprintf (file
, " DBGDMT");
7725 if (val
& EIHD__M_INISHR
)
7726 fprintf (file
, " INISHR");
7727 if (val
& EIHD__M_XLATED
)
7728 fprintf (file
, " XLATED");
7729 if (val
& EIHD__M_BIND_CODE_SEC
)
7730 fprintf (file
, " BIND_CODE_SEC");
7731 if (val
& EIHD__M_BIND_DATA_SEC
)
7732 fprintf (file
, " BIND_DATA_SEC");
7733 if (val
& EIHD__M_MKTHREADS
)
7734 fprintf (file
, " MKTHREADS");
7735 if (val
& EIHD__M_UPCALLS
)
7736 fprintf (file
, " UPCALLS");
7737 if (val
& EIHD__M_OMV_READY
)
7738 fprintf (file
, " OMV_READY");
7739 if (val
& EIHD__M_EXT_BIND_SECT
)
7740 fprintf (file
, " EXT_BIND_SECT");
7741 fprintf (file
, "\n");
7742 /* xgettext:c-format */
7743 fprintf (file
, _(" ident: 0x%08x, sysver: 0x%08x, "
7744 "match ctrl: %u, symvect_size: %u\n"),
7745 (unsigned)bfd_getl32 (eihd
.ident
),
7746 (unsigned)bfd_getl32 (eihd
.sysver
),
7748 (unsigned)bfd_getl32 (eihd
.symvect_size
));
7749 fprintf (file
, _(" BPAGE: %u"),
7750 (unsigned)bfd_getl32 (eihd
.virt_mem_block_size
));
7751 if (val
& (EIHD__M_OMV_READY
| EIHD__M_EXT_BIND_SECT
))
7753 eihef_off
= bfd_getl32 (eihd
.ext_fixup_off
);
7754 eihnp_off
= bfd_getl32 (eihd
.noopt_psect_off
);
7755 /* xgettext:c-format */
7756 fprintf (file
, _(", ext fixup offset: %u, no_opt psect off: %u"),
7757 eihef_off
, eihnp_off
);
7759 fprintf (file
, _(", alias: %u\n"), (unsigned)bfd_getl16 (eihd
.alias
));
7763 struct vms_eihvn eihvn
;
7767 fprintf (file
, _("system version array information:\n"));
7768 if (bfd_seek (abfd
, (file_ptr
) eihvn_off
, SEEK_SET
)
7769 || bfd_bread (&eihvn
, sizeof (eihvn
), abfd
) != sizeof (eihvn
))
7771 fprintf (file
, _("cannot read EIHVN header\n"));
7774 mask
= bfd_getl32 (eihvn
.subsystem_mask
);
7775 for (j
= 0; j
< 32; j
++)
7776 if (mask
& (1 << j
))
7778 struct vms_eihvn_subversion ver
;
7779 if (bfd_bread (&ver
, sizeof (ver
), abfd
) != sizeof (ver
))
7781 fprintf (file
, _("cannot read EIHVN version\n"));
7784 fprintf (file
, _(" %02u "), j
);
7787 case EIHVN__BASE_IMAGE_BIT
:
7788 fputs (_("BASE_IMAGE "), file
);
7790 case EIHVN__MEMORY_MANAGEMENT_BIT
:
7791 fputs (_("MEMORY_MANAGEMENT"), file
);
7794 fputs (_("IO "), file
);
7796 case EIHVN__FILES_VOLUMES_BIT
:
7797 fputs (_("FILES_VOLUMES "), file
);
7799 case EIHVN__PROCESS_SCHED_BIT
:
7800 fputs (_("PROCESS_SCHED "), file
);
7802 case EIHVN__SYSGEN_BIT
:
7803 fputs (_("SYSGEN "), file
);
7805 case EIHVN__CLUSTERS_LOCKMGR_BIT
:
7806 fputs (_("CLUSTERS_LOCKMGR "), file
);
7808 case EIHVN__LOGICAL_NAMES_BIT
:
7809 fputs (_("LOGICAL_NAMES "), file
);
7811 case EIHVN__SECURITY_BIT
:
7812 fputs (_("SECURITY "), file
);
7814 case EIHVN__IMAGE_ACTIVATOR_BIT
:
7815 fputs (_("IMAGE_ACTIVATOR "), file
);
7817 case EIHVN__NETWORKS_BIT
:
7818 fputs (_("NETWORKS "), file
);
7820 case EIHVN__COUNTERS_BIT
:
7821 fputs (_("COUNTERS "), file
);
7823 case EIHVN__STABLE_BIT
:
7824 fputs (_("STABLE "), file
);
7826 case EIHVN__MISC_BIT
:
7827 fputs (_("MISC "), file
);
7829 case EIHVN__CPU_BIT
:
7830 fputs (_("CPU "), file
);
7832 case EIHVN__VOLATILE_BIT
:
7833 fputs (_("VOLATILE "), file
);
7835 case EIHVN__SHELL_BIT
:
7836 fputs (_("SHELL "), file
);
7838 case EIHVN__POSIX_BIT
:
7839 fputs (_("POSIX "), file
);
7841 case EIHVN__MULTI_PROCESSING_BIT
:
7842 fputs (_("MULTI_PROCESSING "), file
);
7844 case EIHVN__GALAXY_BIT
:
7845 fputs (_("GALAXY "), file
);
7848 fputs (_("*unknown* "), file
);
7851 fprintf (file
, ": %u.%u\n",
7852 (unsigned)bfd_getl16 (ver
.major
),
7853 (unsigned)bfd_getl16 (ver
.minor
));
7859 struct vms_eiha eiha
;
7861 if (bfd_seek (abfd
, (file_ptr
) eiha_off
, SEEK_SET
)
7862 || bfd_bread (&eiha
, sizeof (eiha
), abfd
) != sizeof (eiha
))
7864 fprintf (file
, _("cannot read EIHA\n"));
7867 fprintf (file
, _("Image activation: (size=%u)\n"),
7868 (unsigned)bfd_getl32 (eiha
.size
));
7869 /* xgettext:c-format */
7870 fprintf (file
, _(" First address : 0x%08x 0x%08x\n"),
7871 (unsigned)bfd_getl32 (eiha
.tfradr1_h
),
7872 (unsigned)bfd_getl32 (eiha
.tfradr1
));
7873 /* xgettext:c-format */
7874 fprintf (file
, _(" Second address: 0x%08x 0x%08x\n"),
7875 (unsigned)bfd_getl32 (eiha
.tfradr2_h
),
7876 (unsigned)bfd_getl32 (eiha
.tfradr2
));
7877 /* xgettext:c-format */
7878 fprintf (file
, _(" Third address : 0x%08x 0x%08x\n"),
7879 (unsigned)bfd_getl32 (eiha
.tfradr3_h
),
7880 (unsigned)bfd_getl32 (eiha
.tfradr3
));
7881 /* xgettext:c-format */
7882 fprintf (file
, _(" Fourth address: 0x%08x 0x%08x\n"),
7883 (unsigned)bfd_getl32 (eiha
.tfradr4_h
),
7884 (unsigned)bfd_getl32 (eiha
.tfradr4
));
7885 /* xgettext:c-format */
7886 fprintf (file
, _(" Shared image : 0x%08x 0x%08x\n"),
7887 (unsigned)bfd_getl32 (eiha
.inishr_h
),
7888 (unsigned)bfd_getl32 (eiha
.inishr
));
7892 struct vms_eihi eihi
;
7894 if (bfd_seek (abfd
, (file_ptr
) eihi_off
, SEEK_SET
)
7895 || bfd_bread (&eihi
, sizeof (eihi
), abfd
) != sizeof (eihi
))
7897 fprintf (file
, _("cannot read EIHI\n"));
7900 /* xgettext:c-format */
7901 fprintf (file
, _("Image identification: (major: %u, minor: %u)\n"),
7902 (unsigned)bfd_getl32 (eihi
.majorid
),
7903 (unsigned)bfd_getl32 (eihi
.minorid
));
7904 fprintf (file
, _(" image name : %.*s\n"),
7905 eihi
.imgnam
[0], eihi
.imgnam
+ 1);
7906 fprintf (file
, _(" link time : %s\n"),
7907 vms_time_to_str (eihi
.linktime
));
7908 fprintf (file
, _(" image ident : %.*s\n"),
7909 eihi
.imgid
[0], eihi
.imgid
+ 1);
7910 fprintf (file
, _(" linker ident : %.*s\n"),
7911 eihi
.linkid
[0], eihi
.linkid
+ 1);
7912 fprintf (file
, _(" image build ident: %.*s\n"),
7913 eihi
.imgbid
[0], eihi
.imgbid
+ 1);
7917 struct vms_eihs eihs
;
7919 if (bfd_seek (abfd
, (file_ptr
) eihs_off
, SEEK_SET
)
7920 || bfd_bread (&eihs
, sizeof (eihs
), abfd
) != sizeof (eihs
))
7922 fprintf (file
, _("cannot read EIHS\n"));
7925 /* xgettext:c-format */
7926 fprintf (file
, _("Image symbol & debug table: (major: %u, minor: %u)\n"),
7927 (unsigned)bfd_getl32 (eihs
.majorid
),
7928 (unsigned)bfd_getl32 (eihs
.minorid
));
7929 dst_vbn
= bfd_getl32 (eihs
.dstvbn
);
7930 dst_size
= bfd_getl32 (eihs
.dstsize
);
7931 /* xgettext:c-format */
7932 fprintf (file
, _(" debug symbol table : vbn: %u, size: %u (0x%x)\n"),
7933 dst_vbn
, dst_size
, dst_size
);
7934 gst_vbn
= bfd_getl32 (eihs
.gstvbn
);
7935 gst_size
= bfd_getl32 (eihs
.gstsize
);
7936 /* xgettext:c-format */
7937 fprintf (file
, _(" global symbol table: vbn: %u, records: %u\n"),
7939 dmt_vbn
= bfd_getl32 (eihs
.dmtvbn
);
7940 dmt_size
= bfd_getl32 (eihs
.dmtsize
);
7941 /* xgettext:c-format */
7942 fprintf (file
, _(" debug module table : vbn: %u, size: %u\n"),
7945 while (eisd_off
!= 0)
7947 struct vms_eisd eisd
;
7952 if (bfd_seek (abfd
, (file_ptr
) eisd_off
, SEEK_SET
)
7953 || bfd_bread (&eisd
, sizeof (eisd
), abfd
) != sizeof (eisd
))
7955 fprintf (file
, _("cannot read EISD\n"));
7958 len
= (unsigned)bfd_getl32 (eisd
.eisdsize
);
7959 if (len
!= (unsigned)-1)
7963 eisd_off
= (eisd_off
+ VMS_BLOCK_SIZE
) & ~(VMS_BLOCK_SIZE
- 1);
7965 /* xgettext:c-format */
7966 fprintf (file
, _("Image section descriptor: (major: %u, minor: %u, "
7967 "size: %u, offset: %u)\n"),
7968 (unsigned)bfd_getl32 (eisd
.majorid
),
7969 (unsigned)bfd_getl32 (eisd
.minorid
),
7973 /* xgettext:c-format */
7974 fprintf (file
, _(" section: base: 0x%08x%08x size: 0x%08x\n"),
7975 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 4),
7976 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 0),
7977 (unsigned)bfd_getl32 (eisd
.secsize
));
7978 val
= (unsigned)bfd_getl32 (eisd
.flags
);
7979 fprintf (file
, _(" flags: 0x%04x"), val
);
7980 if (val
& EISD__M_GBL
)
7981 fprintf (file
, " GBL");
7982 if (val
& EISD__M_CRF
)
7983 fprintf (file
, " CRF");
7984 if (val
& EISD__M_DZRO
)
7985 fprintf (file
, " DZRO");
7986 if (val
& EISD__M_WRT
)
7987 fprintf (file
, " WRT");
7988 if (val
& EISD__M_INITALCODE
)
7989 fprintf (file
, " INITALCODE");
7990 if (val
& EISD__M_BASED
)
7991 fprintf (file
, " BASED");
7992 if (val
& EISD__M_FIXUPVEC
)
7993 fprintf (file
, " FIXUPVEC");
7994 if (val
& EISD__M_RESIDENT
)
7995 fprintf (file
, " RESIDENT");
7996 if (val
& EISD__M_VECTOR
)
7997 fprintf (file
, " VECTOR");
7998 if (val
& EISD__M_PROTECT
)
7999 fprintf (file
, " PROTECT");
8000 if (val
& EISD__M_LASTCLU
)
8001 fprintf (file
, " LASTCLU");
8002 if (val
& EISD__M_EXE
)
8003 fprintf (file
, " EXE");
8004 if (val
& EISD__M_NONSHRADR
)
8005 fprintf (file
, " NONSHRADR");
8006 if (val
& EISD__M_QUAD_LENGTH
)
8007 fprintf (file
, " QUAD_LENGTH");
8008 if (val
& EISD__M_ALLOC_64BIT
)
8009 fprintf (file
, " ALLOC_64BIT");
8010 fprintf (file
, "\n");
8011 if (val
& EISD__M_FIXUPVEC
)
8013 eiaf_vbn
= bfd_getl32 (eisd
.vbn
);
8014 eiaf_size
= bfd_getl32 (eisd
.secsize
);
8016 /* xgettext:c-format */
8017 fprintf (file
, _(" vbn: %u, pfc: %u, matchctl: %u type: %u ("),
8018 (unsigned)bfd_getl32 (eisd
.vbn
),
8019 eisd
.pfc
, eisd
.matchctl
, eisd
.type
);
8022 case EISD__K_NORMAL
:
8023 fputs (_("NORMAL"), file
);
8025 case EISD__K_SHRFXD
:
8026 fputs (_("SHRFXD"), file
);
8028 case EISD__K_PRVFXD
:
8029 fputs (_("PRVFXD"), file
);
8031 case EISD__K_SHRPIC
:
8032 fputs (_("SHRPIC"), file
);
8034 case EISD__K_PRVPIC
:
8035 fputs (_("PRVPIC"), file
);
8037 case EISD__K_USRSTACK
:
8038 fputs (_("USRSTACK"), file
);
8041 fputs (_("*unknown*"), file
);
8044 fputs (_(")\n"), file
);
8045 if (val
& EISD__M_GBL
)
8046 /* xgettext:c-format */
8047 fprintf (file
, _(" ident: 0x%08x, name: %.*s\n"),
8048 (unsigned)bfd_getl32 (eisd
.ident
),
8049 eisd
.gblnam
[0], eisd
.gblnam
+ 1);
8055 if (bfd_seek (abfd
, (file_ptr
) (dmt_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
8057 fprintf (file
, _("cannot read DMT\n"));
8061 fprintf (file
, _("Debug module table:\n"));
8063 while (dmt_size
> 0)
8065 struct vms_dmt_header dmth
;
8068 if (bfd_bread (&dmth
, sizeof (dmth
), abfd
) != sizeof (dmth
))
8070 fprintf (file
, _("cannot read DMT header\n"));
8073 count
= bfd_getl16 (dmth
.psect_count
);
8075 /* xgettext:c-format */
8076 _(" module offset: 0x%08x, size: 0x%08x, (%u psects)\n"),
8077 (unsigned)bfd_getl32 (dmth
.modbeg
),
8078 (unsigned)bfd_getl32 (dmth
.size
), count
);
8079 dmt_size
-= sizeof (dmth
);
8082 struct vms_dmt_psect dmtp
;
8084 if (bfd_bread (&dmtp
, sizeof (dmtp
), abfd
) != sizeof (dmtp
))
8086 fprintf (file
, _("cannot read DMT psect\n"));
8089 /* xgettext:c-format */
8090 fprintf (file
, _(" psect start: 0x%08x, length: %u\n"),
8091 (unsigned)bfd_getl32 (dmtp
.start
),
8092 (unsigned)bfd_getl32 (dmtp
.length
));
8094 dmt_size
-= sizeof (dmtp
);
8101 if (bfd_seek (abfd
, (file_ptr
) (dst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
8103 fprintf (file
, _("cannot read DST\n"));
8107 evax_bfd_print_dst (abfd
, dst_size
, file
);
8111 if (bfd_seek (abfd
, (file_ptr
) (gst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
8113 fprintf (file
, _("cannot read GST\n"));
8117 fprintf (file
, _("Global symbol table:\n"));
8118 evax_bfd_print_eobj (abfd
, file
);
8123 struct vms_eiaf
*eiaf
;
8124 unsigned int qrelfixoff
;
8125 unsigned int lrelfixoff
;
8126 unsigned int qdotadroff
;
8127 unsigned int ldotadroff
;
8128 unsigned int shrimgcnt
;
8129 unsigned int shlstoff
;
8130 unsigned int codeadroff
;
8131 unsigned int lpfixoff
;
8132 unsigned int chgprtoff
;
8133 file_ptr f_off
= (file_ptr
) (eiaf_vbn
- 1) * VMS_BLOCK_SIZE
;
8135 if (bfd_seek (abfd
, f_off
, SEEK_SET
) != 0
8136 || (buf
= _bfd_malloc_and_read (abfd
, eiaf_size
, eiaf_size
)) == NULL
)
8138 fprintf (file
, _("cannot read EIHA\n"));
8141 eiaf
= (struct vms_eiaf
*)buf
;
8143 /* xgettext:c-format */
8144 _("Image activator fixup: (major: %u, minor: %u)\n"),
8145 (unsigned)bfd_getl32 (eiaf
->majorid
),
8146 (unsigned)bfd_getl32 (eiaf
->minorid
));
8147 /* xgettext:c-format */
8148 fprintf (file
, _(" iaflink : 0x%08x %08x\n"),
8149 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 0),
8150 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 4));
8151 /* xgettext:c-format */
8152 fprintf (file
, _(" fixuplnk: 0x%08x %08x\n"),
8153 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 0),
8154 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 4));
8155 fprintf (file
, _(" size : %u\n"),
8156 (unsigned)bfd_getl32 (eiaf
->size
));
8157 fprintf (file
, _(" flags: 0x%08x\n"),
8158 (unsigned)bfd_getl32 (eiaf
->flags
));
8159 qrelfixoff
= bfd_getl32 (eiaf
->qrelfixoff
);
8160 lrelfixoff
= bfd_getl32 (eiaf
->lrelfixoff
);
8161 /* xgettext:c-format */
8162 fprintf (file
, _(" qrelfixoff: %5u, lrelfixoff: %5u\n"),
8163 qrelfixoff
, lrelfixoff
);
8164 qdotadroff
= bfd_getl32 (eiaf
->qdotadroff
);
8165 ldotadroff
= bfd_getl32 (eiaf
->ldotadroff
);
8166 /* xgettext:c-format */
8167 fprintf (file
, _(" qdotadroff: %5u, ldotadroff: %5u\n"),
8168 qdotadroff
, ldotadroff
);
8169 codeadroff
= bfd_getl32 (eiaf
->codeadroff
);
8170 lpfixoff
= bfd_getl32 (eiaf
->lpfixoff
);
8171 /* xgettext:c-format */
8172 fprintf (file
, _(" codeadroff: %5u, lpfixoff : %5u\n"),
8173 codeadroff
, lpfixoff
);
8174 chgprtoff
= bfd_getl32 (eiaf
->chgprtoff
);
8175 fprintf (file
, _(" chgprtoff : %5u\n"), chgprtoff
);
8176 shrimgcnt
= bfd_getl32 (eiaf
->shrimgcnt
);
8177 shlstoff
= bfd_getl32 (eiaf
->shlstoff
);
8178 /* xgettext:c-format */
8179 fprintf (file
, _(" shlstoff : %5u, shrimgcnt : %5u\n"),
8180 shlstoff
, shrimgcnt
);
8181 /* xgettext:c-format */
8182 fprintf (file
, _(" shlextra : %5u, permctx : %5u\n"),
8183 (unsigned)bfd_getl32 (eiaf
->shlextra
),
8184 (unsigned)bfd_getl32 (eiaf
->permctx
));
8185 fprintf (file
, _(" base_va : 0x%08x\n"),
8186 (unsigned)bfd_getl32 (eiaf
->base_va
));
8187 fprintf (file
, _(" lppsbfixoff: %5u\n"),
8188 (unsigned)bfd_getl32 (eiaf
->lppsbfixoff
));
8192 struct vms_shl
*shl
= (struct vms_shl
*)(buf
+ shlstoff
);
8195 fprintf (file
, _(" Shareable images:\n"));
8196 for (j
= 0; j
< shrimgcnt
; j
++, shl
++)
8199 /* xgettext:c-format */
8200 _(" %u: size: %u, flags: 0x%02x, name: %.*s\n"),
8201 j
, shl
->size
, shl
->flags
,
8202 shl
->imgnam
[0], shl
->imgnam
+ 1);
8205 if (qrelfixoff
!= 0)
8207 fprintf (file
, _(" quad-word relocation fixups:\n"));
8208 evax_bfd_print_relocation_records (file
, buf
+ qrelfixoff
, 8);
8210 if (lrelfixoff
!= 0)
8212 fprintf (file
, _(" long-word relocation fixups:\n"));
8213 evax_bfd_print_relocation_records (file
, buf
+ lrelfixoff
, 4);
8215 if (qdotadroff
!= 0)
8217 fprintf (file
, _(" quad-word .address reference fixups:\n"));
8218 evax_bfd_print_address_fixups (file
, buf
+ qdotadroff
);
8220 if (ldotadroff
!= 0)
8222 fprintf (file
, _(" long-word .address reference fixups:\n"));
8223 evax_bfd_print_address_fixups (file
, buf
+ ldotadroff
);
8225 if (codeadroff
!= 0)
8227 fprintf (file
, _(" Code Address Reference Fixups:\n"));
8228 evax_bfd_print_reference_fixups (file
, buf
+ codeadroff
);
8232 fprintf (file
, _(" Linkage Pairs Reference Fixups:\n"));
8233 evax_bfd_print_reference_fixups (file
, buf
+ lpfixoff
);
8237 unsigned int count
= (unsigned)bfd_getl32 (buf
+ chgprtoff
);
8238 struct vms_eicp
*eicp
= (struct vms_eicp
*)(buf
+ chgprtoff
+ 4);
8241 fprintf (file
, _(" Change Protection (%u entries):\n"), count
);
8242 for (j
= 0; j
< count
; j
++, eicp
++)
8244 unsigned int prot
= bfd_getl32 (eicp
->newprt
);
8246 /* xgettext:c-format */
8247 _(" base: 0x%08x %08x, size: 0x%08x, prot: 0x%08x "),
8248 (unsigned)bfd_getl32 (eicp
->baseva
+ 4),
8249 (unsigned)bfd_getl32 (eicp
->baseva
+ 0),
8250 (unsigned)bfd_getl32 (eicp
->size
),
8251 (unsigned)bfd_getl32 (eicp
->newprt
));
8255 fprintf (file
, "NA");
8257 case PRT__C_RESERVED
:
8258 fprintf (file
, "RES");
8261 fprintf (file
, "KW");
8264 fprintf (file
, "KR");
8267 fprintf (file
, "UW");
8270 fprintf (file
, "EW");
8273 fprintf (file
, "ERKW");
8276 fprintf (file
, "ER");
8279 fprintf (file
, "SW");
8282 fprintf (file
, "SREW");
8285 fprintf (file
, "SRKW");
8288 fprintf (file
, "SR");
8291 fprintf (file
, "URSW");
8294 fprintf (file
, "UREW");
8297 fprintf (file
, "URKW");
8300 fprintf (file
, "UR");
8314 vms_bfd_print_private_bfd_data (bfd
*abfd
, void *ptr
)
8316 FILE *file
= (FILE *)ptr
;
8318 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
8319 evax_bfd_print_image (abfd
, file
);
8322 if (bfd_seek (abfd
, 0, SEEK_SET
))
8324 evax_bfd_print_eobj (abfd
, file
);
8331 /* Slurp ETIR/EDBG/ETBT VMS object records. */
8334 alpha_vms_read_sections_content (bfd
*abfd
, struct bfd_link_info
*info
)
8336 asection
*cur_section
;
8337 file_ptr cur_offset
;
8338 asection
*dst_section
;
8339 file_ptr dst_offset
;
8341 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
8347 dst_section
= PRIV (dst_section
);
8351 if (info
->strip
== strip_all
|| info
->strip
== strip_debugger
)
8353 /* Discard the DST section. */
8357 else if (dst_section
)
8359 dst_offset
= dst_section
->output_offset
;
8360 dst_section
= dst_section
->output_section
;
8369 type
= _bfd_vms_get_object_record (abfd
);
8372 vms_debug2 ((2, "next_record failed\n"));
8378 PRIV (image_section
) = cur_section
;
8379 PRIV (image_offset
) = cur_offset
;
8380 res
= _bfd_vms_slurp_etir (abfd
, info
);
8381 cur_section
= PRIV (image_section
);
8382 cur_offset
= PRIV (image_offset
);
8386 if (dst_section
== NULL
)
8388 PRIV (image_section
) = dst_section
;
8389 PRIV (image_offset
) = dst_offset
;
8390 res
= _bfd_vms_slurp_etir (abfd
, info
);
8391 dst_offset
= PRIV (image_offset
);
8400 vms_debug2 ((2, "slurp eobj type %d failed\n", type
));
8407 alpha_vms_sizeof_headers (bfd
*abfd ATTRIBUTE_UNUSED
,
8408 struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8413 /* Add a linkage pair fixup at address SECT + OFFSET to SHLIB. */
8416 alpha_vms_add_fixup_lp (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
8418 struct alpha_vms_shlib_el
*sl
;
8419 asection
*sect
= PRIV2 (src
, image_section
);
8420 file_ptr offset
= PRIV2 (src
, image_offset
);
8423 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8424 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8425 sl
->has_fixups
= TRUE
;
8426 p
= VEC_APPEND (sl
->lp
, bfd_vma
);
8429 *p
= sect
->output_section
->vma
+ sect
->output_offset
+ offset
;
8430 sect
->output_section
->flags
|= SEC_RELOC
;
8434 /* Add a code address fixup at address SECT + OFFSET to SHLIB. */
8437 alpha_vms_add_fixup_ca (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
8439 struct alpha_vms_shlib_el
*sl
;
8440 asection
*sect
= PRIV2 (src
, image_section
);
8441 file_ptr offset
= PRIV2 (src
, image_offset
);
8444 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8445 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8446 sl
->has_fixups
= TRUE
;
8447 p
= VEC_APPEND (sl
->ca
, bfd_vma
);
8450 *p
= sect
->output_section
->vma
+ sect
->output_offset
+ offset
;
8451 sect
->output_section
->flags
|= SEC_RELOC
;
8455 /* Add a quad word relocation fixup at address SECT + OFFSET to SHLIB. */
8458 alpha_vms_add_fixup_qr (struct bfd_link_info
*info
, bfd
*src
,
8459 bfd
*shlib
, bfd_vma vec
)
8461 struct alpha_vms_shlib_el
*sl
;
8462 struct alpha_vms_vma_ref
*r
;
8463 asection
*sect
= PRIV2 (src
, image_section
);
8464 file_ptr offset
= PRIV2 (src
, image_offset
);
8466 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8467 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8468 sl
->has_fixups
= TRUE
;
8469 r
= VEC_APPEND (sl
->qr
, struct alpha_vms_vma_ref
);
8472 r
->vma
= sect
->output_section
->vma
+ sect
->output_offset
+ offset
;
8474 sect
->output_section
->flags
|= SEC_RELOC
;
8479 alpha_vms_add_fixup_lr (struct bfd_link_info
*info ATTRIBUTE_UNUSED
,
8480 unsigned int shr ATTRIBUTE_UNUSED
,
8481 bfd_vma vec ATTRIBUTE_UNUSED
)
8483 /* Not yet supported. */
8487 /* Add relocation. FIXME: Not yet emitted. */
8490 alpha_vms_add_lw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8496 alpha_vms_add_qw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8501 static struct bfd_hash_entry
*
8502 alpha_vms_link_hash_newfunc (struct bfd_hash_entry
*entry
,
8503 struct bfd_hash_table
*table
,
8506 struct alpha_vms_link_hash_entry
*ret
=
8507 (struct alpha_vms_link_hash_entry
*) entry
;
8509 /* Allocate the structure if it has not already been allocated by a
8512 ret
= ((struct alpha_vms_link_hash_entry
*)
8513 bfd_hash_allocate (table
,
8514 sizeof (struct alpha_vms_link_hash_entry
)));
8518 /* Call the allocation method of the superclass. */
8519 ret
= ((struct alpha_vms_link_hash_entry
*)
8520 _bfd_link_hash_newfunc ((struct bfd_hash_entry
*) ret
,
8525 return (struct bfd_hash_entry
*) ret
;
8529 alpha_vms_bfd_link_hash_table_free (bfd
*abfd
)
8531 struct alpha_vms_link_hash_table
*t
;
8534 t
= (struct alpha_vms_link_hash_table
*) abfd
->link
.hash
;
8535 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8537 struct alpha_vms_shlib_el
*shlib
;
8539 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8540 free (&VEC_EL (shlib
->ca
, bfd_vma
, 0));
8541 free (&VEC_EL (shlib
->lp
, bfd_vma
, 0));
8542 free (&VEC_EL (shlib
->qr
, struct alpha_vms_vma_ref
, 0));
8544 free (&VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, 0));
8546 _bfd_generic_link_hash_table_free (abfd
);
8549 /* Create an Alpha/VMS link hash table. */
8551 static struct bfd_link_hash_table
*
8552 alpha_vms_bfd_link_hash_table_create (bfd
*abfd
)
8554 struct alpha_vms_link_hash_table
*ret
;
8555 size_t amt
= sizeof (struct alpha_vms_link_hash_table
);
8557 ret
= (struct alpha_vms_link_hash_table
*) bfd_malloc (amt
);
8560 if (!_bfd_link_hash_table_init (&ret
->root
, abfd
,
8561 alpha_vms_link_hash_newfunc
,
8562 sizeof (struct alpha_vms_link_hash_entry
)))
8568 VEC_INIT (ret
->shrlibs
);
8570 ret
->root
.hash_table_free
= alpha_vms_bfd_link_hash_table_free
;
8576 alpha_vms_link_add_object_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8580 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
8582 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
8583 struct alpha_vms_link_hash_entry
*h
;
8584 struct bfd_link_hash_entry
*h_root
;
8587 if (!alpha_vms_convert_symbol (abfd
, e
, &sym
))
8590 if ((e
->flags
& EGSY__V_DEF
) && abfd
->selective_search
)
8592 /* In selective_search mode, only add definition that are
8594 h
= (struct alpha_vms_link_hash_entry
*)bfd_link_hash_lookup
8595 (info
->hash
, sym
.name
, FALSE
, FALSE
, FALSE
);
8596 if (h
== NULL
|| h
->root
.type
!= bfd_link_hash_undefined
)
8602 h_root
= (struct bfd_link_hash_entry
*) h
;
8603 if (!_bfd_generic_link_add_one_symbol (info
, abfd
, sym
.name
, sym
.flags
,
8604 sym
.section
, sym
.value
, NULL
,
8605 FALSE
, FALSE
, &h_root
))
8607 h
= (struct alpha_vms_link_hash_entry
*) h_root
;
8609 if ((e
->flags
& EGSY__V_DEF
)
8611 && abfd
->xvec
== info
->output_bfd
->xvec
)
8615 if (abfd
->flags
& DYNAMIC
)
8617 struct alpha_vms_shlib_el
*shlib
;
8619 /* We do not want to include any of the sections in a dynamic
8620 object in the output file. See comment in elflink.c. */
8621 bfd_section_list_clear (abfd
);
8623 shlib
= VEC_APPEND (alpha_vms_link_hash (info
)->shrlibs
,
8624 struct alpha_vms_shlib_el
);
8628 VEC_INIT (shlib
->ca
);
8629 VEC_INIT (shlib
->lp
);
8630 VEC_INIT (shlib
->qr
);
8631 PRIV (shr_index
) = VEC_COUNT (alpha_vms_link_hash (info
)->shrlibs
) - 1;
8638 alpha_vms_link_add_archive_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8641 struct bfd_link_hash_entry
**pundef
;
8642 struct bfd_link_hash_entry
**next_pundef
;
8644 /* We only accept VMS libraries. */
8645 if (info
->output_bfd
->xvec
!= abfd
->xvec
)
8647 bfd_set_error (bfd_error_wrong_format
);
8651 /* The archive_pass field in the archive itself is used to
8652 initialize PASS, since we may search the same archive multiple
8654 pass
= ++abfd
->archive_pass
;
8656 /* Look through the list of undefined symbols. */
8657 for (pundef
= &info
->hash
->undefs
; *pundef
!= NULL
; pundef
= next_pundef
)
8659 struct bfd_link_hash_entry
*h
;
8665 next_pundef
= &(*pundef
)->u
.undef
.next
;
8667 /* When a symbol is defined, it is not necessarily removed from
8669 if (h
->type
!= bfd_link_hash_undefined
8670 && h
->type
!= bfd_link_hash_common
)
8672 /* Remove this entry from the list, for general cleanliness
8673 and because we are going to look through the list again
8674 if we search any more libraries. We can't remove the
8675 entry if it is the tail, because that would lose any
8676 entries we add to the list later on. */
8677 if (*pundef
!= info
->hash
->undefs_tail
)
8679 *pundef
= *next_pundef
;
8680 next_pundef
= pundef
;
8685 /* Look for this symbol in the archive hash table. */
8686 symidx
= _bfd_vms_lib_find_symbol (abfd
, h
->root
.string
);
8687 if (symidx
== BFD_NO_MORE_SYMBOLS
)
8689 /* Nothing in this slot. */
8693 element
= bfd_get_elt_at_index (abfd
, symidx
);
8694 if (element
== NULL
)
8697 if (element
->archive_pass
== -1 || element
->archive_pass
== pass
)
8699 /* Next symbol if this archive is wrong or already handled. */
8703 if (! bfd_check_format (element
, bfd_object
))
8705 element
->archive_pass
= -1;
8709 orig_element
= element
;
8710 if (bfd_is_thin_archive (abfd
))
8712 element
= _bfd_vms_lib_get_imagelib_file (element
);
8713 if (element
== NULL
|| !bfd_check_format (element
, bfd_object
))
8715 orig_element
->archive_pass
= -1;
8720 /* Unlike the generic linker, we know that this element provides
8721 a definition for an undefined symbol and we know that we want
8722 to include it. We don't need to check anything. */
8723 if (!(*info
->callbacks
8724 ->add_archive_element
) (info
, element
, h
->root
.string
, &element
))
8726 if (!alpha_vms_link_add_object_symbols (element
, info
))
8729 orig_element
->archive_pass
= pass
;
8736 alpha_vms_bfd_link_add_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8738 switch (bfd_get_format (abfd
))
8741 vms_debug2 ((2, "vms_link_add_symbols for object %s\n",
8743 return alpha_vms_link_add_object_symbols (abfd
, info
);
8746 vms_debug2 ((2, "vms_link_add_symbols for archive %s\n",
8748 return alpha_vms_link_add_archive_symbols (abfd
, info
);
8751 bfd_set_error (bfd_error_wrong_format
);
8757 alpha_vms_build_fixups (struct bfd_link_info
*info
)
8759 struct alpha_vms_link_hash_table
*t
= alpha_vms_link_hash (info
);
8760 unsigned char *content
;
8762 unsigned int sz
= 0;
8763 unsigned int lp_sz
= 0;
8764 unsigned int ca_sz
= 0;
8765 unsigned int qr_sz
= 0;
8766 unsigned int shrimg_cnt
= 0;
8767 unsigned int chgprt_num
= 0;
8768 unsigned int chgprt_sz
= 0;
8769 struct vms_eiaf
*eiaf
;
8773 /* Shared libraries. */
8774 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8776 struct alpha_vms_shlib_el
*shlib
;
8778 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8780 if (!shlib
->has_fixups
)
8785 if (VEC_COUNT (shlib
->ca
) > 0)
8787 /* Header + entries. */
8789 ca_sz
+= VEC_COUNT (shlib
->ca
) * 4;
8791 if (VEC_COUNT (shlib
->lp
) > 0)
8793 /* Header + entries. */
8795 lp_sz
+= VEC_COUNT (shlib
->lp
) * 4;
8797 if (VEC_COUNT (shlib
->qr
) > 0)
8799 /* Header + entries. */
8801 qr_sz
+= VEC_COUNT (shlib
->qr
) * 8;
8812 /* Finish now if there is no content. */
8813 if (ca_sz
+ lp_sz
+ qr_sz
== 0)
8816 /* Add an eicp entry for the fixup itself. */
8818 for (sec
= info
->output_bfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
8820 /* This isect could be made RO or EXE after relocations are applied. */
8821 if ((sec
->flags
& SEC_RELOC
) != 0
8822 && (sec
->flags
& (SEC_CODE
| SEC_READONLY
)) != 0)
8825 chgprt_sz
= 4 + chgprt_num
* sizeof (struct vms_eicp
);
8827 /* Allocate section content (round-up size) */
8828 sz
= sizeof (struct vms_eiaf
) + shrimg_cnt
* sizeof (struct vms_shl
)
8829 + ca_sz
+ lp_sz
+ qr_sz
+ chgprt_sz
;
8830 sz
= (sz
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
8831 content
= bfd_zalloc (info
->output_bfd
, sz
);
8832 if (content
== NULL
)
8835 sec
= alpha_vms_link_hash (info
)->fixup
;
8836 sec
->contents
= content
;
8839 eiaf
= (struct vms_eiaf
*)content
;
8840 off
= sizeof (struct vms_eiaf
);
8841 bfd_putl32 (0, eiaf
->majorid
);
8842 bfd_putl32 (0, eiaf
->minorid
);
8843 bfd_putl32 (0, eiaf
->iaflink
);
8844 bfd_putl32 (0, eiaf
->fixuplnk
);
8845 bfd_putl32 (sizeof (struct vms_eiaf
), eiaf
->size
);
8846 bfd_putl32 (0, eiaf
->flags
);
8847 bfd_putl32 (0, eiaf
->qrelfixoff
);
8848 bfd_putl32 (0, eiaf
->lrelfixoff
);
8849 bfd_putl32 (0, eiaf
->qdotadroff
);
8850 bfd_putl32 (0, eiaf
->ldotadroff
);
8851 bfd_putl32 (0, eiaf
->codeadroff
);
8852 bfd_putl32 (0, eiaf
->lpfixoff
);
8853 bfd_putl32 (0, eiaf
->chgprtoff
);
8854 bfd_putl32 (shrimg_cnt
? off
: 0, eiaf
->shlstoff
);
8855 bfd_putl32 (shrimg_cnt
, eiaf
->shrimgcnt
);
8856 bfd_putl32 (0, eiaf
->shlextra
);
8857 bfd_putl32 (0, eiaf
->permctx
);
8858 bfd_putl32 (0, eiaf
->base_va
);
8859 bfd_putl32 (0, eiaf
->lppsbfixoff
);
8866 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8868 struct alpha_vms_shlib_el
*shlib
;
8869 struct vms_shl
*shl
;
8871 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8873 if (!shlib
->has_fixups
)
8876 /* Renumber shared images. */
8877 PRIV2 (shlib
->abfd
, shr_index
) = shrimg_cnt
++;
8879 shl
= (struct vms_shl
*)(content
+ off
);
8880 bfd_putl32 (0, shl
->baseva
);
8881 bfd_putl32 (0, shl
->shlptr
);
8882 bfd_putl32 (0, shl
->ident
);
8883 bfd_putl32 (0, shl
->permctx
);
8884 shl
->size
= sizeof (struct vms_shl
);
8885 bfd_putl16 (0, shl
->fill_1
);
8887 bfd_putl32 (0, shl
->icb
);
8888 shl
->imgnam
[0] = strlen (PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
));
8889 memcpy (shl
->imgnam
+ 1, PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
),
8892 off
+= sizeof (struct vms_shl
);
8898 bfd_putl32 (off
, eiaf
->codeadroff
);
8900 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8902 struct alpha_vms_shlib_el
*shlib
;
8905 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8907 if (VEC_COUNT (shlib
->ca
) == 0)
8910 bfd_putl32 (VEC_COUNT (shlib
->ca
), content
+ off
);
8911 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8914 for (j
= 0; j
< VEC_COUNT (shlib
->ca
); j
++)
8916 bfd_putl32 (VEC_EL (shlib
->ca
, bfd_vma
, j
) - t
->base_addr
,
8922 bfd_putl32 (0, content
+ off
);
8923 bfd_putl32 (0, content
+ off
+ 4);
8930 bfd_putl32 (off
, eiaf
->lpfixoff
);
8932 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8934 struct alpha_vms_shlib_el
*shlib
;
8937 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8939 if (VEC_COUNT (shlib
->lp
) == 0)
8942 bfd_putl32 (VEC_COUNT (shlib
->lp
), content
+ off
);
8943 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8946 for (j
= 0; j
< VEC_COUNT (shlib
->lp
); j
++)
8948 bfd_putl32 (VEC_EL (shlib
->lp
, bfd_vma
, j
) - t
->base_addr
,
8954 bfd_putl32 (0, content
+ off
);
8955 bfd_putl32 (0, content
+ off
+ 4);
8962 bfd_putl32 (off
, eiaf
->qdotadroff
);
8964 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8966 struct alpha_vms_shlib_el
*shlib
;
8969 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8971 if (VEC_COUNT (shlib
->qr
) == 0)
8974 bfd_putl32 (VEC_COUNT (shlib
->qr
), content
+ off
);
8975 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8978 for (j
= 0; j
< VEC_COUNT (shlib
->qr
); j
++)
8980 struct alpha_vms_vma_ref
*r
;
8981 r
= &VEC_EL (shlib
->qr
, struct alpha_vms_vma_ref
, j
);
8982 bfd_putl32 (r
->vma
- t
->base_addr
, content
+ off
);
8983 bfd_putl32 (r
->ref
, content
+ off
+ 4);
8988 bfd_putl32 (0, content
+ off
);
8989 bfd_putl32 (0, content
+ off
+ 4);
8994 /* Write the change protection table. */
8995 bfd_putl32 (off
, eiaf
->chgprtoff
);
8996 bfd_putl32 (chgprt_num
, content
+ off
);
8999 for (sec
= info
->output_bfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
9001 struct vms_eicp
*eicp
;
9004 if ((sec
->flags
& SEC_LINKER_CREATED
) != 0 &&
9005 strcmp (sec
->name
, "$FIXUP$") == 0)
9007 else if ((sec
->flags
& SEC_RELOC
) != 0
9008 && (sec
->flags
& (SEC_CODE
| SEC_READONLY
)) != 0)
9013 eicp
= (struct vms_eicp
*)(content
+ off
);
9014 bfd_putl64 (sec
->vma
- t
->base_addr
, eicp
->baseva
);
9015 bfd_putl32 ((sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1),
9017 bfd_putl32 (prot
, eicp
->newprt
);
9018 off
+= sizeof (struct vms_eicp
);
9024 /* Called by bfd_hash_traverse to fill the symbol table.
9025 Return FALSE in case of failure. */
9028 alpha_vms_link_output_symbol (struct bfd_hash_entry
*bh
, void *infov
)
9030 struct bfd_link_hash_entry
*hc
= (struct bfd_link_hash_entry
*) bh
;
9031 struct bfd_link_info
*info
= (struct bfd_link_info
*)infov
;
9032 struct alpha_vms_link_hash_entry
*h
;
9033 struct vms_symbol_entry
*sym
;
9035 if (hc
->type
== bfd_link_hash_warning
)
9038 if (hc
->type
== bfd_link_hash_new
)
9041 h
= (struct alpha_vms_link_hash_entry
*) hc
;
9043 switch (h
->root
.type
)
9045 case bfd_link_hash_undefined
:
9047 case bfd_link_hash_new
:
9048 case bfd_link_hash_warning
:
9050 case bfd_link_hash_undefweak
:
9052 case bfd_link_hash_defined
:
9053 case bfd_link_hash_defweak
:
9055 asection
*sec
= h
->root
.u
.def
.section
;
9057 /* FIXME: this is certainly a symbol from a dynamic library. */
9058 if (bfd_is_abs_section (sec
))
9061 if (sec
->owner
->flags
& DYNAMIC
)
9065 case bfd_link_hash_common
:
9067 case bfd_link_hash_indirect
:
9071 /* Do not write not kept symbols. */
9072 if (info
->strip
== strip_some
9073 && bfd_hash_lookup (info
->keep_hash
, h
->root
.root
.string
,
9074 FALSE
, FALSE
) != NULL
)
9079 /* This symbol doesn't come from a VMS object. So we suppose it is
9081 int len
= strlen (h
->root
.root
.string
);
9083 sym
= (struct vms_symbol_entry
*)bfd_zalloc (info
->output_bfd
,
9084 sizeof (*sym
) + len
);
9088 memcpy (sym
->name
, h
->root
.root
.string
, len
);
9090 sym
->owner
= info
->output_bfd
;
9092 sym
->typ
= EGSD__C_SYMG
;
9094 sym
->flags
= EGSY__V_DEF
| EGSY__V_REL
;
9095 sym
->symbol_vector
= h
->root
.u
.def
.value
;
9096 sym
->section
= h
->root
.u
.def
.section
;
9097 sym
->value
= h
->root
.u
.def
.value
;
9102 if (!add_symbol_entry (info
->output_bfd
, sym
))
9109 alpha_vms_bfd_final_link (bfd
*abfd
, struct bfd_link_info
*info
)
9112 struct bfd_link_order
*p
;
9120 if (bfd_link_relocatable (info
))
9122 /* FIXME: we do not yet support relocatable link. It is not obvious
9123 how to do it for debug infos. */
9124 (*info
->callbacks
->einfo
)(_("%P: relocatable link is not supported\n"));
9128 abfd
->outsymbols
= NULL
;
9131 /* Mark all sections which will be included in the output file. */
9132 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9133 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
9134 if (p
->type
== bfd_indirect_link_order
)
9135 p
->u
.indirect
.section
->linker_mark
= TRUE
;
9138 /* Handle all the link order information for the sections. */
9139 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9141 printf ("For section %s (at 0x%08x, flags=0x%08x):\n",
9142 o
->name
, (unsigned)o
->vma
, (unsigned)o
->flags
);
9144 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
9146 printf (" at 0x%08x - 0x%08x: ",
9147 (unsigned)p
->offset
, (unsigned)(p
->offset
+ p
->size
- 1));
9150 case bfd_section_reloc_link_order
:
9151 case bfd_symbol_reloc_link_order
:
9152 printf (" section/symbol reloc\n");
9154 case bfd_indirect_link_order
:
9155 printf (" section %s of %s\n",
9156 p
->u
.indirect
.section
->name
,
9157 p
->u
.indirect
.section
->owner
->filename
);
9159 case bfd_data_link_order
:
9160 printf (" explicit data\n");
9163 printf (" *unknown* type %u\n", p
->type
);
9170 /* Generate the symbol table. */
9171 BFD_ASSERT (PRIV (syms
) == NULL
);
9172 if (info
->strip
!= strip_all
)
9173 bfd_hash_traverse (&info
->hash
->table
, alpha_vms_link_output_symbol
, info
);
9175 /* Find the entry point. */
9176 if (bfd_get_start_address (abfd
) == 0)
9178 bfd
*startbfd
= NULL
;
9180 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9182 /* Consider only VMS object files. */
9183 if (sub
->xvec
!= abfd
->xvec
)
9186 if (!PRIV2 (sub
, eom_data
).eom_has_transfer
)
9188 if ((PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
) && startbfd
)
9190 if (startbfd
!= NULL
9191 && !(PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
))
9193 (*info
->callbacks
->einfo
)
9194 /* xgettext:c-format */
9195 (_("%P: multiple entry points: in modules %pB and %pB\n"),
9204 unsigned int ps_idx
= PRIV2 (startbfd
, eom_data
).eom_l_psindx
;
9205 bfd_vma tfradr
= PRIV2 (startbfd
, eom_data
).eom_l_tfradr
;
9208 sec
= PRIV2 (startbfd
, sections
)[ps_idx
];
9210 bfd_set_start_address
9211 (abfd
, sec
->output_section
->vma
+ sec
->output_offset
+ tfradr
);
9215 /* Set transfer addresses. */
9218 struct bfd_link_hash_entry
*h
;
9221 PRIV (transfer_address
[i
++]) = 0xffffffff00000340ULL
; /* SYS$IMGACT */
9222 h
= bfd_link_hash_lookup (info
->hash
, "LIB$INITIALIZE", FALSE
, FALSE
, TRUE
);
9223 if (h
!= NULL
&& h
->type
== bfd_link_hash_defined
)
9224 PRIV (transfer_address
[i
++]) =
9225 alpha_vms_get_sym_value (h
->u
.def
.section
, h
->u
.def
.value
);
9226 PRIV (transfer_address
[i
++]) = bfd_get_start_address (abfd
);
9228 PRIV (transfer_address
[i
++]) = 0;
9231 /* Allocate contents.
9232 Also compute the virtual base address. */
9233 base_addr
= (bfd_vma
)-1;
9235 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9237 if (o
->flags
& SEC_HAS_CONTENTS
)
9239 o
->contents
= bfd_alloc (abfd
, o
->size
);
9240 if (o
->contents
== NULL
)
9243 if (o
->flags
& SEC_LOAD
)
9245 if (o
->vma
< base_addr
)
9247 if (o
->vma
+ o
->size
> last_addr
)
9248 last_addr
= o
->vma
+ o
->size
;
9250 /* Clear the RELOC flags. Currently we don't support incremental
9251 linking. We use the RELOC flag for computing the eicp entries. */
9252 o
->flags
&= ~SEC_RELOC
;
9255 /* Create the fixup section. */
9256 fixupsec
= bfd_make_section_anyway_with_flags
9257 (info
->output_bfd
, "$FIXUP$",
9258 SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
9259 if (fixupsec
== NULL
)
9261 last_addr
= (last_addr
+ 0xffff) & ~0xffff;
9262 fixupsec
->vma
= last_addr
;
9264 alpha_vms_link_hash (info
)->fixup
= fixupsec
;
9265 alpha_vms_link_hash (info
)->base_addr
= base_addr
;
9267 /* Create the DMT section, if necessary. */
9268 BFD_ASSERT (PRIV (dst_section
) == NULL
);
9269 dst
= bfd_get_section_by_name (abfd
, "$DST$");
9270 if (dst
!= NULL
&& dst
->size
== 0)
9274 PRIV (dst_section
) = dst
;
9275 dmt
= bfd_make_section_anyway_with_flags
9276 (info
->output_bfd
, "$DMT$",
9277 SEC_DEBUGGING
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
9284 /* Read all sections from the inputs. */
9285 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9287 if (sub
->flags
& DYNAMIC
)
9289 alpha_vms_create_eisd_for_shared (abfd
, sub
);
9293 if (!alpha_vms_read_sections_content (sub
, info
))
9297 /* Handle all the link order information for the sections.
9298 Note: past this point, it is not possible to create new sections. */
9299 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9301 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
9305 case bfd_section_reloc_link_order
:
9306 case bfd_symbol_reloc_link_order
:
9309 case bfd_indirect_link_order
:
9313 if (! _bfd_default_link_order (abfd
, info
, o
, p
))
9320 /* Compute fixups. */
9321 if (!alpha_vms_build_fixups (info
))
9324 /* Compute the DMT. */
9328 unsigned char *contents
= NULL
;
9330 /* In pass 1, compute the size. In pass 2, write the DMT contents. */
9331 for (pass
= 0; pass
< 2; pass
++)
9333 unsigned int off
= 0;
9335 /* For each object file (ie for each module). */
9336 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9339 struct vms_dmt_header
*dmth
= NULL
;
9340 unsigned int psect_count
;
9342 /* Skip this module if it has no DST. */
9343 sub_dst
= PRIV2 (sub
, dst_section
);
9344 if (sub_dst
== NULL
|| sub_dst
->size
== 0)
9349 /* Write the header. */
9350 dmth
= (struct vms_dmt_header
*)(contents
+ off
);
9351 bfd_putl32 (sub_dst
->output_offset
, dmth
->modbeg
);
9352 bfd_putl32 (sub_dst
->size
, dmth
->size
);
9355 off
+= sizeof (struct vms_dmt_header
);
9358 /* For each section (ie for each psect). */
9359 for (o
= sub
->sections
; o
!= NULL
; o
= o
->next
)
9361 /* Only consider interesting sections. */
9362 if (!(o
->flags
& SEC_ALLOC
))
9364 if (o
->flags
& SEC_LINKER_CREATED
)
9369 /* Write an entry. */
9370 struct vms_dmt_psect
*dmtp
;
9372 dmtp
= (struct vms_dmt_psect
*)(contents
+ off
);
9373 bfd_putl32 (o
->output_offset
+ o
->output_section
->vma
,
9375 bfd_putl32 (o
->size
, dmtp
->length
);
9378 off
+= sizeof (struct vms_dmt_psect
);
9381 bfd_putl32 (psect_count
, dmth
->psect_count
);
9386 contents
= bfd_zalloc (info
->output_bfd
, off
);
9387 if (contents
== NULL
)
9389 dmt
->contents
= contents
;
9394 BFD_ASSERT (off
== dmt
->size
);
9402 /* Read the contents of a section.
9403 buf points to a buffer of buf_size bytes to be filled with
9404 section data (starting at offset into section) */
9407 alpha_vms_get_section_contents (bfd
*abfd
, asection
*section
,
9408 void *buf
, file_ptr offset
,
9409 bfd_size_type count
)
9413 /* Image are easy. */
9414 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
9415 return _bfd_generic_get_section_contents (abfd
, section
,
9416 buf
, offset
, count
);
9419 if (offset
+ count
< count
9420 || offset
+ count
> section
->size
)
9422 bfd_set_error (bfd_error_invalid_operation
);
9426 /* If the section is already in memory, just copy it. */
9427 if (section
->flags
& SEC_IN_MEMORY
)
9429 BFD_ASSERT (section
->contents
!= NULL
);
9430 memcpy (buf
, section
->contents
+ offset
, count
);
9433 if (section
->size
== 0)
9436 /* Alloc in memory and read ETIRs. */
9437 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
9439 BFD_ASSERT (sec
->contents
== NULL
);
9441 if (sec
->size
!= 0 && (sec
->flags
& SEC_HAS_CONTENTS
))
9443 sec
->contents
= bfd_alloc (abfd
, sec
->size
);
9444 if (sec
->contents
== NULL
)
9448 if (!alpha_vms_read_sections_content (abfd
, NULL
))
9450 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
9452 sec
->flags
|= SEC_IN_MEMORY
;
9453 memcpy (buf
, section
->contents
+ offset
, count
);
9458 /* Set the format of a file being written. */
9461 alpha_vms_mkobject (bfd
* abfd
)
9463 const bfd_arch_info_type
*arch
;
9465 vms_debug2 ((1, "alpha_vms_mkobject (%p)\n", abfd
));
9467 if (!vms_initialize (abfd
))
9470 PRIV (recwr
.buf
) = bfd_alloc (abfd
, MAX_OUTREC_SIZE
);
9471 if (PRIV (recwr
.buf
) == NULL
)
9474 arch
= bfd_scan_arch ("alpha");
9478 bfd_set_error (bfd_error_wrong_format
);
9482 abfd
->arch_info
= arch
;
9489 /* Called when the BFD is being closed to do any necessary cleanup. */
9492 vms_close_and_cleanup (bfd
* abfd
)
9494 vms_debug2 ((1, "vms_close_and_cleanup (%p)\n", abfd
));
9496 if (abfd
== NULL
|| abfd
->tdata
.any
== NULL
)
9499 if (abfd
->format
== bfd_object
)
9501 alpha_vms_free_private (abfd
);
9504 if (abfd
->direction
== write_direction
)
9506 /* Last step on VMS is to convert the file to variable record length
9508 if (!bfd_cache_close (abfd
))
9510 if (!_bfd_vms_convert_to_var_unix_filename (abfd
->filename
))
9516 return _bfd_generic_close_and_cleanup (abfd
);
9519 /* Called when a new section is created. */
9522 vms_new_section_hook (bfd
* abfd
, asection
*section
)
9526 vms_debug2 ((1, "vms_new_section_hook (%p, [%u]%s)\n",
9527 abfd
, section
->index
, section
->name
));
9529 if (!bfd_set_section_alignment (section
, 0))
9532 vms_debug2 ((7, "%u: %s\n", section
->index
, section
->name
));
9534 amt
= sizeof (struct vms_section_data_struct
);
9535 section
->used_by_bfd
= bfd_zalloc (abfd
, amt
);
9536 if (section
->used_by_bfd
== NULL
)
9539 /* Create the section symbol. */
9540 return _bfd_generic_new_section_hook (abfd
, section
);
9543 /* Part 4.5, symbols. */
9545 /* Print symbol to file according to how. how is one of
9546 bfd_print_symbol_name just print the name
9547 bfd_print_symbol_more print more (???)
9548 bfd_print_symbol_all print all we know, which is not much right now :-). */
9551 vms_print_symbol (bfd
* abfd
,
9554 bfd_print_symbol_type how
)
9556 vms_debug2 ((1, "vms_print_symbol (%p, %p, %p, %d)\n",
9557 abfd
, file
, symbol
, how
));
9561 case bfd_print_symbol_name
:
9562 case bfd_print_symbol_more
:
9563 fprintf ((FILE *)file
," %s", symbol
->name
);
9566 case bfd_print_symbol_all
:
9568 const char *section_name
= symbol
->section
->name
;
9570 bfd_print_symbol_vandf (abfd
, file
, symbol
);
9572 fprintf ((FILE *) file
," %-8s %s", section_name
, symbol
->name
);
9578 /* Return information about symbol in ret.
9580 fill type, value and name
9583 B bss segment symbol
9585 D data segment symbol
9587 t a static function symbol
9588 T text segment symbol
9593 vms_get_symbol_info (bfd
* abfd ATTRIBUTE_UNUSED
,
9599 vms_debug2 ((1, "vms_get_symbol_info (%p, %p, %p)\n", abfd
, symbol
, ret
));
9601 sec
= symbol
->section
;
9608 else if (bfd_is_com_section (sec
))
9610 else if (bfd_is_abs_section (sec
))
9612 else if (bfd_is_und_section (sec
))
9614 else if (bfd_is_ind_section (sec
))
9616 else if ((symbol
->flags
& BSF_FUNCTION
)
9617 || (bfd_section_flags (sec
) & SEC_CODE
))
9619 else if (bfd_section_flags (sec
) & SEC_DATA
)
9621 else if (bfd_section_flags (sec
) & SEC_ALLOC
)
9626 if (ret
->type
!= 'U')
9627 ret
->value
= symbol
->value
+ symbol
->section
->vma
;
9630 ret
->name
= symbol
->name
;
9633 /* Return TRUE if the given symbol sym in the BFD abfd is
9634 a compiler generated local label, else return FALSE. */
9637 vms_bfd_is_local_label_name (bfd
* abfd ATTRIBUTE_UNUSED
,
9640 return name
[0] == '$';
9643 /* Part 4.7, writing an object file. */
9645 /* Sets the contents of the section section in BFD abfd to the data starting
9646 in memory at LOCATION. The data is written to the output section starting
9647 at offset offset for count bytes.
9649 Normally TRUE is returned, else FALSE. Possible error returns are:
9650 o bfd_error_no_contents - The output section does not have the
9651 SEC_HAS_CONTENTS attribute, so nothing can be written to it.
9652 o and some more too */
9655 _bfd_vms_set_section_contents (bfd
* abfd
,
9657 const void * location
,
9659 bfd_size_type count
)
9661 if (section
->contents
== NULL
)
9663 section
->contents
= bfd_alloc (abfd
, section
->size
);
9664 if (section
->contents
== NULL
)
9667 memcpy (section
->contents
+ offset
, location
, (size_t) count
);
9673 /* Set the architecture and machine type in BFD abfd to arch and mach.
9674 Find the correct pointer to a structure and insert it into the arch_info
9678 alpha_vms_set_arch_mach (bfd
*abfd
,
9679 enum bfd_architecture arch
, unsigned long mach
)
9681 if (arch
!= bfd_arch_alpha
9682 && arch
!= bfd_arch_unknown
)
9685 return bfd_default_set_arch_mach (abfd
, arch
, mach
);
9688 /* Set section VMS flags. Clear NO_FLAGS and set FLAGS. */
9691 bfd_vms_set_section_flags (bfd
*abfd ATTRIBUTE_UNUSED
,
9692 asection
*sec
, flagword no_flags
, flagword flags
)
9694 vms_section_data (sec
)->no_flags
= no_flags
;
9695 vms_section_data (sec
)->flags
= flags
;
9698 struct vms_private_data_struct
*
9699 bfd_vms_get_data (bfd
*abfd
)
9701 return (struct vms_private_data_struct
*)abfd
->tdata
.any
;
9704 #define vms_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false
9705 #define vms_bfd_link_just_syms _bfd_generic_link_just_syms
9706 #define vms_bfd_copy_link_hash_symbol_type \
9707 _bfd_generic_copy_link_hash_symbol_type
9708 #define vms_bfd_is_group_section bfd_generic_is_group_section
9709 #define vms_bfd_group_name bfd_generic_group_name
9710 #define vms_bfd_discard_group bfd_generic_discard_group
9711 #define vms_section_already_linked _bfd_generic_section_already_linked
9712 #define vms_bfd_define_common_symbol bfd_generic_define_common_symbol
9713 #define vms_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
9714 #define vms_bfd_define_start_stop bfd_generic_define_start_stop
9715 #define vms_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
9717 #define vms_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
9718 #define vms_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
9719 #define vms_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data
9720 #define vms_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
9721 #define vms_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
9722 #define vms_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
9724 /* Symbols table. */
9725 #define alpha_vms_make_empty_symbol _bfd_generic_make_empty_symbol
9726 #define alpha_vms_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false
9727 #define alpha_vms_print_symbol vms_print_symbol
9728 #define alpha_vms_get_symbol_info vms_get_symbol_info
9729 #define alpha_vms_get_symbol_version_string \
9730 _bfd_nosymbols_get_symbol_version_string
9732 #define alpha_vms_read_minisymbols _bfd_generic_read_minisymbols
9733 #define alpha_vms_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
9734 #define alpha_vms_get_lineno _bfd_nosymbols_get_lineno
9735 #define alpha_vms_find_inliner_info _bfd_nosymbols_find_inliner_info
9736 #define alpha_vms_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
9737 #define alpha_vms_find_nearest_line _bfd_vms_find_nearest_line
9738 #define alpha_vms_find_line _bfd_nosymbols_find_line
9739 #define alpha_vms_bfd_is_local_label_name vms_bfd_is_local_label_name
9741 /* Generic table. */
9742 #define alpha_vms_close_and_cleanup vms_close_and_cleanup
9743 #define alpha_vms_bfd_free_cached_info vms_bfd_free_cached_info
9744 #define alpha_vms_new_section_hook vms_new_section_hook
9745 #define alpha_vms_set_section_contents _bfd_vms_set_section_contents
9746 #define alpha_vms_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
9748 #define alpha_vms_bfd_get_relocated_section_contents \
9749 bfd_generic_get_relocated_section_contents
9751 #define alpha_vms_bfd_relax_section bfd_generic_relax_section
9752 #define alpha_vms_bfd_gc_sections bfd_generic_gc_sections
9753 #define alpha_vms_bfd_lookup_section_flags bfd_generic_lookup_section_flags
9754 #define alpha_vms_bfd_merge_sections bfd_generic_merge_sections
9755 #define alpha_vms_bfd_is_group_section bfd_generic_is_group_section
9756 #define alpha_vms_bfd_group_name bfd_generic_group_name
9757 #define alpha_vms_bfd_discard_group bfd_generic_discard_group
9758 #define alpha_vms_section_already_linked \
9759 _bfd_generic_section_already_linked
9761 #define alpha_vms_bfd_define_common_symbol bfd_generic_define_common_symbol
9762 #define alpha_vms_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
9763 #define alpha_vms_bfd_define_start_stop bfd_generic_define_start_stop
9764 #define alpha_vms_bfd_link_just_syms _bfd_generic_link_just_syms
9765 #define alpha_vms_bfd_copy_link_hash_symbol_type \
9766 _bfd_generic_copy_link_hash_symbol_type
9768 #define alpha_vms_bfd_link_split_section _bfd_generic_link_split_section
9770 #define alpha_vms_get_dynamic_symtab_upper_bound \
9771 _bfd_nodynamic_get_dynamic_symtab_upper_bound
9772 #define alpha_vms_canonicalize_dynamic_symtab \
9773 _bfd_nodynamic_canonicalize_dynamic_symtab
9774 #define alpha_vms_get_dynamic_reloc_upper_bound \
9775 _bfd_nodynamic_get_dynamic_reloc_upper_bound
9776 #define alpha_vms_canonicalize_dynamic_reloc \
9777 _bfd_nodynamic_canonicalize_dynamic_reloc
9778 #define alpha_vms_bfd_link_check_relocs _bfd_generic_link_check_relocs
9780 const bfd_target alpha_vms_vec
=
9782 "vms-alpha", /* Name. */
9783 bfd_target_evax_flavour
,
9784 BFD_ENDIAN_LITTLE
, /* Data byte order is little. */
9785 BFD_ENDIAN_LITTLE
, /* Header byte order is little. */
9787 (HAS_RELOC
| EXEC_P
| HAS_LINENO
| HAS_DEBUG
| HAS_SYMS
| HAS_LOCALS
9788 | WP_TEXT
| D_PAGED
), /* Object flags. */
9789 (SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
9790 | SEC_READONLY
| SEC_CODE
| SEC_DATA
9791 | SEC_HAS_CONTENTS
| SEC_IN_MEMORY
), /* Sect flags. */
9792 0, /* symbol_leading_char. */
9793 ' ', /* ar_pad_char. */
9794 15, /* ar_max_namelen. */
9795 0, /* match priority. */
9796 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
9797 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
9798 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
9799 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
9800 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
9801 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
9803 { /* bfd_check_format. */
9806 _bfd_vms_lib_alpha_archive_p
,
9809 { /* bfd_set_format. */
9810 _bfd_bool_bfd_false_error
,
9812 _bfd_vms_lib_alpha_mkarchive
,
9813 _bfd_bool_bfd_false_error
9815 { /* bfd_write_contents. */
9816 _bfd_bool_bfd_false_error
,
9817 alpha_vms_write_object_contents
,
9818 _bfd_vms_lib_write_archive_contents
,
9819 _bfd_bool_bfd_false_error
9822 BFD_JUMP_TABLE_GENERIC (alpha_vms
),
9823 BFD_JUMP_TABLE_COPY (vms
),
9824 BFD_JUMP_TABLE_CORE (_bfd_nocore
),
9825 BFD_JUMP_TABLE_ARCHIVE (_bfd_vms_lib
),
9826 BFD_JUMP_TABLE_SYMBOLS (alpha_vms
),
9827 BFD_JUMP_TABLE_RELOCS (alpha_vms
),
9828 BFD_JUMP_TABLE_WRITE (alpha_vms
),
9829 BFD_JUMP_TABLE_LINK (alpha_vms
),
9830 BFD_JUMP_TABLE_DYNAMIC (alpha_vms
),