1 /* vms.c -- BFD back-end for EVAX (openVMS/Alpha) files.
2 Copyright (C) 1996-2017 Free Software Foundation, Inc.
4 Initial version written by Klaus Kaempf (kkaempf@rmi.de)
5 Major rewrite by Adacore.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20 MA 02110-1301, USA. */
25 o Generation of shared image
26 o Relocation optimizations
32 o protected sections (for messages)
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;
524 /* PR 17512: file: 3d9e9fe9.
525 12 is the offset of the eisdsize field from the start of the record (8)
526 plus the size of the eisdsize field (4). */
527 if (offset >= PRIV (recrd.rec_size) - 12)
529 eisd = (struct vms_eisd *)(PRIV (recrd.rec) + offset);
530 rec_size = bfd_getl32 (eisd->eisdsize);
534 /* Skip to next block if pad. */
535 if (rec_size == 0xffffffff)
537 offset = (offset + VMS_BLOCK_SIZE) & ~(VMS_BLOCK_SIZE - 1);
541 /* Make sure that there is enough data present in the record. */
542 /* FIXME: Should we use sizeof (struct vms_eisd) rather than just 32 here ? */
545 /* Make sure that the record is not too big either. */
546 if (offset + rec_size >= PRIV (recrd.rec_size))
551 size = bfd_getl32 (eisd->secsize);
552 vaddr = bfd_getl64 (eisd->virt_addr);
553 flags = bfd_getl32 (eisd->flags);
554 vbn = bfd_getl32 (eisd->vbn);
556 vms_debug2 ((4, "EISD at 0x%x size 0x%x addr 0x%lx flags 0x%x blk %d\n",
557 offset, size, (unsigned long)vaddr, flags, vbn));
559 /* VMS combines psects from .obj files into isects in the .exe. This
560 process doesn't preserve enough information to reliably determine
561 what's in each section without examining the data. This is
562 especially true of DWARF debug sections. */
563 bfd_flags = SEC_ALLOC;
565 bfd_flags |= SEC_HAS_CONTENTS | SEC_LOAD;
567 if (flags & EISD__M_EXE)
568 bfd_flags |= SEC_CODE;
570 if (flags & EISD__M_NONSHRADR)
571 bfd_flags |= SEC_DATA;
573 if (!(flags & EISD__M_WRT))
574 bfd_flags |= SEC_READONLY;
576 if (flags & EISD__M_DZRO)
577 bfd_flags |= SEC_DATA;
579 if (flags & EISD__M_FIXUPVEC)
580 bfd_flags |= SEC_DATA;
582 if (flags & EISD__M_CRF)
583 bfd_flags |= SEC_DATA;
585 if (flags & EISD__M_GBL)
587 if (rec_size < offsetof (struct vms_eisd, gblnam))
589 else if (rec_size < sizeof (struct vms_eisd))
590 name = _bfd_vms_save_counted_string (eisd->gblnam,
591 rec_size - offsetof (struct vms_eisd, gblnam));
593 name = _bfd_vms_save_counted_string (eisd->gblnam, EISD__K_GBLNAMLEN);
594 bfd_flags |= SEC_COFF_SHARED_LIBRARY;
595 bfd_flags &= ~(SEC_ALLOC | SEC_LOAD);
597 else if (flags & EISD__M_FIXUPVEC)
599 else if (eisd->type == EISD__K_USRSTACK)
605 name = (char*) bfd_alloc (abfd, 32);
606 if (flags & EISD__M_DZRO)
608 else if (flags & EISD__M_EXE)
610 else if (!(flags & EISD__M_WRT))
614 BFD_ASSERT (section_count < 999);
615 sprintf (name, "$%s_%03d$", pfx, section_count++);
618 section = bfd_make_section (abfd, name);
623 section->filepos = vbn ? VMS_BLOCK_SIZE * (vbn - 1) : 0;
624 section->size = size;
625 section->vma = vaddr;
627 if (!bfd_set_section_flags (abfd, section, bfd_flags))
634 /* Read & process EIHS record.
635 Return TRUE on success, FALSE on error. */
638 _bfd_vms_slurp_eihs (bfd *abfd, unsigned int offset)
640 unsigned char *p = PRIV (recrd.rec) + offset;
642 unsigned int gstsize ATTRIBUTE_UNUSED;
644 unsigned int dstsize;
646 unsigned int dmtbytes;
649 /* PR 21611: Check that offset is valid. */
650 if (offset > PRIV (recrd.rec_size) - (EIHS__L_DMTBYTES + 4))
652 _bfd_error_handler (_("Unable to read EIHS record at offset %#x"), offset);
653 bfd_set_error (bfd_error_file_truncated);
657 gstvbn = bfd_getl32 (p + EIHS__L_GSTVBN);
658 gstsize = bfd_getl32 (p + EIHS__L_GSTSIZE);
659 dstvbn = bfd_getl32 (p + EIHS__L_DSTVBN);
660 dstsize = bfd_getl32 (p + EIHS__L_DSTSIZE);
661 dmtvbn = bfd_getl32 (p + EIHS__L_DMTVBN);
662 dmtbytes = bfd_getl32 (p + EIHS__L_DMTBYTES);
665 vms_debug (8, "_bfd_vms_slurp_ihs\n");
666 vms_debug (4, "EIHS record gstvbn %d gstsize %d dstvbn %d dstsize %d dmtvbn %d dmtbytes %d\n",
667 gstvbn, gstsize, dstvbn, dstsize, dmtvbn, dmtbytes);
672 flagword bfd_flags = SEC_HAS_CONTENTS | SEC_DEBUGGING;
674 section = bfd_make_section (abfd, "$DST$");
678 section->size = dstsize;
679 section->filepos = VMS_BLOCK_SIZE * (dstvbn - 1);
681 if (!bfd_set_section_flags (abfd, section, bfd_flags))
684 PRIV (dst_section) = section;
685 abfd->flags |= (HAS_DEBUG | HAS_LINENO);
690 flagword bfd_flags = SEC_HAS_CONTENTS | SEC_DEBUGGING;
692 section = bfd_make_section (abfd, "$DMT$");
696 section->size = dmtbytes;
697 section->filepos = VMS_BLOCK_SIZE * (dmtvbn - 1);
699 if (!bfd_set_section_flags (abfd, section, bfd_flags))
705 if (bfd_seek (abfd, VMS_BLOCK_SIZE * (gstvbn - 1), SEEK_SET))
707 bfd_set_error (bfd_error_file_truncated);
711 if (!_bfd_vms_slurp_object_records (abfd))
714 abfd->flags |= HAS_SYMS;
720 /* Object file reading. */
722 /* Object file input functions. */
724 /* Get next record from object file to vms_buf.
725 Set PRIV(buf_size) and return it
727 This is a little tricky since it should be portable.
729 The openVMS object file has 'variable length' which means that
730 read() returns data in chunks of (hopefully) correct and expected
731 size. The linker (and other tools on VMS) depend on that. Unix
732 doesn't know about 'formatted' files, so reading and writing such
733 an object file in a Unix environment is not trivial.
735 With the tool 'file' (available on all VMS FTP sites), one
736 can view and change the attributes of a file. Changing from
737 'variable length' to 'fixed length, 512 bytes' reveals the
738 record size at the first 2 bytes of every record. The same
739 may happen during the transfer of object files from VMS to Unix,
740 at least with UCX, the DEC implementation of TCP/IP.
742 The VMS format repeats the size at bytes 2 & 3 of every record.
744 On the first call (file_format == FF_UNKNOWN) we check if
745 the first and the third byte pair (!) of the record match.
746 If they do it's an object file in an Unix environment or with
747 wrong attributes (FF_FOREIGN), else we should be in a VMS
748 environment where read() returns the record size (FF_NATIVE).
750 Reading is always done in 2 steps:
751 1. first just the record header is read and the size extracted,
752 2. then the read buffer is adjusted and the remaining bytes are
755 All file I/O is done on even file positions. */
757 #define VMS_OBJECT_ADJUSTMENT 2
760 maybe_adjust_record_pointer_for_object (bfd *abfd)
762 /* Set the file format once for all on the first invocation. */
763 if (PRIV (recrd.file_format) == FF_UNKNOWN)
765 if (PRIV (recrd.rec)[0] == PRIV (recrd.rec)[4]
766 && PRIV (recrd.rec)[1] == PRIV (recrd.rec)[5])
767 PRIV (recrd.file_format) = FF_FOREIGN;
769 PRIV (recrd.file_format) = FF_NATIVE;
772 /* The adjustment is needed only in an Unix environment. */
773 if (PRIV (recrd.file_format) == FF_FOREIGN)
774 PRIV (recrd.rec) += VMS_OBJECT_ADJUSTMENT;
777 /* Implement step #1 of the object record reading procedure.
778 Return the record type or -1 on failure. */
781 _bfd_vms_get_object_record (bfd *abfd)
783 unsigned int test_len = 6;
786 vms_debug2 ((8, "_bfd_vms_get_obj_record\n"));
788 /* Skip alignment byte if the current position is odd. */
789 if (PRIV (recrd.file_format) == FF_FOREIGN && (bfd_tell (abfd) & 1))
791 if (bfd_bread (PRIV (recrd.buf), 1, abfd) != 1)
793 bfd_set_error (bfd_error_file_truncated);
798 /* Read the record header */
799 if (bfd_bread (PRIV (recrd.buf), test_len, abfd) != test_len)
801 bfd_set_error (bfd_error_file_truncated);
805 /* Reset the record pointer. */
806 PRIV (recrd.rec) = PRIV (recrd.buf);
807 maybe_adjust_record_pointer_for_object (abfd);
809 if (vms_get_remaining_object_record (abfd, test_len) <= 0)
812 type = bfd_getl16 (PRIV (recrd.rec));
814 vms_debug2 ((8, "_bfd_vms_get_obj_record: rec %p, size %d, type %d\n",
815 PRIV (recrd.rec), PRIV (recrd.rec_size), type));
820 /* Implement step #2 of the object record reading procedure.
821 Return the size of the record or 0 on failure. */
824 vms_get_remaining_object_record (bfd *abfd, unsigned int read_so_far)
826 unsigned int to_read;
828 vms_debug2 ((8, "vms_get_remaining_obj_record\n"));
830 /* Extract record size. */
831 PRIV (recrd.rec_size) = bfd_getl16 (PRIV (recrd.rec) + 2);
833 if (PRIV (recrd.rec_size) == 0)
835 bfd_set_error (bfd_error_file_truncated);
839 /* That's what the linker manual says. */
840 if (PRIV (recrd.rec_size) > EOBJ__C_MAXRECSIZ)
842 bfd_set_error (bfd_error_file_truncated);
846 /* Take into account object adjustment. */
847 to_read = PRIV (recrd.rec_size);
848 if (PRIV (recrd.file_format) == FF_FOREIGN)
849 to_read += VMS_OBJECT_ADJUSTMENT;
851 /* Adjust the buffer. */
852 if (to_read > PRIV (recrd.buf_size))
855 = (unsigned char *) bfd_realloc (PRIV (recrd.buf), to_read);
856 if (PRIV (recrd.buf) == NULL)
858 PRIV (recrd.buf_size) = to_read;
860 /* PR 17512: file: 025-1974-0.004. */
861 else if (to_read <= read_so_far)
864 /* Read the remaining record. */
865 to_read -= read_so_far;
867 vms_debug2 ((8, "vms_get_remaining_obj_record: to_read %d\n", to_read));
869 if (bfd_bread (PRIV (recrd.buf) + read_so_far, to_read, abfd) != to_read)
871 bfd_set_error (bfd_error_file_truncated);
875 /* Reset the record pointer. */
876 PRIV (recrd.rec) = PRIV (recrd.buf);
877 maybe_adjust_record_pointer_for_object (abfd);
879 vms_debug2 ((8, "vms_get_remaining_obj_record: size %d\n",
880 PRIV (recrd.rec_size)));
882 return PRIV (recrd.rec_size);
885 /* Read and process emh record.
886 Return TRUE on success, FALSE on error. */
889 _bfd_vms_slurp_ehdr (bfd *abfd)
892 unsigned char *vms_rec;
896 vms_rec = PRIV (recrd.rec);
897 /* PR 17512: file: 62736583. */
898 end = vms_rec + PRIV (recrd.buf_size);
900 vms_debug2 ((2, "HDR/EMH\n"));
902 subtype = bfd_getl16 (vms_rec + 4);
904 vms_debug2 ((3, "subtype %d\n", subtype));
910 if (vms_rec + 21 >= end)
912 PRIV (hdr_data).hdr_b_strlvl = vms_rec[6];
913 PRIV (hdr_data).hdr_l_arch1 = bfd_getl32 (vms_rec + 8);
914 PRIV (hdr_data).hdr_l_arch2 = bfd_getl32 (vms_rec + 12);
915 PRIV (hdr_data).hdr_l_recsiz = bfd_getl32 (vms_rec + 16);
916 if ((vms_rec + 20 + vms_rec[20] + 1) >= end)
918 PRIV (hdr_data).hdr_t_name = _bfd_vms_save_counted_string (vms_rec + 20, vms_rec[20]);
919 ptr = vms_rec + 20 + vms_rec[20] + 1;
920 if ((ptr + *ptr + 1) >= end)
922 PRIV (hdr_data).hdr_t_version =_bfd_vms_save_counted_string (ptr, *ptr);
926 PRIV (hdr_data).hdr_t_date = _bfd_vms_save_sized_string (ptr, 17);
930 if (vms_rec + PRIV (recrd.rec_size - 6) > end)
932 PRIV (hdr_data).hdr_c_lnm =
933 _bfd_vms_save_sized_string (vms_rec, PRIV (recrd.rec_size - 6));
937 if (vms_rec + PRIV (recrd.rec_size - 6) > end)
939 PRIV (hdr_data).hdr_c_src =
940 _bfd_vms_save_sized_string (vms_rec, PRIV (recrd.rec_size - 6));
944 if (vms_rec + PRIV (recrd.rec_size - 6) > end)
946 PRIV (hdr_data).hdr_c_ttl =
947 _bfd_vms_save_sized_string (vms_rec, PRIV (recrd.rec_size - 6));
957 bfd_set_error (bfd_error_wrong_format);
964 /* Typical sections for evax object files. */
966 #define EVAX_ABS_NAME "$ABS$"
967 #define EVAX_CODE_NAME "$CODE$"
968 #define EVAX_LINK_NAME "$LINK$"
969 #define EVAX_DATA_NAME "$DATA$"
970 #define EVAX_BSS_NAME "$BSS$"
971 #define EVAX_READONLYADDR_NAME "$READONLY_ADDR$"
972 #define EVAX_READONLY_NAME "$READONLY$"
973 #define EVAX_LITERAL_NAME "$LITERAL$"
974 #define EVAX_LITERALS_NAME "$LITERALS"
975 #define EVAX_COMMON_NAME "$COMMON$"
976 #define EVAX_LOCAL_NAME "$LOCAL$"
978 struct sec_flags_struct
980 const char *name; /* Name of section. */
982 flagword flags_always; /* Flags we set always. */
984 flagword flags_hassize; /* Flags we set if the section has a size > 0. */
987 /* These flags are deccrtl/vaxcrtl (openVMS 6.2 Alpha) compatible. */
989 static const struct sec_flags_struct evax_section_flags[] =
997 EGPS__V_PIC | EGPS__V_REL | EGPS__V_SHR | EGPS__V_EXE,
998 SEC_CODE | SEC_READONLY,
999 EGPS__V_PIC | EGPS__V_REL | EGPS__V_SHR | EGPS__V_EXE,
1000 SEC_CODE | SEC_READONLY | SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD },
1001 { EVAX_LITERAL_NAME,
1002 EGPS__V_PIC | EGPS__V_REL | EGPS__V_SHR | EGPS__V_RD | EGPS__V_NOMOD,
1003 SEC_DATA | SEC_READONLY,
1004 EGPS__V_PIC | EGPS__V_REL | EGPS__V_SHR | EGPS__V_RD,
1005 SEC_DATA | SEC_READONLY | SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD },
1007 EGPS__V_REL | EGPS__V_RD,
1008 SEC_DATA | SEC_READONLY,
1009 EGPS__V_REL | EGPS__V_RD,
1010 SEC_DATA | SEC_READONLY | SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD },
1012 EGPS__V_REL | EGPS__V_RD | EGPS__V_WRT | EGPS__V_NOMOD,
1014 EGPS__V_REL | EGPS__V_RD | EGPS__V_WRT,
1015 SEC_DATA | SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD },
1017 EGPS__V_REL | EGPS__V_RD | EGPS__V_WRT | EGPS__V_NOMOD,
1019 EGPS__V_REL | EGPS__V_RD | EGPS__V_WRT | EGPS__V_NOMOD,
1021 { EVAX_READONLYADDR_NAME,
1022 EGPS__V_PIC | EGPS__V_REL | EGPS__V_RD,
1023 SEC_DATA | SEC_READONLY,
1024 EGPS__V_PIC | EGPS__V_REL | EGPS__V_RD,
1025 SEC_DATA | SEC_READONLY | SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD },
1026 { EVAX_READONLY_NAME,
1027 EGPS__V_PIC | EGPS__V_REL | EGPS__V_SHR | EGPS__V_RD | EGPS__V_NOMOD,
1028 SEC_DATA | SEC_READONLY,
1029 EGPS__V_PIC | EGPS__V_REL | EGPS__V_SHR | EGPS__V_RD,
1030 SEC_DATA | SEC_READONLY | SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD },
1032 EGPS__V_REL | EGPS__V_RD | EGPS__V_WRT,
1034 EGPS__V_REL | EGPS__V_RD | EGPS__V_WRT,
1035 SEC_DATA | SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD },
1036 { EVAX_LITERALS_NAME,
1037 EGPS__V_PIC | EGPS__V_OVR,
1038 SEC_DATA | SEC_READONLY,
1039 EGPS__V_PIC | EGPS__V_OVR,
1040 SEC_DATA | SEC_READONLY | SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD },
1042 EGPS__V_REL | EGPS__V_RD | EGPS__V_WRT,
1044 EGPS__V_REL | EGPS__V_RD | EGPS__V_WRT,
1045 SEC_DATA | SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD }
1048 /* Retrieve BFD section flags by name and size. */
1051 vms_secflag_by_name (const struct sec_flags_struct *section_flags,
1057 while (section_flags[i].name != NULL)
1059 if (strcmp (name, section_flags[i].name) == 0)
1062 return section_flags[i].flags_hassize;
1064 return section_flags[i].flags_always;
1069 return section_flags[i].flags_hassize;
1070 return section_flags[i].flags_always;
1073 /* Retrieve VMS section flags by name and size. */
1076 vms_esecflag_by_name (const struct sec_flags_struct *section_flags,
1082 while (section_flags[i].name != NULL)
1084 if (strcmp (name, section_flags[i].name) == 0)
1087 return section_flags[i].vflags_hassize;
1089 return section_flags[i].vflags_always;
1094 return section_flags[i].vflags_hassize;
1095 return section_flags[i].vflags_always;
1098 /* Add SYM to the symbol table of ABFD.
1099 Return FALSE in case of error. */
1102 add_symbol_entry (bfd *abfd, struct vms_symbol_entry *sym)
1104 if (PRIV (gsd_sym_count) >= PRIV (max_sym_count))
1106 if (PRIV (max_sym_count) == 0)
1108 PRIV (max_sym_count) = 128;
1109 PRIV (syms) = bfd_malloc
1110 (PRIV (max_sym_count) * sizeof (struct vms_symbol_entry *));
1114 PRIV (max_sym_count) *= 2;
1115 PRIV (syms) = bfd_realloc
1117 (PRIV (max_sym_count) * sizeof (struct vms_symbol_entry *)));
1119 if (PRIV (syms) == NULL)
1123 PRIV (syms)[PRIV (gsd_sym_count)++] = sym;
1127 /* Create a symbol whose name is ASCIC and add it to ABFD.
1128 Return NULL in case of error. */
1130 static struct vms_symbol_entry *
1131 add_symbol (bfd *abfd, const unsigned char *ascic)
1133 struct vms_symbol_entry *entry;
1137 entry = (struct vms_symbol_entry *)bfd_zalloc (abfd, sizeof (*entry) + len);
1140 entry->namelen = len;
1141 memcpy (entry->name, ascic, len);
1142 entry->name[len] = 0;
1143 entry->owner = abfd;
1145 if (!add_symbol_entry (abfd, entry))
1150 /* Read and process EGSD. Return FALSE on failure. */
1153 _bfd_vms_slurp_egsd (bfd *abfd)
1156 unsigned int gsd_size;
1157 unsigned char *vms_rec;
1158 unsigned long base_addr;
1160 vms_debug2 ((2, "EGSD\n"));
1162 if (PRIV (recrd.rec_size) < 8)
1164 _bfd_error_handler (_("Corrupt EGSD record: its size (%#x) is too small"),
1165 PRIV (recrd.rec_size));
1166 bfd_set_error (bfd_error_bad_value);
1170 PRIV (recrd.rec) += 8; /* Skip type, size, align pad. */
1171 PRIV (recrd.rec_size) -= 8;
1173 /* Calculate base address for each section. */
1176 while (PRIV (recrd.rec_size) > 4)
1178 vms_rec = PRIV (recrd.rec);
1180 gsd_type = bfd_getl16 (vms_rec);
1181 gsd_size = bfd_getl16 (vms_rec + 2);
1183 vms_debug2 ((3, "egsd_type %d\n", gsd_type));
1185 /* PR 21615: Check for size overflow. */
1186 if (PRIV (recrd.rec_size) < gsd_size)
1188 _bfd_error_handler (_("Corrupt EGSD record: size (%#x) is larger than remaining space (%#x)"),
1189 gsd_size, PRIV (recrd.rec_size));
1190 bfd_set_error (bfd_error_bad_value);
1196 _bfd_error_handler (_("Corrupt EGSD record: size (%#x) is too small"),
1198 bfd_set_error (bfd_error_bad_value);
1205 /* Program section definition. */
1207 struct vms_egps *egps = (struct vms_egps *)vms_rec;
1208 flagword new_flags, vms_flags;
1211 vms_flags = bfd_getl16 (egps->flags);
1213 if ((vms_flags & EGPS__V_REL) == 0)
1215 /* Use the global absolute section for all
1216 absolute sections. */
1217 section = bfd_abs_section_ptr;
1222 unsigned long align_addr;
1224 name = _bfd_vms_save_counted_string (&egps->namlng, gsd_size - 4);
1226 section = bfd_make_section (abfd, name);
1230 section->filepos = 0;
1231 section->size = bfd_getl32 (egps->alloc);
1232 section->alignment_power = egps->align;
1234 vms_section_data (section)->flags = vms_flags;
1235 vms_section_data (section)->no_flags = 0;
1237 new_flags = vms_secflag_by_name (evax_section_flags, name,
1239 if (section->size > 0)
1240 new_flags |= SEC_LOAD;
1241 if (!(vms_flags & EGPS__V_NOMOD) && section->size > 0)
1243 /* Set RELOC and HAS_CONTENTS if the section is not
1244 demand-zero and not empty. */
1245 new_flags |= SEC_HAS_CONTENTS;
1246 if (vms_flags & EGPS__V_REL)
1247 new_flags |= SEC_RELOC;
1249 if (vms_flags & EGPS__V_EXE)
1251 /* Set CODE if section is executable. */
1252 new_flags |= SEC_CODE;
1253 new_flags &= ~SEC_DATA;
1255 if (!bfd_set_section_flags (abfd, section, new_flags))
1258 /* Give a non-overlapping vma to non absolute sections. */
1259 align_addr = (1 << section->alignment_power);
1260 if ((base_addr % align_addr) != 0)
1261 base_addr += (align_addr - (base_addr % align_addr));
1262 section->vma = (bfd_vma)base_addr;
1263 base_addr += section->size;
1266 /* Append it to the section array. */
1267 if (PRIV (section_count) >= PRIV (section_max))
1269 if (PRIV (section_max) == 0)
1270 PRIV (section_max) = 16;
1272 PRIV (section_max) *= 2;
1273 PRIV (sections) = bfd_realloc_or_free
1274 (PRIV (sections), PRIV (section_max) * sizeof (asection *));
1275 if (PRIV (sections) == NULL)
1279 PRIV (sections)[PRIV (section_count)] = section;
1280 PRIV (section_count)++;
1287 struct vms_symbol_entry *entry;
1288 struct vms_egsy *egsy = (struct vms_egsy *) vms_rec;
1291 old_flags = bfd_getl16 (egsy->flags);
1292 if (old_flags & EGSY__V_DEF)
1293 nameoff = ESDF__B_NAMLNG;
1295 nameoff = ESRF__B_NAMLNG;
1297 entry = add_symbol (abfd, vms_rec + nameoff);
1301 /* Allow only duplicate reference. */
1302 if ((entry->flags & EGSY__V_DEF) && (old_flags & EGSY__V_DEF))
1305 if (entry->typ == 0)
1307 entry->typ = gsd_type;
1308 entry->data_type = egsy->datyp;
1309 entry->flags = old_flags;
1312 if (old_flags & EGSY__V_DEF)
1314 struct vms_esdf *esdf = (struct vms_esdf *)vms_rec;
1316 entry->value = bfd_getl64 (esdf->value);
1317 if (PRIV (sections) == NULL)
1319 entry->section = PRIV (sections)[bfd_getl32 (esdf->psindx)];
1321 if (old_flags & EGSY__V_NORM)
1323 PRIV (norm_sym_count)++;
1325 entry->code_value = bfd_getl64 (esdf->code_address);
1326 entry->code_section =
1327 PRIV (sections)[bfd_getl32 (esdf->ca_psindx)];
1335 struct vms_symbol_entry *entry;
1336 struct vms_egst *egst = (struct vms_egst *)vms_rec;
1339 old_flags = bfd_getl16 (egst->header.flags);
1341 entry = add_symbol (abfd, &egst->namlng);
1346 entry->typ = gsd_type;
1347 entry->data_type = egst->header.datyp;
1348 entry->flags = old_flags;
1350 entry->symbol_vector = bfd_getl32 (egst->value);
1352 if (old_flags & EGSY__V_REL)
1354 if (PRIV (sections) == NULL)
1356 entry->section = PRIV (sections)[bfd_getl32 (egst->psindx)];
1359 entry->section = bfd_abs_section_ptr;
1361 entry->value = bfd_getl64 (egst->lp_2);
1363 if (old_flags & EGSY__V_NORM)
1365 PRIV (norm_sym_count)++;
1367 entry->code_value = bfd_getl64 (egst->lp_1);
1368 entry->code_section = bfd_abs_section_ptr;
1375 /* Currently ignored. */
1380 _bfd_error_handler (_("Unknown EGSD subtype %d"), gsd_type);
1381 bfd_set_error (bfd_error_bad_value);
1385 PRIV (recrd.rec_size) -= gsd_size;
1386 PRIV (recrd.rec) += gsd_size;
1389 /* FIXME: Should we complain if PRIV (recrd.rec_size) is not zero ? */
1391 if (PRIV (gsd_sym_count) > 0)
1392 abfd->flags |= HAS_SYMS;
1397 /* Stack routines for vms ETIR commands. */
1399 /* Push value and section index. */
1402 _bfd_vms_push (bfd *abfd, bfd_vma val, unsigned int reloc)
1404 vms_debug2 ((4, "<push %08lx (0x%08x) at %d>\n",
1405 (unsigned long)val, reloc, PRIV (stackptr)));
1407 PRIV (stack[PRIV (stackptr)]).value = val;
1408 PRIV (stack[PRIV (stackptr)]).reloc = reloc;
1410 if (PRIV (stackptr) >= STACKSIZE)
1412 bfd_set_error (bfd_error_bad_value);
1413 _bfd_error_handler (_("Stack overflow (%d) in _bfd_vms_push"), PRIV (stackptr));
1418 /* Pop value and section index. */
1421 _bfd_vms_pop (bfd *abfd, bfd_vma *val, unsigned int *rel)
1423 if (PRIV (stackptr) == 0)
1425 bfd_set_error (bfd_error_bad_value);
1426 _bfd_error_handler (_("Stack underflow in _bfd_vms_pop"));
1430 *val = PRIV (stack[PRIV (stackptr)]).value;
1431 *rel = PRIV (stack[PRIV (stackptr)]).reloc;
1433 vms_debug2 ((4, "<pop %08lx (0x%08x)>\n", (unsigned long)*val, *rel));
1436 /* Routines to fill sections contents during tir/etir read. */
1438 /* Initialize image buffer pointer to be filled. */
1441 image_set_ptr (bfd *abfd, bfd_vma vma, int sect, struct bfd_link_info *info)
1445 vms_debug2 ((4, "image_set_ptr (0x%08x, sect=%d)\n", (unsigned)vma, sect));
1447 if (PRIV (sections) == NULL)
1449 sec = PRIV (sections)[sect];
1453 /* Reading contents to an output bfd. */
1455 if (sec->output_section == NULL)
1457 /* Section discarded. */
1458 vms_debug2 ((5, " section %s discarded\n", sec->name));
1460 /* This is not used. */
1461 PRIV (image_section) = NULL;
1462 PRIV (image_offset) = 0;
1465 PRIV (image_offset) = sec->output_offset + vma;
1466 PRIV (image_section) = sec->output_section;
1470 PRIV (image_offset) = vma;
1471 PRIV (image_section) = sec;
1475 /* Increment image buffer pointer by offset. */
1478 image_inc_ptr (bfd *abfd, bfd_vma offset)
1480 vms_debug2 ((4, "image_inc_ptr (%u)\n", (unsigned)offset));
1482 PRIV (image_offset) += offset;
1485 /* Save current DST location counter under specified index. */
1488 dst_define_location (bfd *abfd, unsigned int loc)
1490 vms_debug2 ((4, "dst_define_location (%d)\n", (int)loc));
1492 /* Grow the ptr offset table if necessary. */
1493 if (loc + 1 > PRIV (dst_ptr_offsets_count))
1495 PRIV (dst_ptr_offsets) = bfd_realloc (PRIV (dst_ptr_offsets),
1496 (loc + 1) * sizeof (unsigned int));
1497 PRIV (dst_ptr_offsets_count) = loc + 1;
1500 PRIV (dst_ptr_offsets)[loc] = PRIV (image_offset);
1503 /* Restore saved DST location counter from specified index. */
1506 dst_restore_location (bfd *abfd, unsigned int loc)
1508 vms_debug2 ((4, "dst_restore_location (%d)\n", (int)loc));
1510 PRIV (image_offset) = PRIV (dst_ptr_offsets)[loc];
1513 /* Retrieve saved DST location counter from specified index. */
1516 dst_retrieve_location (bfd *abfd, unsigned int loc)
1518 vms_debug2 ((4, "dst_retrieve_location (%d)\n", (int)loc));
1520 return PRIV (dst_ptr_offsets)[loc];
1523 /* Write multiple bytes to section image. */
1526 image_write (bfd *abfd, unsigned char *ptr, unsigned int size)
1529 _bfd_vms_debug (8, "image_write from (%p, %d) to (%ld)\n", ptr, size,
1530 (long)PRIV (image_offset));
1531 _bfd_hexdump (9, ptr, size, 0);
1534 if (PRIV (image_section)->contents != NULL)
1536 asection *sec = PRIV (image_section);
1537 file_ptr off = PRIV (image_offset);
1540 if (off > (file_ptr)sec->size
1541 || size > (file_ptr)sec->size
1542 || off + size > (file_ptr)sec->size)
1544 bfd_set_error (bfd_error_bad_value);
1548 memcpy (sec->contents + off, ptr, size);
1551 PRIV (image_offset) += size;
1555 /* Write byte to section image. */
1558 image_write_b (bfd * abfd, unsigned int value)
1560 unsigned char data[1];
1562 vms_debug2 ((6, "image_write_b (%02x)\n", (int) value));
1566 return image_write (abfd, data, sizeof (data));
1569 /* Write 2-byte word to image. */
1572 image_write_w (bfd * abfd, unsigned int value)
1574 unsigned char data[2];
1576 vms_debug2 ((6, "image_write_w (%04x)\n", (int) value));
1578 bfd_putl16 (value, data);
1579 return image_write (abfd, data, sizeof (data));
1582 /* Write 4-byte long to image. */
1585 image_write_l (bfd * abfd, unsigned long value)
1587 unsigned char data[4];
1589 vms_debug2 ((6, "image_write_l (%08lx)\n", value));
1591 bfd_putl32 (value, data);
1592 return image_write (abfd, data, sizeof (data));
1595 /* Write 8-byte quad to image. */
1598 image_write_q (bfd * abfd, bfd_vma value)
1600 unsigned char data[8];
1602 vms_debug2 ((6, "image_write_q (%08lx)\n", (unsigned long)value));
1604 bfd_putl64 (value, data);
1605 return image_write (abfd, data, sizeof (data));
1609 _bfd_vms_etir_name (int cmd)
1613 case ETIR__C_STA_GBL: return "ETIR__C_STA_GBL";
1614 case ETIR__C_STA_LW: return "ETIR__C_STA_LW";
1615 case ETIR__C_STA_QW: return "ETIR__C_STA_QW";
1616 case ETIR__C_STA_PQ: return "ETIR__C_STA_PQ";
1617 case ETIR__C_STA_LI: return "ETIR__C_STA_LI";
1618 case ETIR__C_STA_MOD: return "ETIR__C_STA_MOD";
1619 case ETIR__C_STA_CKARG: return "ETIR__C_STA_CKARG";
1620 case ETIR__C_STO_B: return "ETIR__C_STO_B";
1621 case ETIR__C_STO_W: return "ETIR__C_STO_W";
1622 case ETIR__C_STO_GBL: return "ETIR__C_STO_GBL";
1623 case ETIR__C_STO_CA: return "ETIR__C_STO_CA";
1624 case ETIR__C_STO_RB: return "ETIR__C_STO_RB";
1625 case ETIR__C_STO_AB: return "ETIR__C_STO_AB";
1626 case ETIR__C_STO_OFF: return "ETIR__C_STO_OFF";
1627 case ETIR__C_STO_IMM: return "ETIR__C_STO_IMM";
1628 case ETIR__C_STO_IMMR: return "ETIR__C_STO_IMMR";
1629 case ETIR__C_STO_LW: return "ETIR__C_STO_LW";
1630 case ETIR__C_STO_QW: return "ETIR__C_STO_QW";
1631 case ETIR__C_STO_GBL_LW: return "ETIR__C_STO_GBL_LW";
1632 case ETIR__C_STO_LP_PSB: return "ETIR__C_STO_LP_PSB";
1633 case ETIR__C_STO_HINT_GBL: return "ETIR__C_STO_HINT_GBL";
1634 case ETIR__C_STO_HINT_PS: return "ETIR__C_STO_HINT_PS";
1635 case ETIR__C_OPR_ADD: return "ETIR__C_OPR_ADD";
1636 case ETIR__C_OPR_SUB: return "ETIR__C_OPR_SUB";
1637 case ETIR__C_OPR_INSV: return "ETIR__C_OPR_INSV";
1638 case ETIR__C_OPR_USH: return "ETIR__C_OPR_USH";
1639 case ETIR__C_OPR_ROT: return "ETIR__C_OPR_ROT";
1640 case ETIR__C_OPR_REDEF: return "ETIR__C_OPR_REDEF";
1641 case ETIR__C_OPR_DFLIT: return "ETIR__C_OPR_DFLIT";
1642 case ETIR__C_STC_LP: return "ETIR__C_STC_LP";
1643 case ETIR__C_STC_GBL: return "ETIR__C_STC_GBL";
1644 case ETIR__C_STC_GCA: return "ETIR__C_STC_GCA";
1645 case ETIR__C_STC_PS: return "ETIR__C_STC_PS";
1646 case ETIR__C_STC_NBH_PS: return "ETIR__C_STC_NBH_PS";
1647 case ETIR__C_STC_NOP_GBL: return "ETIR__C_STC_NOP_GBL";
1648 case ETIR__C_STC_NOP_PS: return "ETIR__C_STC_NOP_PS";
1649 case ETIR__C_STC_BSR_GBL: return "ETIR__C_STC_BSR_GBL";
1650 case ETIR__C_STC_BSR_PS: return "ETIR__C_STC_BSR_PS";
1651 case ETIR__C_STC_LDA_GBL: return "ETIR__C_STC_LDA_GBL";
1652 case ETIR__C_STC_LDA_PS: return "ETIR__C_STC_LDA_PS";
1653 case ETIR__C_STC_BOH_GBL: return "ETIR__C_STC_BOH_GBL";
1654 case ETIR__C_STC_BOH_PS: return "ETIR__C_STC_BOH_PS";
1655 case ETIR__C_STC_NBH_GBL: return "ETIR__C_STC_NBH_GBL";
1656 case ETIR__C_STC_LP_PSB: return "ETIR__C_STC_LP_PSB";
1657 case ETIR__C_CTL_SETRB: return "ETIR__C_CTL_SETRB";
1658 case ETIR__C_CTL_AUGRB: return "ETIR__C_CTL_AUGRB";
1659 case ETIR__C_CTL_DFLOC: return "ETIR__C_CTL_DFLOC";
1660 case ETIR__C_CTL_STLOC: return "ETIR__C_CTL_STLOC";
1661 case ETIR__C_CTL_STKDL: return "ETIR__C_CTL_STKDL";
1664 /* These names have not yet been added to this switch statement. */
1665 _bfd_error_handler (_("unknown ETIR command %d"), cmd);
1670 #define HIGHBIT(op) ((op & 0x80000000L) == 0x80000000L)
1673 _bfd_vms_get_value (bfd *abfd,
1674 const unsigned char *ascic,
1675 const unsigned char *max_ascic,
1676 struct bfd_link_info *info,
1678 struct alpha_vms_link_hash_entry **hp)
1683 struct alpha_vms_link_hash_entry *h;
1685 /* Not linking. Do not try to resolve the symbol. */
1694 if (ascic + len >= max_ascic)
1696 _bfd_error_handler (_("Corrupt vms value"));
1702 for (i = 0; i < len; i++)
1703 name[i] = ascic[i + 1];
1706 h = (struct alpha_vms_link_hash_entry *)
1707 bfd_link_hash_lookup (info->hash, name, FALSE, FALSE, TRUE);
1712 && (h->root.type == bfd_link_hash_defined
1713 || h->root.type == bfd_link_hash_defweak))
1714 *vma = h->root.u.def.value
1715 + h->root.u.def.section->output_offset
1716 + h->root.u.def.section->output_section->vma;
1717 else if (h && h->root.type == bfd_link_hash_undefweak)
1721 (*info->callbacks->undefined_symbol)
1722 (info, name, abfd, PRIV (image_section), PRIV (image_offset), TRUE);
1729 #define RELC_SHR_BASE 0x10000
1730 #define RELC_SEC_BASE 0x20000
1731 #define RELC_MASK 0x0ffff
1734 alpha_vms_sym_to_ctxt (struct alpha_vms_link_hash_entry *h)
1736 /* Handle undefined symbols. */
1737 if (h == NULL || h->sym == NULL)
1740 if (h->sym->typ == EGSD__C_SYMG)
1742 if (h->sym->flags & EGSY__V_REL)
1743 return RELC_SHR_BASE + PRIV2 (h->sym->owner, shr_index);
1746 /* Can this happen (non-relocatable symg) ? I'd like to see
1751 if (h->sym->typ == EGSD__C_SYM)
1753 if (h->sym->flags & EGSY__V_REL)
1762 alpha_vms_get_sym_value (asection *sect, bfd_vma addr)
1764 return sect->output_section->vma + sect->output_offset + addr;
1768 alpha_vms_fix_sec_rel (bfd *abfd, struct bfd_link_info *info,
1769 unsigned int rel, bfd_vma vma)
1773 if (PRIV (sections) == NULL)
1776 sec = PRIV (sections)[rel & RELC_MASK];
1780 if (sec->output_section == NULL)
1782 return vma + sec->output_section->vma + sec->output_offset;
1785 return vma + sec->vma;
1788 /* Read an ETIR record from ABFD. If INFO is not null, put the content into
1789 the output section (used during linking).
1790 Return FALSE in case of error. */
1793 _bfd_vms_slurp_etir (bfd *abfd, struct bfd_link_info *info)
1796 unsigned int length;
1797 unsigned char *maxptr;
1802 struct alpha_vms_link_hash_entry *h;
1804 PRIV (recrd.rec) += ETIR__C_HEADER_SIZE;
1805 PRIV (recrd.rec_size) -= ETIR__C_HEADER_SIZE;
1807 ptr = PRIV (recrd.rec);
1808 length = PRIV (recrd.rec_size);
1809 maxptr = ptr + length;
1811 vms_debug2 ((2, "ETIR: %d bytes\n", length));
1813 while (ptr < maxptr)
1815 int cmd = bfd_getl16 (ptr);
1816 int cmd_length = bfd_getl16 (ptr + 2);
1820 /* PR 21589 and 21579: Check for a corrupt ETIR record. */
1821 if (cmd_length < 4 || (ptr + cmd_length > maxptr + 4))
1824 _bfd_error_handler (_("Corrupt ETIR record encountered"));
1825 bfd_set_error (bfd_error_bad_value);
1830 _bfd_vms_debug (4, "etir: %s(%d)\n",
1831 _bfd_vms_etir_name (cmd), cmd);
1832 _bfd_hexdump (8, ptr, cmd_length - 4, 0);
1840 stack 32 bit value of symbol (high bits set to 0). */
1841 case ETIR__C_STA_GBL:
1842 _bfd_vms_get_value (abfd, ptr, maxptr, info, &op1, &h);
1843 _bfd_vms_push (abfd, op1, alpha_vms_sym_to_ctxt (h));
1849 stack 32 bit value, sign extend to 64 bit. */
1850 case ETIR__C_STA_LW:
1851 if (ptr + 4 >= maxptr)
1853 _bfd_vms_push (abfd, bfd_getl32 (ptr), RELC_NONE);
1859 stack 64 bit value of symbol. */
1860 case ETIR__C_STA_QW:
1861 if (ptr + 8 >= maxptr)
1863 _bfd_vms_push (abfd, bfd_getl64 (ptr), RELC_NONE);
1866 /* Stack psect base plus quadword offset
1867 arg: lw section index
1868 qw signed quadword offset (low 32 bits)
1870 Stack qw argument and section index
1871 (see ETIR__C_STO_OFF, ETIR__C_CTL_SETRB). */
1872 case ETIR__C_STA_PQ:
1876 if (ptr + 12 >= maxptr)
1878 psect = bfd_getl32 (ptr);
1879 if ((unsigned int) psect >= PRIV (section_count))
1881 _bfd_error_handler (_("bad section index in %s"),
1882 _bfd_vms_etir_name (cmd));
1883 bfd_set_error (bfd_error_bad_value);
1886 op1 = bfd_getl64 (ptr + 4);
1887 _bfd_vms_push (abfd, op1, psect | RELC_SEC_BASE);
1891 case ETIR__C_STA_LI:
1892 case ETIR__C_STA_MOD:
1893 case ETIR__C_STA_CKARG:
1894 _bfd_error_handler (_("unsupported STA cmd %s"),
1895 _bfd_vms_etir_name (cmd));
1899 /* Store byte: pop stack, write byte
1902 _bfd_vms_pop (abfd, &op1, &rel1);
1903 if (rel1 != RELC_NONE)
1905 image_write_b (abfd, (unsigned int) op1 & 0xff);
1908 /* Store word: pop stack, write word
1911 _bfd_vms_pop (abfd, &op1, &rel1);
1912 if (rel1 != RELC_NONE)
1914 image_write_w (abfd, (unsigned int) op1 & 0xffff);
1917 /* Store longword: pop stack, write longword
1919 case ETIR__C_STO_LW:
1920 _bfd_vms_pop (abfd, &op1, &rel1);
1921 if (rel1 & RELC_SEC_BASE)
1923 op1 = alpha_vms_fix_sec_rel (abfd, info, rel1, op1);
1926 else if (rel1 & RELC_SHR_BASE)
1928 alpha_vms_add_fixup_lr (info, rel1 & RELC_MASK, op1);
1931 if (rel1 != RELC_NONE)
1933 if (rel1 != RELC_REL)
1935 alpha_vms_add_lw_reloc (info);
1937 image_write_l (abfd, op1);
1940 /* Store quadword: pop stack, write quadword
1942 case ETIR__C_STO_QW:
1943 _bfd_vms_pop (abfd, &op1, &rel1);
1944 if (rel1 & RELC_SEC_BASE)
1946 op1 = alpha_vms_fix_sec_rel (abfd, info, rel1, op1);
1949 else if (rel1 & RELC_SHR_BASE)
1951 if (rel1 != RELC_NONE)
1953 if (rel1 != RELC_REL)
1955 alpha_vms_add_qw_reloc (info);
1957 image_write_q (abfd, op1);
1960 /* Store immediate repeated: pop stack for repeat count
1963 case ETIR__C_STO_IMMR:
1967 if (ptr + 4 >= maxptr)
1969 size = bfd_getl32 (ptr);
1970 _bfd_vms_pop (abfd, &op1, &rel1);
1971 if (rel1 != RELC_NONE)
1974 image_write (abfd, ptr + 4, size);
1978 /* Store global: write symbol value
1979 arg: cs global symbol name. */
1980 case ETIR__C_STO_GBL:
1981 _bfd_vms_get_value (abfd, ptr, maxptr, info, &op1, &h);
1984 if (h->sym->typ == EGSD__C_SYMG)
1986 alpha_vms_add_fixup_qr
1987 (info, abfd, h->sym->owner, h->sym->symbol_vector);
1992 op1 = alpha_vms_get_sym_value (h->sym->section,
1994 alpha_vms_add_qw_reloc (info);
1997 image_write_q (abfd, op1);
2000 /* Store code address: write address of entry point
2001 arg: cs global symbol name (procedure). */
2002 case ETIR__C_STO_CA:
2003 _bfd_vms_get_value (abfd, ptr, maxptr, info, &op1, &h);
2006 if (h->sym->flags & EGSY__V_NORM)
2008 /* That's really a procedure. */
2009 if (h->sym->typ == EGSD__C_SYMG)
2011 alpha_vms_add_fixup_ca (info, abfd, h->sym->owner);
2012 op1 = h->sym->symbol_vector;
2016 op1 = alpha_vms_get_sym_value (h->sym->code_section,
2017 h->sym->code_value);
2018 alpha_vms_add_qw_reloc (info);
2023 /* Symbol is not a procedure. */
2027 image_write_q (abfd, op1);
2030 /* Store offset to psect: pop stack, add low 32 bits to base of psect
2032 case ETIR__C_STO_OFF:
2033 _bfd_vms_pop (abfd, &op1, &rel1);
2035 if (!(rel1 & RELC_SEC_BASE))
2038 op1 = alpha_vms_fix_sec_rel (abfd, info, rel1, op1);
2040 image_write_q (abfd, op1);
2044 arg: lw count of bytes
2046 case ETIR__C_STO_IMM:
2050 if (ptr + 4 >= maxptr)
2052 size = bfd_getl32 (ptr);
2053 image_write (abfd, ptr + 4, size);
2057 /* This code is 'reserved to digital' according to the openVMS
2058 linker manual, however it is generated by the DEC C compiler
2059 and defined in the include file.
2060 FIXME, since the following is just a guess
2061 store global longword: store 32bit value of symbol
2062 arg: cs symbol name. */
2063 case ETIR__C_STO_GBL_LW:
2064 _bfd_vms_get_value (abfd, ptr, maxptr, info, &op1, &h);
2068 image_write_l (abfd, op1);
2071 case ETIR__C_STO_RB:
2072 case ETIR__C_STO_AB:
2073 case ETIR__C_STO_LP_PSB:
2074 _bfd_error_handler (_("%s: not supported"),
2075 _bfd_vms_etir_name (cmd));
2078 case ETIR__C_STO_HINT_GBL:
2079 case ETIR__C_STO_HINT_PS:
2080 _bfd_error_handler (_("%s: not implemented"),
2081 _bfd_vms_etir_name (cmd));
2085 /* 200 Store-conditional Linkage Pair
2087 case ETIR__C_STC_LP:
2089 /* 202 Store-conditional Address at global address
2093 case ETIR__C_STC_GBL:
2095 /* 203 Store-conditional Code Address at global address
2097 cs procedure name. */
2098 case ETIR__C_STC_GCA:
2100 /* 204 Store-conditional Address at psect + offset
2104 case ETIR__C_STC_PS:
2105 _bfd_error_handler (_("%s: not supported"),
2106 _bfd_vms_etir_name (cmd));
2110 /* 201 Store-conditional Linkage Pair with Procedure Signature
2116 case ETIR__C_STC_LP_PSB:
2117 _bfd_vms_get_value (abfd, ptr + 4, maxptr, info, &op1, &h);
2120 if (h->sym->typ == EGSD__C_SYMG)
2122 alpha_vms_add_fixup_lp (info, abfd, h->sym->owner);
2123 op1 = h->sym->symbol_vector;
2128 op1 = alpha_vms_get_sym_value (h->sym->code_section,
2129 h->sym->code_value);
2130 op2 = alpha_vms_get_sym_value (h->sym->section,
2136 /* Undefined symbol. */
2140 image_write_q (abfd, op1);
2141 image_write_q (abfd, op2);
2144 /* 205 Store-conditional NOP at address of global
2146 case ETIR__C_STC_NOP_GBL:
2149 /* 207 Store-conditional BSR at global address
2152 case ETIR__C_STC_BSR_GBL:
2155 /* 209 Store-conditional LDA at global address
2158 case ETIR__C_STC_LDA_GBL:
2161 /* 211 Store-conditional BSR or Hint at global address
2164 case ETIR__C_STC_BOH_GBL:
2165 /* Currentl ignored. */
2168 /* 213 Store-conditional NOP,BSR or HINT at global address
2171 case ETIR__C_STC_NBH_GBL:
2173 /* 206 Store-conditional NOP at pect + offset
2176 case ETIR__C_STC_NOP_PS:
2178 /* 208 Store-conditional BSR at pect + offset
2181 case ETIR__C_STC_BSR_PS:
2183 /* 210 Store-conditional LDA at psect + offset
2186 case ETIR__C_STC_LDA_PS:
2188 /* 212 Store-conditional BSR or Hint at pect + offset
2191 case ETIR__C_STC_BOH_PS:
2193 /* 214 Store-conditional NOP, BSR or HINT at psect + offset
2195 case ETIR__C_STC_NBH_PS:
2196 _bfd_error_handler (_("%s: not supported"),
2197 _bfd_vms_etir_name (cmd));
2201 /* Det relocation base: pop stack, set image location counter
2203 case ETIR__C_CTL_SETRB:
2204 _bfd_vms_pop (abfd, &op1, &rel1);
2205 if (!(rel1 & RELC_SEC_BASE))
2207 image_set_ptr (abfd, op1, rel1 & RELC_MASK, info);
2210 /* Augment relocation base: increment image location counter by offset
2211 arg: lw offset value. */
2212 case ETIR__C_CTL_AUGRB:
2213 if (ptr + 4 >= maxptr)
2215 op1 = bfd_getl32 (ptr);
2216 image_inc_ptr (abfd, op1);
2219 /* Define location: pop index, save location counter under index
2221 case ETIR__C_CTL_DFLOC:
2222 _bfd_vms_pop (abfd, &op1, &rel1);
2223 if (rel1 != RELC_NONE)
2225 dst_define_location (abfd, op1);
2228 /* Set location: pop index, restore location counter from index
2230 case ETIR__C_CTL_STLOC:
2231 _bfd_vms_pop (abfd, &op1, &rel1);
2232 if (rel1 != RELC_NONE)
2234 dst_restore_location (abfd, op1);
2237 /* Stack defined location: pop index, push location counter from index
2239 case ETIR__C_CTL_STKDL:
2240 _bfd_vms_pop (abfd, &op1, &rel1);
2241 if (rel1 != RELC_NONE)
2243 _bfd_vms_push (abfd, dst_retrieve_location (abfd, op1), RELC_NONE);
2246 case ETIR__C_OPR_NOP: /* No-op. */
2249 case ETIR__C_OPR_ADD: /* Add. */
2250 _bfd_vms_pop (abfd, &op1, &rel1);
2251 _bfd_vms_pop (abfd, &op2, &rel2);
2252 if (rel1 == RELC_NONE && rel2 != RELC_NONE)
2254 else if (rel1 != RELC_NONE && rel2 != RELC_NONE)
2256 _bfd_vms_push (abfd, op1 + op2, rel1);
2259 case ETIR__C_OPR_SUB: /* Subtract. */
2260 _bfd_vms_pop (abfd, &op1, &rel1);
2261 _bfd_vms_pop (abfd, &op2, &rel2);
2262 if (rel1 == RELC_NONE && rel2 != RELC_NONE)
2264 else if ((rel1 & RELC_SEC_BASE) && (rel2 & RELC_SEC_BASE))
2266 op1 = alpha_vms_fix_sec_rel (abfd, info, rel1, op1);
2267 op2 = alpha_vms_fix_sec_rel (abfd, info, rel2, op2);
2270 else if (rel1 != RELC_NONE && rel2 != RELC_NONE)
2272 _bfd_vms_push (abfd, op2 - op1, rel1);
2275 case ETIR__C_OPR_MUL: /* Multiply. */
2276 _bfd_vms_pop (abfd, &op1, &rel1);
2277 _bfd_vms_pop (abfd, &op2, &rel2);
2278 if (rel1 != RELC_NONE || rel2 != RELC_NONE)
2280 _bfd_vms_push (abfd, op1 * op2, RELC_NONE);
2283 case ETIR__C_OPR_DIV: /* Divide. */
2284 _bfd_vms_pop (abfd, &op1, &rel1);
2285 _bfd_vms_pop (abfd, &op2, &rel2);
2286 if (rel1 != RELC_NONE || rel2 != RELC_NONE)
2289 _bfd_vms_push (abfd, 0, RELC_NONE);
2291 _bfd_vms_push (abfd, op2 / op1, RELC_NONE);
2294 case ETIR__C_OPR_AND: /* Logical AND. */
2295 _bfd_vms_pop (abfd, &op1, &rel1);
2296 _bfd_vms_pop (abfd, &op2, &rel2);
2297 if (rel1 != RELC_NONE || rel2 != RELC_NONE)
2299 _bfd_vms_push (abfd, op1 & op2, RELC_NONE);
2302 case ETIR__C_OPR_IOR: /* Logical inclusive OR. */
2303 _bfd_vms_pop (abfd, &op1, &rel1);
2304 _bfd_vms_pop (abfd, &op2, &rel2);
2305 if (rel1 != RELC_NONE || rel2 != RELC_NONE)
2307 _bfd_vms_push (abfd, op1 | op2, RELC_NONE);
2310 case ETIR__C_OPR_EOR: /* Logical exclusive OR. */
2311 _bfd_vms_pop (abfd, &op1, &rel1);
2312 _bfd_vms_pop (abfd, &op2, &rel2);
2313 if (rel1 != RELC_NONE || rel2 != RELC_NONE)
2315 _bfd_vms_push (abfd, op1 ^ op2, RELC_NONE);
2318 case ETIR__C_OPR_NEG: /* Negate. */
2319 _bfd_vms_pop (abfd, &op1, &rel1);
2320 if (rel1 != RELC_NONE)
2322 _bfd_vms_push (abfd, -op1, RELC_NONE);
2325 case ETIR__C_OPR_COM: /* Complement. */
2326 _bfd_vms_pop (abfd, &op1, &rel1);
2327 if (rel1 != RELC_NONE)
2329 _bfd_vms_push (abfd, ~op1, RELC_NONE);
2332 case ETIR__C_OPR_ASH: /* Arithmetic shift. */
2333 _bfd_vms_pop (abfd, &op1, &rel1);
2334 _bfd_vms_pop (abfd, &op2, &rel2);
2335 if (rel1 != RELC_NONE || rel2 != RELC_NONE)
2338 _bfd_error_handler (_("invalid use of %s with contexts"),
2339 _bfd_vms_etir_name (cmd));
2342 if ((int)op2 < 0) /* Shift right. */
2344 else /* Shift left. */
2346 _bfd_vms_push (abfd, op1, RELC_NONE); /* FIXME: sym. */
2349 case ETIR__C_OPR_INSV: /* Insert field. */
2350 case ETIR__C_OPR_USH: /* Unsigned shift. */
2351 case ETIR__C_OPR_ROT: /* Rotate. */
2352 case ETIR__C_OPR_REDEF: /* Redefine symbol to current location. */
2353 case ETIR__C_OPR_DFLIT: /* Define a literal. */
2354 _bfd_error_handler (_("%s: not supported"),
2355 _bfd_vms_etir_name (cmd));
2359 case ETIR__C_OPR_SEL: /* Select. */
2360 _bfd_vms_pop (abfd, &op1, &rel1);
2362 _bfd_vms_pop (abfd, &op1, &rel1);
2365 _bfd_vms_pop (abfd, &op1, &rel1);
2366 _bfd_vms_pop (abfd, &op2, &rel2);
2367 _bfd_vms_push (abfd, op1, rel1);
2372 _bfd_error_handler (_("reserved cmd %d"), cmd);
2377 ptr += cmd_length - 4;
2383 /* Process EDBG/ETBT record.
2384 Return TRUE on success, FALSE on error */
2387 vms_slurp_debug (bfd *abfd)
2389 asection *section = PRIV (dst_section);
2391 if (section == NULL)
2393 /* We have no way to find out beforehand how much debug info there
2394 is in an object file, so pick an initial amount and grow it as
2396 flagword flags = SEC_HAS_CONTENTS | SEC_DEBUGGING | SEC_RELOC
2399 section = bfd_make_section (abfd, "$DST$");
2402 if (!bfd_set_section_flags (abfd, section, flags))
2404 PRIV (dst_section) = section;
2407 PRIV (image_section) = section;
2408 PRIV (image_offset) = section->size;
2410 if (!_bfd_vms_slurp_etir (abfd, NULL))
2413 section->size = PRIV (image_offset);
2417 /* Process EDBG record.
2418 Return TRUE on success, FALSE on error. */
2421 _bfd_vms_slurp_edbg (bfd *abfd)
2423 vms_debug2 ((2, "EDBG\n"));
2425 abfd->flags |= HAS_DEBUG | HAS_LINENO;
2427 return vms_slurp_debug (abfd);
2430 /* Process ETBT record.
2431 Return TRUE on success, FALSE on error. */
2434 _bfd_vms_slurp_etbt (bfd *abfd)
2436 vms_debug2 ((2, "ETBT\n"));
2438 abfd->flags |= HAS_LINENO;
2440 return vms_slurp_debug (abfd);
2443 /* Process EEOM record.
2444 Return TRUE on success, FALSE on error. */
2447 _bfd_vms_slurp_eeom (bfd *abfd)
2449 struct vms_eeom *eeom = (struct vms_eeom *) PRIV (recrd.rec);
2451 vms_debug2 ((2, "EEOM\n"));
2453 PRIV (eom_data).eom_l_total_lps = bfd_getl32 (eeom->total_lps);
2454 PRIV (eom_data).eom_w_comcod = bfd_getl16 (eeom->comcod);
2455 if (PRIV (eom_data).eom_w_comcod > 1)
2457 _bfd_error_handler (_("Object module NOT error-free !\n"));
2458 bfd_set_error (bfd_error_bad_value);
2462 PRIV (eom_data).eom_has_transfer = FALSE;
2463 if (PRIV (recrd.rec_size) > 10)
2465 PRIV (eom_data).eom_has_transfer = TRUE;
2466 PRIV (eom_data).eom_b_tfrflg = eeom->tfrflg;
2467 PRIV (eom_data).eom_l_psindx = bfd_getl32 (eeom->psindx);
2468 PRIV (eom_data).eom_l_tfradr = bfd_getl32 (eeom->tfradr);
2470 abfd->start_address = PRIV (eom_data).eom_l_tfradr;
2475 /* Slurp an ordered set of VMS object records. Return FALSE on error. */
2478 _bfd_vms_slurp_object_records (bfd * abfd)
2485 vms_debug2 ((7, "reading at %08lx\n", (unsigned long)bfd_tell (abfd)));
2487 type = _bfd_vms_get_object_record (abfd);
2490 vms_debug2 ((2, "next_record failed\n"));
2497 err = _bfd_vms_slurp_ehdr (abfd);
2500 err = _bfd_vms_slurp_eeom (abfd);
2503 err = _bfd_vms_slurp_egsd (abfd);
2506 err = TRUE; /* _bfd_vms_slurp_etir (abfd); */
2509 err = _bfd_vms_slurp_edbg (abfd);
2512 err = _bfd_vms_slurp_etbt (abfd);
2519 vms_debug2 ((2, "slurp type %d failed\n", type));
2523 while (type != EOBJ__C_EEOM);
2528 /* Initialize private data */
2530 vms_initialize (bfd * abfd)
2534 amt = sizeof (struct vms_private_data_struct);
2535 abfd->tdata.any = bfd_zalloc (abfd, amt);
2536 if (abfd->tdata.any == NULL)
2539 PRIV (recrd.file_format) = FF_UNKNOWN;
2541 amt = sizeof (struct stack_struct) * STACKSIZE;
2542 PRIV (stack) = bfd_alloc (abfd, amt);
2543 if (PRIV (stack) == NULL)
2549 bfd_release (abfd, abfd->tdata.any);
2550 abfd->tdata.any = NULL;
2554 /* Check the format for a file being read.
2555 Return a (bfd_target *) if it's an object file or zero if not. */
2557 static const struct bfd_target *
2558 alpha_vms_object_p (bfd *abfd)
2560 void *tdata_save = abfd->tdata.any;
2561 unsigned int test_len;
2564 vms_debug2 ((1, "vms_object_p(%p)\n", abfd));
2566 /* Allocate alpha-vms specific data. */
2567 if (!vms_initialize (abfd))
2570 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET))
2571 goto err_wrong_format;
2573 /* The first challenge with VMS is to discover the kind of the file.
2575 Image files (executable or shared images) are stored as a raw
2576 stream of bytes (like on UNIX), but there is no magic number.
2578 Object files are written with RMS (record management service), ie
2579 each records are preceeded by its length (on a word - 2 bytes), and
2580 padded for word-alignment. That would be simple but when files
2581 are transfered to a UNIX filesystem (using ftp), records are lost.
2582 Only the raw content of the records are transfered. Fortunately,
2583 the Alpha Object file format also store the length of the record
2584 in the records. Is that clear ? */
2586 /* Minimum is 6 bytes for objects (2 bytes size, 2 bytes record id,
2587 2 bytes size repeated) and 12 bytes for images (4 bytes major id,
2588 4 bytes minor id, 4 bytes length). */
2591 /* Size the main buffer. */
2592 buf = (unsigned char *) bfd_malloc (test_len);
2595 PRIV (recrd.buf) = buf;
2596 PRIV (recrd.buf_size) = test_len;
2598 /* Initialize the record pointer. */
2599 PRIV (recrd.rec) = buf;
2601 if (bfd_bread (buf, test_len, abfd) != test_len)
2602 goto err_wrong_format;
2604 /* Is it an image? */
2605 if ((bfd_getl32 (buf) == EIHD__K_MAJORID)
2606 && (bfd_getl32 (buf + 4) == EIHD__K_MINORID))
2608 unsigned int to_read;
2609 unsigned int read_so_far;
2610 unsigned int remaining;
2611 unsigned int eisd_offset, eihs_offset;
2613 /* Extract the header size. */
2614 PRIV (recrd.rec_size) = bfd_getl32 (buf + EIHD__L_SIZE);
2616 /* The header size is 0 for DSF files. */
2617 if (PRIV (recrd.rec_size) == 0)
2618 PRIV (recrd.rec_size) = sizeof (struct vms_eihd);
2620 if (PRIV (recrd.rec_size) > PRIV (recrd.buf_size))
2622 buf = bfd_realloc_or_free (buf, PRIV (recrd.rec_size));
2626 PRIV (recrd.buf) = NULL;
2629 PRIV (recrd.buf) = buf;
2630 PRIV (recrd.buf_size) = PRIV (recrd.rec_size);
2633 /* Read the remaining record. */
2634 remaining = PRIV (recrd.rec_size) - test_len;
2635 to_read = MIN (VMS_BLOCK_SIZE - test_len, remaining);
2636 read_so_far = test_len;
2638 while (remaining > 0)
2640 if (bfd_bread (buf + read_so_far, to_read, abfd) != to_read)
2641 goto err_wrong_format;
2643 read_so_far += to_read;
2644 remaining -= to_read;
2646 to_read = MIN (VMS_BLOCK_SIZE, remaining);
2649 /* Reset the record pointer. */
2650 PRIV (recrd.rec) = buf;
2652 /* PR 17512: file: 7d7c57c2. */
2653 if (PRIV (recrd.rec_size) < sizeof (struct vms_eihd))
2655 vms_debug2 ((2, "file type is image\n"));
2657 if (!_bfd_vms_slurp_eihd (abfd, &eisd_offset, &eihs_offset))
2658 goto err_wrong_format;
2660 if (!_bfd_vms_slurp_eisd (abfd, eisd_offset))
2661 goto err_wrong_format;
2663 /* EIHS is optional. */
2664 if (eihs_offset != 0 && !_bfd_vms_slurp_eihs (abfd, eihs_offset))
2665 goto err_wrong_format;
2671 /* Assume it's a module and adjust record pointer if necessary. */
2672 maybe_adjust_record_pointer_for_object (abfd);
2674 /* But is it really a module? */
2675 if (bfd_getl16 (PRIV (recrd.rec)) <= EOBJ__C_MAXRECTYP
2676 && bfd_getl16 (PRIV (recrd.rec) + 2) <= EOBJ__C_MAXRECSIZ)
2678 if (vms_get_remaining_object_record (abfd, test_len) <= 0)
2679 goto err_wrong_format;
2681 vms_debug2 ((2, "file type is module\n"));
2683 type = bfd_getl16 (PRIV (recrd.rec));
2684 if (type != EOBJ__C_EMH || !_bfd_vms_slurp_ehdr (abfd))
2685 goto err_wrong_format;
2687 if (!_bfd_vms_slurp_object_records (abfd))
2688 goto err_wrong_format;
2691 goto err_wrong_format;
2694 /* Set arch_info to alpha. */
2696 if (! bfd_default_set_arch_mach (abfd, bfd_arch_alpha, 0))
2697 goto err_wrong_format;
2702 bfd_set_error (bfd_error_wrong_format);
2705 if (PRIV (recrd.buf))
2706 free (PRIV (recrd.buf));
2707 if (abfd->tdata.any != tdata_save && abfd->tdata.any != NULL)
2708 bfd_release (abfd, abfd->tdata.any);
2709 abfd->tdata.any = tdata_save;
2715 /* Write an EMH/MHD record. */
2718 _bfd_vms_write_emh (bfd *abfd)
2720 struct vms_rec_wr *recwr = &PRIV (recwr);
2722 _bfd_vms_output_alignment (recwr, 2);
2725 _bfd_vms_output_begin (recwr, EOBJ__C_EMH);
2726 _bfd_vms_output_short (recwr, EMH__C_MHD);
2727 _bfd_vms_output_short (recwr, EOBJ__C_STRLVL);
2728 _bfd_vms_output_long (recwr, 0);
2729 _bfd_vms_output_long (recwr, 0);
2730 _bfd_vms_output_long (recwr, MAX_OUTREC_SIZE);
2732 /* Create module name from filename. */
2733 if (bfd_get_filename (abfd) != 0)
2735 char *module = vms_get_module_name (bfd_get_filename (abfd), TRUE);
2736 _bfd_vms_output_counted (recwr, module);
2740 _bfd_vms_output_counted (recwr, "NONAME");
2742 _bfd_vms_output_counted (recwr, BFD_VERSION_STRING);
2743 _bfd_vms_output_dump (recwr, get_vms_time_string (), EMH_DATE_LENGTH);
2744 _bfd_vms_output_fill (recwr, 0, EMH_DATE_LENGTH);
2745 _bfd_vms_output_end (abfd, recwr);
2748 /* Write an EMH/LMN record. */
2751 _bfd_vms_write_lmn (bfd *abfd, const char *name)
2754 struct vms_rec_wr *recwr = &PRIV (recwr);
2755 unsigned int ver = BFD_VERSION / 10000;
2758 _bfd_vms_output_begin (recwr, EOBJ__C_EMH);
2759 _bfd_vms_output_short (recwr, EMH__C_LNM);
2760 snprintf (version, sizeof (version), "%s %d.%d.%d", name,
2761 ver / 10000, (ver / 100) % 100, ver % 100);
2762 _bfd_vms_output_dump (recwr, (unsigned char *)version, strlen (version));
2763 _bfd_vms_output_end (abfd, recwr);
2767 /* Write eom record for bfd abfd. Return FALSE on error. */
2770 _bfd_vms_write_eeom (bfd *abfd)
2772 struct vms_rec_wr *recwr = &PRIV (recwr);
2774 vms_debug2 ((2, "vms_write_eeom\n"));
2776 _bfd_vms_output_alignment (recwr, 2);
2778 _bfd_vms_output_begin (recwr, EOBJ__C_EEOM);
2779 _bfd_vms_output_long (recwr, PRIV (vms_linkage_index + 1) >> 1);
2780 _bfd_vms_output_byte (recwr, 0); /* Completion code. */
2781 _bfd_vms_output_byte (recwr, 0); /* Fill byte. */
2783 if ((abfd->flags & EXEC_P) == 0
2784 && bfd_get_start_address (abfd) != (bfd_vma)-1)
2788 section = bfd_get_section_by_name (abfd, ".link");
2791 bfd_set_error (bfd_error_nonrepresentable_section);
2794 _bfd_vms_output_short (recwr, 0);
2795 _bfd_vms_output_long (recwr, (unsigned long) section->target_index);
2796 _bfd_vms_output_long (recwr,
2797 (unsigned long) bfd_get_start_address (abfd));
2798 _bfd_vms_output_long (recwr, 0);
2801 _bfd_vms_output_end (abfd, recwr);
2806 vector_grow1 (struct vector_type *vec, size_t elsz)
2808 if (vec->nbr_el + 1 < vec->max_el)
2811 if (vec->max_el == 0)
2814 vec->els = bfd_malloc2 (vec->max_el, elsz);
2819 vec->els = bfd_realloc2 (vec->els, vec->max_el, elsz);
2823 /* Bump ABFD file position to next block. */
2826 alpha_vms_file_position_block (bfd *abfd)
2829 PRIV (file_pos) += VMS_BLOCK_SIZE - 1;
2830 PRIV (file_pos) -= (PRIV (file_pos) % VMS_BLOCK_SIZE);
2833 /* Convert from internal structure SRC to external structure DST. */
2836 alpha_vms_swap_eisd_out (struct vms_internal_eisd_map *src,
2837 struct vms_eisd *dst)
2839 bfd_putl32 (src->u.eisd.majorid, dst->majorid);
2840 bfd_putl32 (src->u.eisd.minorid, dst->minorid);
2841 bfd_putl32 (src->u.eisd.eisdsize, dst->eisdsize);
2842 if (src->u.eisd.eisdsize <= EISD__K_LENEND)
2844 bfd_putl32 (src->u.eisd.secsize, dst->secsize);
2845 bfd_putl64 (src->u.eisd.virt_addr, dst->virt_addr);
2846 bfd_putl32 (src->u.eisd.flags, dst->flags);
2847 bfd_putl32 (src->u.eisd.vbn, dst->vbn);
2848 dst->pfc = src->u.eisd.pfc;
2849 dst->matchctl = src->u.eisd.matchctl;
2850 dst->type = src->u.eisd.type;
2852 if (src->u.eisd.flags & EISD__M_GBL)
2854 bfd_putl32 (src->u.gbl_eisd.ident, dst->ident);
2855 memcpy (dst->gblnam, src->u.gbl_eisd.gblnam,
2856 src->u.gbl_eisd.gblnam[0] + 1);
2860 /* Append EISD to the list of extra eisd for ABFD. */
2863 alpha_vms_append_extra_eisd (bfd *abfd, struct vms_internal_eisd_map *eisd)
2866 if (PRIV (gbl_eisd_head) == NULL)
2867 PRIV (gbl_eisd_head) = eisd;
2869 PRIV (gbl_eisd_tail)->next = eisd;
2870 PRIV (gbl_eisd_tail) = eisd;
2873 /* Create an EISD for shared image SHRIMG.
2874 Return FALSE in case of error. */
2877 alpha_vms_create_eisd_for_shared (bfd *abfd, bfd *shrimg)
2879 struct vms_internal_eisd_map *eisd;
2882 namlen = strlen (PRIV2 (shrimg, hdr_data.hdr_t_name));
2883 if (namlen + 5 > EISD__K_GBLNAMLEN)
2889 eisd = bfd_alloc (abfd, sizeof (*eisd));
2893 /* Fill the fields. */
2894 eisd->u.gbl_eisd.common.majorid = EISD__K_MAJORID;
2895 eisd->u.gbl_eisd.common.minorid = EISD__K_MINORID;
2896 eisd->u.gbl_eisd.common.eisdsize = (EISD__K_LEN + 4 + namlen + 5 + 3) & ~3;
2897 eisd->u.gbl_eisd.common.secsize = VMS_BLOCK_SIZE; /* Must not be 0. */
2898 eisd->u.gbl_eisd.common.virt_addr = 0;
2899 eisd->u.gbl_eisd.common.flags = EISD__M_GBL;
2900 eisd->u.gbl_eisd.common.vbn = 0;
2901 eisd->u.gbl_eisd.common.pfc = 0;
2902 eisd->u.gbl_eisd.common.matchctl = PRIV2 (shrimg, matchctl);
2903 eisd->u.gbl_eisd.common.type = EISD__K_SHRPIC;
2905 eisd->u.gbl_eisd.ident = PRIV2 (shrimg, ident);
2906 eisd->u.gbl_eisd.gblnam[0] = namlen + 4;
2907 memcpy (eisd->u.gbl_eisd.gblnam + 1, PRIV2 (shrimg, hdr_data.hdr_t_name),
2909 memcpy (eisd->u.gbl_eisd.gblnam + 1 + namlen, "_001", 4);
2911 /* Append it to the list. */
2912 alpha_vms_append_extra_eisd (abfd, eisd);
2917 /* Create an EISD for section SEC.
2918 Return FALSE in case of failure. */
2921 alpha_vms_create_eisd_for_section (bfd *abfd, asection *sec)
2923 struct vms_internal_eisd_map *eisd;
2925 /* Only for allocating section. */
2926 if (!(sec->flags & SEC_ALLOC))
2929 BFD_ASSERT (vms_section_data (sec)->eisd == NULL);
2930 eisd = bfd_alloc (abfd, sizeof (*eisd));
2933 vms_section_data (sec)->eisd = eisd;
2935 /* Fill the fields. */
2936 eisd->u.eisd.majorid = EISD__K_MAJORID;
2937 eisd->u.eisd.minorid = EISD__K_MINORID;
2938 eisd->u.eisd.eisdsize = EISD__K_LEN;
2939 eisd->u.eisd.secsize =
2940 (sec->size + VMS_BLOCK_SIZE - 1) & ~(VMS_BLOCK_SIZE - 1);
2941 eisd->u.eisd.virt_addr = sec->vma;
2942 eisd->u.eisd.flags = 0;
2943 eisd->u.eisd.vbn = 0; /* To be later defined. */
2944 eisd->u.eisd.pfc = 0; /* Default. */
2945 eisd->u.eisd.matchctl = EISD__K_MATALL;
2946 eisd->u.eisd.type = EISD__K_NORMAL;
2948 if (sec->flags & SEC_CODE)
2949 eisd->u.eisd.flags |= EISD__M_EXE;
2950 if (!(sec->flags & SEC_READONLY))
2951 eisd->u.eisd.flags |= EISD__M_WRT | EISD__M_CRF;
2953 /* If relocations or fixup will be applied, make this isect writeable. */
2954 if (sec->flags & SEC_RELOC)
2955 eisd->u.eisd.flags |= EISD__M_WRT | EISD__M_CRF;
2957 if (!(sec->flags & SEC_HAS_CONTENTS))
2959 eisd->u.eisd.flags |= EISD__M_DZRO;
2960 eisd->u.eisd.flags &= ~EISD__M_CRF;
2962 if (sec->flags & SEC_LINKER_CREATED)
2964 if (strcmp (sec->name, "$FIXUP$") == 0)
2965 eisd->u.eisd.flags |= EISD__M_FIXUPVEC;
2968 /* Append it to the list. */
2970 if (PRIV (eisd_head) == NULL)
2971 PRIV (eisd_head) = eisd;
2973 PRIV (eisd_tail)->next = eisd;
2974 PRIV (eisd_tail) = eisd;
2979 /* Layout executable ABFD and write it to the disk.
2980 Return FALSE in case of failure. */
2983 alpha_vms_write_exec (bfd *abfd)
2985 struct vms_eihd eihd;
2986 struct vms_eiha *eiha;
2987 struct vms_eihi *eihi;
2988 struct vms_eihs *eihs = NULL;
2990 struct vms_internal_eisd_map *first_eisd;
2991 struct vms_internal_eisd_map *eisd;
2994 file_ptr gst_filepos = 0;
2995 unsigned int lnkflags = 0;
2997 /* Build the EIHD. */
2998 PRIV (file_pos) = EIHD__C_LENGTH;
3000 memset (&eihd, 0, sizeof (eihd));
3001 memset (eihd.fill_2, 0xff, sizeof (eihd.fill_2));
3003 bfd_putl32 (EIHD__K_MAJORID, eihd.majorid);
3004 bfd_putl32 (EIHD__K_MINORID, eihd.minorid);
3006 bfd_putl32 (sizeof (eihd), eihd.size);
3007 bfd_putl32 (0, eihd.isdoff);
3008 bfd_putl32 (0, eihd.activoff);
3009 bfd_putl32 (0, eihd.symdbgoff);
3010 bfd_putl32 (0, eihd.imgidoff);
3011 bfd_putl32 (0, eihd.patchoff);
3012 bfd_putl64 (0, eihd.iafva);
3013 bfd_putl32 (0, eihd.version_array_off);
3015 bfd_putl32 (EIHD__K_EXE, eihd.imgtype);
3016 bfd_putl32 (0, eihd.subtype);
3018 bfd_putl32 (0, eihd.imgiocnt);
3019 bfd_putl32 (-1, eihd.privreqs);
3020 bfd_putl32 (-1, eihd.privreqs + 4);
3022 bfd_putl32 ((sizeof (eihd) + VMS_BLOCK_SIZE - 1) / VMS_BLOCK_SIZE,
3024 bfd_putl32 (0, eihd.ident);
3025 bfd_putl32 (0, eihd.sysver);
3028 bfd_putl32 (0, eihd.symvect_size);
3029 bfd_putl32 (16, eihd.virt_mem_block_size);
3030 bfd_putl32 (0, eihd.ext_fixup_off);
3031 bfd_putl32 (0, eihd.noopt_psect_off);
3032 bfd_putl32 (-1, eihd.alias);
3035 eiha = (struct vms_eiha *)((char *) &eihd + PRIV (file_pos));
3036 bfd_putl32 (PRIV (file_pos), eihd.activoff);
3037 PRIV (file_pos) += sizeof (struct vms_eiha);
3039 bfd_putl32 (sizeof (struct vms_eiha), eiha->size);
3040 bfd_putl32 (0, eiha->spare);
3041 bfd_putl64 (PRIV (transfer_address[0]), eiha->tfradr1);
3042 bfd_putl64 (PRIV (transfer_address[1]), eiha->tfradr2);
3043 bfd_putl64 (PRIV (transfer_address[2]), eiha->tfradr3);
3044 bfd_putl64 (PRIV (transfer_address[3]), eiha->tfradr4);
3045 bfd_putl64 (0, eiha->inishr);
3048 eihi = (struct vms_eihi *)((char *) &eihd + PRIV (file_pos));
3049 bfd_putl32 (PRIV (file_pos), eihd.imgidoff);
3050 PRIV (file_pos) += sizeof (struct vms_eihi);
3052 bfd_putl32 (EIHI__K_MAJORID, eihi->majorid);
3053 bfd_putl32 (EIHI__K_MINORID, eihi->minorid);
3058 /* Set module name. */
3059 module = vms_get_module_name (bfd_get_filename (abfd), TRUE);
3060 len = strlen (module);
3061 if (len > sizeof (eihi->imgnam) - 1)
3062 len = sizeof (eihi->imgnam) - 1;
3063 eihi->imgnam[0] = len;
3064 memcpy (eihi->imgnam + 1, module, len);
3072 vms_get_time (&hi, &lo);
3073 bfd_putl32 (lo, eihi->linktime + 0);
3074 bfd_putl32 (hi, eihi->linktime + 4);
3077 eihi->linkid[0] = 0;
3078 eihi->imgbid[0] = 0;
3081 dst = PRIV (dst_section);
3082 dmt = bfd_get_section_by_name (abfd, "$DMT$");
3083 if (dst != NULL && dst->size != 0)
3085 eihs = (struct vms_eihs *)((char *) &eihd + PRIV (file_pos));
3086 bfd_putl32 (PRIV (file_pos), eihd.symdbgoff);
3087 PRIV (file_pos) += sizeof (struct vms_eihs);
3089 bfd_putl32 (EIHS__K_MAJORID, eihs->majorid);
3090 bfd_putl32 (EIHS__K_MINORID, eihs->minorid);
3091 bfd_putl32 (0, eihs->dstvbn);
3092 bfd_putl32 (0, eihs->dstsize);
3093 bfd_putl32 (0, eihs->gstvbn);
3094 bfd_putl32 (0, eihs->gstsize);
3095 bfd_putl32 (0, eihs->dmtvbn);
3096 bfd_putl32 (0, eihs->dmtsize);
3099 /* One EISD per section. */
3100 for (sec = abfd->sections; sec; sec = sec->next)
3102 if (!alpha_vms_create_eisd_for_section (abfd, sec))
3106 /* Merge section EIDS which extra ones. */
3107 if (PRIV (eisd_tail))
3108 PRIV (eisd_tail)->next = PRIV (gbl_eisd_head);
3110 PRIV (eisd_head) = PRIV (gbl_eisd_head);
3111 if (PRIV (gbl_eisd_tail))
3112 PRIV (eisd_tail) = PRIV (gbl_eisd_tail);
3114 first_eisd = PRIV (eisd_head);
3116 /* Add end of eisd. */
3119 eisd = bfd_zalloc (abfd, sizeof (*eisd));
3122 eisd->u.eisd.majorid = 0;
3123 eisd->u.eisd.minorid = 0;
3124 eisd->u.eisd.eisdsize = 0;
3125 alpha_vms_append_extra_eisd (abfd, eisd);
3128 /* Place EISD in the file. */
3129 for (eisd = first_eisd; eisd; eisd = eisd->next)
3131 file_ptr room = VMS_BLOCK_SIZE - (PRIV (file_pos) % VMS_BLOCK_SIZE);
3133 /* First block is a little bit special: there is a word at the end. */
3134 if (PRIV (file_pos) < VMS_BLOCK_SIZE && room > 2)
3136 if (room < eisd->u.eisd.eisdsize + EISD__K_LENEND)
3137 alpha_vms_file_position_block (abfd);
3139 eisd->file_pos = PRIV (file_pos);
3140 PRIV (file_pos) += eisd->u.eisd.eisdsize;
3142 if (eisd->u.eisd.flags & EISD__M_FIXUPVEC)
3143 bfd_putl64 (eisd->u.eisd.virt_addr, eihd.iafva);
3146 if (first_eisd != NULL)
3148 bfd_putl32 (first_eisd->file_pos, eihd.isdoff);
3149 /* Real size of end of eisd marker. */
3150 PRIV (file_pos) += EISD__K_LENEND;
3153 bfd_putl32 (PRIV (file_pos), eihd.size);
3154 bfd_putl32 ((PRIV (file_pos) + VMS_BLOCK_SIZE - 1) / VMS_BLOCK_SIZE,
3157 /* Place sections. */
3158 for (sec = abfd->sections; sec; sec = sec->next)
3160 if (!(sec->flags & SEC_HAS_CONTENTS))
3163 eisd = vms_section_data (sec)->eisd;
3165 /* Align on a block. */
3166 alpha_vms_file_position_block (abfd);
3167 sec->filepos = PRIV (file_pos);
3170 eisd->u.eisd.vbn = (sec->filepos / VMS_BLOCK_SIZE) + 1;
3172 PRIV (file_pos) += sec->size;
3176 if (eihs != NULL && dst != NULL)
3178 bfd_putl32 ((dst->filepos / VMS_BLOCK_SIZE) + 1, eihs->dstvbn);
3179 bfd_putl32 (dst->size, eihs->dstsize);
3183 lnkflags |= EIHD__M_DBGDMT;
3184 bfd_putl32 ((dmt->filepos / VMS_BLOCK_SIZE) + 1, eihs->dmtvbn);
3185 bfd_putl32 (dmt->size, eihs->dmtsize);
3187 if (PRIV (gsd_sym_count) != 0)
3189 alpha_vms_file_position_block (abfd);
3190 gst_filepos = PRIV (file_pos);
3191 bfd_putl32 ((gst_filepos / VMS_BLOCK_SIZE) + 1, eihs->gstvbn);
3192 bfd_putl32 ((PRIV (gsd_sym_count) + 4) / 5 + 4, eihs->gstsize);
3196 /* Write EISD in hdr. */
3197 for (eisd = first_eisd; eisd && eisd->file_pos < VMS_BLOCK_SIZE;
3199 alpha_vms_swap_eisd_out
3200 (eisd, (struct vms_eisd *)((char *)&eihd + eisd->file_pos));
3202 /* Write first block. */
3203 bfd_putl32 (lnkflags, eihd.lnkflags);
3204 if (bfd_bwrite (&eihd, sizeof (eihd), abfd) != sizeof (eihd))
3207 /* Write remaining eisd. */
3210 unsigned char blk[VMS_BLOCK_SIZE];
3211 struct vms_internal_eisd_map *next_eisd;
3213 memset (blk, 0xff, sizeof (blk));
3214 while (eisd != NULL)
3216 alpha_vms_swap_eisd_out
3218 (struct vms_eisd *)(blk + (eisd->file_pos % VMS_BLOCK_SIZE)));
3220 next_eisd = eisd->next;
3221 if (next_eisd == NULL
3222 || (next_eisd->file_pos / VMS_BLOCK_SIZE
3223 != eisd->file_pos / VMS_BLOCK_SIZE))
3225 if (bfd_bwrite (blk, sizeof (blk), abfd) != sizeof (blk))
3228 memset (blk, 0xff, sizeof (blk));
3234 /* Write sections. */
3235 for (sec = abfd->sections; sec; sec = sec->next)
3237 unsigned char blk[VMS_BLOCK_SIZE];
3240 if (sec->size == 0 || !(sec->flags & SEC_HAS_CONTENTS))
3242 if (bfd_bwrite (sec->contents, sec->size, abfd) != sec->size)
3246 len = VMS_BLOCK_SIZE - sec->size % VMS_BLOCK_SIZE;
3247 if (len != VMS_BLOCK_SIZE)
3249 memset (blk, 0, len);
3250 if (bfd_bwrite (blk, len, abfd) != len)
3256 if (gst_filepos != 0)
3258 struct vms_rec_wr *recwr = &PRIV (recwr);
3261 _bfd_vms_write_emh (abfd);
3262 _bfd_vms_write_lmn (abfd, "GNU LD");
3264 /* PSC for the absolute section. */
3265 _bfd_vms_output_begin (recwr, EOBJ__C_EGSD);
3266 _bfd_vms_output_long (recwr, 0);
3267 _bfd_vms_output_begin_subrec (recwr, EGSD__C_PSC);
3268 _bfd_vms_output_short (recwr, 0);
3269 _bfd_vms_output_short (recwr, EGPS__V_PIC | EGPS__V_LIB | EGPS__V_RD);
3270 _bfd_vms_output_long (recwr, 0);
3271 _bfd_vms_output_counted (recwr, ".$$ABS$$.");
3272 _bfd_vms_output_end_subrec (recwr);
3273 _bfd_vms_output_end (abfd, recwr);
3275 for (i = 0; i < PRIV (gsd_sym_count); i++)
3277 struct vms_symbol_entry *sym = PRIV (syms)[i];
3283 _bfd_vms_output_alignment (recwr, 8);
3284 _bfd_vms_output_begin (recwr, EOBJ__C_EGSD);
3285 _bfd_vms_output_long (recwr, 0);
3287 _bfd_vms_output_begin_subrec (recwr, EGSD__C_SYMG);
3288 _bfd_vms_output_short (recwr, 0); /* Data type, alignment. */
3289 _bfd_vms_output_short (recwr, sym->flags);
3291 if (sym->code_section)
3292 ep = alpha_vms_get_sym_value (sym->code_section, sym->code_value);
3295 BFD_ASSERT (sym->code_value == 0);
3298 val = alpha_vms_get_sym_value (sym->section, sym->value);
3299 _bfd_vms_output_quad
3300 (recwr, sym->typ == EGSD__C_SYMG ? sym->symbol_vector : val);
3301 _bfd_vms_output_quad (recwr, ep);
3302 _bfd_vms_output_quad (recwr, val);
3303 _bfd_vms_output_long (recwr, 0);
3304 _bfd_vms_output_counted (recwr, sym->name);
3305 _bfd_vms_output_end_subrec (recwr);
3307 _bfd_vms_output_end (abfd, recwr);
3310 _bfd_vms_output_end (abfd, recwr);
3312 if (!_bfd_vms_write_eeom (abfd))
3320 /* Write section and symbol directory of bfd abfd. Return FALSE on error. */
3323 _bfd_vms_write_egsd (bfd *abfd)
3327 unsigned int symnum;
3329 flagword new_flags, old_flags;
3330 int abs_section_index = -1;
3331 unsigned int target_index = 0;
3332 struct vms_rec_wr *recwr = &PRIV (recwr);
3334 vms_debug2 ((2, "vms_write_egsd\n"));
3336 /* Egsd is quadword aligned. */
3337 _bfd_vms_output_alignment (recwr, 8);
3339 _bfd_vms_output_begin (recwr, EOBJ__C_EGSD);
3340 _bfd_vms_output_long (recwr, 0);
3342 /* Number sections. */
3343 for (section = abfd->sections; section != NULL; section = section->next)
3345 if (section->flags & SEC_DEBUGGING)
3347 if (!strcmp (section->name, ".vmsdebug"))
3349 section->flags |= SEC_DEBUGGING;
3352 section->target_index = target_index++;
3355 for (section = abfd->sections; section != NULL; section = section->next)
3357 vms_debug2 ((3, "Section #%d %s, %d bytes\n",
3358 section->target_index, section->name, (int)section->size));
3360 /* Don't write out the VMS debug info section since it is in the
3361 ETBT and EDBG sections in etir. */
3362 if (section->flags & SEC_DEBUGGING)
3365 /* 13 bytes egsd, max 31 chars name -> should be 44 bytes. */
3366 if (_bfd_vms_output_check (recwr, 64) < 0)
3368 _bfd_vms_output_end (abfd, recwr);
3369 _bfd_vms_output_begin (recwr, EOBJ__C_EGSD);
3370 _bfd_vms_output_long (recwr, 0);
3373 /* Don't know if this is necessary for the linker but for now it keeps
3374 vms_slurp_gsd happy. */
3375 sname = section->name;
3378 /* Remove leading dot. */
3380 if ((*sname == 't') && (strcmp (sname, "text") == 0))
3381 sname = EVAX_CODE_NAME;
3382 else if ((*sname == 'd') && (strcmp (sname, "data") == 0))
3383 sname = EVAX_DATA_NAME;
3384 else if ((*sname == 'b') && (strcmp (sname, "bss") == 0))
3385 sname = EVAX_BSS_NAME;
3386 else if ((*sname == 'l') && (strcmp (sname, "link") == 0))
3387 sname = EVAX_LINK_NAME;
3388 else if ((*sname == 'r') && (strcmp (sname, "rdata") == 0))
3389 sname = EVAX_READONLY_NAME;
3390 else if ((*sname == 'l') && (strcmp (sname, "literal") == 0))
3391 sname = EVAX_LITERAL_NAME;
3392 else if ((*sname == 'l') && (strcmp (sname, "literals") == 0))
3393 sname = EVAX_LITERALS_NAME;
3394 else if ((*sname == 'c') && (strcmp (sname, "comm") == 0))
3395 sname = EVAX_COMMON_NAME;
3396 else if ((*sname == 'l') && (strcmp (sname, "lcomm") == 0))
3397 sname = EVAX_LOCAL_NAME;
3400 if (bfd_is_com_section (section))
3401 new_flags = (EGPS__V_OVR | EGPS__V_REL | EGPS__V_GBL | EGPS__V_RD
3402 | EGPS__V_WRT | EGPS__V_NOMOD | EGPS__V_COM);
3404 new_flags = vms_esecflag_by_name (evax_section_flags, sname,
3407 /* Modify them as directed. */
3408 if (section->flags & SEC_READONLY)
3409 new_flags &= ~EGPS__V_WRT;
3411 new_flags &= ~vms_section_data (section)->no_flags;
3412 new_flags |= vms_section_data (section)->flags;
3414 vms_debug2 ((3, "sec flags %x\n", section->flags));
3415 vms_debug2 ((3, "new_flags %x, _raw_size %lu\n",
3416 new_flags, (unsigned long)section->size));
3418 _bfd_vms_output_begin_subrec (recwr, EGSD__C_PSC);
3419 _bfd_vms_output_short (recwr, section->alignment_power & 0xff);
3420 _bfd_vms_output_short (recwr, new_flags);
3421 _bfd_vms_output_long (recwr, (unsigned long) section->size);
3422 _bfd_vms_output_counted (recwr, sname);
3423 _bfd_vms_output_end_subrec (recwr);
3425 /* If the section is an obsolute one, remind its index as it will be
3426 used later for absolute symbols. */
3427 if ((new_flags & EGPS__V_REL) == 0 && abs_section_index < 0)
3428 abs_section_index = section->target_index;
3431 /* Output symbols. */
3432 vms_debug2 ((3, "%d symbols found\n", abfd->symcount));
3434 bfd_set_start_address (abfd, (bfd_vma) -1);
3436 for (symnum = 0; symnum < abfd->symcount; symnum++)
3438 symbol = abfd->outsymbols[symnum];
3439 old_flags = symbol->flags;
3441 /* Work-around a missing feature: consider __main as the main entry
3443 if (symbol->name[0] == '_' && strcmp (symbol->name, "__main") == 0)
3444 bfd_set_start_address (abfd, (bfd_vma)symbol->value);
3446 /* Only put in the GSD the global and the undefined symbols. */
3447 if (old_flags & BSF_FILE)
3450 if ((old_flags & BSF_GLOBAL) == 0 && !bfd_is_und_section (symbol->section))
3452 /* If the LIB$INITIIALIZE section is present, add a reference to
3453 LIB$INITIALIZE symbol. FIXME: this should be done explicitely
3454 in the assembly file. */
3455 if (!((old_flags & BSF_SECTION_SYM) != 0
3456 && strcmp (symbol->section->name, "LIB$INITIALIZE") == 0))
3460 /* 13 bytes egsd, max 64 chars name -> should be 77 bytes. Add 16 more
3461 bytes for a possible ABS section. */
3462 if (_bfd_vms_output_check (recwr, 80 + 16) < 0)
3464 _bfd_vms_output_end (abfd, recwr);
3465 _bfd_vms_output_begin (recwr, EOBJ__C_EGSD);
3466 _bfd_vms_output_long (recwr, 0);
3469 if ((old_flags & BSF_GLOBAL) != 0
3470 && bfd_is_abs_section (symbol->section)
3471 && abs_section_index <= 0)
3473 /* Create an absolute section if none was defined. It is highly
3474 unlikely that the name $ABS$ clashes with a user defined
3475 non-absolute section name. */
3476 _bfd_vms_output_begin_subrec (recwr, EGSD__C_PSC);
3477 _bfd_vms_output_short (recwr, 4);
3478 _bfd_vms_output_short (recwr, EGPS__V_SHR);
3479 _bfd_vms_output_long (recwr, 0);
3480 _bfd_vms_output_counted (recwr, "$ABS$");
3481 _bfd_vms_output_end_subrec (recwr);
3483 abs_section_index = target_index++;
3486 _bfd_vms_output_begin_subrec (recwr, EGSD__C_SYM);
3488 /* Data type, alignment. */
3489 _bfd_vms_output_short (recwr, 0);
3493 if (old_flags & BSF_WEAK)
3494 new_flags |= EGSY__V_WEAK;
3495 if (bfd_is_com_section (symbol->section)) /* .comm */
3496 new_flags |= (EGSY__V_WEAK | EGSY__V_COMM);
3498 if (old_flags & BSF_FUNCTION)
3500 new_flags |= EGSY__V_NORM;
3501 new_flags |= EGSY__V_REL;
3503 if (old_flags & BSF_GLOBAL)
3505 new_flags |= EGSY__V_DEF;
3506 if (!bfd_is_abs_section (symbol->section))
3507 new_flags |= EGSY__V_REL;
3509 _bfd_vms_output_short (recwr, new_flags);
3511 if (old_flags & BSF_GLOBAL)
3513 /* Symbol definition. */
3514 bfd_vma code_address = 0;
3515 unsigned long ca_psindx = 0;
3516 unsigned long psindx;
3518 if ((old_flags & BSF_FUNCTION) && symbol->udata.p != NULL)
3523 ((struct evax_private_udata_struct *)symbol->udata.p)->enbsym;
3524 code_address = sym->value;
3525 ca_psindx = sym->section->target_index;
3527 if (bfd_is_abs_section (symbol->section))
3528 psindx = abs_section_index;
3530 psindx = symbol->section->target_index;
3532 _bfd_vms_output_quad (recwr, symbol->value);
3533 _bfd_vms_output_quad (recwr, code_address);
3534 _bfd_vms_output_long (recwr, ca_psindx);
3535 _bfd_vms_output_long (recwr, psindx);
3537 _bfd_vms_output_counted (recwr, symbol->name);
3539 _bfd_vms_output_end_subrec (recwr);
3542 _bfd_vms_output_alignment (recwr, 8);
3543 _bfd_vms_output_end (abfd, recwr);
3548 /* Write object header for bfd abfd. Return FALSE on error. */
3551 _bfd_vms_write_ehdr (bfd *abfd)
3554 unsigned int symnum;
3555 struct vms_rec_wr *recwr = &PRIV (recwr);
3557 vms_debug2 ((2, "vms_write_ehdr (%p)\n", abfd));
3559 _bfd_vms_output_alignment (recwr, 2);
3561 _bfd_vms_write_emh (abfd);
3562 _bfd_vms_write_lmn (abfd, "GNU AS");
3565 _bfd_vms_output_begin (recwr, EOBJ__C_EMH);
3566 _bfd_vms_output_short (recwr, EMH__C_SRC);
3568 for (symnum = 0; symnum < abfd->symcount; symnum++)
3570 symbol = abfd->outsymbols[symnum];
3572 if (symbol->flags & BSF_FILE)
3574 _bfd_vms_output_dump (recwr, (unsigned char *) symbol->name,
3575 (int) strlen (symbol->name));
3580 if (symnum == abfd->symcount)
3581 _bfd_vms_output_dump (recwr, (unsigned char *) STRING_COMMA_LEN ("noname"));
3583 _bfd_vms_output_end (abfd, recwr);
3586 _bfd_vms_output_begin (recwr, EOBJ__C_EMH);
3587 _bfd_vms_output_short (recwr, EMH__C_TTL);
3588 _bfd_vms_output_dump (recwr, (unsigned char *) STRING_COMMA_LEN ("TTL"));
3589 _bfd_vms_output_end (abfd, recwr);
3592 _bfd_vms_output_begin (recwr, EOBJ__C_EMH);
3593 _bfd_vms_output_short (recwr, EMH__C_CPR);
3594 _bfd_vms_output_dump (recwr,
3595 (unsigned char *)"GNU BFD ported by Klaus Kämpf 1994-1996",
3597 _bfd_vms_output_end (abfd, recwr);
3602 /* Part 4.6, relocations. */
3605 /* WRITE ETIR SECTION
3607 This is still under construction and therefore not documented. */
3609 /* Close the etir/etbt record. */
3612 end_etir_record (bfd * abfd)
3614 struct vms_rec_wr *recwr = &PRIV (recwr);
3616 _bfd_vms_output_end (abfd, recwr);
3620 start_etir_or_etbt_record (bfd *abfd, asection *section, bfd_vma offset)
3622 struct vms_rec_wr *recwr = &PRIV (recwr);
3624 if (section->flags & SEC_DEBUGGING)
3626 _bfd_vms_output_begin (recwr, EOBJ__C_ETBT);
3630 /* Push start offset. */
3631 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STA_LW);
3632 _bfd_vms_output_long (recwr, (unsigned long) 0);
3633 _bfd_vms_output_end_subrec (recwr);
3636 _bfd_vms_output_begin_subrec (recwr, ETIR__C_CTL_DFLOC);
3637 _bfd_vms_output_end_subrec (recwr);
3642 _bfd_vms_output_begin (recwr, EOBJ__C_ETIR);
3646 /* Push start offset. */
3647 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STA_PQ);
3648 _bfd_vms_output_long (recwr, (unsigned long) section->target_index);
3649 _bfd_vms_output_quad (recwr, offset);
3650 _bfd_vms_output_end_subrec (recwr);
3652 /* Start = pop (). */
3653 _bfd_vms_output_begin_subrec (recwr, ETIR__C_CTL_SETRB);
3654 _bfd_vms_output_end_subrec (recwr);
3659 /* Output a STO_IMM command for SSIZE bytes of data from CPR at virtual
3660 address VADDR in section specified by SEC_INDEX and NAME. */
3663 sto_imm (bfd *abfd, asection *section,
3664 bfd_size_type ssize, unsigned char *cptr, bfd_vma vaddr)
3667 struct vms_rec_wr *recwr = &PRIV (recwr);
3670 _bfd_vms_debug (8, "sto_imm %d bytes\n", (int) ssize);
3671 _bfd_hexdump (9, cptr, (int) ssize, (int) vaddr);
3676 /* Try all the rest. */
3679 if (_bfd_vms_output_check (recwr, size) < 0)
3681 /* Doesn't fit, split ! */
3682 end_etir_record (abfd);
3684 start_etir_or_etbt_record (abfd, section, vaddr);
3686 size = _bfd_vms_output_check (recwr, 0); /* get max size */
3687 if (size > ssize) /* more than what's left ? */
3691 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STO_IMM);
3692 _bfd_vms_output_long (recwr, (unsigned long) (size));
3693 _bfd_vms_output_dump (recwr, cptr, size);
3694 _bfd_vms_output_end_subrec (recwr);
3697 _bfd_vms_debug (10, "dumped %d bytes\n", (int) size);
3698 _bfd_hexdump (10, cptr, (int) size, (int) vaddr);
3708 etir_output_check (bfd *abfd, asection *section, bfd_vma vaddr, int checklen)
3710 if (_bfd_vms_output_check (&PRIV (recwr), checklen) < 0)
3712 /* Not enough room in this record. Close it and open a new one. */
3713 end_etir_record (abfd);
3714 start_etir_or_etbt_record (abfd, section, vaddr);
3718 /* Return whether RELOC must be deferred till the end. */
3721 defer_reloc_p (arelent *reloc)
3723 switch (reloc->howto->type)
3736 /* Write section contents for bfd abfd. Return FALSE on error. */
3739 _bfd_vms_write_etir (bfd * abfd, int objtype ATTRIBUTE_UNUSED)
3742 struct vms_rec_wr *recwr = &PRIV (recwr);
3744 vms_debug2 ((2, "vms_write_tir (%p, %d)\n", abfd, objtype));
3746 _bfd_vms_output_alignment (recwr, 4);
3748 PRIV (vms_linkage_index) = 0;
3750 for (section = abfd->sections; section; section = section->next)
3752 vms_debug2 ((4, "writing %d. section '%s' (%d bytes)\n",
3753 section->target_index, section->name, (int) (section->size)));
3755 if (!(section->flags & SEC_HAS_CONTENTS)
3756 || bfd_is_com_section (section))
3759 if (!section->contents)
3761 bfd_set_error (bfd_error_no_contents);
3765 start_etir_or_etbt_record (abfd, section, 0);
3767 if (section->flags & SEC_RELOC)
3769 bfd_vma curr_addr = 0;
3770 unsigned char *curr_data = section->contents;
3772 int pass2_needed = 0;
3773 int pass2_in_progress = 0;
3776 if (section->reloc_count == 0)
3778 (_("SEC_RELOC with no relocs in section %A"), section);
3783 int i = section->reloc_count;
3784 arelent **rptr = section->orelocation;
3785 _bfd_vms_debug (4, "%d relocations:\n", i);
3788 _bfd_vms_debug (4, "sym %s in sec %s, value %08lx, "
3789 "addr %08lx, off %08lx, len %d: %s\n",
3790 (*(*rptr)->sym_ptr_ptr)->name,
3791 (*(*rptr)->sym_ptr_ptr)->section->name,
3792 (long) (*(*rptr)->sym_ptr_ptr)->value,
3793 (unsigned long)(*rptr)->address,
3794 (unsigned long)(*rptr)->addend,
3795 bfd_get_reloc_size ((*rptr)->howto),
3796 ( *rptr)->howto->name);
3803 for (irel = 0; irel < section->reloc_count; irel++)
3805 struct evax_private_udata_struct *udata;
3806 arelent *rptr = section->orelocation [irel];
3807 bfd_vma addr = rptr->address;
3808 asymbol *sym = *rptr->sym_ptr_ptr;
3809 asection *sec = sym->section;
3810 bfd_boolean defer = defer_reloc_p (rptr);
3813 if (pass2_in_progress)
3815 /* Non-deferred relocs have already been output. */
3821 /* Deferred relocs must be output at the very end. */
3828 /* Regular relocs are intertwined with binary data. */
3829 if (curr_addr > addr)
3830 _bfd_error_handler (_("Size error in section %A"),
3832 size = addr - curr_addr;
3833 sto_imm (abfd, section, size, curr_data, curr_addr);
3838 size = bfd_get_reloc_size (rptr->howto);
3840 switch (rptr->howto->type)
3842 case ALPHA_R_IGNORE:
3845 case ALPHA_R_REFLONG:
3846 if (bfd_is_und_section (sym->section))
3848 bfd_vma addend = rptr->addend;
3849 slen = strlen ((char *) sym->name);
3850 etir_output_check (abfd, section, curr_addr, slen);
3853 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STA_GBL);
3854 _bfd_vms_output_counted (recwr, sym->name);
3855 _bfd_vms_output_end_subrec (recwr);
3856 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STA_LW);
3857 _bfd_vms_output_long (recwr, (unsigned long) addend);
3858 _bfd_vms_output_end_subrec (recwr);
3859 _bfd_vms_output_begin_subrec (recwr, ETIR__C_OPR_ADD);
3860 _bfd_vms_output_end_subrec (recwr);
3861 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STO_LW);
3862 _bfd_vms_output_end_subrec (recwr);
3866 _bfd_vms_output_begin_subrec
3867 (recwr, ETIR__C_STO_GBL_LW);
3868 _bfd_vms_output_counted (recwr, sym->name);
3869 _bfd_vms_output_end_subrec (recwr);
3872 else if (bfd_is_abs_section (sym->section))
3874 etir_output_check (abfd, section, curr_addr, 16);
3875 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STA_LW);
3876 _bfd_vms_output_long (recwr, (unsigned long) sym->value);
3877 _bfd_vms_output_end_subrec (recwr);
3878 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STO_LW);
3879 _bfd_vms_output_end_subrec (recwr);
3883 etir_output_check (abfd, section, curr_addr, 32);
3884 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STA_PQ);
3885 _bfd_vms_output_long (recwr,
3886 (unsigned long) sec->target_index);
3887 _bfd_vms_output_quad (recwr, rptr->addend + sym->value);
3888 _bfd_vms_output_end_subrec (recwr);
3889 /* ??? Table B-8 of the OpenVMS Linker Utilily Manual
3890 says that we should have a ETIR__C_STO_OFF here.
3891 But the relocation would not be BFD_RELOC_32 then.
3892 This case is very likely unreachable. */
3893 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STO_LW);
3894 _bfd_vms_output_end_subrec (recwr);
3898 case ALPHA_R_REFQUAD:
3899 if (bfd_is_und_section (sym->section))
3901 bfd_vma addend = rptr->addend;
3902 slen = strlen ((char *) sym->name);
3903 etir_output_check (abfd, section, curr_addr, slen);
3906 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STA_GBL);
3907 _bfd_vms_output_counted (recwr, sym->name);
3908 _bfd_vms_output_end_subrec (recwr);
3909 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STA_QW);
3910 _bfd_vms_output_quad (recwr, addend);
3911 _bfd_vms_output_end_subrec (recwr);
3912 _bfd_vms_output_begin_subrec (recwr, ETIR__C_OPR_ADD);
3913 _bfd_vms_output_end_subrec (recwr);
3914 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STO_QW);
3915 _bfd_vms_output_end_subrec (recwr);
3919 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STO_GBL);
3920 _bfd_vms_output_counted (recwr, sym->name);
3921 _bfd_vms_output_end_subrec (recwr);
3924 else if (bfd_is_abs_section (sym->section))
3926 etir_output_check (abfd, section, curr_addr, 16);
3927 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STA_QW);
3928 _bfd_vms_output_quad (recwr, sym->value);
3929 _bfd_vms_output_end_subrec (recwr);
3930 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STO_QW);
3931 _bfd_vms_output_end_subrec (recwr);
3935 etir_output_check (abfd, section, curr_addr, 32);
3936 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STA_PQ);
3937 _bfd_vms_output_long (recwr,
3938 (unsigned long) sec->target_index);
3939 _bfd_vms_output_quad (recwr, rptr->addend + sym->value);
3940 _bfd_vms_output_end_subrec (recwr);
3941 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STO_OFF);
3942 _bfd_vms_output_end_subrec (recwr);
3947 sto_imm (abfd, section, size, curr_data, curr_addr);
3950 case ALPHA_R_LINKAGE:
3951 etir_output_check (abfd, section, curr_addr, 64);
3952 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STC_LP_PSB);
3953 _bfd_vms_output_long
3954 (recwr, (unsigned long) rptr->addend);
3955 if (rptr->addend > PRIV (vms_linkage_index))
3956 PRIV (vms_linkage_index) = rptr->addend;
3957 _bfd_vms_output_counted (recwr, sym->name);
3958 _bfd_vms_output_byte (recwr, 0);
3959 _bfd_vms_output_end_subrec (recwr);
3962 case ALPHA_R_CODEADDR:
3963 slen = strlen ((char *) sym->name);
3964 etir_output_check (abfd, section, curr_addr, slen);
3965 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STO_CA);
3966 _bfd_vms_output_counted (recwr, sym->name);
3967 _bfd_vms_output_end_subrec (recwr);
3972 = (struct evax_private_udata_struct *) rptr->sym_ptr_ptr;
3973 etir_output_check (abfd, section, curr_addr,
3974 32 + 1 + strlen (udata->origname));
3975 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STC_NOP_GBL);
3976 _bfd_vms_output_long (recwr, (unsigned long) udata->lkindex);
3977 _bfd_vms_output_long
3978 (recwr, (unsigned long) section->target_index);
3979 _bfd_vms_output_quad (recwr, rptr->address);
3980 _bfd_vms_output_long (recwr, (unsigned long) 0x47ff041f);
3981 _bfd_vms_output_long
3982 (recwr, (unsigned long) section->target_index);
3983 _bfd_vms_output_quad (recwr, rptr->addend);
3984 _bfd_vms_output_counted (recwr, udata->origname);
3985 _bfd_vms_output_end_subrec (recwr);
3989 _bfd_error_handler (_("Spurious ALPHA_R_BSR reloc"));
3994 = (struct evax_private_udata_struct *) rptr->sym_ptr_ptr;
3995 etir_output_check (abfd, section, curr_addr,
3996 32 + 1 + strlen (udata->origname));
3997 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STC_LDA_GBL);
3998 _bfd_vms_output_long
3999 (recwr, (unsigned long) udata->lkindex + 1);
4000 _bfd_vms_output_long
4001 (recwr, (unsigned long) section->target_index);
4002 _bfd_vms_output_quad (recwr, rptr->address);
4003 _bfd_vms_output_long (recwr, (unsigned long) 0x237B0000);
4004 _bfd_vms_output_long
4005 (recwr, (unsigned long) udata->bsym->section->target_index);
4006 _bfd_vms_output_quad (recwr, rptr->addend);
4007 _bfd_vms_output_counted (recwr, udata->origname);
4008 _bfd_vms_output_end_subrec (recwr);
4013 = (struct evax_private_udata_struct *) rptr->sym_ptr_ptr;
4014 etir_output_check (abfd, section, curr_addr,
4015 32 + 1 + strlen (udata->origname));
4016 _bfd_vms_output_begin_subrec (recwr, ETIR__C_STC_BOH_GBL);
4017 _bfd_vms_output_long (recwr, (unsigned long) udata->lkindex);
4018 _bfd_vms_output_long
4019 (recwr, (unsigned long) section->target_index);
4020 _bfd_vms_output_quad (recwr, rptr->address);
4021 _bfd_vms_output_long (recwr, (unsigned long) 0xD3400000);
4022 _bfd_vms_output_long
4023 (recwr, (unsigned long) section->target_index);
4024 _bfd_vms_output_quad (recwr, rptr->addend);
4025 _bfd_vms_output_counted (recwr, udata->origname);
4026 _bfd_vms_output_end_subrec (recwr);
4030 _bfd_error_handler (_("Unhandled relocation %s"),
4037 } /* End of relocs loop. */
4039 if (!pass2_in_progress)
4041 /* Output rest of section. */
4042 if (curr_addr > section->size)
4043 _bfd_error_handler (_("Size error in section %A"), section);
4044 size = section->size - curr_addr;
4045 sto_imm (abfd, section, size, curr_data, curr_addr);
4051 pass2_in_progress = 1;
4057 else /* (section->flags & SEC_RELOC) */
4058 sto_imm (abfd, section, section->size, section->contents, 0);
4060 end_etir_record (abfd);
4063 _bfd_vms_output_alignment (recwr, 2);
4067 /* Write cached information into a file being written, at bfd_close. */
4070 alpha_vms_write_object_contents (bfd *abfd)
4072 vms_debug2 ((1, "vms_write_object_contents (%p)\n", abfd));
4074 if (abfd->flags & (EXEC_P | DYNAMIC))
4076 return alpha_vms_write_exec (abfd);
4080 if (abfd->section_count > 0) /* we have sections */
4082 if (!_bfd_vms_write_ehdr (abfd))
4084 if (!_bfd_vms_write_egsd (abfd))
4086 if (!_bfd_vms_write_etir (abfd, EOBJ__C_ETIR))
4088 if (!_bfd_vms_write_eeom (abfd))
4095 /* Debug stuff: nearest line. */
4097 #define SET_MODULE_PARSED(m) \
4098 do { if ((m)->name == NULL) (m)->name = ""; } while (0)
4099 #define IS_MODULE_PARSED(m) ((m)->name != NULL)
4101 /* Build a new module for the specified BFD. */
4103 static struct module *
4104 new_module (bfd *abfd)
4106 struct module *module
4107 = (struct module *) bfd_zalloc (abfd, sizeof (struct module));
4108 module->file_table_count = 16; /* Arbitrary. */
4110 = bfd_malloc (module->file_table_count * sizeof (struct fileinfo));
4114 /* Parse debug info for a module and internalize it. */
4117 parse_module (bfd *abfd, struct module *module, unsigned char *ptr,
4120 unsigned char *maxptr = ptr + length;
4121 unsigned char *src_ptr, *pcl_ptr;
4122 unsigned int prev_linum = 0, curr_linenum = 0;
4123 bfd_vma prev_pc = 0, curr_pc = 0;
4124 struct srecinfo *curr_srec, *srec;
4125 struct lineinfo *curr_line, *line;
4126 struct funcinfo *funcinfo;
4128 /* Initialize tables with zero element. */
4129 curr_srec = (struct srecinfo *) bfd_zalloc (abfd, sizeof (struct srecinfo));
4130 module->srec_table = curr_srec;
4132 curr_line = (struct lineinfo *) bfd_zalloc (abfd, sizeof (struct lineinfo));
4133 module->line_table = curr_line;
4135 while (length == -1 || ptr < maxptr)
4137 /* The first byte is not counted in the recorded length. */
4138 int rec_length = bfd_getl16 (ptr) + 1;
4139 int rec_type = bfd_getl16 (ptr + 2);
4141 vms_debug2 ((2, "DST record: leng %d, type %d\n", rec_length, rec_type));
4143 if (length == -1 && rec_type == DST__K_MODEND)
4150 = _bfd_vms_save_counted_string (ptr + DST_S_B_MODBEG_NAME,
4151 maxptr - (ptr + DST_S_B_MODBEG_NAME));
4158 vms_debug2 ((3, "module: %s\n", module->name));
4165 funcinfo = (struct funcinfo *)
4166 bfd_zalloc (abfd, sizeof (struct funcinfo));
4168 = _bfd_vms_save_counted_string (ptr + DST_S_B_RTNBEG_NAME,
4169 maxptr - (ptr + DST_S_B_RTNBEG_NAME));
4170 funcinfo->low = bfd_getl32 (ptr + DST_S_L_RTNBEG_ADDRESS);
4171 funcinfo->next = module->func_table;
4172 module->func_table = funcinfo;
4174 vms_debug2 ((3, "routine: %s at 0x%lx\n",
4175 funcinfo->name, (unsigned long) funcinfo->low));
4179 module->func_table->high = module->func_table->low
4180 + bfd_getl32 (ptr + DST_S_L_RTNEND_SIZE) - 1;
4182 if (module->func_table->high > module->high)
4183 module->high = module->func_table->high;
4185 vms_debug2 ((3, "end routine\n"));
4189 vms_debug2 ((3, "prologue\n"));
4193 vms_debug2 ((3, "epilog\n"));
4197 vms_debug2 ((3, "block\n"));
4201 vms_debug2 ((3, "end block\n"));
4205 src_ptr = ptr + DST_S_C_SOURCE_HEADER_SIZE;
4207 vms_debug2 ((3, "source info\n"));
4209 while (src_ptr < ptr + rec_length)
4211 int cmd = src_ptr[0], cmd_length, data;
4215 case DST__K_SRC_DECLFILE:
4218 = bfd_getl16 (src_ptr + DST_S_W_SRC_DF_FILEID);
4220 = _bfd_vms_save_counted_string (src_ptr + DST_S_B_SRC_DF_FILENAME,
4221 (ptr + rec_length) -
4222 (src_ptr + DST_S_B_SRC_DF_FILENAME)
4225 while (fileid >= module->file_table_count)
4227 module->file_table_count *= 2;
4229 = bfd_realloc (module->file_table,
4230 module->file_table_count
4231 * sizeof (struct fileinfo));
4234 module->file_table [fileid].name = filename;
4235 module->file_table [fileid].srec = 1;
4236 cmd_length = src_ptr[DST_S_B_SRC_DF_LENGTH] + 2;
4237 vms_debug2 ((4, "DST_S_C_SRC_DECLFILE: %d, %s\n",
4238 fileid, module->file_table [fileid].name));
4242 case DST__K_SRC_DEFLINES_B:
4243 /* Perform the association and set the next higher index
4245 data = src_ptr[DST_S_B_SRC_UNSBYTE];
4246 srec = (struct srecinfo *)
4247 bfd_zalloc (abfd, sizeof (struct srecinfo));
4248 srec->line = curr_srec->line + data;
4249 srec->srec = curr_srec->srec + data;
4250 srec->sfile = curr_srec->sfile;
4251 curr_srec->next = srec;
4254 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_B: %d\n", data));
4257 case DST__K_SRC_DEFLINES_W:
4258 /* Perform the association and set the next higher index
4260 data = bfd_getl16 (src_ptr + DST_S_W_SRC_UNSWORD);
4261 srec = (struct srecinfo *)
4262 bfd_zalloc (abfd, sizeof (struct srecinfo));
4263 srec->line = curr_srec->line + data;
4264 srec->srec = curr_srec->srec + data,
4265 srec->sfile = curr_srec->sfile;
4266 curr_srec->next = srec;
4269 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_W: %d\n", data));
4272 case DST__K_SRC_INCRLNUM_B:
4273 data = src_ptr[DST_S_B_SRC_UNSBYTE];
4274 curr_srec->line += data;
4276 vms_debug2 ((4, "DST_S_C_SRC_INCRLNUM_B: %d\n", data));
4279 case DST__K_SRC_SETFILE:
4280 data = bfd_getl16 (src_ptr + DST_S_W_SRC_UNSWORD);
4281 curr_srec->sfile = data;
4282 curr_srec->srec = module->file_table[data].srec;
4284 vms_debug2 ((4, "DST_S_C_SRC_SETFILE: %d\n", data));
4287 case DST__K_SRC_SETLNUM_L:
4288 data = bfd_getl32 (src_ptr + DST_S_L_SRC_UNSLONG);
4289 curr_srec->line = data;
4291 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_L: %d\n", data));
4294 case DST__K_SRC_SETLNUM_W:
4295 data = bfd_getl16 (src_ptr + DST_S_W_SRC_UNSWORD);
4296 curr_srec->line = data;
4298 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_W: %d\n", data));
4301 case DST__K_SRC_SETREC_L:
4302 data = bfd_getl32 (src_ptr + DST_S_L_SRC_UNSLONG);
4303 curr_srec->srec = data;
4304 module->file_table[curr_srec->sfile].srec = data;
4306 vms_debug2 ((4, "DST_S_C_SRC_SETREC_L: %d\n", data));
4309 case DST__K_SRC_SETREC_W:
4310 data = bfd_getl16 (src_ptr + DST_S_W_SRC_UNSWORD);
4311 curr_srec->srec = data;
4312 module->file_table[curr_srec->sfile].srec = data;
4314 vms_debug2 ((4, "DST_S_C_SRC_SETREC_W: %d\n", data));
4317 case DST__K_SRC_FORMFEED:
4319 vms_debug2 ((4, "DST_S_C_SRC_FORMFEED\n"));
4323 _bfd_error_handler (_("unknown source command %d"),
4329 src_ptr += cmd_length;
4333 case DST__K_LINE_NUM:
4334 pcl_ptr = ptr + DST_S_C_LINE_NUM_HEADER_SIZE;
4336 vms_debug2 ((3, "line info\n"));
4338 while (pcl_ptr < ptr + rec_length)
4340 /* The command byte is signed so we must sign-extend it. */
4341 int cmd = ((signed char *)pcl_ptr)[0], cmd_length, data;
4345 case DST__K_DELTA_PC_W:
4346 data = bfd_getl16 (pcl_ptr + DST_S_W_PCLINE_UNSWORD);
4350 vms_debug2 ((4, "DST__K_DELTA_PC_W: %d\n", data));
4353 case DST__K_DELTA_PC_L:
4354 data = bfd_getl32 (pcl_ptr + DST_S_L_PCLINE_UNSLONG);
4358 vms_debug2 ((4, "DST__K_DELTA_PC_L: %d\n", data));
4361 case DST__K_INCR_LINUM:
4362 data = pcl_ptr[DST_S_B_PCLINE_UNSBYTE];
4363 curr_linenum += data;
4365 vms_debug2 ((4, "DST__K_INCR_LINUM: %d\n", data));
4368 case DST__K_INCR_LINUM_W:
4369 data = bfd_getl16 (pcl_ptr + DST_S_W_PCLINE_UNSWORD);
4370 curr_linenum += data;
4372 vms_debug2 ((4, "DST__K_INCR_LINUM_W: %d\n", data));
4375 case DST__K_INCR_LINUM_L:
4376 data = bfd_getl32 (pcl_ptr + DST_S_L_PCLINE_UNSLONG);
4377 curr_linenum += data;
4379 vms_debug2 ((4, "DST__K_INCR_LINUM_L: %d\n", data));
4382 case DST__K_SET_LINUM_INCR:
4384 (_("DST__K_SET_LINUM_INCR not implemented"));
4388 case DST__K_SET_LINUM_INCR_W:
4390 (_("DST__K_SET_LINUM_INCR_W not implemented"));
4394 case DST__K_RESET_LINUM_INCR:
4396 (_("DST__K_RESET_LINUM_INCR not implemented"));
4400 case DST__K_BEG_STMT_MODE:
4402 (_("DST__K_BEG_STMT_MODE not implemented"));
4406 case DST__K_END_STMT_MODE:
4408 (_("DST__K_END_STMT_MODE not implemented"));
4412 case DST__K_SET_LINUM_B:
4413 data = pcl_ptr[DST_S_B_PCLINE_UNSBYTE];
4414 curr_linenum = data;
4416 vms_debug2 ((4, "DST__K_SET_LINUM_B: %d\n", data));
4419 case DST__K_SET_LINUM:
4420 data = bfd_getl16 (pcl_ptr + DST_S_W_PCLINE_UNSWORD);
4421 curr_linenum = data;
4423 vms_debug2 ((4, "DST__K_SET_LINE_NUM: %d\n", data));
4426 case DST__K_SET_LINUM_L:
4427 data = bfd_getl32 (pcl_ptr + DST_S_L_PCLINE_UNSLONG);
4428 curr_linenum = data;
4430 vms_debug2 ((4, "DST__K_SET_LINUM_L: %d\n", data));
4435 (_("DST__K_SET_PC not implemented"));
4439 case DST__K_SET_PC_W:
4441 (_("DST__K_SET_PC_W not implemented"));
4445 case DST__K_SET_PC_L:
4447 (_("DST__K_SET_PC_L not implemented"));
4451 case DST__K_SET_STMTNUM:
4453 (_("DST__K_SET_STMTNUM not implemented"));
4458 data = pcl_ptr[DST_S_B_PCLINE_UNSBYTE];
4461 vms_debug2 ((4, "DST__K_TERM: %d\n", data));
4465 data = bfd_getl16 (pcl_ptr + DST_S_W_PCLINE_UNSWORD);
4468 vms_debug2 ((4, "DST__K_TERM_W: %d\n", data));
4472 data = bfd_getl32 (pcl_ptr + DST_S_L_PCLINE_UNSLONG);
4475 vms_debug2 ((4, "DST__K_TERM_L: %d\n", data));
4478 case DST__K_SET_ABS_PC:
4479 data = bfd_getl32 (pcl_ptr + DST_S_L_PCLINE_UNSLONG);
4482 vms_debug2 ((4, "DST__K_SET_ABS_PC: 0x%x\n", data));
4491 vms_debug2 ((4, "bump pc to 0x%lx and line to %d\n",
4492 (unsigned long)curr_pc, curr_linenum));
4496 _bfd_error_handler (_("unknown line command %d"), cmd);
4502 if ((curr_linenum != prev_linum && curr_pc != prev_pc)
4504 || cmd == DST__K_DELTA_PC_L
4505 || cmd == DST__K_DELTA_PC_W)
4507 line = (struct lineinfo *)
4508 bfd_zalloc (abfd, sizeof (struct lineinfo));
4509 line->address = curr_pc;
4510 line->line = curr_linenum;
4512 curr_line->next = line;
4515 prev_linum = curr_linenum;
4517 vms_debug2 ((4, "-> correlate pc 0x%lx with line %d\n",
4518 (unsigned long)curr_pc, curr_linenum));
4521 pcl_ptr += cmd_length;
4525 case 0x17: /* Undocumented type used by DEC C to declare equates. */
4526 vms_debug2 ((3, "undocumented type 0x17\n"));
4530 vms_debug2 ((3, "ignoring record\n"));
4538 /* Finalize tables with EOL marker. */
4539 srec = (struct srecinfo *) bfd_zalloc (abfd, sizeof (struct srecinfo));
4540 srec->line = (unsigned int) -1;
4541 srec->srec = (unsigned int) -1;
4542 curr_srec->next = srec;
4544 line = (struct lineinfo *) bfd_zalloc (abfd, sizeof (struct lineinfo));
4545 line->line = (unsigned int) -1;
4546 line->address = (bfd_vma) -1;
4547 curr_line->next = line;
4549 /* Advertise that this module has been parsed. This is needed
4550 because parsing can be either performed at module creation
4551 or deferred until debug info is consumed. */
4552 SET_MODULE_PARSED (module);
4555 /* Build the list of modules for the specified BFD. */
4557 static struct module *
4558 build_module_list (bfd *abfd)
4560 struct module *module, *list = NULL;
4563 if ((dmt = bfd_get_section_by_name (abfd, "$DMT$")))
4565 /* We have a DMT section so this must be an image. Parse the
4566 section and build the list of modules. This is sufficient
4567 since we can compute the start address and the end address
4568 of every module from the section contents. */
4569 bfd_size_type size = bfd_get_section_size (dmt);
4570 unsigned char *ptr, *end;
4572 ptr = (unsigned char *) bfd_alloc (abfd, size);
4576 if (! bfd_get_section_contents (abfd, dmt, ptr, 0, size))
4579 vms_debug2 ((2, "DMT\n"));
4585 /* Each header declares a module with its start offset and size
4586 of debug info in the DST section, as well as the count of
4587 program sections (i.e. address spans) it contains. */
4588 int modbeg = bfd_getl32 (ptr + DBG_S_L_DMT_MODBEG);
4589 int msize = bfd_getl32 (ptr + DBG_S_L_DST_SIZE);
4590 int count = bfd_getl16 (ptr + DBG_S_W_DMT_PSECT_COUNT);
4591 ptr += DBG_S_C_DMT_HEADER_SIZE;
4593 vms_debug2 ((3, "module: modbeg = %d, size = %d, count = %d\n",
4594 modbeg, msize, count));
4596 /* We create a 'module' structure for each program section since
4597 we only support contiguous addresses in a 'module' structure.
4598 As a consequence, the actual debug info in the DST section is
4599 shared and can be parsed multiple times; that doesn't seem to
4600 cause problems in practice. */
4603 int start = bfd_getl32 (ptr + DBG_S_L_DMT_PSECT_START);
4604 int length = bfd_getl32 (ptr + DBG_S_L_DMT_PSECT_LENGTH);
4605 module = new_module (abfd);
4606 module->modbeg = modbeg;
4607 module->size = msize;
4608 module->low = start;
4609 module->high = start + length;
4610 module->next = list;
4612 ptr += DBG_S_C_DMT_PSECT_SIZE;
4614 vms_debug2 ((4, "section: start = 0x%x, length = %d\n",
4621 /* We don't have a DMT section so this must be an object. Parse
4622 the module right now in order to compute its start address and
4624 void *dst = PRIV (dst_section)->contents;
4629 module = new_module (abfd);
4630 parse_module (abfd, module, PRIV (dst_section)->contents, -1);
4637 /* Calculate and return the name of the source file and the line nearest
4638 to the wanted location in the specified module. */
4641 module_find_nearest_line (bfd *abfd, struct module *module, bfd_vma addr,
4642 const char **file, const char **func,
4645 struct funcinfo *funcinfo;
4646 struct lineinfo *lineinfo;
4647 struct srecinfo *srecinfo;
4648 bfd_boolean ret = FALSE;
4650 /* Parse this module if that was not done at module creation. */
4651 if (! IS_MODULE_PARSED (module))
4653 unsigned int size = module->size;
4654 unsigned int modbeg = PRIV (dst_section)->filepos + module->modbeg;
4655 unsigned char *buffer = (unsigned char *) bfd_malloc (module->size);
4657 if (bfd_seek (abfd, modbeg, SEEK_SET) != 0
4658 || bfd_bread (buffer, size, abfd) != size)
4660 bfd_set_error (bfd_error_no_debug_section);
4664 parse_module (abfd, module, buffer, size);
4668 /* Find out the function (if any) that contains the address. */
4669 for (funcinfo = module->func_table; funcinfo; funcinfo = funcinfo->next)
4670 if (addr >= funcinfo->low && addr <= funcinfo->high)
4672 *func = funcinfo->name;
4677 /* Find out the source file and the line nearest to the address. */
4678 for (lineinfo = module->line_table; lineinfo; lineinfo = lineinfo->next)
4679 if (lineinfo->next && addr < lineinfo->next->address)
4681 for (srecinfo = module->srec_table; srecinfo; srecinfo = srecinfo->next)
4682 if (srecinfo->next && lineinfo->line < srecinfo->next->line)
4684 if (srecinfo->sfile > 0)
4686 *file = module->file_table[srecinfo->sfile].name;
4687 *line = srecinfo->srec + lineinfo->line - srecinfo->line;
4691 *file = module->name;
4692 *line = lineinfo->line;
4703 /* Provided a BFD, a section and an offset into the section, calculate and
4704 return the name of the source file and the line nearest to the wanted
4708 _bfd_vms_find_nearest_line (bfd *abfd,
4709 asymbol **symbols ATTRIBUTE_UNUSED,
4715 unsigned int *discriminator)
4717 struct module *module;
4719 /* What address are we looking for? */
4720 bfd_vma addr = section->vma + offset;
4728 /* We can't do anything if there is no DST (debug symbol table). */
4729 if (PRIV (dst_section) == NULL)
4732 /* Create the module list - if not already done. */
4733 if (PRIV (modules) == NULL)
4735 PRIV (modules) = build_module_list (abfd);
4736 if (PRIV (modules) == NULL)
4740 for (module = PRIV (modules); module; module = module->next)
4741 if (addr >= module->low && addr <= module->high)
4742 return module_find_nearest_line (abfd, module, addr, file, func, line);
4747 /* Canonicalizations. */
4748 /* Set name, value, section and flags of SYM from E. */
4751 alpha_vms_convert_symbol (bfd *abfd, struct vms_symbol_entry *e, asymbol *sym)
4760 flags = BSF_NO_FLAGS;
4766 if (e->flags & EGSY__V_WEAK)
4769 if (e->flags & EGSY__V_DEF)
4771 /* Symbol definition. */
4772 flags |= BSF_GLOBAL;
4773 if (e->flags & EGSY__V_NORM)
4774 flags |= BSF_FUNCTION;
4780 /* Symbol reference. */
4781 sec = bfd_und_section_ptr;
4786 /* A universal symbol is by definition global... */
4787 flags |= BSF_GLOBAL;
4789 /* ...and dynamic in shared libraries. */
4790 if (abfd->flags & DYNAMIC)
4791 flags |= BSF_DYNAMIC;
4793 if (e->flags & EGSY__V_WEAK)
4796 if (!(e->flags & EGSY__V_DEF))
4799 if (e->flags & EGSY__V_NORM)
4800 flags |= BSF_FUNCTION;
4803 /* sec = e->section; */
4804 sec = bfd_abs_section_ptr;
4819 /* Return the number of bytes required to store a vector of pointers
4820 to asymbols for all the symbols in the BFD abfd, including a
4821 terminal NULL pointer. If there are no symbols in the BFD,
4822 then return 0. If an error occurs, return -1. */
4825 alpha_vms_get_symtab_upper_bound (bfd *abfd)
4827 vms_debug2 ((1, "alpha_vms_get_symtab_upper_bound (%p), %d symbols\n",
4828 abfd, PRIV (gsd_sym_count)));
4830 return (PRIV (gsd_sym_count) + 1) * sizeof (asymbol *);
4833 /* Read the symbols from the BFD abfd, and fills in the vector
4834 location with pointers to the symbols and a trailing NULL.
4836 Return number of symbols read. */
4839 alpha_vms_canonicalize_symtab (bfd *abfd, asymbol **symbols)
4843 vms_debug2 ((1, "alpha_vms_canonicalize_symtab (%p, <ret>)\n", abfd));
4845 if (PRIV (csymbols) == NULL)
4847 PRIV (csymbols) = (asymbol **) bfd_alloc
4848 (abfd, PRIV (gsd_sym_count) * sizeof (asymbol *));
4850 /* Traverse table and fill symbols vector. */
4851 for (i = 0; i < PRIV (gsd_sym_count); i++)
4853 struct vms_symbol_entry *e = PRIV (syms)[i];
4856 sym = bfd_make_empty_symbol (abfd);
4857 if (sym == NULL || !alpha_vms_convert_symbol (abfd, e, sym))
4859 bfd_release (abfd, PRIV (csymbols));
4860 PRIV (csymbols) = NULL;
4864 PRIV (csymbols)[i] = sym;
4868 if (symbols != NULL)
4870 for (i = 0; i < PRIV (gsd_sym_count); i++)
4871 symbols[i] = PRIV (csymbols)[i];
4875 return PRIV (gsd_sym_count);
4878 /* Read and convert relocations from ETIR. We do it once for all sections. */
4881 alpha_vms_slurp_relocs (bfd *abfd)
4885 vms_debug2 ((3, "alpha_vms_slurp_relocs\n"));
4887 /* We slurp relocs only once, for all sections. */
4888 if (PRIV (reloc_done))
4890 PRIV (reloc_done) = TRUE;
4892 if (alpha_vms_canonicalize_symtab (abfd, NULL) < 0)
4895 if (bfd_seek (abfd, 0, SEEK_SET) != 0)
4900 unsigned char *begin;
4903 bfd_reloc_code_real_type reloc_code;
4909 bfd_vma cur_address;
4911 unsigned char *cur_sym = NULL;
4913 bfd_vma cur_addend = 0;
4915 /* Skip non-ETIR records. */
4916 type = _bfd_vms_get_object_record (abfd);
4917 if (type == EOBJ__C_EEOM)
4919 if (type != EOBJ__C_ETIR)
4922 begin = PRIV (recrd.rec) + 4;
4923 end = PRIV (recrd.rec) + PRIV (recrd.rec_size);
4925 for (ptr = begin; ptr < end; ptr += length)
4929 cmd = bfd_getl16 (ptr);
4930 length = bfd_getl16 (ptr + 2);
4932 cur_address = vaddr;
4934 vms_debug2 ((4, "alpha_vms_slurp_relocs: etir %s\n",
4935 _bfd_vms_etir_name (cmd)));
4939 case ETIR__C_STA_GBL: /* ALPHA_R_REFLONG und_section, step 1 */
4940 /* ALPHA_R_REFQUAD und_section, step 1 */
4945 case ETIR__C_STA_PQ: /* ALPHA_R_REF{LONG|QUAD}, others part 1 */
4946 cur_psidx = bfd_getl32 (ptr + 4);
4947 cur_addend = bfd_getl64 (ptr + 8);
4951 case ETIR__C_CTL_SETRB:
4952 if (prev_cmd != ETIR__C_STA_PQ)
4955 /* xgettext:c-format */
4956 (_("Unknown reloc %s + %s"), _bfd_vms_etir_name (prev_cmd),
4957 _bfd_vms_etir_name (cmd));
4960 cur_psect = cur_psidx;
4966 case ETIR__C_STA_LW: /* ALPHA_R_REFLONG abs_section, step 1 */
4967 /* ALPHA_R_REFLONG und_section, step 2 */
4970 if (prev_cmd != ETIR__C_STA_GBL)
4973 /* xgettext:c-format */
4974 (_("Unknown reloc %s + %s"), _bfd_vms_etir_name (cmd),
4975 _bfd_vms_etir_name (ETIR__C_STA_LW));
4979 cur_addend = bfd_getl32 (ptr + 4);
4983 case ETIR__C_STA_QW: /* ALPHA_R_REFQUAD abs_section, step 1 */
4984 /* ALPHA_R_REFQUAD und_section, step 2 */
4985 if (prev_cmd != -1 && prev_cmd != ETIR__C_STA_GBL)
4988 /* xgettext:c-format */
4989 (_("Unknown reloc %s + %s"), _bfd_vms_etir_name (cmd),
4990 _bfd_vms_etir_name (ETIR__C_STA_QW));
4993 cur_addend = bfd_getl64 (ptr + 4);
4997 case ETIR__C_STO_LW: /* ALPHA_R_REFLONG und_section, step 4 */
4998 /* ALPHA_R_REFLONG abs_section, step 2 */
4999 /* ALPHA_R_REFLONG others, step 2 */
5000 if (prev_cmd != ETIR__C_OPR_ADD
5001 && prev_cmd != ETIR__C_STA_LW
5002 && prev_cmd != ETIR__C_STA_PQ)
5004 /* xgettext:c-format */
5005 _bfd_error_handler (_("Unknown reloc %s + %s"),
5006 _bfd_vms_etir_name (prev_cmd),
5007 _bfd_vms_etir_name (ETIR__C_STO_LW));
5010 reloc_code = BFD_RELOC_32;
5013 case ETIR__C_STO_QW: /* ALPHA_R_REFQUAD und_section, step 4 */
5014 /* ALPHA_R_REFQUAD abs_section, step 2 */
5015 if (prev_cmd != ETIR__C_OPR_ADD && prev_cmd != ETIR__C_STA_QW)
5017 /* xgettext:c-format */
5018 _bfd_error_handler (_("Unknown reloc %s + %s"),
5019 _bfd_vms_etir_name (prev_cmd),
5020 _bfd_vms_etir_name (ETIR__C_STO_QW));
5023 reloc_code = BFD_RELOC_64;
5026 case ETIR__C_STO_OFF: /* ALPHA_R_REFQUAD others, step 2 */
5027 if (prev_cmd != ETIR__C_STA_PQ)
5029 /* xgettext:c-format */
5030 _bfd_error_handler (_("Unknown reloc %s + %s"),
5031 _bfd_vms_etir_name (prev_cmd),
5032 _bfd_vms_etir_name (ETIR__C_STO_OFF));
5035 reloc_code = BFD_RELOC_64;
5038 case ETIR__C_OPR_ADD: /* ALPHA_R_REFLONG und_section, step 3 */
5039 /* ALPHA_R_REFQUAD und_section, step 3 */
5040 if (prev_cmd != ETIR__C_STA_LW && prev_cmd != ETIR__C_STA_QW)
5042 /* xgettext:c-format */
5043 _bfd_error_handler (_("Unknown reloc %s + %s"),
5044 _bfd_vms_etir_name (prev_cmd),
5045 _bfd_vms_etir_name (ETIR__C_OPR_ADD));
5048 prev_cmd = ETIR__C_OPR_ADD;
5051 case ETIR__C_STO_CA: /* ALPHA_R_CODEADDR */
5052 reloc_code = BFD_RELOC_ALPHA_CODEADDR;
5056 case ETIR__C_STO_GBL: /* ALPHA_R_REFQUAD und_section */
5057 reloc_code = BFD_RELOC_64;
5061 case ETIR__C_STO_GBL_LW: /* ALPHA_R_REFLONG und_section */
5062 reloc_code = BFD_RELOC_32;
5066 case ETIR__C_STC_LP_PSB: /* ALPHA_R_LINKAGE */
5067 reloc_code = BFD_RELOC_ALPHA_LINKAGE;
5071 case ETIR__C_STC_NOP_GBL: /* ALPHA_R_NOP */
5072 reloc_code = BFD_RELOC_ALPHA_NOP;
5075 case ETIR__C_STC_BSR_GBL: /* ALPHA_R_BSR */
5076 reloc_code = BFD_RELOC_ALPHA_BSR;
5079 case ETIR__C_STC_LDA_GBL: /* ALPHA_R_LDA */
5080 reloc_code = BFD_RELOC_ALPHA_LDA;
5083 case ETIR__C_STC_BOH_GBL: /* ALPHA_R_BOH */
5084 reloc_code = BFD_RELOC_ALPHA_BOH;
5088 cur_sym = ptr + 4 + 32;
5089 cur_address = bfd_getl64 (ptr + 4 + 8);
5090 cur_addend = bfd_getl64 (ptr + 4 + 24);
5093 case ETIR__C_STO_IMM:
5094 vaddr += bfd_getl32 (ptr + 4);
5098 _bfd_error_handler (_("Unknown reloc %s"),
5099 _bfd_vms_etir_name (cmd));
5105 struct vms_section_data_struct *vms_sec;
5108 /* Get section to which the relocation applies. */
5109 if (cur_psect < 0 || cur_psect > (int)PRIV (section_count))
5111 _bfd_error_handler (_("Invalid section index in ETIR"));
5115 if (PRIV (sections) == NULL)
5117 sec = PRIV (sections)[cur_psect];
5118 if (sec == bfd_abs_section_ptr)
5120 _bfd_error_handler (_("Relocation for non-REL psect"));
5124 vms_sec = vms_section_data (sec);
5126 /* Allocate a reloc entry. */
5127 if (sec->reloc_count >= vms_sec->reloc_max)
5129 if (vms_sec->reloc_max == 0)
5131 vms_sec->reloc_max = 64;
5132 sec->relocation = bfd_zmalloc
5133 (vms_sec->reloc_max * sizeof (arelent));
5137 vms_sec->reloc_max *= 2;
5138 sec->relocation = bfd_realloc
5139 (sec->relocation, vms_sec->reloc_max * sizeof (arelent));
5142 reloc = &sec->relocation[sec->reloc_count];
5145 reloc->howto = bfd_reloc_type_lookup (abfd, reloc_code);
5147 if (cur_sym != NULL)
5150 unsigned int symlen = *cur_sym;
5153 /* Linear search. */
5158 for (j = 0; j < PRIV (gsd_sym_count); j++)
5159 if (PRIV (syms)[j]->namelen == symlen
5160 && memcmp (PRIV (syms)[j]->name, cur_sym, symlen) == 0)
5162 sym = &PRIV (csymbols)[j];
5167 _bfd_error_handler (_("Unknown symbol in command %s"),
5168 _bfd_vms_etir_name (cmd));
5169 reloc->sym_ptr_ptr = NULL;
5172 reloc->sym_ptr_ptr = sym;
5174 else if (cur_psidx >= 0)
5176 if (PRIV (sections) == NULL)
5178 reloc->sym_ptr_ptr =
5179 PRIV (sections)[cur_psidx]->symbol_ptr_ptr;
5182 reloc->sym_ptr_ptr = NULL;
5184 reloc->address = cur_address;
5185 reloc->addend = cur_addend;
5187 vaddr += bfd_get_reloc_size (reloc->howto);
5196 vms_debug2 ((3, "alpha_vms_slurp_relocs: result = TRUE\n"));
5201 /* Return the number of bytes required to store the relocation
5202 information associated with the given section. */
5205 alpha_vms_get_reloc_upper_bound (bfd *abfd ATTRIBUTE_UNUSED, asection *section)
5207 alpha_vms_slurp_relocs (abfd);
5209 return (section->reloc_count + 1) * sizeof (arelent *);
5212 /* Convert relocations from VMS (external) form into BFD internal
5213 form. Return the number of relocations. */
5216 alpha_vms_canonicalize_reloc (bfd *abfd, asection *section, arelent **relptr,
5217 asymbol **symbols ATTRIBUTE_UNUSED)
5222 if (!alpha_vms_slurp_relocs (abfd))
5225 count = section->reloc_count;
5226 tblptr = section->relocation;
5229 *relptr++ = tblptr++;
5231 *relptr = (arelent *) NULL;
5232 return section->reloc_count;
5235 /* Install a new set of internal relocs. */
5237 #define alpha_vms_set_reloc _bfd_generic_set_reloc
5240 /* This is just copied from ecoff-alpha, needs to be fixed probably. */
5242 /* How to process the various reloc types. */
5244 static bfd_reloc_status_type
5245 reloc_nil (bfd * abfd ATTRIBUTE_UNUSED,
5246 arelent *reloc ATTRIBUTE_UNUSED,
5247 asymbol *sym ATTRIBUTE_UNUSED,
5248 void * data ATTRIBUTE_UNUSED,
5249 asection *sec ATTRIBUTE_UNUSED,
5250 bfd *output_bfd ATTRIBUTE_UNUSED,
5251 char **error_message ATTRIBUTE_UNUSED)
5254 vms_debug (1, "reloc_nil (abfd %p, output_bfd %p)\n", abfd, output_bfd);
5255 vms_debug (2, "In section %s, symbol %s\n",
5256 sec->name, sym->name);
5257 vms_debug (2, "reloc sym %s, addr %08lx, addend %08lx, reloc is a %s\n",
5258 reloc->sym_ptr_ptr[0]->name,
5259 (unsigned long)reloc->address,
5260 (unsigned long)reloc->addend, reloc->howto->name);
5261 vms_debug (2, "data at %p\n", data);
5262 /* _bfd_hexdump (2, data, bfd_get_reloc_size (reloc->howto), 0); */
5265 return bfd_reloc_ok;
5268 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
5269 from smaller values. Start with zero, widen, *then* decrement. */
5270 #define MINUS_ONE (((bfd_vma)0) - 1)
5272 static reloc_howto_type alpha_howto_table[] =
5274 HOWTO (ALPHA_R_IGNORE, /* Type. */
5275 0, /* Rightshift. */
5276 0, /* Size (0 = byte, 1 = short, 2 = long). */
5278 TRUE, /* PC relative. */
5280 complain_overflow_dont,/* Complain_on_overflow. */
5281 reloc_nil, /* Special_function. */
5282 "IGNORE", /* Name. */
5283 TRUE, /* Partial_inplace. */
5284 0, /* Source mask */
5286 TRUE), /* PC rel offset. */
5288 /* A 64 bit reference to a symbol. */
5289 HOWTO (ALPHA_R_REFQUAD, /* Type. */
5290 0, /* Rightshift. */
5291 4, /* Size (0 = byte, 1 = short, 2 = long). */
5293 FALSE, /* PC relative. */
5295 complain_overflow_bitfield, /* Complain_on_overflow. */
5296 reloc_nil, /* Special_function. */
5297 "REFQUAD", /* Name. */
5298 TRUE, /* Partial_inplace. */
5299 MINUS_ONE, /* Source mask. */
5300 MINUS_ONE, /* Dest mask. */
5301 FALSE), /* PC rel offset. */
5303 /* A 21 bit branch. The native assembler generates these for
5304 branches within the text segment, and also fills in the PC
5305 relative offset in the instruction. */
5306 HOWTO (ALPHA_R_BRADDR, /* Type. */
5307 2, /* Rightshift. */
5308 2, /* Size (0 = byte, 1 = short, 2 = long). */
5310 TRUE, /* PC relative. */
5312 complain_overflow_signed, /* Complain_on_overflow. */
5313 reloc_nil, /* Special_function. */
5314 "BRADDR", /* Name. */
5315 TRUE, /* Partial_inplace. */
5316 0x1fffff, /* Source mask. */
5317 0x1fffff, /* Dest mask. */
5318 FALSE), /* PC rel offset. */
5320 /* A hint for a jump to a register. */
5321 HOWTO (ALPHA_R_HINT, /* Type. */
5322 2, /* Rightshift. */
5323 1, /* Size (0 = byte, 1 = short, 2 = long). */
5325 TRUE, /* PC relative. */
5327 complain_overflow_dont,/* Complain_on_overflow. */
5328 reloc_nil, /* Special_function. */
5330 TRUE, /* Partial_inplace. */
5331 0x3fff, /* Source mask. */
5332 0x3fff, /* Dest mask. */
5333 FALSE), /* PC rel offset. */
5335 /* 16 bit PC relative offset. */
5336 HOWTO (ALPHA_R_SREL16, /* Type. */
5337 0, /* Rightshift. */
5338 1, /* Size (0 = byte, 1 = short, 2 = long). */
5340 TRUE, /* PC relative. */
5342 complain_overflow_signed, /* Complain_on_overflow. */
5343 reloc_nil, /* Special_function. */
5344 "SREL16", /* Name. */
5345 TRUE, /* Partial_inplace. */
5346 0xffff, /* Source mask. */
5347 0xffff, /* Dest mask. */
5348 FALSE), /* PC rel offset. */
5350 /* 32 bit PC relative offset. */
5351 HOWTO (ALPHA_R_SREL32, /* Type. */
5352 0, /* Rightshift. */
5353 2, /* Size (0 = byte, 1 = short, 2 = long). */
5355 TRUE, /* PC relative. */
5357 complain_overflow_signed, /* Complain_on_overflow. */
5358 reloc_nil, /* Special_function. */
5359 "SREL32", /* Name. */
5360 TRUE, /* Partial_inplace. */
5361 0xffffffff, /* Source mask. */
5362 0xffffffff, /* Dest mask. */
5363 FALSE), /* PC rel offset. */
5365 /* A 64 bit PC relative offset. */
5366 HOWTO (ALPHA_R_SREL64, /* Type. */
5367 0, /* Rightshift. */
5368 4, /* Size (0 = byte, 1 = short, 2 = long). */
5370 TRUE, /* PC relative. */
5372 complain_overflow_signed, /* Complain_on_overflow. */
5373 reloc_nil, /* Special_function. */
5374 "SREL64", /* Name. */
5375 TRUE, /* Partial_inplace. */
5376 MINUS_ONE, /* Source mask. */
5377 MINUS_ONE, /* Dest mask. */
5378 FALSE), /* PC rel offset. */
5380 /* Push a value on the reloc evaluation stack. */
5381 HOWTO (ALPHA_R_OP_PUSH, /* Type. */
5382 0, /* Rightshift. */
5383 0, /* Size (0 = byte, 1 = short, 2 = long). */
5385 FALSE, /* PC relative. */
5387 complain_overflow_dont,/* Complain_on_overflow. */
5388 reloc_nil, /* Special_function. */
5389 "OP_PUSH", /* Name. */
5390 FALSE, /* Partial_inplace. */
5391 0, /* Source mask. */
5393 FALSE), /* PC rel offset. */
5395 /* Store the value from the stack at the given address. Store it in
5396 a bitfield of size r_size starting at bit position r_offset. */
5397 HOWTO (ALPHA_R_OP_STORE, /* Type. */
5398 0, /* Rightshift. */
5399 4, /* Size (0 = byte, 1 = short, 2 = long). */
5401 FALSE, /* PC relative. */
5403 complain_overflow_dont,/* Complain_on_overflow. */
5404 reloc_nil, /* Special_function. */
5405 "OP_STORE", /* Name. */
5406 FALSE, /* Partial_inplace. */
5407 0, /* Source mask. */
5408 MINUS_ONE, /* Dest mask. */
5409 FALSE), /* PC rel offset. */
5411 /* Subtract the reloc address from the value on the top of the
5412 relocation stack. */
5413 HOWTO (ALPHA_R_OP_PSUB, /* Type. */
5414 0, /* Rightshift. */
5415 0, /* Size (0 = byte, 1 = short, 2 = long). */
5417 FALSE, /* PC relative. */
5419 complain_overflow_dont,/* Complain_on_overflow. */
5420 reloc_nil, /* Special_function. */
5421 "OP_PSUB", /* Name. */
5422 FALSE, /* Partial_inplace. */
5423 0, /* Source mask. */
5425 FALSE), /* PC rel offset. */
5427 /* Shift the value on the top of the relocation stack right by the
5429 HOWTO (ALPHA_R_OP_PRSHIFT, /* Type. */
5430 0, /* Rightshift. */
5431 0, /* Size (0 = byte, 1 = short, 2 = long). */
5433 FALSE, /* PC relative. */
5435 complain_overflow_dont,/* Complain_on_overflow. */
5436 reloc_nil, /* Special_function. */
5437 "OP_PRSHIFT", /* Name. */
5438 FALSE, /* Partial_inplace. */
5439 0, /* Source mask. */
5441 FALSE), /* PC rel offset. */
5443 /* Hack. Linkage is done by linker. */
5444 HOWTO (ALPHA_R_LINKAGE, /* Type. */
5445 0, /* Rightshift. */
5446 8, /* Size (0 = byte, 1 = short, 2 = long). */
5448 FALSE, /* PC relative. */
5450 complain_overflow_dont,/* Complain_on_overflow. */
5451 reloc_nil, /* Special_function. */
5452 "LINKAGE", /* Name. */
5453 FALSE, /* Partial_inplace. */
5454 0, /* Source mask. */
5456 FALSE), /* PC rel offset. */
5458 /* A 32 bit reference to a symbol. */
5459 HOWTO (ALPHA_R_REFLONG, /* Type. */
5460 0, /* Rightshift. */
5461 2, /* Size (0 = byte, 1 = short, 2 = long). */
5463 FALSE, /* PC relative. */
5465 complain_overflow_bitfield, /* Complain_on_overflow. */
5466 reloc_nil, /* Special_function. */
5467 "REFLONG", /* Name. */
5468 TRUE, /* Partial_inplace. */
5469 0xffffffff, /* Source mask. */
5470 0xffffffff, /* Dest mask. */
5471 FALSE), /* PC rel offset. */
5473 /* A 64 bit reference to a procedure, written as 32 bit value. */
5474 HOWTO (ALPHA_R_CODEADDR, /* Type. */
5475 0, /* Rightshift. */
5476 4, /* Size (0 = byte, 1 = short, 2 = long). */
5478 FALSE, /* PC relative. */
5480 complain_overflow_signed,/* Complain_on_overflow. */
5481 reloc_nil, /* Special_function. */
5482 "CODEADDR", /* Name. */
5483 FALSE, /* Partial_inplace. */
5484 0xffffffff, /* Source mask. */
5485 0xffffffff, /* Dest mask. */
5486 FALSE), /* PC rel offset. */
5488 HOWTO (ALPHA_R_NOP, /* Type. */
5489 0, /* Rightshift. */
5490 3, /* Size (0 = byte, 1 = short, 2 = long). */
5492 /* The following value must match that of ALPHA_R_BSR/ALPHA_R_BOH
5493 because the calculations for the 3 relocations are the same.
5494 See B.4.5.2 of the OpenVMS Linker Utility Manual. */
5495 TRUE, /* PC relative. */
5497 complain_overflow_dont,/* Complain_on_overflow. */
5498 reloc_nil, /* Special_function. */
5500 FALSE, /* Partial_inplace. */
5501 0xffffffff, /* Source mask. */
5502 0xffffffff, /* Dest mask. */
5503 FALSE), /* PC rel offset. */
5505 HOWTO (ALPHA_R_BSR, /* Type. */
5506 0, /* Rightshift. */
5507 3, /* Size (0 = byte, 1 = short, 2 = long). */
5509 TRUE, /* PC relative. */
5511 complain_overflow_dont,/* Complain_on_overflow. */
5512 reloc_nil, /* Special_function. */
5514 FALSE, /* Partial_inplace. */
5515 0xffffffff, /* Source mask. */
5516 0xffffffff, /* Dest mask. */
5517 FALSE), /* PC rel offset. */
5519 HOWTO (ALPHA_R_LDA, /* Type. */
5520 0, /* Rightshift. */
5521 3, /* Size (0 = byte, 1 = short, 2 = long). */
5523 FALSE, /* PC relative. */
5525 complain_overflow_dont,/* Complain_on_overflow. */
5526 reloc_nil, /* Special_function. */
5528 FALSE, /* Partial_inplace. */
5529 0xffffffff, /* Source mask. */
5530 0xffffffff, /* Dest mask. */
5531 FALSE), /* PC rel offset. */
5533 HOWTO (ALPHA_R_BOH, /* Type. */
5534 0, /* Rightshift. */
5535 3, /* Size (0 = byte, 1 = short, 2 = long, 3 = nil). */
5537 TRUE, /* PC relative. */
5539 complain_overflow_dont,/* Complain_on_overflow. */
5540 reloc_nil, /* Special_function. */
5542 FALSE, /* Partial_inplace. */
5543 0xffffffff, /* Source mask. */
5544 0xffffffff, /* Dest mask. */
5545 FALSE), /* PC rel offset. */
5548 /* Return a pointer to a howto structure which, when invoked, will perform
5549 the relocation code on data from the architecture noted. */
5551 static const struct reloc_howto_struct *
5552 alpha_vms_bfd_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
5553 bfd_reloc_code_real_type code)
5557 vms_debug2 ((1, "vms_bfd_reloc_type_lookup (%p, %d)\t", abfd, code));
5561 case BFD_RELOC_16: alpha_type = ALPHA_R_SREL16; break;
5562 case BFD_RELOC_32: alpha_type = ALPHA_R_REFLONG; break;
5563 case BFD_RELOC_64: alpha_type = ALPHA_R_REFQUAD; break;
5564 case BFD_RELOC_CTOR: alpha_type = ALPHA_R_REFQUAD; break;
5565 case BFD_RELOC_23_PCREL_S2: alpha_type = ALPHA_R_BRADDR; break;
5566 case BFD_RELOC_ALPHA_HINT: alpha_type = ALPHA_R_HINT; break;
5567 case BFD_RELOC_16_PCREL: alpha_type = ALPHA_R_SREL16; break;
5568 case BFD_RELOC_32_PCREL: alpha_type = ALPHA_R_SREL32; break;
5569 case BFD_RELOC_64_PCREL: alpha_type = ALPHA_R_SREL64; break;
5570 case BFD_RELOC_ALPHA_LINKAGE: alpha_type = ALPHA_R_LINKAGE; break;
5571 case BFD_RELOC_ALPHA_CODEADDR: alpha_type = ALPHA_R_CODEADDR; break;
5572 case BFD_RELOC_ALPHA_NOP: alpha_type = ALPHA_R_NOP; break;
5573 case BFD_RELOC_ALPHA_BSR: alpha_type = ALPHA_R_BSR; break;
5574 case BFD_RELOC_ALPHA_LDA: alpha_type = ALPHA_R_LDA; break;
5575 case BFD_RELOC_ALPHA_BOH: alpha_type = ALPHA_R_BOH; break;
5577 _bfd_error_handler (_("reloc (%d) is *UNKNOWN*"), code);
5580 vms_debug2 ((2, "reloc is %s\n", alpha_howto_table[alpha_type].name));
5581 return & alpha_howto_table[alpha_type];
5584 static reloc_howto_type *
5585 alpha_vms_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
5591 i < sizeof (alpha_howto_table) / sizeof (alpha_howto_table[0]);
5593 if (alpha_howto_table[i].name != NULL
5594 && strcasecmp (alpha_howto_table[i].name, r_name) == 0)
5595 return &alpha_howto_table[i];
5601 alpha_vms_get_synthetic_symtab (bfd *abfd,
5602 long symcount ATTRIBUTE_UNUSED,
5603 asymbol **usyms ATTRIBUTE_UNUSED,
5604 long dynsymcount ATTRIBUTE_UNUSED,
5605 asymbol **dynsyms ATTRIBUTE_UNUSED,
5612 syms = (asymbol *) bfd_malloc (PRIV (norm_sym_count) * sizeof (asymbol));
5617 for (i = 0; i < PRIV (gsd_sym_count); i++)
5619 struct vms_symbol_entry *e = PRIV (syms)[i];
5630 flags = BSF_LOCAL | BSF_SYNTHETIC;
5637 if ((e->flags & EGSY__V_DEF) && (e->flags & EGSY__V_NORM))
5639 value = e->code_value;
5640 sec = e->code_section;
5651 sname = bfd_alloc (abfd, l + 5);
5654 memcpy (sname, name, l);
5655 memcpy (sname + l, "..en", 5);
5662 sym->udata.p = NULL;
5671 vms_time_to_str (unsigned char *buf)
5673 time_t t = vms_rawtime_to_time_t (buf);
5674 char *res = ctime (&t);
5677 res = "*invalid time*";
5684 evax_bfd_print_emh (FILE *file, unsigned char *rec, unsigned int rec_len)
5686 struct vms_emh_common *emh = (struct vms_emh_common *)rec;
5687 unsigned int subtype;
5689 subtype = (unsigned)bfd_getl16 (emh->subtyp);
5691 /* xgettext:c-format */
5692 fprintf (file, _(" EMH %u (len=%u): "), subtype, rec_len);
5694 /* PR 21618: Check for invalid lengths. */
5695 if (rec_len < sizeof (* emh))
5697 fprintf (file, _(" Error: The length is less than the length of an EMH record\n"));
5705 struct vms_emh_mhd *mhd = (struct vms_emh_mhd *)rec;
5708 fprintf (file, _("Module header\n"));
5709 fprintf (file, _(" structure level: %u\n"), mhd->strlvl);
5710 fprintf (file, _(" max record size: %u\n"),
5711 (unsigned)bfd_getl32 (mhd->recsiz));
5712 name = (char *)(mhd + 1);
5713 fprintf (file, _(" module name : %.*s\n"), name[0], name + 1);
5714 name += name[0] + 1;
5715 fprintf (file, _(" module version : %.*s\n"), name[0], name + 1);
5716 name += name[0] + 1;
5717 fprintf (file, _(" compile date : %.17s\n"), name);
5722 fprintf (file, _("Language Processor Name\n"));
5723 fprintf (file, _(" language name: %.*s\n"),
5724 (int)(rec_len - sizeof (struct vms_emh_common)),
5725 (char *)rec + sizeof (struct vms_emh_common));
5730 fprintf (file, _("Source Files Header\n"));
5731 fprintf (file, _(" file: %.*s\n"),
5732 (int)(rec_len - sizeof (struct vms_emh_common)),
5733 (char *)rec + sizeof (struct vms_emh_common));
5738 fprintf (file, _("Title Text Header\n"));
5739 fprintf (file, _(" title: %.*s\n"),
5740 (int)(rec_len - sizeof (struct vms_emh_common)),
5741 (char *)rec + sizeof (struct vms_emh_common));
5746 fprintf (file, _("Copyright Header\n"));
5747 fprintf (file, _(" copyright: %.*s\n"),
5748 (int)(rec_len - sizeof (struct vms_emh_common)),
5749 (char *)rec + sizeof (struct vms_emh_common));
5753 fprintf (file, _("unhandled emh subtype %u\n"), subtype);
5759 evax_bfd_print_eeom (FILE *file, unsigned char *rec, unsigned int rec_len)
5761 struct vms_eeom *eeom = (struct vms_eeom *)rec;
5763 fprintf (file, _(" EEOM (len=%u):\n"), rec_len);
5765 /* PR 21618: Check for invalid lengths. */
5766 if (rec_len < sizeof (* eeom))
5768 fprintf (file, _(" Error: The length is less than the length of an EEOM record\n"));
5772 fprintf (file, _(" number of cond linkage pairs: %u\n"),
5773 (unsigned)bfd_getl32 (eeom->total_lps));
5774 fprintf (file, _(" completion code: %u\n"),
5775 (unsigned)bfd_getl16 (eeom->comcod));
5778 fprintf (file, _(" transfer addr flags: 0x%02x\n"), eeom->tfrflg);
5779 fprintf (file, _(" transfer addr psect: %u\n"),
5780 (unsigned)bfd_getl32 (eeom->psindx));
5781 fprintf (file, _(" transfer address : 0x%08x\n"),
5782 (unsigned)bfd_getl32 (eeom->tfradr));
5787 exav_bfd_print_egsy_flags (unsigned int flags, FILE *file)
5789 if (flags & EGSY__V_WEAK)
5790 fputs (_(" WEAK"), file);
5791 if (flags & EGSY__V_DEF)
5792 fputs (_(" DEF"), file);
5793 if (flags & EGSY__V_UNI)
5794 fputs (_(" UNI"), file);
5795 if (flags & EGSY__V_REL)
5796 fputs (_(" REL"), file);
5797 if (flags & EGSY__V_COMM)
5798 fputs (_(" COMM"), file);
5799 if (flags & EGSY__V_VECEP)
5800 fputs (_(" VECEP"), file);
5801 if (flags & EGSY__V_NORM)
5802 fputs (_(" NORM"), file);
5803 if (flags & EGSY__V_QUAD_VAL)
5804 fputs (_(" QVAL"), file);
5808 evax_bfd_print_egsd_flags (FILE *file, unsigned int flags)
5810 if (flags & EGPS__V_PIC)
5811 fputs (_(" PIC"), file);
5812 if (flags & EGPS__V_LIB)
5813 fputs (_(" LIB"), file);
5814 if (flags & EGPS__V_OVR)
5815 fputs (_(" OVR"), file);
5816 if (flags & EGPS__V_REL)
5817 fputs (_(" REL"), file);
5818 if (flags & EGPS__V_GBL)
5819 fputs (_(" GBL"), file);
5820 if (flags & EGPS__V_SHR)
5821 fputs (_(" SHR"), file);
5822 if (flags & EGPS__V_EXE)
5823 fputs (_(" EXE"), file);
5824 if (flags & EGPS__V_RD)
5825 fputs (_(" RD"), file);
5826 if (flags & EGPS__V_WRT)
5827 fputs (_(" WRT"), file);
5828 if (flags & EGPS__V_VEC)
5829 fputs (_(" VEC"), file);
5830 if (flags & EGPS__V_NOMOD)
5831 fputs (_(" NOMOD"), file);
5832 if (flags & EGPS__V_COM)
5833 fputs (_(" COM"), file);
5834 if (flags & EGPS__V_ALLOC_64BIT)
5835 fputs (_(" 64B"), file);
5839 evax_bfd_print_egsd (FILE *file, unsigned char *rec, unsigned int rec_len)
5841 unsigned int off = sizeof (struct vms_egsd);
5844 fprintf (file, _(" EGSD (len=%u):\n"), rec_len);
5847 for (off = sizeof (struct vms_egsd); off < rec_len; )
5849 struct vms_egsd_entry *e = (struct vms_egsd_entry *)(rec + off);
5853 type = (unsigned)bfd_getl16 (e->gsdtyp);
5854 len = (unsigned)bfd_getl16 (e->gsdsiz);
5856 /* xgettext:c-format */
5857 fprintf (file, _(" EGSD entry %2u (type: %u, len: %u): "),
5861 if (off + len > rec_len || off + len < off)
5863 fprintf (file, _(" Error: length larger than remaining space in record\n"));
5871 struct vms_egps *egps = (struct vms_egps *)e;
5872 unsigned int flags = bfd_getl16 (egps->flags);
5875 fprintf (file, _("PSC - Program section definition\n"));
5876 fprintf (file, _(" alignment : 2**%u\n"), egps->align);
5877 fprintf (file, _(" flags : 0x%04x"), flags);
5878 evax_bfd_print_egsd_flags (file, flags);
5880 l = bfd_getl32 (egps->alloc);
5881 fprintf (file, _(" alloc (len): %u (0x%08x)\n"), l, l);
5882 fprintf (file, _(" name : %.*s\n"),
5883 egps->namlng, egps->name);
5888 struct vms_esgps *esgps = (struct vms_esgps *)e;
5889 unsigned int flags = bfd_getl16 (esgps->flags);
5892 fprintf (file, _("SPSC - Shared Image Program section def\n"));
5893 fprintf (file, _(" alignment : 2**%u\n"), esgps->align);
5894 fprintf (file, _(" flags : 0x%04x"), flags);
5895 evax_bfd_print_egsd_flags (file, flags);
5897 l = bfd_getl32 (esgps->alloc);
5898 fprintf (file, _(" alloc (len) : %u (0x%08x)\n"), l, l);
5899 fprintf (file, _(" image offset : 0x%08x\n"),
5900 (unsigned int)bfd_getl32 (esgps->base));
5901 fprintf (file, _(" symvec offset : 0x%08x\n"),
5902 (unsigned int)bfd_getl32 (esgps->value));
5903 fprintf (file, _(" name : %.*s\n"),
5904 esgps->namlng, esgps->name);
5909 struct vms_egsy *egsy = (struct vms_egsy *)e;
5910 unsigned int flags = bfd_getl16 (egsy->flags);
5912 if (flags & EGSY__V_DEF)
5914 struct vms_esdf *esdf = (struct vms_esdf *)e;
5916 fprintf (file, _("SYM - Global symbol definition\n"));
5917 fprintf (file, _(" flags: 0x%04x"), flags);
5918 exav_bfd_print_egsy_flags (flags, file);
5920 fprintf (file, _(" psect offset: 0x%08x\n"),
5921 (unsigned)bfd_getl32 (esdf->value));
5922 if (flags & EGSY__V_NORM)
5924 fprintf (file, _(" code address: 0x%08x\n"),
5925 (unsigned)bfd_getl32 (esdf->code_address));
5926 fprintf (file, _(" psect index for entry point : %u\n"),
5927 (unsigned)bfd_getl32 (esdf->ca_psindx));
5929 fprintf (file, _(" psect index : %u\n"),
5930 (unsigned)bfd_getl32 (esdf->psindx));
5931 fprintf (file, _(" name : %.*s\n"),
5932 esdf->namlng, esdf->name);
5936 struct vms_esrf *esrf = (struct vms_esrf *)e;
5938 fprintf (file, _("SYM - Global symbol reference\n"));
5939 fprintf (file, _(" name : %.*s\n"),
5940 esrf->namlng, esrf->name);
5946 struct vms_eidc *eidc = (struct vms_eidc *)e;
5947 unsigned int flags = bfd_getl32 (eidc->flags);
5950 fprintf (file, _("IDC - Ident Consistency check\n"));
5951 fprintf (file, _(" flags : 0x%08x"), flags);
5952 if (flags & EIDC__V_BINIDENT)
5953 fputs (" BINDENT", file);
5955 fprintf (file, _(" id match : %x\n"),
5956 (flags >> EIDC__V_IDMATCH_SH) & EIDC__V_IDMATCH_MASK);
5957 fprintf (file, _(" error severity: %x\n"),
5958 (flags >> EIDC__V_ERRSEV_SH) & EIDC__V_ERRSEV_MASK);
5960 fprintf (file, _(" entity name : %.*s\n"), p[0], p + 1);
5962 fprintf (file, _(" object name : %.*s\n"), p[0], p + 1);
5964 if (flags & EIDC__V_BINIDENT)
5965 fprintf (file, _(" binary ident : 0x%08x\n"),
5966 (unsigned)bfd_getl32 (p + 1));
5968 fprintf (file, _(" ascii ident : %.*s\n"), p[0], p + 1);
5973 struct vms_egst *egst = (struct vms_egst *)e;
5974 unsigned int flags = bfd_getl16 (egst->header.flags);
5976 fprintf (file, _("SYMG - Universal symbol definition\n"));
5977 fprintf (file, _(" flags: 0x%04x"), flags);
5978 exav_bfd_print_egsy_flags (flags, file);
5980 fprintf (file, _(" symbol vector offset: 0x%08x\n"),
5981 (unsigned)bfd_getl32 (egst->value));
5982 fprintf (file, _(" entry point: 0x%08x\n"),
5983 (unsigned)bfd_getl32 (egst->lp_1));
5984 fprintf (file, _(" proc descr : 0x%08x\n"),
5985 (unsigned)bfd_getl32 (egst->lp_2));
5986 fprintf (file, _(" psect index: %u\n"),
5987 (unsigned)bfd_getl32 (egst->psindx));
5988 fprintf (file, _(" name : %.*s\n"),
5989 egst->namlng, egst->name);
5994 struct vms_esdfv *esdfv = (struct vms_esdfv *)e;
5995 unsigned int flags = bfd_getl16 (esdfv->flags);
5997 fprintf (file, _("SYMV - Vectored symbol definition\n"));
5998 fprintf (file, _(" flags: 0x%04x"), flags);
5999 exav_bfd_print_egsy_flags (flags, file);
6001 fprintf (file, _(" vector : 0x%08x\n"),
6002 (unsigned)bfd_getl32 (esdfv->vector));
6003 fprintf (file, _(" psect offset: %u\n"),
6004 (unsigned)bfd_getl32 (esdfv->value));
6005 fprintf (file, _(" psect index : %u\n"),
6006 (unsigned)bfd_getl32 (esdfv->psindx));
6007 fprintf (file, _(" name : %.*s\n"),
6008 esdfv->namlng, esdfv->name);
6013 struct vms_esdfm *esdfm = (struct vms_esdfm *)e;
6014 unsigned int flags = bfd_getl16 (esdfm->flags);
6016 fprintf (file, _("SYMM - Global symbol definition with version\n"));
6017 fprintf (file, _(" flags: 0x%04x"), flags);
6018 exav_bfd_print_egsy_flags (flags, file);
6020 fprintf (file, _(" version mask: 0x%08x\n"),
6021 (unsigned)bfd_getl32 (esdfm->version_mask));
6022 fprintf (file, _(" psect offset: %u\n"),
6023 (unsigned)bfd_getl32 (esdfm->value));
6024 fprintf (file, _(" psect index : %u\n"),
6025 (unsigned)bfd_getl32 (esdfm->psindx));
6026 fprintf (file, _(" name : %.*s\n"),
6027 esdfm->namlng, esdfm->name);
6031 fprintf (file, _("unhandled egsd entry type %u\n"), type);
6039 evax_bfd_print_hex (FILE *file, const char *pfx,
6040 const unsigned char *buf, unsigned int len)
6046 for (i = 0; i < len; i++)
6050 fprintf (file, " %02x", buf[i]);
6063 evax_bfd_print_etir_stc_ir (FILE *file, const unsigned char *buf, int is_ps)
6065 /* xgettext:c-format */
6066 fprintf (file, _(" linkage index: %u, replacement insn: 0x%08x\n"),
6067 (unsigned)bfd_getl32 (buf),
6068 (unsigned)bfd_getl32 (buf + 16));
6069 /* xgettext:c-format */
6070 fprintf (file, _(" psect idx 1: %u, offset 1: 0x%08x %08x\n"),
6071 (unsigned)bfd_getl32 (buf + 4),
6072 (unsigned)bfd_getl32 (buf + 12),
6073 (unsigned)bfd_getl32 (buf + 8));
6074 /* xgettext:c-format */
6075 fprintf (file, _(" psect idx 2: %u, offset 2: 0x%08x %08x\n"),
6076 (unsigned)bfd_getl32 (buf + 20),
6077 (unsigned)bfd_getl32 (buf + 28),
6078 (unsigned)bfd_getl32 (buf + 24));
6080 /* xgettext:c-format */
6081 fprintf (file, _(" psect idx 3: %u, offset 3: 0x%08x %08x\n"),
6082 (unsigned)bfd_getl32 (buf + 32),
6083 (unsigned)bfd_getl32 (buf + 40),
6084 (unsigned)bfd_getl32 (buf + 36));
6086 fprintf (file, _(" global name: %.*s\n"), buf[32], buf + 33);
6090 evax_bfd_print_etir (FILE *file, const char *name,
6091 unsigned char *rec, unsigned int rec_len)
6093 unsigned int off = sizeof (struct vms_egsd);
6094 unsigned int sec_len = 0;
6096 /* xgettext:c-format */
6097 fprintf (file, _(" %s (len=%u+%u):\n"), name,
6098 (unsigned)(rec_len - sizeof (struct vms_eobjrec)),
6099 (unsigned)sizeof (struct vms_eobjrec));
6101 for (off = sizeof (struct vms_eobjrec); off < rec_len; )
6103 struct vms_etir *etir = (struct vms_etir *)(rec + off);
6108 type = bfd_getl16 (etir->rectyp);
6109 size = bfd_getl16 (etir->size);
6110 buf = rec + off + sizeof (struct vms_etir);
6112 if (off + size > rec_len || off + size < off)
6114 fprintf (file, _(" Error: length larger than remaining space in record\n"));
6118 /* xgettext:c-format */
6119 fprintf (file, _(" (type: %3u, size: 4+%3u): "), type, size - 4);
6122 case ETIR__C_STA_GBL:
6123 fprintf (file, _("STA_GBL (stack global) %.*s\n"),
6126 case ETIR__C_STA_LW:
6127 fprintf (file, _("STA_LW (stack longword) 0x%08x\n"),
6128 (unsigned)bfd_getl32 (buf));
6130 case ETIR__C_STA_QW:
6131 fprintf (file, _("STA_QW (stack quadword) 0x%08x %08x\n"),
6132 (unsigned)bfd_getl32 (buf + 4),
6133 (unsigned)bfd_getl32 (buf + 0));
6135 case ETIR__C_STA_PQ:
6136 fprintf (file, _("STA_PQ (stack psect base + offset)\n"));
6137 /* xgettext:c-format */
6138 fprintf (file, _(" psect: %u, offset: 0x%08x %08x\n"),
6139 (unsigned)bfd_getl32 (buf + 0),
6140 (unsigned)bfd_getl32 (buf + 8),
6141 (unsigned)bfd_getl32 (buf + 4));
6143 case ETIR__C_STA_LI:
6144 fprintf (file, _("STA_LI (stack literal)\n"));
6146 case ETIR__C_STA_MOD:
6147 fprintf (file, _("STA_MOD (stack module)\n"));
6149 case ETIR__C_STA_CKARG:
6150 fprintf (file, _("STA_CKARG (compare procedure argument)\n"));
6154 fprintf (file, _("STO_B (store byte)\n"));
6157 fprintf (file, _("STO_W (store word)\n"));
6159 case ETIR__C_STO_LW:
6160 fprintf (file, _("STO_LW (store longword)\n"));
6162 case ETIR__C_STO_QW:
6163 fprintf (file, _("STO_QW (store quadword)\n"));
6165 case ETIR__C_STO_IMMR:
6167 unsigned int len = bfd_getl32 (buf);
6169 _("STO_IMMR (store immediate repeat) %u bytes\n"),
6171 evax_bfd_print_hex (file, " ", buf + 4, len);
6175 case ETIR__C_STO_GBL:
6176 fprintf (file, _("STO_GBL (store global) %.*s\n"),
6179 case ETIR__C_STO_CA:
6180 fprintf (file, _("STO_CA (store code address) %.*s\n"),
6183 case ETIR__C_STO_RB:
6184 fprintf (file, _("STO_RB (store relative branch)\n"));
6186 case ETIR__C_STO_AB:
6187 fprintf (file, _("STO_AB (store absolute branch)\n"));
6189 case ETIR__C_STO_OFF:
6190 fprintf (file, _("STO_OFF (store offset to psect)\n"));
6192 case ETIR__C_STO_IMM:
6194 unsigned int len = bfd_getl32 (buf);
6196 _("STO_IMM (store immediate) %u bytes\n"),
6198 evax_bfd_print_hex (file, " ", buf + 4, len);
6202 case ETIR__C_STO_GBL_LW:
6203 fprintf (file, _("STO_GBL_LW (store global longword) %.*s\n"),
6206 case ETIR__C_STO_LP_PSB:
6207 fprintf (file, _("STO_OFF (store LP with procedure signature)\n"));
6209 case ETIR__C_STO_HINT_GBL:
6210 fprintf (file, _("STO_BR_GBL (store branch global) *todo*\n"));
6212 case ETIR__C_STO_HINT_PS:
6213 fprintf (file, _("STO_BR_PS (store branch psect + offset) *todo*\n"));
6216 case ETIR__C_OPR_NOP:
6217 fprintf (file, _("OPR_NOP (no-operation)\n"));
6219 case ETIR__C_OPR_ADD:
6220 fprintf (file, _("OPR_ADD (add)\n"));
6222 case ETIR__C_OPR_SUB:
6223 fprintf (file, _("OPR_SUB (subtract)\n"));
6225 case ETIR__C_OPR_MUL:
6226 fprintf (file, _("OPR_MUL (multiply)\n"));
6228 case ETIR__C_OPR_DIV:
6229 fprintf (file, _("OPR_DIV (divide)\n"));
6231 case ETIR__C_OPR_AND:
6232 fprintf (file, _("OPR_AND (logical and)\n"));
6234 case ETIR__C_OPR_IOR:
6235 fprintf (file, _("OPR_IOR (logical inclusive or)\n"));
6237 case ETIR__C_OPR_EOR:
6238 fprintf (file, _("OPR_EOR (logical exclusive or)\n"));
6240 case ETIR__C_OPR_NEG:
6241 fprintf (file, _("OPR_NEG (negate)\n"));
6243 case ETIR__C_OPR_COM:
6244 fprintf (file, _("OPR_COM (complement)\n"));
6246 case ETIR__C_OPR_INSV:
6247 fprintf (file, _("OPR_INSV (insert field)\n"));
6249 case ETIR__C_OPR_ASH:
6250 fprintf (file, _("OPR_ASH (arithmetic shift)\n"));
6252 case ETIR__C_OPR_USH:
6253 fprintf (file, _("OPR_USH (unsigned shift)\n"));
6255 case ETIR__C_OPR_ROT:
6256 fprintf (file, _("OPR_ROT (rotate)\n"));
6258 case ETIR__C_OPR_SEL:
6259 fprintf (file, _("OPR_SEL (select)\n"));
6261 case ETIR__C_OPR_REDEF:
6262 fprintf (file, _("OPR_REDEF (redefine symbol to curr location)\n"));
6264 case ETIR__C_OPR_DFLIT:
6265 fprintf (file, _("OPR_REDEF (define a literal)\n"));
6268 case ETIR__C_STC_LP:
6269 fprintf (file, _("STC_LP (store cond linkage pair)\n"));
6271 case ETIR__C_STC_LP_PSB:
6273 _("STC_LP_PSB (store cond linkage pair + signature)\n"));
6274 /* xgettext:c-format */
6275 fprintf (file, _(" linkage index: %u, procedure: %.*s\n"),
6276 (unsigned)bfd_getl32 (buf), buf[4], buf + 5);
6277 buf += 4 + 1 + buf[4];
6278 fprintf (file, _(" signature: %.*s\n"), buf[0], buf + 1);
6280 case ETIR__C_STC_GBL:
6281 fprintf (file, _("STC_GBL (store cond global)\n"));
6282 /* xgettext:c-format */
6283 fprintf (file, _(" linkage index: %u, global: %.*s\n"),
6284 (unsigned)bfd_getl32 (buf), buf[4], buf + 5);
6286 case ETIR__C_STC_GCA:
6287 fprintf (file, _("STC_GCA (store cond code address)\n"));
6288 /* xgettext:c-format */
6289 fprintf (file, _(" linkage index: %u, procedure name: %.*s\n"),
6290 (unsigned)bfd_getl32 (buf), buf[4], buf + 5);
6292 case ETIR__C_STC_PS:
6293 fprintf (file, _("STC_PS (store cond psect + offset)\n"));
6295 /* xgettext:c-format */
6296 _(" linkage index: %u, psect: %u, offset: 0x%08x %08x\n"),
6297 (unsigned)bfd_getl32 (buf),
6298 (unsigned)bfd_getl32 (buf + 4),
6299 (unsigned)bfd_getl32 (buf + 12),
6300 (unsigned)bfd_getl32 (buf + 8));
6302 case ETIR__C_STC_NOP_GBL:
6303 fprintf (file, _("STC_NOP_GBL (store cond NOP at global addr)\n"));
6304 evax_bfd_print_etir_stc_ir (file, buf, 0);
6306 case ETIR__C_STC_NOP_PS:
6307 fprintf (file, _("STC_NOP_PS (store cond NOP at psect + offset)\n"));
6308 evax_bfd_print_etir_stc_ir (file, buf, 1);
6310 case ETIR__C_STC_BSR_GBL:
6311 fprintf (file, _("STC_BSR_GBL (store cond BSR at global addr)\n"));
6312 evax_bfd_print_etir_stc_ir (file, buf, 0);
6314 case ETIR__C_STC_BSR_PS:
6315 fprintf (file, _("STC_BSR_PS (store cond BSR at psect + offset)\n"));
6316 evax_bfd_print_etir_stc_ir (file, buf, 1);
6318 case ETIR__C_STC_LDA_GBL:
6319 fprintf (file, _("STC_LDA_GBL (store cond LDA at global addr)\n"));
6320 evax_bfd_print_etir_stc_ir (file, buf, 0);
6322 case ETIR__C_STC_LDA_PS:
6323 fprintf (file, _("STC_LDA_PS (store cond LDA at psect + offset)\n"));
6324 evax_bfd_print_etir_stc_ir (file, buf, 1);
6326 case ETIR__C_STC_BOH_GBL:
6327 fprintf (file, _("STC_BOH_GBL (store cond BOH at global addr)\n"));
6328 evax_bfd_print_etir_stc_ir (file, buf, 0);
6330 case ETIR__C_STC_BOH_PS:
6331 fprintf (file, _("STC_BOH_PS (store cond BOH at psect + offset)\n"));
6332 evax_bfd_print_etir_stc_ir (file, buf, 1);
6334 case ETIR__C_STC_NBH_GBL:
6336 _("STC_NBH_GBL (store cond or hint at global addr)\n"));
6338 case ETIR__C_STC_NBH_PS:
6340 _("STC_NBH_PS (store cond or hint at psect + offset)\n"));
6343 case ETIR__C_CTL_SETRB:
6344 fprintf (file, _("CTL_SETRB (set relocation base)\n"));
6347 case ETIR__C_CTL_AUGRB:
6349 unsigned int val = bfd_getl32 (buf);
6350 fprintf (file, _("CTL_AUGRB (augment relocation base) %u\n"), val);
6353 case ETIR__C_CTL_DFLOC:
6354 fprintf (file, _("CTL_DFLOC (define location)\n"));
6356 case ETIR__C_CTL_STLOC:
6357 fprintf (file, _("CTL_STLOC (set location)\n"));
6359 case ETIR__C_CTL_STKDL:
6360 fprintf (file, _("CTL_STKDL (stack defined location)\n"));
6363 fprintf (file, _("*unhandled*\n"));
6371 evax_bfd_print_eobj (struct bfd *abfd, FILE *file)
6373 bfd_boolean is_first = TRUE;
6374 bfd_boolean has_records = FALSE;
6378 unsigned int rec_len;
6379 unsigned int pad_len;
6381 unsigned int hdr_size;
6386 unsigned char buf[6];
6391 if (bfd_bread (buf, sizeof (buf), abfd) != sizeof (buf))
6393 fprintf (file, _("cannot read GST record length\n"));
6396 rec_len = bfd_getl16 (buf + 0);
6397 if (rec_len == bfd_getl16 (buf + 4)
6398 && bfd_getl16 (buf + 2) == EOBJ__C_EMH)
6400 /* The format is raw: record-size, type, record-size. */
6402 pad_len = (rec_len + 1) & ~1U;
6405 else if (rec_len == EOBJ__C_EMH)
6407 has_records = FALSE;
6408 pad_len = bfd_getl16 (buf + 2);
6414 fprintf (file, _("cannot find EMH in first GST record\n"));
6417 rec = bfd_malloc (pad_len);
6418 memcpy (rec, buf + sizeof (buf) - hdr_size, hdr_size);
6422 unsigned int rec_len2 = 0;
6423 unsigned char hdr[4];
6427 unsigned char buf_len[2];
6429 if (bfd_bread (buf_len, sizeof (buf_len), abfd)
6430 != sizeof (buf_len))
6432 fprintf (file, _("cannot read GST record length\n"));
6435 rec_len2 = (unsigned)bfd_getl16 (buf_len);
6438 if (bfd_bread (hdr, sizeof (hdr), abfd) != sizeof (hdr))
6440 fprintf (file, _("cannot read GST record header\n"));
6443 rec_len = (unsigned)bfd_getl16 (hdr + 2);
6445 pad_len = (rec_len + 1) & ~1U;
6448 rec = bfd_malloc (pad_len);
6449 memcpy (rec, hdr, sizeof (hdr));
6450 hdr_size = sizeof (hdr);
6451 if (has_records && rec_len2 != rec_len)
6453 fprintf (file, _(" corrupted GST\n"));
6458 if (bfd_bread (rec + hdr_size, pad_len - hdr_size, abfd)
6459 != pad_len - hdr_size)
6461 fprintf (file, _("cannot read GST record\n"));
6465 type = (unsigned)bfd_getl16 (rec);
6470 evax_bfd_print_emh (file, rec, rec_len);
6473 evax_bfd_print_egsd (file, rec, rec_len);
6476 evax_bfd_print_eeom (file, rec, rec_len);
6481 evax_bfd_print_etir (file, "ETIR", rec, rec_len);
6484 evax_bfd_print_etir (file, "EDBG", rec, rec_len);
6487 evax_bfd_print_etir (file, "ETBT", rec, rec_len);
6490 fprintf (file, _(" unhandled EOBJ record type %u\n"), type);
6498 evax_bfd_print_relocation_records (FILE *file, const unsigned char *rel,
6499 unsigned int stride)
6507 count = bfd_getl32 (rel + 0);
6511 base = bfd_getl32 (rel + 4);
6513 /* xgettext:c-format */
6514 fprintf (file, _(" bitcount: %u, base addr: 0x%08x\n"),
6518 for (j = 0; count > 0; j += 4, count -= 32)
6524 val = bfd_getl32 (rel);
6527 /* xgettext:c-format */
6528 fprintf (file, _(" bitmap: 0x%08x (count: %u):\n"), val, count);
6530 for (k = 0; k < 32; k++)
6535 fprintf (file, _(" %08x"), base + (j * 8 + k) * stride);
6550 evax_bfd_print_address_fixups (FILE *file, const unsigned char *rel)
6557 count = bfd_getl32 (rel + 0);
6560 /* xgettext:c-format */
6561 fprintf (file, _(" image %u (%u entries)\n"),
6562 (unsigned)bfd_getl32 (rel + 4), count);
6564 for (j = 0; j < count; j++)
6566 /* xgettext:c-format */
6567 fprintf (file, _(" offset: 0x%08x, val: 0x%08x\n"),
6568 (unsigned)bfd_getl32 (rel + 0),
6569 (unsigned)bfd_getl32 (rel + 4));
6576 evax_bfd_print_reference_fixups (FILE *file, const unsigned char *rel)
6585 count = bfd_getl32 (rel + 0);
6588 /* xgettext:c-format */
6589 fprintf (file, _(" image %u (%u entries), offsets:\n"),
6590 (unsigned)bfd_getl32 (rel + 4), count);
6592 for (j = 0; j < count; j++)
6596 fprintf (file, _(" 0x%08x"), (unsigned)bfd_getl32 (rel));
6611 evax_bfd_print_indent (int indent, FILE *file)
6613 for (; indent; indent--)
6618 evax_bfd_get_dsc_name (unsigned int v)
6622 case DSC__K_DTYPE_Z:
6623 return "Z (Unspecified)";
6624 case DSC__K_DTYPE_V:
6626 case DSC__K_DTYPE_BU:
6627 return "BU (Byte logical)";
6628 case DSC__K_DTYPE_WU:
6629 return "WU (Word logical)";
6630 case DSC__K_DTYPE_LU:
6631 return "LU (Longword logical)";
6632 case DSC__K_DTYPE_QU:
6633 return "QU (Quadword logical)";
6634 case DSC__K_DTYPE_B:
6635 return "B (Byte integer)";
6636 case DSC__K_DTYPE_W:
6637 return "W (Word integer)";
6638 case DSC__K_DTYPE_L:
6639 return "L (Longword integer)";
6640 case DSC__K_DTYPE_Q:
6641 return "Q (Quadword integer)";
6642 case DSC__K_DTYPE_F:
6643 return "F (Single-precision floating)";
6644 case DSC__K_DTYPE_D:
6645 return "D (Double-precision floating)";
6646 case DSC__K_DTYPE_FC:
6647 return "FC (Complex)";
6648 case DSC__K_DTYPE_DC:
6649 return "DC (Double-precision Complex)";
6650 case DSC__K_DTYPE_T:
6651 return "T (ASCII text string)";
6652 case DSC__K_DTYPE_NU:
6653 return "NU (Numeric string, unsigned)";
6654 case DSC__K_DTYPE_NL:
6655 return "NL (Numeric string, left separate sign)";
6656 case DSC__K_DTYPE_NLO:
6657 return "NLO (Numeric string, left overpunched sign)";
6658 case DSC__K_DTYPE_NR:
6659 return "NR (Numeric string, right separate sign)";
6660 case DSC__K_DTYPE_NRO:
6661 return "NRO (Numeric string, right overpunched sig)";
6662 case DSC__K_DTYPE_NZ:
6663 return "NZ (Numeric string, zoned sign)";
6664 case DSC__K_DTYPE_P:
6665 return "P (Packed decimal string)";
6666 case DSC__K_DTYPE_ZI:
6667 return "ZI (Sequence of instructions)";
6668 case DSC__K_DTYPE_ZEM:
6669 return "ZEM (Procedure entry mask)";
6670 case DSC__K_DTYPE_DSC:
6671 return "DSC (Descriptor, used for arrays of dyn strings)";
6672 case DSC__K_DTYPE_OU:
6673 return "OU (Octaword logical)";
6674 case DSC__K_DTYPE_O:
6675 return "O (Octaword integer)";
6676 case DSC__K_DTYPE_G:
6677 return "G (Double precision G floating, 64 bit)";
6678 case DSC__K_DTYPE_H:
6679 return "H (Quadruple precision floating, 128 bit)";
6680 case DSC__K_DTYPE_GC:
6681 return "GC (Double precision complex, G floating)";
6682 case DSC__K_DTYPE_HC:
6683 return "HC (Quadruple precision complex, H floating)";
6684 case DSC__K_DTYPE_CIT:
6685 return "CIT (COBOL intermediate temporary)";
6686 case DSC__K_DTYPE_BPV:
6687 return "BPV (Bound Procedure Value)";
6688 case DSC__K_DTYPE_BLV:
6689 return "BLV (Bound Label Value)";
6690 case DSC__K_DTYPE_VU:
6691 return "VU (Bit Unaligned)";
6692 case DSC__K_DTYPE_ADT:
6693 return "ADT (Absolute Date-Time)";
6694 case DSC__K_DTYPE_VT:
6695 return "VT (Varying Text)";
6696 case DSC__K_DTYPE_T2:
6697 return "T2 (16-bit char)";
6698 case DSC__K_DTYPE_VT2:
6699 return "VT2 (16-bit varying char)";
6701 return "?? (unknown)";
6706 evax_bfd_print_desc (const unsigned char *buf, int indent, FILE *file)
6708 unsigned char bclass = buf[3];
6709 unsigned char dtype = buf[2];
6710 unsigned int len = (unsigned)bfd_getl16 (buf);
6711 unsigned int pointer = (unsigned)bfd_getl32 (buf + 4);
6713 evax_bfd_print_indent (indent, file);
6715 if (len == 1 && pointer == 0xffffffffUL)
6718 fprintf (file, _("64 bits *unhandled*\n"));
6722 /* xgettext:c-format */
6723 fprintf (file, _("class: %u, dtype: %u, length: %u, pointer: 0x%08x\n"),
6724 bclass, dtype, len, pointer);
6727 case DSC__K_CLASS_NCA:
6729 const struct vms_dsc_nca *dsc = (const void *)buf;
6731 const unsigned char *b;
6733 evax_bfd_print_indent (indent, file);
6734 fprintf (file, _("non-contiguous array of %s\n"),
6735 evax_bfd_get_dsc_name (dsc->dtype));
6736 evax_bfd_print_indent (indent + 1, file);
6738 /* xgettext:c-format */
6739 _("dimct: %u, aflags: 0x%02x, digits: %u, scale: %u\n"),
6740 dsc->dimct, dsc->aflags, dsc->digits, dsc->scale);
6741 evax_bfd_print_indent (indent + 1, file);
6743 /* xgettext:c-format */
6744 _("arsize: %u, a0: 0x%08x\n"),
6745 (unsigned)bfd_getl32 (dsc->arsize),
6746 (unsigned)bfd_getl32 (dsc->a0));
6747 evax_bfd_print_indent (indent + 1, file);
6748 fprintf (file, _("Strides:\n"));
6749 b = buf + sizeof (*dsc);
6750 for (i = 0; i < dsc->dimct; i++)
6752 evax_bfd_print_indent (indent + 2, file);
6753 fprintf (file, "[%u]: %u\n", i + 1,
6754 (unsigned)bfd_getl32 (b));
6757 evax_bfd_print_indent (indent + 1, file);
6758 fprintf (file, _("Bounds:\n"));
6759 b = buf + sizeof (*dsc);
6760 for (i = 0; i < dsc->dimct; i++)
6762 evax_bfd_print_indent (indent + 2, file);
6763 /* xgettext:c-format */
6764 fprintf (file, _("[%u]: Lower: %u, upper: %u\n"), i + 1,
6765 (unsigned)bfd_getl32 (b + 0),
6766 (unsigned)bfd_getl32 (b + 4));
6771 case DSC__K_CLASS_UBS:
6773 const struct vms_dsc_ubs *ubs = (const void *)buf;
6775 evax_bfd_print_indent (indent, file);
6776 fprintf (file, _("unaligned bit-string of %s\n"),
6777 evax_bfd_get_dsc_name (ubs->dtype));
6778 evax_bfd_print_indent (indent + 1, file);
6780 /* xgettext:c-format */
6781 _("base: %u, pos: %u\n"),
6782 (unsigned)bfd_getl32 (ubs->base),
6783 (unsigned)bfd_getl32 (ubs->pos));
6787 fprintf (file, _("*unhandled*\n"));
6794 evax_bfd_print_valspec (const unsigned char *buf, int indent, FILE *file)
6796 unsigned int vflags = buf[0];
6797 unsigned int value = (unsigned)bfd_getl32 (buf + 1);
6798 unsigned int len = 5;
6800 evax_bfd_print_indent (indent, file);
6801 /* xgettext:c-format */
6802 fprintf (file, _("vflags: 0x%02x, value: 0x%08x "), vflags, value);
6807 case DST__K_VFLAGS_NOVAL:
6808 fprintf (file, _("(no value)\n"));
6810 case DST__K_VFLAGS_NOTACTIVE:
6811 fprintf (file, _("(not active)\n"));
6813 case DST__K_VFLAGS_UNALLOC:
6814 fprintf (file, _("(not allocated)\n"));
6816 case DST__K_VFLAGS_DSC:
6817 fprintf (file, _("(descriptor)\n"));
6818 evax_bfd_print_desc (buf + value, indent + 1, file);
6820 case DST__K_VFLAGS_TVS:
6821 fprintf (file, _("(trailing value)\n"));
6823 case DST__K_VS_FOLLOWS:
6824 fprintf (file, _("(value spec follows)\n"));
6826 case DST__K_VFLAGS_BITOFFS:
6827 fprintf (file, _("(at bit offset %u)\n"), value);
6830 /* xgettext:c-format */
6831 fprintf (file, _("(reg: %u, disp: %u, indir: %u, kind: "),
6832 (vflags & DST__K_REGNUM_MASK) >> DST__K_REGNUM_SHIFT,
6833 vflags & DST__K_DISP ? 1 : 0,
6834 vflags & DST__K_INDIR ? 1 : 0);
6835 switch (vflags & DST__K_VALKIND_MASK)
6837 case DST__K_VALKIND_LITERAL:
6838 fputs (_("literal"), file);
6840 case DST__K_VALKIND_ADDR:
6841 fputs (_("address"), file);
6843 case DST__K_VALKIND_DESC:
6844 fputs (_("desc"), file);
6846 case DST__K_VALKIND_REG:
6847 fputs (_("reg"), file);
6850 fputs (")\n", file);
6857 evax_bfd_print_typspec (const unsigned char *buf, int indent, FILE *file)
6859 unsigned char kind = buf[2];
6860 unsigned int len = (unsigned)bfd_getl16 (buf);
6862 evax_bfd_print_indent (indent, file);
6863 /* xgettext:c-format */
6864 fprintf (file, _("len: %2u, kind: %2u "), len, kind);
6868 case DST__K_TS_ATOM:
6869 /* xgettext:c-format */
6870 fprintf (file, _("atomic, type=0x%02x %s\n"),
6871 buf[0], evax_bfd_get_dsc_name (buf[0]));
6874 fprintf (file, _("indirect, defined at 0x%08x\n"),
6875 (unsigned)bfd_getl32 (buf));
6877 case DST__K_TS_TPTR:
6878 fprintf (file, _("typed pointer\n"));
6879 evax_bfd_print_typspec (buf, indent + 1, file);
6882 fprintf (file, _("pointer\n"));
6884 case DST__K_TS_ARRAY:
6886 const unsigned char *vs;
6887 unsigned int vec_len;
6890 fprintf (file, _("array, dim: %u, bitmap: "), buf[0]);
6891 vec_len = (buf[0] + 1 + 7) / 8;
6892 for (i = 0; i < vec_len; i++)
6893 fprintf (file, " %02x", buf[i + 1]);
6895 vs = buf + 1 + vec_len;
6896 evax_bfd_print_indent (indent, file);
6897 fprintf (file, _("array descriptor:\n"));
6898 vs += evax_bfd_print_valspec (vs, indent + 1, file);
6899 for (i = 0; i < buf[0] + 1U; i++)
6900 if (buf[1 + i / 8] & (1 << (i % 8)))
6902 evax_bfd_print_indent (indent, file);
6904 fprintf (file, _("type spec for element:\n"));
6906 fprintf (file, _("type spec for subscript %u:\n"), i);
6907 evax_bfd_print_typspec (vs, indent + 1, file);
6908 vs += bfd_getl16 (vs);
6913 fprintf (file, _("*unhandled*\n"));
6918 evax_bfd_print_dst (struct bfd *abfd, unsigned int dst_size, FILE *file)
6920 unsigned int off = 0;
6921 unsigned int pc = 0;
6922 unsigned int line = 0;
6924 fprintf (file, _("Debug symbol table:\n"));
6926 while (dst_size > 0)
6928 struct vms_dst_header dsth;
6933 if (bfd_bread (&dsth, sizeof (dsth), abfd) != sizeof (dsth))
6935 fprintf (file, _("cannot read DST header\n"));
6938 len = bfd_getl16 (dsth.length);
6939 type = bfd_getl16 (dsth.type);
6940 /* xgettext:c-format */
6941 fprintf (file, _(" type: %3u, len: %3u (at 0x%08x): "),
6951 len -= sizeof (dsth);
6952 buf = bfd_malloc (len);
6953 if (bfd_bread (buf, len, abfd) != len)
6955 fprintf (file, _("cannot read DST symbol\n"));
6960 case DSC__K_DTYPE_V:
6961 case DSC__K_DTYPE_BU:
6962 case DSC__K_DTYPE_WU:
6963 case DSC__K_DTYPE_LU:
6964 case DSC__K_DTYPE_QU:
6965 case DSC__K_DTYPE_B:
6966 case DSC__K_DTYPE_W:
6967 case DSC__K_DTYPE_L:
6968 case DSC__K_DTYPE_Q:
6969 case DSC__K_DTYPE_F:
6970 case DSC__K_DTYPE_D:
6971 case DSC__K_DTYPE_FC:
6972 case DSC__K_DTYPE_DC:
6973 case DSC__K_DTYPE_T:
6974 case DSC__K_DTYPE_NU:
6975 case DSC__K_DTYPE_NL:
6976 case DSC__K_DTYPE_NLO:
6977 case DSC__K_DTYPE_NR:
6978 case DSC__K_DTYPE_NRO:
6979 case DSC__K_DTYPE_NZ:
6980 case DSC__K_DTYPE_P:
6981 case DSC__K_DTYPE_ZI:
6982 case DSC__K_DTYPE_ZEM:
6983 case DSC__K_DTYPE_DSC:
6984 case DSC__K_DTYPE_OU:
6985 case DSC__K_DTYPE_O:
6986 case DSC__K_DTYPE_G:
6987 case DSC__K_DTYPE_H:
6988 case DSC__K_DTYPE_GC:
6989 case DSC__K_DTYPE_HC:
6990 case DSC__K_DTYPE_CIT:
6991 case DSC__K_DTYPE_BPV:
6992 case DSC__K_DTYPE_BLV:
6993 case DSC__K_DTYPE_VU:
6994 case DSC__K_DTYPE_ADT:
6995 case DSC__K_DTYPE_VT:
6996 case DSC__K_DTYPE_T2:
6997 case DSC__K_DTYPE_VT2:
6998 fprintf (file, _("standard data: %s\n"),
6999 evax_bfd_get_dsc_name (type));
7000 evax_bfd_print_valspec (buf, 4, file);
7001 fprintf (file, _(" name: %.*s\n"), buf[5], buf + 6);
7005 struct vms_dst_modbeg *dst = (void *)buf;
7006 const char *name = (const char *)buf + sizeof (*dst);
7008 fprintf (file, _("modbeg\n"));
7009 /* xgettext:c-format */
7010 fprintf (file, _(" flags: %d, language: %u, "
7011 "major: %u, minor: %u\n"),
7013 (unsigned)bfd_getl32 (dst->language),
7014 (unsigned)bfd_getl16 (dst->major),
7015 (unsigned)bfd_getl16 (dst->minor));
7016 fprintf (file, _(" module name: %.*s\n"),
7018 name += name[0] + 1;
7019 fprintf (file, _(" compiler : %.*s\n"),
7024 fprintf (file, _("modend\n"));
7028 struct vms_dst_rtnbeg *dst = (void *)buf;
7029 const char *name = (const char *)buf + sizeof (*dst);
7031 fputs (_("rtnbeg\n"), file);
7032 /* xgettext:c-format */
7033 fprintf (file, _(" flags: %u, address: 0x%08x, "
7034 "pd-address: 0x%08x\n"),
7036 (unsigned)bfd_getl32 (dst->address),
7037 (unsigned)bfd_getl32 (dst->pd_address));
7038 fprintf (file, _(" routine name: %.*s\n"),
7044 struct vms_dst_rtnend *dst = (void *)buf;
7046 fprintf (file, _("rtnend: size 0x%08x\n"),
7047 (unsigned)bfd_getl32 (dst->size));
7052 struct vms_dst_prolog *dst = (void *)buf;
7054 fprintf (file, _("prolog: bkpt address 0x%08x\n"),
7055 (unsigned)bfd_getl32 (dst->bkpt_addr));
7060 struct vms_dst_epilog *dst = (void *)buf;
7062 /* xgettext:c-format */
7063 fprintf (file, _("epilog: flags: %u, count: %u\n"),
7064 dst->flags, (unsigned)bfd_getl32 (dst->count));
7069 struct vms_dst_blkbeg *dst = (void *)buf;
7070 const char *name = (const char *)buf + sizeof (*dst);
7072 /* xgettext:c-format */
7073 fprintf (file, _("blkbeg: address: 0x%08x, name: %.*s\n"),
7074 (unsigned)bfd_getl32 (dst->address),
7080 struct vms_dst_blkend *dst = (void *)buf;
7082 fprintf (file, _("blkend: size: 0x%08x\n"),
7083 (unsigned)bfd_getl32 (dst->size));
7086 case DST__K_TYPSPEC:
7088 fprintf (file, _("typspec (len: %u)\n"), len);
7089 fprintf (file, _(" name: %.*s\n"), buf[0], buf + 1);
7090 evax_bfd_print_typspec (buf + 1 + buf[0], 5, file);
7095 fprintf (file, _("septyp, name: %.*s\n"), buf[5], buf + 6);
7096 evax_bfd_print_valspec (buf, 4, file);
7101 struct vms_dst_recbeg *recbeg = (void *)buf;
7102 const char *name = (const char *)buf + sizeof (*recbeg);
7104 fprintf (file, _("recbeg: name: %.*s\n"), name[0], name + 1);
7105 evax_bfd_print_valspec (buf, 4, file);
7106 fprintf (file, _(" len: %u bits\n"),
7107 (unsigned)bfd_getl32 (name + 1 + name[0]));
7111 fprintf (file, _("recend\n"));
7113 case DST__K_ENUMBEG:
7114 /* xgettext:c-format */
7115 fprintf (file, _("enumbeg, len: %u, name: %.*s\n"),
7116 buf[0], buf[1], buf + 2);
7118 case DST__K_ENUMELT:
7119 fprintf (file, _("enumelt, name: %.*s\n"), buf[5], buf + 6);
7120 evax_bfd_print_valspec (buf, 4, file);
7122 case DST__K_ENUMEND:
7123 fprintf (file, _("enumend\n"));
7127 struct vms_dst_label *lab = (void *)buf;
7128 fprintf (file, _("label, name: %.*s\n"),
7129 lab->name[0], lab->name + 1);
7130 fprintf (file, _(" address: 0x%08x\n"),
7131 (unsigned)bfd_getl32 (lab->value));
7134 case DST__K_DIS_RANGE:
7136 unsigned int cnt = bfd_getl32 (buf);
7137 unsigned char *rng = buf + 4;
7140 fprintf (file, _("discontiguous range (nbr: %u)\n"), cnt);
7141 for (i = 0; i < cnt; i++, rng += 8)
7142 /* xgettext:c-format */
7143 fprintf (file, _(" address: 0x%08x, size: %u\n"),
7144 (unsigned)bfd_getl32 (rng),
7145 (unsigned)bfd_getl32 (rng + 4));
7149 case DST__K_LINE_NUM:
7151 unsigned char *buf_orig = buf;
7153 fprintf (file, _("line num (len: %u)\n"), len);
7158 unsigned char cmdlen;
7168 case DST__K_DELTA_PC_W:
7169 val = bfd_getl16 (buf + 1);
7170 fprintf (file, _("delta_pc_w %u\n"), val);
7175 case DST__K_INCR_LINUM:
7177 fprintf (file, _("incr_linum(b): +%u\n"), val);
7181 case DST__K_INCR_LINUM_W:
7182 val = bfd_getl16 (buf + 1);
7183 fprintf (file, _("incr_linum_w: +%u\n"), val);
7187 case DST__K_INCR_LINUM_L:
7188 val = bfd_getl32 (buf + 1);
7189 fprintf (file, _("incr_linum_l: +%u\n"), val);
7193 case DST__K_SET_LINUM:
7194 line = bfd_getl16 (buf + 1);
7195 fprintf (file, _("set_line_num(w) %u\n"), line);
7198 case DST__K_SET_LINUM_B:
7200 fprintf (file, _("set_line_num_b %u\n"), line);
7203 case DST__K_SET_LINUM_L:
7204 line = bfd_getl32 (buf + 1);
7205 fprintf (file, _("set_line_num_l %u\n"), line);
7208 case DST__K_SET_ABS_PC:
7209 pc = bfd_getl32 (buf + 1);
7210 fprintf (file, _("set_abs_pc: 0x%08x\n"), pc);
7213 case DST__K_DELTA_PC_L:
7214 fprintf (file, _("delta_pc_l: +0x%08x\n"),
7215 (unsigned)bfd_getl32 (buf + 1));
7219 fprintf (file, _("term(b): 0x%02x"), buf[1]);
7221 fprintf (file, _(" pc: 0x%08x\n"), pc);
7225 val = bfd_getl16 (buf + 1);
7226 fprintf (file, _("term_w: 0x%04x"), val);
7228 fprintf (file, _(" pc: 0x%08x\n"), pc);
7234 fprintf (file, _("delta pc +%-4d"), -cmd);
7235 line++; /* FIXME: curr increment. */
7237 /* xgettext:c-format */
7238 fprintf (file, _(" pc: 0x%08x line: %5u\n"),
7243 fprintf (file, _(" *unhandled* cmd %u\n"), cmd);
7256 unsigned char *buf_orig = buf;
7258 fprintf (file, _("source (len: %u)\n"), len);
7262 signed char cmd = buf[0];
7263 unsigned char cmdlen = 0;
7267 case DST__K_SRC_DECLFILE:
7269 struct vms_dst_src_decl_src *src = (void *)(buf + 1);
7272 /* xgettext:c-format */
7273 fprintf (file, _(" declfile: len: %u, flags: %u, "
7275 src->length, src->flags,
7276 (unsigned)bfd_getl16 (src->fileid));
7277 /* xgettext:c-format */
7278 fprintf (file, _(" rms: cdt: 0x%08x %08x, "
7279 "ebk: 0x%08x, ffb: 0x%04x, "
7281 (unsigned)bfd_getl32 (src->rms_cdt + 4),
7282 (unsigned)bfd_getl32 (src->rms_cdt + 0),
7283 (unsigned)bfd_getl32 (src->rms_ebk),
7284 (unsigned)bfd_getl16 (src->rms_ffb),
7286 name = (const char *)buf + 1 + sizeof (*src);
7287 fprintf (file, _(" filename : %.*s\n"),
7289 name += name[0] + 1;
7290 fprintf (file, _(" module name: %.*s\n"),
7292 cmdlen = 2 + src->length;
7295 case DST__K_SRC_SETFILE:
7296 fprintf (file, _(" setfile %u\n"),
7297 (unsigned)bfd_getl16 (buf + 1));
7300 case DST__K_SRC_SETREC_W:
7301 fprintf (file, _(" setrec %u\n"),
7302 (unsigned)bfd_getl16 (buf + 1));
7305 case DST__K_SRC_SETREC_L:
7306 fprintf (file, _(" setrec %u\n"),
7307 (unsigned)bfd_getl32 (buf + 1));
7310 case DST__K_SRC_SETLNUM_W:
7311 fprintf (file, _(" setlnum %u\n"),
7312 (unsigned)bfd_getl16 (buf + 1));
7315 case DST__K_SRC_SETLNUM_L:
7316 fprintf (file, _(" setlnum %u\n"),
7317 (unsigned)bfd_getl32 (buf + 1));
7320 case DST__K_SRC_DEFLINES_W:
7321 fprintf (file, _(" deflines %u\n"),
7322 (unsigned)bfd_getl16 (buf + 1));
7325 case DST__K_SRC_DEFLINES_B:
7326 fprintf (file, _(" deflines %u\n"), buf[1]);
7329 case DST__K_SRC_FORMFEED:
7330 fprintf (file, _(" formfeed\n"));
7334 fprintf (file, _(" *unhandled* cmd %u\n"), cmd);
7346 fprintf (file, _("*unhandled* dst type %u\n"), type);
7354 evax_bfd_print_image (bfd *abfd, FILE *file)
7356 struct vms_eihd eihd;
7359 unsigned int eiha_off;
7360 unsigned int eihi_off;
7361 unsigned int eihs_off;
7362 unsigned int eisd_off;
7363 unsigned int eihef_off = 0;
7364 unsigned int eihnp_off = 0;
7365 unsigned int dmt_vbn = 0;
7366 unsigned int dmt_size = 0;
7367 unsigned int dst_vbn = 0;
7368 unsigned int dst_size = 0;
7369 unsigned int gst_vbn = 0;
7370 unsigned int gst_size = 0;
7371 unsigned int eiaf_vbn = 0;
7372 unsigned int eiaf_size = 0;
7373 unsigned int eihvn_off;
7375 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET)
7376 || bfd_bread (&eihd, sizeof (eihd), abfd) != sizeof (eihd))
7378 fprintf (file, _("cannot read EIHD\n"));
7381 /* xgettext:c-format */
7382 fprintf (file, _("EIHD: (size: %u, nbr blocks: %u)\n"),
7383 (unsigned)bfd_getl32 (eihd.size),
7384 (unsigned)bfd_getl32 (eihd.hdrblkcnt));
7385 /* xgettext:c-format */
7386 fprintf (file, _(" majorid: %u, minorid: %u\n"),
7387 (unsigned)bfd_getl32 (eihd.majorid),
7388 (unsigned)bfd_getl32 (eihd.minorid));
7390 val = (unsigned)bfd_getl32 (eihd.imgtype);
7394 name = _("executable");
7397 name = _("linkable image");
7400 name = _("unknown");
7403 /* xgettext:c-format */
7404 fprintf (file, _(" image type: %u (%s)"), val, name);
7406 val = (unsigned)bfd_getl32 (eihd.subtype);
7409 case EIHD__C_NATIVE:
7416 name = _("unknown");
7419 /* xgettext:c-format */
7420 fprintf (file, _(", subtype: %u (%s)\n"), val, name);
7422 eisd_off = bfd_getl32 (eihd.isdoff);
7423 eiha_off = bfd_getl32 (eihd.activoff);
7424 eihi_off = bfd_getl32 (eihd.imgidoff);
7425 eihs_off = bfd_getl32 (eihd.symdbgoff);
7426 /* xgettext:c-format */
7427 fprintf (file, _(" offsets: isd: %u, activ: %u, symdbg: %u, "
7428 "imgid: %u, patch: %u\n"),
7429 eisd_off, eiha_off, eihs_off, eihi_off,
7430 (unsigned)bfd_getl32 (eihd.patchoff));
7431 fprintf (file, _(" fixup info rva: "));
7432 bfd_fprintf_vma (abfd, file, bfd_getl64 (eihd.iafva));
7433 fprintf (file, _(", symbol vector rva: "));
7434 bfd_fprintf_vma (abfd, file, bfd_getl64 (eihd.symvva));
7435 eihvn_off = bfd_getl32 (eihd.version_array_off);
7436 fprintf (file, _("\n"
7437 " version array off: %u\n"),
7440 /* xgettext:c-format */
7441 _(" img I/O count: %u, nbr channels: %u, req pri: %08x%08x\n"),
7442 (unsigned)bfd_getl32 (eihd.imgiocnt),
7443 (unsigned)bfd_getl32 (eihd.iochancnt),
7444 (unsigned)bfd_getl32 (eihd.privreqs + 4),
7445 (unsigned)bfd_getl32 (eihd.privreqs + 0));
7446 val = (unsigned)bfd_getl32 (eihd.lnkflags);
7447 fprintf (file, _(" linker flags: %08x:"), val);
7448 if (val & EIHD__M_LNKDEBUG)
7449 fprintf (file, " LNKDEBUG");
7450 if (val & EIHD__M_LNKNOTFR)
7451 fprintf (file, " LNKNOTFR");
7452 if (val & EIHD__M_NOP0BUFS)
7453 fprintf (file, " NOP0BUFS");
7454 if (val & EIHD__M_PICIMG)
7455 fprintf (file, " PICIMG");
7456 if (val & EIHD__M_P0IMAGE)
7457 fprintf (file, " P0IMAGE");
7458 if (val & EIHD__M_DBGDMT)
7459 fprintf (file, " DBGDMT");
7460 if (val & EIHD__M_INISHR)
7461 fprintf (file, " INISHR");
7462 if (val & EIHD__M_XLATED)
7463 fprintf (file, " XLATED");
7464 if (val & EIHD__M_BIND_CODE_SEC)
7465 fprintf (file, " BIND_CODE_SEC");
7466 if (val & EIHD__M_BIND_DATA_SEC)
7467 fprintf (file, " BIND_DATA_SEC");
7468 if (val & EIHD__M_MKTHREADS)
7469 fprintf (file, " MKTHREADS");
7470 if (val & EIHD__M_UPCALLS)
7471 fprintf (file, " UPCALLS");
7472 if (val & EIHD__M_OMV_READY)
7473 fprintf (file, " OMV_READY");
7474 if (val & EIHD__M_EXT_BIND_SECT)
7475 fprintf (file, " EXT_BIND_SECT");
7476 fprintf (file, "\n");
7477 /* xgettext:c-format */
7478 fprintf (file, _(" ident: 0x%08x, sysver: 0x%08x, "
7479 "match ctrl: %u, symvect_size: %u\n"),
7480 (unsigned)bfd_getl32 (eihd.ident),
7481 (unsigned)bfd_getl32 (eihd.sysver),
7483 (unsigned)bfd_getl32 (eihd.symvect_size));
7484 fprintf (file, _(" BPAGE: %u"),
7485 (unsigned)bfd_getl32 (eihd.virt_mem_block_size));
7486 if (val & (EIHD__M_OMV_READY | EIHD__M_EXT_BIND_SECT))
7488 eihef_off = bfd_getl32 (eihd.ext_fixup_off);
7489 eihnp_off = bfd_getl32 (eihd.noopt_psect_off);
7490 /* xgettext:c-format */
7491 fprintf (file, _(", ext fixup offset: %u, no_opt psect off: %u"),
7492 eihef_off, eihnp_off);
7494 fprintf (file, _(", alias: %u\n"), (unsigned)bfd_getl16 (eihd.alias));
7498 struct vms_eihvn eihvn;
7502 fprintf (file, _("system version array information:\n"));
7503 if (bfd_seek (abfd, (file_ptr) eihvn_off, SEEK_SET)
7504 || bfd_bread (&eihvn, sizeof (eihvn), abfd) != sizeof (eihvn))
7506 fprintf (file, _("cannot read EIHVN header\n"));
7509 mask = bfd_getl32 (eihvn.subsystem_mask);
7510 for (j = 0; j < 32; j++)
7511 if (mask & (1 << j))
7513 struct vms_eihvn_subversion ver;
7514 if (bfd_bread (&ver, sizeof (ver), abfd) != sizeof (ver))
7516 fprintf (file, _("cannot read EIHVN version\n"));
7519 fprintf (file, _(" %02u "), j);
7522 case EIHVN__BASE_IMAGE_BIT:
7523 fputs (_("BASE_IMAGE "), file);
7525 case EIHVN__MEMORY_MANAGEMENT_BIT:
7526 fputs (_("MEMORY_MANAGEMENT"), file);
7529 fputs (_("IO "), file);
7531 case EIHVN__FILES_VOLUMES_BIT:
7532 fputs (_("FILES_VOLUMES "), file);
7534 case EIHVN__PROCESS_SCHED_BIT:
7535 fputs (_("PROCESS_SCHED "), file);
7537 case EIHVN__SYSGEN_BIT:
7538 fputs (_("SYSGEN "), file);
7540 case EIHVN__CLUSTERS_LOCKMGR_BIT:
7541 fputs (_("CLUSTERS_LOCKMGR "), file);
7543 case EIHVN__LOGICAL_NAMES_BIT:
7544 fputs (_("LOGICAL_NAMES "), file);
7546 case EIHVN__SECURITY_BIT:
7547 fputs (_("SECURITY "), file);
7549 case EIHVN__IMAGE_ACTIVATOR_BIT:
7550 fputs (_("IMAGE_ACTIVATOR "), file);
7552 case EIHVN__NETWORKS_BIT:
7553 fputs (_("NETWORKS "), file);
7555 case EIHVN__COUNTERS_BIT:
7556 fputs (_("COUNTERS "), file);
7558 case EIHVN__STABLE_BIT:
7559 fputs (_("STABLE "), file);
7561 case EIHVN__MISC_BIT:
7562 fputs (_("MISC "), file);
7564 case EIHVN__CPU_BIT:
7565 fputs (_("CPU "), file);
7567 case EIHVN__VOLATILE_BIT:
7568 fputs (_("VOLATILE "), file);
7570 case EIHVN__SHELL_BIT:
7571 fputs (_("SHELL "), file);
7573 case EIHVN__POSIX_BIT:
7574 fputs (_("POSIX "), file);
7576 case EIHVN__MULTI_PROCESSING_BIT:
7577 fputs (_("MULTI_PROCESSING "), file);
7579 case EIHVN__GALAXY_BIT:
7580 fputs (_("GALAXY "), file);
7583 fputs (_("*unknown* "), file);
7586 fprintf (file, ": %u.%u\n",
7587 (unsigned)bfd_getl16 (ver.major),
7588 (unsigned)bfd_getl16 (ver.minor));
7594 struct vms_eiha eiha;
7596 if (bfd_seek (abfd, (file_ptr) eiha_off, SEEK_SET)
7597 || bfd_bread (&eiha, sizeof (eiha), abfd) != sizeof (eiha))
7599 fprintf (file, _("cannot read EIHA\n"));
7602 fprintf (file, _("Image activation: (size=%u)\n"),
7603 (unsigned)bfd_getl32 (eiha.size));
7604 /* xgettext:c-format */
7605 fprintf (file, _(" First address : 0x%08x 0x%08x\n"),
7606 (unsigned)bfd_getl32 (eiha.tfradr1_h),
7607 (unsigned)bfd_getl32 (eiha.tfradr1));
7608 /* xgettext:c-format */
7609 fprintf (file, _(" Second address: 0x%08x 0x%08x\n"),
7610 (unsigned)bfd_getl32 (eiha.tfradr2_h),
7611 (unsigned)bfd_getl32 (eiha.tfradr2));
7612 /* xgettext:c-format */
7613 fprintf (file, _(" Third address : 0x%08x 0x%08x\n"),
7614 (unsigned)bfd_getl32 (eiha.tfradr3_h),
7615 (unsigned)bfd_getl32 (eiha.tfradr3));
7616 /* xgettext:c-format */
7617 fprintf (file, _(" Fourth address: 0x%08x 0x%08x\n"),
7618 (unsigned)bfd_getl32 (eiha.tfradr4_h),
7619 (unsigned)bfd_getl32 (eiha.tfradr4));
7620 /* xgettext:c-format */
7621 fprintf (file, _(" Shared image : 0x%08x 0x%08x\n"),
7622 (unsigned)bfd_getl32 (eiha.inishr_h),
7623 (unsigned)bfd_getl32 (eiha.inishr));
7627 struct vms_eihi eihi;
7629 if (bfd_seek (abfd, (file_ptr) eihi_off, SEEK_SET)
7630 || bfd_bread (&eihi, sizeof (eihi), abfd) != sizeof (eihi))
7632 fprintf (file, _("cannot read EIHI\n"));
7635 /* xgettext:c-format */
7636 fprintf (file, _("Image identification: (major: %u, minor: %u)\n"),
7637 (unsigned)bfd_getl32 (eihi.majorid),
7638 (unsigned)bfd_getl32 (eihi.minorid));
7639 fprintf (file, _(" image name : %.*s\n"),
7640 eihi.imgnam[0], eihi.imgnam + 1);
7641 fprintf (file, _(" link time : %s\n"),
7642 vms_time_to_str (eihi.linktime));
7643 fprintf (file, _(" image ident : %.*s\n"),
7644 eihi.imgid[0], eihi.imgid + 1);
7645 fprintf (file, _(" linker ident : %.*s\n"),
7646 eihi.linkid[0], eihi.linkid + 1);
7647 fprintf (file, _(" image build ident: %.*s\n"),
7648 eihi.imgbid[0], eihi.imgbid + 1);
7652 struct vms_eihs eihs;
7654 if (bfd_seek (abfd, (file_ptr) eihs_off, SEEK_SET)
7655 || bfd_bread (&eihs, sizeof (eihs), abfd) != sizeof (eihs))
7657 fprintf (file, _("cannot read EIHS\n"));
7660 /* xgettext:c-format */
7661 fprintf (file, _("Image symbol & debug table: (major: %u, minor: %u)\n"),
7662 (unsigned)bfd_getl32 (eihs.majorid),
7663 (unsigned)bfd_getl32 (eihs.minorid));
7664 dst_vbn = bfd_getl32 (eihs.dstvbn);
7665 dst_size = bfd_getl32 (eihs.dstsize);
7666 /* xgettext:c-format */
7667 fprintf (file, _(" debug symbol table : vbn: %u, size: %u (0x%x)\n"),
7668 dst_vbn, dst_size, dst_size);
7669 gst_vbn = bfd_getl32 (eihs.gstvbn);
7670 gst_size = bfd_getl32 (eihs.gstsize);
7671 /* xgettext:c-format */
7672 fprintf (file, _(" global symbol table: vbn: %u, records: %u\n"),
7674 dmt_vbn = bfd_getl32 (eihs.dmtvbn);
7675 dmt_size = bfd_getl32 (eihs.dmtsize);
7676 /* xgettext:c-format */
7677 fprintf (file, _(" debug module table : vbn: %u, size: %u\n"),
7680 while (eisd_off != 0)
7682 struct vms_eisd eisd;
7687 if (bfd_seek (abfd, (file_ptr) eisd_off, SEEK_SET)
7688 || bfd_bread (&eisd, sizeof (eisd), abfd) != sizeof (eisd))
7690 fprintf (file, _("cannot read EISD\n"));
7693 len = (unsigned)bfd_getl32 (eisd.eisdsize);
7694 if (len != (unsigned)-1)
7698 eisd_off = (eisd_off + VMS_BLOCK_SIZE) & ~(VMS_BLOCK_SIZE - 1);
7700 /* xgettext:c-format */
7701 fprintf (file, _("Image section descriptor: (major: %u, minor: %u, "
7702 "size: %u, offset: %u)\n"),
7703 (unsigned)bfd_getl32 (eisd.majorid),
7704 (unsigned)bfd_getl32 (eisd.minorid),
7708 /* xgettext:c-format */
7709 fprintf (file, _(" section: base: 0x%08x%08x size: 0x%08x\n"),
7710 (unsigned)bfd_getl32 (eisd.virt_addr + 4),
7711 (unsigned)bfd_getl32 (eisd.virt_addr + 0),
7712 (unsigned)bfd_getl32 (eisd.secsize));
7713 val = (unsigned)bfd_getl32 (eisd.flags);
7714 fprintf (file, _(" flags: 0x%04x"), val);
7715 if (val & EISD__M_GBL)
7716 fprintf (file, " GBL");
7717 if (val & EISD__M_CRF)
7718 fprintf (file, " CRF");
7719 if (val & EISD__M_DZRO)
7720 fprintf (file, " DZRO");
7721 if (val & EISD__M_WRT)
7722 fprintf (file, " WRT");
7723 if (val & EISD__M_INITALCODE)
7724 fprintf (file, " INITALCODE");
7725 if (val & EISD__M_BASED)
7726 fprintf (file, " BASED");
7727 if (val & EISD__M_FIXUPVEC)
7728 fprintf (file, " FIXUPVEC");
7729 if (val & EISD__M_RESIDENT)
7730 fprintf (file, " RESIDENT");
7731 if (val & EISD__M_VECTOR)
7732 fprintf (file, " VECTOR");
7733 if (val & EISD__M_PROTECT)
7734 fprintf (file, " PROTECT");
7735 if (val & EISD__M_LASTCLU)
7736 fprintf (file, " LASTCLU");
7737 if (val & EISD__M_EXE)
7738 fprintf (file, " EXE");
7739 if (val & EISD__M_NONSHRADR)
7740 fprintf (file, " NONSHRADR");
7741 if (val & EISD__M_QUAD_LENGTH)
7742 fprintf (file, " QUAD_LENGTH");
7743 if (val & EISD__M_ALLOC_64BIT)
7744 fprintf (file, " ALLOC_64BIT");
7745 fprintf (file, "\n");
7746 if (val & EISD__M_FIXUPVEC)
7748 eiaf_vbn = bfd_getl32 (eisd.vbn);
7749 eiaf_size = bfd_getl32 (eisd.secsize);
7751 /* xgettext:c-format */
7752 fprintf (file, _(" vbn: %u, pfc: %u, matchctl: %u type: %u ("),
7753 (unsigned)bfd_getl32 (eisd.vbn),
7754 eisd.pfc, eisd.matchctl, eisd.type);
7757 case EISD__K_NORMAL:
7758 fputs (_("NORMAL"), file);
7760 case EISD__K_SHRFXD:
7761 fputs (_("SHRFXD"), file);
7763 case EISD__K_PRVFXD:
7764 fputs (_("PRVFXD"), file);
7766 case EISD__K_SHRPIC:
7767 fputs (_("SHRPIC"), file);
7769 case EISD__K_PRVPIC:
7770 fputs (_("PRVPIC"), file);
7772 case EISD__K_USRSTACK:
7773 fputs (_("USRSTACK"), file);
7776 fputs (_("*unknown*"), file);
7779 fputs (_(")\n"), file);
7780 if (val & EISD__M_GBL)
7781 /* xgettext:c-format */
7782 fprintf (file, _(" ident: 0x%08x, name: %.*s\n"),
7783 (unsigned)bfd_getl32 (eisd.ident),
7784 eisd.gblnam[0], eisd.gblnam + 1);
7790 if (bfd_seek (abfd, (file_ptr) (dmt_vbn - 1) * VMS_BLOCK_SIZE, SEEK_SET))
7792 fprintf (file, _("cannot read DMT\n"));
7796 fprintf (file, _("Debug module table:\n"));
7798 while (dmt_size > 0)
7800 struct vms_dmt_header dmth;
7803 if (bfd_bread (&dmth, sizeof (dmth), abfd) != sizeof (dmth))
7805 fprintf (file, _("cannot read DMT header\n"));
7808 count = bfd_getl16 (dmth.psect_count);
7810 /* xgettext:c-format */
7811 _(" module offset: 0x%08x, size: 0x%08x, (%u psects)\n"),
7812 (unsigned)bfd_getl32 (dmth.modbeg),
7813 (unsigned)bfd_getl32 (dmth.size), count);
7814 dmt_size -= sizeof (dmth);
7817 struct vms_dmt_psect dmtp;
7819 if (bfd_bread (&dmtp, sizeof (dmtp), abfd) != sizeof (dmtp))
7821 fprintf (file, _("cannot read DMT psect\n"));
7824 /* xgettext:c-format */
7825 fprintf (file, _(" psect start: 0x%08x, length: %u\n"),
7826 (unsigned)bfd_getl32 (dmtp.start),
7827 (unsigned)bfd_getl32 (dmtp.length));
7829 dmt_size -= sizeof (dmtp);
7836 if (bfd_seek (abfd, (file_ptr) (dst_vbn - 1) * VMS_BLOCK_SIZE, SEEK_SET))
7838 fprintf (file, _("cannot read DST\n"));
7842 evax_bfd_print_dst (abfd, dst_size, file);
7846 if (bfd_seek (abfd, (file_ptr) (gst_vbn - 1) * VMS_BLOCK_SIZE, SEEK_SET))
7848 fprintf (file, _("cannot read GST\n"));
7852 fprintf (file, _("Global symbol table:\n"));
7853 evax_bfd_print_eobj (abfd, file);
7858 struct vms_eiaf *eiaf;
7859 unsigned int qrelfixoff;
7860 unsigned int lrelfixoff;
7861 unsigned int qdotadroff;
7862 unsigned int ldotadroff;
7863 unsigned int shrimgcnt;
7864 unsigned int shlstoff;
7865 unsigned int codeadroff;
7866 unsigned int lpfixoff;
7867 unsigned int chgprtoff;
7869 buf = bfd_malloc (eiaf_size);
7871 if (bfd_seek (abfd, (file_ptr) (eiaf_vbn - 1) * VMS_BLOCK_SIZE, SEEK_SET)
7872 || bfd_bread (buf, eiaf_size, abfd) != eiaf_size)
7874 fprintf (file, _("cannot read EIHA\n"));
7878 eiaf = (struct vms_eiaf *)buf;
7880 /* xgettext:c-format */
7881 _("Image activator fixup: (major: %u, minor: %u)\n"),
7882 (unsigned)bfd_getl32 (eiaf->majorid),
7883 (unsigned)bfd_getl32 (eiaf->minorid));
7884 /* xgettext:c-format */
7885 fprintf (file, _(" iaflink : 0x%08x %08x\n"),
7886 (unsigned)bfd_getl32 (eiaf->iaflink + 0),
7887 (unsigned)bfd_getl32 (eiaf->iaflink + 4));
7888 /* xgettext:c-format */
7889 fprintf (file, _(" fixuplnk: 0x%08x %08x\n"),
7890 (unsigned)bfd_getl32 (eiaf->fixuplnk + 0),
7891 (unsigned)bfd_getl32 (eiaf->fixuplnk + 4));
7892 fprintf (file, _(" size : %u\n"),
7893 (unsigned)bfd_getl32 (eiaf->size));
7894 fprintf (file, _(" flags: 0x%08x\n"),
7895 (unsigned)bfd_getl32 (eiaf->flags));
7896 qrelfixoff = bfd_getl32 (eiaf->qrelfixoff);
7897 lrelfixoff = bfd_getl32 (eiaf->lrelfixoff);
7898 /* xgettext:c-format */
7899 fprintf (file, _(" qrelfixoff: %5u, lrelfixoff: %5u\n"),
7900 qrelfixoff, lrelfixoff);
7901 qdotadroff = bfd_getl32 (eiaf->qdotadroff);
7902 ldotadroff = bfd_getl32 (eiaf->ldotadroff);
7903 /* xgettext:c-format */
7904 fprintf (file, _(" qdotadroff: %5u, ldotadroff: %5u\n"),
7905 qdotadroff, ldotadroff);
7906 codeadroff = bfd_getl32 (eiaf->codeadroff);
7907 lpfixoff = bfd_getl32 (eiaf->lpfixoff);
7908 /* xgettext:c-format */
7909 fprintf (file, _(" codeadroff: %5u, lpfixoff : %5u\n"),
7910 codeadroff, lpfixoff);
7911 chgprtoff = bfd_getl32 (eiaf->chgprtoff);
7912 fprintf (file, _(" chgprtoff : %5u\n"), chgprtoff);
7913 shrimgcnt = bfd_getl32 (eiaf->shrimgcnt);
7914 shlstoff = bfd_getl32 (eiaf->shlstoff);
7915 /* xgettext:c-format */
7916 fprintf (file, _(" shlstoff : %5u, shrimgcnt : %5u\n"),
7917 shlstoff, shrimgcnt);
7918 /* xgettext:c-format */
7919 fprintf (file, _(" shlextra : %5u, permctx : %5u\n"),
7920 (unsigned)bfd_getl32 (eiaf->shlextra),
7921 (unsigned)bfd_getl32 (eiaf->permctx));
7922 fprintf (file, _(" base_va : 0x%08x\n"),
7923 (unsigned)bfd_getl32 (eiaf->base_va));
7924 fprintf (file, _(" lppsbfixoff: %5u\n"),
7925 (unsigned)bfd_getl32 (eiaf->lppsbfixoff));
7929 struct vms_shl *shl = (struct vms_shl *)(buf + shlstoff);
7932 fprintf (file, _(" Shareable images:\n"));
7933 for (j = 0; j < shrimgcnt; j++, shl++)
7936 /* xgettext:c-format */
7937 _(" %u: size: %u, flags: 0x%02x, name: %.*s\n"),
7938 j, shl->size, shl->flags,
7939 shl->imgnam[0], shl->imgnam + 1);
7942 if (qrelfixoff != 0)
7944 fprintf (file, _(" quad-word relocation fixups:\n"));
7945 evax_bfd_print_relocation_records (file, buf + qrelfixoff, 8);
7947 if (lrelfixoff != 0)
7949 fprintf (file, _(" long-word relocation fixups:\n"));
7950 evax_bfd_print_relocation_records (file, buf + lrelfixoff, 4);
7952 if (qdotadroff != 0)
7954 fprintf (file, _(" quad-word .address reference fixups:\n"));
7955 evax_bfd_print_address_fixups (file, buf + qdotadroff);
7957 if (ldotadroff != 0)
7959 fprintf (file, _(" long-word .address reference fixups:\n"));
7960 evax_bfd_print_address_fixups (file, buf + ldotadroff);
7962 if (codeadroff != 0)
7964 fprintf (file, _(" Code Address Reference Fixups:\n"));
7965 evax_bfd_print_reference_fixups (file, buf + codeadroff);
7969 fprintf (file, _(" Linkage Pairs Reference Fixups:\n"));
7970 evax_bfd_print_reference_fixups (file, buf + lpfixoff);
7974 unsigned int count = (unsigned)bfd_getl32 (buf + chgprtoff);
7975 struct vms_eicp *eicp = (struct vms_eicp *)(buf + chgprtoff + 4);
7978 fprintf (file, _(" Change Protection (%u entries):\n"), count);
7979 for (j = 0; j < count; j++, eicp++)
7981 unsigned int prot = bfd_getl32 (eicp->newprt);
7983 /* xgettext:c-format */
7984 _(" base: 0x%08x %08x, size: 0x%08x, prot: 0x%08x "),
7985 (unsigned)bfd_getl32 (eicp->baseva + 4),
7986 (unsigned)bfd_getl32 (eicp->baseva + 0),
7987 (unsigned)bfd_getl32 (eicp->size),
7988 (unsigned)bfd_getl32 (eicp->newprt));
7992 fprintf (file, "NA");
7994 case PRT__C_RESERVED:
7995 fprintf (file, "RES");
7998 fprintf (file, "KW");
8001 fprintf (file, "KR");
8004 fprintf (file, "UW");
8007 fprintf (file, "EW");
8010 fprintf (file, "ERKW");
8013 fprintf (file, "ER");
8016 fprintf (file, "SW");
8019 fprintf (file, "SREW");
8022 fprintf (file, "SRKW");
8025 fprintf (file, "SR");
8028 fprintf (file, "URSW");
8031 fprintf (file, "UREW");
8034 fprintf (file, "URKW");
8037 fprintf (file, "UR");
8051 vms_bfd_print_private_bfd_data (bfd *abfd, void *ptr)
8053 FILE *file = (FILE *)ptr;
8055 if (bfd_get_file_flags (abfd) & (EXEC_P | DYNAMIC))
8056 evax_bfd_print_image (abfd, file);
8059 if (bfd_seek (abfd, 0, SEEK_SET))
8061 evax_bfd_print_eobj (abfd, file);
8068 /* Slurp ETIR/EDBG/ETBT VMS object records. */
8071 alpha_vms_read_sections_content (bfd *abfd, struct bfd_link_info *info)
8073 asection *cur_section;
8074 file_ptr cur_offset;
8075 asection *dst_section;
8076 file_ptr dst_offset;
8078 if (bfd_seek (abfd, 0, SEEK_SET) != 0)
8084 dst_section = PRIV (dst_section);
8088 if (info->strip == strip_all || info->strip == strip_debugger)
8090 /* Discard the DST section. */
8094 else if (dst_section)
8096 dst_offset = dst_section->output_offset;
8097 dst_section = dst_section->output_section;
8106 type = _bfd_vms_get_object_record (abfd);
8109 vms_debug2 ((2, "next_record failed\n"));
8115 PRIV (image_section) = cur_section;
8116 PRIV (image_offset) = cur_offset;
8117 res = _bfd_vms_slurp_etir (abfd, info);
8118 cur_section = PRIV (image_section);
8119 cur_offset = PRIV (image_offset);
8123 if (dst_section == NULL)
8125 PRIV (image_section) = dst_section;
8126 PRIV (image_offset) = dst_offset;
8127 res = _bfd_vms_slurp_etir (abfd, info);
8128 dst_offset = PRIV (image_offset);
8137 vms_debug2 ((2, "slurp eobj type %d failed\n", type));
8144 alpha_vms_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
8145 struct bfd_link_info *info ATTRIBUTE_UNUSED)
8150 /* Add a linkage pair fixup at address SECT + OFFSET to SHLIB. */
8153 alpha_vms_add_fixup_lp (struct bfd_link_info *info, bfd *src, bfd *shlib)
8155 struct alpha_vms_shlib_el *sl;
8156 asection *sect = PRIV2 (src, image_section);
8157 file_ptr offset = PRIV2 (src, image_offset);
8159 sl = &VEC_EL (alpha_vms_link_hash (info)->shrlibs,
8160 struct alpha_vms_shlib_el, PRIV2 (shlib, shr_index));
8161 sl->has_fixups = TRUE;
8162 VEC_APPEND_EL (sl->lp, bfd_vma,
8163 sect->output_section->vma + sect->output_offset + offset);
8164 sect->output_section->flags |= SEC_RELOC;
8167 /* Add a code address fixup at address SECT + OFFSET to SHLIB. */
8170 alpha_vms_add_fixup_ca (struct bfd_link_info *info, bfd *src, bfd *shlib)
8172 struct alpha_vms_shlib_el *sl;
8173 asection *sect = PRIV2 (src, image_section);
8174 file_ptr offset = PRIV2 (src, image_offset);
8176 sl = &VEC_EL (alpha_vms_link_hash (info)->shrlibs,
8177 struct alpha_vms_shlib_el, PRIV2 (shlib, shr_index));
8178 sl->has_fixups = TRUE;
8179 VEC_APPEND_EL (sl->ca, bfd_vma,
8180 sect->output_section->vma + sect->output_offset + offset);
8181 sect->output_section->flags |= SEC_RELOC;
8184 /* Add a quad word relocation fixup at address SECT + OFFSET to SHLIB. */
8187 alpha_vms_add_fixup_qr (struct bfd_link_info *info, bfd *src,
8188 bfd *shlib, bfd_vma vec)
8190 struct alpha_vms_shlib_el *sl;
8191 struct alpha_vms_vma_ref *r;
8192 asection *sect = PRIV2 (src, image_section);
8193 file_ptr offset = PRIV2 (src, image_offset);
8195 sl = &VEC_EL (alpha_vms_link_hash (info)->shrlibs,
8196 struct alpha_vms_shlib_el, PRIV2 (shlib, shr_index));
8197 sl->has_fixups = TRUE;
8198 r = VEC_APPEND (sl->qr, struct alpha_vms_vma_ref);
8199 r->vma = sect->output_section->vma + sect->output_offset + offset;
8201 sect->output_section->flags |= SEC_RELOC;
8205 alpha_vms_add_fixup_lr (struct bfd_link_info *info ATTRIBUTE_UNUSED,
8206 unsigned int shr ATTRIBUTE_UNUSED,
8207 bfd_vma vec ATTRIBUTE_UNUSED)
8209 /* Not yet supported. */
8213 /* Add relocation. FIXME: Not yet emitted. */
8216 alpha_vms_add_lw_reloc (struct bfd_link_info *info ATTRIBUTE_UNUSED)
8221 alpha_vms_add_qw_reloc (struct bfd_link_info *info ATTRIBUTE_UNUSED)
8225 static struct bfd_hash_entry *
8226 alpha_vms_link_hash_newfunc (struct bfd_hash_entry *entry,
8227 struct bfd_hash_table *table,
8230 struct alpha_vms_link_hash_entry *ret =
8231 (struct alpha_vms_link_hash_entry *) entry;
8233 /* Allocate the structure if it has not already been allocated by a
8236 ret = ((struct alpha_vms_link_hash_entry *)
8237 bfd_hash_allocate (table,
8238 sizeof (struct alpha_vms_link_hash_entry)));
8242 /* Call the allocation method of the superclass. */
8243 ret = ((struct alpha_vms_link_hash_entry *)
8244 _bfd_link_hash_newfunc ((struct bfd_hash_entry *) ret,
8249 return (struct bfd_hash_entry *) ret;
8252 /* Create an Alpha/VMS link hash table. */
8254 static struct bfd_link_hash_table *
8255 alpha_vms_bfd_link_hash_table_create (bfd *abfd)
8257 struct alpha_vms_link_hash_table *ret;
8258 bfd_size_type amt = sizeof (struct alpha_vms_link_hash_table);
8260 ret = (struct alpha_vms_link_hash_table *) bfd_malloc (amt);
8263 if (!_bfd_link_hash_table_init (&ret->root, abfd,
8264 alpha_vms_link_hash_newfunc,
8265 sizeof (struct alpha_vms_link_hash_entry)))
8271 VEC_INIT (ret->shrlibs);
8278 alpha_vms_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
8282 for (i = 0; i < PRIV (gsd_sym_count); i++)
8284 struct vms_symbol_entry *e = PRIV (syms)[i];
8285 struct alpha_vms_link_hash_entry *h;
8286 struct bfd_link_hash_entry *h_root;
8289 if (!alpha_vms_convert_symbol (abfd, e, &sym))
8292 if ((e->flags & EGSY__V_DEF) && abfd->selective_search)
8294 /* In selective_search mode, only add definition that are
8296 h = (struct alpha_vms_link_hash_entry *)bfd_link_hash_lookup
8297 (info->hash, sym.name, FALSE, FALSE, FALSE);
8298 if (h == NULL || h->root.type != bfd_link_hash_undefined)
8304 h_root = (struct bfd_link_hash_entry *) h;
8305 if (!_bfd_generic_link_add_one_symbol (info, abfd, sym.name, sym.flags,
8306 sym.section, sym.value, NULL,
8307 FALSE, FALSE, &h_root))
8309 h = (struct alpha_vms_link_hash_entry *) h_root;
8311 if ((e->flags & EGSY__V_DEF)
8313 && abfd->xvec == info->output_bfd->xvec)
8317 if (abfd->flags & DYNAMIC)
8319 struct alpha_vms_shlib_el *shlib;
8321 /* We do not want to include any of the sections in a dynamic
8322 object in the output file. See comment in elflink.c. */
8323 bfd_section_list_clear (abfd);
8325 shlib = VEC_APPEND (alpha_vms_link_hash (info)->shrlibs,
8326 struct alpha_vms_shlib_el);
8328 VEC_INIT (shlib->ca);
8329 VEC_INIT (shlib->lp);
8330 VEC_INIT (shlib->qr);
8331 PRIV (shr_index) = VEC_COUNT (alpha_vms_link_hash (info)->shrlibs) - 1;
8338 alpha_vms_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info)
8341 struct bfd_link_hash_entry **pundef;
8342 struct bfd_link_hash_entry **next_pundef;
8344 /* We only accept VMS libraries. */
8345 if (info->output_bfd->xvec != abfd->xvec)
8347 bfd_set_error (bfd_error_wrong_format);
8351 /* The archive_pass field in the archive itself is used to
8352 initialize PASS, since we may search the same archive multiple
8354 pass = ++abfd->archive_pass;
8356 /* Look through the list of undefined symbols. */
8357 for (pundef = &info->hash->undefs; *pundef != NULL; pundef = next_pundef)
8359 struct bfd_link_hash_entry *h;
8365 next_pundef = &(*pundef)->u.undef.next;
8367 /* When a symbol is defined, it is not necessarily removed from
8369 if (h->type != bfd_link_hash_undefined
8370 && h->type != bfd_link_hash_common)
8372 /* Remove this entry from the list, for general cleanliness
8373 and because we are going to look through the list again
8374 if we search any more libraries. We can't remove the
8375 entry if it is the tail, because that would lose any
8376 entries we add to the list later on. */
8377 if (*pundef != info->hash->undefs_tail)
8379 *pundef = *next_pundef;
8380 next_pundef = pundef;
8385 /* Look for this symbol in the archive hash table. */
8386 symidx = _bfd_vms_lib_find_symbol (abfd, h->root.string);
8387 if (symidx == BFD_NO_MORE_SYMBOLS)
8389 /* Nothing in this slot. */
8393 element = bfd_get_elt_at_index (abfd, symidx);
8394 if (element == NULL)
8397 if (element->archive_pass == -1 || element->archive_pass == pass)
8399 /* Next symbol if this archive is wrong or already handled. */
8403 if (! bfd_check_format (element, bfd_object))
8405 element->archive_pass = -1;
8409 orig_element = element;
8410 if (bfd_is_thin_archive (abfd))
8412 element = _bfd_vms_lib_get_imagelib_file (element);
8413 if (element == NULL || !bfd_check_format (element, bfd_object))
8415 orig_element->archive_pass = -1;
8420 /* Unlike the generic linker, we know that this element provides
8421 a definition for an undefined symbol and we know that we want
8422 to include it. We don't need to check anything. */
8423 if (!(*info->callbacks
8424 ->add_archive_element) (info, element, h->root.string, &element))
8426 if (!alpha_vms_link_add_object_symbols (element, info))
8429 orig_element->archive_pass = pass;
8436 alpha_vms_bfd_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
8438 switch (bfd_get_format (abfd))
8441 vms_debug2 ((2, "vms_link_add_symbols for object %s\n",
8443 return alpha_vms_link_add_object_symbols (abfd, info);
8446 vms_debug2 ((2, "vms_link_add_symbols for archive %s\n",
8448 return alpha_vms_link_add_archive_symbols (abfd, info);
8451 bfd_set_error (bfd_error_wrong_format);
8457 alpha_vms_build_fixups (struct bfd_link_info *info)
8459 struct alpha_vms_link_hash_table *t = alpha_vms_link_hash (info);
8460 unsigned char *content;
8462 unsigned int sz = 0;
8463 unsigned int lp_sz = 0;
8464 unsigned int ca_sz = 0;
8465 unsigned int qr_sz = 0;
8466 unsigned int shrimg_cnt = 0;
8467 unsigned int chgprt_num = 0;
8468 unsigned int chgprt_sz = 0;
8469 struct vms_eiaf *eiaf;
8473 /* Shared libraries. */
8474 for (i = 0; i < VEC_COUNT (t->shrlibs); i++)
8476 struct alpha_vms_shlib_el *shlib;
8478 shlib = &VEC_EL (t->shrlibs, struct alpha_vms_shlib_el, i);
8480 if (!shlib->has_fixups)
8485 if (VEC_COUNT (shlib->ca) > 0)
8487 /* Header + entries. */
8489 ca_sz += VEC_COUNT (shlib->ca) * 4;
8491 if (VEC_COUNT (shlib->lp) > 0)
8493 /* Header + entries. */
8495 lp_sz += VEC_COUNT (shlib->lp) * 4;
8497 if (VEC_COUNT (shlib->qr) > 0)
8499 /* Header + entries. */
8501 qr_sz += VEC_COUNT (shlib->qr) * 8;
8512 /* Finish now if there is no content. */
8513 if (ca_sz + lp_sz + qr_sz == 0)
8516 /* Add an eicp entry for the fixup itself. */
8518 for (sec = info->output_bfd->sections; sec != NULL; sec = sec->next)
8520 /* This isect could be made RO or EXE after relocations are applied. */
8521 if ((sec->flags & SEC_RELOC) != 0
8522 && (sec->flags & (SEC_CODE | SEC_READONLY)) != 0)
8525 chgprt_sz = 4 + chgprt_num * sizeof (struct vms_eicp);
8527 /* Allocate section content (round-up size) */
8528 sz = sizeof (struct vms_eiaf) + shrimg_cnt * sizeof (struct vms_shl)
8529 + ca_sz + lp_sz + qr_sz + chgprt_sz;
8530 sz = (sz + VMS_BLOCK_SIZE - 1) & ~(VMS_BLOCK_SIZE - 1);
8531 content = bfd_zalloc (info->output_bfd, sz);
8532 if (content == NULL)
8535 sec = alpha_vms_link_hash (info)->fixup;
8536 sec->contents = content;
8539 eiaf = (struct vms_eiaf *)content;
8540 off = sizeof (struct vms_eiaf);
8541 bfd_putl32 (0, eiaf->majorid);
8542 bfd_putl32 (0, eiaf->minorid);
8543 bfd_putl32 (0, eiaf->iaflink);
8544 bfd_putl32 (0, eiaf->fixuplnk);
8545 bfd_putl32 (sizeof (struct vms_eiaf), eiaf->size);
8546 bfd_putl32 (0, eiaf->flags);
8547 bfd_putl32 (0, eiaf->qrelfixoff);
8548 bfd_putl32 (0, eiaf->lrelfixoff);
8549 bfd_putl32 (0, eiaf->qdotadroff);
8550 bfd_putl32 (0, eiaf->ldotadroff);
8551 bfd_putl32 (0, eiaf->codeadroff);
8552 bfd_putl32 (0, eiaf->lpfixoff);
8553 bfd_putl32 (0, eiaf->chgprtoff);
8554 bfd_putl32 (shrimg_cnt ? off : 0, eiaf->shlstoff);
8555 bfd_putl32 (shrimg_cnt, eiaf->shrimgcnt);
8556 bfd_putl32 (0, eiaf->shlextra);
8557 bfd_putl32 (0, eiaf->permctx);
8558 bfd_putl32 (0, eiaf->base_va);
8559 bfd_putl32 (0, eiaf->lppsbfixoff);
8566 for (i = 0; i < VEC_COUNT (t->shrlibs); i++)
8568 struct alpha_vms_shlib_el *shlib;
8569 struct vms_shl *shl;
8571 shlib = &VEC_EL (t->shrlibs, struct alpha_vms_shlib_el, i);
8573 if (!shlib->has_fixups)
8576 /* Renumber shared images. */
8577 PRIV2 (shlib->abfd, shr_index) = shrimg_cnt++;
8579 shl = (struct vms_shl *)(content + off);
8580 bfd_putl32 (0, shl->baseva);
8581 bfd_putl32 (0, shl->shlptr);
8582 bfd_putl32 (0, shl->ident);
8583 bfd_putl32 (0, shl->permctx);
8584 shl->size = sizeof (struct vms_shl);
8585 bfd_putl16 (0, shl->fill_1);
8587 bfd_putl32 (0, shl->icb);
8588 shl->imgnam[0] = strlen (PRIV2 (shlib->abfd, hdr_data.hdr_t_name));
8589 memcpy (shl->imgnam + 1, PRIV2 (shlib->abfd, hdr_data.hdr_t_name),
8592 off += sizeof (struct vms_shl);
8598 bfd_putl32 (off, eiaf->codeadroff);
8600 for (i = 0; i < VEC_COUNT (t->shrlibs); i++)
8602 struct alpha_vms_shlib_el *shlib;
8605 shlib = &VEC_EL (t->shrlibs, struct alpha_vms_shlib_el, i);
8607 if (VEC_COUNT (shlib->ca) == 0)
8610 bfd_putl32 (VEC_COUNT (shlib->ca), content + off);
8611 bfd_putl32 (PRIV2 (shlib->abfd, shr_index), content + off + 4);
8614 for (j = 0; j < VEC_COUNT (shlib->ca); j++)
8616 bfd_putl32 (VEC_EL (shlib->ca, bfd_vma, j) - t->base_addr,
8622 bfd_putl32 (0, content + off);
8623 bfd_putl32 (0, content + off + 4);
8630 bfd_putl32 (off, eiaf->lpfixoff);
8632 for (i = 0; i < VEC_COUNT (t->shrlibs); i++)
8634 struct alpha_vms_shlib_el *shlib;
8637 shlib = &VEC_EL (t->shrlibs, struct alpha_vms_shlib_el, i);
8639 if (VEC_COUNT (shlib->lp) == 0)
8642 bfd_putl32 (VEC_COUNT (shlib->lp), content + off);
8643 bfd_putl32 (PRIV2 (shlib->abfd, shr_index), content + off + 4);
8646 for (j = 0; j < VEC_COUNT (shlib->lp); j++)
8648 bfd_putl32 (VEC_EL (shlib->lp, bfd_vma, j) - t->base_addr,
8654 bfd_putl32 (0, content + off);
8655 bfd_putl32 (0, content + off + 4);
8662 bfd_putl32 (off, eiaf->qdotadroff);
8664 for (i = 0; i < VEC_COUNT (t->shrlibs); i++)
8666 struct alpha_vms_shlib_el *shlib;
8669 shlib = &VEC_EL (t->shrlibs, struct alpha_vms_shlib_el, i);
8671 if (VEC_COUNT (shlib->qr) == 0)
8674 bfd_putl32 (VEC_COUNT (shlib->qr), content + off);
8675 bfd_putl32 (PRIV2 (shlib->abfd, shr_index), content + off + 4);
8678 for (j = 0; j < VEC_COUNT (shlib->qr); j++)
8680 struct alpha_vms_vma_ref *r;
8681 r = &VEC_EL (shlib->qr, struct alpha_vms_vma_ref, j);
8682 bfd_putl32 (r->vma - t->base_addr, content + off);
8683 bfd_putl32 (r->ref, content + off + 4);
8688 bfd_putl32 (0, content + off);
8689 bfd_putl32 (0, content + off + 4);
8694 /* Write the change protection table. */
8695 bfd_putl32 (off, eiaf->chgprtoff);
8696 bfd_putl32 (chgprt_num, content + off);
8699 for (sec = info->output_bfd->sections; sec != NULL; sec = sec->next)
8701 struct vms_eicp *eicp;
8704 if ((sec->flags & SEC_LINKER_CREATED) != 0 &&
8705 strcmp (sec->name, "$FIXUP$") == 0)
8707 else if ((sec->flags & SEC_RELOC) != 0
8708 && (sec->flags & (SEC_CODE | SEC_READONLY)) != 0)
8713 eicp = (struct vms_eicp *)(content + off);
8714 bfd_putl64 (sec->vma - t->base_addr, eicp->baseva);
8715 bfd_putl32 ((sec->size + VMS_BLOCK_SIZE - 1) & ~(VMS_BLOCK_SIZE - 1),
8717 bfd_putl32 (prot, eicp->newprt);
8718 off += sizeof (struct vms_eicp);
8724 /* Called by bfd_hash_traverse to fill the symbol table.
8725 Return FALSE in case of failure. */
8728 alpha_vms_link_output_symbol (struct bfd_hash_entry *bh, void *infov)
8730 struct bfd_link_hash_entry *hc = (struct bfd_link_hash_entry *) bh;
8731 struct bfd_link_info *info = (struct bfd_link_info *)infov;
8732 struct alpha_vms_link_hash_entry *h;
8733 struct vms_symbol_entry *sym;
8735 if (hc->type == bfd_link_hash_warning)
8738 if (hc->type == bfd_link_hash_new)
8741 h = (struct alpha_vms_link_hash_entry *) hc;
8743 switch (h->root.type)
8745 case bfd_link_hash_undefined:
8747 case bfd_link_hash_new:
8748 case bfd_link_hash_warning:
8750 case bfd_link_hash_undefweak:
8752 case bfd_link_hash_defined:
8753 case bfd_link_hash_defweak:
8755 asection *sec = h->root.u.def.section;
8757 /* FIXME: this is certainly a symbol from a dynamic library. */
8758 if (bfd_is_abs_section (sec))
8761 if (sec->owner->flags & DYNAMIC)
8765 case bfd_link_hash_common:
8767 case bfd_link_hash_indirect:
8771 /* Do not write not kept symbols. */
8772 if (info->strip == strip_some
8773 && bfd_hash_lookup (info->keep_hash, h->root.root.string,
8774 FALSE, FALSE) != NULL)
8779 /* This symbol doesn't come from a VMS object. So we suppose it is
8781 int len = strlen (h->root.root.string);
8783 sym = (struct vms_symbol_entry *)bfd_zalloc (info->output_bfd,
8784 sizeof (*sym) + len);
8788 memcpy (sym->name, h->root.root.string, len);
8790 sym->owner = info->output_bfd;
8792 sym->typ = EGSD__C_SYMG;
8794 sym->flags = EGSY__V_DEF | EGSY__V_REL;
8795 sym->symbol_vector = h->root.u.def.value;
8796 sym->section = h->root.u.def.section;
8797 sym->value = h->root.u.def.value;
8802 if (!add_symbol_entry (info->output_bfd, sym))
8809 alpha_vms_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
8812 struct bfd_link_order *p;
8820 if (bfd_link_relocatable (info))
8822 /* FIXME: we do not yet support relocatable link. It is not obvious
8823 how to do it for debug infos. */
8824 (*info->callbacks->einfo)(_("%P: relocatable link is not supported\n"));
8828 bfd_get_outsymbols (abfd) = NULL;
8829 bfd_get_symcount (abfd) = 0;
8831 /* Mark all sections which will be included in the output file. */
8832 for (o = abfd->sections; o != NULL; o = o->next)
8833 for (p = o->map_head.link_order; p != NULL; p = p->next)
8834 if (p->type == bfd_indirect_link_order)
8835 p->u.indirect.section->linker_mark = TRUE;
8838 /* Handle all the link order information for the sections. */
8839 for (o = abfd->sections; o != NULL; o = o->next)
8841 printf ("For section %s (at 0x%08x, flags=0x%08x):\n",
8842 o->name, (unsigned)o->vma, (unsigned)o->flags);
8844 for (p = o->map_head.link_order; p != NULL; p = p->next)
8846 printf (" at 0x%08x - 0x%08x: ",
8847 (unsigned)p->offset, (unsigned)(p->offset + p->size - 1));
8850 case bfd_section_reloc_link_order:
8851 case bfd_symbol_reloc_link_order:
8852 printf (" section/symbol reloc\n");
8854 case bfd_indirect_link_order:
8855 printf (" section %s of %s\n",
8856 p->u.indirect.section->name,
8857 p->u.indirect.section->owner->filename);
8859 case bfd_data_link_order:
8860 printf (" explicit data\n");
8863 printf (" *unknown* type %u\n", p->type);
8870 /* Generate the symbol table. */
8871 BFD_ASSERT (PRIV (syms) == NULL);
8872 if (info->strip != strip_all)
8873 bfd_hash_traverse (&info->hash->table, alpha_vms_link_output_symbol, info);
8875 /* Find the entry point. */
8876 if (bfd_get_start_address (abfd) == 0)
8878 bfd *startbfd = NULL;
8880 for (sub = info->input_bfds; sub != NULL; sub = sub->link.next)
8882 /* Consider only VMS object files. */
8883 if (sub->xvec != abfd->xvec)
8886 if (!PRIV2 (sub, eom_data).eom_has_transfer)
8888 if ((PRIV2 (sub, eom_data).eom_b_tfrflg & EEOM__M_WKTFR) && startbfd)
8890 if (startbfd != NULL
8891 && !(PRIV2 (sub, eom_data).eom_b_tfrflg & EEOM__M_WKTFR))
8893 (*info->callbacks->einfo)
8894 /* xgettext:c-format */
8895 (_("%P: multiple entry points: in modules %B and %B\n"),
8904 unsigned int ps_idx = PRIV2 (startbfd, eom_data).eom_l_psindx;
8905 bfd_vma tfradr = PRIV2 (startbfd, eom_data).eom_l_tfradr;
8908 sec = PRIV2 (startbfd, sections)[ps_idx];
8910 bfd_set_start_address
8911 (abfd, sec->output_section->vma + sec->output_offset + tfradr);
8915 /* Set transfer addresses. */
8918 struct bfd_link_hash_entry *h;
8921 PRIV (transfer_address[i++]) = 0xffffffff00000340ULL; /* SYS$IMGACT */
8922 h = bfd_link_hash_lookup (info->hash, "LIB$INITIALIZE", FALSE, FALSE, TRUE);
8923 if (h != NULL && h->type == bfd_link_hash_defined)
8924 PRIV (transfer_address[i++]) =
8925 alpha_vms_get_sym_value (h->u.def.section, h->u.def.value);
8926 PRIV (transfer_address[i++]) = bfd_get_start_address (abfd);
8928 PRIV (transfer_address[i++]) = 0;
8931 /* Allocate contents.
8932 Also compute the virtual base address. */
8933 base_addr = (bfd_vma)-1;
8935 for (o = abfd->sections; o != NULL; o = o->next)
8937 if (o->flags & SEC_HAS_CONTENTS)
8939 o->contents = bfd_alloc (abfd, o->size);
8940 if (o->contents == NULL)
8943 if (o->flags & SEC_LOAD)
8945 if (o->vma < base_addr)
8947 if (o->vma + o->size > last_addr)
8948 last_addr = o->vma + o->size;
8950 /* Clear the RELOC flags. Currently we don't support incremental
8951 linking. We use the RELOC flag for computing the eicp entries. */
8952 o->flags &= ~SEC_RELOC;
8955 /* Create the fixup section. */
8956 fixupsec = bfd_make_section_anyway_with_flags
8957 (info->output_bfd, "$FIXUP$",
8958 SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_LINKER_CREATED);
8959 if (fixupsec == NULL)
8961 last_addr = (last_addr + 0xffff) & ~0xffff;
8962 fixupsec->vma = last_addr;
8964 alpha_vms_link_hash (info)->fixup = fixupsec;
8965 alpha_vms_link_hash (info)->base_addr = base_addr;
8967 /* Create the DMT section, if necessary. */
8968 BFD_ASSERT (PRIV (dst_section) == NULL);
8969 dst = bfd_get_section_by_name (abfd, "$DST$");
8970 if (dst != NULL && dst->size == 0)
8974 PRIV (dst_section) = dst;
8975 dmt = bfd_make_section_anyway_with_flags
8976 (info->output_bfd, "$DMT$",
8977 SEC_DEBUGGING | SEC_HAS_CONTENTS | SEC_LINKER_CREATED);
8984 /* Read all sections from the inputs. */
8985 for (sub = info->input_bfds; sub != NULL; sub = sub->link.next)
8987 if (sub->flags & DYNAMIC)
8989 alpha_vms_create_eisd_for_shared (abfd, sub);
8993 if (!alpha_vms_read_sections_content (sub, info))
8997 /* Handle all the link order information for the sections.
8998 Note: past this point, it is not possible to create new sections. */
8999 for (o = abfd->sections; o != NULL; o = o->next)
9001 for (p = o->map_head.link_order; p != NULL; p = p->next)
9005 case bfd_section_reloc_link_order:
9006 case bfd_symbol_reloc_link_order:
9009 case bfd_indirect_link_order:
9013 if (! _bfd_default_link_order (abfd, info, o, p))
9020 /* Compute fixups. */
9021 if (!alpha_vms_build_fixups (info))
9024 /* Compute the DMT. */
9028 unsigned char *contents = NULL;
9030 /* In pass 1, compute the size. In pass 2, write the DMT contents. */
9031 for (pass = 0; pass < 2; pass++)
9033 unsigned int off = 0;
9035 /* For each object file (ie for each module). */
9036 for (sub = info->input_bfds; sub != NULL; sub = sub->link.next)
9039 struct vms_dmt_header *dmth = NULL;
9040 unsigned int psect_count;
9042 /* Skip this module if it has no DST. */
9043 sub_dst = PRIV2 (sub, dst_section);
9044 if (sub_dst == NULL || sub_dst->size == 0)
9049 /* Write the header. */
9050 dmth = (struct vms_dmt_header *)(contents + off);
9051 bfd_putl32 (sub_dst->output_offset, dmth->modbeg);
9052 bfd_putl32 (sub_dst->size, dmth->size);
9055 off += sizeof (struct vms_dmt_header);
9058 /* For each section (ie for each psect). */
9059 for (o = sub->sections; o != NULL; o = o->next)
9061 /* Only consider interesting sections. */
9062 if (!(o->flags & SEC_ALLOC))
9064 if (o->flags & SEC_LINKER_CREATED)
9069 /* Write an entry. */
9070 struct vms_dmt_psect *dmtp;
9072 dmtp = (struct vms_dmt_psect *)(contents + off);
9073 bfd_putl32 (o->output_offset + o->output_section->vma,
9075 bfd_putl32 (o->size, dmtp->length);
9078 off += sizeof (struct vms_dmt_psect);
9081 bfd_putl32 (psect_count, dmth->psect_count);
9086 contents = bfd_zalloc (info->output_bfd, off);
9087 if (contents == NULL)
9089 dmt->contents = contents;
9094 BFD_ASSERT (off == dmt->size);
9102 /* Read the contents of a section.
9103 buf points to a buffer of buf_size bytes to be filled with
9104 section data (starting at offset into section) */
9107 alpha_vms_get_section_contents (bfd *abfd, asection *section,
9108 void *buf, file_ptr offset,
9109 bfd_size_type count)
9113 /* Image are easy. */
9114 if (bfd_get_file_flags (abfd) & (EXEC_P | DYNAMIC))
9115 return _bfd_generic_get_section_contents (abfd, section,
9116 buf, offset, count);
9119 if (offset + count < count
9120 || offset + count > section->size)
9122 bfd_set_error (bfd_error_invalid_operation);
9126 /* If the section is already in memory, just copy it. */
9127 if (section->flags & SEC_IN_MEMORY)
9129 BFD_ASSERT (section->contents != NULL);
9130 memcpy (buf, section->contents + offset, count);
9133 if (section->size == 0)
9136 /* Alloc in memory and read ETIRs. */
9137 for (sec = abfd->sections; sec; sec = sec->next)
9139 BFD_ASSERT (sec->contents == NULL);
9141 if (sec->size != 0 && (sec->flags & SEC_HAS_CONTENTS))
9143 sec->contents = bfd_alloc (abfd, sec->size);
9144 if (sec->contents == NULL)
9148 if (!alpha_vms_read_sections_content (abfd, NULL))
9150 for (sec = abfd->sections; sec; sec = sec->next)
9152 sec->flags |= SEC_IN_MEMORY;
9153 memcpy (buf, section->contents + offset, count);
9158 /* Set the format of a file being written. */
9161 alpha_vms_mkobject (bfd * abfd)
9163 const bfd_arch_info_type *arch;
9165 vms_debug2 ((1, "alpha_vms_mkobject (%p)\n", abfd));
9167 if (!vms_initialize (abfd))
9170 PRIV (recwr.buf) = bfd_alloc (abfd, MAX_OUTREC_SIZE);
9171 if (PRIV (recwr.buf) == NULL)
9174 arch = bfd_scan_arch ("alpha");
9178 bfd_set_error (bfd_error_wrong_format);
9182 abfd->arch_info = arch;
9189 /* Called when the BFD is being closed to do any necessary cleanup. */
9192 vms_close_and_cleanup (bfd * abfd)
9194 vms_debug2 ((1, "vms_close_and_cleanup (%p)\n", abfd));
9196 if (abfd == NULL || abfd->tdata.any == NULL)
9199 if (abfd->format == bfd_archive)
9201 bfd_release (abfd, abfd->tdata.any);
9202 abfd->tdata.any = NULL;
9206 if (PRIV (recrd.buf) != NULL)
9207 free (PRIV (recrd.buf));
9209 if (PRIV (sections) != NULL)
9210 free (PRIV (sections));
9212 bfd_release (abfd, abfd->tdata.any);
9213 abfd->tdata.any = NULL;
9216 if (abfd->direction == write_direction)
9218 /* Last step on VMS is to convert the file to variable record length
9220 if (!bfd_cache_close (abfd))
9222 if (!_bfd_vms_convert_to_var_unix_filename (abfd->filename))
9230 /* Called when a new section is created. */
9233 vms_new_section_hook (bfd * abfd, asection *section)
9237 vms_debug2 ((1, "vms_new_section_hook (%p, [%u]%s)\n",
9238 abfd, section->index, section->name));
9240 if (! bfd_set_section_alignment (abfd, section, 0))
9243 vms_debug2 ((7, "%u: %s\n", section->index, section->name));
9245 amt = sizeof (struct vms_section_data_struct);
9246 section->used_by_bfd = bfd_zalloc (abfd, amt);
9247 if (section->used_by_bfd == NULL)
9250 /* Create the section symbol. */
9251 return _bfd_generic_new_section_hook (abfd, section);
9254 /* Part 4.5, symbols. */
9256 /* Print symbol to file according to how. how is one of
9257 bfd_print_symbol_name just print the name
9258 bfd_print_symbol_more print more (???)
9259 bfd_print_symbol_all print all we know, which is not much right now :-). */
9262 vms_print_symbol (bfd * abfd,
9265 bfd_print_symbol_type how)
9267 vms_debug2 ((1, "vms_print_symbol (%p, %p, %p, %d)\n",
9268 abfd, file, symbol, how));
9272 case bfd_print_symbol_name:
9273 case bfd_print_symbol_more:
9274 fprintf ((FILE *)file," %s", symbol->name);
9277 case bfd_print_symbol_all:
9279 const char *section_name = symbol->section->name;
9281 bfd_print_symbol_vandf (abfd, file, symbol);
9283 fprintf ((FILE *) file," %-8s %s", section_name, symbol->name);
9289 /* Return information about symbol in ret.
9291 fill type, value and name
9294 B bss segment symbol
9296 D data segment symbol
9298 t a static function symbol
9299 T text segment symbol
9304 vms_get_symbol_info (bfd * abfd ATTRIBUTE_UNUSED,
9310 vms_debug2 ((1, "vms_get_symbol_info (%p, %p, %p)\n", abfd, symbol, ret));
9312 sec = symbol->section;
9319 else if (bfd_is_com_section (sec))
9321 else if (bfd_is_abs_section (sec))
9323 else if (bfd_is_und_section (sec))
9325 else if (bfd_is_ind_section (sec))
9327 else if ((symbol->flags & BSF_FUNCTION)
9328 || (bfd_get_section_flags (abfd, sec) & SEC_CODE))
9330 else if (bfd_get_section_flags (abfd, sec) & SEC_DATA)
9332 else if (bfd_get_section_flags (abfd, sec) & SEC_ALLOC)
9337 if (ret->type != 'U')
9338 ret->value = symbol->value + symbol->section->vma;
9341 ret->name = symbol->name;
9344 /* Return TRUE if the given symbol sym in the BFD abfd is
9345 a compiler generated local label, else return FALSE. */
9348 vms_bfd_is_local_label_name (bfd * abfd ATTRIBUTE_UNUSED,
9351 return name[0] == '$';
9354 /* Part 4.7, writing an object file. */
9356 /* Sets the contents of the section section in BFD abfd to the data starting
9357 in memory at LOCATION. The data is written to the output section starting
9358 at offset offset for count bytes.
9360 Normally TRUE is returned, else FALSE. Possible error returns are:
9361 o bfd_error_no_contents - The output section does not have the
9362 SEC_HAS_CONTENTS attribute, so nothing can be written to it.
9363 o and some more too */
9366 _bfd_vms_set_section_contents (bfd * abfd,
9368 const void * location,
9370 bfd_size_type count)
9372 if (section->contents == NULL)
9374 section->contents = bfd_alloc (abfd, section->size);
9375 if (section->contents == NULL)
9378 memcpy (section->contents + offset, location, (size_t) count);
9384 /* Set the architecture and machine type in BFD abfd to arch and mach.
9385 Find the correct pointer to a structure and insert it into the arch_info
9389 alpha_vms_set_arch_mach (bfd *abfd,
9390 enum bfd_architecture arch, unsigned long mach)
9392 if (arch != bfd_arch_alpha
9393 && arch != bfd_arch_unknown)
9396 return bfd_default_set_arch_mach (abfd, arch, mach);
9399 /* Set section VMS flags. Clear NO_FLAGS and set FLAGS. */
9402 bfd_vms_set_section_flags (bfd *abfd ATTRIBUTE_UNUSED,
9403 asection *sec, flagword no_flags, flagword flags)
9405 vms_section_data (sec)->no_flags = no_flags;
9406 vms_section_data (sec)->flags = flags;
9409 struct vms_private_data_struct *
9410 bfd_vms_get_data (bfd *abfd)
9412 return (struct vms_private_data_struct *)abfd->tdata.any;
9415 #define vms_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
9416 #define vms_bfd_link_just_syms _bfd_generic_link_just_syms
9417 #define vms_bfd_copy_link_hash_symbol_type \
9418 _bfd_generic_copy_link_hash_symbol_type
9419 #define vms_bfd_is_group_section bfd_generic_is_group_section
9420 #define vms_bfd_discard_group bfd_generic_discard_group
9421 #define vms_section_already_linked _bfd_generic_section_already_linked
9422 #define vms_bfd_define_common_symbol bfd_generic_define_common_symbol
9423 #define vms_bfd_define_start_stop bfd_generic_define_start_stop
9424 #define vms_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
9426 #define vms_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
9427 #define vms_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
9428 #define vms_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data
9429 #define vms_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
9430 #define vms_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
9431 #define vms_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
9433 /* Symbols table. */
9434 #define alpha_vms_make_empty_symbol _bfd_generic_make_empty_symbol
9435 #define alpha_vms_bfd_is_target_special_symbol \
9436 ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
9437 #define alpha_vms_print_symbol vms_print_symbol
9438 #define alpha_vms_get_symbol_info vms_get_symbol_info
9439 #define alpha_vms_get_symbol_version_string \
9440 _bfd_nosymbols_get_symbol_version_string
9442 #define alpha_vms_read_minisymbols _bfd_generic_read_minisymbols
9443 #define alpha_vms_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
9444 #define alpha_vms_get_lineno _bfd_nosymbols_get_lineno
9445 #define alpha_vms_find_inliner_info _bfd_nosymbols_find_inliner_info
9446 #define alpha_vms_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
9447 #define alpha_vms_find_nearest_line _bfd_vms_find_nearest_line
9448 #define alpha_vms_find_line _bfd_nosymbols_find_line
9449 #define alpha_vms_bfd_is_local_label_name vms_bfd_is_local_label_name
9451 /* Generic table. */
9452 #define alpha_vms_close_and_cleanup vms_close_and_cleanup
9453 #define alpha_vms_bfd_free_cached_info vms_bfd_free_cached_info
9454 #define alpha_vms_new_section_hook vms_new_section_hook
9455 #define alpha_vms_set_section_contents _bfd_vms_set_section_contents
9456 #define alpha_vms_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
9458 #define alpha_vms_bfd_get_relocated_section_contents \
9459 bfd_generic_get_relocated_section_contents
9461 #define alpha_vms_bfd_relax_section bfd_generic_relax_section
9462 #define alpha_vms_bfd_gc_sections bfd_generic_gc_sections
9463 #define alpha_vms_bfd_lookup_section_flags bfd_generic_lookup_section_flags
9464 #define alpha_vms_bfd_merge_sections bfd_generic_merge_sections
9465 #define alpha_vms_bfd_is_group_section bfd_generic_is_group_section
9466 #define alpha_vms_bfd_discard_group bfd_generic_discard_group
9467 #define alpha_vms_section_already_linked \
9468 _bfd_generic_section_already_linked
9470 #define alpha_vms_bfd_define_common_symbol bfd_generic_define_common_symbol
9471 #define alpha_vms_bfd_define_start_stop bfd_generic_define_start_stop
9472 #define alpha_vms_bfd_link_just_syms _bfd_generic_link_just_syms
9473 #define alpha_vms_bfd_copy_link_hash_symbol_type \
9474 _bfd_generic_copy_link_hash_symbol_type
9476 #define alpha_vms_bfd_link_split_section _bfd_generic_link_split_section
9478 #define alpha_vms_get_dynamic_symtab_upper_bound \
9479 _bfd_nodynamic_get_dynamic_symtab_upper_bound
9480 #define alpha_vms_canonicalize_dynamic_symtab \
9481 _bfd_nodynamic_canonicalize_dynamic_symtab
9482 #define alpha_vms_get_dynamic_reloc_upper_bound \
9483 _bfd_nodynamic_get_dynamic_reloc_upper_bound
9484 #define alpha_vms_canonicalize_dynamic_reloc \
9485 _bfd_nodynamic_canonicalize_dynamic_reloc
9486 #define alpha_vms_bfd_link_check_relocs _bfd_generic_link_check_relocs
9488 const bfd_target alpha_vms_vec =
9490 "vms-alpha", /* Name. */
9491 bfd_target_evax_flavour,
9492 BFD_ENDIAN_LITTLE, /* Data byte order is little. */
9493 BFD_ENDIAN_LITTLE, /* Header byte order is little. */
9495 (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS
9496 | WP_TEXT | D_PAGED), /* Object flags. */
9497 (SEC_ALLOC | SEC_LOAD | SEC_RELOC
9498 | SEC_READONLY | SEC_CODE | SEC_DATA
9499 | SEC_HAS_CONTENTS | SEC_IN_MEMORY), /* Sect flags. */
9500 0, /* symbol_leading_char. */
9501 ' ', /* ar_pad_char. */
9502 15, /* ar_max_namelen. */
9503 0, /* match priority. */
9504 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
9505 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
9506 bfd_getl16, bfd_getl_signed_16, bfd_putl16,
9507 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
9508 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
9509 bfd_getl16, bfd_getl_signed_16, bfd_putl16,
9511 {_bfd_dummy_target, alpha_vms_object_p, /* bfd_check_format. */
9512 _bfd_vms_lib_alpha_archive_p, _bfd_dummy_target},
9513 {bfd_false, alpha_vms_mkobject, /* bfd_set_format. */
9514 _bfd_vms_lib_alpha_mkarchive, bfd_false},
9515 {bfd_false, alpha_vms_write_object_contents, /* bfd_write_contents. */
9516 _bfd_vms_lib_write_archive_contents, bfd_false},
9518 BFD_JUMP_TABLE_GENERIC (alpha_vms),
9519 BFD_JUMP_TABLE_COPY (vms),
9520 BFD_JUMP_TABLE_CORE (_bfd_nocore),
9521 BFD_JUMP_TABLE_ARCHIVE (_bfd_vms_lib),
9522 BFD_JUMP_TABLE_SYMBOLS (alpha_vms),
9523 BFD_JUMP_TABLE_RELOCS (alpha_vms),
9524 BFD_JUMP_TABLE_WRITE (alpha_vms),
9525 BFD_JUMP_TABLE_LINK (alpha_vms),
9526 BFD_JUMP_TABLE_DYNAMIC (alpha_vms),