1 /* vms.c -- BFD back-end for EVAX (openVMS/Alpha) files.
2 Copyright (C) 1996-2017 Free Software Foundation, Inc.
5 Major rewrite by Adacore.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20 MA 02110-1301, USA. */
25 o Generation of shared image
26 o Relocation optimizations
32 o protected sections (for messages)
50 #include "vms/eihvn.h"
51 #include "vms/eobjrec.h"
54 #include "vms/esgps.h"
63 #include "vms/esdfm.h"
64 #include "vms/esdfv.h"
70 #include "vms/internal.h"
73 #define MIN(a,b) ((a) < (b) ? (a) : (b))
75 /* The r_type field in a reloc is one of the following values. */
76 #define ALPHA_R_IGNORE 0
77 #define ALPHA_R_REFQUAD 1
78 #define ALPHA_R_BRADDR 2
79 #define ALPHA_R_HINT 3
80 #define ALPHA_R_SREL16 4
81 #define ALPHA_R_SREL32 5
82 #define ALPHA_R_SREL64 6
83 #define ALPHA_R_OP_PUSH 7
84 #define ALPHA_R_OP_STORE 8
85 #define ALPHA_R_OP_PSUB 9
86 #define ALPHA_R_OP_PRSHIFT 10
87 #define ALPHA_R_LINKAGE 11
88 #define ALPHA_R_REFLONG 12
89 #define ALPHA_R_CODEADDR 13
90 #define ALPHA_R_NOP 14
91 #define ALPHA_R_BSR 15
92 #define ALPHA_R_LDA 16
93 #define ALPHA_R_BOH 17
95 /* These are used with DST_S_C_LINE_NUM. */
96 #define DST_S_C_LINE_NUM_HEADER_SIZE 4
98 /* These are used with DST_S_C_SOURCE */
100 #define DST_S_B_PCLINE_UNSBYTE 1
101 #define DST_S_W_PCLINE_UNSWORD 1
102 #define DST_S_L_PCLINE_UNSLONG 1
104 #define DST_S_B_MODBEG_NAME 14
105 #define DST_S_L_RTNBEG_ADDRESS 5
106 #define DST_S_B_RTNBEG_NAME 13
107 #define DST_S_L_RTNEND_SIZE 5
109 /* These are used with DST_S_C_SOURCE. */
110 #define DST_S_C_SOURCE_HEADER_SIZE 4
112 #define DST_S_B_SRC_DF_LENGTH 1
113 #define DST_S_W_SRC_DF_FILEID 3
114 #define DST_S_B_SRC_DF_FILENAME 20
115 #define DST_S_B_SRC_UNSBYTE 1
116 #define DST_S_W_SRC_UNSWORD 1
117 #define DST_S_L_SRC_UNSLONG 1
119 /* Debugger symbol definitions. */
121 #define DBG_S_L_DMT_MODBEG 0
122 #define DBG_S_L_DST_SIZE 4
123 #define DBG_S_W_DMT_PSECT_COUNT 8
124 #define DBG_S_C_DMT_HEADER_SIZE 12
126 #define DBG_S_L_DMT_PSECT_START 0
127 #define DBG_S_L_DMT_PSECT_LENGTH 4
128 #define DBG_S_C_DMT_PSECT_SIZE 8
130 /* VMS module header. */
146 #define EMH_DATE_LENGTH 17
148 /* VMS End-Of-Module records (EOM/EEOM). */
152 unsigned int eom_l_total_lps;
153 unsigned short eom_w_comcod;
154 bfd_boolean eom_has_transfer;
155 unsigned char eom_b_tfrflg;
156 unsigned int eom_l_psindx;
157 unsigned int eom_l_tfradr;
160 struct vms_symbol_entry
166 unsigned char data_type;
167 unsigned short flags;
169 /* Section and offset/value of the symbol. */
173 /* Section and offset/value for the entry point (only for subprg). */
174 asection *code_section;
175 unsigned int code_value;
177 /* Symbol vector offset. */
178 unsigned int symbol_vector;
180 /* Length of the name. */
181 unsigned char namelen;
186 /* Stack value for push/pop commands. */
194 #define STACKSIZE 128
196 /* A minimal decoding of DST compilation units. We only decode
197 what's needed to get to the line number information. */
207 struct srecinfo *next;
215 struct lineinfo *next;
222 struct funcinfo *next;
230 /* Chain the previously read compilation unit. */
233 /* The module name. */
236 /* The start offset and size of debug info in the DST section. */
240 /* The lowest and highest addresses contained in this compilation
241 unit as specified in the compilation unit header. */
245 /* The listing line table. */
246 struct lineinfo *line_table;
248 /* The source record table. */
249 struct srecinfo *srec_table;
251 /* A list of the functions found in this module. */
252 struct funcinfo *func_table;
254 /* Current allocation of file_table. */
255 unsigned int file_table_count;
257 /* An array of the files making up this module. */
258 struct fileinfo *file_table;
261 /* BFD private data for alpha-vms. */
263 struct vms_private_data_struct
265 /* If true, relocs have been read. */
266 bfd_boolean reloc_done;
268 /* Record input buffer. */
269 struct vms_rec_rd recrd;
270 struct vms_rec_wr recwr;
272 struct hdr_struct hdr_data; /* data from HDR/EMH record */
273 struct eom_struct eom_data; /* data from EOM/EEOM record */
275 /* Transfer addresses (entry points). */
276 bfd_vma transfer_address[4];
278 /* Array of GSD sections to get the correspond BFD one. */
279 unsigned int section_max; /* Size of the sections array. */
280 unsigned int section_count; /* Number of GSD sections. */
283 /* Array of raw symbols. */
284 struct vms_symbol_entry **syms;
286 /* Canonicalized symbols. */
289 /* Number of symbols. */
290 unsigned int gsd_sym_count;
291 /* Size of the syms array. */
292 unsigned int max_sym_count;
293 /* Number of procedure symbols. */
294 unsigned int norm_sym_count;
296 /* Stack used to evaluate TIR/ETIR commands. */
297 struct stack_struct *stack;
300 /* Content reading. */
301 asection *image_section; /* section for image_ptr */
302 file_ptr image_offset; /* Offset for image_ptr. */
304 struct module *modules; /* list of all compilation units */
306 /* The DST section. */
307 asection *dst_section;
309 unsigned int dst_ptr_offsets_count; /* # of offsets in following array */
310 unsigned int *dst_ptr_offsets; /* array of saved image_ptr offsets */
312 /* Shared library support */
313 bfd_vma symvva; /* relative virtual address of symbol vector */
315 unsigned char matchctl;
317 /* Shared library index. This is used for input bfd while linking. */
318 unsigned int shr_index;
320 /* Used to place structures in the file. */
323 /* Simply linked list of eisd. */
324 struct vms_internal_eisd_map *eisd_head;
325 struct vms_internal_eisd_map *eisd_tail;
327 /* Simply linked list of eisd for shared libraries. */
328 struct vms_internal_eisd_map *gbl_eisd_head;
329 struct vms_internal_eisd_map *gbl_eisd_tail;
331 /* linkage index counter used by conditional store commands */
332 unsigned int vms_linkage_index;
335 #define PRIV2(abfd, name) \
336 (((struct vms_private_data_struct *)(abfd)->tdata.any)->name)
337 #define PRIV(name) PRIV2(abfd,name)
340 /* Used to keep extra VMS specific information for a given section.
342 reloc_size holds the size of the relocation stream, note this
343 is very different from the number of relocations as VMS relocations
346 reloc_stream is the actual stream of relocation entries. */
348 struct vms_section_data_struct
350 /* Maximnum number of entries in sec->relocation. */
353 /* Corresponding eisd. Used only while generating executables. */
354 struct vms_internal_eisd_map *eisd;
356 /* PSC flags to be clear. */
359 /* PSC flags to be set. */
363 #define vms_section_data(sec) \
364 ((struct vms_section_data_struct *)sec->used_by_bfd)
366 /* To be called from the debugger. */
367 struct vms_private_data_struct *bfd_vms_get_data (bfd *);
369 static int vms_get_remaining_object_record (bfd *, unsigned int);
370 static bfd_boolean _bfd_vms_slurp_object_records (bfd * abfd);
371 static void alpha_vms_add_fixup_lp (struct bfd_link_info *, bfd *, bfd *);
372 static void alpha_vms_add_fixup_ca (struct bfd_link_info *, bfd *, bfd *);
373 static void alpha_vms_add_fixup_qr (struct bfd_link_info *, bfd *, bfd *,
375 static void alpha_vms_add_fixup_lr (struct bfd_link_info *, unsigned int,
377 static void alpha_vms_add_lw_reloc (struct bfd_link_info *);
378 static void alpha_vms_add_qw_reloc (struct bfd_link_info *);
387 /* Number of elements in VEC. */
389 #define VEC_COUNT(VEC) ((VEC).nbr_el)
391 /* Get the address of the Nth element. */
393 #define VEC_EL(VEC, TYPE, N) (((TYPE *)((VEC).els))[N])
395 #define VEC_INIT(VEC) \
402 /* Be sure there is room for a new element. */
404 static void vector_grow1 (struct vector_type *vec, size_t elsz);
406 /* Allocate room for a new element and return its address. */
408 #define VEC_APPEND(VEC, TYPE) \
409 (vector_grow1 (&VEC, sizeof (TYPE)), &VEC_EL(VEC, TYPE, (VEC).nbr_el++))
411 /* Append an element. */
413 #define VEC_APPEND_EL(VEC, TYPE, EL) \
414 (*(VEC_APPEND (VEC, TYPE)) = EL)
416 struct alpha_vms_vma_ref
418 bfd_vma vma; /* Vma in the output. */
419 bfd_vma ref; /* Reference in the input. */
422 struct alpha_vms_shlib_el
425 bfd_boolean has_fixups;
427 struct vector_type lp; /* Vector of bfd_vma. */
428 struct vector_type ca; /* Vector of bfd_vma. */
429 struct vector_type qr; /* Vector of struct alpha_vms_vma_ref. */
432 /* Alpha VMS linker hash table. */
434 struct alpha_vms_link_hash_table
436 struct bfd_link_hash_table root;
438 /* Vector of shared libraries. */
439 struct vector_type shrlibs;
444 /* Base address. Used by fixups. */
448 #define alpha_vms_link_hash(INFO) \
449 ((struct alpha_vms_link_hash_table *)(INFO->hash))
451 /* Alpha VMS linker hash table entry. */
453 struct alpha_vms_link_hash_entry
455 struct bfd_link_hash_entry root;
457 /* Pointer to the original vms symbol. */
458 struct vms_symbol_entry *sym;
463 /* Read & process EIHD record.
464 Return TRUE on success, FALSE on error. */
467 _bfd_vms_slurp_eihd (bfd *abfd, unsigned int *eisd_offset,
468 unsigned int *eihs_offset)
470 unsigned int imgtype, size;
472 struct vms_eihd *eihd = (struct vms_eihd *)PRIV (recrd.rec);
474 vms_debug2 ((8, "_bfd_vms_slurp_eihd\n"));
476 size = bfd_getl32 (eihd->size);
477 imgtype = bfd_getl32 (eihd->imgtype);
479 if (imgtype == EIHD__K_EXE || imgtype == EIHD__K_LIM)
480 abfd->flags |= EXEC_P;
482 symvva = bfd_getl64 (eihd->symvva);
485 PRIV (symvva) = symvva;
486 abfd->flags |= DYNAMIC;
489 PRIV (ident) = bfd_getl32 (eihd->ident);
490 PRIV (matchctl) = eihd->matchctl;
492 *eisd_offset = bfd_getl32 (eihd->isdoff);
493 *eihs_offset = bfd_getl32 (eihd->symdbgoff);
495 vms_debug2 ((4, "EIHD size %d imgtype %d symvva 0x%lx eisd %d eihs %d\n",
496 size, imgtype, (unsigned long)symvva,
497 *eisd_offset, *eihs_offset));
502 /* Read & process EISD record.
503 Return TRUE on success, FALSE on error. */
506 _bfd_vms_slurp_eisd (bfd *abfd, unsigned int offset)
508 int section_count = 0;
510 vms_debug2 ((8, "_bfd_vms_slurp_eisd\n"));
514 struct vms_eisd *eisd;
515 unsigned int rec_size;
517 unsigned long long vaddr;
524 /* PR 17512: file: 3d9e9fe9. */
525 if (offset >= PRIV (recrd.rec_size))
527 eisd = (struct vms_eisd *)(PRIV (recrd.rec) + offset);
528 rec_size = bfd_getl32 (eisd->eisdsize);
532 /* Skip to next block if pad. */
533 if (rec_size == 0xffffffff)
535 offset = (offset + VMS_BLOCK_SIZE) & ~(VMS_BLOCK_SIZE - 1);
541 size = bfd_getl32 (eisd->secsize);
542 vaddr = bfd_getl64 (eisd->virt_addr);
543 flags = bfd_getl32 (eisd->flags);
544 vbn = bfd_getl32 (eisd->vbn);
546 vms_debug2 ((4, "EISD at 0x%x size 0x%x addr 0x%lx flags 0x%x blk %d\n",
547 offset, size, (unsigned long)vaddr, flags, vbn));
549 /* VMS combines psects from .obj files into isects in the .exe. This
550 process doesn't preserve enough information to reliably determine
551 what's in each section without examining the data. This is
552 especially true of DWARF debug sections. */
553 bfd_flags = SEC_ALLOC;
555 bfd_flags |= SEC_HAS_CONTENTS | SEC_LOAD;
557 if (flags & EISD__M_EXE)
558 bfd_flags |= SEC_CODE;
560 if (flags & EISD__M_NONSHRADR)
561 bfd_flags |= SEC_DATA;
563 if (!(flags & EISD__M_WRT))
564 bfd_flags |= SEC_READONLY;
566 if (flags & EISD__M_DZRO)
567 bfd_flags |= SEC_DATA;
569 if (flags & EISD__M_FIXUPVEC)
570 bfd_flags |= SEC_DATA;
572 if (flags & EISD__M_CRF)
573 bfd_flags |= SEC_DATA;
575 if (flags & EISD__M_GBL)
577 name = _bfd_vms_save_counted_string (eisd->gblnam);
578 bfd_flags |= SEC_COFF_SHARED_LIBRARY;
579 bfd_flags &= ~(SEC_ALLOC | SEC_LOAD);
581 else if (flags & EISD__M_FIXUPVEC)
583 else if (eisd->type == EISD__K_USRSTACK)
589 name = (char*) bfd_alloc (abfd, 32);
590 if (flags & EISD__M_DZRO)
592 else if (flags & EISD__M_EXE)
594 else if (!(flags & EISD__M_WRT))
598 BFD_ASSERT (section_count < 999);
599 sprintf (name, "$%s_%03d$", pfx, section_count++);
602 section = bfd_make_section (abfd, name);
607 section->filepos = vbn ? VMS_BLOCK_SIZE * (vbn - 1) : 0;
608 section->size = size;
609 section->vma = vaddr;
611 if (!bfd_set_section_flags (abfd, section, bfd_flags))
618 /* Read & process EIHS record.
619 Return TRUE on success, FALSE on error. */
622 _bfd_vms_slurp_eihs (bfd *abfd, unsigned int offset)
624 unsigned char *p = PRIV (recrd.rec) + offset;
625 unsigned int gstvbn = bfd_getl32 (p + EIHS__L_GSTVBN);
626 unsigned int gstsize ATTRIBUTE_UNUSED = bfd_getl32 (p + EIHS__L_GSTSIZE);
627 unsigned int dstvbn = bfd_getl32 (p + EIHS__L_DSTVBN);
628 unsigned int dstsize = bfd_getl32 (p + EIHS__L_DSTSIZE);
629 unsigned int dmtvbn = bfd_getl32 (p + EIHS__L_DMTVBN);
630 unsigned int dmtbytes = bfd_getl32 (p + EIHS__L_DMTBYTES);
634 vms_debug (8, "_bfd_vms_slurp_ihs\n");
635 vms_debug (4, "EIHS record gstvbn %d gstsize %d dstvbn %d dstsize %d dmtvbn %d dmtbytes %d\n",
636 gstvbn, gstsize, dstvbn, dstsize, dmtvbn, dmtbytes);
641 flagword bfd_flags = SEC_HAS_CONTENTS | SEC_DEBUGGING;
643 section = bfd_make_section (abfd, "$DST$");
647 section->size = dstsize;
648 section->filepos = VMS_BLOCK_SIZE * (dstvbn - 1);
650 if (!bfd_set_section_flags (abfd, section, bfd_flags))
653 PRIV (dst_section) = section;
654 abfd->flags |= (HAS_DEBUG | HAS_LINENO);
659 flagword bfd_flags = SEC_HAS_CONTENTS | SEC_DEBUGGING;
661 section = bfd_make_section (abfd, "$DMT$");
665 section->size = dmtbytes;
666 section->filepos = VMS_BLOCK_SIZE * (dmtvbn - 1);
668 if (!bfd_set_section_flags (abfd, section, bfd_flags))
674 if (bfd_seek (abfd, VMS_BLOCK_SIZE * (gstvbn - 1), SEEK_SET))
676 bfd_set_error (bfd_error_file_truncated);
680 if (!_bfd_vms_slurp_object_records (abfd))
683 abfd->flags |= HAS_SYMS;
689 /* Object file reading. */
691 /* Object file input functions. */
693 /* Get next record from object file to vms_buf.
694 Set PRIV(buf_size) and return it
696 This is a little tricky since it should be portable.
698 The openVMS object file has 'variable length' which means that
699 read() returns data in chunks of (hopefully) correct and expected
700 size. The linker (and other tools on VMS) depend on that. Unix
701 doesn't know about 'formatted' files, so reading and writing such
702 an object file in a Unix environment is not trivial.
704 With the tool 'file' (available on all VMS FTP sites), one
705 can view and change the attributes of a file. Changing from
706 'variable length' to 'fixed length, 512 bytes' reveals the
707 record size at the first 2 bytes of every record. The same
708 may happen during the transfer of object files from VMS to Unix,
709 at least with UCX, the DEC implementation of TCP/IP.
711 The VMS format repeats the size at bytes 2 & 3 of every record.
713 On the first call (file_format == FF_UNKNOWN) we check if
714 the first and the third byte pair (!) of the record match.
715 If they do it's an object file in an Unix environment or with
716 wrong attributes (FF_FOREIGN), else we should be in a VMS
717 environment where read() returns the record size (FF_NATIVE).
719 Reading is always done in 2 steps:
720 1. first just the record header is read and the size extracted,
721 2. then the read buffer is adjusted and the remaining bytes are
724 All file I/O is done on even file positions. */
726 #define VMS_OBJECT_ADJUSTMENT 2
729 maybe_adjust_record_pointer_for_object (bfd *abfd)
731 /* Set the file format once for all on the first invocation. */
732 if (PRIV (recrd.file_format) == FF_UNKNOWN)
734 if (PRIV (recrd.rec)[0] == PRIV (recrd.rec)[4]
735 && PRIV (recrd.rec)[1] == PRIV (recrd.rec)[5])
736 PRIV (recrd.file_format) = FF_FOREIGN;
738 PRIV (recrd.file_format) = FF_NATIVE;
741 /* The adjustment is needed only in an Unix environment. */
742 if (PRIV (recrd.file_format) == FF_FOREIGN)
743 PRIV (recrd.rec) += VMS_OBJECT_ADJUSTMENT;
746 /* Implement step #1 of the object record reading procedure.
747 Return the record type or -1 on failure. */
750 _bfd_vms_get_object_record (bfd *abfd)
752 unsigned int test_len = 6;
755 vms_debug2 ((8, "_bfd_vms_get_obj_record\n"));
757 /* Skip alignment byte if the current position is odd. */
758 if (PRIV (recrd.file_format) == FF_FOREIGN && (bfd_tell (abfd) & 1))
760 if (bfd_bread (PRIV (recrd.buf), 1, abfd) != 1)
762 bfd_set_error (bfd_error_file_truncated);
767 /* Read the record header */
768 if (bfd_bread (PRIV (recrd.buf), test_len, abfd) != test_len)
770 bfd_set_error (bfd_error_file_truncated);
774 /* Reset the record pointer. */
775 PRIV (recrd.rec) = PRIV (recrd.buf);
776 maybe_adjust_record_pointer_for_object (abfd);
778 if (vms_get_remaining_object_record (abfd, test_len) <= 0)
781 type = bfd_getl16 (PRIV (recrd.rec));
783 vms_debug2 ((8, "_bfd_vms_get_obj_record: rec %p, size %d, type %d\n",
784 PRIV (recrd.rec), PRIV (recrd.rec_size), type));
789 /* Implement step #2 of the object record reading procedure.
790 Return the size of the record or 0 on failure. */
793 vms_get_remaining_object_record (bfd *abfd, unsigned int read_so_far)
795 unsigned int to_read;
797 vms_debug2 ((8, "vms_get_remaining_obj_record\n"));
799 /* Extract record size. */
800 PRIV (recrd.rec_size) = bfd_getl16 (PRIV (recrd.rec) + 2);
802 if (PRIV (recrd.rec_size) == 0)
804 bfd_set_error (bfd_error_file_truncated);
808 /* That's what the linker manual says. */
809 if (PRIV (recrd.rec_size) > EOBJ__C_MAXRECSIZ)
811 bfd_set_error (bfd_error_file_truncated);
815 /* Take into account object adjustment. */
816 to_read = PRIV (recrd.rec_size);
817 if (PRIV (recrd.file_format) == FF_FOREIGN)
818 to_read += VMS_OBJECT_ADJUSTMENT;
820 /* Adjust the buffer. */
821 if (to_read > PRIV (recrd.buf_size))
824 = (unsigned char *) bfd_realloc (PRIV (recrd.buf), to_read);
825 if (PRIV (recrd.buf) == NULL)
827 PRIV (recrd.buf_size) = to_read;
829 /* PR 17512: file: 025-1974-0.004. */
830 else if (to_read <= read_so_far)
833 /* Read the remaining record. */
834 to_read -= read_so_far;
836 vms_debug2 ((8, "vms_get_remaining_obj_record: to_read %d\n", to_read));
838 if (bfd_bread (PRIV (recrd.buf) + read_so_far, to_read, abfd) != to_read)
840 bfd_set_error (bfd_error_file_truncated);
844 /* Reset the record pointer. */
845 PRIV (recrd.rec) = PRIV (recrd.buf);
846 maybe_adjust_record_pointer_for_object (abfd);
848 vms_debug2 ((8, "vms_get_remaining_obj_record: size %d\n",
849 PRIV (recrd.rec_size)));
851 return PRIV (recrd.rec_size);
854 /* Read and process emh record.
855 Return TRUE on success, FALSE on error. */
858 _bfd_vms_slurp_ehdr (bfd *abfd)
861 unsigned char *vms_rec;
865 vms_rec = PRIV (recrd.rec);
866 /* PR 17512: file: 62736583. */
867 end = PRIV (recrd.buf) + PRIV (recrd.buf_size);
869 vms_debug2 ((2, "HDR/EMH\n"));
871 subtype = bfd_getl16 (vms_rec + 4);
873 vms_debug2 ((3, "subtype %d\n", subtype));
879 if (vms_rec + 21 >= end)
881 PRIV (hdr_data).hdr_b_strlvl = vms_rec[6];
882 PRIV (hdr_data).hdr_l_arch1 = bfd_getl32 (vms_rec + 8);
883 PRIV (hdr_data).hdr_l_arch2 = bfd_getl32 (vms_rec + 12);
884 PRIV (hdr_data).hdr_l_recsiz = bfd_getl32 (vms_rec + 16);
885 if ((vms_rec + 20 + vms_rec[20] + 1) >= end)
887 PRIV (hdr_data).hdr_t_name = _bfd_vms_save_counted_string (vms_rec + 20);
888 ptr = vms_rec + 20 + vms_rec[20] + 1;
889 if ((ptr + *ptr + 1) >= end)
891 PRIV (hdr_data).hdr_t_version =_bfd_vms_save_counted_string (ptr);
895 PRIV (hdr_data).hdr_t_date = _bfd_vms_save_sized_string (ptr, 17);
899 if (vms_rec + PRIV (recrd.rec_size - 6) > end)
901 PRIV (hdr_data).hdr_c_lnm =
902 _bfd_vms_save_sized_string (vms_rec, PRIV (recrd.rec_size - 6));
906 if (vms_rec + PRIV (recrd.rec_size - 6) > end)
908 PRIV (hdr_data).hdr_c_src =
909 _bfd_vms_save_sized_string (vms_rec, PRIV (recrd.rec_size - 6));
913 if (vms_rec + PRIV (recrd.rec_size - 6) > end)
915 PRIV (hdr_data).hdr_c_ttl =
916 _bfd_vms_save_sized_string (vms_rec, PRIV (recrd.rec_size - 6));
926 bfd_set_error (bfd_error_wrong_format);
933 /* Typical sections for evax object files. */
935 #define EVAX_ABS_NAME "$ABS$"
936 #define EVAX_CODE_NAME "$CODE$"
937 #define EVAX_LINK_NAME "$LINK$"
938 #define EVAX_DATA_NAME "$DATA$"
939 #define EVAX_BSS_NAME "$BSS$"
940 #define EVAX_READONLYADDR_NAME "$READONLY_ADDR$"
941 #define EVAX_READONLY_NAME "$READONLY$"
942 #define EVAX_LITERAL_NAME "$LITERAL$"
943 #define EVAX_LITERALS_NAME "$LITERALS"
944 #define EVAX_COMMON_NAME "$COMMON$"
945 #define EVAX_LOCAL_NAME "$LOCAL$"
947 struct sec_flags_struct
949 const char *name; /* Name of section. */
951 flagword flags_always; /* Flags we set always. */
953 flagword flags_hassize; /* Flags we set if the section has a size > 0. */
956 /* These flags are deccrtl/vaxcrtl (openVMS 6.2 Alpha) compatible. */
958 static const struct sec_flags_struct evax_section_flags[] =
966 EGPS__V_PIC | EGPS__V_REL | EGPS__V_SHR | EGPS__V_EXE,
967 SEC_CODE | SEC_READONLY,
968 EGPS__V_PIC | EGPS__V_REL | EGPS__V_SHR | EGPS__V_EXE,
969 SEC_CODE | SEC_READONLY | SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD },
971 EGPS__V_PIC | EGPS__V_REL | EGPS__V_SHR | EGPS__V_RD | EGPS__V_NOMOD,
972 SEC_DATA | SEC_READONLY,
973 EGPS__V_PIC | EGPS__V_REL | EGPS__V_SHR | EGPS__V_RD,
974 SEC_DATA | SEC_READONLY | SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD },
976 EGPS__V_REL | EGPS__V_RD,
977 SEC_DATA | SEC_READONLY,
978 EGPS__V_REL | EGPS__V_RD,
979 SEC_DATA | SEC_READONLY | SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD },
981 EGPS__V_REL | EGPS__V_RD | EGPS__V_WRT | EGPS__V_NOMOD,
983 EGPS__V_REL | EGPS__V_RD | EGPS__V_WRT,
984 SEC_DATA | SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD },
986 EGPS__V_REL | EGPS__V_RD | EGPS__V_WRT | EGPS__V_NOMOD,
988 EGPS__V_REL | EGPS__V_RD | EGPS__V_WRT | EGPS__V_NOMOD,
990 { EVAX_READONLYADDR_NAME,
991 EGPS__V_PIC | EGPS__V_REL | EGPS__V_RD,
992 SEC_DATA | SEC_READONLY,
993 EGPS__V_PIC | EGPS__V_REL | EGPS__V_RD,
994 SEC_DATA | SEC_READONLY | SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD },
995 { EVAX_READONLY_NAME,
996 EGPS__V_PIC | EGPS__V_REL | EGPS__V_SHR | EGPS__V_RD | EGPS__V_NOMOD,
997 SEC_DATA | SEC_READONLY,
998 EGPS__V_PIC | EGPS__V_REL | EGPS__V_SHR | EGPS__V_RD,
999 SEC_DATA | SEC_READONLY | SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD },
1001 EGPS__V_REL | EGPS__V_RD | EGPS__V_WRT,
1003 EGPS__V_REL | EGPS__V_RD | EGPS__V_WRT,
1004 SEC_DATA | SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD },
1005 { EVAX_LITERALS_NAME,
1006 EGPS__V_PIC | EGPS__V_OVR,
1007 SEC_DATA | SEC_READONLY,
1008 EGPS__V_PIC | EGPS__V_OVR,
1009 SEC_DATA | SEC_READONLY | SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD },
1011 EGPS__V_REL | EGPS__V_RD | EGPS__V_WRT,
1013 EGPS__V_REL | EGPS__V_RD | EGPS__V_WRT,
1014 SEC_DATA | SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD }
1017 /* Retrieve BFD section flags by name and size. */
1020 vms_secflag_by_name (const struct sec_flags_struct *section_flags,
1026 while (section_flags[i].name != NULL)
1028 if (strcmp (name, section_flags[i].name) == 0)
1031 return section_flags[i].flags_hassize;
1033 return section_flags[i].flags_always;
1038 return section_flags[i].flags_hassize;
1039 return section_flags[i].flags_always;
1042 /* Retrieve VMS section flags by name and size. */
1045 vms_esecflag_by_name (const struct sec_flags_struct *section_flags,
1051 while (section_flags[i].name != NULL)
1053 if (strcmp (name, section_flags[i].name) == 0)
1056 return section_flags[i].vflags_hassize;
1058 return section_flags[i].vflags_always;
1063 return section_flags[i].vflags_hassize;
1064 return section_flags[i].vflags_always;
1067 /* Add SYM to the symbol table of ABFD.
1068 Return FALSE in case of error. */
1071 add_symbol_entry (bfd *abfd, struct vms_symbol_entry *sym)
1073 if (PRIV (gsd_sym_count) >= PRIV (max_sym_count))
1075 if (PRIV (max_sym_count) == 0)
1077 PRIV (max_sym_count) = 128;
1078 PRIV (syms) = bfd_malloc
1079 (PRIV (max_sym_count) * sizeof (struct vms_symbol_entry *));
1083 PRIV (max_sym_count) *= 2;
1084 PRIV (syms) = bfd_realloc
1086 (PRIV (max_sym_count) * sizeof (struct vms_symbol_entry *)));
1088 if (PRIV (syms) == NULL)
1092 PRIV (syms)[PRIV (gsd_sym_count)++] = sym;
1096 /* Create a symbol whose name is ASCIC and add it to ABFD.
1097 Return NULL in case of error. */
1099 static struct vms_symbol_entry *
1100 add_symbol (bfd *abfd, const unsigned char *ascic)
1102 struct vms_symbol_entry *entry;
1106 entry = (struct vms_symbol_entry *)bfd_zalloc (abfd, sizeof (*entry) + len);
1109 entry->namelen = len;
1110 memcpy (entry->name, ascic, len);
1111 entry->name[len] = 0;
1112 entry->owner = abfd;
1114 if (!add_symbol_entry (abfd, entry))
1119 /* Read and process EGSD. Return FALSE on failure. */
1122 _bfd_vms_slurp_egsd (bfd *abfd)
1124 int gsd_type, gsd_size;
1125 unsigned char *vms_rec;
1126 unsigned long base_addr;
1128 vms_debug2 ((2, "EGSD\n"));
1130 PRIV (recrd.rec) += 8; /* Skip type, size, align pad. */
1131 PRIV (recrd.rec_size) -= 8;
1133 /* Calculate base address for each section. */
1136 while (PRIV (recrd.rec_size) > 0)
1138 vms_rec = PRIV (recrd.rec);
1140 gsd_type = bfd_getl16 (vms_rec);
1141 gsd_size = bfd_getl16 (vms_rec + 2);
1143 vms_debug2 ((3, "egsd_type %d\n", gsd_type));
1148 /* Program section definition. */
1150 struct vms_egps *egps = (struct vms_egps *)vms_rec;
1151 flagword new_flags, vms_flags;
1154 vms_flags = bfd_getl16 (egps->flags);
1156 if ((vms_flags & EGPS__V_REL) == 0)
1158 /* Use the global absolute section for all
1159 absolute sections. */
1160 section = bfd_abs_section_ptr;
1165 unsigned long align_addr;
1167 name = _bfd_vms_save_counted_string (&egps->namlng);
1169 section = bfd_make_section (abfd, name);
1173 section->filepos = 0;
1174 section->size = bfd_getl32 (egps->alloc);
1175 section->alignment_power = egps->align;
1177 vms_section_data (section)->flags = vms_flags;
1178 vms_section_data (section)->no_flags = 0;
1180 new_flags = vms_secflag_by_name (evax_section_flags, name,
1182 if (section->size > 0)
1183 new_flags |= SEC_LOAD;
1184 if (!(vms_flags & EGPS__V_NOMOD) && section->size > 0)
1186 /* Set RELOC and HAS_CONTENTS if the section is not
1187 demand-zero and not empty. */
1188 new_flags |= SEC_HAS_CONTENTS;
1189 if (vms_flags & EGPS__V_REL)
1190 new_flags |= SEC_RELOC;
1192 if (vms_flags & EGPS__V_EXE)
1194 /* Set CODE if section is executable. */
1195 new_flags |= SEC_CODE;
1196 new_flags &= ~SEC_DATA;
1198 if (!bfd_set_section_flags (abfd, section, new_flags))
1201 /* Give a non-overlapping vma to non absolute sections. */
1202 align_addr = (1 << section->alignment_power);
1203 if ((base_addr % align_addr) != 0)
1204 base_addr += (align_addr - (base_addr % align_addr));
1205 section->vma = (bfd_vma)base_addr;
1206 base_addr += section->size;
1209 /* Append it to the section array. */
1210 if (PRIV (section_count) >= PRIV (section_max))
1212 if (PRIV (section_max) == 0)
1213 PRIV (section_max) = 16;
1215 PRIV (section_max) *= 2;
1216 PRIV (sections) = bfd_realloc_or_free
1217 (PRIV (sections), PRIV (section_max) * sizeof (asection *));
1218 if (PRIV (sections) == NULL)
1222 PRIV (sections)[PRIV (section_count)] = section;
1223 PRIV (section_count)++;
1230 struct vms_symbol_entry *entry;
1231 struct vms_egsy *egsy = (struct vms_egsy *) vms_rec;
1234 old_flags = bfd_getl16 (egsy->flags);
1235 if (old_flags & EGSY__V_DEF)
1236 nameoff = ESDF__B_NAMLNG;
1238 nameoff = ESRF__B_NAMLNG;
1240 entry = add_symbol (abfd, vms_rec + nameoff);
1244 /* Allow only duplicate reference. */
1245 if ((entry->flags & EGSY__V_DEF) && (old_flags & EGSY__V_DEF))
1248 if (entry->typ == 0)
1250 entry->typ = gsd_type;
1251 entry->data_type = egsy->datyp;
1252 entry->flags = old_flags;
1255 if (old_flags & EGSY__V_DEF)
1257 struct vms_esdf *esdf = (struct vms_esdf *)vms_rec;
1259 entry->value = bfd_getl64 (esdf->value);
1260 entry->section = PRIV (sections)[bfd_getl32 (esdf->psindx)];
1262 if (old_flags & EGSY__V_NORM)
1264 PRIV (norm_sym_count)++;
1266 entry->code_value = bfd_getl64 (esdf->code_address);
1267 entry->code_section =
1268 PRIV (sections)[bfd_getl32 (esdf->ca_psindx)];
1276 struct vms_symbol_entry *entry;
1277 struct vms_egst *egst = (struct vms_egst *)vms_rec;
1280 old_flags = bfd_getl16 (egst->header.flags);
1282 entry = add_symbol (abfd, &egst->namlng);
1287 entry->typ = gsd_type;
1288 entry->data_type = egst->header.datyp;
1289 entry->flags = old_flags;
1291 entry->symbol_vector = bfd_getl32 (egst->value);
1293 if (old_flags & EGSY__V_REL)
1294 entry->section = PRIV (sections)[bfd_getl32 (egst->psindx)];
1296 entry->section = bfd_abs_section_ptr;
1298 entry->value = bfd_getl64 (egst->lp_2);
1300 if (old_flags & EGSY__V_NORM)
1302 PRIV (norm_sym_count)++;
1304 entry->code_value = bfd_getl64 (egst->lp_1);
1305 entry->code_section = bfd_abs_section_ptr;
1312 /* Currently ignored. */
1317 _bfd_error_handler (_("Unknown EGSD subtype %d"), gsd_type);
1318 bfd_set_error (bfd_error_bad_value);
1322 PRIV (recrd.rec_size) -= gsd_size;
1323 PRIV (recrd.rec) += gsd_size;
1326 if (PRIV (gsd_sym_count) > 0)
1327 abfd->flags |= HAS_SYMS;
1332 /* Stack routines for vms ETIR commands. */
1334 /* Push value and section index. */
1337 _bfd_vms_push (bfd *abfd, bfd_vma val, unsigned int reloc)
1339 vms_debug2 ((4, "<push %08lx (0x%08x) at %d>\n",
1340 (unsigned long)val, reloc, PRIV (stackptr)));
1342 PRIV (stack[PRIV (stackptr)]).value = val;
1343 PRIV (stack[PRIV (stackptr)]).reloc = reloc;
1345 if (PRIV (stackptr) >= STACKSIZE)
1347 bfd_set_error (bfd_error_bad_value);
1348 _bfd_error_handler (_("Stack overflow (%d) in _bfd_vms_push"), PRIV (stackptr));
1353 /* Pop value and section index. */
1356 _bfd_vms_pop (bfd *abfd, bfd_vma *val, unsigned int *rel)
1358 if (PRIV (stackptr) == 0)
1360 bfd_set_error (bfd_error_bad_value);
1361 _bfd_error_handler (_("Stack underflow in _bfd_vms_pop"));
1365 *val = PRIV (stack[PRIV (stackptr)]).value;
1366 *rel = PRIV (stack[PRIV (stackptr)]).reloc;
1368 vms_debug2 ((4, "<pop %08lx (0x%08x)>\n", (unsigned long)*val, *rel));
1371 /* Routines to fill sections contents during tir/etir read. */
1373 /* Initialize image buffer pointer to be filled. */
1376 image_set_ptr (bfd *abfd, bfd_vma vma, int sect, struct bfd_link_info *info)
1380 vms_debug2 ((4, "image_set_ptr (0x%08x, sect=%d)\n", (unsigned)vma, sect));
1382 sec = PRIV (sections)[sect];
1386 /* Reading contents to an output bfd. */
1388 if (sec->output_section == NULL)
1390 /* Section discarded. */
1391 vms_debug2 ((5, " section %s discarded\n", sec->name));
1393 /* This is not used. */
1394 PRIV (image_section) = NULL;
1395 PRIV (image_offset) = 0;
1398 PRIV (image_offset) = sec->output_offset + vma;
1399 PRIV (image_section) = sec->output_section;
1403 PRIV (image_offset) = vma;
1404 PRIV (image_section) = sec;
1408 /* Increment image buffer pointer by offset. */
1411 image_inc_ptr (bfd *abfd, bfd_vma offset)
1413 vms_debug2 ((4, "image_inc_ptr (%u)\n", (unsigned)offset));
1415 PRIV (image_offset) += offset;
1418 /* Save current DST location counter under specified index. */
1421 dst_define_location (bfd *abfd, unsigned int loc)
1423 vms_debug2 ((4, "dst_define_location (%d)\n", (int)loc));
1425 /* Grow the ptr offset table if necessary. */
1426 if (loc + 1 > PRIV (dst_ptr_offsets_count))
1428 PRIV (dst_ptr_offsets) = bfd_realloc (PRIV (dst_ptr_offsets),
1429 (loc + 1) * sizeof (unsigned int));
1430 PRIV (dst_ptr_offsets_count) = loc + 1;
1433 PRIV (dst_ptr_offsets)[loc] = PRIV (image_offset);
1436 /* Restore saved DST location counter from specified index. */
1439 dst_restore_location (bfd *abfd, unsigned int loc)
1441 vms_debug2 ((4, "dst_restore_location (%d)\n", (int)loc));
1443 PRIV (image_offset) = PRIV (dst_ptr_offsets)[loc];
1446 /* Retrieve saved DST location counter from specified index. */
1449 dst_retrieve_location (bfd *abfd, unsigned int loc)
1451 vms_debug2 ((4, "dst_retrieve_location (%d)\n", (int)loc));
1453 return PRIV (dst_ptr_offsets)[loc];
1456 /* Write multiple bytes to section image. */
1459 image_write (bfd *abfd, unsigned char *ptr, unsigned int size)
1462 _bfd_vms_debug (8, "image_write from (%p, %d) to (%ld)\n", ptr, size,
1463 (long)PRIV (image_offset));
1464 _bfd_hexdump (9, ptr, size, 0);
1467 if (PRIV (image_section)->contents != NULL)
1469 asection *sec = PRIV (image_section);
1470 file_ptr off = PRIV (image_offset);
1473 if (off > (file_ptr)sec->size
1474 || size > (file_ptr)sec->size
1475 || off + size > (file_ptr)sec->size)
1477 bfd_set_error (bfd_error_bad_value);
1481 memcpy (sec->contents + off, ptr, size);
1484 PRIV (image_offset) += size;
1488 /* Write byte to section image. */
1491 image_write_b (bfd * abfd, unsigned int value)
1493 unsigned char data[1];
1495 vms_debug2 ((6, "image_write_b (%02x)\n", (int) value));
1499 return image_write (abfd, data, sizeof (data));
1502 /* Write 2-byte word to image. */
1505 image_write_w (bfd * abfd, unsigned int value)
1507 unsigned char data[2];
1509 vms_debug2 ((6, "image_write_w (%04x)\n", (int) value));
1511 bfd_putl16 (value, data);
1512 return image_write (abfd, data, sizeof (data));
1515 /* Write 4-byte long to image. */
1518 image_write_l (bfd * abfd, unsigned long value)
1520 unsigned char data[4];
1522 vms_debug2 ((6, "image_write_l (%08lx)\n", value));
1524 bfd_putl32 (value, data);
1525 return image_write (abfd, data, sizeof (data));
1528 /* Write 8-byte quad to image. */
1531 image_write_q (bfd * abfd, bfd_vma value)
1533 unsigned char data[8];
1535 vms_debug2 ((6, "image_write_q (%08lx)\n", (unsigned long)value));
1537 bfd_putl64 (value, data);
1538 return image_write (abfd, data, sizeof (data));
1542 _bfd_vms_etir_name (int cmd)
1546 case ETIR__C_STA_GBL: return "ETIR__C_STA_GBL";
1547 case ETIR__C_STA_LW: return "ETIR__C_STA_LW";
1548 case ETIR__C_STA_QW: return "ETIR__C_STA_QW";
1549 case ETIR__C_STA_PQ: return "ETIR__C_STA_PQ";
1550 case ETIR__C_STA_LI: return "ETIR__C_STA_LI";
1551 case ETIR__C_STA_MOD: return "ETIR__C_STA_MOD";
1552 case ETIR__C_STA_CKARG: return "ETIR__C_STA_CKARG";
1553 case ETIR__C_STO_B: return "ETIR__C_STO_B";
1554 case ETIR__C_STO_W: return "ETIR__C_STO_W";
1555 case ETIR__C_STO_GBL: return "ETIR__C_STO_GBL";
1556 case ETIR__C_STO_CA: return "ETIR__C_STO_CA";
1557 case ETIR__C_STO_RB: return "ETIR__C_STO_RB";
1558 case ETIR__C_STO_AB: return "ETIR__C_STO_AB";
1559 case ETIR__C_STO_OFF: return "ETIR__C_STO_OFF";
1560 case ETIR__C_STO_IMM: return "ETIR__C_STO_IMM";
1561 case ETIR__C_STO_IMMR: return "ETIR__C_STO_IMMR";
1562 case ETIR__C_STO_LW: return "ETIR__C_STO_LW";
1563 case ETIR__C_STO_QW: return "ETIR__C_STO_QW";
1564 case ETIR__C_STO_GBL_LW: return "ETIR__C_STO_GBL_LW";
1565 case ETIR__C_STO_LP_PSB: return "ETIR__C_STO_LP_PSB";
1566 case ETIR__C_STO_HINT_GBL: return "ETIR__C_STO_HINT_GBL";
1567 case ETIR__C_STO_HINT_PS: return "ETIR__C_STO_HINT_PS";
1568 case ETIR__C_OPR_ADD: return "ETIR__C_OPR_ADD";
1569 case ETIR__C_OPR_SUB: return "ETIR__C_OPR_SUB";
1570 case ETIR__C_OPR_INSV: return "ETIR__C_OPR_INSV";
1571 case ETIR__C_OPR_USH: return "ETIR__C_OPR_USH";
1572 case ETIR__C_OPR_ROT: return "ETIR__C_OPR_ROT";
1573 case ETIR__C_OPR_REDEF: return "ETIR__C_OPR_REDEF";
1574 case ETIR__C_OPR_DFLIT: return "ETIR__C_OPR_DFLIT";
1575 case ETIR__C_STC_LP: return "ETIR__C_STC_LP";
1576 case ETIR__C_STC_GBL: return "ETIR__C_STC_GBL";
1577 case ETIR__C_STC_GCA: return "ETIR__C_STC_GCA";
1578 case ETIR__C_STC_PS: return "ETIR__C_STC_PS";
1579 case ETIR__C_STC_NBH_PS: return "ETIR__C_STC_NBH_PS";
1580 case ETIR__C_STC_NOP_GBL: return "ETIR__C_STC_NOP_GBL";
1581 case ETIR__C_STC_NOP_PS: return "ETIR__C_STC_NOP_PS";
1582 case ETIR__C_STC_BSR_GBL: return "ETIR__C_STC_BSR_GBL";
1583 case ETIR__C_STC_BSR_PS: return "ETIR__C_STC_BSR_PS";
1584 case ETIR__C_STC_LDA_GBL: return "ETIR__C_STC_LDA_GBL";
1585 case ETIR__C_STC_LDA_PS: return "ETIR__C_STC_LDA_PS";
1586 case ETIR__C_STC_BOH_GBL: return "ETIR__C_STC_BOH_GBL";
1587 case ETIR__C_STC_BOH_PS: return "ETIR__C_STC_BOH_PS";
1588 case ETIR__C_STC_NBH_GBL: return "ETIR__C_STC_NBH_GBL";
1589 case ETIR__C_STC_LP_PSB: return "ETIR__C_STC_LP_PSB";
1590 case ETIR__C_CTL_SETRB: return "ETIR__C_CTL_SETRB";
1591 case ETIR__C_CTL_AUGRB: return "ETIR__C_CTL_AUGRB";
1592 case ETIR__C_CTL_DFLOC: return "ETIR__C_CTL_DFLOC";
1593 case ETIR__C_CTL_STLOC: return "ETIR__C_CTL_STLOC";
1594 case ETIR__C_CTL_STKDL: return "ETIR__C_CTL_STKDL";
1597 /* These names have not yet been added to this switch statement. */
1598 _bfd_error_handler (_("unknown ETIR command %d"), cmd);
1603 #define HIGHBIT(op) ((op & 0x80000000L) == 0x80000000L)
1606 _bfd_vms_get_value (bfd *abfd,
1607 const unsigned char *ascic,
1608 const unsigned char *max_ascic,
1609 struct bfd_link_info *info,
1611 struct alpha_vms_link_hash_entry **hp)
1616 struct alpha_vms_link_hash_entry *h;
1618 /* Not linking. Do not try to resolve the symbol. */
1627 if (ascic + len >= max_ascic)
1629 _bfd_error_handler (_("Corrupt vms value"));
1635 for (i = 0; i < len; i++)
1636 name[i] = ascic[i + 1];
1639 h = (struct alpha_vms_link_hash_entry *)
1640 bfd_link_hash_lookup (info->hash, name, FALSE, FALSE, TRUE);
1645 && (h->root.type == bfd_link_hash_defined
1646 || h->root.type == bfd_link_hash_defweak))
1647 *vma = h->root.u.def.value
1648 + h->root.u.def.section->output_offset
1649 + h->root.u.def.section->output_section->vma;
1650 else if (h && h->root.type == bfd_link_hash_undefweak)
1654 (*info->callbacks->undefined_symbol)
1655 (info, name, abfd, PRIV (image_section), PRIV (image_offset), TRUE);
1662 #define RELC_SHR_BASE 0x10000
1663 #define RELC_SEC_BASE 0x20000
1664 #define RELC_MASK 0x0ffff
1667 alpha_vms_sym_to_ctxt (struct alpha_vms_link_hash_entry *h)
1669 /* Handle undefined symbols. */
1670 if (h == NULL || h->sym == NULL)
1673 if (h->sym->typ == EGSD__C_SYMG)
1675 if (h->sym->flags & EGSY__V_REL)
1676 return RELC_SHR_BASE + PRIV2 (h->sym->owner, shr_index);
1679 /* Can this happen (non-relocatable symg) ? I'd like to see
1684 if (h->sym->typ == EGSD__C_SYM)
1686 if (h->sym->flags & EGSY__V_REL)
1695 alpha_vms_get_sym_value (asection *sect, bfd_vma addr)
1697 return sect->output_section->vma + sect->output_offset + addr;
1701 alpha_vms_fix_sec_rel (bfd *abfd, struct bfd_link_info *info,
1702 unsigned int rel, bfd_vma vma)
1704 asection *sec = PRIV (sections)[rel & RELC_MASK];
1708 if (sec->output_section == NULL)
1710 return vma + sec->output_section->vma + sec->output_offset;
1713 return vma + sec->vma;
1716 /* Read an ETIR record from ABFD. If INFO is not null, put the content into
1717 the output section (used during linking).
1718 Return FALSE in case of error. */
1721 _bfd_vms_slurp_etir (bfd *abfd, struct bfd_link_info *info)
1724 unsigned int length;
1725 unsigned char *maxptr;
1730 struct alpha_vms_link_hash_entry *h;
1732 PRIV (recrd.rec) += ETIR__C_HEADER_SIZE;
1733 PRIV (recrd.rec_size) -= ETIR__C_HEADER_SIZE;
1735 ptr = PRIV (recrd.rec);
1736 length = PRIV (recrd.rec_size);
1737 maxptr = ptr + length;
1739 vms_debug2 ((2, "ETIR: %d bytes\n", length));
1741 while (ptr < maxptr)
1743 int cmd = bfd_getl16 (ptr);
1744 int cmd_length = bfd_getl16 (ptr + 2);
1749 _bfd_vms_debug (4, "etir: %s(%d)\n",
1750 _bfd_vms_etir_name (cmd), cmd);
1751 _bfd_hexdump (8, ptr, cmd_length - 4, 0);
1754 /* PR 21589: Check for a corrupt ETIR record. */
1758 _bfd_error_handler (_("Corrupt ETIR record encountered"));
1759 bfd_set_error (bfd_error_bad_value);
1768 stack 32 bit value of symbol (high bits set to 0). */
1769 case ETIR__C_STA_GBL:
1770 _bfd_vms_get_value (abfd, ptr, maxptr, info, &op1, &h);
1771 _bfd_vms_push (abfd, op1, alpha_vms_sym_to_ctxt (h));
1777 stack 32 bit value, sign extend to 64 bit. */
1778 case ETIR__C_STA_LW:
1779 if (ptr + 4 >= maxptr)
1781 _bfd_vms_push (abfd, bfd_getl32 (ptr), RELC_NONE);
1787 stack 64 bit value of symbol. */
1788 case ETIR__C_STA_QW:
1789 if (ptr + 8 >= maxptr)
1791 _bfd_vms_push (abfd, bfd_getl64 (ptr), RELC_NONE);
1794 /* Stack psect base plus quadword offset
1795 arg: lw section index
1796 qw signed quadword offset (low 32 bits)
1798 Stack qw argument and section index
1799 (see ETIR__C_STO_OFF, ETIR__C_CTL_SETRB). */
1800 case ETIR__C_STA_PQ:
1804 if (ptr + 12 >= maxptr)
1806 psect = bfd_getl32 (ptr);
1807 if ((unsigned int) psect >= PRIV (section_count))
1809 _bfd_error_handler (_("bad section index in %s"),
1810 _bfd_vms_etir_name (cmd));
1811 bfd_set_error (bfd_error_bad_value);
1814 op1 = bfd_getl64 (ptr + 4);
1815 _bfd_vms_push (abfd, op1, psect | RELC_SEC_BASE);
1819 case ETIR__C_STA_LI:
1820 case ETIR__C_STA_MOD:
1821 case ETIR__C_STA_CKARG:
1822 _bfd_error_handler (_("unsupported STA cmd %s"),
1823 _bfd_vms_etir_name (cmd));
1827 /* Store byte: pop stack, write byte
1830 _bfd_vms_pop (abfd, &op1, &rel1);
1831 if (rel1 != RELC_NONE)
1833 image_write_b (abfd, (unsigned int) op1 & 0xff);
1836 /* Store word: pop stack, write word
1839 _bfd_vms_pop (abfd, &op1, &rel1);
1840 if (rel1 != RELC_NONE)
1842 image_write_w (abfd, (unsigned int) op1 & 0xffff);
1845 /* Store longword: pop stack, write longword
1847 case ETIR__C_STO_LW:
1848 _bfd_vms_pop (abfd, &op1, &rel1);
1849 if (rel1 & RELC_SEC_BASE)
1851 op1 = alpha_vms_fix_sec_rel (abfd, info, rel1, op1);
1854 else if (rel1 & RELC_SHR_BASE)
1856 alpha_vms_add_fixup_lr (info, rel1 & RELC_MASK, op1);
1859 if (rel1 != RELC_NONE)
1861 if (rel1 != RELC_REL)
1863 alpha_vms_add_lw_reloc (info);
1865 image_write_l (abfd, op1);
1868 /* Store quadword: pop stack, write quadword
1870 case ETIR__C_STO_QW:
1871 _bfd_vms_pop (abfd, &op1, &rel1);
1872 if (rel1 & RELC_SEC_BASE)
1874 op1 = alpha_vms_fix_sec_rel (abfd, info, rel1, op1);
1877 else if (rel1 & RELC_SHR_BASE)
1879 if (rel1 != RELC_NONE)
1881 if (rel1 != RELC_REL)
1883 alpha_vms_add_qw_reloc (info);
1885 image_write_q (abfd, op1);
1888 /* Store immediate repeated: pop stack for repeat count
1891 case ETIR__C_STO_IMMR:
1895 if (ptr + 4 >= maxptr)
1897 size = bfd_getl32 (ptr);
1898 _bfd_vms_pop (abfd, &op1, &rel1);
1899 if (rel1 != RELC_NONE)
1902 image_write (abfd, ptr + 4, size);
1906 /* Store global: write symbol value
1907 arg: cs global symbol name. */
1908 case ETIR__C_STO_GBL:
1909 _bfd_vms_get_value (abfd, ptr, maxptr, info, &op1, &h);
1912 if (h->sym->typ == EGSD__C_SYMG)
1914 alpha_vms_add_fixup_qr
1915 (info, abfd, h->sym->owner, h->sym->symbol_vector);
1920 op1 = alpha_vms_get_sym_value (h->sym->section,
1922 alpha_vms_add_qw_reloc (info);
1925 image_write_q (abfd, op1);
1928 /* Store code address: write address of entry point
1929 arg: cs global symbol name (procedure). */
1930 case ETIR__C_STO_CA:
1931 _bfd_vms_get_value (abfd, ptr, maxptr, info, &op1, &h);
1934 if (h->sym->flags & EGSY__V_NORM)
1936 /* That's really a procedure. */
1937 if (h->sym->typ == EGSD__C_SYMG)
1939 alpha_vms_add_fixup_ca (info, abfd, h->sym->owner);
1940 op1 = h->sym->symbol_vector;
1944 op1 = alpha_vms_get_sym_value (h->sym->code_section,
1945 h->sym->code_value);
1946 alpha_vms_add_qw_reloc (info);
1951 /* Symbol is not a procedure. */
1955 image_write_q (abfd, op1);
1958 /* Store offset to psect: pop stack, add low 32 bits to base of psect
1960 case ETIR__C_STO_OFF:
1961 _bfd_vms_pop (abfd, &op1, &rel1);
1963 if (!(rel1 & RELC_SEC_BASE))
1966 op1 = alpha_vms_fix_sec_rel (abfd, info, rel1, op1);
1968 image_write_q (abfd, op1);
1972 arg: lw count of bytes
1974 case ETIR__C_STO_IMM:
1978 if (ptr + 4 >= maxptr)
1980 size = bfd_getl32 (ptr);
1981 image_write (abfd, ptr + 4, size);
1985 /* This code is 'reserved to digital' according to the openVMS
1986 linker manual, however it is generated by the DEC C compiler
1987 and defined in the include file.
1988 FIXME, since the following is just a guess
1989 store global longword: store 32bit value of symbol
1990 arg: cs symbol name. */
1991 case ETIR__C_STO_GBL_LW:
1992 _bfd_vms_get_value (abfd, ptr, maxptr, info, &op1, &h);
1996 image_write_l (abfd, op1);
1999 case ETIR__C_STO_RB:
2000 case ETIR__C_STO_AB:
2001 case ETIR__C_STO_LP_PSB:
2002 _bfd_error_handler (_("%s: not supported"),
2003 _bfd_vms_etir_name (cmd));
2006 case ETIR__C_STO_HINT_GBL:
2007 case ETIR__C_STO_HINT_PS:
2008 _bfd_error_handler (_("%s: not implemented"),
2009 _bfd_vms_etir_name (cmd));
2013 /* 200 Store-conditional Linkage Pair
2015 case ETIR__C_STC_LP:
2017 /* 202 Store-conditional Address at global address
2021 case ETIR__C_STC_GBL:
2023 /* 203 Store-conditional Code Address at global address
2025 cs procedure name. */
2026 case ETIR__C_STC_GCA:
2028 /* 204 Store-conditional Address at psect + offset
2032 case ETIR__C_STC_PS:
2033 _bfd_error_handler (_("%s: not supported"),
2034 _bfd_vms_etir_name (cmd));
2038 /* 201 Store-conditional Linkage Pair with Procedure Signature
2044 case ETIR__C_STC_LP_PSB:
2045 _bfd_vms_get_value (abfd, ptr + 4, maxptr, info, &op1, &h);
2048 if (h->sym->typ == EGSD__C_SYMG)
2050 alpha_vms_add_fixup_lp (info, abfd, h->sym->owner);
2051 op1 = h->sym->symbol_vector;
2056 op1 = alpha_vms_get_sym_value (h->sym->code_section,
2057 h->sym->code_value);
2058 op2 = alpha_vms_get_sym_value (h->sym->section,
2064 /* Undefined symbol. */
2068 image_write_q (abfd, op1);
2069 image_write_q (abfd, op2);
2072 /* 205 Store-conditional NOP at address of global
2074 case ETIR__C_STC_NOP_GBL:
2077 /* 207 Store-conditional BSR at global address
2080 case ETIR__C_STC_BSR_GBL:
2083 /* 209 Store-conditional LDA at global address
2086 case ETIR__C_STC_LDA_GBL:
2089 /* 211 Store-conditional BSR or Hint at global address
2092 case ETIR__C_STC_BOH_GBL:
2093 /* Currentl ignored. */
2096 /* 213 Store-conditional NOP,BSR or HINT at global address
2099 case ETIR__C_STC_NBH_GBL:
2101 /* 206 Store-conditional NOP at pect + offset
2104 case ETIR__C_STC_NOP_PS:
2106 /* 208 Store-conditional BSR at pect + offset
2109 case ETIR__C_STC_BSR_PS:
2111 /* 210 Store-conditional LDA at psect + offset
2114 case ETIR__C_STC_LDA_PS:
2116 /* 212 Store-conditional BSR or Hint at pect + offset
2119 case ETIR__C_STC_BOH_PS:
2121 /* 214 Store-conditional NOP, BSR or HINT at psect + offset
2123 case ETIR__C_STC_NBH_PS:
2124 _bfd_error_handler (_("%s: not supported"),
2125 _bfd_vms_etir_name (cmd));
2129 /* Det relocation base: pop stack, set image location counter
2131 case ETIR__C_CTL_SETRB:
2132 _bfd_vms_pop (abfd, &op1, &rel1);
2133 if (!(rel1 & RELC_SEC_BASE))
2135 image_set_ptr (abfd, op1, rel1 & RELC_MASK, info);
2138 /* Augment relocation base: increment image location counter by offset
2139 arg: lw offset value. */
2140 case ETIR__C_CTL_AUGRB:
2141 if (ptr + 4 >= maxptr)
2143 op1 = bfd_getl32 (ptr);
2144 image_inc_ptr (abfd, op1);
2147 /* Define location: pop index, save location counter under index
2149 case ETIR__C_CTL_DFLOC:
2150 _bfd_vms_pop (abfd, &op1, &rel1);
2151 if (rel1 != RELC_NONE)
2153 dst_define_location (abfd, op1);
2156 /* Set location: pop index, restore location counter from index
2158 case ETIR__C_CTL_STLOC:
2159 _bfd_vms_pop (abfd, &op1, &rel1);
2160 if (rel1 != RELC_NONE)
2162 dst_restore_location (abfd, op1);
2165 /* Stack defined location: pop index, push location counter from index
2167 case ETIR__C_CTL_STKDL:
2168 _bfd_vms_pop (abfd, &op1, &rel1);
2169 if (rel1 != RELC_NONE)
2171 _bfd_vms_push (abfd, dst_retrieve_location (abfd, op1), RELC_NONE);
2174 case ETIR__C_OPR_NOP: /* No-op. */
2177 case ETIR__C_OPR_ADD: /* Add. */
2178 _bfd_vms_pop (abfd, &op1, &rel1);
2179 _bfd_vms_pop (abfd, &op2, &rel2);
2180 if (rel1 == RELC_NONE && rel2 != RELC_NONE)
2182 else if (rel1 != RELC_NONE && rel2 != RELC_NONE)
2184 _bfd_vms_push (abfd, op1 + op2, rel1);
2187 case ETIR__C_OPR_SUB: /* Subtract. */
2188 _bfd_vms_pop (abfd, &op1, &rel1);
2189 _bfd_vms_pop (abfd, &op2, &rel2);
2190 if (rel1 == RELC_NONE && rel2 != RELC_NONE)
2192 else if ((rel1 & RELC_SEC_BASE) && (rel2 & RELC_SEC_BASE))
2194 op1 = alpha_vms_fix_sec_rel (abfd, info, rel1, op1);
2195 op2 = alpha_vms_fix_sec_rel (abfd, info, rel2, op2);
2198 else if (rel1 != RELC_NONE && rel2 != RELC_NONE)
2200 _bfd_vms_push (abfd, op2 - op1, rel1);
2203 case ETIR__C_OPR_MUL: /* Multiply. */
2204 _bfd_vms_pop (abfd, &op1, &rel1);
2205 _bfd_vms_pop (abfd, &op2, &rel2);
2206 if (rel1 != RELC_NONE || rel2 != RELC_NONE)
2208 _bfd_vms_push (abfd, op1 * op2, RELC_NONE);
2211 case ETIR__C_OPR_DIV: /* Divide. */
2212 _bfd_vms_pop (abfd, &op1, &rel1);
2213 _bfd_vms_pop (abfd, &op2, &rel2);
2214 if (rel1 != RELC_NONE || rel2 != RELC_NONE)
2217 _bfd_vms_push (abfd, 0, RELC_NONE);
2219 _bfd_vms_push (abfd, op2 / op1, RELC_NONE);
2222 case ETIR__C_OPR_AND: /* Logical AND. */
2223 _bfd_vms_pop (abfd, &op1, &rel1);
2224 _bfd_vms_pop (abfd, &op2, &rel2);
2225 if (rel1 != RELC_NONE || rel2 != RELC_NONE)
2227 _bfd_vms_push (abfd, op1 & op2, RELC_NONE);
2230 case ETIR__C_OPR_IOR: /* Logical inclusive OR. */
2231 _bfd_vms_pop (abfd, &op1, &rel1);
2232 _bfd_vms_pop (abfd, &op2, &rel2);
2233 if (rel1 != RELC_NONE || rel2 != RELC_NONE)
2235 _bfd_vms_push (abfd, op1 | op2, RELC_NONE);
2238 case ETIR__C_OPR_EOR: /* Logical exclusive OR. */
2239 _bfd_vms_pop (abfd, &op1, &rel1);
2240 _bfd_vms_pop (abfd, &op2, &rel2);
2241 if (rel1 != RELC_NONE || rel2 != RELC_NONE)
2243 _bfd_vms_push (abfd, op1 ^ op2, RELC_NONE);
2246 case ETIR__C_OPR_NEG: /* Negate. */
2247 _bfd_vms_pop (abfd, &op1, &rel1);
2248 if (rel1 != RELC_NONE)
2250 _bfd_vms_push (abfd, -op1, RELC_NONE);
2253 case ETIR__C_OPR_COM: /* Complement. */
2254 _bfd_vms_pop (abfd, &op1, &rel1);
2255 if (rel1 != RELC_NONE)
2257 _bfd_vms_push (abfd, ~op1, RELC_NONE);
2260 case ETIR__C_OPR_ASH: /* Arithmetic shift. */
2261 _bfd_vms_pop (abfd, &op1, &rel1);
2262 _bfd_vms_pop (abfd, &op2, &rel2);
2263 if (rel1 != RELC_NONE || rel2 != RELC_NONE)
2266 _bfd_error_handler (_("invalid use of %s with contexts"),
2267 _bfd_vms_etir_name (cmd));
2270 if ((int)op2 < 0) /* Shift right. */
2272 else /* Shift left. */
2274 _bfd_vms_push (abfd, op1, RELC_NONE); /* FIXME: sym. */
2277 case ETIR__C_OPR_INSV: /* Insert field. */
2278 case ETIR__C_OPR_USH: /* Unsigned shift. */
2279 case ETIR__C_OPR_ROT: /* Rotate. */
2280 case ETIR__C_OPR_REDEF: /* Redefine symbol to current location. */
2281 case ETIR__C_OPR_DFLIT: /* Define a literal. */
2282 _bfd_error_handler (_("%s: not supported"),
2283 _bfd_vms_etir_name (cmd));
2287 case ETIR__C_OPR_SEL: /* Select. */
2288 _bfd_vms_pop (abfd, &op1, &rel1);
2290 _bfd_vms_pop (abfd, &op1, &rel1);
2293 _bfd_vms_pop (abfd, &op1, &rel1);
2294 _bfd_vms_pop (abfd, &op2, &rel2);
2295 _bfd_vms_push (abfd, op1, rel1);
2300 _bfd_error_handler (_("reserved cmd %d"), cmd);
2305 ptr += cmd_length - 4;
2311 /* Process EDBG/ETBT record.
2312 Return TRUE on success, FALSE on error */
2315 vms_slurp_debug (bfd *abfd)
2317 asection *section = PRIV (dst_section);
2319 if (section == NULL)
2321 /* We have no way to find out beforehand how much debug info there
2322 is in an object file, so pick an initial amount and grow it as
2324 flagword flags = SEC_HAS_CONTENTS | SEC_DEBUGGING | SEC_RELOC
2327 section = bfd_make_section (abfd, "$DST$");
2330 if (!bfd_set_section_flags (abfd, section, flags))
2332 PRIV (dst_section) = section;
2335 PRIV (image_section) = section;
2336 PRIV (image_offset) = section->size;
2338 if (!_bfd_vms_slurp_etir (abfd, NULL))
2341 section->size = PRIV (image_offset);
2345 /* Process EDBG record.
2346 Return TRUE on success, FALSE on error. */
2349 _bfd_vms_slurp_edbg (bfd *abfd)
2351 vms_debug2 ((2, "EDBG\n"));
2353 abfd->flags |= HAS_DEBUG | HAS_LINENO;
2355 return vms_slurp_debug (abfd);
2358 /* Process ETBT record.
2359 Return TRUE on success, FALSE on error. */
2362 _bfd_vms_slurp_etbt (bfd *abfd)
2364 vms_debug2 ((2, "ETBT\n"));
2366 abfd->flags |= HAS_LINENO;
2368 return vms_slurp_debug (abfd);
2371 /* Process EEOM record.
2372 Return TRUE on success, FALSE on error. */
2375 _bfd_vms_slurp_eeom (bfd *abfd)
2377 struct vms_eeom *eeom = (struct vms_eeom *) PRIV (recrd.rec);
2379 vms_debug2 ((2, "EEOM\n"));
2381 PRIV (eom_data).eom_l_total_lps = bfd_getl32 (eeom->total_lps);
2382 PRIV (eom_data).eom_w_comcod = bfd_getl16 (eeom->comcod);
2383 if (PRIV (eom_data).eom_w_comcod > 1)
2385 _bfd_error_handler (_("Object module NOT error-free !\n"));
2386 bfd_set_error (bfd_error_bad_value);
2390 PRIV (eom_data).eom_has_transfer = FALSE;
2391 if (PRIV (recrd.rec_size) > 10)
2393 PRIV (eom_data).eom_has_transfer = TRUE;
2394 PRIV (eom_data).eom_b_tfrflg = eeom->tfrflg;
2395 PRIV (eom_data).eom_l_psindx = bfd_getl32 (eeom->psindx);
2396 PRIV (eom_data).eom_l_tfradr = bfd_getl32 (eeom->tfradr);
2398 abfd->start_address = PRIV (eom_data).eom_l_tfradr;
2403 /* Slurp an ordered set of VMS object records. Return FALSE on error. */
2406 _bfd_vms_slurp_object_records (bfd * abfd)
2413 vms_debug2 ((7, "reading at %08lx\n", (unsigned long)bfd_tell (abfd)));
2415 type = _bfd_vms_get_object_record (abfd);
2418 vms_debug2 ((2, "next_record failed\n"));
2425 err = _bfd_vms_slurp_ehdr (abfd);
2428 err = _bfd_vms_slurp_eeom (abfd);
2431 err = _bfd_vms_slurp_egsd (abfd);
2434 err = TRUE; /* _bfd_vms_slurp_etir (abfd); */
2437 err = _bfd_vms_slurp_edbg (abfd);
2440 err = _bfd_vms_slurp_etbt (abfd);
2447 vms_debug2 ((2, "slurp type %d failed\n", type));
2451 while (type != EOBJ__C_EEOM);
2456 /* Initialize private data */
2458 vms_initialize (bfd * abfd)
2462 amt = sizeof (struct vms_private_data_struct);
2463 abfd->tdata.any = bfd_zalloc (abfd, amt);
2464 if (abfd->tdata.any == NULL)
2467 PRIV (recrd.file_format) = FF_UNKNOWN;
2469 amt = sizeof (struct stack_struct) * STACKSIZE;
2470 PRIV (stack) = bfd_alloc (abfd, amt);
2471 if (PRIV (stack) == NULL)
2477 bfd_release (abfd, abfd->tdata.any);
2478 abfd->tdata.any = NULL;
2482 /* Check the format for a file being read.
2483 Return a (bfd_target *) if it's an object file or zero if not. */
2485 static const struct bfd_target *
2486 alpha_vms_object_p (bfd *abfd)
2488 void *tdata_save = abfd->tdata.any;
2489 unsigned int test_len;
2492 vms_debug2 ((1, "vms_object_p(%p)\n", abfd));
2494 /* Allocate alpha-vms specific data. */
2495 if (!vms_initialize (abfd))
2498 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET))
2499 goto err_wrong_format;
2501 /* The first challenge with VMS is to discover the kind of the file.
2503 Image files (executable or shared images) are stored as a raw
2504 stream of bytes (like on UNIX), but there is no magic number.
2506 Object files are written with RMS (record management service), ie
2507 each records are preceeded by its length (on a word - 2 bytes), and
2508 padded for word-alignment. That would be simple but when files
2509 are transfered to a UNIX filesystem (using ftp), records are lost.
2510 Only the raw content of the records are transfered. Fortunately,
2511 the Alpha Object file format also store the length of the record
2512 in the records. Is that clear ? */
2514 /* Minimum is 6 bytes for objects (2 bytes size, 2 bytes record id,
2515 2 bytes size repeated) and 12 bytes for images (4 bytes major id,
2516 4 bytes minor id, 4 bytes length). */
2519 /* Size the main buffer. */
2520 buf = (unsigned char *) bfd_malloc (test_len);
2523 PRIV (recrd.buf) = buf;
2524 PRIV (recrd.buf_size) = test_len;
2526 /* Initialize the record pointer. */
2527 PRIV (recrd.rec) = buf;
2529 if (bfd_bread (buf, test_len, abfd) != test_len)
2530 goto err_wrong_format;
2532 /* Is it an image? */
2533 if ((bfd_getl32 (buf) == EIHD__K_MAJORID)
2534 && (bfd_getl32 (buf + 4) == EIHD__K_MINORID))
2536 unsigned int to_read;
2537 unsigned int read_so_far;
2538 unsigned int remaining;
2539 unsigned int eisd_offset, eihs_offset;
2541 /* Extract the header size. */
2542 PRIV (recrd.rec_size) = bfd_getl32 (buf + EIHD__L_SIZE);
2544 /* The header size is 0 for DSF files. */
2545 if (PRIV (recrd.rec_size) == 0)
2546 PRIV (recrd.rec_size) = sizeof (struct vms_eihd);
2548 if (PRIV (recrd.rec_size) > PRIV (recrd.buf_size))
2550 buf = bfd_realloc_or_free (buf, PRIV (recrd.rec_size));
2554 PRIV (recrd.buf) = NULL;
2557 PRIV (recrd.buf) = buf;
2558 PRIV (recrd.buf_size) = PRIV (recrd.rec_size);
2561 /* Read the remaining record. */
2562 remaining = PRIV (recrd.rec_size) - test_len;
2563 to_read = MIN (VMS_BLOCK_SIZE - test_len, remaining);
2564 read_so_far = test_len;
2566 while (remaining > 0)
2568 if (bfd_bread (buf + read_so_far, to_read, abfd) != to_read)
2569 goto err_wrong_format;
2571 read_so_far += to_read;
2572 remaining -= to_read;
2574 to_read = MIN (VMS_BLOCK_SIZE, remaining);
2577 /* Reset the record pointer. */
2578 PRIV (recrd.rec) = buf;
2580 /* PR 17512: file: 7d7c57c2. */
2581 if (PRIV (recrd.rec_size) < sizeof (struct vms_eihd))
2583 vms_debug2 ((2, "file type is image\n"));
2585 if (!_bfd_vms_slurp_eihd (abfd, &eisd_offset, &eihs_offset))
2586 goto err_wrong_format;
2588 if (!_bfd_vms_slurp_eisd (abfd, eisd_offset))
2589 goto err_wrong_format;
2591 /* EIHS is optional. */
2592 if (eihs_offset != 0 && !_bfd_vms_slurp_eihs (abfd, eihs_offset))
2593 goto err_wrong_format;
2599 /* Assume it's a module and adjust record pointer if necessary. */
2600 maybe_adjust_record_pointer_for_object (abfd);
2602 /* But is it really a module? */
2603 if (bfd_getl16 (PRIV (recrd.rec)) <= EOBJ__C_MAXRECTYP
2604 && bfd_getl16 (PRIV (recrd.rec) + 2) <= EOBJ__C_MAXRECSIZ)
2606 if (vms_get_remaining_object_record (abfd, test_len) <= 0)
2607 goto err_wrong_format;
2609 vms_debug2 ((2, "file type is module\n"));
2611 type = bfd_getl16 (PRIV (recrd.rec));
2612 if (type != EOBJ__C_EMH || !_bfd_vms_slurp_ehdr (abfd))
2613 goto err_wrong_format;
2615 if (!_bfd_vms_slurp_object_records (abfd))
2616 goto err_wrong_format;
2619 goto err_wrong_format;
2622 /* Set arch_info to alpha. */
2624 if (! bfd_default_set_arch_mach (abfd, bfd_arch_alpha, 0))
2625 goto err_wrong_format;
2630 bfd_set_error (bfd_error_wrong_format);
2633 if (PRIV (recrd.buf))
2634 free (PRIV (recrd.buf));
2635 if (abfd->tdata.any != tdata_save && abfd->tdata.any != NULL)
2636 bfd_release (abfd, abfd->tdata.any);
2637 abfd->tdata.any = tdata_save;
2643 /* Write an EMH/MHD record. */
2646 _bfd_vms_write_emh (bfd *abfd)
2648 struct vms_rec_wr *recwr = &PRIV (recwr);
2650 _bfd_vms_output_alignment (recwr, 2);
2653 _bfd_vms_output_begin (recwr, EOBJ__C_EMH);
2654 _bfd_vms_output_short (recwr, EMH__C_MHD);
2655 _bfd_vms_output_short (recwr, EOBJ__C_STRLVL);
2656 _bfd_vms_output_long (recwr, 0);
2657 _bfd_vms_output_long (recwr, 0);
2658 _bfd_vms_output_long (recwr, MAX_OUTREC_SIZE);
2660 /* Create module name from filename. */
2661 if (bfd_get_filename (abfd) != 0)
2663 char *module = vms_get_module_name (bfd_get_filename (abfd), TRUE);
2664 _bfd_vms_output_counted (recwr, module);
2668 _bfd_vms_output_counted (recwr, "NONAME");
2670 _bfd_vms_output_counted (recwr, BFD_VERSION_STRING);
2671 _bfd_vms_output_dump (recwr, get_vms_time_string (), EMH_DATE_LENGTH);
2672 _bfd_vms_output_fill (recwr, 0, EMH_DATE_LENGTH);
2673 _bfd_vms_output_end (abfd, recwr);
2676 /* Write an EMH/LMN record. */
2679 _bfd_vms_write_lmn (bfd *abfd, const char *name)
2682 struct vms_rec_wr *recwr = &PRIV (recwr);
2683 unsigned int ver = BFD_VERSION / 10000;
2686 _bfd_vms_output_begin (recwr, EOBJ__C_EMH);
2687 _bfd_vms_output_short (recwr, EMH__C_LNM);
2688 snprintf (version, sizeof (version), "%s %d.%d.%d", name,
2689 ver / 10000, (ver / 100) % 100, ver % 100);
2690 _bfd_vms_output_dump (recwr, (unsigned char *)version, strlen (version));
2691 _bfd_vms_output_end (abfd, recwr);
2695 /* Write eom record for bfd abfd. Return FALSE on error. */
2698 _bfd_vms_write_eeom (bfd *abfd)
2700 struct vms_rec_wr *recwr = &PRIV (recwr);
2702 vms_debug2 ((2, "vms_write_eeom\n"));
2704 _bfd_vms_output_alignment (recwr, 2);
2706 _bfd_vms_output_begin (recwr, EOBJ__C_EEOM);
2707 _bfd_vms_output_long (recwr, PRIV (vms_linkage_index + 1) >> 1);
2708 _bfd_vms_output_byte (recwr, 0); /* Completion code. */
2709 _bfd_vms_output_byte (recwr, 0); /* Fill byte. */
2711 if ((abfd->flags & EXEC_P) == 0
2712 && bfd_get_start_address (abfd) != (bfd_vma)-1)
2716 section = bfd_get_section_by_name (abfd, ".link");
2719 bfd_set_error (bfd_error_nonrepresentable_section);
2722 _bfd_vms_output_short (recwr, 0);
2723 _bfd_vms_output_long (recwr, (unsigned long) section->target_index);
2724 _bfd_vms_output_long (recwr,
2725 (unsigned long) bfd_get_start_address (abfd));
2726 _bfd_vms_output_long (recwr, 0);
2729 _bfd_vms_output_end (abfd, recwr);
2734 vector_grow1 (struct vector_type *vec, size_t elsz)
2736 if (vec->nbr_el + 1 < vec->max_el)
2739 if (vec->max_el == 0)
2742 vec->els = bfd_malloc2 (vec->max_el, elsz);
2747 vec->els = bfd_realloc2 (vec->els, vec->max_el, elsz);
2751 /* Bump ABFD file position to next block. */
2754 alpha_vms_file_position_block (bfd *abfd)
2757 PRIV (file_pos) += VMS_BLOCK_SIZE - 1;
2758 PRIV (file_pos) -= (PRIV (file_pos) % VMS_BLOCK_SIZE);
2761 /* Convert from internal structure SRC to external structure DST. */
2764 alpha_vms_swap_eisd_out (struct vms_internal_eisd_map *src,
2765 struct vms_eisd *dst)
2767 bfd_putl32 (src->u.eisd.majorid, dst->majorid);
2768 bfd_putl32 (src->u.eisd.minorid, dst->minorid);
2769 bfd_putl32 (src->u.eisd.eisdsize, dst->eisdsize);
2770 if (src->u.eisd.eisdsize <= EISD__K_LENEND)
2772 bfd_putl32 (src->u.eisd.secsize, dst->secsize);
2773 bfd_putl64 (src->u.eisd.virt_addr, dst->virt_addr);
2774 bfd_putl32 (src->u.eisd.flags, dst->flags);
2775 bfd_putl32 (src->u.eisd.vbn, dst->vbn);
2776 dst->pfc = src->u.eisd.pfc;
2777 dst->matchctl = src->u.eisd.matchctl;
2778 dst->type = src->u.eisd.type;
2780 if (src->u.eisd.flags & EISD__M_GBL)
2782 bfd_putl32 (src->u.gbl_eisd.ident, dst->ident);
2783 memcpy (dst->gblnam, src->u.gbl_eisd.gblnam,
2784 src->u.gbl_eisd.gblnam[0] + 1);
2788 /* Append EISD to the list of extra eisd for ABFD. */
2791 alpha_vms_append_extra_eisd (bfd *abfd, struct vms_internal_eisd_map *eisd)
2794 if (PRIV (gbl_eisd_head) == NULL)
2795 PRIV (gbl_eisd_head) = eisd;
2797 PRIV (gbl_eisd_tail)->next = eisd;
2798 PRIV (gbl_eisd_tail) = eisd;
2801 /* Create an EISD for shared image SHRIMG.
2802 Return FALSE in case of error. */
2805 alpha_vms_create_eisd_for_shared (bfd *abfd, bfd *shrimg)
2807 struct vms_internal_eisd_map *eisd;
2810 namlen = strlen (PRIV2 (shrimg, hdr_data.hdr_t_name));
2811 if (namlen + 5 > EISD__K_GBLNAMLEN)
2817 eisd = bfd_alloc (abfd, sizeof (*eisd));
2821 /* Fill the fields. */
2822 eisd->u.gbl_eisd.common.majorid = EISD__K_MAJORID;
2823 eisd->u.gbl_eisd.common.minorid = EISD__K_MINORID;
2824 eisd->u.gbl_eisd.common.eisdsize = (EISD__K_LEN + 4 + namlen + 5 + 3) & ~3;
2825 eisd->u.gbl_eisd.common.secsize = VMS_BLOCK_SIZE; /* Must not be 0. */
2826 eisd->u.gbl_eisd.common.virt_addr = 0;
2827 eisd->u.gbl_eisd.common.flags = EISD__M_GBL;
2828 eisd->u.gbl_eisd.common.vbn = 0;
2829 eisd->u.gbl_eisd.common.pfc = 0;
2830 eisd->u.gbl_eisd.common.matchctl = PRIV2 (shrimg, matchctl);
2831 eisd->u.gbl_eisd.common.type = EISD__K_SHRPIC;
2833 eisd->u.gbl_eisd.ident = PRIV2 (shrimg, ident);
2834 eisd->u.gbl_eisd.gblnam[0] = namlen + 4;
2835 memcpy (eisd->u.gbl_eisd.gblnam + 1, PRIV2 (shrimg, hdr_data.hdr_t_name),
2837 memcpy (eisd->u.gbl_eisd.gblnam + 1 + namlen, "_001", 4);
2839 /* Append it to the list. */
2840 alpha_vms_append_extra_eisd (abfd, eisd);
2845 /* Create an EISD for section SEC.
2846 Return FALSE in case of failure. */
2849 alpha_vms_create_eisd_for_section (bfd *abfd, asection *sec)
2851 struct vms_internal_eisd_map *eisd;
2853 /* Only for allocating section. */
2854 if (!(sec->flags & SEC_ALLOC))
2857 BFD_ASSERT (vms_section_data (sec)->eisd == NULL);
2858 eisd = bfd_alloc (abfd, sizeof (*eisd));
2861 vms_section_data (sec)->eisd = eisd;
2863 /* Fill the fields. */
2864 eisd->u.eisd.majorid = EISD__K_MAJORID;
2865 eisd->u.eisd.minorid = EISD__K_MINORID;
2866 eisd->u.eisd.eisdsize = EISD__K_LEN;
2867 eisd->u.eisd.secsize =
2868 (sec->size + VMS_BLOCK_SIZE - 1) & ~(VMS_BLOCK_SIZE - 1);
2869 eisd->u.eisd.virt_addr = sec->vma;
2870 eisd->u.eisd.flags = 0;
2871 eisd->u.eisd.vbn = 0; /* To be later defined. */
2872 eisd->u.eisd.pfc = 0; /* Default. */
2873 eisd->u.eisd.matchctl = EISD__K_MATALL;
2874 eisd->u.eisd.type = EISD__K_NORMAL;
2876 if (sec->flags & SEC_CODE)
2877 eisd->u.eisd.flags |= EISD__M_EXE;
2878 if (!(sec->flags & SEC_READONLY))
2879 eisd->u.eisd.flags |= EISD__M_WRT | EISD__M_CRF;
2881 /* If relocations or fixup will be applied, make this isect writeable. */
2882 if (sec->flags & SEC_RELOC)
2883 eisd->u.eisd.flags |= EISD__M_WRT | EISD__M_CRF;
2885 if (!(sec->flags & SEC_HAS_CONTENTS))
2887 eisd->u.eisd.flags |= EISD__M_DZRO;
2888 eisd->u.eisd.flags &= ~EISD__M_CRF;
2890 if (sec->flags & SEC_LINKER_CREATED)
2892 if (strcmp (sec->name, "$FIXUP$") == 0)
2893 eisd->u.eisd.flags |= EISD__M_FIXUPVEC;
2896 /* Append it to the list. */
2898 if (PRIV (eisd_head) == NULL)
2899 PRIV (eisd_head) = eisd;
2901 PRIV (eisd_tail)->next = eisd;
2902 PRIV (eisd_tail) = eisd;
2907 /* Layout executable ABFD and write it to the disk.
2908 Return FALSE in case of failure. */
2911 alpha_vms_write_exec (bfd *abfd)
2913 struct vms_eihd eihd;
2914 struct vms_eiha *eiha;
2915 struct vms_eihi *eihi;
2916 struct vms_eihs *eihs = NULL;
2918 struct vms_internal_eisd_map *first_eisd;
2919 struct vms_internal_eisd_map *eisd;
2922 file_ptr gst_filepos = 0;
2923 unsigned int lnkflags = 0;
2925 /* Build the EIHD. */
2926 PRIV (file_pos) = EIHD__C_LENGTH;
2928 memset (&eihd, 0, sizeof (eihd));
2929 memset (eihd.fill_2, 0xff, sizeof (eihd.fill_2));
2931 bfd_putl32 (EIHD__K_MAJORID, eihd.majorid);
2932 bfd_putl32 (EIHD__K_MINORID, eihd.minorid);
2934 bfd_putl32 (sizeof (eihd), eihd.size);
2935 bfd_putl32 (0, eihd.isdoff);
2936 bfd_putl32 (0, eihd.activoff);
2937 bfd_putl32 (0, eihd.symdbgoff);
2938 bfd_putl32 (0, eihd.imgidoff);
2939 bfd_putl32 (0, eihd.patchoff);
2940 bfd_putl64 (0, eihd.iafva);
2941 bfd_putl32 (0, eihd.version_array_off);
2943 bfd_putl32 (EIHD__K_EXE, eihd.imgtype);
2944 bfd_putl32 (0, eihd.subtype);
2946 bfd_putl32 (0, eihd.imgiocnt);
2947 bfd_putl32 (-1, eihd.privreqs);
2948 bfd_putl32 (-1, eihd.privreqs + 4);
2950 bfd_putl32 ((sizeof (eihd) + VMS_BLOCK_SIZE - 1) / VMS_BLOCK_SIZE,
2952 bfd_putl32 (0, eihd.ident);
2953 bfd_putl32 (0, eihd.sysver);
2956 bfd_putl32 (0, eihd.symvect_size);
2957 bfd_putl32 (16, eihd.virt_mem_block_size);
2958 bfd_putl32 (0, eihd.ext_fixup_off);
2959 bfd_putl32 (0, eihd.noopt_psect_off);
2960 bfd_putl32 (-1, eihd.alias);
2963 eiha = (struct vms_eiha *)((char *) &eihd + PRIV (file_pos));
2964 bfd_putl32 (PRIV (file_pos), eihd.activoff);
2965 PRIV (file_pos) += sizeof (struct vms_eiha);
2967 bfd_putl32 (sizeof (struct vms_eiha), eiha->size);
2968 bfd_putl32 (0, eiha->spare);
2969 bfd_putl64 (PRIV (transfer_address[0]), eiha->tfradr1);
2970 bfd_putl64 (PRIV (transfer_address[1]), eiha->tfradr2);
2971 bfd_putl64 (PRIV (transfer_address[2]), eiha->tfradr3);
2972 bfd_putl64 (PRIV (transfer_address[3]), eiha->tfradr4);
2973 bfd_putl64 (0, eiha->inishr);
2976 eihi = (struct vms_eihi *)((char *) &eihd + PRIV (file_pos));
2977 bfd_putl32 (PRIV (file_pos), eihd.imgidoff);
2978 PRIV (file_pos) += sizeof (struct vms_eihi);
2980 bfd_putl32 (EIHI__K_MAJORID, eihi->majorid);
2981 bfd_putl32 (EIHI__K_MINORID, eihi->minorid);
2986 /* Set module name. */
2987 module = vms_get_module_name (bfd_get_filename (abfd), TRUE);
2988 len = strlen (module);
2989 if (len > sizeof (eihi->imgnam) - 1)
2990 len = sizeof (eihi->imgnam) - 1;
2991 eihi->imgnam[0] = len;
2992 memcpy (eihi->imgnam + 1, module, len);
3000 vms_get_time (&hi, &lo);
3001 bfd_putl32 (lo, eihi->linktime + 0);
3002 bfd_putl32 (hi, eihi->linktime + 4);
3005 eihi->linkid[0] = 0;
3006 eihi->imgbid[0] = 0;
3009 dst = PRIV (dst_section);
3010 dmt = bfd_get_section_by_name (abfd, "$DMT$");
3011 if (dst != NULL && dst->size != 0)
3013 eihs = (struct vms_eihs *)((char *) &eihd + PRIV (file_pos));
3014 bfd_putl32 (PRIV (file_pos), eihd.symdbgoff);
3015 PRIV (file_pos) += sizeof (struct vms_eihs);
3017 bfd_putl32 (EIHS__K_MAJORID, eihs->majorid);
3018 bfd_putl32 (EIHS__K_MINORID, eihs->minorid);
3019 bfd_putl32 (0, eihs->dstvbn);
3020 bfd_putl32 (0, eihs->dstsize);
3021 bfd_putl32 (0, eihs->gstvbn);
3022 bfd_putl32 (0, eihs->gstsize);
3023 bfd_putl32 (0, eihs->dmtvbn);
3024 bfd_putl32 (0, eihs->dmtsize);
3027 /* One EISD per section. */
3028 for (sec = abfd->sections; sec; sec = sec->next)
3030 if (!alpha_vms_create_eisd_for_section (abfd, sec))
3034 /* Merge section EIDS which extra ones. */
3035 if (PRIV (eisd_tail))
3036 PRIV (eisd_tail)->next = PRIV (gbl_eisd_head);
3038 PRIV (eisd_head) = PRIV (gbl_eisd_head);
3039 if (PRIV (gbl_eisd_tail))
3040 PRIV (eisd_tail) = PRIV (gbl_eisd_tail);
3042 first_eisd = PRIV (eisd_head);
3044 /* Add end of eisd. */
3047 eisd = bfd_zalloc (abfd, sizeof (*eisd));
3050 eisd->u.eisd.majorid = 0;
3051 eisd->u.eisd.minorid = 0;
3052 eisd->u.eisd.eisdsize = 0;
3053 alpha_vms_append_extra_eisd (abfd, eisd);
3056 /* Place EISD in the file. */
3057 for (eisd = first_eisd; eisd; eisd = eisd->next)
3059 file_ptr room = VMS_BLOCK_SIZE - (PRIV (file_pos) % VMS_BLOCK_SIZE);
3061 /* First block is a little bit special: there is a word at the end. */
3062 if (PRIV (file_pos) < VMS_BLOCK_SIZE && room > 2)
3064 if (room < eisd->u.eisd.eisdsize + EISD__K_LENEND)
3065 alpha_vms_file_position_block (abfd);
3067 eisd->file_pos = PRIV (file_pos);
3068 PRIV (file_pos) += eisd->u.eisd.eisdsize;
3070 if (eisd->u.eisd.flags & EISD__M_FIXUPVEC)
3071 bfd_putl64 (eisd->u.eisd.virt_addr, eihd.iafva);
3074 if (first_eisd != NULL)
3076 bfd_putl32 (first_eisd->file_pos, eihd.isdoff);
3077 /* Real size of end of eisd marker. */
3078 PRIV (file_pos) += EISD__K_LENEND;
3081 bfd_putl32 (PRIV (file_pos), eihd.size);
3082 bfd_putl32 ((PRIV (file_pos) + VMS_BLOCK_SIZE - 1) / VMS_BLOCK_SIZE,
3085 /* Place sections. */
3086 for (sec = abfd->sections; sec; sec = sec->next)
3088 if (!(sec->flags & SEC_HAS_CONTENTS))
3091 eisd = vms_section_data (sec)->eisd;
3093 /* Align on a block. */
3094 alpha_vms_file_position_block (abfd);
3095 sec->filepos = PRIV (file_pos);
3098 eisd->u.eisd.vbn = (sec->filepos / VMS_BLOCK_SIZE) + 1;
3100 PRIV (file_pos) += sec->size;
3104 if (eihs != NULL && dst != NULL)
3106 bfd_putl32 ((dst->filepos / VMS_BLOCK_SIZE) + 1, eihs->dstvbn);
3107 bfd_putl32 (dst->size, eihs->dstsize);
3111 lnkflags |= EIHD__M_DBGDMT;
3112 bfd_putl32 ((dmt->filepos / VMS_BLOCK_SIZE) + 1, eihs->dmtvbn);
3113 bfd_putl32 (dmt->size, eihs->dmtsize);
3115 if (PRIV (gsd_sym_count) != 0)
3117 alpha_vms_file_position_block (abfd);
3118 gst_filepos = PRIV (file_pos);
3119 bfd_putl32 ((gst_filepos / VMS_BLOCK_SIZE) + 1, eihs->gstvbn);
3120 bfd_putl32 ((PRIV (gsd_sym_count) + 4) / 5 + 4, eihs->gstsize);
3124 /* Write EISD in hdr. */
3125 for (eisd = first_eisd; eisd && eisd->file_pos < VMS_BLOCK_SIZE;
3127 alpha_vms_swap_eisd_out
3128 (eisd, (struct vms_eisd *)((char *)&eihd + eisd->file_pos));
3130 /* Write first block. */
3131 bfd_putl32 (lnkflags, eihd.lnkflags);
3132 if (bfd_bwrite (&eihd, sizeof (eihd), abfd) != sizeof (eihd))
3135 /* Write remaining eisd. */
3138 unsigned char blk[VMS_BLOCK_SIZE];
3139 struct vms_internal_eisd_map *next_eisd;
3141 memset (blk, 0xff, sizeof (blk));
3142 while (eisd != NULL)
3144 alpha_vms_swap_eisd_out
3146 (struct vms_eisd *)(blk + (eisd->file_pos % VMS_BLOCK_SIZE)));
3148 next_eisd = eisd->next;
3149 if (next_eisd == NULL
3150 || (next_eisd->file_pos / VMS_BLOCK_SIZE
3151 != eisd->file_pos / VMS_BLOCK_SIZE))
3153 if (bfd_bwrite (blk, sizeof (blk), abfd) != sizeof (blk))
3156 memset (blk, 0xff, sizeof (blk));
3162 /* Write sections. */
3163 for (sec = abfd->sections; sec; sec = sec->next)
3165 unsigned char blk[VMS_BLOCK_SIZE];
3168 if (sec->size == 0 || !(sec->flags & SEC_HAS_CONTENTS))
3170 if (bfd_bwrite (sec->contents, sec->size, abfd) != sec->size)
3174 len = VMS_BLOCK_SIZE - sec->size % VMS_BLOCK_SIZE;
3175 if (len != VMS_BLOCK_SIZE)
3177 memset (blk, 0, len);
3178 if (bfd_bwrite (blk, len, abfd) != len)
3184 if (gst_filepos != 0)
3186 struct vms_rec_wr *recwr = &PRIV (recwr);
3189 _bfd_vms_write_emh (abfd);
3190 _bfd_vms_write_lmn (abfd, "GNU LD");
3192 /* PSC for the absolute section. */
3193 _bfd_vms_output_begin (recwr, EOBJ__C_EGSD);
3194 _bfd_vms_output_long (recwr, 0);
3195 _bfd_vms_output_begin_subrec (recwr, EGSD__C_PSC);
3196 _bfd_vms_output_short (recwr, 0);
3197 _bfd_vms_output_short (recwr, EGPS__V_PIC | EGPS__V_LIB | EGPS__V_RD);
3198 _bfd_vms_output_long (recwr, 0);
3199 _bfd_vms_output_counted (recwr, ".$$ABS$$.");
3200 _bfd_vms_output_end_subrec (recwr);
3201 _bfd_vms_output_end (abfd, recwr);
3203 for (i = 0; i < PRIV (gsd_sym_count); i++)
3205 struct vms_symbol_entry *sym = PRIV (syms)[i];
3211 _bfd_vms_output_alignment (recwr, 8);
3212 _bfd_vms_output_begin (recwr, EOBJ__C_EGSD);
3213 _bfd_vms_output_long (recwr, 0);
3215 _bfd_vms_output_begin_subrec (recwr, EGSD__C_SYMG);
3216 _bfd_vms_output_short (recwr, 0); /* Data type, alignment. */
3217 _bfd_vms_output_short (recwr, sym->flags);
3219 if (sym->code_section)
3220 ep = alpha_vms_get_sym_value (sym->code_section, sym->code_value);
3223 BFD_ASSERT (sym->code_value == 0);
3226 val = alpha_vms_get_sym_value (sym->section, sym->value);
3227 _bfd_vms_output_quad
3228 (recwr, sym->typ == EGSD__C_SYMG ? sym->symbol_vector : val);
3229 _bfd_vms_output_quad (recwr, ep);
3230 _bfd_vms_output_quad (recwr, val);
3231 _bfd_vms_output_long (recwr, 0);
3232 _bfd_vms_output_counted (recwr, sym->name);
3233 _bfd_vms_output_end_subrec (recwr);
3235 _bfd_vms_output_end (abfd, recwr);
3238 _bfd_vms_output_end (abfd, recwr);
3240 if (!_bfd_vms_write_eeom (abfd))
3248 /* Write section and symbol directory of bfd abfd. Return FALSE on error. */
3251 _bfd_vms_write_egsd (bfd *abfd)
3255 unsigned int symnum;
3257 flagword new_flags, old_flags;
3258 int abs_section_index = -1;
3259 unsigned int target_index = 0;
3260 struct vms_rec_wr *recwr = &PRIV (recwr);
3262 vms_debug2 ((2, "vms_write_egsd\n"));
3264 /* Egsd is quadword aligned. */
3265 _bfd_vms_output_alignment (recwr, 8);
3267 _bfd_vms_output_begin (recwr, EOBJ__C_EGSD);
3268 _bfd_vms_output_long (recwr, 0);
3270 /* Number sections. */
3271 for (section = abfd->sections; section != NULL; section = section->next)
3273 if (section->flags & SEC_DEBUGGING)
3275 if (!strcmp (section->name, ".vmsdebug"))
3277 section->flags |= SEC_DEBUGGING;
3280 section->target_index = target_index++;
3283 for (section = abfd->sections; section != NULL; section = section->next)
3285 vms_debug2 ((3, "Section #%d %s, %d bytes\n",
3286 section->target_index, section->name, (int)section->size));
3288 /* Don't write out the VMS debug info section since it is in the
3289 ETBT and EDBG sections in etir. */
3290 if (section->flags & SEC_DEBUGGING)
3293 /* 13 bytes egsd, max 31 chars name -> should be 44 bytes. */
3294 if (_bfd_vms_output_check (recwr, 64) < 0)
3296 _bfd_vms_output_end (abfd, recwr);
3297 _bfd_vms_output_begin (recwr, EOBJ__C_EGSD);
3298 _bfd_vms_output_long (recwr, 0);
3301 /* Don't know if this is necessary for the linker but for now it keeps
3302 vms_slurp_gsd happy. */
3303 sname = section->name;
3306 /* Remove leading dot. */
3308 if ((*sname == 't') && (strcmp (sname, "text") == 0))
3309 sname = EVAX_CODE_NAME;
3310 else if ((*sname == 'd') && (strcmp (sname, "data") == 0))
3311 sname = EVAX_DATA_NAME;
3312 else if ((*sname == 'b') && (strcmp (sname, "bss") == 0))
3313 sname = EVAX_BSS_NAME;
3314 else if ((*sname == 'l') && (strcmp (sname, "link") == 0))
3315 sname = EVAX_LINK_NAME;
3316 else if ((*sname == 'r') && (strcmp (sname, "rdata") == 0))
3317 sname = EVAX_READONLY_NAME;
3318 else if ((*sname == 'l') && (strcmp (sname, "literal") == 0))
3319 sname = EVAX_LITERAL_NAME;
3320 else if ((*sname == 'l') && (strcmp (sname, "literals") == 0))
3321 sname = EVAX_LITERALS_NAME;
3322 else if ((*sname == 'c') && (strcmp (sname, "comm") == 0))
3323 sname = EVAX_COMMON_NAME;
3324 else if ((*sname == 'l') && (strcmp (sname, "lcomm") == 0))
3325 sname = EVAX_LOCAL_NAME;
3328 if (bfd_is_com_section (section))
3329 new_flags = (EGPS__V_OVR | EGPS__V_REL | EGPS__V_GBL | EGPS__V_RD
3330 | EGPS__V_WRT | EGPS__V_NOMOD | EGPS__V_COM);
3332 new_flags = vms_esecflag_by_name (evax_section_flags, sname,
3335 /* Modify them as directed. */
3336 if (section->flags & SEC_READONLY)
3337 new_flags &= ~EGPS__V_WRT;
3339 new_flags &= ~vms_section_data (section)->no_flags;
3340 new_flags |= vms_section_data (section)->flags;
3342 vms_debug2 ((3, "sec flags %x\n", section->flags));
3343 vms_debug2 ((3, "new_flags %x, _raw_size %lu\n",
3344 new_flags, (unsigned long)section->size));
3346 _bfd_vms_output_begin_subrec (recwr, EGSD__C_PSC);
3347 _bfd_vms_output_short (recwr, section->alignment_power & 0xff);
3348 _bfd_vms_output_short (recwr, new_flags);
3349 _bfd_vms_output_long (recwr, (unsigned long) section->size);
3350 _bfd_vms_output_counted (recwr, sname);
3351 _bfd_vms_output_end_subrec (recwr);
3353 /* If the section is an obsolute one, remind its index as it will be
3354 used later for absolute symbols. */
3355 if ((new_flags & EGPS__V_REL) == 0 && abs_section_index < 0)
3356 abs_section_index = section->target_index;
3359 /* Output symbols. */
3360 vms_debug2 ((3, "%d symbols found\n", abfd->symcount));
3362 bfd_set_start_address (abfd, (bfd_vma) -1);
3364 for (symnum = 0; symnum < abfd->symcount; symnum++)
3366 symbol = abfd->outsymbols[symnum];
3367 old_flags = symbol->flags;
3369 /* Work-around a missing feature: consider __main as the main entry
3371 if (symbol->name[0] == '_' && strcmp (symbol->name, "__main") == 0)
3372 bfd_set_start_address (abfd, (bfd_vma)symbol->value);
3374 /* Only put in the GSD the global and the undefined symbols. */
3375 if (old_flags & BSF_FILE)
3378 if ((old_flags & BSF_GLOBAL) == 0 && !bfd_is_und_section (symbol->section))
3380 /* If the LIB$INITIIALIZE section is present, add a reference to
3381 LIB$INITIALIZE symbol. FIXME: this should be done explicitely
3382 in the assembly file. */
3383 if (!((old_flags & BSF_SECTION_SYM) != 0
3384 && strcmp (symbol->section->name, "LIB$INITIALIZE") == 0))
3388 /* 13 bytes egsd, max 64 chars name -> should be 77 bytes. Add 16 more
3389 bytes for a possible ABS section. */
3390 if (_bfd_vms_output_check (recwr, 80 + 16) < 0)
3392 _bfd_vms_output_end (abfd, recwr);
3393 _bfd_vms_output_begin (recwr, EOBJ__C_EGSD);
3394 _bfd_vms_output_long (recwr, 0);
3397 if ((old_flags & BSF_GLOBAL) != 0
3398 && bfd_is_abs_section (symbol->section)
3399 && abs_section_index <= 0)
3401 /* Create an absolute section if none was defined. It is highly
3402 unlikely that the name $ABS$ clashes with a user defined
3403 non-absolute section name. */
3404 _bfd_vms_output_begin_subrec (recwr, EGSD__C_PSC);
3405 _bfd_vms_output_short (recwr, 4);
3406 _bfd_vms_output_short (recwr, EGPS__V_SHR);
3407 _bfd_vms_output_long (recwr, 0);
3408 _bfd_vms_output_counted (recwr, "$ABS$");
3409 _bfd_vms_output_end_subrec (recwr);
3411 abs_section_index = target_index++;
3414 _bfd_vms_output_begin_subrec (recwr, EGSD__C_SYM);
3416 /* Data type, alignment. */
3417 _bfd_vms_output_short (recwr, 0);
3421 if (old_flags & BSF_WEAK)
3422 new_flags |= EGSY__V_WEAK;
3423 if (bfd_is_com_section (symbol->section)) /* .comm */
3424 new_flags |= (EGSY__V_WEAK | EGSY__V_COMM);
3426 if (old_flags & BSF_FUNCTION)
3428 new_flags |= EGSY__V_NORM;
3429 new_flags |= EGSY__V_REL;
3431 if (old_flags & BSF_GLOBAL)
3433 new_flags |= EGSY__V_DEF;
3434 if (!bfd_is_abs_section (symbol->section))
3435 new_flags |= EGSY__V_REL;
3437 _bfd_vms_output_short (recwr, new_flags);
3439 if (old_flags & BSF_GLOBAL)
3441 /* Symbol definition. */
3442 bfd_vma code_address = 0;
3443 unsigned long ca_psindx = 0;
3444 unsigned long psindx;
3446 if ((old_flags & BSF_FUNCTION) && symbol->udata.p != NULL)
3451 ((struct evax_private_udata_struct *)symbol->udata.p)->enbsym;
3452 code_address = sym->value;
3453 ca_psindx = sym->section->target_index;
3455 if (bfd_is_abs_section (symbol->section))
3456 psindx = abs_section_index;
3458 psindx = symbol->section->target_index;
3460 _bfd_vms_output_quad (recwr, symbol->value);
3461 _bfd_vms_output_quad (recwr, code_address);
3462 _bfd_vms_output_long (recwr, ca_psindx);
3463 _bfd_vms_output_long (recwr, psindx);
3465 _bfd_vms_output_counted (recwr, symbol->name);
3467 _bfd_vms_output_end_subrec (recwr);
3470 _bfd_vms_output_alignment (recwr, 8);
3471 _bfd_vms_output_end (abfd, recwr);
3476 /* Write object header for bfd abfd. Return FALSE on error. */
3479 _bfd_vms_write_ehdr (bfd *abfd)
3482 unsigned int symnum;
3483 struct vms_rec_wr *recwr = &PRIV (recwr);
3485 vms_debug2 ((2, "vms_write_ehdr (%p)\n", abfd));
3487 _bfd_vms_output_alignment (recwr, 2);
3489 _bfd_vms_write_emh (abfd);
3490 _bfd_vms_write_lmn (abfd, "GNU AS");
3493 _bfd_vms_output_begin (recwr, EOBJ__C_EMH);
3494 _bfd_vms_output_short (recwr, EMH__C_SRC);
3496 for (symnum = 0; symnum < abfd->symcount; symnum++)
3498 symbol = abfd->outsymbols[symnum];
3500 if (symbol->flags & BSF_FILE)
3502 _bfd_vms_output_dump (recwr, (unsigned char *) symbol->name,
3503 (int) strlen (symbol->name));
3508 if (symnum == abfd->symcount)
3509 _bfd_vms_output_dump (recwr, (unsigned char *) STRING_COMMA_LEN ("noname"));
3511 _bfd_vms_output_end (abfd, recwr);
3514 _bfd_vms_output_begin (recwr, EOBJ__C_EMH);
3515 _bfd_vms_output_short (recwr, EMH__C_TTL);
3516 _bfd_vms_output_dump (recwr, (unsigned char *) STRING_COMMA_LEN ("TTL"));
3517 _bfd_vms_output_end (abfd, recwr);
3520 _bfd_vms_output_begin (recwr, EOBJ__C_EMH);
3521 _bfd_vms_output_short (recwr, EMH__C_CPR);
3522 _bfd_vms_output_dump (recwr,
3523 (unsigned char *)"GNU BFD ported by Klaus Kämpf 1994-1996",
3525 _bfd_vms_output_end (abfd, recwr);
3530 /* Part 4.6, relocations. */
3533 /* WRITE ETIR SECTION
3535 This is still under construction and therefore not documented. */
3537 /* Close the etir/etbt record. */
3540 end_etir_record (bfd * abfd)
3542 struct vms_rec_wr *recwr = &PRIV (recwr);
3544 _bfd_vms_output_end (abfd, recwr);
3548 start_etir_or_etbt_record (bfd *abfd, asection *section, bfd_vma offset)
3550 struct vms_rec_wr *recwr = &PRIV (recwr);
3552 if (section->flags & SEC_DEBUGGING)
3554 _bfd_vms_output_begin (recwr, EOBJ__C_ETBT);
3558 /* Push start offset. */
3559 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STA_LW);
3560 _bfd_vms_output_long (recwr, (unsigned long) 0);
3561 _bfd_vms_output_end_subrec (recwr);
3564 _bfd_vms_output_begin_subrec (recwr, ETIR__C_CTL_DFLOC);
3565 _bfd_vms_output_end_subrec (recwr);
3570 _bfd_vms_output_begin (recwr, EOBJ__C_ETIR);
3574 /* Push start offset. */
3575 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STA_PQ);
3576 _bfd_vms_output_long (recwr, (unsigned long) section->target_index);
3577 _bfd_vms_output_quad (recwr, offset);
3578 _bfd_vms_output_end_subrec (recwr);
3580 /* Start = pop (). */
3581 _bfd_vms_output_begin_subrec (recwr, ETIR__C_CTL_SETRB);
3582 _bfd_vms_output_end_subrec (recwr);
3587 /* Output a STO_IMM command for SSIZE bytes of data from CPR at virtual
3588 address VADDR in section specified by SEC_INDEX and NAME. */
3591 sto_imm (bfd *abfd, asection *section,
3592 bfd_size_type ssize, unsigned char *cptr, bfd_vma vaddr)
3595 struct vms_rec_wr *recwr = &PRIV (recwr);
3598 _bfd_vms_debug (8, "sto_imm %d bytes\n", (int) ssize);
3599 _bfd_hexdump (9, cptr, (int) ssize, (int) vaddr);
3604 /* Try all the rest. */
3607 if (_bfd_vms_output_check (recwr, size) < 0)
3609 /* Doesn't fit, split ! */
3610 end_etir_record (abfd);
3612 start_etir_or_etbt_record (abfd, section, vaddr);
3614 size = _bfd_vms_output_check (recwr, 0); /* get max size */
3615 if (size > ssize) /* more than what's left ? */
3619 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STO_IMM);
3620 _bfd_vms_output_long (recwr, (unsigned long) (size));
3621 _bfd_vms_output_dump (recwr, cptr, size);
3622 _bfd_vms_output_end_subrec (recwr);
3625 _bfd_vms_debug (10, "dumped %d bytes\n", (int) size);
3626 _bfd_hexdump (10, cptr, (int) size, (int) vaddr);
3636 etir_output_check (bfd *abfd, asection *section, bfd_vma vaddr, int checklen)
3638 if (_bfd_vms_output_check (&PRIV (recwr), checklen) < 0)
3640 /* Not enough room in this record. Close it and open a new one. */
3641 end_etir_record (abfd);
3642 start_etir_or_etbt_record (abfd, section, vaddr);
3646 /* Return whether RELOC must be deferred till the end. */
3649 defer_reloc_p (arelent *reloc)
3651 switch (reloc->howto->type)
3664 /* Write section contents for bfd abfd. Return FALSE on error. */
3667 _bfd_vms_write_etir (bfd * abfd, int objtype ATTRIBUTE_UNUSED)
3670 struct vms_rec_wr *recwr = &PRIV (recwr);
3672 vms_debug2 ((2, "vms_write_tir (%p, %d)\n", abfd, objtype));
3674 _bfd_vms_output_alignment (recwr, 4);
3676 PRIV (vms_linkage_index) = 0;
3678 for (section = abfd->sections; section; section = section->next)
3680 vms_debug2 ((4, "writing %d. section '%s' (%d bytes)\n",
3681 section->target_index, section->name, (int) (section->size)));
3683 if (!(section->flags & SEC_HAS_CONTENTS)
3684 || bfd_is_com_section (section))
3687 if (!section->contents)
3689 bfd_set_error (bfd_error_no_contents);
3693 start_etir_or_etbt_record (abfd, section, 0);
3695 if (section->flags & SEC_RELOC)
3697 bfd_vma curr_addr = 0;
3698 unsigned char *curr_data = section->contents;
3700 int pass2_needed = 0;
3701 int pass2_in_progress = 0;
3704 if (section->reloc_count == 0)
3706 (_("SEC_RELOC with no relocs in section %A"), section);
3711 int i = section->reloc_count;
3712 arelent **rptr = section->orelocation;
3713 _bfd_vms_debug (4, "%d relocations:\n", i);
3716 _bfd_vms_debug (4, "sym %s in sec %s, value %08lx, "
3717 "addr %08lx, off %08lx, len %d: %s\n",
3718 (*(*rptr)->sym_ptr_ptr)->name,
3719 (*(*rptr)->sym_ptr_ptr)->section->name,
3720 (long) (*(*rptr)->sym_ptr_ptr)->value,
3721 (unsigned long)(*rptr)->address,
3722 (unsigned long)(*rptr)->addend,
3723 bfd_get_reloc_size ((*rptr)->howto),
3724 ( *rptr)->howto->name);
3731 for (irel = 0; irel < section->reloc_count; irel++)
3733 struct evax_private_udata_struct *udata;
3734 arelent *rptr = section->orelocation [irel];
3735 bfd_vma addr = rptr->address;
3736 asymbol *sym = *rptr->sym_ptr_ptr;
3737 asection *sec = sym->section;
3738 bfd_boolean defer = defer_reloc_p (rptr);
3741 if (pass2_in_progress)
3743 /* Non-deferred relocs have already been output. */
3749 /* Deferred relocs must be output at the very end. */
3756 /* Regular relocs are intertwined with binary data. */
3757 if (curr_addr > addr)
3758 _bfd_error_handler (_("Size error in section %A"),
3760 size = addr - curr_addr;
3761 sto_imm (abfd, section, size, curr_data, curr_addr);
3766 size = bfd_get_reloc_size (rptr->howto);
3768 switch (rptr->howto->type)
3770 case ALPHA_R_IGNORE:
3773 case ALPHA_R_REFLONG:
3774 if (bfd_is_und_section (sym->section))
3776 bfd_vma addend = rptr->addend;
3777 slen = strlen ((char *) sym->name);
3778 etir_output_check (abfd, section, curr_addr, slen);
3781 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STA_GBL);
3782 _bfd_vms_output_counted (recwr, sym->name);
3783 _bfd_vms_output_end_subrec (recwr);
3784 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STA_LW);
3785 _bfd_vms_output_long (recwr, (unsigned long) addend);
3786 _bfd_vms_output_end_subrec (recwr);
3787 _bfd_vms_output_begin_subrec (recwr, ETIR__C_OPR_ADD);
3788 _bfd_vms_output_end_subrec (recwr);
3789 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STO_LW);
3790 _bfd_vms_output_end_subrec (recwr);
3794 _bfd_vms_output_begin_subrec
3795 (recwr, ETIR__C_STO_GBL_LW);
3796 _bfd_vms_output_counted (recwr, sym->name);
3797 _bfd_vms_output_end_subrec (recwr);
3800 else if (bfd_is_abs_section (sym->section))
3802 etir_output_check (abfd, section, curr_addr, 16);
3803 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STA_LW);
3804 _bfd_vms_output_long (recwr, (unsigned long) sym->value);
3805 _bfd_vms_output_end_subrec (recwr);
3806 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STO_LW);
3807 _bfd_vms_output_end_subrec (recwr);
3811 etir_output_check (abfd, section, curr_addr, 32);
3812 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STA_PQ);
3813 _bfd_vms_output_long (recwr,
3814 (unsigned long) sec->target_index);
3815 _bfd_vms_output_quad (recwr, rptr->addend + sym->value);
3816 _bfd_vms_output_end_subrec (recwr);
3817 /* ??? Table B-8 of the OpenVMS Linker Utilily Manual
3818 says that we should have a ETIR__C_STO_OFF here.
3819 But the relocation would not be BFD_RELOC_32 then.
3820 This case is very likely unreachable. */
3821 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STO_LW);
3822 _bfd_vms_output_end_subrec (recwr);
3826 case ALPHA_R_REFQUAD:
3827 if (bfd_is_und_section (sym->section))
3829 bfd_vma addend = rptr->addend;
3830 slen = strlen ((char *) sym->name);
3831 etir_output_check (abfd, section, curr_addr, slen);
3834 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STA_GBL);
3835 _bfd_vms_output_counted (recwr, sym->name);
3836 _bfd_vms_output_end_subrec (recwr);
3837 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STA_QW);
3838 _bfd_vms_output_quad (recwr, addend);
3839 _bfd_vms_output_end_subrec (recwr);
3840 _bfd_vms_output_begin_subrec (recwr, ETIR__C_OPR_ADD);
3841 _bfd_vms_output_end_subrec (recwr);
3842 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STO_QW);
3843 _bfd_vms_output_end_subrec (recwr);
3847 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STO_GBL);
3848 _bfd_vms_output_counted (recwr, sym->name);
3849 _bfd_vms_output_end_subrec (recwr);
3852 else if (bfd_is_abs_section (sym->section))
3854 etir_output_check (abfd, section, curr_addr, 16);
3855 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STA_QW);
3856 _bfd_vms_output_quad (recwr, sym->value);
3857 _bfd_vms_output_end_subrec (recwr);
3858 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STO_QW);
3859 _bfd_vms_output_end_subrec (recwr);
3863 etir_output_check (abfd, section, curr_addr, 32);
3864 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STA_PQ);
3865 _bfd_vms_output_long (recwr,
3866 (unsigned long) sec->target_index);
3867 _bfd_vms_output_quad (recwr, rptr->addend + sym->value);
3868 _bfd_vms_output_end_subrec (recwr);
3869 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STO_OFF);
3870 _bfd_vms_output_end_subrec (recwr);
3875 sto_imm (abfd, section, size, curr_data, curr_addr);
3878 case ALPHA_R_LINKAGE:
3879 etir_output_check (abfd, section, curr_addr, 64);
3880 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STC_LP_PSB);
3881 _bfd_vms_output_long
3882 (recwr, (unsigned long) rptr->addend);
3883 if (rptr->addend > PRIV (vms_linkage_index))
3884 PRIV (vms_linkage_index) = rptr->addend;
3885 _bfd_vms_output_counted (recwr, sym->name);
3886 _bfd_vms_output_byte (recwr, 0);
3887 _bfd_vms_output_end_subrec (recwr);
3890 case ALPHA_R_CODEADDR:
3891 slen = strlen ((char *) sym->name);
3892 etir_output_check (abfd, section, curr_addr, slen);
3893 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STO_CA);
3894 _bfd_vms_output_counted (recwr, sym->name);
3895 _bfd_vms_output_end_subrec (recwr);
3900 = (struct evax_private_udata_struct *) rptr->sym_ptr_ptr;
3901 etir_output_check (abfd, section, curr_addr,
3902 32 + 1 + strlen (udata->origname));
3903 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STC_NOP_GBL);
3904 _bfd_vms_output_long (recwr, (unsigned long) udata->lkindex);
3905 _bfd_vms_output_long
3906 (recwr, (unsigned long) section->target_index);
3907 _bfd_vms_output_quad (recwr, rptr->address);
3908 _bfd_vms_output_long (recwr, (unsigned long) 0x47ff041f);
3909 _bfd_vms_output_long
3910 (recwr, (unsigned long) section->target_index);
3911 _bfd_vms_output_quad (recwr, rptr->addend);
3912 _bfd_vms_output_counted (recwr, udata->origname);
3913 _bfd_vms_output_end_subrec (recwr);
3917 _bfd_error_handler (_("Spurious ALPHA_R_BSR reloc"));
3922 = (struct evax_private_udata_struct *) rptr->sym_ptr_ptr;
3923 etir_output_check (abfd, section, curr_addr,
3924 32 + 1 + strlen (udata->origname));
3925 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STC_LDA_GBL);
3926 _bfd_vms_output_long
3927 (recwr, (unsigned long) udata->lkindex + 1);
3928 _bfd_vms_output_long
3929 (recwr, (unsigned long) section->target_index);
3930 _bfd_vms_output_quad (recwr, rptr->address);
3931 _bfd_vms_output_long (recwr, (unsigned long) 0x237B0000);
3932 _bfd_vms_output_long
3933 (recwr, (unsigned long) udata->bsym->section->target_index);
3934 _bfd_vms_output_quad (recwr, rptr->addend);
3935 _bfd_vms_output_counted (recwr, udata->origname);
3936 _bfd_vms_output_end_subrec (recwr);
3941 = (struct evax_private_udata_struct *) rptr->sym_ptr_ptr;
3942 etir_output_check (abfd, section, curr_addr,
3943 32 + 1 + strlen (udata->origname));
3944 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STC_BOH_GBL);
3945 _bfd_vms_output_long (recwr, (unsigned long) udata->lkindex);
3946 _bfd_vms_output_long
3947 (recwr, (unsigned long) section->target_index);
3948 _bfd_vms_output_quad (recwr, rptr->address);
3949 _bfd_vms_output_long (recwr, (unsigned long) 0xD3400000);
3950 _bfd_vms_output_long
3951 (recwr, (unsigned long) section->target_index);
3952 _bfd_vms_output_quad (recwr, rptr->addend);
3953 _bfd_vms_output_counted (recwr, udata->origname);
3954 _bfd_vms_output_end_subrec (recwr);
3958 _bfd_error_handler (_("Unhandled relocation %s"),
3965 } /* End of relocs loop. */
3967 if (!pass2_in_progress)
3969 /* Output rest of section. */
3970 if (curr_addr > section->size)
3971 _bfd_error_handler (_("Size error in section %A"), section);
3972 size = section->size - curr_addr;
3973 sto_imm (abfd, section, size, curr_data, curr_addr);
3979 pass2_in_progress = 1;
3985 else /* (section->flags & SEC_RELOC) */
3986 sto_imm (abfd, section, section->size, section->contents, 0);
3988 end_etir_record (abfd);
3991 _bfd_vms_output_alignment (recwr, 2);
3995 /* Write cached information into a file being written, at bfd_close. */
3998 alpha_vms_write_object_contents (bfd *abfd)
4000 vms_debug2 ((1, "vms_write_object_contents (%p)\n", abfd));
4002 if (abfd->flags & (EXEC_P | DYNAMIC))
4004 return alpha_vms_write_exec (abfd);
4008 if (abfd->section_count > 0) /* we have sections */
4010 if (!_bfd_vms_write_ehdr (abfd))
4012 if (!_bfd_vms_write_egsd (abfd))
4014 if (!_bfd_vms_write_etir (abfd, EOBJ__C_ETIR))
4016 if (!_bfd_vms_write_eeom (abfd))
4023 /* Debug stuff: nearest line. */
4025 #define SET_MODULE_PARSED(m) \
4026 do { if ((m)->name == NULL) (m)->name = ""; } while (0)
4027 #define IS_MODULE_PARSED(m) ((m)->name != NULL)
4029 /* Build a new module for the specified BFD. */
4031 static struct module *
4032 new_module (bfd *abfd)
4034 struct module *module
4035 = (struct module *) bfd_zalloc (abfd, sizeof (struct module));
4036 module->file_table_count = 16; /* Arbitrary. */
4038 = bfd_malloc (module->file_table_count * sizeof (struct fileinfo));
4042 /* Parse debug info for a module and internalize it. */
4045 parse_module (bfd *abfd, struct module *module, unsigned char *ptr,
4048 unsigned char *maxptr = ptr + length;
4049 unsigned char *src_ptr, *pcl_ptr;
4050 unsigned int prev_linum = 0, curr_linenum = 0;
4051 bfd_vma prev_pc = 0, curr_pc = 0;
4052 struct srecinfo *curr_srec, *srec;
4053 struct lineinfo *curr_line, *line;
4054 struct funcinfo *funcinfo;
4056 /* Initialize tables with zero element. */
4057 curr_srec = (struct srecinfo *) bfd_zalloc (abfd, sizeof (struct srecinfo));
4058 module->srec_table = curr_srec;
4060 curr_line = (struct lineinfo *) bfd_zalloc (abfd, sizeof (struct lineinfo));
4061 module->line_table = curr_line;
4063 while (length == -1 || ptr < maxptr)
4065 /* The first byte is not counted in the recorded length. */
4066 int rec_length = bfd_getl16 (ptr) + 1;
4067 int rec_type = bfd_getl16 (ptr + 2);
4069 vms_debug2 ((2, "DST record: leng %d, type %d\n", rec_length, rec_type));
4071 if (length == -1 && rec_type == DST__K_MODEND)
4078 = _bfd_vms_save_counted_string (ptr + DST_S_B_MODBEG_NAME);
4085 vms_debug2 ((3, "module: %s\n", module->name));
4092 funcinfo = (struct funcinfo *)
4093 bfd_zalloc (abfd, sizeof (struct funcinfo));
4095 = _bfd_vms_save_counted_string (ptr + DST_S_B_RTNBEG_NAME);
4096 funcinfo->low = bfd_getl32 (ptr + DST_S_L_RTNBEG_ADDRESS);
4097 funcinfo->next = module->func_table;
4098 module->func_table = funcinfo;
4100 vms_debug2 ((3, "routine: %s at 0x%lx\n",
4101 funcinfo->name, (unsigned long) funcinfo->low));
4105 module->func_table->high = module->func_table->low
4106 + bfd_getl32 (ptr + DST_S_L_RTNEND_SIZE) - 1;
4108 if (module->func_table->high > module->high)
4109 module->high = module->func_table->high;
4111 vms_debug2 ((3, "end routine\n"));
4115 vms_debug2 ((3, "prologue\n"));
4119 vms_debug2 ((3, "epilog\n"));
4123 vms_debug2 ((3, "block\n"));
4127 vms_debug2 ((3, "end block\n"));
4131 src_ptr = ptr + DST_S_C_SOURCE_HEADER_SIZE;
4133 vms_debug2 ((3, "source info\n"));
4135 while (src_ptr < ptr + rec_length)
4137 int cmd = src_ptr[0], cmd_length, data;
4141 case DST__K_SRC_DECLFILE:
4144 = bfd_getl16 (src_ptr + DST_S_W_SRC_DF_FILEID);
4146 = _bfd_vms_save_counted_string (src_ptr
4147 + DST_S_B_SRC_DF_FILENAME);
4149 while (fileid >= module->file_table_count)
4151 module->file_table_count *= 2;
4153 = bfd_realloc (module->file_table,
4154 module->file_table_count
4155 * sizeof (struct fileinfo));
4158 module->file_table [fileid].name = filename;
4159 module->file_table [fileid].srec = 1;
4160 cmd_length = src_ptr[DST_S_B_SRC_DF_LENGTH] + 2;
4161 vms_debug2 ((4, "DST_S_C_SRC_DECLFILE: %d, %s\n",
4162 fileid, module->file_table [fileid].name));
4166 case DST__K_SRC_DEFLINES_B:
4167 /* Perform the association and set the next higher index
4169 data = src_ptr[DST_S_B_SRC_UNSBYTE];
4170 srec = (struct srecinfo *)
4171 bfd_zalloc (abfd, sizeof (struct srecinfo));
4172 srec->line = curr_srec->line + data;
4173 srec->srec = curr_srec->srec + data;
4174 srec->sfile = curr_srec->sfile;
4175 curr_srec->next = srec;
4178 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_B: %d\n", data));
4181 case DST__K_SRC_DEFLINES_W:
4182 /* Perform the association and set the next higher index
4184 data = bfd_getl16 (src_ptr + DST_S_W_SRC_UNSWORD);
4185 srec = (struct srecinfo *)
4186 bfd_zalloc (abfd, sizeof (struct srecinfo));
4187 srec->line = curr_srec->line + data;
4188 srec->srec = curr_srec->srec + data,
4189 srec->sfile = curr_srec->sfile;
4190 curr_srec->next = srec;
4193 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_W: %d\n", data));
4196 case DST__K_SRC_INCRLNUM_B:
4197 data = src_ptr[DST_S_B_SRC_UNSBYTE];
4198 curr_srec->line += data;
4200 vms_debug2 ((4, "DST_S_C_SRC_INCRLNUM_B: %d\n", data));
4203 case DST__K_SRC_SETFILE:
4204 data = bfd_getl16 (src_ptr + DST_S_W_SRC_UNSWORD);
4205 curr_srec->sfile = data;
4206 curr_srec->srec = module->file_table[data].srec;
4208 vms_debug2 ((4, "DST_S_C_SRC_SETFILE: %d\n", data));
4211 case DST__K_SRC_SETLNUM_L:
4212 data = bfd_getl32 (src_ptr + DST_S_L_SRC_UNSLONG);
4213 curr_srec->line = data;
4215 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_L: %d\n", data));
4218 case DST__K_SRC_SETLNUM_W:
4219 data = bfd_getl16 (src_ptr + DST_S_W_SRC_UNSWORD);
4220 curr_srec->line = data;
4222 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_W: %d\n", data));
4225 case DST__K_SRC_SETREC_L:
4226 data = bfd_getl32 (src_ptr + DST_S_L_SRC_UNSLONG);
4227 curr_srec->srec = data;
4228 module->file_table[curr_srec->sfile].srec = data;
4230 vms_debug2 ((4, "DST_S_C_SRC_SETREC_L: %d\n", data));
4233 case DST__K_SRC_SETREC_W:
4234 data = bfd_getl16 (src_ptr + DST_S_W_SRC_UNSWORD);
4235 curr_srec->srec = data;
4236 module->file_table[curr_srec->sfile].srec = data;
4238 vms_debug2 ((4, "DST_S_C_SRC_SETREC_W: %d\n", data));
4241 case DST__K_SRC_FORMFEED:
4243 vms_debug2 ((4, "DST_S_C_SRC_FORMFEED\n"));
4247 _bfd_error_handler (_("unknown source command %d"),
4253 src_ptr += cmd_length;
4257 case DST__K_LINE_NUM:
4258 pcl_ptr = ptr + DST_S_C_LINE_NUM_HEADER_SIZE;
4260 vms_debug2 ((3, "line info\n"));
4262 while (pcl_ptr < ptr + rec_length)
4264 /* The command byte is signed so we must sign-extend it. */
4265 int cmd = ((signed char *)pcl_ptr)[0], cmd_length, data;
4269 case DST__K_DELTA_PC_W:
4270 data = bfd_getl16 (pcl_ptr + DST_S_W_PCLINE_UNSWORD);
4274 vms_debug2 ((4, "DST__K_DELTA_PC_W: %d\n", data));
4277 case DST__K_DELTA_PC_L:
4278 data = bfd_getl32 (pcl_ptr + DST_S_L_PCLINE_UNSLONG);
4282 vms_debug2 ((4, "DST__K_DELTA_PC_L: %d\n", data));
4285 case DST__K_INCR_LINUM:
4286 data = pcl_ptr[DST_S_B_PCLINE_UNSBYTE];
4287 curr_linenum += data;
4289 vms_debug2 ((4, "DST__K_INCR_LINUM: %d\n", data));
4292 case DST__K_INCR_LINUM_W:
4293 data = bfd_getl16 (pcl_ptr + DST_S_W_PCLINE_UNSWORD);
4294 curr_linenum += data;
4296 vms_debug2 ((4, "DST__K_INCR_LINUM_W: %d\n", data));
4299 case DST__K_INCR_LINUM_L:
4300 data = bfd_getl32 (pcl_ptr + DST_S_L_PCLINE_UNSLONG);
4301 curr_linenum += data;
4303 vms_debug2 ((4, "DST__K_INCR_LINUM_L: %d\n", data));
4306 case DST__K_SET_LINUM_INCR:
4308 (_("DST__K_SET_LINUM_INCR not implemented"));
4312 case DST__K_SET_LINUM_INCR_W:
4314 (_("DST__K_SET_LINUM_INCR_W not implemented"));
4318 case DST__K_RESET_LINUM_INCR:
4320 (_("DST__K_RESET_LINUM_INCR not implemented"));
4324 case DST__K_BEG_STMT_MODE:
4326 (_("DST__K_BEG_STMT_MODE not implemented"));
4330 case DST__K_END_STMT_MODE:
4332 (_("DST__K_END_STMT_MODE not implemented"));
4336 case DST__K_SET_LINUM_B:
4337 data = pcl_ptr[DST_S_B_PCLINE_UNSBYTE];
4338 curr_linenum = data;
4340 vms_debug2 ((4, "DST__K_SET_LINUM_B: %d\n", data));
4343 case DST__K_SET_LINUM:
4344 data = bfd_getl16 (pcl_ptr + DST_S_W_PCLINE_UNSWORD);
4345 curr_linenum = data;
4347 vms_debug2 ((4, "DST__K_SET_LINE_NUM: %d\n", data));
4350 case DST__K_SET_LINUM_L:
4351 data = bfd_getl32 (pcl_ptr + DST_S_L_PCLINE_UNSLONG);
4352 curr_linenum = data;
4354 vms_debug2 ((4, "DST__K_SET_LINUM_L: %d\n", data));
4359 (_("DST__K_SET_PC not implemented"));
4363 case DST__K_SET_PC_W:
4365 (_("DST__K_SET_PC_W not implemented"));
4369 case DST__K_SET_PC_L:
4371 (_("DST__K_SET_PC_L not implemented"));
4375 case DST__K_SET_STMTNUM:
4377 (_("DST__K_SET_STMTNUM not implemented"));
4382 data = pcl_ptr[DST_S_B_PCLINE_UNSBYTE];
4385 vms_debug2 ((4, "DST__K_TERM: %d\n", data));
4389 data = bfd_getl16 (pcl_ptr + DST_S_W_PCLINE_UNSWORD);
4392 vms_debug2 ((4, "DST__K_TERM_W: %d\n", data));
4396 data = bfd_getl32 (pcl_ptr + DST_S_L_PCLINE_UNSLONG);
4399 vms_debug2 ((4, "DST__K_TERM_L: %d\n", data));
4402 case DST__K_SET_ABS_PC:
4403 data = bfd_getl32 (pcl_ptr + DST_S_L_PCLINE_UNSLONG);
4406 vms_debug2 ((4, "DST__K_SET_ABS_PC: 0x%x\n", data));
4415 vms_debug2 ((4, "bump pc to 0x%lx and line to %d\n",
4416 (unsigned long)curr_pc, curr_linenum));
4420 _bfd_error_handler (_("unknown line command %d"), cmd);
4426 if ((curr_linenum != prev_linum && curr_pc != prev_pc)
4428 || cmd == DST__K_DELTA_PC_L
4429 || cmd == DST__K_DELTA_PC_W)
4431 line = (struct lineinfo *)
4432 bfd_zalloc (abfd, sizeof (struct lineinfo));
4433 line->address = curr_pc;
4434 line->line = curr_linenum;
4436 curr_line->next = line;
4439 prev_linum = curr_linenum;
4441 vms_debug2 ((4, "-> correlate pc 0x%lx with line %d\n",
4442 (unsigned long)curr_pc, curr_linenum));
4445 pcl_ptr += cmd_length;
4449 case 0x17: /* Undocumented type used by DEC C to declare equates. */
4450 vms_debug2 ((3, "undocumented type 0x17\n"));
4454 vms_debug2 ((3, "ignoring record\n"));
4462 /* Finalize tables with EOL marker. */
4463 srec = (struct srecinfo *) bfd_zalloc (abfd, sizeof (struct srecinfo));
4464 srec->line = (unsigned int) -1;
4465 srec->srec = (unsigned int) -1;
4466 curr_srec->next = srec;
4468 line = (struct lineinfo *) bfd_zalloc (abfd, sizeof (struct lineinfo));
4469 line->line = (unsigned int) -1;
4470 line->address = (bfd_vma) -1;
4471 curr_line->next = line;
4473 /* Advertise that this module has been parsed. This is needed
4474 because parsing can be either performed at module creation
4475 or deferred until debug info is consumed. */
4476 SET_MODULE_PARSED (module);
4479 /* Build the list of modules for the specified BFD. */
4481 static struct module *
4482 build_module_list (bfd *abfd)
4484 struct module *module, *list = NULL;
4487 if ((dmt = bfd_get_section_by_name (abfd, "$DMT$")))
4489 /* We have a DMT section so this must be an image. Parse the
4490 section and build the list of modules. This is sufficient
4491 since we can compute the start address and the end address
4492 of every module from the section contents. */
4493 bfd_size_type size = bfd_get_section_size (dmt);
4494 unsigned char *ptr, *end;
4496 ptr = (unsigned char *) bfd_alloc (abfd, size);
4500 if (! bfd_get_section_contents (abfd, dmt, ptr, 0, size))
4503 vms_debug2 ((2, "DMT\n"));
4509 /* Each header declares a module with its start offset and size
4510 of debug info in the DST section, as well as the count of
4511 program sections (i.e. address spans) it contains. */
4512 int modbeg = bfd_getl32 (ptr + DBG_S_L_DMT_MODBEG);
4513 int msize = bfd_getl32 (ptr + DBG_S_L_DST_SIZE);
4514 int count = bfd_getl16 (ptr + DBG_S_W_DMT_PSECT_COUNT);
4515 ptr += DBG_S_C_DMT_HEADER_SIZE;
4517 vms_debug2 ((3, "module: modbeg = %d, size = %d, count = %d\n",
4518 modbeg, msize, count));
4520 /* We create a 'module' structure for each program section since
4521 we only support contiguous addresses in a 'module' structure.
4522 As a consequence, the actual debug info in the DST section is
4523 shared and can be parsed multiple times; that doesn't seem to
4524 cause problems in practice. */
4527 int start = bfd_getl32 (ptr + DBG_S_L_DMT_PSECT_START);
4528 int length = bfd_getl32 (ptr + DBG_S_L_DMT_PSECT_LENGTH);
4529 module = new_module (abfd);
4530 module->modbeg = modbeg;
4531 module->size = msize;
4532 module->low = start;
4533 module->high = start + length;
4534 module->next = list;
4536 ptr += DBG_S_C_DMT_PSECT_SIZE;
4538 vms_debug2 ((4, "section: start = 0x%x, length = %d\n",
4545 /* We don't have a DMT section so this must be an object. Parse
4546 the module right now in order to compute its start address and
4548 void *dst = PRIV (dst_section)->contents;
4553 module = new_module (abfd);
4554 parse_module (abfd, module, PRIV (dst_section)->contents, -1);
4561 /* Calculate and return the name of the source file and the line nearest
4562 to the wanted location in the specified module. */
4565 module_find_nearest_line (bfd *abfd, struct module *module, bfd_vma addr,
4566 const char **file, const char **func,
4569 struct funcinfo *funcinfo;
4570 struct lineinfo *lineinfo;
4571 struct srecinfo *srecinfo;
4572 bfd_boolean ret = FALSE;
4574 /* Parse this module if that was not done at module creation. */
4575 if (! IS_MODULE_PARSED (module))
4577 unsigned int size = module->size;
4578 unsigned int modbeg = PRIV (dst_section)->filepos + module->modbeg;
4579 unsigned char *buffer = (unsigned char *) bfd_malloc (module->size);
4581 if (bfd_seek (abfd, modbeg, SEEK_SET) != 0
4582 || bfd_bread (buffer, size, abfd) != size)
4584 bfd_set_error (bfd_error_no_debug_section);
4588 parse_module (abfd, module, buffer, size);
4592 /* Find out the function (if any) that contains the address. */
4593 for (funcinfo = module->func_table; funcinfo; funcinfo = funcinfo->next)
4594 if (addr >= funcinfo->low && addr <= funcinfo->high)
4596 *func = funcinfo->name;
4601 /* Find out the source file and the line nearest to the address. */
4602 for (lineinfo = module->line_table; lineinfo; lineinfo = lineinfo->next)
4603 if (lineinfo->next && addr < lineinfo->next->address)
4605 for (srecinfo = module->srec_table; srecinfo; srecinfo = srecinfo->next)
4606 if (srecinfo->next && lineinfo->line < srecinfo->next->line)
4608 if (srecinfo->sfile > 0)
4610 *file = module->file_table[srecinfo->sfile].name;
4611 *line = srecinfo->srec + lineinfo->line - srecinfo->line;
4615 *file = module->name;
4616 *line = lineinfo->line;
4627 /* Provided a BFD, a section and an offset into the section, calculate and
4628 return the name of the source file and the line nearest to the wanted
4632 _bfd_vms_find_nearest_line (bfd *abfd,
4633 asymbol **symbols ATTRIBUTE_UNUSED,
4639 unsigned int *discriminator)
4641 struct module *module;
4643 /* What address are we looking for? */
4644 bfd_vma addr = section->vma + offset;
4652 /* We can't do anything if there is no DST (debug symbol table). */
4653 if (PRIV (dst_section) == NULL)
4656 /* Create the module list - if not already done. */
4657 if (PRIV (modules) == NULL)
4659 PRIV (modules) = build_module_list (abfd);
4660 if (PRIV (modules) == NULL)
4664 for (module = PRIV (modules); module; module = module->next)
4665 if (addr >= module->low && addr <= module->high)
4666 return module_find_nearest_line (abfd, module, addr, file, func, line);
4671 /* Canonicalizations. */
4672 /* Set name, value, section and flags of SYM from E. */
4675 alpha_vms_convert_symbol (bfd *abfd, struct vms_symbol_entry *e, asymbol *sym)
4684 flags = BSF_NO_FLAGS;
4690 if (e->flags & EGSY__V_WEAK)
4693 if (e->flags & EGSY__V_DEF)
4695 /* Symbol definition. */
4696 flags |= BSF_GLOBAL;
4697 if (e->flags & EGSY__V_NORM)
4698 flags |= BSF_FUNCTION;
4704 /* Symbol reference. */
4705 sec = bfd_und_section_ptr;
4710 /* A universal symbol is by definition global... */
4711 flags |= BSF_GLOBAL;
4713 /* ...and dynamic in shared libraries. */
4714 if (abfd->flags & DYNAMIC)
4715 flags |= BSF_DYNAMIC;
4717 if (e->flags & EGSY__V_WEAK)
4720 if (!(e->flags & EGSY__V_DEF))
4723 if (e->flags & EGSY__V_NORM)
4724 flags |= BSF_FUNCTION;
4727 /* sec = e->section; */
4728 sec = bfd_abs_section_ptr;
4743 /* Return the number of bytes required to store a vector of pointers
4744 to asymbols for all the symbols in the BFD abfd, including a
4745 terminal NULL pointer. If there are no symbols in the BFD,
4746 then return 0. If an error occurs, return -1. */
4749 alpha_vms_get_symtab_upper_bound (bfd *abfd)
4751 vms_debug2 ((1, "alpha_vms_get_symtab_upper_bound (%p), %d symbols\n",
4752 abfd, PRIV (gsd_sym_count)));
4754 return (PRIV (gsd_sym_count) + 1) * sizeof (asymbol *);
4757 /* Read the symbols from the BFD abfd, and fills in the vector
4758 location with pointers to the symbols and a trailing NULL.
4760 Return number of symbols read. */
4763 alpha_vms_canonicalize_symtab (bfd *abfd, asymbol **symbols)
4767 vms_debug2 ((1, "alpha_vms_canonicalize_symtab (%p, <ret>)\n", abfd));
4769 if (PRIV (csymbols) == NULL)
4771 PRIV (csymbols) = (asymbol **) bfd_alloc
4772 (abfd, PRIV (gsd_sym_count) * sizeof (asymbol *));
4774 /* Traverse table and fill symbols vector. */
4775 for (i = 0; i < PRIV (gsd_sym_count); i++)
4777 struct vms_symbol_entry *e = PRIV (syms)[i];
4780 sym = bfd_make_empty_symbol (abfd);
4781 if (sym == NULL || !alpha_vms_convert_symbol (abfd, e, sym))
4783 bfd_release (abfd, PRIV (csymbols));
4784 PRIV (csymbols) = NULL;
4788 PRIV (csymbols)[i] = sym;
4792 if (symbols != NULL)
4794 for (i = 0; i < PRIV (gsd_sym_count); i++)
4795 symbols[i] = PRIV (csymbols)[i];
4799 return PRIV (gsd_sym_count);
4802 /* Read and convert relocations from ETIR. We do it once for all sections. */
4805 alpha_vms_slurp_relocs (bfd *abfd)
4809 vms_debug2 ((3, "alpha_vms_slurp_relocs\n"));
4811 /* We slurp relocs only once, for all sections. */
4812 if (PRIV (reloc_done))
4814 PRIV (reloc_done) = TRUE;
4816 if (alpha_vms_canonicalize_symtab (abfd, NULL) < 0)
4819 if (bfd_seek (abfd, 0, SEEK_SET) != 0)
4824 unsigned char *begin;
4827 bfd_reloc_code_real_type reloc_code;
4833 bfd_vma cur_address;
4835 unsigned char *cur_sym = NULL;
4837 bfd_vma cur_addend = 0;
4839 /* Skip non-ETIR records. */
4840 type = _bfd_vms_get_object_record (abfd);
4841 if (type == EOBJ__C_EEOM)
4843 if (type != EOBJ__C_ETIR)
4846 begin = PRIV (recrd.rec) + 4;
4847 end = PRIV (recrd.rec) + PRIV (recrd.rec_size);
4849 for (ptr = begin; ptr < end; ptr += length)
4853 cmd = bfd_getl16 (ptr);
4854 length = bfd_getl16 (ptr + 2);
4856 cur_address = vaddr;
4858 vms_debug2 ((4, "alpha_vms_slurp_relocs: etir %s\n",
4859 _bfd_vms_etir_name (cmd)));
4863 case ETIR__C_STA_GBL: /* ALPHA_R_REFLONG und_section, step 1 */
4864 /* ALPHA_R_REFQUAD und_section, step 1 */
4869 case ETIR__C_STA_PQ: /* ALPHA_R_REF{LONG|QUAD}, others part 1 */
4870 cur_psidx = bfd_getl32 (ptr + 4);
4871 cur_addend = bfd_getl64 (ptr + 8);
4875 case ETIR__C_CTL_SETRB:
4876 if (prev_cmd != ETIR__C_STA_PQ)
4879 /* xgettext:c-format */
4880 (_("Unknown reloc %s + %s"), _bfd_vms_etir_name (prev_cmd),
4881 _bfd_vms_etir_name (cmd));
4884 cur_psect = cur_psidx;
4890 case ETIR__C_STA_LW: /* ALPHA_R_REFLONG abs_section, step 1 */
4891 /* ALPHA_R_REFLONG und_section, step 2 */
4894 if (prev_cmd != ETIR__C_STA_GBL)
4897 /* xgettext:c-format */
4898 (_("Unknown reloc %s + %s"), _bfd_vms_etir_name (cmd),
4899 _bfd_vms_etir_name (ETIR__C_STA_LW));
4903 cur_addend = bfd_getl32 (ptr + 4);
4907 case ETIR__C_STA_QW: /* ALPHA_R_REFQUAD abs_section, step 1 */
4908 /* ALPHA_R_REFQUAD und_section, step 2 */
4909 if (prev_cmd != -1 && prev_cmd != ETIR__C_STA_GBL)
4912 /* xgettext:c-format */
4913 (_("Unknown reloc %s + %s"), _bfd_vms_etir_name (cmd),
4914 _bfd_vms_etir_name (ETIR__C_STA_QW));
4917 cur_addend = bfd_getl64 (ptr + 4);
4921 case ETIR__C_STO_LW: /* ALPHA_R_REFLONG und_section, step 4 */
4922 /* ALPHA_R_REFLONG abs_section, step 2 */
4923 /* ALPHA_R_REFLONG others, step 2 */
4924 if (prev_cmd != ETIR__C_OPR_ADD
4925 && prev_cmd != ETIR__C_STA_LW
4926 && prev_cmd != ETIR__C_STA_PQ)
4928 /* xgettext:c-format */
4929 _bfd_error_handler (_("Unknown reloc %s + %s"),
4930 _bfd_vms_etir_name (prev_cmd),
4931 _bfd_vms_etir_name (ETIR__C_STO_LW));
4934 reloc_code = BFD_RELOC_32;
4937 case ETIR__C_STO_QW: /* ALPHA_R_REFQUAD und_section, step 4 */
4938 /* ALPHA_R_REFQUAD abs_section, step 2 */
4939 if (prev_cmd != ETIR__C_OPR_ADD && prev_cmd != ETIR__C_STA_QW)
4941 /* xgettext:c-format */
4942 _bfd_error_handler (_("Unknown reloc %s + %s"),
4943 _bfd_vms_etir_name (prev_cmd),
4944 _bfd_vms_etir_name (ETIR__C_STO_QW));
4947 reloc_code = BFD_RELOC_64;
4950 case ETIR__C_STO_OFF: /* ALPHA_R_REFQUAD others, step 2 */
4951 if (prev_cmd != ETIR__C_STA_PQ)
4953 /* xgettext:c-format */
4954 _bfd_error_handler (_("Unknown reloc %s + %s"),
4955 _bfd_vms_etir_name (prev_cmd),
4956 _bfd_vms_etir_name (ETIR__C_STO_OFF));
4959 reloc_code = BFD_RELOC_64;
4962 case ETIR__C_OPR_ADD: /* ALPHA_R_REFLONG und_section, step 3 */
4963 /* ALPHA_R_REFQUAD und_section, step 3 */
4964 if (prev_cmd != ETIR__C_STA_LW && prev_cmd != ETIR__C_STA_QW)
4966 /* xgettext:c-format */
4967 _bfd_error_handler (_("Unknown reloc %s + %s"),
4968 _bfd_vms_etir_name (prev_cmd),
4969 _bfd_vms_etir_name (ETIR__C_OPR_ADD));
4972 prev_cmd = ETIR__C_OPR_ADD;
4975 case ETIR__C_STO_CA: /* ALPHA_R_CODEADDR */
4976 reloc_code = BFD_RELOC_ALPHA_CODEADDR;
4980 case ETIR__C_STO_GBL: /* ALPHA_R_REFQUAD und_section */
4981 reloc_code = BFD_RELOC_64;
4985 case ETIR__C_STO_GBL_LW: /* ALPHA_R_REFLONG und_section */
4986 reloc_code = BFD_RELOC_32;
4990 case ETIR__C_STC_LP_PSB: /* ALPHA_R_LINKAGE */
4991 reloc_code = BFD_RELOC_ALPHA_LINKAGE;
4995 case ETIR__C_STC_NOP_GBL: /* ALPHA_R_NOP */
4996 reloc_code = BFD_RELOC_ALPHA_NOP;
4999 case ETIR__C_STC_BSR_GBL: /* ALPHA_R_BSR */
5000 reloc_code = BFD_RELOC_ALPHA_BSR;
5003 case ETIR__C_STC_LDA_GBL: /* ALPHA_R_LDA */
5004 reloc_code = BFD_RELOC_ALPHA_LDA;
5007 case ETIR__C_STC_BOH_GBL: /* ALPHA_R_BOH */
5008 reloc_code = BFD_RELOC_ALPHA_BOH;
5012 cur_sym = ptr + 4 + 32;
5013 cur_address = bfd_getl64 (ptr + 4 + 8);
5014 cur_addend = bfd_getl64 (ptr + 4 + 24);
5017 case ETIR__C_STO_IMM:
5018 vaddr += bfd_getl32 (ptr + 4);
5022 _bfd_error_handler (_("Unknown reloc %s"),
5023 _bfd_vms_etir_name (cmd));
5029 struct vms_section_data_struct *vms_sec;
5032 /* Get section to which the relocation applies. */
5033 if (cur_psect < 0 || cur_psect > (int)PRIV (section_count))
5035 _bfd_error_handler (_("Invalid section index in ETIR"));
5039 sec = PRIV (sections)[cur_psect];
5040 if (sec == bfd_abs_section_ptr)
5042 _bfd_error_handler (_("Relocation for non-REL psect"));
5046 vms_sec = vms_section_data (sec);
5048 /* Allocate a reloc entry. */
5049 if (sec->reloc_count >= vms_sec->reloc_max)
5051 if (vms_sec->reloc_max == 0)
5053 vms_sec->reloc_max = 64;
5054 sec->relocation = bfd_zmalloc
5055 (vms_sec->reloc_max * sizeof (arelent));
5059 vms_sec->reloc_max *= 2;
5060 sec->relocation = bfd_realloc
5061 (sec->relocation, vms_sec->reloc_max * sizeof (arelent));
5064 reloc = &sec->relocation[sec->reloc_count];
5067 reloc->howto = bfd_reloc_type_lookup (abfd, reloc_code);
5069 if (cur_sym != NULL)
5072 unsigned int symlen = *cur_sym;
5075 /* Linear search. */
5080 for (j = 0; j < PRIV (gsd_sym_count); j++)
5081 if (PRIV (syms)[j]->namelen == symlen
5082 && memcmp (PRIV (syms)[j]->name, cur_sym, symlen) == 0)
5084 sym = &PRIV (csymbols)[j];
5089 _bfd_error_handler (_("Unknown symbol in command %s"),
5090 _bfd_vms_etir_name (cmd));
5091 reloc->sym_ptr_ptr = NULL;
5094 reloc->sym_ptr_ptr = sym;
5096 else if (cur_psidx >= 0)
5097 reloc->sym_ptr_ptr =
5098 PRIV (sections)[cur_psidx]->symbol_ptr_ptr;
5100 reloc->sym_ptr_ptr = NULL;
5102 reloc->address = cur_address;
5103 reloc->addend = cur_addend;
5105 vaddr += bfd_get_reloc_size (reloc->howto);
5114 vms_debug2 ((3, "alpha_vms_slurp_relocs: result = TRUE\n"));
5119 /* Return the number of bytes required to store the relocation
5120 information associated with the given section. */
5123 alpha_vms_get_reloc_upper_bound (bfd *abfd ATTRIBUTE_UNUSED, asection *section)
5125 alpha_vms_slurp_relocs (abfd);
5127 return (section->reloc_count + 1) * sizeof (arelent *);
5130 /* Convert relocations from VMS (external) form into BFD internal
5131 form. Return the number of relocations. */
5134 alpha_vms_canonicalize_reloc (bfd *abfd, asection *section, arelent **relptr,
5135 asymbol **symbols ATTRIBUTE_UNUSED)
5140 if (!alpha_vms_slurp_relocs (abfd))
5143 count = section->reloc_count;
5144 tblptr = section->relocation;
5147 *relptr++ = tblptr++;
5149 *relptr = (arelent *) NULL;
5150 return section->reloc_count;
5153 /* Install a new set of internal relocs. */
5155 #define alpha_vms_set_reloc _bfd_generic_set_reloc
5158 /* This is just copied from ecoff-alpha, needs to be fixed probably. */
5160 /* How to process the various reloc types. */
5162 static bfd_reloc_status_type
5163 reloc_nil (bfd * abfd ATTRIBUTE_UNUSED,
5164 arelent *reloc ATTRIBUTE_UNUSED,
5165 asymbol *sym ATTRIBUTE_UNUSED,
5166 void * data ATTRIBUTE_UNUSED,
5167 asection *sec ATTRIBUTE_UNUSED,
5168 bfd *output_bfd ATTRIBUTE_UNUSED,
5169 char **error_message ATTRIBUTE_UNUSED)
5172 vms_debug (1, "reloc_nil (abfd %p, output_bfd %p)\n", abfd, output_bfd);
5173 vms_debug (2, "In section %s, symbol %s\n",
5174 sec->name, sym->name);
5175 vms_debug (2, "reloc sym %s, addr %08lx, addend %08lx, reloc is a %s\n",
5176 reloc->sym_ptr_ptr[0]->name,
5177 (unsigned long)reloc->address,
5178 (unsigned long)reloc->addend, reloc->howto->name);
5179 vms_debug (2, "data at %p\n", data);
5180 /* _bfd_hexdump (2, data, bfd_get_reloc_size (reloc->howto), 0); */
5183 return bfd_reloc_ok;
5186 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
5187 from smaller values. Start with zero, widen, *then* decrement. */
5188 #define MINUS_ONE (((bfd_vma)0) - 1)
5190 static reloc_howto_type alpha_howto_table[] =
5192 HOWTO (ALPHA_R_IGNORE, /* Type. */
5193 0, /* Rightshift. */
5194 0, /* Size (0 = byte, 1 = short, 2 = long). */
5196 TRUE, /* PC relative. */
5198 complain_overflow_dont,/* Complain_on_overflow. */
5199 reloc_nil, /* Special_function. */
5200 "IGNORE", /* Name. */
5201 TRUE, /* Partial_inplace. */
5202 0, /* Source mask */
5204 TRUE), /* PC rel offset. */
5206 /* A 64 bit reference to a symbol. */
5207 HOWTO (ALPHA_R_REFQUAD, /* Type. */
5208 0, /* Rightshift. */
5209 4, /* Size (0 = byte, 1 = short, 2 = long). */
5211 FALSE, /* PC relative. */
5213 complain_overflow_bitfield, /* Complain_on_overflow. */
5214 reloc_nil, /* Special_function. */
5215 "REFQUAD", /* Name. */
5216 TRUE, /* Partial_inplace. */
5217 MINUS_ONE, /* Source mask. */
5218 MINUS_ONE, /* Dest mask. */
5219 FALSE), /* PC rel offset. */
5221 /* A 21 bit branch. The native assembler generates these for
5222 branches within the text segment, and also fills in the PC
5223 relative offset in the instruction. */
5224 HOWTO (ALPHA_R_BRADDR, /* Type. */
5225 2, /* Rightshift. */
5226 2, /* Size (0 = byte, 1 = short, 2 = long). */
5228 TRUE, /* PC relative. */
5230 complain_overflow_signed, /* Complain_on_overflow. */
5231 reloc_nil, /* Special_function. */
5232 "BRADDR", /* Name. */
5233 TRUE, /* Partial_inplace. */
5234 0x1fffff, /* Source mask. */
5235 0x1fffff, /* Dest mask. */
5236 FALSE), /* PC rel offset. */
5238 /* A hint for a jump to a register. */
5239 HOWTO (ALPHA_R_HINT, /* Type. */
5240 2, /* Rightshift. */
5241 1, /* Size (0 = byte, 1 = short, 2 = long). */
5243 TRUE, /* PC relative. */
5245 complain_overflow_dont,/* Complain_on_overflow. */
5246 reloc_nil, /* Special_function. */
5248 TRUE, /* Partial_inplace. */
5249 0x3fff, /* Source mask. */
5250 0x3fff, /* Dest mask. */
5251 FALSE), /* PC rel offset. */
5253 /* 16 bit PC relative offset. */
5254 HOWTO (ALPHA_R_SREL16, /* Type. */
5255 0, /* Rightshift. */
5256 1, /* Size (0 = byte, 1 = short, 2 = long). */
5258 TRUE, /* PC relative. */
5260 complain_overflow_signed, /* Complain_on_overflow. */
5261 reloc_nil, /* Special_function. */
5262 "SREL16", /* Name. */
5263 TRUE, /* Partial_inplace. */
5264 0xffff, /* Source mask. */
5265 0xffff, /* Dest mask. */
5266 FALSE), /* PC rel offset. */
5268 /* 32 bit PC relative offset. */
5269 HOWTO (ALPHA_R_SREL32, /* Type. */
5270 0, /* Rightshift. */
5271 2, /* Size (0 = byte, 1 = short, 2 = long). */
5273 TRUE, /* PC relative. */
5275 complain_overflow_signed, /* Complain_on_overflow. */
5276 reloc_nil, /* Special_function. */
5277 "SREL32", /* Name. */
5278 TRUE, /* Partial_inplace. */
5279 0xffffffff, /* Source mask. */
5280 0xffffffff, /* Dest mask. */
5281 FALSE), /* PC rel offset. */
5283 /* A 64 bit PC relative offset. */
5284 HOWTO (ALPHA_R_SREL64, /* Type. */
5285 0, /* Rightshift. */
5286 4, /* Size (0 = byte, 1 = short, 2 = long). */
5288 TRUE, /* PC relative. */
5290 complain_overflow_signed, /* Complain_on_overflow. */
5291 reloc_nil, /* Special_function. */
5292 "SREL64", /* Name. */
5293 TRUE, /* Partial_inplace. */
5294 MINUS_ONE, /* Source mask. */
5295 MINUS_ONE, /* Dest mask. */
5296 FALSE), /* PC rel offset. */
5298 /* Push a value on the reloc evaluation stack. */
5299 HOWTO (ALPHA_R_OP_PUSH, /* Type. */
5300 0, /* Rightshift. */
5301 0, /* Size (0 = byte, 1 = short, 2 = long). */
5303 FALSE, /* PC relative. */
5305 complain_overflow_dont,/* Complain_on_overflow. */
5306 reloc_nil, /* Special_function. */
5307 "OP_PUSH", /* Name. */
5308 FALSE, /* Partial_inplace. */
5309 0, /* Source mask. */
5311 FALSE), /* PC rel offset. */
5313 /* Store the value from the stack at the given address. Store it in
5314 a bitfield of size r_size starting at bit position r_offset. */
5315 HOWTO (ALPHA_R_OP_STORE, /* Type. */
5316 0, /* Rightshift. */
5317 4, /* Size (0 = byte, 1 = short, 2 = long). */
5319 FALSE, /* PC relative. */
5321 complain_overflow_dont,/* Complain_on_overflow. */
5322 reloc_nil, /* Special_function. */
5323 "OP_STORE", /* Name. */
5324 FALSE, /* Partial_inplace. */
5325 0, /* Source mask. */
5326 MINUS_ONE, /* Dest mask. */
5327 FALSE), /* PC rel offset. */
5329 /* Subtract the reloc address from the value on the top of the
5330 relocation stack. */
5331 HOWTO (ALPHA_R_OP_PSUB, /* Type. */
5332 0, /* Rightshift. */
5333 0, /* Size (0 = byte, 1 = short, 2 = long). */
5335 FALSE, /* PC relative. */
5337 complain_overflow_dont,/* Complain_on_overflow. */
5338 reloc_nil, /* Special_function. */
5339 "OP_PSUB", /* Name. */
5340 FALSE, /* Partial_inplace. */
5341 0, /* Source mask. */
5343 FALSE), /* PC rel offset. */
5345 /* Shift the value on the top of the relocation stack right by the
5347 HOWTO (ALPHA_R_OP_PRSHIFT, /* Type. */
5348 0, /* Rightshift. */
5349 0, /* Size (0 = byte, 1 = short, 2 = long). */
5351 FALSE, /* PC relative. */
5353 complain_overflow_dont,/* Complain_on_overflow. */
5354 reloc_nil, /* Special_function. */
5355 "OP_PRSHIFT", /* Name. */
5356 FALSE, /* Partial_inplace. */
5357 0, /* Source mask. */
5359 FALSE), /* PC rel offset. */
5361 /* Hack. Linkage is done by linker. */
5362 HOWTO (ALPHA_R_LINKAGE, /* Type. */
5363 0, /* Rightshift. */
5364 8, /* Size (0 = byte, 1 = short, 2 = long). */
5366 FALSE, /* PC relative. */
5368 complain_overflow_dont,/* Complain_on_overflow. */
5369 reloc_nil, /* Special_function. */
5370 "LINKAGE", /* Name. */
5371 FALSE, /* Partial_inplace. */
5372 0, /* Source mask. */
5374 FALSE), /* PC rel offset. */
5376 /* A 32 bit reference to a symbol. */
5377 HOWTO (ALPHA_R_REFLONG, /* Type. */
5378 0, /* Rightshift. */
5379 2, /* Size (0 = byte, 1 = short, 2 = long). */
5381 FALSE, /* PC relative. */
5383 complain_overflow_bitfield, /* Complain_on_overflow. */
5384 reloc_nil, /* Special_function. */
5385 "REFLONG", /* Name. */
5386 TRUE, /* Partial_inplace. */
5387 0xffffffff, /* Source mask. */
5388 0xffffffff, /* Dest mask. */
5389 FALSE), /* PC rel offset. */
5391 /* A 64 bit reference to a procedure, written as 32 bit value. */
5392 HOWTO (ALPHA_R_CODEADDR, /* Type. */
5393 0, /* Rightshift. */
5394 4, /* Size (0 = byte, 1 = short, 2 = long). */
5396 FALSE, /* PC relative. */
5398 complain_overflow_signed,/* Complain_on_overflow. */
5399 reloc_nil, /* Special_function. */
5400 "CODEADDR", /* Name. */
5401 FALSE, /* Partial_inplace. */
5402 0xffffffff, /* Source mask. */
5403 0xffffffff, /* Dest mask. */
5404 FALSE), /* PC rel offset. */
5406 HOWTO (ALPHA_R_NOP, /* Type. */
5407 0, /* Rightshift. */
5408 3, /* Size (0 = byte, 1 = short, 2 = long). */
5410 /* The following value must match that of ALPHA_R_BSR/ALPHA_R_BOH
5411 because the calculations for the 3 relocations are the same.
5412 See B.4.5.2 of the OpenVMS Linker Utility Manual. */
5413 TRUE, /* PC relative. */
5415 complain_overflow_dont,/* Complain_on_overflow. */
5416 reloc_nil, /* Special_function. */
5418 FALSE, /* Partial_inplace. */
5419 0xffffffff, /* Source mask. */
5420 0xffffffff, /* Dest mask. */
5421 FALSE), /* PC rel offset. */
5423 HOWTO (ALPHA_R_BSR, /* Type. */
5424 0, /* Rightshift. */
5425 3, /* Size (0 = byte, 1 = short, 2 = long). */
5427 TRUE, /* PC relative. */
5429 complain_overflow_dont,/* Complain_on_overflow. */
5430 reloc_nil, /* Special_function. */
5432 FALSE, /* Partial_inplace. */
5433 0xffffffff, /* Source mask. */
5434 0xffffffff, /* Dest mask. */
5435 FALSE), /* PC rel offset. */
5437 HOWTO (ALPHA_R_LDA, /* Type. */
5438 0, /* Rightshift. */
5439 3, /* Size (0 = byte, 1 = short, 2 = long). */
5441 FALSE, /* PC relative. */
5443 complain_overflow_dont,/* Complain_on_overflow. */
5444 reloc_nil, /* Special_function. */
5446 FALSE, /* Partial_inplace. */
5447 0xffffffff, /* Source mask. */
5448 0xffffffff, /* Dest mask. */
5449 FALSE), /* PC rel offset. */
5451 HOWTO (ALPHA_R_BOH, /* Type. */
5452 0, /* Rightshift. */
5453 3, /* Size (0 = byte, 1 = short, 2 = long, 3 = nil). */
5455 TRUE, /* PC relative. */
5457 complain_overflow_dont,/* Complain_on_overflow. */
5458 reloc_nil, /* Special_function. */
5460 FALSE, /* Partial_inplace. */
5461 0xffffffff, /* Source mask. */
5462 0xffffffff, /* Dest mask. */
5463 FALSE), /* PC rel offset. */
5466 /* Return a pointer to a howto structure which, when invoked, will perform
5467 the relocation code on data from the architecture noted. */
5469 static const struct reloc_howto_struct *
5470 alpha_vms_bfd_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
5471 bfd_reloc_code_real_type code)
5475 vms_debug2 ((1, "vms_bfd_reloc_type_lookup (%p, %d)\t", abfd, code));
5479 case BFD_RELOC_16: alpha_type = ALPHA_R_SREL16; break;
5480 case BFD_RELOC_32: alpha_type = ALPHA_R_REFLONG; break;
5481 case BFD_RELOC_64: alpha_type = ALPHA_R_REFQUAD; break;
5482 case BFD_RELOC_CTOR: alpha_type = ALPHA_R_REFQUAD; break;
5483 case BFD_RELOC_23_PCREL_S2: alpha_type = ALPHA_R_BRADDR; break;
5484 case BFD_RELOC_ALPHA_HINT: alpha_type = ALPHA_R_HINT; break;
5485 case BFD_RELOC_16_PCREL: alpha_type = ALPHA_R_SREL16; break;
5486 case BFD_RELOC_32_PCREL: alpha_type = ALPHA_R_SREL32; break;
5487 case BFD_RELOC_64_PCREL: alpha_type = ALPHA_R_SREL64; break;
5488 case BFD_RELOC_ALPHA_LINKAGE: alpha_type = ALPHA_R_LINKAGE; break;
5489 case BFD_RELOC_ALPHA_CODEADDR: alpha_type = ALPHA_R_CODEADDR; break;
5490 case BFD_RELOC_ALPHA_NOP: alpha_type = ALPHA_R_NOP; break;
5491 case BFD_RELOC_ALPHA_BSR: alpha_type = ALPHA_R_BSR; break;
5492 case BFD_RELOC_ALPHA_LDA: alpha_type = ALPHA_R_LDA; break;
5493 case BFD_RELOC_ALPHA_BOH: alpha_type = ALPHA_R_BOH; break;
5495 _bfd_error_handler (_("reloc (%d) is *UNKNOWN*"), code);
5498 vms_debug2 ((2, "reloc is %s\n", alpha_howto_table[alpha_type].name));
5499 return & alpha_howto_table[alpha_type];
5502 static reloc_howto_type *
5503 alpha_vms_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
5509 i < sizeof (alpha_howto_table) / sizeof (alpha_howto_table[0]);
5511 if (alpha_howto_table[i].name != NULL
5512 && strcasecmp (alpha_howto_table[i].name, r_name) == 0)
5513 return &alpha_howto_table[i];
5519 alpha_vms_get_synthetic_symtab (bfd *abfd,
5520 long symcount ATTRIBUTE_UNUSED,
5521 asymbol **usyms ATTRIBUTE_UNUSED,
5522 long dynsymcount ATTRIBUTE_UNUSED,
5523 asymbol **dynsyms ATTRIBUTE_UNUSED,
5530 syms = (asymbol *) bfd_malloc (PRIV (norm_sym_count) * sizeof (asymbol));
5535 for (i = 0; i < PRIV (gsd_sym_count); i++)
5537 struct vms_symbol_entry *e = PRIV (syms)[i];
5548 flags = BSF_LOCAL | BSF_SYNTHETIC;
5555 if ((e->flags & EGSY__V_DEF) && (e->flags & EGSY__V_NORM))
5557 value = e->code_value;
5558 sec = e->code_section;
5569 sname = bfd_alloc (abfd, l + 5);
5572 memcpy (sname, name, l);
5573 memcpy (sname + l, "..en", 5);
5580 sym->udata.p = NULL;
5589 vms_time_to_str (unsigned char *buf)
5591 time_t t = vms_rawtime_to_time_t (buf);
5592 char *res = ctime (&t);
5595 res = "*invalid time*";
5602 evax_bfd_print_emh (FILE *file, unsigned char *rec, unsigned int rec_len)
5604 struct vms_emh_common *emh = (struct vms_emh_common *)rec;
5605 unsigned int subtype;
5607 subtype = (unsigned)bfd_getl16 (emh->subtyp);
5609 /* xgettext:c-format */
5610 fprintf (file, _(" EMH %u (len=%u): "), subtype, rec_len);
5616 struct vms_emh_mhd *mhd = (struct vms_emh_mhd *)rec;
5619 fprintf (file, _("Module header\n"));
5620 fprintf (file, _(" structure level: %u\n"), mhd->strlvl);
5621 fprintf (file, _(" max record size: %u\n"),
5622 (unsigned)bfd_getl32 (mhd->recsiz));
5623 name = (char *)(mhd + 1);
5624 fprintf (file, _(" module name : %.*s\n"), name[0], name + 1);
5625 name += name[0] + 1;
5626 fprintf (file, _(" module version : %.*s\n"), name[0], name + 1);
5627 name += name[0] + 1;
5628 fprintf (file, _(" compile date : %.17s\n"), name);
5633 fprintf (file, _("Language Processor Name\n"));
5634 fprintf (file, _(" language name: %.*s\n"),
5635 (int)(rec_len - sizeof (struct vms_emh_common)),
5636 (char *)rec + sizeof (struct vms_emh_common));
5641 fprintf (file, _("Source Files Header\n"));
5642 fprintf (file, _(" file: %.*s\n"),
5643 (int)(rec_len - sizeof (struct vms_emh_common)),
5644 (char *)rec + sizeof (struct vms_emh_common));
5649 fprintf (file, _("Title Text Header\n"));
5650 fprintf (file, _(" title: %.*s\n"),
5651 (int)(rec_len - sizeof (struct vms_emh_common)),
5652 (char *)rec + sizeof (struct vms_emh_common));
5657 fprintf (file, _("Copyright Header\n"));
5658 fprintf (file, _(" copyright: %.*s\n"),
5659 (int)(rec_len - sizeof (struct vms_emh_common)),
5660 (char *)rec + sizeof (struct vms_emh_common));
5664 fprintf (file, _("unhandled emh subtype %u\n"), subtype);
5670 evax_bfd_print_eeom (FILE *file, unsigned char *rec, unsigned int rec_len)
5672 struct vms_eeom *eeom = (struct vms_eeom *)rec;
5674 fprintf (file, _(" EEOM (len=%u):\n"), rec_len);
5675 fprintf (file, _(" number of cond linkage pairs: %u\n"),
5676 (unsigned)bfd_getl32 (eeom->total_lps));
5677 fprintf (file, _(" completion code: %u\n"),
5678 (unsigned)bfd_getl16 (eeom->comcod));
5681 fprintf (file, _(" transfer addr flags: 0x%02x\n"), eeom->tfrflg);
5682 fprintf (file, _(" transfer addr psect: %u\n"),
5683 (unsigned)bfd_getl32 (eeom->psindx));
5684 fprintf (file, _(" transfer address : 0x%08x\n"),
5685 (unsigned)bfd_getl32 (eeom->tfradr));
5690 exav_bfd_print_egsy_flags (unsigned int flags, FILE *file)
5692 if (flags & EGSY__V_WEAK)
5693 fputs (_(" WEAK"), file);
5694 if (flags & EGSY__V_DEF)
5695 fputs (_(" DEF"), file);
5696 if (flags & EGSY__V_UNI)
5697 fputs (_(" UNI"), file);
5698 if (flags & EGSY__V_REL)
5699 fputs (_(" REL"), file);
5700 if (flags & EGSY__V_COMM)
5701 fputs (_(" COMM"), file);
5702 if (flags & EGSY__V_VECEP)
5703 fputs (_(" VECEP"), file);
5704 if (flags & EGSY__V_NORM)
5705 fputs (_(" NORM"), file);
5706 if (flags & EGSY__V_QUAD_VAL)
5707 fputs (_(" QVAL"), file);
5711 evax_bfd_print_egsd_flags (FILE *file, unsigned int flags)
5713 if (flags & EGPS__V_PIC)
5714 fputs (_(" PIC"), file);
5715 if (flags & EGPS__V_LIB)
5716 fputs (_(" LIB"), file);
5717 if (flags & EGPS__V_OVR)
5718 fputs (_(" OVR"), file);
5719 if (flags & EGPS__V_REL)
5720 fputs (_(" REL"), file);
5721 if (flags & EGPS__V_GBL)
5722 fputs (_(" GBL"), file);
5723 if (flags & EGPS__V_SHR)
5724 fputs (_(" SHR"), file);
5725 if (flags & EGPS__V_EXE)
5726 fputs (_(" EXE"), file);
5727 if (flags & EGPS__V_RD)
5728 fputs (_(" RD"), file);
5729 if (flags & EGPS__V_WRT)
5730 fputs (_(" WRT"), file);
5731 if (flags & EGPS__V_VEC)
5732 fputs (_(" VEC"), file);
5733 if (flags & EGPS__V_NOMOD)
5734 fputs (_(" NOMOD"), file);
5735 if (flags & EGPS__V_COM)
5736 fputs (_(" COM"), file);
5737 if (flags & EGPS__V_ALLOC_64BIT)
5738 fputs (_(" 64B"), file);
5742 evax_bfd_print_egsd (FILE *file, unsigned char *rec, unsigned int rec_len)
5744 unsigned int off = sizeof (struct vms_egsd);
5747 fprintf (file, _(" EGSD (len=%u):\n"), rec_len);
5750 for (off = sizeof (struct vms_egsd); off < rec_len; )
5752 struct vms_egsd_entry *e = (struct vms_egsd_entry *)(rec + off);
5756 type = (unsigned)bfd_getl16 (e->gsdtyp);
5757 len = (unsigned)bfd_getl16 (e->gsdsiz);
5759 /* xgettext:c-format */
5760 fprintf (file, _(" EGSD entry %2u (type: %u, len: %u): "),
5768 struct vms_egps *egps = (struct vms_egps *)e;
5769 unsigned int flags = bfd_getl16 (egps->flags);
5772 fprintf (file, _("PSC - Program section definition\n"));
5773 fprintf (file, _(" alignment : 2**%u\n"), egps->align);
5774 fprintf (file, _(" flags : 0x%04x"), flags);
5775 evax_bfd_print_egsd_flags (file, flags);
5777 l = bfd_getl32 (egps->alloc);
5778 fprintf (file, _(" alloc (len): %u (0x%08x)\n"), l, l);
5779 fprintf (file, _(" name : %.*s\n"),
5780 egps->namlng, egps->name);
5785 struct vms_esgps *esgps = (struct vms_esgps *)e;
5786 unsigned int flags = bfd_getl16 (esgps->flags);
5789 fprintf (file, _("SPSC - Shared Image Program section def\n"));
5790 fprintf (file, _(" alignment : 2**%u\n"), esgps->align);
5791 fprintf (file, _(" flags : 0x%04x"), flags);
5792 evax_bfd_print_egsd_flags (file, flags);
5794 l = bfd_getl32 (esgps->alloc);
5795 fprintf (file, _(" alloc (len) : %u (0x%08x)\n"), l, l);
5796 fprintf (file, _(" image offset : 0x%08x\n"),
5797 (unsigned int)bfd_getl32 (esgps->base));
5798 fprintf (file, _(" symvec offset : 0x%08x\n"),
5799 (unsigned int)bfd_getl32 (esgps->value));
5800 fprintf (file, _(" name : %.*s\n"),
5801 esgps->namlng, esgps->name);
5806 struct vms_egsy *egsy = (struct vms_egsy *)e;
5807 unsigned int flags = bfd_getl16 (egsy->flags);
5809 if (flags & EGSY__V_DEF)
5811 struct vms_esdf *esdf = (struct vms_esdf *)e;
5813 fprintf (file, _("SYM - Global symbol definition\n"));
5814 fprintf (file, _(" flags: 0x%04x"), flags);
5815 exav_bfd_print_egsy_flags (flags, file);
5817 fprintf (file, _(" psect offset: 0x%08x\n"),
5818 (unsigned)bfd_getl32 (esdf->value));
5819 if (flags & EGSY__V_NORM)
5821 fprintf (file, _(" code address: 0x%08x\n"),
5822 (unsigned)bfd_getl32 (esdf->code_address));
5823 fprintf (file, _(" psect index for entry point : %u\n"),
5824 (unsigned)bfd_getl32 (esdf->ca_psindx));
5826 fprintf (file, _(" psect index : %u\n"),
5827 (unsigned)bfd_getl32 (esdf->psindx));
5828 fprintf (file, _(" name : %.*s\n"),
5829 esdf->namlng, esdf->name);
5833 struct vms_esrf *esrf = (struct vms_esrf *)e;
5835 fprintf (file, _("SYM - Global symbol reference\n"));
5836 fprintf (file, _(" name : %.*s\n"),
5837 esrf->namlng, esrf->name);
5843 struct vms_eidc *eidc = (struct vms_eidc *)e;
5844 unsigned int flags = bfd_getl32 (eidc->flags);
5847 fprintf (file, _("IDC - Ident Consistency check\n"));
5848 fprintf (file, _(" flags : 0x%08x"), flags);
5849 if (flags & EIDC__V_BINIDENT)
5850 fputs (" BINDENT", file);
5852 fprintf (file, _(" id match : %x\n"),
5853 (flags >> EIDC__V_IDMATCH_SH) & EIDC__V_IDMATCH_MASK);
5854 fprintf (file, _(" error severity: %x\n"),
5855 (flags >> EIDC__V_ERRSEV_SH) & EIDC__V_ERRSEV_MASK);
5857 fprintf (file, _(" entity name : %.*s\n"), p[0], p + 1);
5859 fprintf (file, _(" object name : %.*s\n"), p[0], p + 1);
5861 if (flags & EIDC__V_BINIDENT)
5862 fprintf (file, _(" binary ident : 0x%08x\n"),
5863 (unsigned)bfd_getl32 (p + 1));
5865 fprintf (file, _(" ascii ident : %.*s\n"), p[0], p + 1);
5870 struct vms_egst *egst = (struct vms_egst *)e;
5871 unsigned int flags = bfd_getl16 (egst->header.flags);
5873 fprintf (file, _("SYMG - Universal symbol definition\n"));
5874 fprintf (file, _(" flags: 0x%04x"), flags);
5875 exav_bfd_print_egsy_flags (flags, file);
5877 fprintf (file, _(" symbol vector offset: 0x%08x\n"),
5878 (unsigned)bfd_getl32 (egst->value));
5879 fprintf (file, _(" entry point: 0x%08x\n"),
5880 (unsigned)bfd_getl32 (egst->lp_1));
5881 fprintf (file, _(" proc descr : 0x%08x\n"),
5882 (unsigned)bfd_getl32 (egst->lp_2));
5883 fprintf (file, _(" psect index: %u\n"),
5884 (unsigned)bfd_getl32 (egst->psindx));
5885 fprintf (file, _(" name : %.*s\n"),
5886 egst->namlng, egst->name);
5891 struct vms_esdfv *esdfv = (struct vms_esdfv *)e;
5892 unsigned int flags = bfd_getl16 (esdfv->flags);
5894 fprintf (file, _("SYMV - Vectored symbol definition\n"));
5895 fprintf (file, _(" flags: 0x%04x"), flags);
5896 exav_bfd_print_egsy_flags (flags, file);
5898 fprintf (file, _(" vector : 0x%08x\n"),
5899 (unsigned)bfd_getl32 (esdfv->vector));
5900 fprintf (file, _(" psect offset: %u\n"),
5901 (unsigned)bfd_getl32 (esdfv->value));
5902 fprintf (file, _(" psect index : %u\n"),
5903 (unsigned)bfd_getl32 (esdfv->psindx));
5904 fprintf (file, _(" name : %.*s\n"),
5905 esdfv->namlng, esdfv->name);
5910 struct vms_esdfm *esdfm = (struct vms_esdfm *)e;
5911 unsigned int flags = bfd_getl16 (esdfm->flags);
5913 fprintf (file, _("SYMM - Global symbol definition with version\n"));
5914 fprintf (file, _(" flags: 0x%04x"), flags);
5915 exav_bfd_print_egsy_flags (flags, file);
5917 fprintf (file, _(" version mask: 0x%08x\n"),
5918 (unsigned)bfd_getl32 (esdfm->version_mask));
5919 fprintf (file, _(" psect offset: %u\n"),
5920 (unsigned)bfd_getl32 (esdfm->value));
5921 fprintf (file, _(" psect index : %u\n"),
5922 (unsigned)bfd_getl32 (esdfm->psindx));
5923 fprintf (file, _(" name : %.*s\n"),
5924 esdfm->namlng, esdfm->name);
5928 fprintf (file, _("unhandled egsd entry type %u\n"), type);
5936 evax_bfd_print_hex (FILE *file, const char *pfx,
5937 const unsigned char *buf, unsigned int len)
5943 for (i = 0; i < len; i++)
5947 fprintf (file, " %02x", buf[i]);
5960 evax_bfd_print_etir_stc_ir (FILE *file, const unsigned char *buf, int is_ps)
5962 /* xgettext:c-format */
5963 fprintf (file, _(" linkage index: %u, replacement insn: 0x%08x\n"),
5964 (unsigned)bfd_getl32 (buf),
5965 (unsigned)bfd_getl32 (buf + 16));
5966 /* xgettext:c-format */
5967 fprintf (file, _(" psect idx 1: %u, offset 1: 0x%08x %08x\n"),
5968 (unsigned)bfd_getl32 (buf + 4),
5969 (unsigned)bfd_getl32 (buf + 12),
5970 (unsigned)bfd_getl32 (buf + 8));
5971 /* xgettext:c-format */
5972 fprintf (file, _(" psect idx 2: %u, offset 2: 0x%08x %08x\n"),
5973 (unsigned)bfd_getl32 (buf + 20),
5974 (unsigned)bfd_getl32 (buf + 28),
5975 (unsigned)bfd_getl32 (buf + 24));
5977 /* xgettext:c-format */
5978 fprintf (file, _(" psect idx 3: %u, offset 3: 0x%08x %08x\n"),
5979 (unsigned)bfd_getl32 (buf + 32),
5980 (unsigned)bfd_getl32 (buf + 40),
5981 (unsigned)bfd_getl32 (buf + 36));
5983 fprintf (file, _(" global name: %.*s\n"), buf[32], buf + 33);
5987 evax_bfd_print_etir (FILE *file, const char *name,
5988 unsigned char *rec, unsigned int rec_len)
5990 unsigned int off = sizeof (struct vms_egsd);
5991 unsigned int sec_len = 0;
5993 /* xgettext:c-format */
5994 fprintf (file, _(" %s (len=%u+%u):\n"), name,
5995 (unsigned)(rec_len - sizeof (struct vms_eobjrec)),
5996 (unsigned)sizeof (struct vms_eobjrec));
5998 for (off = sizeof (struct vms_eobjrec); off < rec_len; )
6000 struct vms_etir *etir = (struct vms_etir *)(rec + off);
6005 type = bfd_getl16 (etir->rectyp);
6006 size = bfd_getl16 (etir->size);
6007 buf = rec + off + sizeof (struct vms_etir);
6009 /* xgettext:c-format */
6010 fprintf (file, _(" (type: %3u, size: 4+%3u): "), type, size - 4);
6013 case ETIR__C_STA_GBL:
6014 fprintf (file, _("STA_GBL (stack global) %.*s\n"),
6017 case ETIR__C_STA_LW:
6018 fprintf (file, _("STA_LW (stack longword) 0x%08x\n"),
6019 (unsigned)bfd_getl32 (buf));
6021 case ETIR__C_STA_QW:
6022 fprintf (file, _("STA_QW (stack quadword) 0x%08x %08x\n"),
6023 (unsigned)bfd_getl32 (buf + 4),
6024 (unsigned)bfd_getl32 (buf + 0));
6026 case ETIR__C_STA_PQ:
6027 fprintf (file, _("STA_PQ (stack psect base + offset)\n"));
6028 /* xgettext:c-format */
6029 fprintf (file, _(" psect: %u, offset: 0x%08x %08x\n"),
6030 (unsigned)bfd_getl32 (buf + 0),
6031 (unsigned)bfd_getl32 (buf + 8),
6032 (unsigned)bfd_getl32 (buf + 4));
6034 case ETIR__C_STA_LI:
6035 fprintf (file, _("STA_LI (stack literal)\n"));
6037 case ETIR__C_STA_MOD:
6038 fprintf (file, _("STA_MOD (stack module)\n"));
6040 case ETIR__C_STA_CKARG:
6041 fprintf (file, _("STA_CKARG (compare procedure argument)\n"));
6045 fprintf (file, _("STO_B (store byte)\n"));
6048 fprintf (file, _("STO_W (store word)\n"));
6050 case ETIR__C_STO_LW:
6051 fprintf (file, _("STO_LW (store longword)\n"));
6053 case ETIR__C_STO_QW:
6054 fprintf (file, _("STO_QW (store quadword)\n"));
6056 case ETIR__C_STO_IMMR:
6058 unsigned int len = bfd_getl32 (buf);
6060 _("STO_IMMR (store immediate repeat) %u bytes\n"),
6062 evax_bfd_print_hex (file, " ", buf + 4, len);
6066 case ETIR__C_STO_GBL:
6067 fprintf (file, _("STO_GBL (store global) %.*s\n"),
6070 case ETIR__C_STO_CA:
6071 fprintf (file, _("STO_CA (store code address) %.*s\n"),
6074 case ETIR__C_STO_RB:
6075 fprintf (file, _("STO_RB (store relative branch)\n"));
6077 case ETIR__C_STO_AB:
6078 fprintf (file, _("STO_AB (store absolute branch)\n"));
6080 case ETIR__C_STO_OFF:
6081 fprintf (file, _("STO_OFF (store offset to psect)\n"));
6083 case ETIR__C_STO_IMM:
6085 unsigned int len = bfd_getl32 (buf);
6087 _("STO_IMM (store immediate) %u bytes\n"),
6089 evax_bfd_print_hex (file, " ", buf + 4, len);
6093 case ETIR__C_STO_GBL_LW:
6094 fprintf (file, _("STO_GBL_LW (store global longword) %.*s\n"),
6097 case ETIR__C_STO_LP_PSB:
6098 fprintf (file, _("STO_OFF (store LP with procedure signature)\n"));
6100 case ETIR__C_STO_HINT_GBL:
6101 fprintf (file, _("STO_BR_GBL (store branch global) *todo*\n"));
6103 case ETIR__C_STO_HINT_PS:
6104 fprintf (file, _("STO_BR_PS (store branch psect + offset) *todo*\n"));
6107 case ETIR__C_OPR_NOP:
6108 fprintf (file, _("OPR_NOP (no-operation)\n"));
6110 case ETIR__C_OPR_ADD:
6111 fprintf (file, _("OPR_ADD (add)\n"));
6113 case ETIR__C_OPR_SUB:
6114 fprintf (file, _("OPR_SUB (substract)\n"));
6116 case ETIR__C_OPR_MUL:
6117 fprintf (file, _("OPR_MUL (multiply)\n"));
6119 case ETIR__C_OPR_DIV:
6120 fprintf (file, _("OPR_DIV (divide)\n"));
6122 case ETIR__C_OPR_AND:
6123 fprintf (file, _("OPR_AND (logical and)\n"));
6125 case ETIR__C_OPR_IOR:
6126 fprintf (file, _("OPR_IOR (logical inclusive or)\n"));
6128 case ETIR__C_OPR_EOR:
6129 fprintf (file, _("OPR_EOR (logical exclusive or)\n"));
6131 case ETIR__C_OPR_NEG:
6132 fprintf (file, _("OPR_NEG (negate)\n"));
6134 case ETIR__C_OPR_COM:
6135 fprintf (file, _("OPR_COM (complement)\n"));
6137 case ETIR__C_OPR_INSV:
6138 fprintf (file, _("OPR_INSV (insert field)\n"));
6140 case ETIR__C_OPR_ASH:
6141 fprintf (file, _("OPR_ASH (arithmetic shift)\n"));
6143 case ETIR__C_OPR_USH:
6144 fprintf (file, _("OPR_USH (unsigned shift)\n"));
6146 case ETIR__C_OPR_ROT:
6147 fprintf (file, _("OPR_ROT (rotate)\n"));
6149 case ETIR__C_OPR_SEL:
6150 fprintf (file, _("OPR_SEL (select)\n"));
6152 case ETIR__C_OPR_REDEF:
6153 fprintf (file, _("OPR_REDEF (redefine symbol to curr location)\n"));
6155 case ETIR__C_OPR_DFLIT:
6156 fprintf (file, _("OPR_REDEF (define a literal)\n"));
6159 case ETIR__C_STC_LP:
6160 fprintf (file, _("STC_LP (store cond linkage pair)\n"));
6162 case ETIR__C_STC_LP_PSB:
6164 _("STC_LP_PSB (store cond linkage pair + signature)\n"));
6165 /* xgettext:c-format */
6166 fprintf (file, _(" linkage index: %u, procedure: %.*s\n"),
6167 (unsigned)bfd_getl32 (buf), buf[4], buf + 5);
6168 buf += 4 + 1 + buf[4];
6169 fprintf (file, _(" signature: %.*s\n"), buf[0], buf + 1);
6171 case ETIR__C_STC_GBL:
6172 fprintf (file, _("STC_GBL (store cond global)\n"));
6173 /* xgettext:c-format */
6174 fprintf (file, _(" linkage index: %u, global: %.*s\n"),
6175 (unsigned)bfd_getl32 (buf), buf[4], buf + 5);
6177 case ETIR__C_STC_GCA:
6178 fprintf (file, _("STC_GCA (store cond code address)\n"));
6179 /* xgettext:c-format */
6180 fprintf (file, _(" linkage index: %u, procedure name: %.*s\n"),
6181 (unsigned)bfd_getl32 (buf), buf[4], buf + 5);
6183 case ETIR__C_STC_PS:
6184 fprintf (file, _("STC_PS (store cond psect + offset)\n"));
6186 /* xgettext:c-format */
6187 _(" linkage index: %u, psect: %u, offset: 0x%08x %08x\n"),
6188 (unsigned)bfd_getl32 (buf),
6189 (unsigned)bfd_getl32 (buf + 4),
6190 (unsigned)bfd_getl32 (buf + 12),
6191 (unsigned)bfd_getl32 (buf + 8));
6193 case ETIR__C_STC_NOP_GBL:
6194 fprintf (file, _("STC_NOP_GBL (store cond NOP at global addr)\n"));
6195 evax_bfd_print_etir_stc_ir (file, buf, 0);
6197 case ETIR__C_STC_NOP_PS:
6198 fprintf (file, _("STC_NOP_PS (store cond NOP at psect + offset)\n"));
6199 evax_bfd_print_etir_stc_ir (file, buf, 1);
6201 case ETIR__C_STC_BSR_GBL:
6202 fprintf (file, _("STC_BSR_GBL (store cond BSR at global addr)\n"));
6203 evax_bfd_print_etir_stc_ir (file, buf, 0);
6205 case ETIR__C_STC_BSR_PS:
6206 fprintf (file, _("STC_BSR_PS (store cond BSR at psect + offset)\n"));
6207 evax_bfd_print_etir_stc_ir (file, buf, 1);
6209 case ETIR__C_STC_LDA_GBL:
6210 fprintf (file, _("STC_LDA_GBL (store cond LDA at global addr)\n"));
6211 evax_bfd_print_etir_stc_ir (file, buf, 0);
6213 case ETIR__C_STC_LDA_PS:
6214 fprintf (file, _("STC_LDA_PS (store cond LDA at psect + offset)\n"));
6215 evax_bfd_print_etir_stc_ir (file, buf, 1);
6217 case ETIR__C_STC_BOH_GBL:
6218 fprintf (file, _("STC_BOH_GBL (store cond BOH at global addr)\n"));
6219 evax_bfd_print_etir_stc_ir (file, buf, 0);
6221 case ETIR__C_STC_BOH_PS:
6222 fprintf (file, _("STC_BOH_PS (store cond BOH at psect + offset)\n"));
6223 evax_bfd_print_etir_stc_ir (file, buf, 1);
6225 case ETIR__C_STC_NBH_GBL:
6227 _("STC_NBH_GBL (store cond or hint at global addr)\n"));
6229 case ETIR__C_STC_NBH_PS:
6231 _("STC_NBH_PS (store cond or hint at psect + offset)\n"));
6234 case ETIR__C_CTL_SETRB:
6235 fprintf (file, _("CTL_SETRB (set relocation base)\n"));
6238 case ETIR__C_CTL_AUGRB:
6240 unsigned int val = bfd_getl32 (buf);
6241 fprintf (file, _("CTL_AUGRB (augment relocation base) %u\n"), val);
6244 case ETIR__C_CTL_DFLOC:
6245 fprintf (file, _("CTL_DFLOC (define location)\n"));
6247 case ETIR__C_CTL_STLOC:
6248 fprintf (file, _("CTL_STLOC (set location)\n"));
6250 case ETIR__C_CTL_STKDL:
6251 fprintf (file, _("CTL_STKDL (stack defined location)\n"));
6254 fprintf (file, _("*unhandled*\n"));
6262 evax_bfd_print_eobj (struct bfd *abfd, FILE *file)
6264 bfd_boolean is_first = TRUE;
6265 bfd_boolean has_records = FALSE;
6269 unsigned int rec_len;
6270 unsigned int pad_len;
6272 unsigned int hdr_size;
6277 unsigned char buf[6];
6282 if (bfd_bread (buf, sizeof (buf), abfd) != sizeof (buf))
6284 fprintf (file, _("cannot read GST record length\n"));
6287 rec_len = bfd_getl16 (buf + 0);
6288 if (rec_len == bfd_getl16 (buf + 4)
6289 && bfd_getl16 (buf + 2) == EOBJ__C_EMH)
6291 /* The format is raw: record-size, type, record-size. */
6293 pad_len = (rec_len + 1) & ~1U;
6296 else if (rec_len == EOBJ__C_EMH)
6298 has_records = FALSE;
6299 pad_len = bfd_getl16 (buf + 2);
6305 fprintf (file, _("cannot find EMH in first GST record\n"));
6308 rec = bfd_malloc (pad_len);
6309 memcpy (rec, buf + sizeof (buf) - hdr_size, hdr_size);
6313 unsigned int rec_len2 = 0;
6314 unsigned char hdr[4];
6318 unsigned char buf_len[2];
6320 if (bfd_bread (buf_len, sizeof (buf_len), abfd)
6321 != sizeof (buf_len))
6323 fprintf (file, _("cannot read GST record length\n"));
6326 rec_len2 = (unsigned)bfd_getl16 (buf_len);
6329 if (bfd_bread (hdr, sizeof (hdr), abfd) != sizeof (hdr))
6331 fprintf (file, _("cannot read GST record header\n"));
6334 rec_len = (unsigned)bfd_getl16 (hdr + 2);
6336 pad_len = (rec_len + 1) & ~1U;
6339 rec = bfd_malloc (pad_len);
6340 memcpy (rec, hdr, sizeof (hdr));
6341 hdr_size = sizeof (hdr);
6342 if (has_records && rec_len2 != rec_len)
6344 fprintf (file, _(" corrupted GST\n"));
6349 if (bfd_bread (rec + hdr_size, pad_len - hdr_size, abfd)
6350 != pad_len - hdr_size)
6352 fprintf (file, _("cannot read GST record\n"));
6356 type = (unsigned)bfd_getl16 (rec);
6361 evax_bfd_print_emh (file, rec, rec_len);
6364 evax_bfd_print_egsd (file, rec, rec_len);
6367 evax_bfd_print_eeom (file, rec, rec_len);
6372 evax_bfd_print_etir (file, "ETIR", rec, rec_len);
6375 evax_bfd_print_etir (file, "EDBG", rec, rec_len);
6378 evax_bfd_print_etir (file, "ETBT", rec, rec_len);
6381 fprintf (file, _(" unhandled EOBJ record type %u\n"), type);
6389 evax_bfd_print_relocation_records (FILE *file, const unsigned char *rel,
6390 unsigned int stride)
6398 count = bfd_getl32 (rel + 0);
6402 base = bfd_getl32 (rel + 4);
6404 /* xgettext:c-format */
6405 fprintf (file, _(" bitcount: %u, base addr: 0x%08x\n"),
6409 for (j = 0; count > 0; j += 4, count -= 32)
6415 val = bfd_getl32 (rel);
6418 /* xgettext:c-format */
6419 fprintf (file, _(" bitmap: 0x%08x (count: %u):\n"), val, count);
6421 for (k = 0; k < 32; k++)
6426 fprintf (file, _(" %08x"), base + (j * 8 + k) * stride);
6441 evax_bfd_print_address_fixups (FILE *file, const unsigned char *rel)
6448 count = bfd_getl32 (rel + 0);
6451 /* xgettext:c-format */
6452 fprintf (file, _(" image %u (%u entries)\n"),
6453 (unsigned)bfd_getl32 (rel + 4), count);
6455 for (j = 0; j < count; j++)
6457 /* xgettext:c-format */
6458 fprintf (file, _(" offset: 0x%08x, val: 0x%08x\n"),
6459 (unsigned)bfd_getl32 (rel + 0),
6460 (unsigned)bfd_getl32 (rel + 4));
6467 evax_bfd_print_reference_fixups (FILE *file, const unsigned char *rel)
6476 count = bfd_getl32 (rel + 0);
6479 /* xgettext:c-format */
6480 fprintf (file, _(" image %u (%u entries), offsets:\n"),
6481 (unsigned)bfd_getl32 (rel + 4), count);
6483 for (j = 0; j < count; j++)
6487 fprintf (file, _(" 0x%08x"), (unsigned)bfd_getl32 (rel));
6502 evax_bfd_print_indent (int indent, FILE *file)
6504 for (; indent; indent--)
6509 evax_bfd_get_dsc_name (unsigned int v)
6513 case DSC__K_DTYPE_Z:
6514 return "Z (Unspecified)";
6515 case DSC__K_DTYPE_V:
6517 case DSC__K_DTYPE_BU:
6518 return "BU (Byte logical)";
6519 case DSC__K_DTYPE_WU:
6520 return "WU (Word logical)";
6521 case DSC__K_DTYPE_LU:
6522 return "LU (Longword logical)";
6523 case DSC__K_DTYPE_QU:
6524 return "QU (Quadword logical)";
6525 case DSC__K_DTYPE_B:
6526 return "B (Byte integer)";
6527 case DSC__K_DTYPE_W:
6528 return "W (Word integer)";
6529 case DSC__K_DTYPE_L:
6530 return "L (Longword integer)";
6531 case DSC__K_DTYPE_Q:
6532 return "Q (Quadword integer)";
6533 case DSC__K_DTYPE_F:
6534 return "F (Single-precision floating)";
6535 case DSC__K_DTYPE_D:
6536 return "D (Double-precision floating)";
6537 case DSC__K_DTYPE_FC:
6538 return "FC (Complex)";
6539 case DSC__K_DTYPE_DC:
6540 return "DC (Double-precision Complex)";
6541 case DSC__K_DTYPE_T:
6542 return "T (ASCII text string)";
6543 case DSC__K_DTYPE_NU:
6544 return "NU (Numeric string, unsigned)";
6545 case DSC__K_DTYPE_NL:
6546 return "NL (Numeric string, left separate sign)";
6547 case DSC__K_DTYPE_NLO:
6548 return "NLO (Numeric string, left overpunched sign)";
6549 case DSC__K_DTYPE_NR:
6550 return "NR (Numeric string, right separate sign)";
6551 case DSC__K_DTYPE_NRO:
6552 return "NRO (Numeric string, right overpunched sig)";
6553 case DSC__K_DTYPE_NZ:
6554 return "NZ (Numeric string, zoned sign)";
6555 case DSC__K_DTYPE_P:
6556 return "P (Packed decimal string)";
6557 case DSC__K_DTYPE_ZI:
6558 return "ZI (Sequence of instructions)";
6559 case DSC__K_DTYPE_ZEM:
6560 return "ZEM (Procedure entry mask)";
6561 case DSC__K_DTYPE_DSC:
6562 return "DSC (Descriptor, used for arrays of dyn strings)";
6563 case DSC__K_DTYPE_OU:
6564 return "OU (Octaword logical)";
6565 case DSC__K_DTYPE_O:
6566 return "O (Octaword integer)";
6567 case DSC__K_DTYPE_G:
6568 return "G (Double precision G floating, 64 bit)";
6569 case DSC__K_DTYPE_H:
6570 return "H (Quadruple precision floating, 128 bit)";
6571 case DSC__K_DTYPE_GC:
6572 return "GC (Double precision complex, G floating)";
6573 case DSC__K_DTYPE_HC:
6574 return "HC (Quadruple precision complex, H floating)";
6575 case DSC__K_DTYPE_CIT:
6576 return "CIT (COBOL intermediate temporary)";
6577 case DSC__K_DTYPE_BPV:
6578 return "BPV (Bound Procedure Value)";
6579 case DSC__K_DTYPE_BLV:
6580 return "BLV (Bound Label Value)";
6581 case DSC__K_DTYPE_VU:
6582 return "VU (Bit Unaligned)";
6583 case DSC__K_DTYPE_ADT:
6584 return "ADT (Absolute Date-Time)";
6585 case DSC__K_DTYPE_VT:
6586 return "VT (Varying Text)";
6587 case DSC__K_DTYPE_T2:
6588 return "T2 (16-bit char)";
6589 case DSC__K_DTYPE_VT2:
6590 return "VT2 (16-bit varying char)";
6592 return "?? (unknown)";
6597 evax_bfd_print_desc (const unsigned char *buf, int indent, FILE *file)
6599 unsigned char bclass = buf[3];
6600 unsigned char dtype = buf[2];
6601 unsigned int len = (unsigned)bfd_getl16 (buf);
6602 unsigned int pointer = (unsigned)bfd_getl32 (buf + 4);
6604 evax_bfd_print_indent (indent, file);
6606 if (len == 1 && pointer == 0xffffffffUL)
6609 fprintf (file, _("64 bits *unhandled*\n"));
6613 /* xgettext:c-format */
6614 fprintf (file, _("class: %u, dtype: %u, length: %u, pointer: 0x%08x\n"),
6615 bclass, dtype, len, pointer);
6618 case DSC__K_CLASS_NCA:
6620 const struct vms_dsc_nca *dsc = (const void *)buf;
6622 const unsigned char *b;
6624 evax_bfd_print_indent (indent, file);
6625 fprintf (file, _("non-contiguous array of %s\n"),
6626 evax_bfd_get_dsc_name (dsc->dtype));
6627 evax_bfd_print_indent (indent + 1, file);
6629 /* xgettext:c-format */
6630 _("dimct: %u, aflags: 0x%02x, digits: %u, scale: %u\n"),
6631 dsc->dimct, dsc->aflags, dsc->digits, dsc->scale);
6632 evax_bfd_print_indent (indent + 1, file);
6634 /* xgettext:c-format */
6635 _("arsize: %u, a0: 0x%08x\n"),
6636 (unsigned)bfd_getl32 (dsc->arsize),
6637 (unsigned)bfd_getl32 (dsc->a0));
6638 evax_bfd_print_indent (indent + 1, file);
6639 fprintf (file, _("Strides:\n"));
6640 b = buf + sizeof (*dsc);
6641 for (i = 0; i < dsc->dimct; i++)
6643 evax_bfd_print_indent (indent + 2, file);
6644 fprintf (file, "[%u]: %u\n", i + 1,
6645 (unsigned)bfd_getl32 (b));
6648 evax_bfd_print_indent (indent + 1, file);
6649 fprintf (file, _("Bounds:\n"));
6650 b = buf + sizeof (*dsc);
6651 for (i = 0; i < dsc->dimct; i++)
6653 evax_bfd_print_indent (indent + 2, file);
6654 /* xgettext:c-format */
6655 fprintf (file, _("[%u]: Lower: %u, upper: %u\n"), i + 1,
6656 (unsigned)bfd_getl32 (b + 0),
6657 (unsigned)bfd_getl32 (b + 4));
6662 case DSC__K_CLASS_UBS:
6664 const struct vms_dsc_ubs *ubs = (const void *)buf;
6666 evax_bfd_print_indent (indent, file);
6667 fprintf (file, _("unaligned bit-string of %s\n"),
6668 evax_bfd_get_dsc_name (ubs->dtype));
6669 evax_bfd_print_indent (indent + 1, file);
6671 /* xgettext:c-format */
6672 _("base: %u, pos: %u\n"),
6673 (unsigned)bfd_getl32 (ubs->base),
6674 (unsigned)bfd_getl32 (ubs->pos));
6678 fprintf (file, _("*unhandled*\n"));
6685 evax_bfd_print_valspec (const unsigned char *buf, int indent, FILE *file)
6687 unsigned int vflags = buf[0];
6688 unsigned int value = (unsigned)bfd_getl32 (buf + 1);
6689 unsigned int len = 5;
6691 evax_bfd_print_indent (indent, file);
6692 /* xgettext:c-format */
6693 fprintf (file, _("vflags: 0x%02x, value: 0x%08x "), vflags, value);
6698 case DST__K_VFLAGS_NOVAL:
6699 fprintf (file, _("(no value)\n"));
6701 case DST__K_VFLAGS_NOTACTIVE:
6702 fprintf (file, _("(not active)\n"));
6704 case DST__K_VFLAGS_UNALLOC:
6705 fprintf (file, _("(not allocated)\n"));
6707 case DST__K_VFLAGS_DSC:
6708 fprintf (file, _("(descriptor)\n"));
6709 evax_bfd_print_desc (buf + value, indent + 1, file);
6711 case DST__K_VFLAGS_TVS:
6712 fprintf (file, _("(trailing value)\n"));
6714 case DST__K_VS_FOLLOWS:
6715 fprintf (file, _("(value spec follows)\n"));
6717 case DST__K_VFLAGS_BITOFFS:
6718 fprintf (file, _("(at bit offset %u)\n"), value);
6721 /* xgettext:c-format */
6722 fprintf (file, _("(reg: %u, disp: %u, indir: %u, kind: "),
6723 (vflags & DST__K_REGNUM_MASK) >> DST__K_REGNUM_SHIFT,
6724 vflags & DST__K_DISP ? 1 : 0,
6725 vflags & DST__K_INDIR ? 1 : 0);
6726 switch (vflags & DST__K_VALKIND_MASK)
6728 case DST__K_VALKIND_LITERAL:
6729 fputs (_("literal"), file);
6731 case DST__K_VALKIND_ADDR:
6732 fputs (_("address"), file);
6734 case DST__K_VALKIND_DESC:
6735 fputs (_("desc"), file);
6737 case DST__K_VALKIND_REG:
6738 fputs (_("reg"), file);
6741 fputs (")\n", file);
6748 evax_bfd_print_typspec (const unsigned char *buf, int indent, FILE *file)
6750 unsigned char kind = buf[2];
6751 unsigned int len = (unsigned)bfd_getl16 (buf);
6753 evax_bfd_print_indent (indent, file);
6754 /* xgettext:c-format */
6755 fprintf (file, _("len: %2u, kind: %2u "), len, kind);
6759 case DST__K_TS_ATOM:
6760 /* xgettext:c-format */
6761 fprintf (file, _("atomic, type=0x%02x %s\n"),
6762 buf[0], evax_bfd_get_dsc_name (buf[0]));
6765 fprintf (file, _("indirect, defined at 0x%08x\n"),
6766 (unsigned)bfd_getl32 (buf));
6768 case DST__K_TS_TPTR:
6769 fprintf (file, _("typed pointer\n"));
6770 evax_bfd_print_typspec (buf, indent + 1, file);
6773 fprintf (file, _("pointer\n"));
6775 case DST__K_TS_ARRAY:
6777 const unsigned char *vs;
6778 unsigned int vec_len;
6781 fprintf (file, _("array, dim: %u, bitmap: "), buf[0]);
6782 vec_len = (buf[0] + 1 + 7) / 8;
6783 for (i = 0; i < vec_len; i++)
6784 fprintf (file, " %02x", buf[i + 1]);
6786 vs = buf + 1 + vec_len;
6787 evax_bfd_print_indent (indent, file);
6788 fprintf (file, _("array descriptor:\n"));
6789 vs += evax_bfd_print_valspec (vs, indent + 1, file);
6790 for (i = 0; i < buf[0] + 1U; i++)
6791 if (buf[1 + i / 8] & (1 << (i % 8)))
6793 evax_bfd_print_indent (indent, file);
6795 fprintf (file, _("type spec for element:\n"));
6797 fprintf (file, _("type spec for subscript %u:\n"), i);
6798 evax_bfd_print_typspec (vs, indent + 1, file);
6799 vs += bfd_getl16 (vs);
6804 fprintf (file, _("*unhandled*\n"));
6809 evax_bfd_print_dst (struct bfd *abfd, unsigned int dst_size, FILE *file)
6811 unsigned int off = 0;
6812 unsigned int pc = 0;
6813 unsigned int line = 0;
6815 fprintf (file, _("Debug symbol table:\n"));
6817 while (dst_size > 0)
6819 struct vms_dst_header dsth;
6824 if (bfd_bread (&dsth, sizeof (dsth), abfd) != sizeof (dsth))
6826 fprintf (file, _("cannot read DST header\n"));
6829 len = bfd_getl16 (dsth.length);
6830 type = bfd_getl16 (dsth.type);
6831 /* xgettext:c-format */
6832 fprintf (file, _(" type: %3u, len: %3u (at 0x%08x): "),
6842 len -= sizeof (dsth);
6843 buf = bfd_malloc (len);
6844 if (bfd_bread (buf, len, abfd) != len)
6846 fprintf (file, _("cannot read DST symbol\n"));
6851 case DSC__K_DTYPE_V:
6852 case DSC__K_DTYPE_BU:
6853 case DSC__K_DTYPE_WU:
6854 case DSC__K_DTYPE_LU:
6855 case DSC__K_DTYPE_QU:
6856 case DSC__K_DTYPE_B:
6857 case DSC__K_DTYPE_W:
6858 case DSC__K_DTYPE_L:
6859 case DSC__K_DTYPE_Q:
6860 case DSC__K_DTYPE_F:
6861 case DSC__K_DTYPE_D:
6862 case DSC__K_DTYPE_FC:
6863 case DSC__K_DTYPE_DC:
6864 case DSC__K_DTYPE_T:
6865 case DSC__K_DTYPE_NU:
6866 case DSC__K_DTYPE_NL:
6867 case DSC__K_DTYPE_NLO:
6868 case DSC__K_DTYPE_NR:
6869 case DSC__K_DTYPE_NRO:
6870 case DSC__K_DTYPE_NZ:
6871 case DSC__K_DTYPE_P:
6872 case DSC__K_DTYPE_ZI:
6873 case DSC__K_DTYPE_ZEM:
6874 case DSC__K_DTYPE_DSC:
6875 case DSC__K_DTYPE_OU:
6876 case DSC__K_DTYPE_O:
6877 case DSC__K_DTYPE_G:
6878 case DSC__K_DTYPE_H:
6879 case DSC__K_DTYPE_GC:
6880 case DSC__K_DTYPE_HC:
6881 case DSC__K_DTYPE_CIT:
6882 case DSC__K_DTYPE_BPV:
6883 case DSC__K_DTYPE_BLV:
6884 case DSC__K_DTYPE_VU:
6885 case DSC__K_DTYPE_ADT:
6886 case DSC__K_DTYPE_VT:
6887 case DSC__K_DTYPE_T2:
6888 case DSC__K_DTYPE_VT2:
6889 fprintf (file, _("standard data: %s\n"),
6890 evax_bfd_get_dsc_name (type));
6891 evax_bfd_print_valspec (buf, 4, file);
6892 fprintf (file, _(" name: %.*s\n"), buf[5], buf + 6);
6896 struct vms_dst_modbeg *dst = (void *)buf;
6897 const char *name = (const char *)buf + sizeof (*dst);
6899 fprintf (file, _("modbeg\n"));
6900 /* xgettext:c-format */
6901 fprintf (file, _(" flags: %d, language: %u, "
6902 "major: %u, minor: %u\n"),
6904 (unsigned)bfd_getl32 (dst->language),
6905 (unsigned)bfd_getl16 (dst->major),
6906 (unsigned)bfd_getl16 (dst->minor));
6907 fprintf (file, _(" module name: %.*s\n"),
6909 name += name[0] + 1;
6910 fprintf (file, _(" compiler : %.*s\n"),
6915 fprintf (file, _("modend\n"));
6919 struct vms_dst_rtnbeg *dst = (void *)buf;
6920 const char *name = (const char *)buf + sizeof (*dst);
6922 fputs (_("rtnbeg\n"), file);
6923 /* xgettext:c-format */
6924 fprintf (file, _(" flags: %u, address: 0x%08x, "
6925 "pd-address: 0x%08x\n"),
6927 (unsigned)bfd_getl32 (dst->address),
6928 (unsigned)bfd_getl32 (dst->pd_address));
6929 fprintf (file, _(" routine name: %.*s\n"),
6935 struct vms_dst_rtnend *dst = (void *)buf;
6937 fprintf (file, _("rtnend: size 0x%08x\n"),
6938 (unsigned)bfd_getl32 (dst->size));
6943 struct vms_dst_prolog *dst = (void *)buf;
6945 fprintf (file, _("prolog: bkpt address 0x%08x\n"),
6946 (unsigned)bfd_getl32 (dst->bkpt_addr));
6951 struct vms_dst_epilog *dst = (void *)buf;
6953 /* xgettext:c-format */
6954 fprintf (file, _("epilog: flags: %u, count: %u\n"),
6955 dst->flags, (unsigned)bfd_getl32 (dst->count));
6960 struct vms_dst_blkbeg *dst = (void *)buf;
6961 const char *name = (const char *)buf + sizeof (*dst);
6963 /* xgettext:c-format */
6964 fprintf (file, _("blkbeg: address: 0x%08x, name: %.*s\n"),
6965 (unsigned)bfd_getl32 (dst->address),
6971 struct vms_dst_blkend *dst = (void *)buf;
6973 fprintf (file, _("blkend: size: 0x%08x\n"),
6974 (unsigned)bfd_getl32 (dst->size));
6977 case DST__K_TYPSPEC:
6979 fprintf (file, _("typspec (len: %u)\n"), len);
6980 fprintf (file, _(" name: %.*s\n"), buf[0], buf + 1);
6981 evax_bfd_print_typspec (buf + 1 + buf[0], 5, file);
6986 fprintf (file, _("septyp, name: %.*s\n"), buf[5], buf + 6);
6987 evax_bfd_print_valspec (buf, 4, file);
6992 struct vms_dst_recbeg *recbeg = (void *)buf;
6993 const char *name = (const char *)buf + sizeof (*recbeg);
6995 fprintf (file, _("recbeg: name: %.*s\n"), name[0], name + 1);
6996 evax_bfd_print_valspec (buf, 4, file);
6997 fprintf (file, _(" len: %u bits\n"),
6998 (unsigned)bfd_getl32 (name + 1 + name[0]));
7002 fprintf (file, _("recend\n"));
7004 case DST__K_ENUMBEG:
7005 /* xgettext:c-format */
7006 fprintf (file, _("enumbeg, len: %u, name: %.*s\n"),
7007 buf[0], buf[1], buf + 2);
7009 case DST__K_ENUMELT:
7010 fprintf (file, _("enumelt, name: %.*s\n"), buf[5], buf + 6);
7011 evax_bfd_print_valspec (buf, 4, file);
7013 case DST__K_ENUMEND:
7014 fprintf (file, _("enumend\n"));
7018 struct vms_dst_label *lab = (void *)buf;
7019 fprintf (file, _("label, name: %.*s\n"),
7020 lab->name[0], lab->name + 1);
7021 fprintf (file, _(" address: 0x%08x\n"),
7022 (unsigned)bfd_getl32 (lab->value));
7025 case DST__K_DIS_RANGE:
7027 unsigned int cnt = bfd_getl32 (buf);
7028 unsigned char *rng = buf + 4;
7031 fprintf (file, _("discontiguous range (nbr: %u)\n"), cnt);
7032 for (i = 0; i < cnt; i++, rng += 8)
7033 /* xgettext:c-format */
7034 fprintf (file, _(" address: 0x%08x, size: %u\n"),
7035 (unsigned)bfd_getl32 (rng),
7036 (unsigned)bfd_getl32 (rng + 4));
7040 case DST__K_LINE_NUM:
7042 unsigned char *buf_orig = buf;
7044 fprintf (file, _("line num (len: %u)\n"), len);
7049 unsigned char cmdlen;
7059 case DST__K_DELTA_PC_W:
7060 val = bfd_getl16 (buf + 1);
7061 fprintf (file, _("delta_pc_w %u\n"), val);
7066 case DST__K_INCR_LINUM:
7068 fprintf (file, _("incr_linum(b): +%u\n"), val);
7072 case DST__K_INCR_LINUM_W:
7073 val = bfd_getl16 (buf + 1);
7074 fprintf (file, _("incr_linum_w: +%u\n"), val);
7078 case DST__K_INCR_LINUM_L:
7079 val = bfd_getl32 (buf + 1);
7080 fprintf (file, _("incr_linum_l: +%u\n"), val);
7084 case DST__K_SET_LINUM:
7085 line = bfd_getl16 (buf + 1);
7086 fprintf (file, _("set_line_num(w) %u\n"), line);
7089 case DST__K_SET_LINUM_B:
7091 fprintf (file, _("set_line_num_b %u\n"), line);
7094 case DST__K_SET_LINUM_L:
7095 line = bfd_getl32 (buf + 1);
7096 fprintf (file, _("set_line_num_l %u\n"), line);
7099 case DST__K_SET_ABS_PC:
7100 pc = bfd_getl32 (buf + 1);
7101 fprintf (file, _("set_abs_pc: 0x%08x\n"), pc);
7104 case DST__K_DELTA_PC_L:
7105 fprintf (file, _("delta_pc_l: +0x%08x\n"),
7106 (unsigned)bfd_getl32 (buf + 1));
7110 fprintf (file, _("term(b): 0x%02x"), buf[1]);
7112 fprintf (file, _(" pc: 0x%08x\n"), pc);
7116 val = bfd_getl16 (buf + 1);
7117 fprintf (file, _("term_w: 0x%04x"), val);
7119 fprintf (file, _(" pc: 0x%08x\n"), pc);
7125 fprintf (file, _("delta pc +%-4d"), -cmd);
7126 line++; /* FIXME: curr increment. */
7128 /* xgettext:c-format */
7129 fprintf (file, _(" pc: 0x%08x line: %5u\n"),
7134 fprintf (file, _(" *unhandled* cmd %u\n"), cmd);
7147 unsigned char *buf_orig = buf;
7149 fprintf (file, _("source (len: %u)\n"), len);
7153 signed char cmd = buf[0];
7154 unsigned char cmdlen = 0;
7158 case DST__K_SRC_DECLFILE:
7160 struct vms_dst_src_decl_src *src = (void *)(buf + 1);
7163 /* xgettext:c-format */
7164 fprintf (file, _(" declfile: len: %u, flags: %u, "
7166 src->length, src->flags,
7167 (unsigned)bfd_getl16 (src->fileid));
7168 /* xgettext:c-format */
7169 fprintf (file, _(" rms: cdt: 0x%08x %08x, "
7170 "ebk: 0x%08x, ffb: 0x%04x, "
7172 (unsigned)bfd_getl32 (src->rms_cdt + 4),
7173 (unsigned)bfd_getl32 (src->rms_cdt + 0),
7174 (unsigned)bfd_getl32 (src->rms_ebk),
7175 (unsigned)bfd_getl16 (src->rms_ffb),
7177 name = (const char *)buf + 1 + sizeof (*src);
7178 fprintf (file, _(" filename : %.*s\n"),
7180 name += name[0] + 1;
7181 fprintf (file, _(" module name: %.*s\n"),
7183 cmdlen = 2 + src->length;
7186 case DST__K_SRC_SETFILE:
7187 fprintf (file, _(" setfile %u\n"),
7188 (unsigned)bfd_getl16 (buf + 1));
7191 case DST__K_SRC_SETREC_W:
7192 fprintf (file, _(" setrec %u\n"),
7193 (unsigned)bfd_getl16 (buf + 1));
7196 case DST__K_SRC_SETREC_L:
7197 fprintf (file, _(" setrec %u\n"),
7198 (unsigned)bfd_getl32 (buf + 1));
7201 case DST__K_SRC_SETLNUM_W:
7202 fprintf (file, _(" setlnum %u\n"),
7203 (unsigned)bfd_getl16 (buf + 1));
7206 case DST__K_SRC_SETLNUM_L:
7207 fprintf (file, _(" setlnum %u\n"),
7208 (unsigned)bfd_getl32 (buf + 1));
7211 case DST__K_SRC_DEFLINES_W:
7212 fprintf (file, _(" deflines %u\n"),
7213 (unsigned)bfd_getl16 (buf + 1));
7216 case DST__K_SRC_DEFLINES_B:
7217 fprintf (file, _(" deflines %u\n"), buf[1]);
7220 case DST__K_SRC_FORMFEED:
7221 fprintf (file, _(" formfeed\n"));
7225 fprintf (file, _(" *unhandled* cmd %u\n"), cmd);
7237 fprintf (file, _("*unhandled* dst type %u\n"), type);
7245 evax_bfd_print_image (bfd *abfd, FILE *file)
7247 struct vms_eihd eihd;
7250 unsigned int eiha_off;
7251 unsigned int eihi_off;
7252 unsigned int eihs_off;
7253 unsigned int eisd_off;
7254 unsigned int eihef_off = 0;
7255 unsigned int eihnp_off = 0;
7256 unsigned int dmt_vbn = 0;
7257 unsigned int dmt_size = 0;
7258 unsigned int dst_vbn = 0;
7259 unsigned int dst_size = 0;
7260 unsigned int gst_vbn = 0;
7261 unsigned int gst_size = 0;
7262 unsigned int eiaf_vbn = 0;
7263 unsigned int eiaf_size = 0;
7264 unsigned int eihvn_off;
7266 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET)
7267 || bfd_bread (&eihd, sizeof (eihd), abfd) != sizeof (eihd))
7269 fprintf (file, _("cannot read EIHD\n"));
7272 /* xgettext:c-format */
7273 fprintf (file, _("EIHD: (size: %u, nbr blocks: %u)\n"),
7274 (unsigned)bfd_getl32 (eihd.size),
7275 (unsigned)bfd_getl32 (eihd.hdrblkcnt));
7276 /* xgettext:c-format */
7277 fprintf (file, _(" majorid: %u, minorid: %u\n"),
7278 (unsigned)bfd_getl32 (eihd.majorid),
7279 (unsigned)bfd_getl32 (eihd.minorid));
7281 val = (unsigned)bfd_getl32 (eihd.imgtype);
7285 name = _("executable");
7288 name = _("linkable image");
7291 name = _("unknown");
7294 /* xgettext:c-format */
7295 fprintf (file, _(" image type: %u (%s)"), val, name);
7297 val = (unsigned)bfd_getl32 (eihd.subtype);
7300 case EIHD__C_NATIVE:
7307 name = _("unknown");
7310 /* xgettext:c-format */
7311 fprintf (file, _(", subtype: %u (%s)\n"), val, name);
7313 eisd_off = bfd_getl32 (eihd.isdoff);
7314 eiha_off = bfd_getl32 (eihd.activoff);
7315 eihi_off = bfd_getl32 (eihd.imgidoff);
7316 eihs_off = bfd_getl32 (eihd.symdbgoff);
7317 /* xgettext:c-format */
7318 fprintf (file, _(" offsets: isd: %u, activ: %u, symdbg: %u, "
7319 "imgid: %u, patch: %u\n"),
7320 eisd_off, eiha_off, eihs_off, eihi_off,
7321 (unsigned)bfd_getl32 (eihd.patchoff));
7322 fprintf (file, _(" fixup info rva: "));
7323 bfd_fprintf_vma (abfd, file, bfd_getl64 (eihd.iafva));
7324 fprintf (file, _(", symbol vector rva: "));
7325 bfd_fprintf_vma (abfd, file, bfd_getl64 (eihd.symvva));
7326 eihvn_off = bfd_getl32 (eihd.version_array_off);
7327 fprintf (file, _("\n"
7328 " version array off: %u\n"),
7331 /* xgettext:c-format */
7332 _(" img I/O count: %u, nbr channels: %u, req pri: %08x%08x\n"),
7333 (unsigned)bfd_getl32 (eihd.imgiocnt),
7334 (unsigned)bfd_getl32 (eihd.iochancnt),
7335 (unsigned)bfd_getl32 (eihd.privreqs + 4),
7336 (unsigned)bfd_getl32 (eihd.privreqs + 0));
7337 val = (unsigned)bfd_getl32 (eihd.lnkflags);
7338 fprintf (file, _(" linker flags: %08x:"), val);
7339 if (val & EIHD__M_LNKDEBUG)
7340 fprintf (file, " LNKDEBUG");
7341 if (val & EIHD__M_LNKNOTFR)
7342 fprintf (file, " LNKNOTFR");
7343 if (val & EIHD__M_NOP0BUFS)
7344 fprintf (file, " NOP0BUFS");
7345 if (val & EIHD__M_PICIMG)
7346 fprintf (file, " PICIMG");
7347 if (val & EIHD__M_P0IMAGE)
7348 fprintf (file, " P0IMAGE");
7349 if (val & EIHD__M_DBGDMT)
7350 fprintf (file, " DBGDMT");
7351 if (val & EIHD__M_INISHR)
7352 fprintf (file, " INISHR");
7353 if (val & EIHD__M_XLATED)
7354 fprintf (file, " XLATED");
7355 if (val & EIHD__M_BIND_CODE_SEC)
7356 fprintf (file, " BIND_CODE_SEC");
7357 if (val & EIHD__M_BIND_DATA_SEC)
7358 fprintf (file, " BIND_DATA_SEC");
7359 if (val & EIHD__M_MKTHREADS)
7360 fprintf (file, " MKTHREADS");
7361 if (val & EIHD__M_UPCALLS)
7362 fprintf (file, " UPCALLS");
7363 if (val & EIHD__M_OMV_READY)
7364 fprintf (file, " OMV_READY");
7365 if (val & EIHD__M_EXT_BIND_SECT)
7366 fprintf (file, " EXT_BIND_SECT");
7367 fprintf (file, "\n");
7368 /* xgettext:c-format */
7369 fprintf (file, _(" ident: 0x%08x, sysver: 0x%08x, "
7370 "match ctrl: %u, symvect_size: %u\n"),
7371 (unsigned)bfd_getl32 (eihd.ident),
7372 (unsigned)bfd_getl32 (eihd.sysver),
7374 (unsigned)bfd_getl32 (eihd.symvect_size));
7375 fprintf (file, _(" BPAGE: %u"),
7376 (unsigned)bfd_getl32 (eihd.virt_mem_block_size));
7377 if (val & (EIHD__M_OMV_READY | EIHD__M_EXT_BIND_SECT))
7379 eihef_off = bfd_getl32 (eihd.ext_fixup_off);
7380 eihnp_off = bfd_getl32 (eihd.noopt_psect_off);
7381 /* xgettext:c-format */
7382 fprintf (file, _(", ext fixup offset: %u, no_opt psect off: %u"),
7383 eihef_off, eihnp_off);
7385 fprintf (file, _(", alias: %u\n"), (unsigned)bfd_getl16 (eihd.alias));
7389 struct vms_eihvn eihvn;
7393 fprintf (file, _("system version array information:\n"));
7394 if (bfd_seek (abfd, (file_ptr) eihvn_off, SEEK_SET)
7395 || bfd_bread (&eihvn, sizeof (eihvn), abfd) != sizeof (eihvn))
7397 fprintf (file, _("cannot read EIHVN header\n"));
7400 mask = bfd_getl32 (eihvn.subsystem_mask);
7401 for (j = 0; j < 32; j++)
7402 if (mask & (1 << j))
7404 struct vms_eihvn_subversion ver;
7405 if (bfd_bread (&ver, sizeof (ver), abfd) != sizeof (ver))
7407 fprintf (file, _("cannot read EIHVN version\n"));
7410 fprintf (file, _(" %02u "), j);
7413 case EIHVN__BASE_IMAGE_BIT:
7414 fputs (_("BASE_IMAGE "), file);
7416 case EIHVN__MEMORY_MANAGEMENT_BIT:
7417 fputs (_("MEMORY_MANAGEMENT"), file);
7420 fputs (_("IO "), file);
7422 case EIHVN__FILES_VOLUMES_BIT:
7423 fputs (_("FILES_VOLUMES "), file);
7425 case EIHVN__PROCESS_SCHED_BIT:
7426 fputs (_("PROCESS_SCHED "), file);
7428 case EIHVN__SYSGEN_BIT:
7429 fputs (_("SYSGEN "), file);
7431 case EIHVN__CLUSTERS_LOCKMGR_BIT:
7432 fputs (_("CLUSTERS_LOCKMGR "), file);
7434 case EIHVN__LOGICAL_NAMES_BIT:
7435 fputs (_("LOGICAL_NAMES "), file);
7437 case EIHVN__SECURITY_BIT:
7438 fputs (_("SECURITY "), file);
7440 case EIHVN__IMAGE_ACTIVATOR_BIT:
7441 fputs (_("IMAGE_ACTIVATOR "), file);
7443 case EIHVN__NETWORKS_BIT:
7444 fputs (_("NETWORKS "), file);
7446 case EIHVN__COUNTERS_BIT:
7447 fputs (_("COUNTERS "), file);
7449 case EIHVN__STABLE_BIT:
7450 fputs (_("STABLE "), file);
7452 case EIHVN__MISC_BIT:
7453 fputs (_("MISC "), file);
7455 case EIHVN__CPU_BIT:
7456 fputs (_("CPU "), file);
7458 case EIHVN__VOLATILE_BIT:
7459 fputs (_("VOLATILE "), file);
7461 case EIHVN__SHELL_BIT:
7462 fputs (_("SHELL "), file);
7464 case EIHVN__POSIX_BIT:
7465 fputs (_("POSIX "), file);
7467 case EIHVN__MULTI_PROCESSING_BIT:
7468 fputs (_("MULTI_PROCESSING "), file);
7470 case EIHVN__GALAXY_BIT:
7471 fputs (_("GALAXY "), file);
7474 fputs (_("*unknown* "), file);
7477 fprintf (file, ": %u.%u\n",
7478 (unsigned)bfd_getl16 (ver.major),
7479 (unsigned)bfd_getl16 (ver.minor));
7485 struct vms_eiha eiha;
7487 if (bfd_seek (abfd, (file_ptr) eiha_off, SEEK_SET)
7488 || bfd_bread (&eiha, sizeof (eiha), abfd) != sizeof (eiha))
7490 fprintf (file, _("cannot read EIHA\n"));
7493 fprintf (file, _("Image activation: (size=%u)\n"),
7494 (unsigned)bfd_getl32 (eiha.size));
7495 /* xgettext:c-format */
7496 fprintf (file, _(" First address : 0x%08x 0x%08x\n"),
7497 (unsigned)bfd_getl32 (eiha.tfradr1_h),
7498 (unsigned)bfd_getl32 (eiha.tfradr1));
7499 /* xgettext:c-format */
7500 fprintf (file, _(" Second address: 0x%08x 0x%08x\n"),
7501 (unsigned)bfd_getl32 (eiha.tfradr2_h),
7502 (unsigned)bfd_getl32 (eiha.tfradr2));
7503 /* xgettext:c-format */
7504 fprintf (file, _(" Third address : 0x%08x 0x%08x\n"),
7505 (unsigned)bfd_getl32 (eiha.tfradr3_h),
7506 (unsigned)bfd_getl32 (eiha.tfradr3));
7507 /* xgettext:c-format */
7508 fprintf (file, _(" Fourth address: 0x%08x 0x%08x\n"),
7509 (unsigned)bfd_getl32 (eiha.tfradr4_h),
7510 (unsigned)bfd_getl32 (eiha.tfradr4));
7511 /* xgettext:c-format */
7512 fprintf (file, _(" Shared image : 0x%08x 0x%08x\n"),
7513 (unsigned)bfd_getl32 (eiha.inishr_h),
7514 (unsigned)bfd_getl32 (eiha.inishr));
7518 struct vms_eihi eihi;
7520 if (bfd_seek (abfd, (file_ptr) eihi_off, SEEK_SET)
7521 || bfd_bread (&eihi, sizeof (eihi), abfd) != sizeof (eihi))
7523 fprintf (file, _("cannot read EIHI\n"));
7526 /* xgettext:c-format */
7527 fprintf (file, _("Image identification: (major: %u, minor: %u)\n"),
7528 (unsigned)bfd_getl32 (eihi.majorid),
7529 (unsigned)bfd_getl32 (eihi.minorid));
7530 fprintf (file, _(" image name : %.*s\n"),
7531 eihi.imgnam[0], eihi.imgnam + 1);
7532 fprintf (file, _(" link time : %s\n"),
7533 vms_time_to_str (eihi.linktime));
7534 fprintf (file, _(" image ident : %.*s\n"),
7535 eihi.imgid[0], eihi.imgid + 1);
7536 fprintf (file, _(" linker ident : %.*s\n"),
7537 eihi.linkid[0], eihi.linkid + 1);
7538 fprintf (file, _(" image build ident: %.*s\n"),
7539 eihi.imgbid[0], eihi.imgbid + 1);
7543 struct vms_eihs eihs;
7545 if (bfd_seek (abfd, (file_ptr) eihs_off, SEEK_SET)
7546 || bfd_bread (&eihs, sizeof (eihs), abfd) != sizeof (eihs))
7548 fprintf (file, _("cannot read EIHS\n"));
7551 /* xgettext:c-format */
7552 fprintf (file, _("Image symbol & debug table: (major: %u, minor: %u)\n"),
7553 (unsigned)bfd_getl32 (eihs.majorid),
7554 (unsigned)bfd_getl32 (eihs.minorid));
7555 dst_vbn = bfd_getl32 (eihs.dstvbn);
7556 dst_size = bfd_getl32 (eihs.dstsize);
7557 /* xgettext:c-format */
7558 fprintf (file, _(" debug symbol table : vbn: %u, size: %u (0x%x)\n"),
7559 dst_vbn, dst_size, dst_size);
7560 gst_vbn = bfd_getl32 (eihs.gstvbn);
7561 gst_size = bfd_getl32 (eihs.gstsize);
7562 /* xgettext:c-format */
7563 fprintf (file, _(" global symbol table: vbn: %u, records: %u\n"),
7565 dmt_vbn = bfd_getl32 (eihs.dmtvbn);
7566 dmt_size = bfd_getl32 (eihs.dmtsize);
7567 /* xgettext:c-format */
7568 fprintf (file, _(" debug module table : vbn: %u, size: %u\n"),
7571 while (eisd_off != 0)
7573 struct vms_eisd eisd;
7578 if (bfd_seek (abfd, (file_ptr) eisd_off, SEEK_SET)
7579 || bfd_bread (&eisd, sizeof (eisd), abfd) != sizeof (eisd))
7581 fprintf (file, _("cannot read EISD\n"));
7584 len = (unsigned)bfd_getl32 (eisd.eisdsize);
7585 if (len != (unsigned)-1)
7589 eisd_off = (eisd_off + VMS_BLOCK_SIZE) & ~(VMS_BLOCK_SIZE - 1);
7591 /* xgettext:c-format */
7592 fprintf (file, _("Image section descriptor: (major: %u, minor: %u, "
7593 "size: %u, offset: %u)\n"),
7594 (unsigned)bfd_getl32 (eisd.majorid),
7595 (unsigned)bfd_getl32 (eisd.minorid),
7599 /* xgettext:c-format */
7600 fprintf (file, _(" section: base: 0x%08x%08x size: 0x%08x\n"),
7601 (unsigned)bfd_getl32 (eisd.virt_addr + 4),
7602 (unsigned)bfd_getl32 (eisd.virt_addr + 0),
7603 (unsigned)bfd_getl32 (eisd.secsize));
7604 val = (unsigned)bfd_getl32 (eisd.flags);
7605 fprintf (file, _(" flags: 0x%04x"), val);
7606 if (val & EISD__M_GBL)
7607 fprintf (file, " GBL");
7608 if (val & EISD__M_CRF)
7609 fprintf (file, " CRF");
7610 if (val & EISD__M_DZRO)
7611 fprintf (file, " DZRO");
7612 if (val & EISD__M_WRT)
7613 fprintf (file, " WRT");
7614 if (val & EISD__M_INITALCODE)
7615 fprintf (file, " INITALCODE");
7616 if (val & EISD__M_BASED)
7617 fprintf (file, " BASED");
7618 if (val & EISD__M_FIXUPVEC)
7619 fprintf (file, " FIXUPVEC");
7620 if (val & EISD__M_RESIDENT)
7621 fprintf (file, " RESIDENT");
7622 if (val & EISD__M_VECTOR)
7623 fprintf (file, " VECTOR");
7624 if (val & EISD__M_PROTECT)
7625 fprintf (file, " PROTECT");
7626 if (val & EISD__M_LASTCLU)
7627 fprintf (file, " LASTCLU");
7628 if (val & EISD__M_EXE)
7629 fprintf (file, " EXE");
7630 if (val & EISD__M_NONSHRADR)
7631 fprintf (file, " NONSHRADR");
7632 if (val & EISD__M_QUAD_LENGTH)
7633 fprintf (file, " QUAD_LENGTH");
7634 if (val & EISD__M_ALLOC_64BIT)
7635 fprintf (file, " ALLOC_64BIT");
7636 fprintf (file, "\n");
7637 if (val & EISD__M_FIXUPVEC)
7639 eiaf_vbn = bfd_getl32 (eisd.vbn);
7640 eiaf_size = bfd_getl32 (eisd.secsize);
7642 /* xgettext:c-format */
7643 fprintf (file, _(" vbn: %u, pfc: %u, matchctl: %u type: %u ("),
7644 (unsigned)bfd_getl32 (eisd.vbn),
7645 eisd.pfc, eisd.matchctl, eisd.type);
7648 case EISD__K_NORMAL:
7649 fputs (_("NORMAL"), file);
7651 case EISD__K_SHRFXD:
7652 fputs (_("SHRFXD"), file);
7654 case EISD__K_PRVFXD:
7655 fputs (_("PRVFXD"), file);
7657 case EISD__K_SHRPIC:
7658 fputs (_("SHRPIC"), file);
7660 case EISD__K_PRVPIC:
7661 fputs (_("PRVPIC"), file);
7663 case EISD__K_USRSTACK:
7664 fputs (_("USRSTACK"), file);
7667 fputs (_("*unknown*"), file);
7670 fputs (_(")\n"), file);
7671 if (val & EISD__M_GBL)
7672 /* xgettext:c-format */
7673 fprintf (file, _(" ident: 0x%08x, name: %.*s\n"),
7674 (unsigned)bfd_getl32 (eisd.ident),
7675 eisd.gblnam[0], eisd.gblnam + 1);
7681 if (bfd_seek (abfd, (file_ptr) (dmt_vbn - 1) * VMS_BLOCK_SIZE, SEEK_SET))
7683 fprintf (file, _("cannot read DMT\n"));
7687 fprintf (file, _("Debug module table:\n"));
7689 while (dmt_size > 0)
7691 struct vms_dmt_header dmth;
7694 if (bfd_bread (&dmth, sizeof (dmth), abfd) != sizeof (dmth))
7696 fprintf (file, _("cannot read DMT header\n"));
7699 count = bfd_getl16 (dmth.psect_count);
7701 /* xgettext:c-format */
7702 _(" module offset: 0x%08x, size: 0x%08x, (%u psects)\n"),
7703 (unsigned)bfd_getl32 (dmth.modbeg),
7704 (unsigned)bfd_getl32 (dmth.size), count);
7705 dmt_size -= sizeof (dmth);
7708 struct vms_dmt_psect dmtp;
7710 if (bfd_bread (&dmtp, sizeof (dmtp), abfd) != sizeof (dmtp))
7712 fprintf (file, _("cannot read DMT psect\n"));
7715 /* xgettext:c-format */
7716 fprintf (file, _(" psect start: 0x%08x, length: %u\n"),
7717 (unsigned)bfd_getl32 (dmtp.start),
7718 (unsigned)bfd_getl32 (dmtp.length));
7720 dmt_size -= sizeof (dmtp);
7727 if (bfd_seek (abfd, (file_ptr) (dst_vbn - 1) * VMS_BLOCK_SIZE, SEEK_SET))
7729 fprintf (file, _("cannot read DST\n"));
7733 evax_bfd_print_dst (abfd, dst_size, file);
7737 if (bfd_seek (abfd, (file_ptr) (gst_vbn - 1) * VMS_BLOCK_SIZE, SEEK_SET))
7739 fprintf (file, _("cannot read GST\n"));
7743 fprintf (file, _("Global symbol table:\n"));
7744 evax_bfd_print_eobj (abfd, file);
7749 struct vms_eiaf *eiaf;
7750 unsigned int qrelfixoff;
7751 unsigned int lrelfixoff;
7752 unsigned int qdotadroff;
7753 unsigned int ldotadroff;
7754 unsigned int shrimgcnt;
7755 unsigned int shlstoff;
7756 unsigned int codeadroff;
7757 unsigned int lpfixoff;
7758 unsigned int chgprtoff;
7760 buf = bfd_malloc (eiaf_size);
7762 if (bfd_seek (abfd, (file_ptr) (eiaf_vbn - 1) * VMS_BLOCK_SIZE, SEEK_SET)
7763 || bfd_bread (buf, eiaf_size, abfd) != eiaf_size)
7765 fprintf (file, _("cannot read EIHA\n"));
7769 eiaf = (struct vms_eiaf *)buf;
7771 /* xgettext:c-format */
7772 _("Image activator fixup: (major: %u, minor: %u)\n"),
7773 (unsigned)bfd_getl32 (eiaf->majorid),
7774 (unsigned)bfd_getl32 (eiaf->minorid));
7775 /* xgettext:c-format */
7776 fprintf (file, _(" iaflink : 0x%08x %08x\n"),
7777 (unsigned)bfd_getl32 (eiaf->iaflink + 0),
7778 (unsigned)bfd_getl32 (eiaf->iaflink + 4));
7779 /* xgettext:c-format */
7780 fprintf (file, _(" fixuplnk: 0x%08x %08x\n"),
7781 (unsigned)bfd_getl32 (eiaf->fixuplnk + 0),
7782 (unsigned)bfd_getl32 (eiaf->fixuplnk + 4));
7783 fprintf (file, _(" size : %u\n"),
7784 (unsigned)bfd_getl32 (eiaf->size));
7785 fprintf (file, _(" flags: 0x%08x\n"),
7786 (unsigned)bfd_getl32 (eiaf->flags));
7787 qrelfixoff = bfd_getl32 (eiaf->qrelfixoff);
7788 lrelfixoff = bfd_getl32 (eiaf->lrelfixoff);
7789 /* xgettext:c-format */
7790 fprintf (file, _(" qrelfixoff: %5u, lrelfixoff: %5u\n"),
7791 qrelfixoff, lrelfixoff);
7792 qdotadroff = bfd_getl32 (eiaf->qdotadroff);
7793 ldotadroff = bfd_getl32 (eiaf->ldotadroff);
7794 /* xgettext:c-format */
7795 fprintf (file, _(" qdotadroff: %5u, ldotadroff: %5u\n"),
7796 qdotadroff, ldotadroff);
7797 codeadroff = bfd_getl32 (eiaf->codeadroff);
7798 lpfixoff = bfd_getl32 (eiaf->lpfixoff);
7799 /* xgettext:c-format */
7800 fprintf (file, _(" codeadroff: %5u, lpfixoff : %5u\n"),
7801 codeadroff, lpfixoff);
7802 chgprtoff = bfd_getl32 (eiaf->chgprtoff);
7803 fprintf (file, _(" chgprtoff : %5u\n"), chgprtoff);
7804 shrimgcnt = bfd_getl32 (eiaf->shrimgcnt);
7805 shlstoff = bfd_getl32 (eiaf->shlstoff);
7806 /* xgettext:c-format */
7807 fprintf (file, _(" shlstoff : %5u, shrimgcnt : %5u\n"),
7808 shlstoff, shrimgcnt);
7809 /* xgettext:c-format */
7810 fprintf (file, _(" shlextra : %5u, permctx : %5u\n"),
7811 (unsigned)bfd_getl32 (eiaf->shlextra),
7812 (unsigned)bfd_getl32 (eiaf->permctx));
7813 fprintf (file, _(" base_va : 0x%08x\n"),
7814 (unsigned)bfd_getl32 (eiaf->base_va));
7815 fprintf (file, _(" lppsbfixoff: %5u\n"),
7816 (unsigned)bfd_getl32 (eiaf->lppsbfixoff));
7820 struct vms_shl *shl = (struct vms_shl *)(buf + shlstoff);
7823 fprintf (file, _(" Shareable images:\n"));
7824 for (j = 0; j < shrimgcnt; j++, shl++)
7827 /* xgettext:c-format */
7828 _(" %u: size: %u, flags: 0x%02x, name: %.*s\n"),
7829 j, shl->size, shl->flags,
7830 shl->imgnam[0], shl->imgnam + 1);
7833 if (qrelfixoff != 0)
7835 fprintf (file, _(" quad-word relocation fixups:\n"));
7836 evax_bfd_print_relocation_records (file, buf + qrelfixoff, 8);
7838 if (lrelfixoff != 0)
7840 fprintf (file, _(" long-word relocation fixups:\n"));
7841 evax_bfd_print_relocation_records (file, buf + lrelfixoff, 4);
7843 if (qdotadroff != 0)
7845 fprintf (file, _(" quad-word .address reference fixups:\n"));
7846 evax_bfd_print_address_fixups (file, buf + qdotadroff);
7848 if (ldotadroff != 0)
7850 fprintf (file, _(" long-word .address reference fixups:\n"));
7851 evax_bfd_print_address_fixups (file, buf + ldotadroff);
7853 if (codeadroff != 0)
7855 fprintf (file, _(" Code Address Reference Fixups:\n"));
7856 evax_bfd_print_reference_fixups (file, buf + codeadroff);
7860 fprintf (file, _(" Linkage Pairs Reference Fixups:\n"));
7861 evax_bfd_print_reference_fixups (file, buf + lpfixoff);
7865 unsigned int count = (unsigned)bfd_getl32 (buf + chgprtoff);
7866 struct vms_eicp *eicp = (struct vms_eicp *)(buf + chgprtoff + 4);
7869 fprintf (file, _(" Change Protection (%u entries):\n"), count);
7870 for (j = 0; j < count; j++, eicp++)
7872 unsigned int prot = bfd_getl32 (eicp->newprt);
7874 /* xgettext:c-format */
7875 _(" base: 0x%08x %08x, size: 0x%08x, prot: 0x%08x "),
7876 (unsigned)bfd_getl32 (eicp->baseva + 4),
7877 (unsigned)bfd_getl32 (eicp->baseva + 0),
7878 (unsigned)bfd_getl32 (eicp->size),
7879 (unsigned)bfd_getl32 (eicp->newprt));
7883 fprintf (file, "NA");
7885 case PRT__C_RESERVED:
7886 fprintf (file, "RES");
7889 fprintf (file, "KW");
7892 fprintf (file, "KR");
7895 fprintf (file, "UW");
7898 fprintf (file, "EW");
7901 fprintf (file, "ERKW");
7904 fprintf (file, "ER");
7907 fprintf (file, "SW");
7910 fprintf (file, "SREW");
7913 fprintf (file, "SRKW");
7916 fprintf (file, "SR");
7919 fprintf (file, "URSW");
7922 fprintf (file, "UREW");
7925 fprintf (file, "URKW");
7928 fprintf (file, "UR");
7942 vms_bfd_print_private_bfd_data (bfd *abfd, void *ptr)
7944 FILE *file = (FILE *)ptr;
7946 if (bfd_get_file_flags (abfd) & (EXEC_P | DYNAMIC))
7947 evax_bfd_print_image (abfd, file);
7950 if (bfd_seek (abfd, 0, SEEK_SET))
7952 evax_bfd_print_eobj (abfd, file);
7959 /* Slurp ETIR/EDBG/ETBT VMS object records. */
7962 alpha_vms_read_sections_content (bfd *abfd, struct bfd_link_info *info)
7964 asection *cur_section;
7965 file_ptr cur_offset;
7966 asection *dst_section;
7967 file_ptr dst_offset;
7969 if (bfd_seek (abfd, 0, SEEK_SET) != 0)
7975 dst_section = PRIV (dst_section);
7979 if (info->strip == strip_all || info->strip == strip_debugger)
7981 /* Discard the DST section. */
7985 else if (dst_section)
7987 dst_offset = dst_section->output_offset;
7988 dst_section = dst_section->output_section;
7997 type = _bfd_vms_get_object_record (abfd);
8000 vms_debug2 ((2, "next_record failed\n"));
8006 PRIV (image_section) = cur_section;
8007 PRIV (image_offset) = cur_offset;
8008 res = _bfd_vms_slurp_etir (abfd, info);
8009 cur_section = PRIV (image_section);
8010 cur_offset = PRIV (image_offset);
8014 if (dst_section == NULL)
8016 PRIV (image_section) = dst_section;
8017 PRIV (image_offset) = dst_offset;
8018 res = _bfd_vms_slurp_etir (abfd, info);
8019 dst_offset = PRIV (image_offset);
8028 vms_debug2 ((2, "slurp eobj type %d failed\n", type));
8035 alpha_vms_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
8036 struct bfd_link_info *info ATTRIBUTE_UNUSED)
8041 /* Add a linkage pair fixup at address SECT + OFFSET to SHLIB. */
8044 alpha_vms_add_fixup_lp (struct bfd_link_info *info, bfd *src, bfd *shlib)
8046 struct alpha_vms_shlib_el *sl;
8047 asection *sect = PRIV2 (src, image_section);
8048 file_ptr offset = PRIV2 (src, image_offset);
8050 sl = &VEC_EL (alpha_vms_link_hash (info)->shrlibs,
8051 struct alpha_vms_shlib_el, PRIV2 (shlib, shr_index));
8052 sl->has_fixups = TRUE;
8053 VEC_APPEND_EL (sl->lp, bfd_vma,
8054 sect->output_section->vma + sect->output_offset + offset);
8055 sect->output_section->flags |= SEC_RELOC;
8058 /* Add a code address fixup at address SECT + OFFSET to SHLIB. */
8061 alpha_vms_add_fixup_ca (struct bfd_link_info *info, bfd *src, bfd *shlib)
8063 struct alpha_vms_shlib_el *sl;
8064 asection *sect = PRIV2 (src, image_section);
8065 file_ptr offset = PRIV2 (src, image_offset);
8067 sl = &VEC_EL (alpha_vms_link_hash (info)->shrlibs,
8068 struct alpha_vms_shlib_el, PRIV2 (shlib, shr_index));
8069 sl->has_fixups = TRUE;
8070 VEC_APPEND_EL (sl->ca, bfd_vma,
8071 sect->output_section->vma + sect->output_offset + offset);
8072 sect->output_section->flags |= SEC_RELOC;
8075 /* Add a quad word relocation fixup at address SECT + OFFSET to SHLIB. */
8078 alpha_vms_add_fixup_qr (struct bfd_link_info *info, bfd *src,
8079 bfd *shlib, bfd_vma vec)
8081 struct alpha_vms_shlib_el *sl;
8082 struct alpha_vms_vma_ref *r;
8083 asection *sect = PRIV2 (src, image_section);
8084 file_ptr offset = PRIV2 (src, image_offset);
8086 sl = &VEC_EL (alpha_vms_link_hash (info)->shrlibs,
8087 struct alpha_vms_shlib_el, PRIV2 (shlib, shr_index));
8088 sl->has_fixups = TRUE;
8089 r = VEC_APPEND (sl->qr, struct alpha_vms_vma_ref);
8090 r->vma = sect->output_section->vma + sect->output_offset + offset;
8092 sect->output_section->flags |= SEC_RELOC;
8096 alpha_vms_add_fixup_lr (struct bfd_link_info *info ATTRIBUTE_UNUSED,
8097 unsigned int shr ATTRIBUTE_UNUSED,
8098 bfd_vma vec ATTRIBUTE_UNUSED)
8100 /* Not yet supported. */
8104 /* Add relocation. FIXME: Not yet emitted. */
8107 alpha_vms_add_lw_reloc (struct bfd_link_info *info ATTRIBUTE_UNUSED)
8112 alpha_vms_add_qw_reloc (struct bfd_link_info *info ATTRIBUTE_UNUSED)
8116 static struct bfd_hash_entry *
8117 alpha_vms_link_hash_newfunc (struct bfd_hash_entry *entry,
8118 struct bfd_hash_table *table,
8121 struct alpha_vms_link_hash_entry *ret =
8122 (struct alpha_vms_link_hash_entry *) entry;
8124 /* Allocate the structure if it has not already been allocated by a
8127 ret = ((struct alpha_vms_link_hash_entry *)
8128 bfd_hash_allocate (table,
8129 sizeof (struct alpha_vms_link_hash_entry)));
8133 /* Call the allocation method of the superclass. */
8134 ret = ((struct alpha_vms_link_hash_entry *)
8135 _bfd_link_hash_newfunc ((struct bfd_hash_entry *) ret,
8140 return (struct bfd_hash_entry *) ret;
8143 /* Create an Alpha/VMS link hash table. */
8145 static struct bfd_link_hash_table *
8146 alpha_vms_bfd_link_hash_table_create (bfd *abfd)
8148 struct alpha_vms_link_hash_table *ret;
8149 bfd_size_type amt = sizeof (struct alpha_vms_link_hash_table);
8151 ret = (struct alpha_vms_link_hash_table *) bfd_malloc (amt);
8154 if (!_bfd_link_hash_table_init (&ret->root, abfd,
8155 alpha_vms_link_hash_newfunc,
8156 sizeof (struct alpha_vms_link_hash_entry)))
8162 VEC_INIT (ret->shrlibs);
8169 alpha_vms_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
8173 for (i = 0; i < PRIV (gsd_sym_count); i++)
8175 struct vms_symbol_entry *e = PRIV (syms)[i];
8176 struct alpha_vms_link_hash_entry *h;
8177 struct bfd_link_hash_entry *h_root;
8180 if (!alpha_vms_convert_symbol (abfd, e, &sym))
8183 if ((e->flags & EGSY__V_DEF) && abfd->selective_search)
8185 /* In selective_search mode, only add definition that are
8187 h = (struct alpha_vms_link_hash_entry *)bfd_link_hash_lookup
8188 (info->hash, sym.name, FALSE, FALSE, FALSE);
8189 if (h == NULL || h->root.type != bfd_link_hash_undefined)
8195 h_root = (struct bfd_link_hash_entry *) h;
8196 if (!_bfd_generic_link_add_one_symbol (info, abfd, sym.name, sym.flags,
8197 sym.section, sym.value, NULL,
8198 FALSE, FALSE, &h_root))
8200 h = (struct alpha_vms_link_hash_entry *) h_root;
8202 if ((e->flags & EGSY__V_DEF)
8204 && abfd->xvec == info->output_bfd->xvec)
8208 if (abfd->flags & DYNAMIC)
8210 struct alpha_vms_shlib_el *shlib;
8212 /* We do not want to include any of the sections in a dynamic
8213 object in the output file. See comment in elflink.c. */
8214 bfd_section_list_clear (abfd);
8216 shlib = VEC_APPEND (alpha_vms_link_hash (info)->shrlibs,
8217 struct alpha_vms_shlib_el);
8219 VEC_INIT (shlib->ca);
8220 VEC_INIT (shlib->lp);
8221 VEC_INIT (shlib->qr);
8222 PRIV (shr_index) = VEC_COUNT (alpha_vms_link_hash (info)->shrlibs) - 1;
8229 alpha_vms_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info)
8232 struct bfd_link_hash_entry **pundef;
8233 struct bfd_link_hash_entry **next_pundef;
8235 /* We only accept VMS libraries. */
8236 if (info->output_bfd->xvec != abfd->xvec)
8238 bfd_set_error (bfd_error_wrong_format);
8242 /* The archive_pass field in the archive itself is used to
8243 initialize PASS, since we may search the same archive multiple
8245 pass = ++abfd->archive_pass;
8247 /* Look through the list of undefined symbols. */
8248 for (pundef = &info->hash->undefs; *pundef != NULL; pundef = next_pundef)
8250 struct bfd_link_hash_entry *h;
8256 next_pundef = &(*pundef)->u.undef.next;
8258 /* When a symbol is defined, it is not necessarily removed from
8260 if (h->type != bfd_link_hash_undefined
8261 && h->type != bfd_link_hash_common)
8263 /* Remove this entry from the list, for general cleanliness
8264 and because we are going to look through the list again
8265 if we search any more libraries. We can't remove the
8266 entry if it is the tail, because that would lose any
8267 entries we add to the list later on. */
8268 if (*pundef != info->hash->undefs_tail)
8270 *pundef = *next_pundef;
8271 next_pundef = pundef;
8276 /* Look for this symbol in the archive hash table. */
8277 symidx = _bfd_vms_lib_find_symbol (abfd, h->root.string);
8278 if (symidx == BFD_NO_MORE_SYMBOLS)
8280 /* Nothing in this slot. */
8284 element = bfd_get_elt_at_index (abfd, symidx);
8285 if (element == NULL)
8288 if (element->archive_pass == -1 || element->archive_pass == pass)
8290 /* Next symbol if this archive is wrong or already handled. */
8294 if (! bfd_check_format (element, bfd_object))
8296 element->archive_pass = -1;
8300 orig_element = element;
8301 if (bfd_is_thin_archive (abfd))
8303 element = _bfd_vms_lib_get_imagelib_file (element);
8304 if (element == NULL || !bfd_check_format (element, bfd_object))
8306 orig_element->archive_pass = -1;
8311 /* Unlike the generic linker, we know that this element provides
8312 a definition for an undefined symbol and we know that we want
8313 to include it. We don't need to check anything. */
8314 if (!(*info->callbacks
8315 ->add_archive_element) (info, element, h->root.string, &element))
8317 if (!alpha_vms_link_add_object_symbols (element, info))
8320 orig_element->archive_pass = pass;
8327 alpha_vms_bfd_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
8329 switch (bfd_get_format (abfd))
8332 vms_debug2 ((2, "vms_link_add_symbols for object %s\n",
8334 return alpha_vms_link_add_object_symbols (abfd, info);
8337 vms_debug2 ((2, "vms_link_add_symbols for archive %s\n",
8339 return alpha_vms_link_add_archive_symbols (abfd, info);
8342 bfd_set_error (bfd_error_wrong_format);
8348 alpha_vms_build_fixups (struct bfd_link_info *info)
8350 struct alpha_vms_link_hash_table *t = alpha_vms_link_hash (info);
8351 unsigned char *content;
8353 unsigned int sz = 0;
8354 unsigned int lp_sz = 0;
8355 unsigned int ca_sz = 0;
8356 unsigned int qr_sz = 0;
8357 unsigned int shrimg_cnt = 0;
8358 unsigned int chgprt_num = 0;
8359 unsigned int chgprt_sz = 0;
8360 struct vms_eiaf *eiaf;
8364 /* Shared libraries. */
8365 for (i = 0; i < VEC_COUNT (t->shrlibs); i++)
8367 struct alpha_vms_shlib_el *shlib;
8369 shlib = &VEC_EL (t->shrlibs, struct alpha_vms_shlib_el, i);
8371 if (!shlib->has_fixups)
8376 if (VEC_COUNT (shlib->ca) > 0)
8378 /* Header + entries. */
8380 ca_sz += VEC_COUNT (shlib->ca) * 4;
8382 if (VEC_COUNT (shlib->lp) > 0)
8384 /* Header + entries. */
8386 lp_sz += VEC_COUNT (shlib->lp) * 4;
8388 if (VEC_COUNT (shlib->qr) > 0)
8390 /* Header + entries. */
8392 qr_sz += VEC_COUNT (shlib->qr) * 8;
8403 /* Finish now if there is no content. */
8404 if (ca_sz + lp_sz + qr_sz == 0)
8407 /* Add an eicp entry for the fixup itself. */
8409 for (sec = info->output_bfd->sections; sec != NULL; sec = sec->next)
8411 /* This isect could be made RO or EXE after relocations are applied. */
8412 if ((sec->flags & SEC_RELOC) != 0
8413 && (sec->flags & (SEC_CODE | SEC_READONLY)) != 0)
8416 chgprt_sz = 4 + chgprt_num * sizeof (struct vms_eicp);
8418 /* Allocate section content (round-up size) */
8419 sz = sizeof (struct vms_eiaf) + shrimg_cnt * sizeof (struct vms_shl)
8420 + ca_sz + lp_sz + qr_sz + chgprt_sz;
8421 sz = (sz + VMS_BLOCK_SIZE - 1) & ~(VMS_BLOCK_SIZE - 1);
8422 content = bfd_zalloc (info->output_bfd, sz);
8423 if (content == NULL)
8426 sec = alpha_vms_link_hash (info)->fixup;
8427 sec->contents = content;
8430 eiaf = (struct vms_eiaf *)content;
8431 off = sizeof (struct vms_eiaf);
8432 bfd_putl32 (0, eiaf->majorid);
8433 bfd_putl32 (0, eiaf->minorid);
8434 bfd_putl32 (0, eiaf->iaflink);
8435 bfd_putl32 (0, eiaf->fixuplnk);
8436 bfd_putl32 (sizeof (struct vms_eiaf), eiaf->size);
8437 bfd_putl32 (0, eiaf->flags);
8438 bfd_putl32 (0, eiaf->qrelfixoff);
8439 bfd_putl32 (0, eiaf->lrelfixoff);
8440 bfd_putl32 (0, eiaf->qdotadroff);
8441 bfd_putl32 (0, eiaf->ldotadroff);
8442 bfd_putl32 (0, eiaf->codeadroff);
8443 bfd_putl32 (0, eiaf->lpfixoff);
8444 bfd_putl32 (0, eiaf->chgprtoff);
8445 bfd_putl32 (shrimg_cnt ? off : 0, eiaf->shlstoff);
8446 bfd_putl32 (shrimg_cnt, eiaf->shrimgcnt);
8447 bfd_putl32 (0, eiaf->shlextra);
8448 bfd_putl32 (0, eiaf->permctx);
8449 bfd_putl32 (0, eiaf->base_va);
8450 bfd_putl32 (0, eiaf->lppsbfixoff);
8457 for (i = 0; i < VEC_COUNT (t->shrlibs); i++)
8459 struct alpha_vms_shlib_el *shlib;
8460 struct vms_shl *shl;
8462 shlib = &VEC_EL (t->shrlibs, struct alpha_vms_shlib_el, i);
8464 if (!shlib->has_fixups)
8467 /* Renumber shared images. */
8468 PRIV2 (shlib->abfd, shr_index) = shrimg_cnt++;
8470 shl = (struct vms_shl *)(content + off);
8471 bfd_putl32 (0, shl->baseva);
8472 bfd_putl32 (0, shl->shlptr);
8473 bfd_putl32 (0, shl->ident);
8474 bfd_putl32 (0, shl->permctx);
8475 shl->size = sizeof (struct vms_shl);
8476 bfd_putl16 (0, shl->fill_1);
8478 bfd_putl32 (0, shl->icb);
8479 shl->imgnam[0] = strlen (PRIV2 (shlib->abfd, hdr_data.hdr_t_name));
8480 memcpy (shl->imgnam + 1, PRIV2 (shlib->abfd, hdr_data.hdr_t_name),
8483 off += sizeof (struct vms_shl);
8489 bfd_putl32 (off, eiaf->codeadroff);
8491 for (i = 0; i < VEC_COUNT (t->shrlibs); i++)
8493 struct alpha_vms_shlib_el *shlib;
8496 shlib = &VEC_EL (t->shrlibs, struct alpha_vms_shlib_el, i);
8498 if (VEC_COUNT (shlib->ca) == 0)
8501 bfd_putl32 (VEC_COUNT (shlib->ca), content + off);
8502 bfd_putl32 (PRIV2 (shlib->abfd, shr_index), content + off + 4);
8505 for (j = 0; j < VEC_COUNT (shlib->ca); j++)
8507 bfd_putl32 (VEC_EL (shlib->ca, bfd_vma, j) - t->base_addr,
8513 bfd_putl32 (0, content + off);
8514 bfd_putl32 (0, content + off + 4);
8521 bfd_putl32 (off, eiaf->lpfixoff);
8523 for (i = 0; i < VEC_COUNT (t->shrlibs); i++)
8525 struct alpha_vms_shlib_el *shlib;
8528 shlib = &VEC_EL (t->shrlibs, struct alpha_vms_shlib_el, i);
8530 if (VEC_COUNT (shlib->lp) == 0)
8533 bfd_putl32 (VEC_COUNT (shlib->lp), content + off);
8534 bfd_putl32 (PRIV2 (shlib->abfd, shr_index), content + off + 4);
8537 for (j = 0; j < VEC_COUNT (shlib->lp); j++)
8539 bfd_putl32 (VEC_EL (shlib->lp, bfd_vma, j) - t->base_addr,
8545 bfd_putl32 (0, content + off);
8546 bfd_putl32 (0, content + off + 4);
8553 bfd_putl32 (off, eiaf->qdotadroff);
8555 for (i = 0; i < VEC_COUNT (t->shrlibs); i++)
8557 struct alpha_vms_shlib_el *shlib;
8560 shlib = &VEC_EL (t->shrlibs, struct alpha_vms_shlib_el, i);
8562 if (VEC_COUNT (shlib->qr) == 0)
8565 bfd_putl32 (VEC_COUNT (shlib->qr), content + off);
8566 bfd_putl32 (PRIV2 (shlib->abfd, shr_index), content + off + 4);
8569 for (j = 0; j < VEC_COUNT (shlib->qr); j++)
8571 struct alpha_vms_vma_ref *r;
8572 r = &VEC_EL (shlib->qr, struct alpha_vms_vma_ref, j);
8573 bfd_putl32 (r->vma - t->base_addr, content + off);
8574 bfd_putl32 (r->ref, content + off + 4);
8579 bfd_putl32 (0, content + off);
8580 bfd_putl32 (0, content + off + 4);
8585 /* Write the change protection table. */
8586 bfd_putl32 (off, eiaf->chgprtoff);
8587 bfd_putl32 (chgprt_num, content + off);
8590 for (sec = info->output_bfd->sections; sec != NULL; sec = sec->next)
8592 struct vms_eicp *eicp;
8595 if ((sec->flags & SEC_LINKER_CREATED) != 0 &&
8596 strcmp (sec->name, "$FIXUP$") == 0)
8598 else if ((sec->flags & SEC_RELOC) != 0
8599 && (sec->flags & (SEC_CODE | SEC_READONLY)) != 0)
8604 eicp = (struct vms_eicp *)(content + off);
8605 bfd_putl64 (sec->vma - t->base_addr, eicp->baseva);
8606 bfd_putl32 ((sec->size + VMS_BLOCK_SIZE - 1) & ~(VMS_BLOCK_SIZE - 1),
8608 bfd_putl32 (prot, eicp->newprt);
8609 off += sizeof (struct vms_eicp);
8615 /* Called by bfd_hash_traverse to fill the symbol table.
8616 Return FALSE in case of failure. */
8619 alpha_vms_link_output_symbol (struct bfd_hash_entry *bh, void *infov)
8621 struct bfd_link_hash_entry *hc = (struct bfd_link_hash_entry *) bh;
8622 struct bfd_link_info *info = (struct bfd_link_info *)infov;
8623 struct alpha_vms_link_hash_entry *h;
8624 struct vms_symbol_entry *sym;
8626 if (hc->type == bfd_link_hash_warning)
8629 if (hc->type == bfd_link_hash_new)
8632 h = (struct alpha_vms_link_hash_entry *) hc;
8634 switch (h->root.type)
8636 case bfd_link_hash_undefined:
8638 case bfd_link_hash_new:
8639 case bfd_link_hash_warning:
8641 case bfd_link_hash_undefweak:
8643 case bfd_link_hash_defined:
8644 case bfd_link_hash_defweak:
8646 asection *sec = h->root.u.def.section;
8648 /* FIXME: this is certainly a symbol from a dynamic library. */
8649 if (bfd_is_abs_section (sec))
8652 if (sec->owner->flags & DYNAMIC)
8656 case bfd_link_hash_common:
8658 case bfd_link_hash_indirect:
8662 /* Do not write not kept symbols. */
8663 if (info->strip == strip_some
8664 && bfd_hash_lookup (info->keep_hash, h->root.root.string,
8665 FALSE, FALSE) != NULL)
8670 /* This symbol doesn't come from a VMS object. So we suppose it is
8672 int len = strlen (h->root.root.string);
8674 sym = (struct vms_symbol_entry *)bfd_zalloc (info->output_bfd,
8675 sizeof (*sym) + len);
8679 memcpy (sym->name, h->root.root.string, len);
8681 sym->owner = info->output_bfd;
8683 sym->typ = EGSD__C_SYMG;
8685 sym->flags = EGSY__V_DEF | EGSY__V_REL;
8686 sym->symbol_vector = h->root.u.def.value;
8687 sym->section = h->root.u.def.section;
8688 sym->value = h->root.u.def.value;
8693 if (!add_symbol_entry (info->output_bfd, sym))
8700 alpha_vms_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
8703 struct bfd_link_order *p;
8711 if (bfd_link_relocatable (info))
8713 /* FIXME: we do not yet support relocatable link. It is not obvious
8714 how to do it for debug infos. */
8715 (*info->callbacks->einfo)(_("%P: relocatable link is not supported\n"));
8719 bfd_get_outsymbols (abfd) = NULL;
8720 bfd_get_symcount (abfd) = 0;
8722 /* Mark all sections which will be included in the output file. */
8723 for (o = abfd->sections; o != NULL; o = o->next)
8724 for (p = o->map_head.link_order; p != NULL; p = p->next)
8725 if (p->type == bfd_indirect_link_order)
8726 p->u.indirect.section->linker_mark = TRUE;
8729 /* Handle all the link order information for the sections. */
8730 for (o = abfd->sections; o != NULL; o = o->next)
8732 printf ("For section %s (at 0x%08x, flags=0x%08x):\n",
8733 o->name, (unsigned)o->vma, (unsigned)o->flags);
8735 for (p = o->map_head.link_order; p != NULL; p = p->next)
8737 printf (" at 0x%08x - 0x%08x: ",
8738 (unsigned)p->offset, (unsigned)(p->offset + p->size - 1));
8741 case bfd_section_reloc_link_order:
8742 case bfd_symbol_reloc_link_order:
8743 printf (" section/symbol reloc\n");
8745 case bfd_indirect_link_order:
8746 printf (" section %s of %s\n",
8747 p->u.indirect.section->name,
8748 p->u.indirect.section->owner->filename);
8750 case bfd_data_link_order:
8751 printf (" explicit data\n");
8754 printf (" *unknown* type %u\n", p->type);
8761 /* Generate the symbol table. */
8762 BFD_ASSERT (PRIV (syms) == NULL);
8763 if (info->strip != strip_all)
8764 bfd_hash_traverse (&info->hash->table, alpha_vms_link_output_symbol, info);
8766 /* Find the entry point. */
8767 if (bfd_get_start_address (abfd) == 0)
8769 bfd *startbfd = NULL;
8771 for (sub = info->input_bfds; sub != NULL; sub = sub->link.next)
8773 /* Consider only VMS object files. */
8774 if (sub->xvec != abfd->xvec)
8777 if (!PRIV2 (sub, eom_data).eom_has_transfer)
8779 if ((PRIV2 (sub, eom_data).eom_b_tfrflg & EEOM__M_WKTFR) && startbfd)
8781 if (startbfd != NULL
8782 && !(PRIV2 (sub, eom_data).eom_b_tfrflg & EEOM__M_WKTFR))
8784 (*info->callbacks->einfo)
8785 /* xgettext:c-format */
8786 (_("%P: multiple entry points: in modules %B and %B\n"),
8795 unsigned int ps_idx = PRIV2 (startbfd, eom_data).eom_l_psindx;
8796 bfd_vma tfradr = PRIV2 (startbfd, eom_data).eom_l_tfradr;
8799 sec = PRIV2 (startbfd, sections)[ps_idx];
8801 bfd_set_start_address
8802 (abfd, sec->output_section->vma + sec->output_offset + tfradr);
8806 /* Set transfer addresses. */
8809 struct bfd_link_hash_entry *h;
8812 PRIV (transfer_address[i++]) = 0xffffffff00000340ULL; /* SYS$IMGACT */
8813 h = bfd_link_hash_lookup (info->hash, "LIB$INITIALIZE", FALSE, FALSE, TRUE);
8814 if (h != NULL && h->type == bfd_link_hash_defined)
8815 PRIV (transfer_address[i++]) =
8816 alpha_vms_get_sym_value (h->u.def.section, h->u.def.value);
8817 PRIV (transfer_address[i++]) = bfd_get_start_address (abfd);
8819 PRIV (transfer_address[i++]) = 0;
8822 /* Allocate contents.
8823 Also compute the virtual base address. */
8824 base_addr = (bfd_vma)-1;
8826 for (o = abfd->sections; o != NULL; o = o->next)
8828 if (o->flags & SEC_HAS_CONTENTS)
8830 o->contents = bfd_alloc (abfd, o->size);
8831 if (o->contents == NULL)
8834 if (o->flags & SEC_LOAD)
8836 if (o->vma < base_addr)
8838 if (o->vma + o->size > last_addr)
8839 last_addr = o->vma + o->size;
8841 /* Clear the RELOC flags. Currently we don't support incremental
8842 linking. We use the RELOC flag for computing the eicp entries. */
8843 o->flags &= ~SEC_RELOC;
8846 /* Create the fixup section. */
8847 fixupsec = bfd_make_section_anyway_with_flags
8848 (info->output_bfd, "$FIXUP$",
8849 SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_LINKER_CREATED);
8850 if (fixupsec == NULL)
8852 last_addr = (last_addr + 0xffff) & ~0xffff;
8853 fixupsec->vma = last_addr;
8855 alpha_vms_link_hash (info)->fixup = fixupsec;
8856 alpha_vms_link_hash (info)->base_addr = base_addr;
8858 /* Create the DMT section, if necessary. */
8859 BFD_ASSERT (PRIV (dst_section) == NULL);
8860 dst = bfd_get_section_by_name (abfd, "$DST$");
8861 if (dst != NULL && dst->size == 0)
8865 PRIV (dst_section) = dst;
8866 dmt = bfd_make_section_anyway_with_flags
8867 (info->output_bfd, "$DMT$",
8868 SEC_DEBUGGING | SEC_HAS_CONTENTS | SEC_LINKER_CREATED);
8875 /* Read all sections from the inputs. */
8876 for (sub = info->input_bfds; sub != NULL; sub = sub->link.next)
8878 if (sub->flags & DYNAMIC)
8880 alpha_vms_create_eisd_for_shared (abfd, sub);
8884 if (!alpha_vms_read_sections_content (sub, info))
8888 /* Handle all the link order information for the sections.
8889 Note: past this point, it is not possible to create new sections. */
8890 for (o = abfd->sections; o != NULL; o = o->next)
8892 for (p = o->map_head.link_order; p != NULL; p = p->next)
8896 case bfd_section_reloc_link_order:
8897 case bfd_symbol_reloc_link_order:
8900 case bfd_indirect_link_order:
8904 if (! _bfd_default_link_order (abfd, info, o, p))
8911 /* Compute fixups. */
8912 if (!alpha_vms_build_fixups (info))
8915 /* Compute the DMT. */
8919 unsigned char *contents = NULL;
8921 /* In pass 1, compute the size. In pass 2, write the DMT contents. */
8922 for (pass = 0; pass < 2; pass++)
8924 unsigned int off = 0;
8926 /* For each object file (ie for each module). */
8927 for (sub = info->input_bfds; sub != NULL; sub = sub->link.next)
8930 struct vms_dmt_header *dmth = NULL;
8931 unsigned int psect_count;
8933 /* Skip this module if it has no DST. */
8934 sub_dst = PRIV2 (sub, dst_section);
8935 if (sub_dst == NULL || sub_dst->size == 0)
8940 /* Write the header. */
8941 dmth = (struct vms_dmt_header *)(contents + off);
8942 bfd_putl32 (sub_dst->output_offset, dmth->modbeg);
8943 bfd_putl32 (sub_dst->size, dmth->size);
8946 off += sizeof (struct vms_dmt_header);
8949 /* For each section (ie for each psect). */
8950 for (o = sub->sections; o != NULL; o = o->next)
8952 /* Only consider interesting sections. */
8953 if (!(o->flags & SEC_ALLOC))
8955 if (o->flags & SEC_LINKER_CREATED)
8960 /* Write an entry. */
8961 struct vms_dmt_psect *dmtp;
8963 dmtp = (struct vms_dmt_psect *)(contents + off);
8964 bfd_putl32 (o->output_offset + o->output_section->vma,
8966 bfd_putl32 (o->size, dmtp->length);
8969 off += sizeof (struct vms_dmt_psect);
8972 bfd_putl32 (psect_count, dmth->psect_count);
8977 contents = bfd_zalloc (info->output_bfd, off);
8978 if (contents == NULL)
8980 dmt->contents = contents;
8985 BFD_ASSERT (off == dmt->size);
8993 /* Read the contents of a section.
8994 buf points to a buffer of buf_size bytes to be filled with
8995 section data (starting at offset into section) */
8998 alpha_vms_get_section_contents (bfd *abfd, asection *section,
8999 void *buf, file_ptr offset,
9000 bfd_size_type count)
9004 /* Image are easy. */
9005 if (bfd_get_file_flags (abfd) & (EXEC_P | DYNAMIC))
9006 return _bfd_generic_get_section_contents (abfd, section,
9007 buf, offset, count);
9010 if (offset + count < count
9011 || offset + count > section->size)
9013 bfd_set_error (bfd_error_invalid_operation);
9017 /* If the section is already in memory, just copy it. */
9018 if (section->flags & SEC_IN_MEMORY)
9020 BFD_ASSERT (section->contents != NULL);
9021 memcpy (buf, section->contents + offset, count);
9024 if (section->size == 0)
9027 /* Alloc in memory and read ETIRs. */
9028 for (sec = abfd->sections; sec; sec = sec->next)
9030 BFD_ASSERT (sec->contents == NULL);
9032 if (sec->size != 0 && (sec->flags & SEC_HAS_CONTENTS))
9034 sec->contents = bfd_alloc (abfd, sec->size);
9035 if (sec->contents == NULL)
9039 if (!alpha_vms_read_sections_content (abfd, NULL))
9041 for (sec = abfd->sections; sec; sec = sec->next)
9043 sec->flags |= SEC_IN_MEMORY;
9044 memcpy (buf, section->contents + offset, count);
9049 /* Set the format of a file being written. */
9052 alpha_vms_mkobject (bfd * abfd)
9054 const bfd_arch_info_type *arch;
9056 vms_debug2 ((1, "alpha_vms_mkobject (%p)\n", abfd));
9058 if (!vms_initialize (abfd))
9061 PRIV (recwr.buf) = bfd_alloc (abfd, MAX_OUTREC_SIZE);
9062 if (PRIV (recwr.buf) == NULL)
9065 arch = bfd_scan_arch ("alpha");
9069 bfd_set_error (bfd_error_wrong_format);
9073 abfd->arch_info = arch;
9080 /* Called when the BFD is being closed to do any necessary cleanup. */
9083 vms_close_and_cleanup (bfd * abfd)
9085 vms_debug2 ((1, "vms_close_and_cleanup (%p)\n", abfd));
9087 if (abfd == NULL || abfd->tdata.any == NULL)
9090 if (abfd->format == bfd_archive)
9092 bfd_release (abfd, abfd->tdata.any);
9093 abfd->tdata.any = NULL;
9097 if (PRIV (recrd.buf) != NULL)
9098 free (PRIV (recrd.buf));
9100 if (PRIV (sections) != NULL)
9101 free (PRIV (sections));
9103 bfd_release (abfd, abfd->tdata.any);
9104 abfd->tdata.any = NULL;
9107 if (abfd->direction == write_direction)
9109 /* Last step on VMS is to convert the file to variable record length
9111 if (!bfd_cache_close (abfd))
9113 if (!_bfd_vms_convert_to_var_unix_filename (abfd->filename))
9121 /* Called when a new section is created. */
9124 vms_new_section_hook (bfd * abfd, asection *section)
9128 vms_debug2 ((1, "vms_new_section_hook (%p, [%u]%s)\n",
9129 abfd, section->index, section->name));
9131 if (! bfd_set_section_alignment (abfd, section, 0))
9134 vms_debug2 ((7, "%u: %s\n", section->index, section->name));
9136 amt = sizeof (struct vms_section_data_struct);
9137 section->used_by_bfd = bfd_zalloc (abfd, amt);
9138 if (section->used_by_bfd == NULL)
9141 /* Create the section symbol. */
9142 return _bfd_generic_new_section_hook (abfd, section);
9145 /* Part 4.5, symbols. */
9147 /* Print symbol to file according to how. how is one of
9148 bfd_print_symbol_name just print the name
9149 bfd_print_symbol_more print more (???)
9150 bfd_print_symbol_all print all we know, which is not much right now :-). */
9153 vms_print_symbol (bfd * abfd,
9156 bfd_print_symbol_type how)
9158 vms_debug2 ((1, "vms_print_symbol (%p, %p, %p, %d)\n",
9159 abfd, file, symbol, how));
9163 case bfd_print_symbol_name:
9164 case bfd_print_symbol_more:
9165 fprintf ((FILE *)file," %s", symbol->name);
9168 case bfd_print_symbol_all:
9170 const char *section_name = symbol->section->name;
9172 bfd_print_symbol_vandf (abfd, file, symbol);
9174 fprintf ((FILE *) file," %-8s %s", section_name, symbol->name);
9180 /* Return information about symbol in ret.
9182 fill type, value and name
9185 B bss segment symbol
9187 D data segment symbol
9189 t a static function symbol
9190 T text segment symbol
9195 vms_get_symbol_info (bfd * abfd ATTRIBUTE_UNUSED,
9201 vms_debug2 ((1, "vms_get_symbol_info (%p, %p, %p)\n", abfd, symbol, ret));
9203 sec = symbol->section;
9210 else if (bfd_is_com_section (sec))
9212 else if (bfd_is_abs_section (sec))
9214 else if (bfd_is_und_section (sec))
9216 else if (bfd_is_ind_section (sec))
9218 else if ((symbol->flags & BSF_FUNCTION)
9219 || (bfd_get_section_flags (abfd, sec) & SEC_CODE))
9221 else if (bfd_get_section_flags (abfd, sec) & SEC_DATA)
9223 else if (bfd_get_section_flags (abfd, sec) & SEC_ALLOC)
9228 if (ret->type != 'U')
9229 ret->value = symbol->value + symbol->section->vma;
9232 ret->name = symbol->name;
9235 /* Return TRUE if the given symbol sym in the BFD abfd is
9236 a compiler generated local label, else return FALSE. */
9239 vms_bfd_is_local_label_name (bfd * abfd ATTRIBUTE_UNUSED,
9242 return name[0] == '$';
9245 /* Part 4.7, writing an object file. */
9247 /* Sets the contents of the section section in BFD abfd to the data starting
9248 in memory at LOCATION. The data is written to the output section starting
9249 at offset offset for count bytes.
9251 Normally TRUE is returned, else FALSE. Possible error returns are:
9252 o bfd_error_no_contents - The output section does not have the
9253 SEC_HAS_CONTENTS attribute, so nothing can be written to it.
9254 o and some more too */
9257 _bfd_vms_set_section_contents (bfd * abfd,
9259 const void * location,
9261 bfd_size_type count)
9263 if (section->contents == NULL)
9265 section->contents = bfd_alloc (abfd, section->size);
9266 if (section->contents == NULL)
9269 memcpy (section->contents + offset, location, (size_t) count);
9275 /* Set the architecture and machine type in BFD abfd to arch and mach.
9276 Find the correct pointer to a structure and insert it into the arch_info
9280 alpha_vms_set_arch_mach (bfd *abfd,
9281 enum bfd_architecture arch, unsigned long mach)
9283 if (arch != bfd_arch_alpha
9284 && arch != bfd_arch_unknown)
9287 return bfd_default_set_arch_mach (abfd, arch, mach);
9290 /* Set section VMS flags. Clear NO_FLAGS and set FLAGS. */
9293 bfd_vms_set_section_flags (bfd *abfd ATTRIBUTE_UNUSED,
9294 asection *sec, flagword no_flags, flagword flags)
9296 vms_section_data (sec)->no_flags = no_flags;
9297 vms_section_data (sec)->flags = flags;
9300 struct vms_private_data_struct *
9301 bfd_vms_get_data (bfd *abfd)
9303 return (struct vms_private_data_struct *)abfd->tdata.any;
9306 #define vms_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
9307 #define vms_bfd_link_just_syms _bfd_generic_link_just_syms
9308 #define vms_bfd_copy_link_hash_symbol_type \
9309 _bfd_generic_copy_link_hash_symbol_type
9310 #define vms_bfd_is_group_section bfd_generic_is_group_section
9311 #define vms_bfd_discard_group bfd_generic_discard_group
9312 #define vms_section_already_linked _bfd_generic_section_already_linked
9313 #define vms_bfd_define_common_symbol bfd_generic_define_common_symbol
9314 #define vms_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
9316 #define vms_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
9317 #define vms_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
9318 #define vms_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data
9319 #define vms_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
9320 #define vms_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
9321 #define vms_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
9323 /* Symbols table. */
9324 #define alpha_vms_make_empty_symbol _bfd_generic_make_empty_symbol
9325 #define alpha_vms_bfd_is_target_special_symbol \
9326 ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
9327 #define alpha_vms_print_symbol vms_print_symbol
9328 #define alpha_vms_get_symbol_info vms_get_symbol_info
9329 #define alpha_vms_get_symbol_version_string \
9330 _bfd_nosymbols_get_symbol_version_string
9332 #define alpha_vms_read_minisymbols _bfd_generic_read_minisymbols
9333 #define alpha_vms_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
9334 #define alpha_vms_get_lineno _bfd_nosymbols_get_lineno
9335 #define alpha_vms_find_inliner_info _bfd_nosymbols_find_inliner_info
9336 #define alpha_vms_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
9337 #define alpha_vms_find_nearest_line _bfd_vms_find_nearest_line
9338 #define alpha_vms_find_line _bfd_nosymbols_find_line
9339 #define alpha_vms_bfd_is_local_label_name vms_bfd_is_local_label_name
9341 /* Generic table. */
9342 #define alpha_vms_close_and_cleanup vms_close_and_cleanup
9343 #define alpha_vms_bfd_free_cached_info vms_bfd_free_cached_info
9344 #define alpha_vms_new_section_hook vms_new_section_hook
9345 #define alpha_vms_set_section_contents _bfd_vms_set_section_contents
9346 #define alpha_vms_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
9348 #define alpha_vms_bfd_get_relocated_section_contents \
9349 bfd_generic_get_relocated_section_contents
9351 #define alpha_vms_bfd_relax_section bfd_generic_relax_section
9352 #define alpha_vms_bfd_gc_sections bfd_generic_gc_sections
9353 #define alpha_vms_bfd_lookup_section_flags bfd_generic_lookup_section_flags
9354 #define alpha_vms_bfd_merge_sections bfd_generic_merge_sections
9355 #define alpha_vms_bfd_is_group_section bfd_generic_is_group_section
9356 #define alpha_vms_bfd_discard_group bfd_generic_discard_group
9357 #define alpha_vms_section_already_linked \
9358 _bfd_generic_section_already_linked
9360 #define alpha_vms_bfd_define_common_symbol bfd_generic_define_common_symbol
9361 #define alpha_vms_bfd_link_just_syms _bfd_generic_link_just_syms
9362 #define alpha_vms_bfd_copy_link_hash_symbol_type \
9363 _bfd_generic_copy_link_hash_symbol_type
9365 #define alpha_vms_bfd_link_split_section _bfd_generic_link_split_section
9367 #define alpha_vms_get_dynamic_symtab_upper_bound \
9368 _bfd_nodynamic_get_dynamic_symtab_upper_bound
9369 #define alpha_vms_canonicalize_dynamic_symtab \
9370 _bfd_nodynamic_canonicalize_dynamic_symtab
9371 #define alpha_vms_get_dynamic_reloc_upper_bound \
9372 _bfd_nodynamic_get_dynamic_reloc_upper_bound
9373 #define alpha_vms_canonicalize_dynamic_reloc \
9374 _bfd_nodynamic_canonicalize_dynamic_reloc
9375 #define alpha_vms_bfd_link_check_relocs _bfd_generic_link_check_relocs
9377 const bfd_target alpha_vms_vec =
9379 "vms-alpha", /* Name. */
9380 bfd_target_evax_flavour,
9381 BFD_ENDIAN_LITTLE, /* Data byte order is little. */
9382 BFD_ENDIAN_LITTLE, /* Header byte order is little. */
9384 (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS
9385 | WP_TEXT | D_PAGED), /* Object flags. */
9386 (SEC_ALLOC | SEC_LOAD | SEC_RELOC
9387 | SEC_READONLY | SEC_CODE | SEC_DATA
9388 | SEC_HAS_CONTENTS | SEC_IN_MEMORY), /* Sect flags. */
9389 0, /* symbol_leading_char. */
9390 ' ', /* ar_pad_char. */
9391 15, /* ar_max_namelen. */
9392 0, /* match priority. */
9393 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
9394 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
9395 bfd_getl16, bfd_getl_signed_16, bfd_putl16,
9396 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
9397 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
9398 bfd_getl16, bfd_getl_signed_16, bfd_putl16,
9400 {_bfd_dummy_target, alpha_vms_object_p, /* bfd_check_format. */
9401 _bfd_vms_lib_alpha_archive_p, _bfd_dummy_target},
9402 {bfd_false, alpha_vms_mkobject, /* bfd_set_format. */
9403 _bfd_vms_lib_alpha_mkarchive, bfd_false},
9404 {bfd_false, alpha_vms_write_object_contents, /* bfd_write_contents. */
9405 _bfd_vms_lib_write_archive_contents, bfd_false},
9407 BFD_JUMP_TABLE_GENERIC (alpha_vms),
9408 BFD_JUMP_TABLE_COPY (vms),
9409 BFD_JUMP_TABLE_CORE (_bfd_nocore),
9410 BFD_JUMP_TABLE_ARCHIVE (_bfd_vms_lib),
9411 BFD_JUMP_TABLE_SYMBOLS (alpha_vms),
9412 BFD_JUMP_TABLE_RELOCS (alpha_vms),
9413 BFD_JUMP_TABLE_WRITE (alpha_vms),
9414 BFD_JUMP_TABLE_LINK (alpha_vms),
9415 BFD_JUMP_TABLE_DYNAMIC (alpha_vms),