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 /* PR 21813: Check for an undersized record. */
477 if (PRIV (recrd
.buf_size
) < sizeof (* eihd
))
479 _bfd_error_handler (_("Corrupt EIHD record - size is too small"));
480 bfd_set_error (bfd_error_bad_value
);
484 size
= bfd_getl32 (eihd
->size
);
485 imgtype
= bfd_getl32 (eihd
->imgtype
);
487 if (imgtype
== EIHD__K_EXE
|| imgtype
== EIHD__K_LIM
)
488 abfd
->flags
|= EXEC_P
;
490 symvva
= bfd_getl64 (eihd
->symvva
);
493 PRIV (symvva
) = symvva
;
494 abfd
->flags
|= DYNAMIC
;
497 PRIV (ident
) = bfd_getl32 (eihd
->ident
);
498 PRIV (matchctl
) = eihd
->matchctl
;
500 *eisd_offset
= bfd_getl32 (eihd
->isdoff
);
501 *eihs_offset
= bfd_getl32 (eihd
->symdbgoff
);
503 vms_debug2 ((4, "EIHD size %d imgtype %d symvva 0x%lx eisd %d eihs %d\n",
504 size
, imgtype
, (unsigned long)symvva
,
505 *eisd_offset
, *eihs_offset
));
510 /* Read & process EISD record.
511 Return TRUE on success, FALSE on error. */
514 _bfd_vms_slurp_eisd (bfd
*abfd
, unsigned int offset
)
516 int section_count
= 0;
518 vms_debug2 ((8, "_bfd_vms_slurp_eisd\n"));
522 struct vms_eisd
*eisd
;
523 unsigned int rec_size
;
532 /* PR 17512: file: 3d9e9fe9.
533 12 is the offset of the eisdsize field from the start of the record (8)
534 plus the size of the eisdsize field (4). */
535 if (offset
>= PRIV (recrd
.rec_size
) - 12)
537 eisd
= (struct vms_eisd
*)(PRIV (recrd
.rec
) + offset
);
538 rec_size
= bfd_getl32 (eisd
->eisdsize
);
542 /* Skip to next block if pad. */
543 if (rec_size
== 0xffffffff)
545 offset
= (offset
+ VMS_BLOCK_SIZE
) & ~(VMS_BLOCK_SIZE
- 1);
549 /* Make sure that there is enough data present in the record. */
550 /* FIXME: Should we use sizeof (struct vms_eisd) rather than just 32 here ? */
553 /* Make sure that the record is not too big either. */
554 if (offset
+ rec_size
>= PRIV (recrd
.rec_size
))
559 size
= bfd_getl32 (eisd
->secsize
);
560 vaddr
= bfd_getl64 (eisd
->virt_addr
);
561 flags
= bfd_getl32 (eisd
->flags
);
562 vbn
= bfd_getl32 (eisd
->vbn
);
564 vms_debug2 ((4, "EISD at 0x%x size 0x%x addr 0x%lx flags 0x%x blk %d\n",
565 offset
, size
, (unsigned long)vaddr
, flags
, vbn
));
567 /* VMS combines psects from .obj files into isects in the .exe. This
568 process doesn't preserve enough information to reliably determine
569 what's in each section without examining the data. This is
570 especially true of DWARF debug sections. */
571 bfd_flags
= SEC_ALLOC
;
573 bfd_flags
|= SEC_HAS_CONTENTS
| SEC_LOAD
;
575 if (flags
& EISD__M_EXE
)
576 bfd_flags
|= SEC_CODE
;
578 if (flags
& EISD__M_NONSHRADR
)
579 bfd_flags
|= SEC_DATA
;
581 if (!(flags
& EISD__M_WRT
))
582 bfd_flags
|= SEC_READONLY
;
584 if (flags
& EISD__M_DZRO
)
585 bfd_flags
|= SEC_DATA
;
587 if (flags
& EISD__M_FIXUPVEC
)
588 bfd_flags
|= SEC_DATA
;
590 if (flags
& EISD__M_CRF
)
591 bfd_flags
|= SEC_DATA
;
593 if (flags
& EISD__M_GBL
)
595 if (rec_size
< offsetof (struct vms_eisd
, gblnam
))
597 else if (rec_size
< sizeof (struct vms_eisd
))
598 name
= _bfd_vms_save_counted_string (eisd
->gblnam
,
599 rec_size
- offsetof (struct vms_eisd
, gblnam
));
601 name
= _bfd_vms_save_counted_string (eisd
->gblnam
, EISD__K_GBLNAMLEN
);
602 bfd_flags
|= SEC_COFF_SHARED_LIBRARY
;
603 bfd_flags
&= ~(SEC_ALLOC
| SEC_LOAD
);
605 else if (flags
& EISD__M_FIXUPVEC
)
607 else if (eisd
->type
== EISD__K_USRSTACK
)
613 name
= (char*) bfd_alloc (abfd
, 32);
614 if (flags
& EISD__M_DZRO
)
616 else if (flags
& EISD__M_EXE
)
618 else if (!(flags
& EISD__M_WRT
))
622 BFD_ASSERT (section_count
< 999);
623 sprintf (name
, "$%s_%03d$", pfx
, section_count
++);
626 section
= bfd_make_section (abfd
, name
);
631 section
->filepos
= vbn
? VMS_BLOCK_SIZE
* (vbn
- 1) : 0;
632 section
->size
= size
;
633 section
->vma
= vaddr
;
635 if (!bfd_set_section_flags (abfd
, section
, bfd_flags
))
642 /* Read & process EIHS record.
643 Return TRUE on success, FALSE on error. */
646 _bfd_vms_slurp_eihs (bfd
*abfd
, unsigned int offset
)
648 unsigned char *p
= PRIV (recrd
.rec
) + offset
;
650 unsigned int gstsize ATTRIBUTE_UNUSED
;
652 unsigned int dstsize
;
654 unsigned int dmtbytes
;
657 /* PR 21611: Check that offset is valid. */
658 if (offset
> PRIV (recrd
.rec_size
) - (EIHS__L_DMTBYTES
+ 4))
660 _bfd_error_handler (_("Unable to read EIHS record at offset %#x"), offset
);
661 bfd_set_error (bfd_error_file_truncated
);
665 gstvbn
= bfd_getl32 (p
+ EIHS__L_GSTVBN
);
666 gstsize
= bfd_getl32 (p
+ EIHS__L_GSTSIZE
);
667 dstvbn
= bfd_getl32 (p
+ EIHS__L_DSTVBN
);
668 dstsize
= bfd_getl32 (p
+ EIHS__L_DSTSIZE
);
669 dmtvbn
= bfd_getl32 (p
+ EIHS__L_DMTVBN
);
670 dmtbytes
= bfd_getl32 (p
+ EIHS__L_DMTBYTES
);
673 vms_debug (8, "_bfd_vms_slurp_ihs\n");
674 vms_debug (4, "EIHS record gstvbn %d gstsize %d dstvbn %d dstsize %d dmtvbn %d dmtbytes %d\n",
675 gstvbn
, gstsize
, dstvbn
, dstsize
, dmtvbn
, dmtbytes
);
680 flagword bfd_flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
;
682 section
= bfd_make_section (abfd
, "$DST$");
686 section
->size
= dstsize
;
687 section
->filepos
= VMS_BLOCK_SIZE
* (dstvbn
- 1);
689 if (!bfd_set_section_flags (abfd
, section
, bfd_flags
))
692 PRIV (dst_section
) = section
;
693 abfd
->flags
|= (HAS_DEBUG
| HAS_LINENO
);
698 flagword bfd_flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
;
700 section
= bfd_make_section (abfd
, "$DMT$");
704 section
->size
= dmtbytes
;
705 section
->filepos
= VMS_BLOCK_SIZE
* (dmtvbn
- 1);
707 if (!bfd_set_section_flags (abfd
, section
, bfd_flags
))
713 if (bfd_seek (abfd
, VMS_BLOCK_SIZE
* (gstvbn
- 1), SEEK_SET
))
715 bfd_set_error (bfd_error_file_truncated
);
719 if (!_bfd_vms_slurp_object_records (abfd
))
722 abfd
->flags
|= HAS_SYMS
;
728 /* Object file reading. */
730 /* Object file input functions. */
732 /* Get next record from object file to vms_buf.
733 Set PRIV(buf_size) and return it
735 This is a little tricky since it should be portable.
737 The openVMS object file has 'variable length' which means that
738 read() returns data in chunks of (hopefully) correct and expected
739 size. The linker (and other tools on VMS) depend on that. Unix
740 doesn't know about 'formatted' files, so reading and writing such
741 an object file in a Unix environment is not trivial.
743 With the tool 'file' (available on all VMS FTP sites), one
744 can view and change the attributes of a file. Changing from
745 'variable length' to 'fixed length, 512 bytes' reveals the
746 record size at the first 2 bytes of every record. The same
747 may happen during the transfer of object files from VMS to Unix,
748 at least with UCX, the DEC implementation of TCP/IP.
750 The VMS format repeats the size at bytes 2 & 3 of every record.
752 On the first call (file_format == FF_UNKNOWN) we check if
753 the first and the third byte pair (!) of the record match.
754 If they do it's an object file in an Unix environment or with
755 wrong attributes (FF_FOREIGN), else we should be in a VMS
756 environment where read() returns the record size (FF_NATIVE).
758 Reading is always done in 2 steps:
759 1. first just the record header is read and the size extracted,
760 2. then the read buffer is adjusted and the remaining bytes are
763 All file I/O is done on even file positions. */
765 #define VMS_OBJECT_ADJUSTMENT 2
768 maybe_adjust_record_pointer_for_object (bfd
*abfd
)
770 /* Set the file format once for all on the first invocation. */
771 if (PRIV (recrd
.file_format
) == FF_UNKNOWN
)
773 if (PRIV (recrd
.rec
)[0] == PRIV (recrd
.rec
)[4]
774 && PRIV (recrd
.rec
)[1] == PRIV (recrd
.rec
)[5])
775 PRIV (recrd
.file_format
) = FF_FOREIGN
;
777 PRIV (recrd
.file_format
) = FF_NATIVE
;
780 /* The adjustment is needed only in an Unix environment. */
781 if (PRIV (recrd
.file_format
) == FF_FOREIGN
)
782 PRIV (recrd
.rec
) += VMS_OBJECT_ADJUSTMENT
;
785 /* Implement step #1 of the object record reading procedure.
786 Return the record type or -1 on failure. */
789 _bfd_vms_get_object_record (bfd
*abfd
)
791 unsigned int test_len
= 6;
794 vms_debug2 ((8, "_bfd_vms_get_obj_record\n"));
796 /* Skip alignment byte if the current position is odd. */
797 if (PRIV (recrd
.file_format
) == FF_FOREIGN
&& (bfd_tell (abfd
) & 1))
799 if (bfd_bread (PRIV (recrd
.buf
), 1, abfd
) != 1)
801 bfd_set_error (bfd_error_file_truncated
);
806 /* Read the record header */
807 if (bfd_bread (PRIV (recrd
.buf
), test_len
, abfd
) != test_len
)
809 bfd_set_error (bfd_error_file_truncated
);
813 /* Reset the record pointer. */
814 PRIV (recrd
.rec
) = PRIV (recrd
.buf
);
815 maybe_adjust_record_pointer_for_object (abfd
);
817 if (vms_get_remaining_object_record (abfd
, test_len
) <= 0)
820 type
= bfd_getl16 (PRIV (recrd
.rec
));
822 vms_debug2 ((8, "_bfd_vms_get_obj_record: rec %p, size %d, type %d\n",
823 PRIV (recrd
.rec
), PRIV (recrd
.rec_size
), type
));
828 /* Implement step #2 of the object record reading procedure.
829 Return the size of the record or 0 on failure. */
832 vms_get_remaining_object_record (bfd
*abfd
, unsigned int read_so_far
)
834 unsigned int to_read
;
836 vms_debug2 ((8, "vms_get_remaining_obj_record\n"));
838 /* Extract record size. */
839 PRIV (recrd
.rec_size
) = bfd_getl16 (PRIV (recrd
.rec
) + 2);
841 if (PRIV (recrd
.rec_size
) == 0)
843 bfd_set_error (bfd_error_file_truncated
);
847 /* That's what the linker manual says. */
848 if (PRIV (recrd
.rec_size
) > EOBJ__C_MAXRECSIZ
)
850 bfd_set_error (bfd_error_file_truncated
);
854 /* Take into account object adjustment. */
855 to_read
= PRIV (recrd
.rec_size
);
856 if (PRIV (recrd
.file_format
) == FF_FOREIGN
)
857 to_read
+= VMS_OBJECT_ADJUSTMENT
;
859 /* Adjust the buffer. */
860 if (to_read
> PRIV (recrd
.buf_size
))
863 = (unsigned char *) bfd_realloc (PRIV (recrd
.buf
), to_read
);
864 if (PRIV (recrd
.buf
) == NULL
)
866 PRIV (recrd
.buf_size
) = to_read
;
868 /* PR 17512: file: 025-1974-0.004. */
869 else if (to_read
<= read_so_far
)
872 /* Read the remaining record. */
873 to_read
-= read_so_far
;
875 vms_debug2 ((8, "vms_get_remaining_obj_record: to_read %d\n", to_read
));
877 if (bfd_bread (PRIV (recrd
.buf
) + read_so_far
, to_read
, abfd
) != to_read
)
879 bfd_set_error (bfd_error_file_truncated
);
883 /* Reset the record pointer. */
884 PRIV (recrd
.rec
) = PRIV (recrd
.buf
);
885 maybe_adjust_record_pointer_for_object (abfd
);
887 vms_debug2 ((8, "vms_get_remaining_obj_record: size %d\n",
888 PRIV (recrd
.rec_size
)));
890 return PRIV (recrd
.rec_size
);
893 /* Read and process emh record.
894 Return TRUE on success, FALSE on error. */
897 _bfd_vms_slurp_ehdr (bfd
*abfd
)
900 unsigned char *vms_rec
;
904 vms_rec
= PRIV (recrd
.rec
);
905 /* PR 17512: file: 62736583. */
906 end
= vms_rec
+ PRIV (recrd
.buf_size
);
908 vms_debug2 ((2, "HDR/EMH\n"));
910 subtype
= bfd_getl16 (vms_rec
+ 4);
912 vms_debug2 ((3, "subtype %d\n", subtype
));
918 if (vms_rec
+ 21 >= end
)
920 PRIV (hdr_data
).hdr_b_strlvl
= vms_rec
[6];
921 PRIV (hdr_data
).hdr_l_arch1
= bfd_getl32 (vms_rec
+ 8);
922 PRIV (hdr_data
).hdr_l_arch2
= bfd_getl32 (vms_rec
+ 12);
923 PRIV (hdr_data
).hdr_l_recsiz
= bfd_getl32 (vms_rec
+ 16);
924 if ((vms_rec
+ 20 + vms_rec
[20] + 1) >= end
)
926 PRIV (hdr_data
).hdr_t_name
= _bfd_vms_save_counted_string (vms_rec
+ 20, vms_rec
[20]);
927 ptr
= vms_rec
+ 20 + vms_rec
[20] + 1;
928 if ((ptr
+ *ptr
+ 1) >= end
)
930 PRIV (hdr_data
).hdr_t_version
=_bfd_vms_save_counted_string (ptr
, *ptr
);
934 PRIV (hdr_data
).hdr_t_date
= _bfd_vms_save_sized_string (ptr
, 17);
938 if (vms_rec
+ PRIV (recrd
.rec_size
- 6) > end
)
940 PRIV (hdr_data
).hdr_c_lnm
=
941 _bfd_vms_save_sized_string (vms_rec
, PRIV (recrd
.rec_size
- 6));
945 if (vms_rec
+ PRIV (recrd
.rec_size
- 6) > end
)
947 PRIV (hdr_data
).hdr_c_src
=
948 _bfd_vms_save_sized_string (vms_rec
, PRIV (recrd
.rec_size
- 6));
952 if (vms_rec
+ PRIV (recrd
.rec_size
- 6) > end
)
954 PRIV (hdr_data
).hdr_c_ttl
=
955 _bfd_vms_save_sized_string (vms_rec
, PRIV (recrd
.rec_size
- 6));
965 bfd_set_error (bfd_error_wrong_format
);
972 /* Typical sections for evax object files. */
974 #define EVAX_ABS_NAME "$ABS$"
975 #define EVAX_CODE_NAME "$CODE$"
976 #define EVAX_LINK_NAME "$LINK$"
977 #define EVAX_DATA_NAME "$DATA$"
978 #define EVAX_BSS_NAME "$BSS$"
979 #define EVAX_READONLYADDR_NAME "$READONLY_ADDR$"
980 #define EVAX_READONLY_NAME "$READONLY$"
981 #define EVAX_LITERAL_NAME "$LITERAL$"
982 #define EVAX_LITERALS_NAME "$LITERALS"
983 #define EVAX_COMMON_NAME "$COMMON$"
984 #define EVAX_LOCAL_NAME "$LOCAL$"
986 struct sec_flags_struct
988 const char *name
; /* Name of section. */
990 flagword flags_always
; /* Flags we set always. */
992 flagword flags_hassize
; /* Flags we set if the section has a size > 0. */
995 /* These flags are deccrtl/vaxcrtl (openVMS 6.2 Alpha) compatible. */
997 static const struct sec_flags_struct evax_section_flags
[] =
1005 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_EXE
,
1006 SEC_CODE
| SEC_READONLY
,
1007 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_EXE
,
1008 SEC_CODE
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1009 { EVAX_LITERAL_NAME
,
1010 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
| EGPS__V_NOMOD
,
1011 SEC_DATA
| SEC_READONLY
,
1012 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
,
1013 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1015 EGPS__V_REL
| EGPS__V_RD
,
1016 SEC_DATA
| SEC_READONLY
,
1017 EGPS__V_REL
| EGPS__V_RD
,
1018 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1020 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
,
1022 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1023 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1025 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
,
1027 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
,
1029 { EVAX_READONLYADDR_NAME
,
1030 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_RD
,
1031 SEC_DATA
| SEC_READONLY
,
1032 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_RD
,
1033 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1034 { EVAX_READONLY_NAME
,
1035 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
| EGPS__V_NOMOD
,
1036 SEC_DATA
| SEC_READONLY
,
1037 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
,
1038 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1040 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1042 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1043 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1044 { EVAX_LITERALS_NAME
,
1045 EGPS__V_PIC
| EGPS__V_OVR
,
1046 SEC_DATA
| SEC_READONLY
,
1047 EGPS__V_PIC
| EGPS__V_OVR
,
1048 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1050 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1052 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1053 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
}
1056 /* Retrieve BFD section flags by name and size. */
1059 vms_secflag_by_name (const struct sec_flags_struct
*section_flags
,
1065 while (section_flags
[i
].name
!= NULL
)
1067 if (strcmp (name
, section_flags
[i
].name
) == 0)
1070 return section_flags
[i
].flags_hassize
;
1072 return section_flags
[i
].flags_always
;
1077 return section_flags
[i
].flags_hassize
;
1078 return section_flags
[i
].flags_always
;
1081 /* Retrieve VMS section flags by name and size. */
1084 vms_esecflag_by_name (const struct sec_flags_struct
*section_flags
,
1090 while (section_flags
[i
].name
!= NULL
)
1092 if (strcmp (name
, section_flags
[i
].name
) == 0)
1095 return section_flags
[i
].vflags_hassize
;
1097 return section_flags
[i
].vflags_always
;
1102 return section_flags
[i
].vflags_hassize
;
1103 return section_flags
[i
].vflags_always
;
1106 /* Add SYM to the symbol table of ABFD.
1107 Return FALSE in case of error. */
1110 add_symbol_entry (bfd
*abfd
, struct vms_symbol_entry
*sym
)
1112 if (PRIV (gsd_sym_count
) >= PRIV (max_sym_count
))
1114 if (PRIV (max_sym_count
) == 0)
1116 PRIV (max_sym_count
) = 128;
1117 PRIV (syms
) = bfd_malloc
1118 (PRIV (max_sym_count
) * sizeof (struct vms_symbol_entry
*));
1122 PRIV (max_sym_count
) *= 2;
1123 PRIV (syms
) = bfd_realloc
1125 (PRIV (max_sym_count
) * sizeof (struct vms_symbol_entry
*)));
1127 if (PRIV (syms
) == NULL
)
1131 PRIV (syms
)[PRIV (gsd_sym_count
)++] = sym
;
1135 /* Create a symbol whose name is ASCIC and add it to ABFD.
1136 Return NULL in case of error. */
1138 static struct vms_symbol_entry
*
1139 add_symbol (bfd
*abfd
, const unsigned char *ascic
)
1141 struct vms_symbol_entry
*entry
;
1145 entry
= (struct vms_symbol_entry
*)bfd_zalloc (abfd
, sizeof (*entry
) + len
);
1148 entry
->namelen
= len
;
1149 memcpy (entry
->name
, ascic
, len
);
1150 entry
->name
[len
] = 0;
1151 entry
->owner
= abfd
;
1153 if (!add_symbol_entry (abfd
, entry
))
1158 /* Read and process EGSD. Return FALSE on failure. */
1161 _bfd_vms_slurp_egsd (bfd
*abfd
)
1164 unsigned int gsd_size
;
1165 unsigned char *vms_rec
;
1166 unsigned long base_addr
;
1168 vms_debug2 ((2, "EGSD\n"));
1170 if (PRIV (recrd
.rec_size
) < 8)
1172 _bfd_error_handler (_("Corrupt EGSD record: its size (%#x) is too small"),
1173 PRIV (recrd
.rec_size
));
1174 bfd_set_error (bfd_error_bad_value
);
1178 PRIV (recrd
.rec
) += 8; /* Skip type, size, align pad. */
1179 PRIV (recrd
.rec_size
) -= 8;
1181 /* Calculate base address for each section. */
1184 while (PRIV (recrd
.rec_size
) > 4)
1186 vms_rec
= PRIV (recrd
.rec
);
1188 gsd_type
= bfd_getl16 (vms_rec
);
1189 gsd_size
= bfd_getl16 (vms_rec
+ 2);
1191 vms_debug2 ((3, "egsd_type %d\n", gsd_type
));
1193 /* PR 21615: Check for size overflow. */
1194 if (PRIV (recrd
.rec_size
) < gsd_size
)
1196 _bfd_error_handler (_("Corrupt EGSD record: size (%#x) is larger than remaining space (%#x)"),
1197 gsd_size
, PRIV (recrd
.rec_size
));
1198 bfd_set_error (bfd_error_bad_value
);
1204 _bfd_error_handler (_("Corrupt EGSD record: size (%#x) is too small"),
1206 bfd_set_error (bfd_error_bad_value
);
1213 /* Program section definition. */
1215 struct vms_egps
*egps
= (struct vms_egps
*)vms_rec
;
1216 flagword new_flags
, vms_flags
;
1219 vms_flags
= bfd_getl16 (egps
->flags
);
1221 if ((vms_flags
& EGPS__V_REL
) == 0)
1223 /* Use the global absolute section for all
1224 absolute sections. */
1225 section
= bfd_abs_section_ptr
;
1230 unsigned long align_addr
;
1232 name
= _bfd_vms_save_counted_string (&egps
->namlng
, gsd_size
- 4);
1234 section
= bfd_make_section (abfd
, name
);
1238 section
->filepos
= 0;
1239 section
->size
= bfd_getl32 (egps
->alloc
);
1240 section
->alignment_power
= egps
->align
;
1242 vms_section_data (section
)->flags
= vms_flags
;
1243 vms_section_data (section
)->no_flags
= 0;
1245 new_flags
= vms_secflag_by_name (evax_section_flags
, name
,
1247 if (section
->size
> 0)
1248 new_flags
|= SEC_LOAD
;
1249 if (!(vms_flags
& EGPS__V_NOMOD
) && section
->size
> 0)
1251 /* Set RELOC and HAS_CONTENTS if the section is not
1252 demand-zero and not empty. */
1253 new_flags
|= SEC_HAS_CONTENTS
;
1254 if (vms_flags
& EGPS__V_REL
)
1255 new_flags
|= SEC_RELOC
;
1257 if (vms_flags
& EGPS__V_EXE
)
1259 /* Set CODE if section is executable. */
1260 new_flags
|= SEC_CODE
;
1261 new_flags
&= ~SEC_DATA
;
1263 if (!bfd_set_section_flags (abfd
, section
, new_flags
))
1266 /* Give a non-overlapping vma to non absolute sections. */
1267 align_addr
= (1 << section
->alignment_power
);
1268 if ((base_addr
% align_addr
) != 0)
1269 base_addr
+= (align_addr
- (base_addr
% align_addr
));
1270 section
->vma
= (bfd_vma
)base_addr
;
1271 base_addr
+= section
->size
;
1274 /* Append it to the section array. */
1275 if (PRIV (section_count
) >= PRIV (section_max
))
1277 if (PRIV (section_max
) == 0)
1278 PRIV (section_max
) = 16;
1280 PRIV (section_max
) *= 2;
1281 PRIV (sections
) = bfd_realloc_or_free
1282 (PRIV (sections
), PRIV (section_max
) * sizeof (asection
*));
1283 if (PRIV (sections
) == NULL
)
1287 PRIV (sections
)[PRIV (section_count
)] = section
;
1288 PRIV (section_count
)++;
1295 struct vms_symbol_entry
*entry
;
1296 struct vms_egsy
*egsy
= (struct vms_egsy
*) vms_rec
;
1299 old_flags
= bfd_getl16 (egsy
->flags
);
1300 if (old_flags
& EGSY__V_DEF
)
1301 nameoff
= ESDF__B_NAMLNG
;
1303 nameoff
= ESRF__B_NAMLNG
;
1305 entry
= add_symbol (abfd
, vms_rec
+ nameoff
);
1309 /* Allow only duplicate reference. */
1310 if ((entry
->flags
& EGSY__V_DEF
) && (old_flags
& EGSY__V_DEF
))
1313 if (entry
->typ
== 0)
1315 entry
->typ
= gsd_type
;
1316 entry
->data_type
= egsy
->datyp
;
1317 entry
->flags
= old_flags
;
1320 if (old_flags
& EGSY__V_DEF
)
1322 struct vms_esdf
*esdf
= (struct vms_esdf
*)vms_rec
;
1325 entry
->value
= bfd_getl64 (esdf
->value
);
1326 if (PRIV (sections
) == NULL
)
1329 psindx
= bfd_getl32 (esdf
->psindx
);
1330 /* PR 21813: Check for an out of range index. */
1331 if (psindx
< 0 || psindx
>= (int) PRIV (section_count
))
1333 _bfd_error_handler (_("Corrupt EGSD record: its psindx field is too big (%#lx)"),
1335 bfd_set_error (bfd_error_bad_value
);
1338 entry
->section
= PRIV (sections
)[psindx
];
1340 if (old_flags
& EGSY__V_NORM
)
1342 PRIV (norm_sym_count
)++;
1344 entry
->code_value
= bfd_getl64 (esdf
->code_address
);
1345 psindx
= bfd_getl32 (esdf
->ca_psindx
);
1346 /* PR 21813: Check for an out of range index. */
1347 if (psindx
< 0 || psindx
>= (int) PRIV (section_count
))
1349 _bfd_error_handler (_("Corrupt EGSD record: its psindx field is too big (%#lx)"),
1351 bfd_set_error (bfd_error_bad_value
);
1354 entry
->code_section
= PRIV (sections
)[psindx
];
1362 struct vms_symbol_entry
*entry
;
1363 struct vms_egst
*egst
= (struct vms_egst
*)vms_rec
;
1366 old_flags
= bfd_getl16 (egst
->header
.flags
);
1368 entry
= add_symbol (abfd
, &egst
->namlng
);
1373 entry
->typ
= gsd_type
;
1374 entry
->data_type
= egst
->header
.datyp
;
1375 entry
->flags
= old_flags
;
1377 entry
->symbol_vector
= bfd_getl32 (egst
->value
);
1379 if (old_flags
& EGSY__V_REL
)
1383 if (PRIV (sections
) == NULL
)
1385 psindx
= bfd_getl32 (egst
->psindx
);
1386 /* PR 21813: Check for an out of range index. */
1387 if (psindx
< 0 || psindx
>= (int) PRIV (section_count
))
1389 _bfd_error_handler (_("Corrupt EGSD record: its psindx field is too big (%#lx)"),
1391 bfd_set_error (bfd_error_bad_value
);
1394 entry
->section
= PRIV (sections
)[psindx
];
1397 entry
->section
= bfd_abs_section_ptr
;
1399 entry
->value
= bfd_getl64 (egst
->lp_2
);
1401 if (old_flags
& EGSY__V_NORM
)
1403 PRIV (norm_sym_count
)++;
1405 entry
->code_value
= bfd_getl64 (egst
->lp_1
);
1406 entry
->code_section
= bfd_abs_section_ptr
;
1413 /* Currently ignored. */
1418 _bfd_error_handler (_("Unknown EGSD subtype %d"), gsd_type
);
1419 bfd_set_error (bfd_error_bad_value
);
1423 PRIV (recrd
.rec_size
) -= gsd_size
;
1424 PRIV (recrd
.rec
) += gsd_size
;
1427 /* FIXME: Should we complain if PRIV (recrd.rec_size) is not zero ? */
1429 if (PRIV (gsd_sym_count
) > 0)
1430 abfd
->flags
|= HAS_SYMS
;
1435 /* Stack routines for vms ETIR commands. */
1437 /* Push value and section index. */
1440 _bfd_vms_push (bfd
*abfd
, bfd_vma val
, unsigned int reloc
)
1442 vms_debug2 ((4, "<push %08lx (0x%08x) at %d>\n",
1443 (unsigned long)val
, reloc
, PRIV (stackptr
)));
1445 PRIV (stack
[PRIV (stackptr
)]).value
= val
;
1446 PRIV (stack
[PRIV (stackptr
)]).reloc
= reloc
;
1448 if (PRIV (stackptr
) >= STACKSIZE
)
1450 bfd_set_error (bfd_error_bad_value
);
1451 _bfd_error_handler (_("Stack overflow (%d) in _bfd_vms_push"), PRIV (stackptr
));
1456 /* Pop value and section index. */
1459 _bfd_vms_pop (bfd
*abfd
, bfd_vma
*val
, unsigned int *rel
)
1461 if (PRIV (stackptr
) == 0)
1463 bfd_set_error (bfd_error_bad_value
);
1464 _bfd_error_handler (_("Stack underflow in _bfd_vms_pop"));
1468 *val
= PRIV (stack
[PRIV (stackptr
)]).value
;
1469 *rel
= PRIV (stack
[PRIV (stackptr
)]).reloc
;
1471 vms_debug2 ((4, "<pop %08lx (0x%08x)>\n", (unsigned long)*val
, *rel
));
1474 /* Routines to fill sections contents during tir/etir read. */
1476 /* Initialize image buffer pointer to be filled. */
1479 image_set_ptr (bfd
*abfd
, bfd_vma vma
, int sect
, struct bfd_link_info
*info
)
1483 vms_debug2 ((4, "image_set_ptr (0x%08x, sect=%d)\n", (unsigned)vma
, sect
));
1485 if (PRIV (sections
) == NULL
)
1487 if (sect
< 0 || sect
>= (int) PRIV (section_count
))
1490 sec
= PRIV (sections
)[sect
];
1494 /* Reading contents to an output bfd. */
1496 if (sec
->output_section
== NULL
)
1498 /* Section discarded. */
1499 vms_debug2 ((5, " section %s discarded\n", sec
->name
));
1501 /* This is not used. */
1502 PRIV (image_section
) = NULL
;
1503 PRIV (image_offset
) = 0;
1506 PRIV (image_offset
) = sec
->output_offset
+ vma
;
1507 PRIV (image_section
) = sec
->output_section
;
1511 PRIV (image_offset
) = vma
;
1512 PRIV (image_section
) = sec
;
1516 /* Increment image buffer pointer by offset. */
1519 image_inc_ptr (bfd
*abfd
, bfd_vma offset
)
1521 vms_debug2 ((4, "image_inc_ptr (%u)\n", (unsigned)offset
));
1523 PRIV (image_offset
) += offset
;
1526 /* Save current DST location counter under specified index. */
1529 dst_define_location (bfd
*abfd
, unsigned int loc
)
1531 vms_debug2 ((4, "dst_define_location (%d)\n", (int)loc
));
1533 /* Grow the ptr offset table if necessary. */
1534 if (loc
+ 1 > PRIV (dst_ptr_offsets_count
))
1536 PRIV (dst_ptr_offsets
) = bfd_realloc (PRIV (dst_ptr_offsets
),
1537 (loc
+ 1) * sizeof (unsigned int));
1538 PRIV (dst_ptr_offsets_count
) = loc
+ 1;
1541 PRIV (dst_ptr_offsets
)[loc
] = PRIV (image_offset
);
1544 /* Restore saved DST location counter from specified index. */
1547 dst_restore_location (bfd
*abfd
, unsigned int loc
)
1549 vms_debug2 ((4, "dst_restore_location (%d)\n", (int)loc
));
1551 PRIV (image_offset
) = PRIV (dst_ptr_offsets
)[loc
];
1554 /* Retrieve saved DST location counter from specified index. */
1557 dst_retrieve_location (bfd
*abfd
, unsigned int loc
)
1559 vms_debug2 ((4, "dst_retrieve_location (%d)\n", (int)loc
));
1561 return PRIV (dst_ptr_offsets
)[loc
];
1564 /* Write multiple bytes to section image. */
1567 image_write (bfd
*abfd
, unsigned char *ptr
, unsigned int size
)
1570 _bfd_vms_debug (8, "image_write from (%p, %d) to (%ld)\n", ptr
, size
,
1571 (long)PRIV (image_offset
));
1572 _bfd_hexdump (9, ptr
, size
, 0);
1575 if (PRIV (image_section
)->contents
!= NULL
)
1577 asection
*sec
= PRIV (image_section
);
1578 file_ptr off
= PRIV (image_offset
);
1581 if (off
> (file_ptr
)sec
->size
1582 || size
> (file_ptr
)sec
->size
1583 || off
+ size
> (file_ptr
)sec
->size
)
1585 bfd_set_error (bfd_error_bad_value
);
1589 memcpy (sec
->contents
+ off
, ptr
, size
);
1592 PRIV (image_offset
) += size
;
1596 /* Write byte to section image. */
1599 image_write_b (bfd
* abfd
, unsigned int value
)
1601 unsigned char data
[1];
1603 vms_debug2 ((6, "image_write_b (%02x)\n", (int) value
));
1607 return image_write (abfd
, data
, sizeof (data
));
1610 /* Write 2-byte word to image. */
1613 image_write_w (bfd
* abfd
, unsigned int value
)
1615 unsigned char data
[2];
1617 vms_debug2 ((6, "image_write_w (%04x)\n", (int) value
));
1619 bfd_putl16 (value
, data
);
1620 return image_write (abfd
, data
, sizeof (data
));
1623 /* Write 4-byte long to image. */
1626 image_write_l (bfd
* abfd
, unsigned long value
)
1628 unsigned char data
[4];
1630 vms_debug2 ((6, "image_write_l (%08lx)\n", value
));
1632 bfd_putl32 (value
, data
);
1633 return image_write (abfd
, data
, sizeof (data
));
1636 /* Write 8-byte quad to image. */
1639 image_write_q (bfd
* abfd
, bfd_vma value
)
1641 unsigned char data
[8];
1643 vms_debug2 ((6, "image_write_q (%08lx)\n", (unsigned long)value
));
1645 bfd_putl64 (value
, data
);
1646 return image_write (abfd
, data
, sizeof (data
));
1650 _bfd_vms_etir_name (int cmd
)
1654 case ETIR__C_STA_GBL
: return "ETIR__C_STA_GBL";
1655 case ETIR__C_STA_LW
: return "ETIR__C_STA_LW";
1656 case ETIR__C_STA_QW
: return "ETIR__C_STA_QW";
1657 case ETIR__C_STA_PQ
: return "ETIR__C_STA_PQ";
1658 case ETIR__C_STA_LI
: return "ETIR__C_STA_LI";
1659 case ETIR__C_STA_MOD
: return "ETIR__C_STA_MOD";
1660 case ETIR__C_STA_CKARG
: return "ETIR__C_STA_CKARG";
1661 case ETIR__C_STO_B
: return "ETIR__C_STO_B";
1662 case ETIR__C_STO_W
: return "ETIR__C_STO_W";
1663 case ETIR__C_STO_GBL
: return "ETIR__C_STO_GBL";
1664 case ETIR__C_STO_CA
: return "ETIR__C_STO_CA";
1665 case ETIR__C_STO_RB
: return "ETIR__C_STO_RB";
1666 case ETIR__C_STO_AB
: return "ETIR__C_STO_AB";
1667 case ETIR__C_STO_OFF
: return "ETIR__C_STO_OFF";
1668 case ETIR__C_STO_IMM
: return "ETIR__C_STO_IMM";
1669 case ETIR__C_STO_IMMR
: return "ETIR__C_STO_IMMR";
1670 case ETIR__C_STO_LW
: return "ETIR__C_STO_LW";
1671 case ETIR__C_STO_QW
: return "ETIR__C_STO_QW";
1672 case ETIR__C_STO_GBL_LW
: return "ETIR__C_STO_GBL_LW";
1673 case ETIR__C_STO_LP_PSB
: return "ETIR__C_STO_LP_PSB";
1674 case ETIR__C_STO_HINT_GBL
: return "ETIR__C_STO_HINT_GBL";
1675 case ETIR__C_STO_HINT_PS
: return "ETIR__C_STO_HINT_PS";
1676 case ETIR__C_OPR_ADD
: return "ETIR__C_OPR_ADD";
1677 case ETIR__C_OPR_SUB
: return "ETIR__C_OPR_SUB";
1678 case ETIR__C_OPR_INSV
: return "ETIR__C_OPR_INSV";
1679 case ETIR__C_OPR_USH
: return "ETIR__C_OPR_USH";
1680 case ETIR__C_OPR_ROT
: return "ETIR__C_OPR_ROT";
1681 case ETIR__C_OPR_REDEF
: return "ETIR__C_OPR_REDEF";
1682 case ETIR__C_OPR_DFLIT
: return "ETIR__C_OPR_DFLIT";
1683 case ETIR__C_STC_LP
: return "ETIR__C_STC_LP";
1684 case ETIR__C_STC_GBL
: return "ETIR__C_STC_GBL";
1685 case ETIR__C_STC_GCA
: return "ETIR__C_STC_GCA";
1686 case ETIR__C_STC_PS
: return "ETIR__C_STC_PS";
1687 case ETIR__C_STC_NBH_PS
: return "ETIR__C_STC_NBH_PS";
1688 case ETIR__C_STC_NOP_GBL
: return "ETIR__C_STC_NOP_GBL";
1689 case ETIR__C_STC_NOP_PS
: return "ETIR__C_STC_NOP_PS";
1690 case ETIR__C_STC_BSR_GBL
: return "ETIR__C_STC_BSR_GBL";
1691 case ETIR__C_STC_BSR_PS
: return "ETIR__C_STC_BSR_PS";
1692 case ETIR__C_STC_LDA_GBL
: return "ETIR__C_STC_LDA_GBL";
1693 case ETIR__C_STC_LDA_PS
: return "ETIR__C_STC_LDA_PS";
1694 case ETIR__C_STC_BOH_GBL
: return "ETIR__C_STC_BOH_GBL";
1695 case ETIR__C_STC_BOH_PS
: return "ETIR__C_STC_BOH_PS";
1696 case ETIR__C_STC_NBH_GBL
: return "ETIR__C_STC_NBH_GBL";
1697 case ETIR__C_STC_LP_PSB
: return "ETIR__C_STC_LP_PSB";
1698 case ETIR__C_CTL_SETRB
: return "ETIR__C_CTL_SETRB";
1699 case ETIR__C_CTL_AUGRB
: return "ETIR__C_CTL_AUGRB";
1700 case ETIR__C_CTL_DFLOC
: return "ETIR__C_CTL_DFLOC";
1701 case ETIR__C_CTL_STLOC
: return "ETIR__C_CTL_STLOC";
1702 case ETIR__C_CTL_STKDL
: return "ETIR__C_CTL_STKDL";
1705 /* These names have not yet been added to this switch statement. */
1706 _bfd_error_handler (_("unknown ETIR command %d"), cmd
);
1711 #define HIGHBIT(op) ((op & 0x80000000L) == 0x80000000L)
1714 _bfd_vms_get_value (bfd
*abfd
,
1715 const unsigned char *ascic
,
1716 const unsigned char *max_ascic
,
1717 struct bfd_link_info
*info
,
1719 struct alpha_vms_link_hash_entry
**hp
)
1724 struct alpha_vms_link_hash_entry
*h
;
1726 /* Not linking. Do not try to resolve the symbol. */
1735 if (ascic
+ len
>= max_ascic
)
1737 _bfd_error_handler (_("Corrupt vms value"));
1743 for (i
= 0; i
< len
; i
++)
1744 name
[i
] = ascic
[i
+ 1];
1747 h
= (struct alpha_vms_link_hash_entry
*)
1748 bfd_link_hash_lookup (info
->hash
, name
, FALSE
, FALSE
, TRUE
);
1753 && (h
->root
.type
== bfd_link_hash_defined
1754 || h
->root
.type
== bfd_link_hash_defweak
))
1755 *vma
= h
->root
.u
.def
.value
1756 + h
->root
.u
.def
.section
->output_offset
1757 + h
->root
.u
.def
.section
->output_section
->vma
;
1758 else if (h
&& h
->root
.type
== bfd_link_hash_undefweak
)
1762 (*info
->callbacks
->undefined_symbol
)
1763 (info
, name
, abfd
, PRIV (image_section
), PRIV (image_offset
), TRUE
);
1770 #define RELC_SHR_BASE 0x10000
1771 #define RELC_SEC_BASE 0x20000
1772 #define RELC_MASK 0x0ffff
1775 alpha_vms_sym_to_ctxt (struct alpha_vms_link_hash_entry
*h
)
1777 /* Handle undefined symbols. */
1778 if (h
== NULL
|| h
->sym
== NULL
)
1781 if (h
->sym
->typ
== EGSD__C_SYMG
)
1783 if (h
->sym
->flags
& EGSY__V_REL
)
1784 return RELC_SHR_BASE
+ PRIV2 (h
->sym
->owner
, shr_index
);
1787 /* Can this happen (non-relocatable symg) ? I'd like to see
1792 if (h
->sym
->typ
== EGSD__C_SYM
)
1794 if (h
->sym
->flags
& EGSY__V_REL
)
1803 alpha_vms_get_sym_value (asection
*sect
, bfd_vma addr
)
1805 return sect
->output_section
->vma
+ sect
->output_offset
+ addr
;
1809 alpha_vms_fix_sec_rel (bfd
*abfd
, struct bfd_link_info
*info
,
1810 unsigned int rel
, bfd_vma vma
)
1814 if (PRIV (sections
) == NULL
)
1817 sec
= PRIV (sections
)[rel
& RELC_MASK
];
1821 if (sec
->output_section
== NULL
)
1823 return vma
+ sec
->output_section
->vma
+ sec
->output_offset
;
1826 return vma
+ sec
->vma
;
1829 /* Read an ETIR record from ABFD. If INFO is not null, put the content into
1830 the output section (used during linking).
1831 Return FALSE in case of error. */
1834 _bfd_vms_slurp_etir (bfd
*abfd
, struct bfd_link_info
*info
)
1837 unsigned int length
;
1838 unsigned char *maxptr
;
1843 struct alpha_vms_link_hash_entry
*h
;
1845 PRIV (recrd
.rec
) += ETIR__C_HEADER_SIZE
;
1846 PRIV (recrd
.rec_size
) -= ETIR__C_HEADER_SIZE
;
1848 ptr
= PRIV (recrd
.rec
);
1849 length
= PRIV (recrd
.rec_size
);
1850 maxptr
= ptr
+ length
;
1852 vms_debug2 ((2, "ETIR: %d bytes\n", length
));
1854 while (ptr
< maxptr
)
1856 int cmd
= bfd_getl16 (ptr
);
1857 int cmd_length
= bfd_getl16 (ptr
+ 2);
1861 /* PR 21589 and 21579: Check for a corrupt ETIR record. */
1862 if (cmd_length
< 4 || (ptr
+ cmd_length
> maxptr
+ 4))
1865 _bfd_error_handler (_("Corrupt ETIR record encountered"));
1866 bfd_set_error (bfd_error_bad_value
);
1871 _bfd_vms_debug (4, "etir: %s(%d)\n",
1872 _bfd_vms_etir_name (cmd
), cmd
);
1873 _bfd_hexdump (8, ptr
, cmd_length
- 4, 0);
1881 stack 32 bit value of symbol (high bits set to 0). */
1882 case ETIR__C_STA_GBL
:
1883 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
1884 _bfd_vms_push (abfd
, op1
, alpha_vms_sym_to_ctxt (h
));
1890 stack 32 bit value, sign extend to 64 bit. */
1891 case ETIR__C_STA_LW
:
1892 if (ptr
+ 4 >= maxptr
)
1894 _bfd_vms_push (abfd
, bfd_getl32 (ptr
), RELC_NONE
);
1900 stack 64 bit value of symbol. */
1901 case ETIR__C_STA_QW
:
1902 if (ptr
+ 8 >= maxptr
)
1904 _bfd_vms_push (abfd
, bfd_getl64 (ptr
), RELC_NONE
);
1907 /* Stack psect base plus quadword offset
1908 arg: lw section index
1909 qw signed quadword offset (low 32 bits)
1911 Stack qw argument and section index
1912 (see ETIR__C_STO_OFF, ETIR__C_CTL_SETRB). */
1913 case ETIR__C_STA_PQ
:
1917 if (ptr
+ 12 >= maxptr
)
1919 psect
= bfd_getl32 (ptr
);
1920 if ((unsigned int) psect
>= PRIV (section_count
))
1922 _bfd_error_handler (_("bad section index in %s"),
1923 _bfd_vms_etir_name (cmd
));
1924 bfd_set_error (bfd_error_bad_value
);
1927 op1
= bfd_getl64 (ptr
+ 4);
1928 _bfd_vms_push (abfd
, op1
, psect
| RELC_SEC_BASE
);
1932 case ETIR__C_STA_LI
:
1933 case ETIR__C_STA_MOD
:
1934 case ETIR__C_STA_CKARG
:
1935 _bfd_error_handler (_("unsupported STA cmd %s"),
1936 _bfd_vms_etir_name (cmd
));
1940 /* Store byte: pop stack, write byte
1943 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1944 if (rel1
!= RELC_NONE
)
1946 image_write_b (abfd
, (unsigned int) op1
& 0xff);
1949 /* Store word: pop stack, write word
1952 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1953 if (rel1
!= RELC_NONE
)
1955 image_write_w (abfd
, (unsigned int) op1
& 0xffff);
1958 /* Store longword: pop stack, write longword
1960 case ETIR__C_STO_LW
:
1961 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1962 if (rel1
& RELC_SEC_BASE
)
1964 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
1967 else if (rel1
& RELC_SHR_BASE
)
1969 alpha_vms_add_fixup_lr (info
, rel1
& RELC_MASK
, op1
);
1972 if (rel1
!= RELC_NONE
)
1974 if (rel1
!= RELC_REL
)
1976 alpha_vms_add_lw_reloc (info
);
1978 image_write_l (abfd
, op1
);
1981 /* Store quadword: pop stack, write quadword
1983 case ETIR__C_STO_QW
:
1984 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1985 if (rel1
& RELC_SEC_BASE
)
1987 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
1990 else if (rel1
& RELC_SHR_BASE
)
1992 if (rel1
!= RELC_NONE
)
1994 if (rel1
!= RELC_REL
)
1996 alpha_vms_add_qw_reloc (info
);
1998 image_write_q (abfd
, op1
);
2001 /* Store immediate repeated: pop stack for repeat count
2004 case ETIR__C_STO_IMMR
:
2008 if (ptr
+ 4 >= maxptr
)
2010 size
= bfd_getl32 (ptr
);
2011 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2012 if (rel1
!= RELC_NONE
)
2015 image_write (abfd
, ptr
+ 4, size
);
2019 /* Store global: write symbol value
2020 arg: cs global symbol name. */
2021 case ETIR__C_STO_GBL
:
2022 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
2025 if (h
->sym
->typ
== EGSD__C_SYMG
)
2027 alpha_vms_add_fixup_qr
2028 (info
, abfd
, h
->sym
->owner
, h
->sym
->symbol_vector
);
2033 op1
= alpha_vms_get_sym_value (h
->sym
->section
,
2035 alpha_vms_add_qw_reloc (info
);
2038 image_write_q (abfd
, op1
);
2041 /* Store code address: write address of entry point
2042 arg: cs global symbol name (procedure). */
2043 case ETIR__C_STO_CA
:
2044 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
2047 if (h
->sym
->flags
& EGSY__V_NORM
)
2049 /* That's really a procedure. */
2050 if (h
->sym
->typ
== EGSD__C_SYMG
)
2052 alpha_vms_add_fixup_ca (info
, abfd
, h
->sym
->owner
);
2053 op1
= h
->sym
->symbol_vector
;
2057 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
2058 h
->sym
->code_value
);
2059 alpha_vms_add_qw_reloc (info
);
2064 /* Symbol is not a procedure. */
2068 image_write_q (abfd
, op1
);
2071 /* Store offset to psect: pop stack, add low 32 bits to base of psect
2073 case ETIR__C_STO_OFF
:
2074 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2076 if (!(rel1
& RELC_SEC_BASE
))
2079 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2081 image_write_q (abfd
, op1
);
2085 arg: lw count of bytes
2087 case ETIR__C_STO_IMM
:
2091 if (ptr
+ 4 >= maxptr
)
2093 size
= bfd_getl32 (ptr
);
2094 image_write (abfd
, ptr
+ 4, size
);
2098 /* This code is 'reserved to digital' according to the openVMS
2099 linker manual, however it is generated by the DEC C compiler
2100 and defined in the include file.
2101 FIXME, since the following is just a guess
2102 store global longword: store 32bit value of symbol
2103 arg: cs symbol name. */
2104 case ETIR__C_STO_GBL_LW
:
2105 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
2109 image_write_l (abfd
, op1
);
2112 case ETIR__C_STO_RB
:
2113 case ETIR__C_STO_AB
:
2114 case ETIR__C_STO_LP_PSB
:
2115 _bfd_error_handler (_("%s: not supported"),
2116 _bfd_vms_etir_name (cmd
));
2119 case ETIR__C_STO_HINT_GBL
:
2120 case ETIR__C_STO_HINT_PS
:
2121 _bfd_error_handler (_("%s: not implemented"),
2122 _bfd_vms_etir_name (cmd
));
2126 /* 200 Store-conditional Linkage Pair
2128 case ETIR__C_STC_LP
:
2130 /* 202 Store-conditional Address at global address
2134 case ETIR__C_STC_GBL
:
2136 /* 203 Store-conditional Code Address at global address
2138 cs procedure name. */
2139 case ETIR__C_STC_GCA
:
2141 /* 204 Store-conditional Address at psect + offset
2145 case ETIR__C_STC_PS
:
2146 _bfd_error_handler (_("%s: not supported"),
2147 _bfd_vms_etir_name (cmd
));
2151 /* 201 Store-conditional Linkage Pair with Procedure Signature
2157 case ETIR__C_STC_LP_PSB
:
2158 _bfd_vms_get_value (abfd
, ptr
+ 4, maxptr
, info
, &op1
, &h
);
2161 if (h
->sym
->typ
== EGSD__C_SYMG
)
2163 alpha_vms_add_fixup_lp (info
, abfd
, h
->sym
->owner
);
2164 op1
= h
->sym
->symbol_vector
;
2169 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
2170 h
->sym
->code_value
);
2171 op2
= alpha_vms_get_sym_value (h
->sym
->section
,
2177 /* Undefined symbol. */
2181 image_write_q (abfd
, op1
);
2182 image_write_q (abfd
, op2
);
2185 /* 205 Store-conditional NOP at address of global
2187 case ETIR__C_STC_NOP_GBL
:
2190 /* 207 Store-conditional BSR at global address
2193 case ETIR__C_STC_BSR_GBL
:
2196 /* 209 Store-conditional LDA at global address
2199 case ETIR__C_STC_LDA_GBL
:
2202 /* 211 Store-conditional BSR or Hint at global address
2205 case ETIR__C_STC_BOH_GBL
:
2206 /* Currentl ignored. */
2209 /* 213 Store-conditional NOP,BSR or HINT at global address
2212 case ETIR__C_STC_NBH_GBL
:
2214 /* 206 Store-conditional NOP at pect + offset
2217 case ETIR__C_STC_NOP_PS
:
2219 /* 208 Store-conditional BSR at pect + offset
2222 case ETIR__C_STC_BSR_PS
:
2224 /* 210 Store-conditional LDA at psect + offset
2227 case ETIR__C_STC_LDA_PS
:
2229 /* 212 Store-conditional BSR or Hint at pect + offset
2232 case ETIR__C_STC_BOH_PS
:
2234 /* 214 Store-conditional NOP, BSR or HINT at psect + offset
2236 case ETIR__C_STC_NBH_PS
:
2237 _bfd_error_handler (_("%s: not supported"),
2238 _bfd_vms_etir_name (cmd
));
2242 /* Det relocation base: pop stack, set image location counter
2244 case ETIR__C_CTL_SETRB
:
2245 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2246 if (!(rel1
& RELC_SEC_BASE
))
2248 image_set_ptr (abfd
, op1
, rel1
& RELC_MASK
, info
);
2251 /* Augment relocation base: increment image location counter by offset
2252 arg: lw offset value. */
2253 case ETIR__C_CTL_AUGRB
:
2254 if (ptr
+ 4 >= maxptr
)
2256 op1
= bfd_getl32 (ptr
);
2257 image_inc_ptr (abfd
, op1
);
2260 /* Define location: pop index, save location counter under index
2262 case ETIR__C_CTL_DFLOC
:
2263 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2264 if (rel1
!= RELC_NONE
)
2266 dst_define_location (abfd
, op1
);
2269 /* Set location: pop index, restore location counter from index
2271 case ETIR__C_CTL_STLOC
:
2272 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2273 if (rel1
!= RELC_NONE
)
2275 dst_restore_location (abfd
, op1
);
2278 /* Stack defined location: pop index, push location counter from index
2280 case ETIR__C_CTL_STKDL
:
2281 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2282 if (rel1
!= RELC_NONE
)
2284 _bfd_vms_push (abfd
, dst_retrieve_location (abfd
, op1
), RELC_NONE
);
2287 case ETIR__C_OPR_NOP
: /* No-op. */
2290 case ETIR__C_OPR_ADD
: /* Add. */
2291 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2292 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2293 if (rel1
== RELC_NONE
&& rel2
!= RELC_NONE
)
2295 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2297 _bfd_vms_push (abfd
, op1
+ op2
, rel1
);
2300 case ETIR__C_OPR_SUB
: /* Subtract. */
2301 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2302 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2303 if (rel1
== RELC_NONE
&& rel2
!= RELC_NONE
)
2305 else if ((rel1
& RELC_SEC_BASE
) && (rel2
& RELC_SEC_BASE
))
2307 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2308 op2
= alpha_vms_fix_sec_rel (abfd
, info
, rel2
, op2
);
2311 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2313 _bfd_vms_push (abfd
, op2
- op1
, rel1
);
2316 case ETIR__C_OPR_MUL
: /* Multiply. */
2317 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2318 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2319 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2321 _bfd_vms_push (abfd
, op1
* op2
, RELC_NONE
);
2324 case ETIR__C_OPR_DIV
: /* Divide. */
2325 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2326 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2327 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2330 _bfd_vms_push (abfd
, 0, RELC_NONE
);
2332 _bfd_vms_push (abfd
, op2
/ op1
, RELC_NONE
);
2335 case ETIR__C_OPR_AND
: /* Logical AND. */
2336 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2337 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2338 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2340 _bfd_vms_push (abfd
, op1
& op2
, RELC_NONE
);
2343 case ETIR__C_OPR_IOR
: /* Logical inclusive OR. */
2344 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2345 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2346 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2348 _bfd_vms_push (abfd
, op1
| op2
, RELC_NONE
);
2351 case ETIR__C_OPR_EOR
: /* Logical exclusive OR. */
2352 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2353 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2354 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2356 _bfd_vms_push (abfd
, op1
^ op2
, RELC_NONE
);
2359 case ETIR__C_OPR_NEG
: /* Negate. */
2360 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2361 if (rel1
!= RELC_NONE
)
2363 _bfd_vms_push (abfd
, -op1
, RELC_NONE
);
2366 case ETIR__C_OPR_COM
: /* Complement. */
2367 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2368 if (rel1
!= RELC_NONE
)
2370 _bfd_vms_push (abfd
, ~op1
, RELC_NONE
);
2373 case ETIR__C_OPR_ASH
: /* Arithmetic shift. */
2374 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2375 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2376 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2379 _bfd_error_handler (_("invalid use of %s with contexts"),
2380 _bfd_vms_etir_name (cmd
));
2383 if ((int)op2
< 0) /* Shift right. */
2385 else /* Shift left. */
2387 _bfd_vms_push (abfd
, op1
, RELC_NONE
); /* FIXME: sym. */
2390 case ETIR__C_OPR_INSV
: /* Insert field. */
2391 case ETIR__C_OPR_USH
: /* Unsigned shift. */
2392 case ETIR__C_OPR_ROT
: /* Rotate. */
2393 case ETIR__C_OPR_REDEF
: /* Redefine symbol to current location. */
2394 case ETIR__C_OPR_DFLIT
: /* Define a literal. */
2395 _bfd_error_handler (_("%s: not supported"),
2396 _bfd_vms_etir_name (cmd
));
2400 case ETIR__C_OPR_SEL
: /* Select. */
2401 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2403 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2406 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2407 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2408 _bfd_vms_push (abfd
, op1
, rel1
);
2413 _bfd_error_handler (_("reserved cmd %d"), cmd
);
2418 ptr
+= cmd_length
- 4;
2424 /* Process EDBG/ETBT record.
2425 Return TRUE on success, FALSE on error */
2428 vms_slurp_debug (bfd
*abfd
)
2430 asection
*section
= PRIV (dst_section
);
2432 if (section
== NULL
)
2434 /* We have no way to find out beforehand how much debug info there
2435 is in an object file, so pick an initial amount and grow it as
2437 flagword flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
| SEC_RELOC
2440 section
= bfd_make_section (abfd
, "$DST$");
2443 if (!bfd_set_section_flags (abfd
, section
, flags
))
2445 PRIV (dst_section
) = section
;
2448 PRIV (image_section
) = section
;
2449 PRIV (image_offset
) = section
->size
;
2451 if (!_bfd_vms_slurp_etir (abfd
, NULL
))
2454 section
->size
= PRIV (image_offset
);
2458 /* Process EDBG record.
2459 Return TRUE on success, FALSE on error. */
2462 _bfd_vms_slurp_edbg (bfd
*abfd
)
2464 vms_debug2 ((2, "EDBG\n"));
2466 abfd
->flags
|= HAS_DEBUG
| HAS_LINENO
;
2468 return vms_slurp_debug (abfd
);
2471 /* Process ETBT record.
2472 Return TRUE on success, FALSE on error. */
2475 _bfd_vms_slurp_etbt (bfd
*abfd
)
2477 vms_debug2 ((2, "ETBT\n"));
2479 abfd
->flags
|= HAS_LINENO
;
2481 return vms_slurp_debug (abfd
);
2484 /* Process EEOM record.
2485 Return TRUE on success, FALSE on error. */
2488 _bfd_vms_slurp_eeom (bfd
*abfd
)
2490 struct vms_eeom
*eeom
= (struct vms_eeom
*) PRIV (recrd
.rec
);
2492 vms_debug2 ((2, "EEOM\n"));
2494 /* PR 21813: Check for an undersized record. */
2495 if (PRIV (recrd
.buf_size
) < sizeof (* eeom
))
2497 _bfd_error_handler (_("Corrupt EEOM record - size is too small"));
2498 bfd_set_error (bfd_error_bad_value
);
2502 PRIV (eom_data
).eom_l_total_lps
= bfd_getl32 (eeom
->total_lps
);
2503 PRIV (eom_data
).eom_w_comcod
= bfd_getl16 (eeom
->comcod
);
2504 if (PRIV (eom_data
).eom_w_comcod
> 1)
2506 _bfd_error_handler (_("Object module NOT error-free !\n"));
2507 bfd_set_error (bfd_error_bad_value
);
2511 PRIV (eom_data
).eom_has_transfer
= FALSE
;
2512 if (PRIV (recrd
.rec_size
) > 10)
2514 PRIV (eom_data
).eom_has_transfer
= TRUE
;
2515 PRIV (eom_data
).eom_b_tfrflg
= eeom
->tfrflg
;
2516 PRIV (eom_data
).eom_l_psindx
= bfd_getl32 (eeom
->psindx
);
2517 PRIV (eom_data
).eom_l_tfradr
= bfd_getl32 (eeom
->tfradr
);
2519 abfd
->start_address
= PRIV (eom_data
).eom_l_tfradr
;
2524 /* Slurp an ordered set of VMS object records. Return FALSE on error. */
2527 _bfd_vms_slurp_object_records (bfd
* abfd
)
2534 vms_debug2 ((7, "reading at %08lx\n", (unsigned long)bfd_tell (abfd
)));
2536 type
= _bfd_vms_get_object_record (abfd
);
2539 vms_debug2 ((2, "next_record failed\n"));
2546 err
= _bfd_vms_slurp_ehdr (abfd
);
2549 err
= _bfd_vms_slurp_eeom (abfd
);
2552 err
= _bfd_vms_slurp_egsd (abfd
);
2555 err
= TRUE
; /* _bfd_vms_slurp_etir (abfd); */
2558 err
= _bfd_vms_slurp_edbg (abfd
);
2561 err
= _bfd_vms_slurp_etbt (abfd
);
2568 vms_debug2 ((2, "slurp type %d failed\n", type
));
2572 while (type
!= EOBJ__C_EEOM
);
2577 /* Initialize private data */
2579 vms_initialize (bfd
* abfd
)
2583 amt
= sizeof (struct vms_private_data_struct
);
2584 abfd
->tdata
.any
= bfd_zalloc (abfd
, amt
);
2585 if (abfd
->tdata
.any
== NULL
)
2588 PRIV (recrd
.file_format
) = FF_UNKNOWN
;
2590 amt
= sizeof (struct stack_struct
) * STACKSIZE
;
2591 PRIV (stack
) = bfd_alloc (abfd
, amt
);
2592 if (PRIV (stack
) == NULL
)
2598 bfd_release (abfd
, abfd
->tdata
.any
);
2599 abfd
->tdata
.any
= NULL
;
2603 /* Check the format for a file being read.
2604 Return a (bfd_target *) if it's an object file or zero if not. */
2606 static const struct bfd_target
*
2607 alpha_vms_object_p (bfd
*abfd
)
2609 void *tdata_save
= abfd
->tdata
.any
;
2610 unsigned int test_len
;
2613 vms_debug2 ((1, "vms_object_p(%p)\n", abfd
));
2615 /* Allocate alpha-vms specific data. */
2616 if (!vms_initialize (abfd
))
2619 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
))
2620 goto err_wrong_format
;
2622 /* The first challenge with VMS is to discover the kind of the file.
2624 Image files (executable or shared images) are stored as a raw
2625 stream of bytes (like on UNIX), but there is no magic number.
2627 Object files are written with RMS (record management service), ie
2628 each records are preceeded by its length (on a word - 2 bytes), and
2629 padded for word-alignment. That would be simple but when files
2630 are transfered to a UNIX filesystem (using ftp), records are lost.
2631 Only the raw content of the records are transfered. Fortunately,
2632 the Alpha Object file format also store the length of the record
2633 in the records. Is that clear ? */
2635 /* Minimum is 6 bytes for objects (2 bytes size, 2 bytes record id,
2636 2 bytes size repeated) and 12 bytes for images (4 bytes major id,
2637 4 bytes minor id, 4 bytes length). */
2640 /* Size the main buffer. */
2641 buf
= (unsigned char *) bfd_malloc (test_len
);
2644 PRIV (recrd
.buf
) = buf
;
2645 PRIV (recrd
.buf_size
) = test_len
;
2647 /* Initialize the record pointer. */
2648 PRIV (recrd
.rec
) = buf
;
2650 if (bfd_bread (buf
, test_len
, abfd
) != test_len
)
2651 goto err_wrong_format
;
2653 /* Is it an image? */
2654 if ((bfd_getl32 (buf
) == EIHD__K_MAJORID
)
2655 && (bfd_getl32 (buf
+ 4) == EIHD__K_MINORID
))
2657 unsigned int to_read
;
2658 unsigned int read_so_far
;
2659 unsigned int remaining
;
2660 unsigned int eisd_offset
, eihs_offset
;
2662 /* Extract the header size. */
2663 PRIV (recrd
.rec_size
) = bfd_getl32 (buf
+ EIHD__L_SIZE
);
2665 /* The header size is 0 for DSF files. */
2666 if (PRIV (recrd
.rec_size
) == 0)
2667 PRIV (recrd
.rec_size
) = sizeof (struct vms_eihd
);
2669 if (PRIV (recrd
.rec_size
) > PRIV (recrd
.buf_size
))
2671 buf
= bfd_realloc_or_free (buf
, PRIV (recrd
.rec_size
));
2675 PRIV (recrd
.buf
) = NULL
;
2678 PRIV (recrd
.buf
) = buf
;
2679 PRIV (recrd
.buf_size
) = PRIV (recrd
.rec_size
);
2682 /* PR 21813: Check for a truncated record. */
2683 if (PRIV (recrd
.rec_size
< test_len
))
2685 /* Read the remaining record. */
2686 remaining
= PRIV (recrd
.rec_size
) - test_len
;
2687 to_read
= MIN (VMS_BLOCK_SIZE
- test_len
, remaining
);
2688 read_so_far
= test_len
;
2690 while (remaining
> 0)
2692 if (bfd_bread (buf
+ read_so_far
, to_read
, abfd
) != to_read
)
2693 goto err_wrong_format
;
2695 read_so_far
+= to_read
;
2696 remaining
-= to_read
;
2698 to_read
= MIN (VMS_BLOCK_SIZE
, remaining
);
2701 /* Reset the record pointer. */
2702 PRIV (recrd
.rec
) = buf
;
2704 /* PR 17512: file: 7d7c57c2. */
2705 if (PRIV (recrd
.rec_size
) < sizeof (struct vms_eihd
))
2707 vms_debug2 ((2, "file type is image\n"));
2709 if (!_bfd_vms_slurp_eihd (abfd
, &eisd_offset
, &eihs_offset
))
2710 goto err_wrong_format
;
2712 if (!_bfd_vms_slurp_eisd (abfd
, eisd_offset
))
2713 goto err_wrong_format
;
2715 /* EIHS is optional. */
2716 if (eihs_offset
!= 0 && !_bfd_vms_slurp_eihs (abfd
, eihs_offset
))
2717 goto err_wrong_format
;
2723 /* Assume it's a module and adjust record pointer if necessary. */
2724 maybe_adjust_record_pointer_for_object (abfd
);
2726 /* But is it really a module? */
2727 if (bfd_getl16 (PRIV (recrd
.rec
)) <= EOBJ__C_MAXRECTYP
2728 && bfd_getl16 (PRIV (recrd
.rec
) + 2) <= EOBJ__C_MAXRECSIZ
)
2730 if (vms_get_remaining_object_record (abfd
, test_len
) <= 0)
2731 goto err_wrong_format
;
2733 vms_debug2 ((2, "file type is module\n"));
2735 type
= bfd_getl16 (PRIV (recrd
.rec
));
2736 if (type
!= EOBJ__C_EMH
|| !_bfd_vms_slurp_ehdr (abfd
))
2737 goto err_wrong_format
;
2739 if (!_bfd_vms_slurp_object_records (abfd
))
2740 goto err_wrong_format
;
2743 goto err_wrong_format
;
2746 /* Set arch_info to alpha. */
2748 if (! bfd_default_set_arch_mach (abfd
, bfd_arch_alpha
, 0))
2749 goto err_wrong_format
;
2754 bfd_set_error (bfd_error_wrong_format
);
2757 if (PRIV (recrd
.buf
))
2758 free (PRIV (recrd
.buf
));
2759 if (abfd
->tdata
.any
!= tdata_save
&& abfd
->tdata
.any
!= NULL
)
2760 bfd_release (abfd
, abfd
->tdata
.any
);
2761 abfd
->tdata
.any
= tdata_save
;
2767 /* Write an EMH/MHD record. */
2770 _bfd_vms_write_emh (bfd
*abfd
)
2772 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2774 _bfd_vms_output_alignment (recwr
, 2);
2777 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
2778 _bfd_vms_output_short (recwr
, EMH__C_MHD
);
2779 _bfd_vms_output_short (recwr
, EOBJ__C_STRLVL
);
2780 _bfd_vms_output_long (recwr
, 0);
2781 _bfd_vms_output_long (recwr
, 0);
2782 _bfd_vms_output_long (recwr
, MAX_OUTREC_SIZE
);
2784 /* Create module name from filename. */
2785 if (bfd_get_filename (abfd
) != 0)
2787 char *module
= vms_get_module_name (bfd_get_filename (abfd
), TRUE
);
2788 _bfd_vms_output_counted (recwr
, module
);
2792 _bfd_vms_output_counted (recwr
, "NONAME");
2794 _bfd_vms_output_counted (recwr
, BFD_VERSION_STRING
);
2795 _bfd_vms_output_dump (recwr
, get_vms_time_string (), EMH_DATE_LENGTH
);
2796 _bfd_vms_output_fill (recwr
, 0, EMH_DATE_LENGTH
);
2797 _bfd_vms_output_end (abfd
, recwr
);
2800 /* Write an EMH/LMN record. */
2803 _bfd_vms_write_lmn (bfd
*abfd
, const char *name
)
2806 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2807 unsigned int ver
= BFD_VERSION
/ 10000;
2810 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
2811 _bfd_vms_output_short (recwr
, EMH__C_LNM
);
2812 snprintf (version
, sizeof (version
), "%s %d.%d.%d", name
,
2813 ver
/ 10000, (ver
/ 100) % 100, ver
% 100);
2814 _bfd_vms_output_dump (recwr
, (unsigned char *)version
, strlen (version
));
2815 _bfd_vms_output_end (abfd
, recwr
);
2819 /* Write eom record for bfd abfd. Return FALSE on error. */
2822 _bfd_vms_write_eeom (bfd
*abfd
)
2824 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2826 vms_debug2 ((2, "vms_write_eeom\n"));
2828 _bfd_vms_output_alignment (recwr
, 2);
2830 _bfd_vms_output_begin (recwr
, EOBJ__C_EEOM
);
2831 _bfd_vms_output_long (recwr
, PRIV (vms_linkage_index
+ 1) >> 1);
2832 _bfd_vms_output_byte (recwr
, 0); /* Completion code. */
2833 _bfd_vms_output_byte (recwr
, 0); /* Fill byte. */
2835 if ((abfd
->flags
& EXEC_P
) == 0
2836 && bfd_get_start_address (abfd
) != (bfd_vma
)-1)
2840 section
= bfd_get_section_by_name (abfd
, ".link");
2843 bfd_set_error (bfd_error_nonrepresentable_section
);
2846 _bfd_vms_output_short (recwr
, 0);
2847 _bfd_vms_output_long (recwr
, (unsigned long) section
->target_index
);
2848 _bfd_vms_output_long (recwr
,
2849 (unsigned long) bfd_get_start_address (abfd
));
2850 _bfd_vms_output_long (recwr
, 0);
2853 _bfd_vms_output_end (abfd
, recwr
);
2858 vector_grow1 (struct vector_type
*vec
, size_t elsz
)
2860 if (vec
->nbr_el
+ 1 < vec
->max_el
)
2863 if (vec
->max_el
== 0)
2866 vec
->els
= bfd_malloc2 (vec
->max_el
, elsz
);
2871 vec
->els
= bfd_realloc2 (vec
->els
, vec
->max_el
, elsz
);
2875 /* Bump ABFD file position to next block. */
2878 alpha_vms_file_position_block (bfd
*abfd
)
2881 PRIV (file_pos
) += VMS_BLOCK_SIZE
- 1;
2882 PRIV (file_pos
) -= (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
2885 /* Convert from internal structure SRC to external structure DST. */
2888 alpha_vms_swap_eisd_out (struct vms_internal_eisd_map
*src
,
2889 struct vms_eisd
*dst
)
2891 bfd_putl32 (src
->u
.eisd
.majorid
, dst
->majorid
);
2892 bfd_putl32 (src
->u
.eisd
.minorid
, dst
->minorid
);
2893 bfd_putl32 (src
->u
.eisd
.eisdsize
, dst
->eisdsize
);
2894 if (src
->u
.eisd
.eisdsize
<= EISD__K_LENEND
)
2896 bfd_putl32 (src
->u
.eisd
.secsize
, dst
->secsize
);
2897 bfd_putl64 (src
->u
.eisd
.virt_addr
, dst
->virt_addr
);
2898 bfd_putl32 (src
->u
.eisd
.flags
, dst
->flags
);
2899 bfd_putl32 (src
->u
.eisd
.vbn
, dst
->vbn
);
2900 dst
->pfc
= src
->u
.eisd
.pfc
;
2901 dst
->matchctl
= src
->u
.eisd
.matchctl
;
2902 dst
->type
= src
->u
.eisd
.type
;
2904 if (src
->u
.eisd
.flags
& EISD__M_GBL
)
2906 bfd_putl32 (src
->u
.gbl_eisd
.ident
, dst
->ident
);
2907 memcpy (dst
->gblnam
, src
->u
.gbl_eisd
.gblnam
,
2908 src
->u
.gbl_eisd
.gblnam
[0] + 1);
2912 /* Append EISD to the list of extra eisd for ABFD. */
2915 alpha_vms_append_extra_eisd (bfd
*abfd
, struct vms_internal_eisd_map
*eisd
)
2918 if (PRIV (gbl_eisd_head
) == NULL
)
2919 PRIV (gbl_eisd_head
) = eisd
;
2921 PRIV (gbl_eisd_tail
)->next
= eisd
;
2922 PRIV (gbl_eisd_tail
) = eisd
;
2925 /* Create an EISD for shared image SHRIMG.
2926 Return FALSE in case of error. */
2929 alpha_vms_create_eisd_for_shared (bfd
*abfd
, bfd
*shrimg
)
2931 struct vms_internal_eisd_map
*eisd
;
2934 namlen
= strlen (PRIV2 (shrimg
, hdr_data
.hdr_t_name
));
2935 if (namlen
+ 5 > EISD__K_GBLNAMLEN
)
2941 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
2945 /* Fill the fields. */
2946 eisd
->u
.gbl_eisd
.common
.majorid
= EISD__K_MAJORID
;
2947 eisd
->u
.gbl_eisd
.common
.minorid
= EISD__K_MINORID
;
2948 eisd
->u
.gbl_eisd
.common
.eisdsize
= (EISD__K_LEN
+ 4 + namlen
+ 5 + 3) & ~3;
2949 eisd
->u
.gbl_eisd
.common
.secsize
= VMS_BLOCK_SIZE
; /* Must not be 0. */
2950 eisd
->u
.gbl_eisd
.common
.virt_addr
= 0;
2951 eisd
->u
.gbl_eisd
.common
.flags
= EISD__M_GBL
;
2952 eisd
->u
.gbl_eisd
.common
.vbn
= 0;
2953 eisd
->u
.gbl_eisd
.common
.pfc
= 0;
2954 eisd
->u
.gbl_eisd
.common
.matchctl
= PRIV2 (shrimg
, matchctl
);
2955 eisd
->u
.gbl_eisd
.common
.type
= EISD__K_SHRPIC
;
2957 eisd
->u
.gbl_eisd
.ident
= PRIV2 (shrimg
, ident
);
2958 eisd
->u
.gbl_eisd
.gblnam
[0] = namlen
+ 4;
2959 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1, PRIV2 (shrimg
, hdr_data
.hdr_t_name
),
2961 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1 + namlen
, "_001", 4);
2963 /* Append it to the list. */
2964 alpha_vms_append_extra_eisd (abfd
, eisd
);
2969 /* Create an EISD for section SEC.
2970 Return FALSE in case of failure. */
2973 alpha_vms_create_eisd_for_section (bfd
*abfd
, asection
*sec
)
2975 struct vms_internal_eisd_map
*eisd
;
2977 /* Only for allocating section. */
2978 if (!(sec
->flags
& SEC_ALLOC
))
2981 BFD_ASSERT (vms_section_data (sec
)->eisd
== NULL
);
2982 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
2985 vms_section_data (sec
)->eisd
= eisd
;
2987 /* Fill the fields. */
2988 eisd
->u
.eisd
.majorid
= EISD__K_MAJORID
;
2989 eisd
->u
.eisd
.minorid
= EISD__K_MINORID
;
2990 eisd
->u
.eisd
.eisdsize
= EISD__K_LEN
;
2991 eisd
->u
.eisd
.secsize
=
2992 (sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
2993 eisd
->u
.eisd
.virt_addr
= sec
->vma
;
2994 eisd
->u
.eisd
.flags
= 0;
2995 eisd
->u
.eisd
.vbn
= 0; /* To be later defined. */
2996 eisd
->u
.eisd
.pfc
= 0; /* Default. */
2997 eisd
->u
.eisd
.matchctl
= EISD__K_MATALL
;
2998 eisd
->u
.eisd
.type
= EISD__K_NORMAL
;
3000 if (sec
->flags
& SEC_CODE
)
3001 eisd
->u
.eisd
.flags
|= EISD__M_EXE
;
3002 if (!(sec
->flags
& SEC_READONLY
))
3003 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
3005 /* If relocations or fixup will be applied, make this isect writeable. */
3006 if (sec
->flags
& SEC_RELOC
)
3007 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
3009 if (!(sec
->flags
& SEC_HAS_CONTENTS
))
3011 eisd
->u
.eisd
.flags
|= EISD__M_DZRO
;
3012 eisd
->u
.eisd
.flags
&= ~EISD__M_CRF
;
3014 if (sec
->flags
& SEC_LINKER_CREATED
)
3016 if (strcmp (sec
->name
, "$FIXUP$") == 0)
3017 eisd
->u
.eisd
.flags
|= EISD__M_FIXUPVEC
;
3020 /* Append it to the list. */
3022 if (PRIV (eisd_head
) == NULL
)
3023 PRIV (eisd_head
) = eisd
;
3025 PRIV (eisd_tail
)->next
= eisd
;
3026 PRIV (eisd_tail
) = eisd
;
3031 /* Layout executable ABFD and write it to the disk.
3032 Return FALSE in case of failure. */
3035 alpha_vms_write_exec (bfd
*abfd
)
3037 struct vms_eihd eihd
;
3038 struct vms_eiha
*eiha
;
3039 struct vms_eihi
*eihi
;
3040 struct vms_eihs
*eihs
= NULL
;
3042 struct vms_internal_eisd_map
*first_eisd
;
3043 struct vms_internal_eisd_map
*eisd
;
3046 file_ptr gst_filepos
= 0;
3047 unsigned int lnkflags
= 0;
3049 /* Build the EIHD. */
3050 PRIV (file_pos
) = EIHD__C_LENGTH
;
3052 memset (&eihd
, 0, sizeof (eihd
));
3053 memset (eihd
.fill_2
, 0xff, sizeof (eihd
.fill_2
));
3055 bfd_putl32 (EIHD__K_MAJORID
, eihd
.majorid
);
3056 bfd_putl32 (EIHD__K_MINORID
, eihd
.minorid
);
3058 bfd_putl32 (sizeof (eihd
), eihd
.size
);
3059 bfd_putl32 (0, eihd
.isdoff
);
3060 bfd_putl32 (0, eihd
.activoff
);
3061 bfd_putl32 (0, eihd
.symdbgoff
);
3062 bfd_putl32 (0, eihd
.imgidoff
);
3063 bfd_putl32 (0, eihd
.patchoff
);
3064 bfd_putl64 (0, eihd
.iafva
);
3065 bfd_putl32 (0, eihd
.version_array_off
);
3067 bfd_putl32 (EIHD__K_EXE
, eihd
.imgtype
);
3068 bfd_putl32 (0, eihd
.subtype
);
3070 bfd_putl32 (0, eihd
.imgiocnt
);
3071 bfd_putl32 (-1, eihd
.privreqs
);
3072 bfd_putl32 (-1, eihd
.privreqs
+ 4);
3074 bfd_putl32 ((sizeof (eihd
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
3076 bfd_putl32 (0, eihd
.ident
);
3077 bfd_putl32 (0, eihd
.sysver
);
3080 bfd_putl32 (0, eihd
.symvect_size
);
3081 bfd_putl32 (16, eihd
.virt_mem_block_size
);
3082 bfd_putl32 (0, eihd
.ext_fixup_off
);
3083 bfd_putl32 (0, eihd
.noopt_psect_off
);
3084 bfd_putl32 (-1, eihd
.alias
);
3087 eiha
= (struct vms_eiha
*)((char *) &eihd
+ PRIV (file_pos
));
3088 bfd_putl32 (PRIV (file_pos
), eihd
.activoff
);
3089 PRIV (file_pos
) += sizeof (struct vms_eiha
);
3091 bfd_putl32 (sizeof (struct vms_eiha
), eiha
->size
);
3092 bfd_putl32 (0, eiha
->spare
);
3093 bfd_putl64 (PRIV (transfer_address
[0]), eiha
->tfradr1
);
3094 bfd_putl64 (PRIV (transfer_address
[1]), eiha
->tfradr2
);
3095 bfd_putl64 (PRIV (transfer_address
[2]), eiha
->tfradr3
);
3096 bfd_putl64 (PRIV (transfer_address
[3]), eiha
->tfradr4
);
3097 bfd_putl64 (0, eiha
->inishr
);
3100 eihi
= (struct vms_eihi
*)((char *) &eihd
+ PRIV (file_pos
));
3101 bfd_putl32 (PRIV (file_pos
), eihd
.imgidoff
);
3102 PRIV (file_pos
) += sizeof (struct vms_eihi
);
3104 bfd_putl32 (EIHI__K_MAJORID
, eihi
->majorid
);
3105 bfd_putl32 (EIHI__K_MINORID
, eihi
->minorid
);
3110 /* Set module name. */
3111 module
= vms_get_module_name (bfd_get_filename (abfd
), TRUE
);
3112 len
= strlen (module
);
3113 if (len
> sizeof (eihi
->imgnam
) - 1)
3114 len
= sizeof (eihi
->imgnam
) - 1;
3115 eihi
->imgnam
[0] = len
;
3116 memcpy (eihi
->imgnam
+ 1, module
, len
);
3124 vms_get_time (&hi
, &lo
);
3125 bfd_putl32 (lo
, eihi
->linktime
+ 0);
3126 bfd_putl32 (hi
, eihi
->linktime
+ 4);
3129 eihi
->linkid
[0] = 0;
3130 eihi
->imgbid
[0] = 0;
3133 dst
= PRIV (dst_section
);
3134 dmt
= bfd_get_section_by_name (abfd
, "$DMT$");
3135 if (dst
!= NULL
&& dst
->size
!= 0)
3137 eihs
= (struct vms_eihs
*)((char *) &eihd
+ PRIV (file_pos
));
3138 bfd_putl32 (PRIV (file_pos
), eihd
.symdbgoff
);
3139 PRIV (file_pos
) += sizeof (struct vms_eihs
);
3141 bfd_putl32 (EIHS__K_MAJORID
, eihs
->majorid
);
3142 bfd_putl32 (EIHS__K_MINORID
, eihs
->minorid
);
3143 bfd_putl32 (0, eihs
->dstvbn
);
3144 bfd_putl32 (0, eihs
->dstsize
);
3145 bfd_putl32 (0, eihs
->gstvbn
);
3146 bfd_putl32 (0, eihs
->gstsize
);
3147 bfd_putl32 (0, eihs
->dmtvbn
);
3148 bfd_putl32 (0, eihs
->dmtsize
);
3151 /* One EISD per section. */
3152 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3154 if (!alpha_vms_create_eisd_for_section (abfd
, sec
))
3158 /* Merge section EIDS which extra ones. */
3159 if (PRIV (eisd_tail
))
3160 PRIV (eisd_tail
)->next
= PRIV (gbl_eisd_head
);
3162 PRIV (eisd_head
) = PRIV (gbl_eisd_head
);
3163 if (PRIV (gbl_eisd_tail
))
3164 PRIV (eisd_tail
) = PRIV (gbl_eisd_tail
);
3166 first_eisd
= PRIV (eisd_head
);
3168 /* Add end of eisd. */
3171 eisd
= bfd_zalloc (abfd
, sizeof (*eisd
));
3174 eisd
->u
.eisd
.majorid
= 0;
3175 eisd
->u
.eisd
.minorid
= 0;
3176 eisd
->u
.eisd
.eisdsize
= 0;
3177 alpha_vms_append_extra_eisd (abfd
, eisd
);
3180 /* Place EISD in the file. */
3181 for (eisd
= first_eisd
; eisd
; eisd
= eisd
->next
)
3183 file_ptr room
= VMS_BLOCK_SIZE
- (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
3185 /* First block is a little bit special: there is a word at the end. */
3186 if (PRIV (file_pos
) < VMS_BLOCK_SIZE
&& room
> 2)
3188 if (room
< eisd
->u
.eisd
.eisdsize
+ EISD__K_LENEND
)
3189 alpha_vms_file_position_block (abfd
);
3191 eisd
->file_pos
= PRIV (file_pos
);
3192 PRIV (file_pos
) += eisd
->u
.eisd
.eisdsize
;
3194 if (eisd
->u
.eisd
.flags
& EISD__M_FIXUPVEC
)
3195 bfd_putl64 (eisd
->u
.eisd
.virt_addr
, eihd
.iafva
);
3198 if (first_eisd
!= NULL
)
3200 bfd_putl32 (first_eisd
->file_pos
, eihd
.isdoff
);
3201 /* Real size of end of eisd marker. */
3202 PRIV (file_pos
) += EISD__K_LENEND
;
3205 bfd_putl32 (PRIV (file_pos
), eihd
.size
);
3206 bfd_putl32 ((PRIV (file_pos
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
3209 /* Place sections. */
3210 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3212 if (!(sec
->flags
& SEC_HAS_CONTENTS
))
3215 eisd
= vms_section_data (sec
)->eisd
;
3217 /* Align on a block. */
3218 alpha_vms_file_position_block (abfd
);
3219 sec
->filepos
= PRIV (file_pos
);
3222 eisd
->u
.eisd
.vbn
= (sec
->filepos
/ VMS_BLOCK_SIZE
) + 1;
3224 PRIV (file_pos
) += sec
->size
;
3228 if (eihs
!= NULL
&& dst
!= NULL
)
3230 bfd_putl32 ((dst
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dstvbn
);
3231 bfd_putl32 (dst
->size
, eihs
->dstsize
);
3235 lnkflags
|= EIHD__M_DBGDMT
;
3236 bfd_putl32 ((dmt
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dmtvbn
);
3237 bfd_putl32 (dmt
->size
, eihs
->dmtsize
);
3239 if (PRIV (gsd_sym_count
) != 0)
3241 alpha_vms_file_position_block (abfd
);
3242 gst_filepos
= PRIV (file_pos
);
3243 bfd_putl32 ((gst_filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->gstvbn
);
3244 bfd_putl32 ((PRIV (gsd_sym_count
) + 4) / 5 + 4, eihs
->gstsize
);
3248 /* Write EISD in hdr. */
3249 for (eisd
= first_eisd
; eisd
&& eisd
->file_pos
< VMS_BLOCK_SIZE
;
3251 alpha_vms_swap_eisd_out
3252 (eisd
, (struct vms_eisd
*)((char *)&eihd
+ eisd
->file_pos
));
3254 /* Write first block. */
3255 bfd_putl32 (lnkflags
, eihd
.lnkflags
);
3256 if (bfd_bwrite (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
3259 /* Write remaining eisd. */
3262 unsigned char blk
[VMS_BLOCK_SIZE
];
3263 struct vms_internal_eisd_map
*next_eisd
;
3265 memset (blk
, 0xff, sizeof (blk
));
3266 while (eisd
!= NULL
)
3268 alpha_vms_swap_eisd_out
3270 (struct vms_eisd
*)(blk
+ (eisd
->file_pos
% VMS_BLOCK_SIZE
)));
3272 next_eisd
= eisd
->next
;
3273 if (next_eisd
== NULL
3274 || (next_eisd
->file_pos
/ VMS_BLOCK_SIZE
3275 != eisd
->file_pos
/ VMS_BLOCK_SIZE
))
3277 if (bfd_bwrite (blk
, sizeof (blk
), abfd
) != sizeof (blk
))
3280 memset (blk
, 0xff, sizeof (blk
));
3286 /* Write sections. */
3287 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3289 unsigned char blk
[VMS_BLOCK_SIZE
];
3292 if (sec
->size
== 0 || !(sec
->flags
& SEC_HAS_CONTENTS
))
3294 if (bfd_bwrite (sec
->contents
, sec
->size
, abfd
) != sec
->size
)
3298 len
= VMS_BLOCK_SIZE
- sec
->size
% VMS_BLOCK_SIZE
;
3299 if (len
!= VMS_BLOCK_SIZE
)
3301 memset (blk
, 0, len
);
3302 if (bfd_bwrite (blk
, len
, abfd
) != len
)
3308 if (gst_filepos
!= 0)
3310 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3313 _bfd_vms_write_emh (abfd
);
3314 _bfd_vms_write_lmn (abfd
, "GNU LD");
3316 /* PSC for the absolute section. */
3317 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3318 _bfd_vms_output_long (recwr
, 0);
3319 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3320 _bfd_vms_output_short (recwr
, 0);
3321 _bfd_vms_output_short (recwr
, EGPS__V_PIC
| EGPS__V_LIB
| EGPS__V_RD
);
3322 _bfd_vms_output_long (recwr
, 0);
3323 _bfd_vms_output_counted (recwr
, ".$$ABS$$.");
3324 _bfd_vms_output_end_subrec (recwr
);
3325 _bfd_vms_output_end (abfd
, recwr
);
3327 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
3329 struct vms_symbol_entry
*sym
= PRIV (syms
)[i
];
3335 _bfd_vms_output_alignment (recwr
, 8);
3336 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3337 _bfd_vms_output_long (recwr
, 0);
3339 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYMG
);
3340 _bfd_vms_output_short (recwr
, 0); /* Data type, alignment. */
3341 _bfd_vms_output_short (recwr
, sym
->flags
);
3343 if (sym
->code_section
)
3344 ep
= alpha_vms_get_sym_value (sym
->code_section
, sym
->code_value
);
3347 BFD_ASSERT (sym
->code_value
== 0);
3350 val
= alpha_vms_get_sym_value (sym
->section
, sym
->value
);
3351 _bfd_vms_output_quad
3352 (recwr
, sym
->typ
== EGSD__C_SYMG
? sym
->symbol_vector
: val
);
3353 _bfd_vms_output_quad (recwr
, ep
);
3354 _bfd_vms_output_quad (recwr
, val
);
3355 _bfd_vms_output_long (recwr
, 0);
3356 _bfd_vms_output_counted (recwr
, sym
->name
);
3357 _bfd_vms_output_end_subrec (recwr
);
3359 _bfd_vms_output_end (abfd
, recwr
);
3362 _bfd_vms_output_end (abfd
, recwr
);
3364 if (!_bfd_vms_write_eeom (abfd
))
3372 /* Write section and symbol directory of bfd abfd. Return FALSE on error. */
3375 _bfd_vms_write_egsd (bfd
*abfd
)
3379 unsigned int symnum
;
3381 flagword new_flags
, old_flags
;
3382 int abs_section_index
= -1;
3383 unsigned int target_index
= 0;
3384 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3386 vms_debug2 ((2, "vms_write_egsd\n"));
3388 /* Egsd is quadword aligned. */
3389 _bfd_vms_output_alignment (recwr
, 8);
3391 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3392 _bfd_vms_output_long (recwr
, 0);
3394 /* Number sections. */
3395 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3397 if (section
->flags
& SEC_DEBUGGING
)
3399 if (!strcmp (section
->name
, ".vmsdebug"))
3401 section
->flags
|= SEC_DEBUGGING
;
3404 section
->target_index
= target_index
++;
3407 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3409 vms_debug2 ((3, "Section #%d %s, %d bytes\n",
3410 section
->target_index
, section
->name
, (int)section
->size
));
3412 /* Don't write out the VMS debug info section since it is in the
3413 ETBT and EDBG sections in etir. */
3414 if (section
->flags
& SEC_DEBUGGING
)
3417 /* 13 bytes egsd, max 31 chars name -> should be 44 bytes. */
3418 if (_bfd_vms_output_check (recwr
, 64) < 0)
3420 _bfd_vms_output_end (abfd
, recwr
);
3421 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3422 _bfd_vms_output_long (recwr
, 0);
3425 /* Don't know if this is necessary for the linker but for now it keeps
3426 vms_slurp_gsd happy. */
3427 sname
= section
->name
;
3430 /* Remove leading dot. */
3432 if ((*sname
== 't') && (strcmp (sname
, "text") == 0))
3433 sname
= EVAX_CODE_NAME
;
3434 else if ((*sname
== 'd') && (strcmp (sname
, "data") == 0))
3435 sname
= EVAX_DATA_NAME
;
3436 else if ((*sname
== 'b') && (strcmp (sname
, "bss") == 0))
3437 sname
= EVAX_BSS_NAME
;
3438 else if ((*sname
== 'l') && (strcmp (sname
, "link") == 0))
3439 sname
= EVAX_LINK_NAME
;
3440 else if ((*sname
== 'r') && (strcmp (sname
, "rdata") == 0))
3441 sname
= EVAX_READONLY_NAME
;
3442 else if ((*sname
== 'l') && (strcmp (sname
, "literal") == 0))
3443 sname
= EVAX_LITERAL_NAME
;
3444 else if ((*sname
== 'l') && (strcmp (sname
, "literals") == 0))
3445 sname
= EVAX_LITERALS_NAME
;
3446 else if ((*sname
== 'c') && (strcmp (sname
, "comm") == 0))
3447 sname
= EVAX_COMMON_NAME
;
3448 else if ((*sname
== 'l') && (strcmp (sname
, "lcomm") == 0))
3449 sname
= EVAX_LOCAL_NAME
;
3452 if (bfd_is_com_section (section
))
3453 new_flags
= (EGPS__V_OVR
| EGPS__V_REL
| EGPS__V_GBL
| EGPS__V_RD
3454 | EGPS__V_WRT
| EGPS__V_NOMOD
| EGPS__V_COM
);
3456 new_flags
= vms_esecflag_by_name (evax_section_flags
, sname
,
3459 /* Modify them as directed. */
3460 if (section
->flags
& SEC_READONLY
)
3461 new_flags
&= ~EGPS__V_WRT
;
3463 new_flags
&= ~vms_section_data (section
)->no_flags
;
3464 new_flags
|= vms_section_data (section
)->flags
;
3466 vms_debug2 ((3, "sec flags %x\n", section
->flags
));
3467 vms_debug2 ((3, "new_flags %x, _raw_size %lu\n",
3468 new_flags
, (unsigned long)section
->size
));
3470 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3471 _bfd_vms_output_short (recwr
, section
->alignment_power
& 0xff);
3472 _bfd_vms_output_short (recwr
, new_flags
);
3473 _bfd_vms_output_long (recwr
, (unsigned long) section
->size
);
3474 _bfd_vms_output_counted (recwr
, sname
);
3475 _bfd_vms_output_end_subrec (recwr
);
3477 /* If the section is an obsolute one, remind its index as it will be
3478 used later for absolute symbols. */
3479 if ((new_flags
& EGPS__V_REL
) == 0 && abs_section_index
< 0)
3480 abs_section_index
= section
->target_index
;
3483 /* Output symbols. */
3484 vms_debug2 ((3, "%d symbols found\n", abfd
->symcount
));
3486 bfd_set_start_address (abfd
, (bfd_vma
) -1);
3488 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3490 symbol
= abfd
->outsymbols
[symnum
];
3491 old_flags
= symbol
->flags
;
3493 /* Work-around a missing feature: consider __main as the main entry
3495 if (symbol
->name
[0] == '_' && strcmp (symbol
->name
, "__main") == 0)
3496 bfd_set_start_address (abfd
, (bfd_vma
)symbol
->value
);
3498 /* Only put in the GSD the global and the undefined symbols. */
3499 if (old_flags
& BSF_FILE
)
3502 if ((old_flags
& BSF_GLOBAL
) == 0 && !bfd_is_und_section (symbol
->section
))
3504 /* If the LIB$INITIIALIZE section is present, add a reference to
3505 LIB$INITIALIZE symbol. FIXME: this should be done explicitely
3506 in the assembly file. */
3507 if (!((old_flags
& BSF_SECTION_SYM
) != 0
3508 && strcmp (symbol
->section
->name
, "LIB$INITIALIZE") == 0))
3512 /* 13 bytes egsd, max 64 chars name -> should be 77 bytes. Add 16 more
3513 bytes for a possible ABS section. */
3514 if (_bfd_vms_output_check (recwr
, 80 + 16) < 0)
3516 _bfd_vms_output_end (abfd
, recwr
);
3517 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3518 _bfd_vms_output_long (recwr
, 0);
3521 if ((old_flags
& BSF_GLOBAL
) != 0
3522 && bfd_is_abs_section (symbol
->section
)
3523 && abs_section_index
<= 0)
3525 /* Create an absolute section if none was defined. It is highly
3526 unlikely that the name $ABS$ clashes with a user defined
3527 non-absolute section name. */
3528 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3529 _bfd_vms_output_short (recwr
, 4);
3530 _bfd_vms_output_short (recwr
, EGPS__V_SHR
);
3531 _bfd_vms_output_long (recwr
, 0);
3532 _bfd_vms_output_counted (recwr
, "$ABS$");
3533 _bfd_vms_output_end_subrec (recwr
);
3535 abs_section_index
= target_index
++;
3538 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYM
);
3540 /* Data type, alignment. */
3541 _bfd_vms_output_short (recwr
, 0);
3545 if (old_flags
& BSF_WEAK
)
3546 new_flags
|= EGSY__V_WEAK
;
3547 if (bfd_is_com_section (symbol
->section
)) /* .comm */
3548 new_flags
|= (EGSY__V_WEAK
| EGSY__V_COMM
);
3550 if (old_flags
& BSF_FUNCTION
)
3552 new_flags
|= EGSY__V_NORM
;
3553 new_flags
|= EGSY__V_REL
;
3555 if (old_flags
& BSF_GLOBAL
)
3557 new_flags
|= EGSY__V_DEF
;
3558 if (!bfd_is_abs_section (symbol
->section
))
3559 new_flags
|= EGSY__V_REL
;
3561 _bfd_vms_output_short (recwr
, new_flags
);
3563 if (old_flags
& BSF_GLOBAL
)
3565 /* Symbol definition. */
3566 bfd_vma code_address
= 0;
3567 unsigned long ca_psindx
= 0;
3568 unsigned long psindx
;
3570 if ((old_flags
& BSF_FUNCTION
) && symbol
->udata
.p
!= NULL
)
3575 ((struct evax_private_udata_struct
*)symbol
->udata
.p
)->enbsym
;
3576 code_address
= sym
->value
;
3577 ca_psindx
= sym
->section
->target_index
;
3579 if (bfd_is_abs_section (symbol
->section
))
3580 psindx
= abs_section_index
;
3582 psindx
= symbol
->section
->target_index
;
3584 _bfd_vms_output_quad (recwr
, symbol
->value
);
3585 _bfd_vms_output_quad (recwr
, code_address
);
3586 _bfd_vms_output_long (recwr
, ca_psindx
);
3587 _bfd_vms_output_long (recwr
, psindx
);
3589 _bfd_vms_output_counted (recwr
, symbol
->name
);
3591 _bfd_vms_output_end_subrec (recwr
);
3594 _bfd_vms_output_alignment (recwr
, 8);
3595 _bfd_vms_output_end (abfd
, recwr
);
3600 /* Write object header for bfd abfd. Return FALSE on error. */
3603 _bfd_vms_write_ehdr (bfd
*abfd
)
3606 unsigned int symnum
;
3607 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3609 vms_debug2 ((2, "vms_write_ehdr (%p)\n", abfd
));
3611 _bfd_vms_output_alignment (recwr
, 2);
3613 _bfd_vms_write_emh (abfd
);
3614 _bfd_vms_write_lmn (abfd
, "GNU AS");
3617 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3618 _bfd_vms_output_short (recwr
, EMH__C_SRC
);
3620 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3622 symbol
= abfd
->outsymbols
[symnum
];
3624 if (symbol
->flags
& BSF_FILE
)
3626 _bfd_vms_output_dump (recwr
, (unsigned char *) symbol
->name
,
3627 (int) strlen (symbol
->name
));
3632 if (symnum
== abfd
->symcount
)
3633 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("noname"));
3635 _bfd_vms_output_end (abfd
, recwr
);
3638 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3639 _bfd_vms_output_short (recwr
, EMH__C_TTL
);
3640 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("TTL"));
3641 _bfd_vms_output_end (abfd
, recwr
);
3644 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3645 _bfd_vms_output_short (recwr
, EMH__C_CPR
);
3646 _bfd_vms_output_dump (recwr
,
3647 (unsigned char *)"GNU BFD ported by Klaus Kämpf 1994-1996",
3649 _bfd_vms_output_end (abfd
, recwr
);
3654 /* Part 4.6, relocations. */
3657 /* WRITE ETIR SECTION
3659 This is still under construction and therefore not documented. */
3661 /* Close the etir/etbt record. */
3664 end_etir_record (bfd
* abfd
)
3666 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3668 _bfd_vms_output_end (abfd
, recwr
);
3672 start_etir_or_etbt_record (bfd
*abfd
, asection
*section
, bfd_vma offset
)
3674 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3676 if (section
->flags
& SEC_DEBUGGING
)
3678 _bfd_vms_output_begin (recwr
, EOBJ__C_ETBT
);
3682 /* Push start offset. */
3683 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3684 _bfd_vms_output_long (recwr
, (unsigned long) 0);
3685 _bfd_vms_output_end_subrec (recwr
);
3688 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_DFLOC
);
3689 _bfd_vms_output_end_subrec (recwr
);
3694 _bfd_vms_output_begin (recwr
, EOBJ__C_ETIR
);
3698 /* Push start offset. */
3699 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3700 _bfd_vms_output_long (recwr
, (unsigned long) section
->target_index
);
3701 _bfd_vms_output_quad (recwr
, offset
);
3702 _bfd_vms_output_end_subrec (recwr
);
3704 /* Start = pop (). */
3705 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_SETRB
);
3706 _bfd_vms_output_end_subrec (recwr
);
3711 /* Output a STO_IMM command for SSIZE bytes of data from CPR at virtual
3712 address VADDR in section specified by SEC_INDEX and NAME. */
3715 sto_imm (bfd
*abfd
, asection
*section
,
3716 bfd_size_type ssize
, unsigned char *cptr
, bfd_vma vaddr
)
3719 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3722 _bfd_vms_debug (8, "sto_imm %d bytes\n", (int) ssize
);
3723 _bfd_hexdump (9, cptr
, (int) ssize
, (int) vaddr
);
3728 /* Try all the rest. */
3731 if (_bfd_vms_output_check (recwr
, size
) < 0)
3733 /* Doesn't fit, split ! */
3734 end_etir_record (abfd
);
3736 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3738 size
= _bfd_vms_output_check (recwr
, 0); /* get max size */
3739 if (size
> ssize
) /* more than what's left ? */
3743 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_IMM
);
3744 _bfd_vms_output_long (recwr
, (unsigned long) (size
));
3745 _bfd_vms_output_dump (recwr
, cptr
, size
);
3746 _bfd_vms_output_end_subrec (recwr
);
3749 _bfd_vms_debug (10, "dumped %d bytes\n", (int) size
);
3750 _bfd_hexdump (10, cptr
, (int) size
, (int) vaddr
);
3760 etir_output_check (bfd
*abfd
, asection
*section
, bfd_vma vaddr
, int checklen
)
3762 if (_bfd_vms_output_check (&PRIV (recwr
), checklen
) < 0)
3764 /* Not enough room in this record. Close it and open a new one. */
3765 end_etir_record (abfd
);
3766 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3770 /* Return whether RELOC must be deferred till the end. */
3773 defer_reloc_p (arelent
*reloc
)
3775 switch (reloc
->howto
->type
)
3788 /* Write section contents for bfd abfd. Return FALSE on error. */
3791 _bfd_vms_write_etir (bfd
* abfd
, int objtype ATTRIBUTE_UNUSED
)
3794 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3796 vms_debug2 ((2, "vms_write_tir (%p, %d)\n", abfd
, objtype
));
3798 _bfd_vms_output_alignment (recwr
, 4);
3800 PRIV (vms_linkage_index
) = 0;
3802 for (section
= abfd
->sections
; section
; section
= section
->next
)
3804 vms_debug2 ((4, "writing %d. section '%s' (%d bytes)\n",
3805 section
->target_index
, section
->name
, (int) (section
->size
)));
3807 if (!(section
->flags
& SEC_HAS_CONTENTS
)
3808 || bfd_is_com_section (section
))
3811 if (!section
->contents
)
3813 bfd_set_error (bfd_error_no_contents
);
3817 start_etir_or_etbt_record (abfd
, section
, 0);
3819 if (section
->flags
& SEC_RELOC
)
3821 bfd_vma curr_addr
= 0;
3822 unsigned char *curr_data
= section
->contents
;
3824 int pass2_needed
= 0;
3825 int pass2_in_progress
= 0;
3828 if (section
->reloc_count
== 0)
3830 (_("SEC_RELOC with no relocs in section %A"), section
);
3835 int i
= section
->reloc_count
;
3836 arelent
**rptr
= section
->orelocation
;
3837 _bfd_vms_debug (4, "%d relocations:\n", i
);
3840 _bfd_vms_debug (4, "sym %s in sec %s, value %08lx, "
3841 "addr %08lx, off %08lx, len %d: %s\n",
3842 (*(*rptr
)->sym_ptr_ptr
)->name
,
3843 (*(*rptr
)->sym_ptr_ptr
)->section
->name
,
3844 (long) (*(*rptr
)->sym_ptr_ptr
)->value
,
3845 (unsigned long)(*rptr
)->address
,
3846 (unsigned long)(*rptr
)->addend
,
3847 bfd_get_reloc_size ((*rptr
)->howto
),
3848 ( *rptr
)->howto
->name
);
3855 for (irel
= 0; irel
< section
->reloc_count
; irel
++)
3857 struct evax_private_udata_struct
*udata
;
3858 arelent
*rptr
= section
->orelocation
[irel
];
3859 bfd_vma addr
= rptr
->address
;
3860 asymbol
*sym
= *rptr
->sym_ptr_ptr
;
3861 asection
*sec
= sym
->section
;
3862 bfd_boolean defer
= defer_reloc_p (rptr
);
3865 if (pass2_in_progress
)
3867 /* Non-deferred relocs have already been output. */
3873 /* Deferred relocs must be output at the very end. */
3880 /* Regular relocs are intertwined with binary data. */
3881 if (curr_addr
> addr
)
3882 _bfd_error_handler (_("Size error in section %A"),
3884 size
= addr
- curr_addr
;
3885 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
3890 size
= bfd_get_reloc_size (rptr
->howto
);
3892 switch (rptr
->howto
->type
)
3894 case ALPHA_R_IGNORE
:
3897 case ALPHA_R_REFLONG
:
3898 if (bfd_is_und_section (sym
->section
))
3900 bfd_vma addend
= rptr
->addend
;
3901 slen
= strlen ((char *) sym
->name
);
3902 etir_output_check (abfd
, section
, curr_addr
, slen
);
3905 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
3906 _bfd_vms_output_counted (recwr
, sym
->name
);
3907 _bfd_vms_output_end_subrec (recwr
);
3908 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3909 _bfd_vms_output_long (recwr
, (unsigned long) addend
);
3910 _bfd_vms_output_end_subrec (recwr
);
3911 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
3912 _bfd_vms_output_end_subrec (recwr
);
3913 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3914 _bfd_vms_output_end_subrec (recwr
);
3918 _bfd_vms_output_begin_subrec
3919 (recwr
, ETIR__C_STO_GBL_LW
);
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_LW
);
3928 _bfd_vms_output_long (recwr
, (unsigned long) sym
->value
);
3929 _bfd_vms_output_end_subrec (recwr
);
3930 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
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 /* ??? Table B-8 of the OpenVMS Linker Utilily Manual
3942 says that we should have a ETIR__C_STO_OFF here.
3943 But the relocation would not be BFD_RELOC_32 then.
3944 This case is very likely unreachable. */
3945 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3946 _bfd_vms_output_end_subrec (recwr
);
3950 case ALPHA_R_REFQUAD
:
3951 if (bfd_is_und_section (sym
->section
))
3953 bfd_vma addend
= rptr
->addend
;
3954 slen
= strlen ((char *) sym
->name
);
3955 etir_output_check (abfd
, section
, curr_addr
, slen
);
3958 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
3959 _bfd_vms_output_counted (recwr
, sym
->name
);
3960 _bfd_vms_output_end_subrec (recwr
);
3961 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
3962 _bfd_vms_output_quad (recwr
, addend
);
3963 _bfd_vms_output_end_subrec (recwr
);
3964 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
3965 _bfd_vms_output_end_subrec (recwr
);
3966 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
3967 _bfd_vms_output_end_subrec (recwr
);
3971 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_GBL
);
3972 _bfd_vms_output_counted (recwr
, sym
->name
);
3973 _bfd_vms_output_end_subrec (recwr
);
3976 else if (bfd_is_abs_section (sym
->section
))
3978 etir_output_check (abfd
, section
, curr_addr
, 16);
3979 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
3980 _bfd_vms_output_quad (recwr
, sym
->value
);
3981 _bfd_vms_output_end_subrec (recwr
);
3982 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
3983 _bfd_vms_output_end_subrec (recwr
);
3987 etir_output_check (abfd
, section
, curr_addr
, 32);
3988 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3989 _bfd_vms_output_long (recwr
,
3990 (unsigned long) sec
->target_index
);
3991 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
3992 _bfd_vms_output_end_subrec (recwr
);
3993 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_OFF
);
3994 _bfd_vms_output_end_subrec (recwr
);
3999 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
4002 case ALPHA_R_LINKAGE
:
4003 etir_output_check (abfd
, section
, curr_addr
, 64);
4004 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LP_PSB
);
4005 _bfd_vms_output_long
4006 (recwr
, (unsigned long) rptr
->addend
);
4007 if (rptr
->addend
> PRIV (vms_linkage_index
))
4008 PRIV (vms_linkage_index
) = rptr
->addend
;
4009 _bfd_vms_output_counted (recwr
, sym
->name
);
4010 _bfd_vms_output_byte (recwr
, 0);
4011 _bfd_vms_output_end_subrec (recwr
);
4014 case ALPHA_R_CODEADDR
:
4015 slen
= strlen ((char *) sym
->name
);
4016 etir_output_check (abfd
, section
, curr_addr
, slen
);
4017 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_CA
);
4018 _bfd_vms_output_counted (recwr
, sym
->name
);
4019 _bfd_vms_output_end_subrec (recwr
);
4024 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4025 etir_output_check (abfd
, section
, curr_addr
,
4026 32 + 1 + strlen (udata
->origname
));
4027 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_NOP_GBL
);
4028 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
4029 _bfd_vms_output_long
4030 (recwr
, (unsigned long) section
->target_index
);
4031 _bfd_vms_output_quad (recwr
, rptr
->address
);
4032 _bfd_vms_output_long (recwr
, (unsigned long) 0x47ff041f);
4033 _bfd_vms_output_long
4034 (recwr
, (unsigned long) section
->target_index
);
4035 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4036 _bfd_vms_output_counted (recwr
, udata
->origname
);
4037 _bfd_vms_output_end_subrec (recwr
);
4041 _bfd_error_handler (_("Spurious ALPHA_R_BSR reloc"));
4046 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4047 etir_output_check (abfd
, section
, curr_addr
,
4048 32 + 1 + strlen (udata
->origname
));
4049 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LDA_GBL
);
4050 _bfd_vms_output_long
4051 (recwr
, (unsigned long) udata
->lkindex
+ 1);
4052 _bfd_vms_output_long
4053 (recwr
, (unsigned long) section
->target_index
);
4054 _bfd_vms_output_quad (recwr
, rptr
->address
);
4055 _bfd_vms_output_long (recwr
, (unsigned long) 0x237B0000);
4056 _bfd_vms_output_long
4057 (recwr
, (unsigned long) udata
->bsym
->section
->target_index
);
4058 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4059 _bfd_vms_output_counted (recwr
, udata
->origname
);
4060 _bfd_vms_output_end_subrec (recwr
);
4065 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4066 etir_output_check (abfd
, section
, curr_addr
,
4067 32 + 1 + strlen (udata
->origname
));
4068 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_BOH_GBL
);
4069 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
4070 _bfd_vms_output_long
4071 (recwr
, (unsigned long) section
->target_index
);
4072 _bfd_vms_output_quad (recwr
, rptr
->address
);
4073 _bfd_vms_output_long (recwr
, (unsigned long) 0xD3400000);
4074 _bfd_vms_output_long
4075 (recwr
, (unsigned long) section
->target_index
);
4076 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4077 _bfd_vms_output_counted (recwr
, udata
->origname
);
4078 _bfd_vms_output_end_subrec (recwr
);
4082 _bfd_error_handler (_("Unhandled relocation %s"),
4089 } /* End of relocs loop. */
4091 if (!pass2_in_progress
)
4093 /* Output rest of section. */
4094 if (curr_addr
> section
->size
)
4095 _bfd_error_handler (_("Size error in section %A"), section
);
4096 size
= section
->size
- curr_addr
;
4097 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
4103 pass2_in_progress
= 1;
4109 else /* (section->flags & SEC_RELOC) */
4110 sto_imm (abfd
, section
, section
->size
, section
->contents
, 0);
4112 end_etir_record (abfd
);
4115 _bfd_vms_output_alignment (recwr
, 2);
4119 /* Write cached information into a file being written, at bfd_close. */
4122 alpha_vms_write_object_contents (bfd
*abfd
)
4124 vms_debug2 ((1, "vms_write_object_contents (%p)\n", abfd
));
4126 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
4128 return alpha_vms_write_exec (abfd
);
4132 if (abfd
->section_count
> 0) /* we have sections */
4134 if (!_bfd_vms_write_ehdr (abfd
))
4136 if (!_bfd_vms_write_egsd (abfd
))
4138 if (!_bfd_vms_write_etir (abfd
, EOBJ__C_ETIR
))
4140 if (!_bfd_vms_write_eeom (abfd
))
4147 /* Debug stuff: nearest line. */
4149 #define SET_MODULE_PARSED(m) \
4150 do { if ((m)->name == NULL) (m)->name = ""; } while (0)
4151 #define IS_MODULE_PARSED(m) ((m)->name != NULL)
4153 /* Build a new module for the specified BFD. */
4155 static struct module
*
4156 new_module (bfd
*abfd
)
4158 struct module
*module
4159 = (struct module
*) bfd_zalloc (abfd
, sizeof (struct module
));
4160 module
->file_table_count
= 16; /* Arbitrary. */
4162 = bfd_malloc (module
->file_table_count
* sizeof (struct fileinfo
));
4166 /* Parse debug info for a module and internalize it. */
4169 parse_module (bfd
*abfd
, struct module
*module
, unsigned char *ptr
,
4172 unsigned char *maxptr
= ptr
+ length
;
4173 unsigned char *src_ptr
, *pcl_ptr
;
4174 unsigned int prev_linum
= 0, curr_linenum
= 0;
4175 bfd_vma prev_pc
= 0, curr_pc
= 0;
4176 struct srecinfo
*curr_srec
, *srec
;
4177 struct lineinfo
*curr_line
, *line
;
4178 struct funcinfo
*funcinfo
;
4180 /* Initialize tables with zero element. */
4181 curr_srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4182 module
->srec_table
= curr_srec
;
4184 curr_line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4185 module
->line_table
= curr_line
;
4187 while (length
== -1 || ptr
< maxptr
)
4189 /* The first byte is not counted in the recorded length. */
4190 int rec_length
= bfd_getl16 (ptr
) + 1;
4191 int rec_type
= bfd_getl16 (ptr
+ 2);
4193 vms_debug2 ((2, "DST record: leng %d, type %d\n", rec_length
, rec_type
));
4195 if (length
== -1 && rec_type
== DST__K_MODEND
)
4202 = _bfd_vms_save_counted_string (ptr
+ DST_S_B_MODBEG_NAME
,
4203 maxptr
- (ptr
+ DST_S_B_MODBEG_NAME
));
4210 vms_debug2 ((3, "module: %s\n", module
->name
));
4217 funcinfo
= (struct funcinfo
*)
4218 bfd_zalloc (abfd
, sizeof (struct funcinfo
));
4220 = _bfd_vms_save_counted_string (ptr
+ DST_S_B_RTNBEG_NAME
,
4221 maxptr
- (ptr
+ DST_S_B_RTNBEG_NAME
));
4222 funcinfo
->low
= bfd_getl32 (ptr
+ DST_S_L_RTNBEG_ADDRESS
);
4223 funcinfo
->next
= module
->func_table
;
4224 module
->func_table
= funcinfo
;
4226 vms_debug2 ((3, "routine: %s at 0x%lx\n",
4227 funcinfo
->name
, (unsigned long) funcinfo
->low
));
4231 module
->func_table
->high
= module
->func_table
->low
4232 + bfd_getl32 (ptr
+ DST_S_L_RTNEND_SIZE
) - 1;
4234 if (module
->func_table
->high
> module
->high
)
4235 module
->high
= module
->func_table
->high
;
4237 vms_debug2 ((3, "end routine\n"));
4241 vms_debug2 ((3, "prologue\n"));
4245 vms_debug2 ((3, "epilog\n"));
4249 vms_debug2 ((3, "block\n"));
4253 vms_debug2 ((3, "end block\n"));
4257 src_ptr
= ptr
+ DST_S_C_SOURCE_HEADER_SIZE
;
4259 vms_debug2 ((3, "source info\n"));
4261 while (src_ptr
< ptr
+ rec_length
)
4263 int cmd
= src_ptr
[0], cmd_length
, data
;
4267 case DST__K_SRC_DECLFILE
:
4270 = bfd_getl16 (src_ptr
+ DST_S_W_SRC_DF_FILEID
);
4272 = _bfd_vms_save_counted_string (src_ptr
+ DST_S_B_SRC_DF_FILENAME
,
4273 (ptr
+ rec_length
) -
4274 (src_ptr
+ DST_S_B_SRC_DF_FILENAME
)
4277 while (fileid
>= module
->file_table_count
)
4279 module
->file_table_count
*= 2;
4281 = bfd_realloc (module
->file_table
,
4282 module
->file_table_count
4283 * sizeof (struct fileinfo
));
4286 module
->file_table
[fileid
].name
= filename
;
4287 module
->file_table
[fileid
].srec
= 1;
4288 cmd_length
= src_ptr
[DST_S_B_SRC_DF_LENGTH
] + 2;
4289 vms_debug2 ((4, "DST_S_C_SRC_DECLFILE: %d, %s\n",
4290 fileid
, module
->file_table
[fileid
].name
));
4294 case DST__K_SRC_DEFLINES_B
:
4295 /* Perform the association and set the next higher index
4297 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4298 srec
= (struct srecinfo
*)
4299 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4300 srec
->line
= curr_srec
->line
+ data
;
4301 srec
->srec
= curr_srec
->srec
+ data
;
4302 srec
->sfile
= curr_srec
->sfile
;
4303 curr_srec
->next
= srec
;
4306 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_B: %d\n", data
));
4309 case DST__K_SRC_DEFLINES_W
:
4310 /* Perform the association and set the next higher index
4312 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4313 srec
= (struct srecinfo
*)
4314 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4315 srec
->line
= curr_srec
->line
+ data
;
4316 srec
->srec
= curr_srec
->srec
+ data
,
4317 srec
->sfile
= curr_srec
->sfile
;
4318 curr_srec
->next
= srec
;
4321 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_W: %d\n", data
));
4324 case DST__K_SRC_INCRLNUM_B
:
4325 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4326 curr_srec
->line
+= data
;
4328 vms_debug2 ((4, "DST_S_C_SRC_INCRLNUM_B: %d\n", data
));
4331 case DST__K_SRC_SETFILE
:
4332 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4333 curr_srec
->sfile
= data
;
4334 curr_srec
->srec
= module
->file_table
[data
].srec
;
4336 vms_debug2 ((4, "DST_S_C_SRC_SETFILE: %d\n", data
));
4339 case DST__K_SRC_SETLNUM_L
:
4340 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4341 curr_srec
->line
= data
;
4343 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_L: %d\n", data
));
4346 case DST__K_SRC_SETLNUM_W
:
4347 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4348 curr_srec
->line
= data
;
4350 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_W: %d\n", data
));
4353 case DST__K_SRC_SETREC_L
:
4354 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4355 curr_srec
->srec
= data
;
4356 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4358 vms_debug2 ((4, "DST_S_C_SRC_SETREC_L: %d\n", data
));
4361 case DST__K_SRC_SETREC_W
:
4362 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4363 curr_srec
->srec
= data
;
4364 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4366 vms_debug2 ((4, "DST_S_C_SRC_SETREC_W: %d\n", data
));
4369 case DST__K_SRC_FORMFEED
:
4371 vms_debug2 ((4, "DST_S_C_SRC_FORMFEED\n"));
4375 _bfd_error_handler (_("unknown source command %d"),
4381 src_ptr
+= cmd_length
;
4385 case DST__K_LINE_NUM
:
4386 pcl_ptr
= ptr
+ DST_S_C_LINE_NUM_HEADER_SIZE
;
4388 vms_debug2 ((3, "line info\n"));
4390 while (pcl_ptr
< ptr
+ rec_length
)
4392 /* The command byte is signed so we must sign-extend it. */
4393 int cmd
= ((signed char *)pcl_ptr
)[0], cmd_length
, data
;
4397 case DST__K_DELTA_PC_W
:
4398 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4402 vms_debug2 ((4, "DST__K_DELTA_PC_W: %d\n", data
));
4405 case DST__K_DELTA_PC_L
:
4406 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4410 vms_debug2 ((4, "DST__K_DELTA_PC_L: %d\n", data
));
4413 case DST__K_INCR_LINUM
:
4414 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4415 curr_linenum
+= data
;
4417 vms_debug2 ((4, "DST__K_INCR_LINUM: %d\n", data
));
4420 case DST__K_INCR_LINUM_W
:
4421 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4422 curr_linenum
+= data
;
4424 vms_debug2 ((4, "DST__K_INCR_LINUM_W: %d\n", data
));
4427 case DST__K_INCR_LINUM_L
:
4428 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4429 curr_linenum
+= data
;
4431 vms_debug2 ((4, "DST__K_INCR_LINUM_L: %d\n", data
));
4434 case DST__K_SET_LINUM_INCR
:
4436 (_("DST__K_SET_LINUM_INCR not implemented"));
4440 case DST__K_SET_LINUM_INCR_W
:
4442 (_("DST__K_SET_LINUM_INCR_W not implemented"));
4446 case DST__K_RESET_LINUM_INCR
:
4448 (_("DST__K_RESET_LINUM_INCR not implemented"));
4452 case DST__K_BEG_STMT_MODE
:
4454 (_("DST__K_BEG_STMT_MODE not implemented"));
4458 case DST__K_END_STMT_MODE
:
4460 (_("DST__K_END_STMT_MODE not implemented"));
4464 case DST__K_SET_LINUM_B
:
4465 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4466 curr_linenum
= data
;
4468 vms_debug2 ((4, "DST__K_SET_LINUM_B: %d\n", data
));
4471 case DST__K_SET_LINUM
:
4472 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4473 curr_linenum
= data
;
4475 vms_debug2 ((4, "DST__K_SET_LINE_NUM: %d\n", data
));
4478 case DST__K_SET_LINUM_L
:
4479 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4480 curr_linenum
= data
;
4482 vms_debug2 ((4, "DST__K_SET_LINUM_L: %d\n", data
));
4487 (_("DST__K_SET_PC not implemented"));
4491 case DST__K_SET_PC_W
:
4493 (_("DST__K_SET_PC_W not implemented"));
4497 case DST__K_SET_PC_L
:
4499 (_("DST__K_SET_PC_L not implemented"));
4503 case DST__K_SET_STMTNUM
:
4505 (_("DST__K_SET_STMTNUM not implemented"));
4510 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4513 vms_debug2 ((4, "DST__K_TERM: %d\n", data
));
4517 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4520 vms_debug2 ((4, "DST__K_TERM_W: %d\n", data
));
4524 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4527 vms_debug2 ((4, "DST__K_TERM_L: %d\n", data
));
4530 case DST__K_SET_ABS_PC
:
4531 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4534 vms_debug2 ((4, "DST__K_SET_ABS_PC: 0x%x\n", data
));
4543 vms_debug2 ((4, "bump pc to 0x%lx and line to %d\n",
4544 (unsigned long)curr_pc
, curr_linenum
));
4548 _bfd_error_handler (_("unknown line command %d"), cmd
);
4554 if ((curr_linenum
!= prev_linum
&& curr_pc
!= prev_pc
)
4556 || cmd
== DST__K_DELTA_PC_L
4557 || cmd
== DST__K_DELTA_PC_W
)
4559 line
= (struct lineinfo
*)
4560 bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4561 line
->address
= curr_pc
;
4562 line
->line
= curr_linenum
;
4564 curr_line
->next
= line
;
4567 prev_linum
= curr_linenum
;
4569 vms_debug2 ((4, "-> correlate pc 0x%lx with line %d\n",
4570 (unsigned long)curr_pc
, curr_linenum
));
4573 pcl_ptr
+= cmd_length
;
4577 case 0x17: /* Undocumented type used by DEC C to declare equates. */
4578 vms_debug2 ((3, "undocumented type 0x17\n"));
4582 vms_debug2 ((3, "ignoring record\n"));
4590 /* Finalize tables with EOL marker. */
4591 srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4592 srec
->line
= (unsigned int) -1;
4593 srec
->srec
= (unsigned int) -1;
4594 curr_srec
->next
= srec
;
4596 line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4597 line
->line
= (unsigned int) -1;
4598 line
->address
= (bfd_vma
) -1;
4599 curr_line
->next
= line
;
4601 /* Advertise that this module has been parsed. This is needed
4602 because parsing can be either performed at module creation
4603 or deferred until debug info is consumed. */
4604 SET_MODULE_PARSED (module
);
4607 /* Build the list of modules for the specified BFD. */
4609 static struct module
*
4610 build_module_list (bfd
*abfd
)
4612 struct module
*module
, *list
= NULL
;
4615 if ((dmt
= bfd_get_section_by_name (abfd
, "$DMT$")))
4617 /* We have a DMT section so this must be an image. Parse the
4618 section and build the list of modules. This is sufficient
4619 since we can compute the start address and the end address
4620 of every module from the section contents. */
4621 bfd_size_type size
= bfd_get_section_size (dmt
);
4622 unsigned char *ptr
, *end
;
4624 ptr
= (unsigned char *) bfd_alloc (abfd
, size
);
4628 if (! bfd_get_section_contents (abfd
, dmt
, ptr
, 0, size
))
4631 vms_debug2 ((2, "DMT\n"));
4637 /* Each header declares a module with its start offset and size
4638 of debug info in the DST section, as well as the count of
4639 program sections (i.e. address spans) it contains. */
4640 int modbeg
= bfd_getl32 (ptr
+ DBG_S_L_DMT_MODBEG
);
4641 int msize
= bfd_getl32 (ptr
+ DBG_S_L_DST_SIZE
);
4642 int count
= bfd_getl16 (ptr
+ DBG_S_W_DMT_PSECT_COUNT
);
4643 ptr
+= DBG_S_C_DMT_HEADER_SIZE
;
4645 vms_debug2 ((3, "module: modbeg = %d, size = %d, count = %d\n",
4646 modbeg
, msize
, count
));
4648 /* We create a 'module' structure for each program section since
4649 we only support contiguous addresses in a 'module' structure.
4650 As a consequence, the actual debug info in the DST section is
4651 shared and can be parsed multiple times; that doesn't seem to
4652 cause problems in practice. */
4655 int start
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_START
);
4656 int length
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_LENGTH
);
4657 module
= new_module (abfd
);
4658 module
->modbeg
= modbeg
;
4659 module
->size
= msize
;
4660 module
->low
= start
;
4661 module
->high
= start
+ length
;
4662 module
->next
= list
;
4664 ptr
+= DBG_S_C_DMT_PSECT_SIZE
;
4666 vms_debug2 ((4, "section: start = 0x%x, length = %d\n",
4673 /* We don't have a DMT section so this must be an object. Parse
4674 the module right now in order to compute its start address and
4676 void *dst
= PRIV (dst_section
)->contents
;
4681 module
= new_module (abfd
);
4682 parse_module (abfd
, module
, PRIV (dst_section
)->contents
, -1);
4689 /* Calculate and return the name of the source file and the line nearest
4690 to the wanted location in the specified module. */
4693 module_find_nearest_line (bfd
*abfd
, struct module
*module
, bfd_vma addr
,
4694 const char **file
, const char **func
,
4697 struct funcinfo
*funcinfo
;
4698 struct lineinfo
*lineinfo
;
4699 struct srecinfo
*srecinfo
;
4700 bfd_boolean ret
= FALSE
;
4702 /* Parse this module if that was not done at module creation. */
4703 if (! IS_MODULE_PARSED (module
))
4705 unsigned int size
= module
->size
;
4706 unsigned int modbeg
= PRIV (dst_section
)->filepos
+ module
->modbeg
;
4707 unsigned char *buffer
= (unsigned char *) bfd_malloc (module
->size
);
4709 if (bfd_seek (abfd
, modbeg
, SEEK_SET
) != 0
4710 || bfd_bread (buffer
, size
, abfd
) != size
)
4712 bfd_set_error (bfd_error_no_debug_section
);
4716 parse_module (abfd
, module
, buffer
, size
);
4720 /* Find out the function (if any) that contains the address. */
4721 for (funcinfo
= module
->func_table
; funcinfo
; funcinfo
= funcinfo
->next
)
4722 if (addr
>= funcinfo
->low
&& addr
<= funcinfo
->high
)
4724 *func
= funcinfo
->name
;
4729 /* Find out the source file and the line nearest to the address. */
4730 for (lineinfo
= module
->line_table
; lineinfo
; lineinfo
= lineinfo
->next
)
4731 if (lineinfo
->next
&& addr
< lineinfo
->next
->address
)
4733 for (srecinfo
= module
->srec_table
; srecinfo
; srecinfo
= srecinfo
->next
)
4734 if (srecinfo
->next
&& lineinfo
->line
< srecinfo
->next
->line
)
4736 if (srecinfo
->sfile
> 0)
4738 *file
= module
->file_table
[srecinfo
->sfile
].name
;
4739 *line
= srecinfo
->srec
+ lineinfo
->line
- srecinfo
->line
;
4743 *file
= module
->name
;
4744 *line
= lineinfo
->line
;
4755 /* Provided a BFD, a section and an offset into the section, calculate and
4756 return the name of the source file and the line nearest to the wanted
4760 _bfd_vms_find_nearest_line (bfd
*abfd
,
4761 asymbol
**symbols ATTRIBUTE_UNUSED
,
4767 unsigned int *discriminator
)
4769 struct module
*module
;
4771 /* What address are we looking for? */
4772 bfd_vma addr
= section
->vma
+ offset
;
4780 /* We can't do anything if there is no DST (debug symbol table). */
4781 if (PRIV (dst_section
) == NULL
)
4784 /* Create the module list - if not already done. */
4785 if (PRIV (modules
) == NULL
)
4787 PRIV (modules
) = build_module_list (abfd
);
4788 if (PRIV (modules
) == NULL
)
4792 for (module
= PRIV (modules
); module
; module
= module
->next
)
4793 if (addr
>= module
->low
&& addr
<= module
->high
)
4794 return module_find_nearest_line (abfd
, module
, addr
, file
, func
, line
);
4799 /* Canonicalizations. */
4800 /* Set name, value, section and flags of SYM from E. */
4803 alpha_vms_convert_symbol (bfd
*abfd
, struct vms_symbol_entry
*e
, asymbol
*sym
)
4812 flags
= BSF_NO_FLAGS
;
4818 if (e
->flags
& EGSY__V_WEAK
)
4821 if (e
->flags
& EGSY__V_DEF
)
4823 /* Symbol definition. */
4824 flags
|= BSF_GLOBAL
;
4825 if (e
->flags
& EGSY__V_NORM
)
4826 flags
|= BSF_FUNCTION
;
4832 /* Symbol reference. */
4833 sec
= bfd_und_section_ptr
;
4838 /* A universal symbol is by definition global... */
4839 flags
|= BSF_GLOBAL
;
4841 /* ...and dynamic in shared libraries. */
4842 if (abfd
->flags
& DYNAMIC
)
4843 flags
|= BSF_DYNAMIC
;
4845 if (e
->flags
& EGSY__V_WEAK
)
4848 if (!(e
->flags
& EGSY__V_DEF
))
4851 if (e
->flags
& EGSY__V_NORM
)
4852 flags
|= BSF_FUNCTION
;
4855 /* sec = e->section; */
4856 sec
= bfd_abs_section_ptr
;
4871 /* Return the number of bytes required to store a vector of pointers
4872 to asymbols for all the symbols in the BFD abfd, including a
4873 terminal NULL pointer. If there are no symbols in the BFD,
4874 then return 0. If an error occurs, return -1. */
4877 alpha_vms_get_symtab_upper_bound (bfd
*abfd
)
4879 vms_debug2 ((1, "alpha_vms_get_symtab_upper_bound (%p), %d symbols\n",
4880 abfd
, PRIV (gsd_sym_count
)));
4882 return (PRIV (gsd_sym_count
) + 1) * sizeof (asymbol
*);
4885 /* Read the symbols from the BFD abfd, and fills in the vector
4886 location with pointers to the symbols and a trailing NULL.
4888 Return number of symbols read. */
4891 alpha_vms_canonicalize_symtab (bfd
*abfd
, asymbol
**symbols
)
4895 vms_debug2 ((1, "alpha_vms_canonicalize_symtab (%p, <ret>)\n", abfd
));
4897 if (PRIV (csymbols
) == NULL
)
4899 PRIV (csymbols
) = (asymbol
**) bfd_alloc
4900 (abfd
, PRIV (gsd_sym_count
) * sizeof (asymbol
*));
4902 /* Traverse table and fill symbols vector. */
4903 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
4905 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
4908 sym
= bfd_make_empty_symbol (abfd
);
4909 if (sym
== NULL
|| !alpha_vms_convert_symbol (abfd
, e
, sym
))
4911 bfd_release (abfd
, PRIV (csymbols
));
4912 PRIV (csymbols
) = NULL
;
4916 PRIV (csymbols
)[i
] = sym
;
4920 if (symbols
!= NULL
)
4922 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
4923 symbols
[i
] = PRIV (csymbols
)[i
];
4927 return PRIV (gsd_sym_count
);
4930 /* Read and convert relocations from ETIR. We do it once for all sections. */
4933 alpha_vms_slurp_relocs (bfd
*abfd
)
4937 vms_debug2 ((3, "alpha_vms_slurp_relocs\n"));
4939 /* We slurp relocs only once, for all sections. */
4940 if (PRIV (reloc_done
))
4942 PRIV (reloc_done
) = TRUE
;
4944 if (alpha_vms_canonicalize_symtab (abfd
, NULL
) < 0)
4947 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
4952 unsigned char *begin
;
4955 bfd_reloc_code_real_type reloc_code
;
4961 bfd_vma cur_address
;
4963 unsigned char *cur_sym
= NULL
;
4965 bfd_vma cur_addend
= 0;
4967 /* Skip non-ETIR records. */
4968 type
= _bfd_vms_get_object_record (abfd
);
4969 if (type
== EOBJ__C_EEOM
)
4971 if (type
!= EOBJ__C_ETIR
)
4974 begin
= PRIV (recrd
.rec
) + 4;
4975 end
= PRIV (recrd
.rec
) + PRIV (recrd
.rec_size
);
4977 for (ptr
= begin
; ptr
< end
; ptr
+= length
)
4981 cmd
= bfd_getl16 (ptr
);
4982 length
= bfd_getl16 (ptr
+ 2);
4984 cur_address
= vaddr
;
4986 vms_debug2 ((4, "alpha_vms_slurp_relocs: etir %s\n",
4987 _bfd_vms_etir_name (cmd
)));
4991 case ETIR__C_STA_GBL
: /* ALPHA_R_REFLONG und_section, step 1 */
4992 /* ALPHA_R_REFQUAD und_section, step 1 */
4997 case ETIR__C_STA_PQ
: /* ALPHA_R_REF{LONG|QUAD}, others part 1 */
4998 cur_psidx
= bfd_getl32 (ptr
+ 4);
4999 cur_addend
= bfd_getl64 (ptr
+ 8);
5003 case ETIR__C_CTL_SETRB
:
5004 if (prev_cmd
!= ETIR__C_STA_PQ
)
5007 /* xgettext:c-format */
5008 (_("Unknown reloc %s + %s"), _bfd_vms_etir_name (prev_cmd
),
5009 _bfd_vms_etir_name (cmd
));
5012 cur_psect
= cur_psidx
;
5018 case ETIR__C_STA_LW
: /* ALPHA_R_REFLONG abs_section, step 1 */
5019 /* ALPHA_R_REFLONG und_section, step 2 */
5022 if (prev_cmd
!= ETIR__C_STA_GBL
)
5025 /* xgettext:c-format */
5026 (_("Unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
5027 _bfd_vms_etir_name (ETIR__C_STA_LW
));
5031 cur_addend
= bfd_getl32 (ptr
+ 4);
5035 case ETIR__C_STA_QW
: /* ALPHA_R_REFQUAD abs_section, step 1 */
5036 /* ALPHA_R_REFQUAD und_section, step 2 */
5037 if (prev_cmd
!= -1 && prev_cmd
!= ETIR__C_STA_GBL
)
5040 /* xgettext:c-format */
5041 (_("Unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
5042 _bfd_vms_etir_name (ETIR__C_STA_QW
));
5045 cur_addend
= bfd_getl64 (ptr
+ 4);
5049 case ETIR__C_STO_LW
: /* ALPHA_R_REFLONG und_section, step 4 */
5050 /* ALPHA_R_REFLONG abs_section, step 2 */
5051 /* ALPHA_R_REFLONG others, step 2 */
5052 if (prev_cmd
!= ETIR__C_OPR_ADD
5053 && prev_cmd
!= ETIR__C_STA_LW
5054 && prev_cmd
!= ETIR__C_STA_PQ
)
5056 /* xgettext:c-format */
5057 _bfd_error_handler (_("Unknown reloc %s + %s"),
5058 _bfd_vms_etir_name (prev_cmd
),
5059 _bfd_vms_etir_name (ETIR__C_STO_LW
));
5062 reloc_code
= BFD_RELOC_32
;
5065 case ETIR__C_STO_QW
: /* ALPHA_R_REFQUAD und_section, step 4 */
5066 /* ALPHA_R_REFQUAD abs_section, step 2 */
5067 if (prev_cmd
!= ETIR__C_OPR_ADD
&& prev_cmd
!= ETIR__C_STA_QW
)
5069 /* xgettext:c-format */
5070 _bfd_error_handler (_("Unknown reloc %s + %s"),
5071 _bfd_vms_etir_name (prev_cmd
),
5072 _bfd_vms_etir_name (ETIR__C_STO_QW
));
5075 reloc_code
= BFD_RELOC_64
;
5078 case ETIR__C_STO_OFF
: /* ALPHA_R_REFQUAD others, step 2 */
5079 if (prev_cmd
!= ETIR__C_STA_PQ
)
5081 /* xgettext:c-format */
5082 _bfd_error_handler (_("Unknown reloc %s + %s"),
5083 _bfd_vms_etir_name (prev_cmd
),
5084 _bfd_vms_etir_name (ETIR__C_STO_OFF
));
5087 reloc_code
= BFD_RELOC_64
;
5090 case ETIR__C_OPR_ADD
: /* ALPHA_R_REFLONG und_section, step 3 */
5091 /* ALPHA_R_REFQUAD und_section, step 3 */
5092 if (prev_cmd
!= ETIR__C_STA_LW
&& prev_cmd
!= ETIR__C_STA_QW
)
5094 /* xgettext:c-format */
5095 _bfd_error_handler (_("Unknown reloc %s + %s"),
5096 _bfd_vms_etir_name (prev_cmd
),
5097 _bfd_vms_etir_name (ETIR__C_OPR_ADD
));
5100 prev_cmd
= ETIR__C_OPR_ADD
;
5103 case ETIR__C_STO_CA
: /* ALPHA_R_CODEADDR */
5104 reloc_code
= BFD_RELOC_ALPHA_CODEADDR
;
5108 case ETIR__C_STO_GBL
: /* ALPHA_R_REFQUAD und_section */
5109 reloc_code
= BFD_RELOC_64
;
5113 case ETIR__C_STO_GBL_LW
: /* ALPHA_R_REFLONG und_section */
5114 reloc_code
= BFD_RELOC_32
;
5118 case ETIR__C_STC_LP_PSB
: /* ALPHA_R_LINKAGE */
5119 reloc_code
= BFD_RELOC_ALPHA_LINKAGE
;
5123 case ETIR__C_STC_NOP_GBL
: /* ALPHA_R_NOP */
5124 reloc_code
= BFD_RELOC_ALPHA_NOP
;
5127 case ETIR__C_STC_BSR_GBL
: /* ALPHA_R_BSR */
5128 reloc_code
= BFD_RELOC_ALPHA_BSR
;
5131 case ETIR__C_STC_LDA_GBL
: /* ALPHA_R_LDA */
5132 reloc_code
= BFD_RELOC_ALPHA_LDA
;
5135 case ETIR__C_STC_BOH_GBL
: /* ALPHA_R_BOH */
5136 reloc_code
= BFD_RELOC_ALPHA_BOH
;
5140 cur_sym
= ptr
+ 4 + 32;
5141 cur_address
= bfd_getl64 (ptr
+ 4 + 8);
5142 cur_addend
= bfd_getl64 (ptr
+ 4 + 24);
5145 case ETIR__C_STO_IMM
:
5146 vaddr
+= bfd_getl32 (ptr
+ 4);
5150 _bfd_error_handler (_("Unknown reloc %s"),
5151 _bfd_vms_etir_name (cmd
));
5157 struct vms_section_data_struct
*vms_sec
;
5160 /* Get section to which the relocation applies. */
5161 if (cur_psect
< 0 || cur_psect
> (int)PRIV (section_count
))
5163 _bfd_error_handler (_("Invalid section index in ETIR"));
5167 if (PRIV (sections
) == NULL
)
5169 sec
= PRIV (sections
)[cur_psect
];
5170 if (sec
== bfd_abs_section_ptr
)
5172 _bfd_error_handler (_("Relocation for non-REL psect"));
5176 vms_sec
= vms_section_data (sec
);
5178 /* Allocate a reloc entry. */
5179 if (sec
->reloc_count
>= vms_sec
->reloc_max
)
5181 if (vms_sec
->reloc_max
== 0)
5183 vms_sec
->reloc_max
= 64;
5184 sec
->relocation
= bfd_zmalloc
5185 (vms_sec
->reloc_max
* sizeof (arelent
));
5189 vms_sec
->reloc_max
*= 2;
5190 sec
->relocation
= bfd_realloc
5191 (sec
->relocation
, vms_sec
->reloc_max
* sizeof (arelent
));
5194 reloc
= &sec
->relocation
[sec
->reloc_count
];
5197 reloc
->howto
= bfd_reloc_type_lookup (abfd
, reloc_code
);
5199 if (cur_sym
!= NULL
)
5202 unsigned int symlen
= *cur_sym
;
5205 /* Linear search. */
5210 for (j
= 0; j
< PRIV (gsd_sym_count
); j
++)
5211 if (PRIV (syms
)[j
]->namelen
== symlen
5212 && memcmp (PRIV (syms
)[j
]->name
, cur_sym
, symlen
) == 0)
5214 sym
= &PRIV (csymbols
)[j
];
5219 _bfd_error_handler (_("Unknown symbol in command %s"),
5220 _bfd_vms_etir_name (cmd
));
5221 reloc
->sym_ptr_ptr
= NULL
;
5224 reloc
->sym_ptr_ptr
= sym
;
5226 else if (cur_psidx
>= 0)
5228 if (PRIV (sections
) == NULL
|| cur_psidx
>= (int) PRIV (section_count
))
5230 reloc
->sym_ptr_ptr
=
5231 PRIV (sections
)[cur_psidx
]->symbol_ptr_ptr
;
5234 reloc
->sym_ptr_ptr
= NULL
;
5236 reloc
->address
= cur_address
;
5237 reloc
->addend
= cur_addend
;
5239 vaddr
+= bfd_get_reloc_size (reloc
->howto
);
5248 vms_debug2 ((3, "alpha_vms_slurp_relocs: result = TRUE\n"));
5253 /* Return the number of bytes required to store the relocation
5254 information associated with the given section. */
5257 alpha_vms_get_reloc_upper_bound (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*section
)
5259 alpha_vms_slurp_relocs (abfd
);
5261 return (section
->reloc_count
+ 1) * sizeof (arelent
*);
5264 /* Convert relocations from VMS (external) form into BFD internal
5265 form. Return the number of relocations. */
5268 alpha_vms_canonicalize_reloc (bfd
*abfd
, asection
*section
, arelent
**relptr
,
5269 asymbol
**symbols ATTRIBUTE_UNUSED
)
5274 if (!alpha_vms_slurp_relocs (abfd
))
5277 count
= section
->reloc_count
;
5278 tblptr
= section
->relocation
;
5281 *relptr
++ = tblptr
++;
5283 *relptr
= (arelent
*) NULL
;
5284 return section
->reloc_count
;
5287 /* Install a new set of internal relocs. */
5289 #define alpha_vms_set_reloc _bfd_generic_set_reloc
5292 /* This is just copied from ecoff-alpha, needs to be fixed probably. */
5294 /* How to process the various reloc types. */
5296 static bfd_reloc_status_type
5297 reloc_nil (bfd
* abfd ATTRIBUTE_UNUSED
,
5298 arelent
*reloc ATTRIBUTE_UNUSED
,
5299 asymbol
*sym ATTRIBUTE_UNUSED
,
5300 void * data ATTRIBUTE_UNUSED
,
5301 asection
*sec ATTRIBUTE_UNUSED
,
5302 bfd
*output_bfd ATTRIBUTE_UNUSED
,
5303 char **error_message ATTRIBUTE_UNUSED
)
5306 vms_debug (1, "reloc_nil (abfd %p, output_bfd %p)\n", abfd
, output_bfd
);
5307 vms_debug (2, "In section %s, symbol %s\n",
5308 sec
->name
, sym
->name
);
5309 vms_debug (2, "reloc sym %s, addr %08lx, addend %08lx, reloc is a %s\n",
5310 reloc
->sym_ptr_ptr
[0]->name
,
5311 (unsigned long)reloc
->address
,
5312 (unsigned long)reloc
->addend
, reloc
->howto
->name
);
5313 vms_debug (2, "data at %p\n", data
);
5314 /* _bfd_hexdump (2, data, bfd_get_reloc_size (reloc->howto), 0); */
5317 return bfd_reloc_ok
;
5320 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
5321 from smaller values. Start with zero, widen, *then* decrement. */
5322 #define MINUS_ONE (((bfd_vma)0) - 1)
5324 static reloc_howto_type alpha_howto_table
[] =
5326 HOWTO (ALPHA_R_IGNORE
, /* Type. */
5327 0, /* Rightshift. */
5328 0, /* Size (0 = byte, 1 = short, 2 = long). */
5330 TRUE
, /* PC relative. */
5332 complain_overflow_dont
,/* Complain_on_overflow. */
5333 reloc_nil
, /* Special_function. */
5334 "IGNORE", /* Name. */
5335 TRUE
, /* Partial_inplace. */
5336 0, /* Source mask */
5338 TRUE
), /* PC rel offset. */
5340 /* A 64 bit reference to a symbol. */
5341 HOWTO (ALPHA_R_REFQUAD
, /* Type. */
5342 0, /* Rightshift. */
5343 4, /* Size (0 = byte, 1 = short, 2 = long). */
5345 FALSE
, /* PC relative. */
5347 complain_overflow_bitfield
, /* Complain_on_overflow. */
5348 reloc_nil
, /* Special_function. */
5349 "REFQUAD", /* Name. */
5350 TRUE
, /* Partial_inplace. */
5351 MINUS_ONE
, /* Source mask. */
5352 MINUS_ONE
, /* Dest mask. */
5353 FALSE
), /* PC rel offset. */
5355 /* A 21 bit branch. The native assembler generates these for
5356 branches within the text segment, and also fills in the PC
5357 relative offset in the instruction. */
5358 HOWTO (ALPHA_R_BRADDR
, /* Type. */
5359 2, /* Rightshift. */
5360 2, /* Size (0 = byte, 1 = short, 2 = long). */
5362 TRUE
, /* PC relative. */
5364 complain_overflow_signed
, /* Complain_on_overflow. */
5365 reloc_nil
, /* Special_function. */
5366 "BRADDR", /* Name. */
5367 TRUE
, /* Partial_inplace. */
5368 0x1fffff, /* Source mask. */
5369 0x1fffff, /* Dest mask. */
5370 FALSE
), /* PC rel offset. */
5372 /* A hint for a jump to a register. */
5373 HOWTO (ALPHA_R_HINT
, /* Type. */
5374 2, /* Rightshift. */
5375 1, /* Size (0 = byte, 1 = short, 2 = long). */
5377 TRUE
, /* PC relative. */
5379 complain_overflow_dont
,/* Complain_on_overflow. */
5380 reloc_nil
, /* Special_function. */
5382 TRUE
, /* Partial_inplace. */
5383 0x3fff, /* Source mask. */
5384 0x3fff, /* Dest mask. */
5385 FALSE
), /* PC rel offset. */
5387 /* 16 bit PC relative offset. */
5388 HOWTO (ALPHA_R_SREL16
, /* Type. */
5389 0, /* Rightshift. */
5390 1, /* Size (0 = byte, 1 = short, 2 = long). */
5392 TRUE
, /* PC relative. */
5394 complain_overflow_signed
, /* Complain_on_overflow. */
5395 reloc_nil
, /* Special_function. */
5396 "SREL16", /* Name. */
5397 TRUE
, /* Partial_inplace. */
5398 0xffff, /* Source mask. */
5399 0xffff, /* Dest mask. */
5400 FALSE
), /* PC rel offset. */
5402 /* 32 bit PC relative offset. */
5403 HOWTO (ALPHA_R_SREL32
, /* Type. */
5404 0, /* Rightshift. */
5405 2, /* Size (0 = byte, 1 = short, 2 = long). */
5407 TRUE
, /* PC relative. */
5409 complain_overflow_signed
, /* Complain_on_overflow. */
5410 reloc_nil
, /* Special_function. */
5411 "SREL32", /* Name. */
5412 TRUE
, /* Partial_inplace. */
5413 0xffffffff, /* Source mask. */
5414 0xffffffff, /* Dest mask. */
5415 FALSE
), /* PC rel offset. */
5417 /* A 64 bit PC relative offset. */
5418 HOWTO (ALPHA_R_SREL64
, /* Type. */
5419 0, /* Rightshift. */
5420 4, /* Size (0 = byte, 1 = short, 2 = long). */
5422 TRUE
, /* PC relative. */
5424 complain_overflow_signed
, /* Complain_on_overflow. */
5425 reloc_nil
, /* Special_function. */
5426 "SREL64", /* Name. */
5427 TRUE
, /* Partial_inplace. */
5428 MINUS_ONE
, /* Source mask. */
5429 MINUS_ONE
, /* Dest mask. */
5430 FALSE
), /* PC rel offset. */
5432 /* Push a value on the reloc evaluation stack. */
5433 HOWTO (ALPHA_R_OP_PUSH
, /* Type. */
5434 0, /* Rightshift. */
5435 0, /* Size (0 = byte, 1 = short, 2 = long). */
5437 FALSE
, /* PC relative. */
5439 complain_overflow_dont
,/* Complain_on_overflow. */
5440 reloc_nil
, /* Special_function. */
5441 "OP_PUSH", /* Name. */
5442 FALSE
, /* Partial_inplace. */
5443 0, /* Source mask. */
5445 FALSE
), /* PC rel offset. */
5447 /* Store the value from the stack at the given address. Store it in
5448 a bitfield of size r_size starting at bit position r_offset. */
5449 HOWTO (ALPHA_R_OP_STORE
, /* Type. */
5450 0, /* Rightshift. */
5451 4, /* Size (0 = byte, 1 = short, 2 = long). */
5453 FALSE
, /* PC relative. */
5455 complain_overflow_dont
,/* Complain_on_overflow. */
5456 reloc_nil
, /* Special_function. */
5457 "OP_STORE", /* Name. */
5458 FALSE
, /* Partial_inplace. */
5459 0, /* Source mask. */
5460 MINUS_ONE
, /* Dest mask. */
5461 FALSE
), /* PC rel offset. */
5463 /* Subtract the reloc address from the value on the top of the
5464 relocation stack. */
5465 HOWTO (ALPHA_R_OP_PSUB
, /* Type. */
5466 0, /* Rightshift. */
5467 0, /* Size (0 = byte, 1 = short, 2 = long). */
5469 FALSE
, /* PC relative. */
5471 complain_overflow_dont
,/* Complain_on_overflow. */
5472 reloc_nil
, /* Special_function. */
5473 "OP_PSUB", /* Name. */
5474 FALSE
, /* Partial_inplace. */
5475 0, /* Source mask. */
5477 FALSE
), /* PC rel offset. */
5479 /* Shift the value on the top of the relocation stack right by the
5481 HOWTO (ALPHA_R_OP_PRSHIFT
, /* Type. */
5482 0, /* Rightshift. */
5483 0, /* Size (0 = byte, 1 = short, 2 = long). */
5485 FALSE
, /* PC relative. */
5487 complain_overflow_dont
,/* Complain_on_overflow. */
5488 reloc_nil
, /* Special_function. */
5489 "OP_PRSHIFT", /* Name. */
5490 FALSE
, /* Partial_inplace. */
5491 0, /* Source mask. */
5493 FALSE
), /* PC rel offset. */
5495 /* Hack. Linkage is done by linker. */
5496 HOWTO (ALPHA_R_LINKAGE
, /* Type. */
5497 0, /* Rightshift. */
5498 8, /* Size (0 = byte, 1 = short, 2 = long). */
5500 FALSE
, /* PC relative. */
5502 complain_overflow_dont
,/* Complain_on_overflow. */
5503 reloc_nil
, /* Special_function. */
5504 "LINKAGE", /* Name. */
5505 FALSE
, /* Partial_inplace. */
5506 0, /* Source mask. */
5508 FALSE
), /* PC rel offset. */
5510 /* A 32 bit reference to a symbol. */
5511 HOWTO (ALPHA_R_REFLONG
, /* Type. */
5512 0, /* Rightshift. */
5513 2, /* Size (0 = byte, 1 = short, 2 = long). */
5515 FALSE
, /* PC relative. */
5517 complain_overflow_bitfield
, /* Complain_on_overflow. */
5518 reloc_nil
, /* Special_function. */
5519 "REFLONG", /* Name. */
5520 TRUE
, /* Partial_inplace. */
5521 0xffffffff, /* Source mask. */
5522 0xffffffff, /* Dest mask. */
5523 FALSE
), /* PC rel offset. */
5525 /* A 64 bit reference to a procedure, written as 32 bit value. */
5526 HOWTO (ALPHA_R_CODEADDR
, /* Type. */
5527 0, /* Rightshift. */
5528 4, /* Size (0 = byte, 1 = short, 2 = long). */
5530 FALSE
, /* PC relative. */
5532 complain_overflow_signed
,/* Complain_on_overflow. */
5533 reloc_nil
, /* Special_function. */
5534 "CODEADDR", /* Name. */
5535 FALSE
, /* Partial_inplace. */
5536 0xffffffff, /* Source mask. */
5537 0xffffffff, /* Dest mask. */
5538 FALSE
), /* PC rel offset. */
5540 HOWTO (ALPHA_R_NOP
, /* Type. */
5541 0, /* Rightshift. */
5542 3, /* Size (0 = byte, 1 = short, 2 = long). */
5544 /* The following value must match that of ALPHA_R_BSR/ALPHA_R_BOH
5545 because the calculations for the 3 relocations are the same.
5546 See B.4.5.2 of the OpenVMS Linker Utility Manual. */
5547 TRUE
, /* PC relative. */
5549 complain_overflow_dont
,/* Complain_on_overflow. */
5550 reloc_nil
, /* Special_function. */
5552 FALSE
, /* Partial_inplace. */
5553 0xffffffff, /* Source mask. */
5554 0xffffffff, /* Dest mask. */
5555 FALSE
), /* PC rel offset. */
5557 HOWTO (ALPHA_R_BSR
, /* Type. */
5558 0, /* Rightshift. */
5559 3, /* Size (0 = byte, 1 = short, 2 = long). */
5561 TRUE
, /* PC relative. */
5563 complain_overflow_dont
,/* Complain_on_overflow. */
5564 reloc_nil
, /* Special_function. */
5566 FALSE
, /* Partial_inplace. */
5567 0xffffffff, /* Source mask. */
5568 0xffffffff, /* Dest mask. */
5569 FALSE
), /* PC rel offset. */
5571 HOWTO (ALPHA_R_LDA
, /* Type. */
5572 0, /* Rightshift. */
5573 3, /* Size (0 = byte, 1 = short, 2 = long). */
5575 FALSE
, /* PC relative. */
5577 complain_overflow_dont
,/* Complain_on_overflow. */
5578 reloc_nil
, /* Special_function. */
5580 FALSE
, /* Partial_inplace. */
5581 0xffffffff, /* Source mask. */
5582 0xffffffff, /* Dest mask. */
5583 FALSE
), /* PC rel offset. */
5585 HOWTO (ALPHA_R_BOH
, /* Type. */
5586 0, /* Rightshift. */
5587 3, /* Size (0 = byte, 1 = short, 2 = long, 3 = nil). */
5589 TRUE
, /* PC relative. */
5591 complain_overflow_dont
,/* Complain_on_overflow. */
5592 reloc_nil
, /* Special_function. */
5594 FALSE
, /* Partial_inplace. */
5595 0xffffffff, /* Source mask. */
5596 0xffffffff, /* Dest mask. */
5597 FALSE
), /* PC rel offset. */
5600 /* Return a pointer to a howto structure which, when invoked, will perform
5601 the relocation code on data from the architecture noted. */
5603 static const struct reloc_howto_struct
*
5604 alpha_vms_bfd_reloc_type_lookup (bfd
* abfd ATTRIBUTE_UNUSED
,
5605 bfd_reloc_code_real_type code
)
5609 vms_debug2 ((1, "vms_bfd_reloc_type_lookup (%p, %d)\t", abfd
, code
));
5613 case BFD_RELOC_16
: alpha_type
= ALPHA_R_SREL16
; break;
5614 case BFD_RELOC_32
: alpha_type
= ALPHA_R_REFLONG
; break;
5615 case BFD_RELOC_64
: alpha_type
= ALPHA_R_REFQUAD
; break;
5616 case BFD_RELOC_CTOR
: alpha_type
= ALPHA_R_REFQUAD
; break;
5617 case BFD_RELOC_23_PCREL_S2
: alpha_type
= ALPHA_R_BRADDR
; break;
5618 case BFD_RELOC_ALPHA_HINT
: alpha_type
= ALPHA_R_HINT
; break;
5619 case BFD_RELOC_16_PCREL
: alpha_type
= ALPHA_R_SREL16
; break;
5620 case BFD_RELOC_32_PCREL
: alpha_type
= ALPHA_R_SREL32
; break;
5621 case BFD_RELOC_64_PCREL
: alpha_type
= ALPHA_R_SREL64
; break;
5622 case BFD_RELOC_ALPHA_LINKAGE
: alpha_type
= ALPHA_R_LINKAGE
; break;
5623 case BFD_RELOC_ALPHA_CODEADDR
: alpha_type
= ALPHA_R_CODEADDR
; break;
5624 case BFD_RELOC_ALPHA_NOP
: alpha_type
= ALPHA_R_NOP
; break;
5625 case BFD_RELOC_ALPHA_BSR
: alpha_type
= ALPHA_R_BSR
; break;
5626 case BFD_RELOC_ALPHA_LDA
: alpha_type
= ALPHA_R_LDA
; break;
5627 case BFD_RELOC_ALPHA_BOH
: alpha_type
= ALPHA_R_BOH
; break;
5629 _bfd_error_handler (_("reloc (%d) is *UNKNOWN*"), code
);
5632 vms_debug2 ((2, "reloc is %s\n", alpha_howto_table
[alpha_type
].name
));
5633 return & alpha_howto_table
[alpha_type
];
5636 static reloc_howto_type
*
5637 alpha_vms_bfd_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
5643 i
< sizeof (alpha_howto_table
) / sizeof (alpha_howto_table
[0]);
5645 if (alpha_howto_table
[i
].name
!= NULL
5646 && strcasecmp (alpha_howto_table
[i
].name
, r_name
) == 0)
5647 return &alpha_howto_table
[i
];
5653 alpha_vms_get_synthetic_symtab (bfd
*abfd
,
5654 long symcount ATTRIBUTE_UNUSED
,
5655 asymbol
**usyms ATTRIBUTE_UNUSED
,
5656 long dynsymcount ATTRIBUTE_UNUSED
,
5657 asymbol
**dynsyms ATTRIBUTE_UNUSED
,
5664 syms
= (asymbol
*) bfd_malloc (PRIV (norm_sym_count
) * sizeof (asymbol
));
5669 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
5671 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
5682 flags
= BSF_LOCAL
| BSF_SYNTHETIC
;
5689 if ((e
->flags
& EGSY__V_DEF
) && (e
->flags
& EGSY__V_NORM
))
5691 value
= e
->code_value
;
5692 sec
= e
->code_section
;
5703 sname
= bfd_alloc (abfd
, l
+ 5);
5706 memcpy (sname
, name
, l
);
5707 memcpy (sname
+ l
, "..en", 5);
5714 sym
->udata
.p
= NULL
;
5723 vms_time_to_str (unsigned char *buf
)
5725 time_t t
= vms_rawtime_to_time_t (buf
);
5726 char *res
= ctime (&t
);
5729 res
= "*invalid time*";
5736 evax_bfd_print_emh (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5738 struct vms_emh_common
*emh
= (struct vms_emh_common
*)rec
;
5739 unsigned int subtype
;
5741 subtype
= (unsigned)bfd_getl16 (emh
->subtyp
);
5743 /* xgettext:c-format */
5744 fprintf (file
, _(" EMH %u (len=%u): "), subtype
, rec_len
);
5746 /* PR 21618: Check for invalid lengths. */
5747 if (rec_len
< sizeof (* emh
))
5749 fprintf (file
, _(" Error: The length is less than the length of an EMH record\n"));
5757 struct vms_emh_mhd
*mhd
= (struct vms_emh_mhd
*)rec
;
5760 fprintf (file
, _("Module header\n"));
5761 fprintf (file
, _(" structure level: %u\n"), mhd
->strlvl
);
5762 fprintf (file
, _(" max record size: %u\n"),
5763 (unsigned)bfd_getl32 (mhd
->recsiz
));
5764 name
= (char *)(mhd
+ 1);
5765 fprintf (file
, _(" module name : %.*s\n"), name
[0], name
+ 1);
5766 name
+= name
[0] + 1;
5767 fprintf (file
, _(" module version : %.*s\n"), name
[0], name
+ 1);
5768 name
+= name
[0] + 1;
5769 fprintf (file
, _(" compile date : %.17s\n"), name
);
5774 fprintf (file
, _("Language Processor Name\n"));
5775 fprintf (file
, _(" language name: %.*s\n"),
5776 (int)(rec_len
- sizeof (struct vms_emh_common
)),
5777 (char *)rec
+ sizeof (struct vms_emh_common
));
5782 fprintf (file
, _("Source Files Header\n"));
5783 fprintf (file
, _(" file: %.*s\n"),
5784 (int)(rec_len
- sizeof (struct vms_emh_common
)),
5785 (char *)rec
+ sizeof (struct vms_emh_common
));
5790 fprintf (file
, _("Title Text Header\n"));
5791 fprintf (file
, _(" title: %.*s\n"),
5792 (int)(rec_len
- sizeof (struct vms_emh_common
)),
5793 (char *)rec
+ sizeof (struct vms_emh_common
));
5798 fprintf (file
, _("Copyright Header\n"));
5799 fprintf (file
, _(" copyright: %.*s\n"),
5800 (int)(rec_len
- sizeof (struct vms_emh_common
)),
5801 (char *)rec
+ sizeof (struct vms_emh_common
));
5805 fprintf (file
, _("unhandled emh subtype %u\n"), subtype
);
5811 evax_bfd_print_eeom (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5813 struct vms_eeom
*eeom
= (struct vms_eeom
*)rec
;
5815 fprintf (file
, _(" EEOM (len=%u):\n"), rec_len
);
5817 /* PR 21618: Check for invalid lengths. */
5818 if (rec_len
< sizeof (* eeom
))
5820 fprintf (file
, _(" Error: The length is less than the length of an EEOM record\n"));
5824 fprintf (file
, _(" number of cond linkage pairs: %u\n"),
5825 (unsigned)bfd_getl32 (eeom
->total_lps
));
5826 fprintf (file
, _(" completion code: %u\n"),
5827 (unsigned)bfd_getl16 (eeom
->comcod
));
5830 fprintf (file
, _(" transfer addr flags: 0x%02x\n"), eeom
->tfrflg
);
5831 fprintf (file
, _(" transfer addr psect: %u\n"),
5832 (unsigned)bfd_getl32 (eeom
->psindx
));
5833 fprintf (file
, _(" transfer address : 0x%08x\n"),
5834 (unsigned)bfd_getl32 (eeom
->tfradr
));
5839 exav_bfd_print_egsy_flags (unsigned int flags
, FILE *file
)
5841 if (flags
& EGSY__V_WEAK
)
5842 fputs (_(" WEAK"), file
);
5843 if (flags
& EGSY__V_DEF
)
5844 fputs (_(" DEF"), file
);
5845 if (flags
& EGSY__V_UNI
)
5846 fputs (_(" UNI"), file
);
5847 if (flags
& EGSY__V_REL
)
5848 fputs (_(" REL"), file
);
5849 if (flags
& EGSY__V_COMM
)
5850 fputs (_(" COMM"), file
);
5851 if (flags
& EGSY__V_VECEP
)
5852 fputs (_(" VECEP"), file
);
5853 if (flags
& EGSY__V_NORM
)
5854 fputs (_(" NORM"), file
);
5855 if (flags
& EGSY__V_QUAD_VAL
)
5856 fputs (_(" QVAL"), file
);
5860 evax_bfd_print_egsd_flags (FILE *file
, unsigned int flags
)
5862 if (flags
& EGPS__V_PIC
)
5863 fputs (_(" PIC"), file
);
5864 if (flags
& EGPS__V_LIB
)
5865 fputs (_(" LIB"), file
);
5866 if (flags
& EGPS__V_OVR
)
5867 fputs (_(" OVR"), file
);
5868 if (flags
& EGPS__V_REL
)
5869 fputs (_(" REL"), file
);
5870 if (flags
& EGPS__V_GBL
)
5871 fputs (_(" GBL"), file
);
5872 if (flags
& EGPS__V_SHR
)
5873 fputs (_(" SHR"), file
);
5874 if (flags
& EGPS__V_EXE
)
5875 fputs (_(" EXE"), file
);
5876 if (flags
& EGPS__V_RD
)
5877 fputs (_(" RD"), file
);
5878 if (flags
& EGPS__V_WRT
)
5879 fputs (_(" WRT"), file
);
5880 if (flags
& EGPS__V_VEC
)
5881 fputs (_(" VEC"), file
);
5882 if (flags
& EGPS__V_NOMOD
)
5883 fputs (_(" NOMOD"), file
);
5884 if (flags
& EGPS__V_COM
)
5885 fputs (_(" COM"), file
);
5886 if (flags
& EGPS__V_ALLOC_64BIT
)
5887 fputs (_(" 64B"), file
);
5891 evax_bfd_print_egsd (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5893 unsigned int off
= sizeof (struct vms_egsd
);
5896 fprintf (file
, _(" EGSD (len=%u):\n"), rec_len
);
5899 for (off
= sizeof (struct vms_egsd
); off
< rec_len
; )
5901 struct vms_egsd_entry
*e
= (struct vms_egsd_entry
*)(rec
+ off
);
5905 type
= (unsigned)bfd_getl16 (e
->gsdtyp
);
5906 len
= (unsigned)bfd_getl16 (e
->gsdsiz
);
5908 /* xgettext:c-format */
5909 fprintf (file
, _(" EGSD entry %2u (type: %u, len: %u): "),
5913 if (off
+ len
> rec_len
|| off
+ len
< off
)
5915 fprintf (file
, _(" Error: length larger than remaining space in record\n"));
5923 struct vms_egps
*egps
= (struct vms_egps
*)e
;
5924 unsigned int flags
= bfd_getl16 (egps
->flags
);
5927 fprintf (file
, _("PSC - Program section definition\n"));
5928 fprintf (file
, _(" alignment : 2**%u\n"), egps
->align
);
5929 fprintf (file
, _(" flags : 0x%04x"), flags
);
5930 evax_bfd_print_egsd_flags (file
, flags
);
5932 l
= bfd_getl32 (egps
->alloc
);
5933 fprintf (file
, _(" alloc (len): %u (0x%08x)\n"), l
, l
);
5934 fprintf (file
, _(" name : %.*s\n"),
5935 egps
->namlng
, egps
->name
);
5940 struct vms_esgps
*esgps
= (struct vms_esgps
*)e
;
5941 unsigned int flags
= bfd_getl16 (esgps
->flags
);
5944 fprintf (file
, _("SPSC - Shared Image Program section def\n"));
5945 fprintf (file
, _(" alignment : 2**%u\n"), esgps
->align
);
5946 fprintf (file
, _(" flags : 0x%04x"), flags
);
5947 evax_bfd_print_egsd_flags (file
, flags
);
5949 l
= bfd_getl32 (esgps
->alloc
);
5950 fprintf (file
, _(" alloc (len) : %u (0x%08x)\n"), l
, l
);
5951 fprintf (file
, _(" image offset : 0x%08x\n"),
5952 (unsigned int)bfd_getl32 (esgps
->base
));
5953 fprintf (file
, _(" symvec offset : 0x%08x\n"),
5954 (unsigned int)bfd_getl32 (esgps
->value
));
5955 fprintf (file
, _(" name : %.*s\n"),
5956 esgps
->namlng
, esgps
->name
);
5961 struct vms_egsy
*egsy
= (struct vms_egsy
*)e
;
5962 unsigned int flags
= bfd_getl16 (egsy
->flags
);
5964 if (flags
& EGSY__V_DEF
)
5966 struct vms_esdf
*esdf
= (struct vms_esdf
*)e
;
5968 fprintf (file
, _("SYM - Global symbol definition\n"));
5969 fprintf (file
, _(" flags: 0x%04x"), flags
);
5970 exav_bfd_print_egsy_flags (flags
, file
);
5972 fprintf (file
, _(" psect offset: 0x%08x\n"),
5973 (unsigned)bfd_getl32 (esdf
->value
));
5974 if (flags
& EGSY__V_NORM
)
5976 fprintf (file
, _(" code address: 0x%08x\n"),
5977 (unsigned)bfd_getl32 (esdf
->code_address
));
5978 fprintf (file
, _(" psect index for entry point : %u\n"),
5979 (unsigned)bfd_getl32 (esdf
->ca_psindx
));
5981 fprintf (file
, _(" psect index : %u\n"),
5982 (unsigned)bfd_getl32 (esdf
->psindx
));
5983 fprintf (file
, _(" name : %.*s\n"),
5984 esdf
->namlng
, esdf
->name
);
5988 struct vms_esrf
*esrf
= (struct vms_esrf
*)e
;
5990 fprintf (file
, _("SYM - Global symbol reference\n"));
5991 fprintf (file
, _(" name : %.*s\n"),
5992 esrf
->namlng
, esrf
->name
);
5998 struct vms_eidc
*eidc
= (struct vms_eidc
*)e
;
5999 unsigned int flags
= bfd_getl32 (eidc
->flags
);
6002 fprintf (file
, _("IDC - Ident Consistency check\n"));
6003 fprintf (file
, _(" flags : 0x%08x"), flags
);
6004 if (flags
& EIDC__V_BINIDENT
)
6005 fputs (" BINDENT", file
);
6007 fprintf (file
, _(" id match : %x\n"),
6008 (flags
>> EIDC__V_IDMATCH_SH
) & EIDC__V_IDMATCH_MASK
);
6009 fprintf (file
, _(" error severity: %x\n"),
6010 (flags
>> EIDC__V_ERRSEV_SH
) & EIDC__V_ERRSEV_MASK
);
6012 fprintf (file
, _(" entity name : %.*s\n"), p
[0], p
+ 1);
6014 fprintf (file
, _(" object name : %.*s\n"), p
[0], p
+ 1);
6016 if (flags
& EIDC__V_BINIDENT
)
6017 fprintf (file
, _(" binary ident : 0x%08x\n"),
6018 (unsigned)bfd_getl32 (p
+ 1));
6020 fprintf (file
, _(" ascii ident : %.*s\n"), p
[0], p
+ 1);
6025 struct vms_egst
*egst
= (struct vms_egst
*)e
;
6026 unsigned int flags
= bfd_getl16 (egst
->header
.flags
);
6028 fprintf (file
, _("SYMG - Universal symbol definition\n"));
6029 fprintf (file
, _(" flags: 0x%04x"), flags
);
6030 exav_bfd_print_egsy_flags (flags
, file
);
6032 fprintf (file
, _(" symbol vector offset: 0x%08x\n"),
6033 (unsigned)bfd_getl32 (egst
->value
));
6034 fprintf (file
, _(" entry point: 0x%08x\n"),
6035 (unsigned)bfd_getl32 (egst
->lp_1
));
6036 fprintf (file
, _(" proc descr : 0x%08x\n"),
6037 (unsigned)bfd_getl32 (egst
->lp_2
));
6038 fprintf (file
, _(" psect index: %u\n"),
6039 (unsigned)bfd_getl32 (egst
->psindx
));
6040 fprintf (file
, _(" name : %.*s\n"),
6041 egst
->namlng
, egst
->name
);
6046 struct vms_esdfv
*esdfv
= (struct vms_esdfv
*)e
;
6047 unsigned int flags
= bfd_getl16 (esdfv
->flags
);
6049 fprintf (file
, _("SYMV - Vectored symbol definition\n"));
6050 fprintf (file
, _(" flags: 0x%04x"), flags
);
6051 exav_bfd_print_egsy_flags (flags
, file
);
6053 fprintf (file
, _(" vector : 0x%08x\n"),
6054 (unsigned)bfd_getl32 (esdfv
->vector
));
6055 fprintf (file
, _(" psect offset: %u\n"),
6056 (unsigned)bfd_getl32 (esdfv
->value
));
6057 fprintf (file
, _(" psect index : %u\n"),
6058 (unsigned)bfd_getl32 (esdfv
->psindx
));
6059 fprintf (file
, _(" name : %.*s\n"),
6060 esdfv
->namlng
, esdfv
->name
);
6065 struct vms_esdfm
*esdfm
= (struct vms_esdfm
*)e
;
6066 unsigned int flags
= bfd_getl16 (esdfm
->flags
);
6068 fprintf (file
, _("SYMM - Global symbol definition with version\n"));
6069 fprintf (file
, _(" flags: 0x%04x"), flags
);
6070 exav_bfd_print_egsy_flags (flags
, file
);
6072 fprintf (file
, _(" version mask: 0x%08x\n"),
6073 (unsigned)bfd_getl32 (esdfm
->version_mask
));
6074 fprintf (file
, _(" psect offset: %u\n"),
6075 (unsigned)bfd_getl32 (esdfm
->value
));
6076 fprintf (file
, _(" psect index : %u\n"),
6077 (unsigned)bfd_getl32 (esdfm
->psindx
));
6078 fprintf (file
, _(" name : %.*s\n"),
6079 esdfm
->namlng
, esdfm
->name
);
6083 fprintf (file
, _("unhandled egsd entry type %u\n"), type
);
6091 evax_bfd_print_hex (FILE *file
, const char *pfx
,
6092 const unsigned char *buf
, unsigned int len
)
6098 for (i
= 0; i
< len
; i
++)
6102 fprintf (file
, " %02x", buf
[i
]);
6115 evax_bfd_print_etir_stc_ir (FILE *file
, const unsigned char *buf
, int is_ps
)
6117 /* xgettext:c-format */
6118 fprintf (file
, _(" linkage index: %u, replacement insn: 0x%08x\n"),
6119 (unsigned)bfd_getl32 (buf
),
6120 (unsigned)bfd_getl32 (buf
+ 16));
6121 /* xgettext:c-format */
6122 fprintf (file
, _(" psect idx 1: %u, offset 1: 0x%08x %08x\n"),
6123 (unsigned)bfd_getl32 (buf
+ 4),
6124 (unsigned)bfd_getl32 (buf
+ 12),
6125 (unsigned)bfd_getl32 (buf
+ 8));
6126 /* xgettext:c-format */
6127 fprintf (file
, _(" psect idx 2: %u, offset 2: 0x%08x %08x\n"),
6128 (unsigned)bfd_getl32 (buf
+ 20),
6129 (unsigned)bfd_getl32 (buf
+ 28),
6130 (unsigned)bfd_getl32 (buf
+ 24));
6132 /* xgettext:c-format */
6133 fprintf (file
, _(" psect idx 3: %u, offset 3: 0x%08x %08x\n"),
6134 (unsigned)bfd_getl32 (buf
+ 32),
6135 (unsigned)bfd_getl32 (buf
+ 40),
6136 (unsigned)bfd_getl32 (buf
+ 36));
6138 fprintf (file
, _(" global name: %.*s\n"), buf
[32], buf
+ 33);
6142 evax_bfd_print_etir (FILE *file
, const char *name
,
6143 unsigned char *rec
, unsigned int rec_len
)
6145 unsigned int off
= sizeof (struct vms_egsd
);
6146 unsigned int sec_len
= 0;
6148 /* xgettext:c-format */
6149 fprintf (file
, _(" %s (len=%u+%u):\n"), name
,
6150 (unsigned)(rec_len
- sizeof (struct vms_eobjrec
)),
6151 (unsigned)sizeof (struct vms_eobjrec
));
6153 for (off
= sizeof (struct vms_eobjrec
); off
< rec_len
; )
6155 struct vms_etir
*etir
= (struct vms_etir
*)(rec
+ off
);
6160 type
= bfd_getl16 (etir
->rectyp
);
6161 size
= bfd_getl16 (etir
->size
);
6162 buf
= rec
+ off
+ sizeof (struct vms_etir
);
6164 if (off
+ size
> rec_len
|| off
+ size
< off
)
6166 fprintf (file
, _(" Error: length larger than remaining space in record\n"));
6170 /* xgettext:c-format */
6171 fprintf (file
, _(" (type: %3u, size: 4+%3u): "), type
, size
- 4);
6174 case ETIR__C_STA_GBL
:
6175 fprintf (file
, _("STA_GBL (stack global) %.*s\n"),
6178 case ETIR__C_STA_LW
:
6179 fprintf (file
, _("STA_LW (stack longword) 0x%08x\n"),
6180 (unsigned)bfd_getl32 (buf
));
6182 case ETIR__C_STA_QW
:
6183 fprintf (file
, _("STA_QW (stack quadword) 0x%08x %08x\n"),
6184 (unsigned)bfd_getl32 (buf
+ 4),
6185 (unsigned)bfd_getl32 (buf
+ 0));
6187 case ETIR__C_STA_PQ
:
6188 fprintf (file
, _("STA_PQ (stack psect base + offset)\n"));
6189 /* xgettext:c-format */
6190 fprintf (file
, _(" psect: %u, offset: 0x%08x %08x\n"),
6191 (unsigned)bfd_getl32 (buf
+ 0),
6192 (unsigned)bfd_getl32 (buf
+ 8),
6193 (unsigned)bfd_getl32 (buf
+ 4));
6195 case ETIR__C_STA_LI
:
6196 fprintf (file
, _("STA_LI (stack literal)\n"));
6198 case ETIR__C_STA_MOD
:
6199 fprintf (file
, _("STA_MOD (stack module)\n"));
6201 case ETIR__C_STA_CKARG
:
6202 fprintf (file
, _("STA_CKARG (compare procedure argument)\n"));
6206 fprintf (file
, _("STO_B (store byte)\n"));
6209 fprintf (file
, _("STO_W (store word)\n"));
6211 case ETIR__C_STO_LW
:
6212 fprintf (file
, _("STO_LW (store longword)\n"));
6214 case ETIR__C_STO_QW
:
6215 fprintf (file
, _("STO_QW (store quadword)\n"));
6217 case ETIR__C_STO_IMMR
:
6219 unsigned int len
= bfd_getl32 (buf
);
6221 _("STO_IMMR (store immediate repeat) %u bytes\n"),
6223 evax_bfd_print_hex (file
, " ", buf
+ 4, len
);
6227 case ETIR__C_STO_GBL
:
6228 fprintf (file
, _("STO_GBL (store global) %.*s\n"),
6231 case ETIR__C_STO_CA
:
6232 fprintf (file
, _("STO_CA (store code address) %.*s\n"),
6235 case ETIR__C_STO_RB
:
6236 fprintf (file
, _("STO_RB (store relative branch)\n"));
6238 case ETIR__C_STO_AB
:
6239 fprintf (file
, _("STO_AB (store absolute branch)\n"));
6241 case ETIR__C_STO_OFF
:
6242 fprintf (file
, _("STO_OFF (store offset to psect)\n"));
6244 case ETIR__C_STO_IMM
:
6246 unsigned int len
= bfd_getl32 (buf
);
6248 _("STO_IMM (store immediate) %u bytes\n"),
6250 evax_bfd_print_hex (file
, " ", buf
+ 4, len
);
6254 case ETIR__C_STO_GBL_LW
:
6255 fprintf (file
, _("STO_GBL_LW (store global longword) %.*s\n"),
6258 case ETIR__C_STO_LP_PSB
:
6259 fprintf (file
, _("STO_OFF (store LP with procedure signature)\n"));
6261 case ETIR__C_STO_HINT_GBL
:
6262 fprintf (file
, _("STO_BR_GBL (store branch global) *todo*\n"));
6264 case ETIR__C_STO_HINT_PS
:
6265 fprintf (file
, _("STO_BR_PS (store branch psect + offset) *todo*\n"));
6268 case ETIR__C_OPR_NOP
:
6269 fprintf (file
, _("OPR_NOP (no-operation)\n"));
6271 case ETIR__C_OPR_ADD
:
6272 fprintf (file
, _("OPR_ADD (add)\n"));
6274 case ETIR__C_OPR_SUB
:
6275 fprintf (file
, _("OPR_SUB (subtract)\n"));
6277 case ETIR__C_OPR_MUL
:
6278 fprintf (file
, _("OPR_MUL (multiply)\n"));
6280 case ETIR__C_OPR_DIV
:
6281 fprintf (file
, _("OPR_DIV (divide)\n"));
6283 case ETIR__C_OPR_AND
:
6284 fprintf (file
, _("OPR_AND (logical and)\n"));
6286 case ETIR__C_OPR_IOR
:
6287 fprintf (file
, _("OPR_IOR (logical inclusive or)\n"));
6289 case ETIR__C_OPR_EOR
:
6290 fprintf (file
, _("OPR_EOR (logical exclusive or)\n"));
6292 case ETIR__C_OPR_NEG
:
6293 fprintf (file
, _("OPR_NEG (negate)\n"));
6295 case ETIR__C_OPR_COM
:
6296 fprintf (file
, _("OPR_COM (complement)\n"));
6298 case ETIR__C_OPR_INSV
:
6299 fprintf (file
, _("OPR_INSV (insert field)\n"));
6301 case ETIR__C_OPR_ASH
:
6302 fprintf (file
, _("OPR_ASH (arithmetic shift)\n"));
6304 case ETIR__C_OPR_USH
:
6305 fprintf (file
, _("OPR_USH (unsigned shift)\n"));
6307 case ETIR__C_OPR_ROT
:
6308 fprintf (file
, _("OPR_ROT (rotate)\n"));
6310 case ETIR__C_OPR_SEL
:
6311 fprintf (file
, _("OPR_SEL (select)\n"));
6313 case ETIR__C_OPR_REDEF
:
6314 fprintf (file
, _("OPR_REDEF (redefine symbol to curr location)\n"));
6316 case ETIR__C_OPR_DFLIT
:
6317 fprintf (file
, _("OPR_REDEF (define a literal)\n"));
6320 case ETIR__C_STC_LP
:
6321 fprintf (file
, _("STC_LP (store cond linkage pair)\n"));
6323 case ETIR__C_STC_LP_PSB
:
6325 _("STC_LP_PSB (store cond linkage pair + signature)\n"));
6326 /* xgettext:c-format */
6327 fprintf (file
, _(" linkage index: %u, procedure: %.*s\n"),
6328 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6329 buf
+= 4 + 1 + buf
[4];
6330 fprintf (file
, _(" signature: %.*s\n"), buf
[0], buf
+ 1);
6332 case ETIR__C_STC_GBL
:
6333 fprintf (file
, _("STC_GBL (store cond global)\n"));
6334 /* xgettext:c-format */
6335 fprintf (file
, _(" linkage index: %u, global: %.*s\n"),
6336 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6338 case ETIR__C_STC_GCA
:
6339 fprintf (file
, _("STC_GCA (store cond code address)\n"));
6340 /* xgettext:c-format */
6341 fprintf (file
, _(" linkage index: %u, procedure name: %.*s\n"),
6342 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6344 case ETIR__C_STC_PS
:
6345 fprintf (file
, _("STC_PS (store cond psect + offset)\n"));
6347 /* xgettext:c-format */
6348 _(" linkage index: %u, psect: %u, offset: 0x%08x %08x\n"),
6349 (unsigned)bfd_getl32 (buf
),
6350 (unsigned)bfd_getl32 (buf
+ 4),
6351 (unsigned)bfd_getl32 (buf
+ 12),
6352 (unsigned)bfd_getl32 (buf
+ 8));
6354 case ETIR__C_STC_NOP_GBL
:
6355 fprintf (file
, _("STC_NOP_GBL (store cond NOP at global addr)\n"));
6356 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6358 case ETIR__C_STC_NOP_PS
:
6359 fprintf (file
, _("STC_NOP_PS (store cond NOP at psect + offset)\n"));
6360 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6362 case ETIR__C_STC_BSR_GBL
:
6363 fprintf (file
, _("STC_BSR_GBL (store cond BSR at global addr)\n"));
6364 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6366 case ETIR__C_STC_BSR_PS
:
6367 fprintf (file
, _("STC_BSR_PS (store cond BSR at psect + offset)\n"));
6368 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6370 case ETIR__C_STC_LDA_GBL
:
6371 fprintf (file
, _("STC_LDA_GBL (store cond LDA at global addr)\n"));
6372 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6374 case ETIR__C_STC_LDA_PS
:
6375 fprintf (file
, _("STC_LDA_PS (store cond LDA at psect + offset)\n"));
6376 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6378 case ETIR__C_STC_BOH_GBL
:
6379 fprintf (file
, _("STC_BOH_GBL (store cond BOH at global addr)\n"));
6380 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6382 case ETIR__C_STC_BOH_PS
:
6383 fprintf (file
, _("STC_BOH_PS (store cond BOH at psect + offset)\n"));
6384 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6386 case ETIR__C_STC_NBH_GBL
:
6388 _("STC_NBH_GBL (store cond or hint at global addr)\n"));
6390 case ETIR__C_STC_NBH_PS
:
6392 _("STC_NBH_PS (store cond or hint at psect + offset)\n"));
6395 case ETIR__C_CTL_SETRB
:
6396 fprintf (file
, _("CTL_SETRB (set relocation base)\n"));
6399 case ETIR__C_CTL_AUGRB
:
6401 unsigned int val
= bfd_getl32 (buf
);
6402 fprintf (file
, _("CTL_AUGRB (augment relocation base) %u\n"), val
);
6405 case ETIR__C_CTL_DFLOC
:
6406 fprintf (file
, _("CTL_DFLOC (define location)\n"));
6408 case ETIR__C_CTL_STLOC
:
6409 fprintf (file
, _("CTL_STLOC (set location)\n"));
6411 case ETIR__C_CTL_STKDL
:
6412 fprintf (file
, _("CTL_STKDL (stack defined location)\n"));
6415 fprintf (file
, _("*unhandled*\n"));
6423 evax_bfd_print_eobj (struct bfd
*abfd
, FILE *file
)
6425 bfd_boolean is_first
= TRUE
;
6426 bfd_boolean has_records
= FALSE
;
6430 unsigned int rec_len
;
6431 unsigned int pad_len
;
6433 unsigned int hdr_size
;
6438 unsigned char buf
[6];
6443 if (bfd_bread (buf
, sizeof (buf
), abfd
) != sizeof (buf
))
6445 fprintf (file
, _("cannot read GST record length\n"));
6448 rec_len
= bfd_getl16 (buf
+ 0);
6449 if (rec_len
== bfd_getl16 (buf
+ 4)
6450 && bfd_getl16 (buf
+ 2) == EOBJ__C_EMH
)
6452 /* The format is raw: record-size, type, record-size. */
6454 pad_len
= (rec_len
+ 1) & ~1U;
6457 else if (rec_len
== EOBJ__C_EMH
)
6459 has_records
= FALSE
;
6460 pad_len
= bfd_getl16 (buf
+ 2);
6466 fprintf (file
, _("cannot find EMH in first GST record\n"));
6469 rec
= bfd_malloc (pad_len
);
6470 memcpy (rec
, buf
+ sizeof (buf
) - hdr_size
, hdr_size
);
6474 unsigned int rec_len2
= 0;
6475 unsigned char hdr
[4];
6479 unsigned char buf_len
[2];
6481 if (bfd_bread (buf_len
, sizeof (buf_len
), abfd
)
6482 != sizeof (buf_len
))
6484 fprintf (file
, _("cannot read GST record length\n"));
6487 rec_len2
= (unsigned)bfd_getl16 (buf_len
);
6490 if (bfd_bread (hdr
, sizeof (hdr
), abfd
) != sizeof (hdr
))
6492 fprintf (file
, _("cannot read GST record header\n"));
6495 rec_len
= (unsigned)bfd_getl16 (hdr
+ 2);
6497 pad_len
= (rec_len
+ 1) & ~1U;
6500 rec
= bfd_malloc (pad_len
);
6501 memcpy (rec
, hdr
, sizeof (hdr
));
6502 hdr_size
= sizeof (hdr
);
6503 if (has_records
&& rec_len2
!= rec_len
)
6505 fprintf (file
, _(" corrupted GST\n"));
6510 if (bfd_bread (rec
+ hdr_size
, pad_len
- hdr_size
, abfd
)
6511 != pad_len
- hdr_size
)
6513 fprintf (file
, _("cannot read GST record\n"));
6517 type
= (unsigned)bfd_getl16 (rec
);
6522 evax_bfd_print_emh (file
, rec
, rec_len
);
6525 evax_bfd_print_egsd (file
, rec
, rec_len
);
6528 evax_bfd_print_eeom (file
, rec
, rec_len
);
6533 evax_bfd_print_etir (file
, "ETIR", rec
, rec_len
);
6536 evax_bfd_print_etir (file
, "EDBG", rec
, rec_len
);
6539 evax_bfd_print_etir (file
, "ETBT", rec
, rec_len
);
6542 fprintf (file
, _(" unhandled EOBJ record type %u\n"), type
);
6550 evax_bfd_print_relocation_records (FILE *file
, const unsigned char *rel
,
6551 unsigned int stride
)
6559 count
= bfd_getl32 (rel
+ 0);
6563 base
= bfd_getl32 (rel
+ 4);
6565 /* xgettext:c-format */
6566 fprintf (file
, _(" bitcount: %u, base addr: 0x%08x\n"),
6570 for (j
= 0; count
> 0; j
+= 4, count
-= 32)
6576 val
= bfd_getl32 (rel
);
6579 /* xgettext:c-format */
6580 fprintf (file
, _(" bitmap: 0x%08x (count: %u):\n"), val
, count
);
6582 for (k
= 0; k
< 32; k
++)
6587 fprintf (file
, _(" %08x"), base
+ (j
* 8 + k
) * stride
);
6602 evax_bfd_print_address_fixups (FILE *file
, const unsigned char *rel
)
6609 count
= bfd_getl32 (rel
+ 0);
6612 /* xgettext:c-format */
6613 fprintf (file
, _(" image %u (%u entries)\n"),
6614 (unsigned)bfd_getl32 (rel
+ 4), count
);
6616 for (j
= 0; j
< count
; j
++)
6618 /* xgettext:c-format */
6619 fprintf (file
, _(" offset: 0x%08x, val: 0x%08x\n"),
6620 (unsigned)bfd_getl32 (rel
+ 0),
6621 (unsigned)bfd_getl32 (rel
+ 4));
6628 evax_bfd_print_reference_fixups (FILE *file
, const unsigned char *rel
)
6637 count
= bfd_getl32 (rel
+ 0);
6640 /* xgettext:c-format */
6641 fprintf (file
, _(" image %u (%u entries), offsets:\n"),
6642 (unsigned)bfd_getl32 (rel
+ 4), count
);
6644 for (j
= 0; j
< count
; j
++)
6648 fprintf (file
, _(" 0x%08x"), (unsigned)bfd_getl32 (rel
));
6663 evax_bfd_print_indent (int indent
, FILE *file
)
6665 for (; indent
; indent
--)
6670 evax_bfd_get_dsc_name (unsigned int v
)
6674 case DSC__K_DTYPE_Z
:
6675 return "Z (Unspecified)";
6676 case DSC__K_DTYPE_V
:
6678 case DSC__K_DTYPE_BU
:
6679 return "BU (Byte logical)";
6680 case DSC__K_DTYPE_WU
:
6681 return "WU (Word logical)";
6682 case DSC__K_DTYPE_LU
:
6683 return "LU (Longword logical)";
6684 case DSC__K_DTYPE_QU
:
6685 return "QU (Quadword logical)";
6686 case DSC__K_DTYPE_B
:
6687 return "B (Byte integer)";
6688 case DSC__K_DTYPE_W
:
6689 return "W (Word integer)";
6690 case DSC__K_DTYPE_L
:
6691 return "L (Longword integer)";
6692 case DSC__K_DTYPE_Q
:
6693 return "Q (Quadword integer)";
6694 case DSC__K_DTYPE_F
:
6695 return "F (Single-precision floating)";
6696 case DSC__K_DTYPE_D
:
6697 return "D (Double-precision floating)";
6698 case DSC__K_DTYPE_FC
:
6699 return "FC (Complex)";
6700 case DSC__K_DTYPE_DC
:
6701 return "DC (Double-precision Complex)";
6702 case DSC__K_DTYPE_T
:
6703 return "T (ASCII text string)";
6704 case DSC__K_DTYPE_NU
:
6705 return "NU (Numeric string, unsigned)";
6706 case DSC__K_DTYPE_NL
:
6707 return "NL (Numeric string, left separate sign)";
6708 case DSC__K_DTYPE_NLO
:
6709 return "NLO (Numeric string, left overpunched sign)";
6710 case DSC__K_DTYPE_NR
:
6711 return "NR (Numeric string, right separate sign)";
6712 case DSC__K_DTYPE_NRO
:
6713 return "NRO (Numeric string, right overpunched sig)";
6714 case DSC__K_DTYPE_NZ
:
6715 return "NZ (Numeric string, zoned sign)";
6716 case DSC__K_DTYPE_P
:
6717 return "P (Packed decimal string)";
6718 case DSC__K_DTYPE_ZI
:
6719 return "ZI (Sequence of instructions)";
6720 case DSC__K_DTYPE_ZEM
:
6721 return "ZEM (Procedure entry mask)";
6722 case DSC__K_DTYPE_DSC
:
6723 return "DSC (Descriptor, used for arrays of dyn strings)";
6724 case DSC__K_DTYPE_OU
:
6725 return "OU (Octaword logical)";
6726 case DSC__K_DTYPE_O
:
6727 return "O (Octaword integer)";
6728 case DSC__K_DTYPE_G
:
6729 return "G (Double precision G floating, 64 bit)";
6730 case DSC__K_DTYPE_H
:
6731 return "H (Quadruple precision floating, 128 bit)";
6732 case DSC__K_DTYPE_GC
:
6733 return "GC (Double precision complex, G floating)";
6734 case DSC__K_DTYPE_HC
:
6735 return "HC (Quadruple precision complex, H floating)";
6736 case DSC__K_DTYPE_CIT
:
6737 return "CIT (COBOL intermediate temporary)";
6738 case DSC__K_DTYPE_BPV
:
6739 return "BPV (Bound Procedure Value)";
6740 case DSC__K_DTYPE_BLV
:
6741 return "BLV (Bound Label Value)";
6742 case DSC__K_DTYPE_VU
:
6743 return "VU (Bit Unaligned)";
6744 case DSC__K_DTYPE_ADT
:
6745 return "ADT (Absolute Date-Time)";
6746 case DSC__K_DTYPE_VT
:
6747 return "VT (Varying Text)";
6748 case DSC__K_DTYPE_T2
:
6749 return "T2 (16-bit char)";
6750 case DSC__K_DTYPE_VT2
:
6751 return "VT2 (16-bit varying char)";
6753 return "?? (unknown)";
6758 evax_bfd_print_desc (const unsigned char *buf
, int indent
, FILE *file
)
6760 unsigned char bclass
= buf
[3];
6761 unsigned char dtype
= buf
[2];
6762 unsigned int len
= (unsigned)bfd_getl16 (buf
);
6763 unsigned int pointer
= (unsigned)bfd_getl32 (buf
+ 4);
6765 evax_bfd_print_indent (indent
, file
);
6767 if (len
== 1 && pointer
== 0xffffffffUL
)
6770 fprintf (file
, _("64 bits *unhandled*\n"));
6774 /* xgettext:c-format */
6775 fprintf (file
, _("class: %u, dtype: %u, length: %u, pointer: 0x%08x\n"),
6776 bclass
, dtype
, len
, pointer
);
6779 case DSC__K_CLASS_NCA
:
6781 const struct vms_dsc_nca
*dsc
= (const void *)buf
;
6783 const unsigned char *b
;
6785 evax_bfd_print_indent (indent
, file
);
6786 fprintf (file
, _("non-contiguous array of %s\n"),
6787 evax_bfd_get_dsc_name (dsc
->dtype
));
6788 evax_bfd_print_indent (indent
+ 1, file
);
6790 /* xgettext:c-format */
6791 _("dimct: %u, aflags: 0x%02x, digits: %u, scale: %u\n"),
6792 dsc
->dimct
, dsc
->aflags
, dsc
->digits
, dsc
->scale
);
6793 evax_bfd_print_indent (indent
+ 1, file
);
6795 /* xgettext:c-format */
6796 _("arsize: %u, a0: 0x%08x\n"),
6797 (unsigned)bfd_getl32 (dsc
->arsize
),
6798 (unsigned)bfd_getl32 (dsc
->a0
));
6799 evax_bfd_print_indent (indent
+ 1, file
);
6800 fprintf (file
, _("Strides:\n"));
6801 b
= buf
+ sizeof (*dsc
);
6802 for (i
= 0; i
< dsc
->dimct
; i
++)
6804 evax_bfd_print_indent (indent
+ 2, file
);
6805 fprintf (file
, "[%u]: %u\n", i
+ 1,
6806 (unsigned)bfd_getl32 (b
));
6809 evax_bfd_print_indent (indent
+ 1, file
);
6810 fprintf (file
, _("Bounds:\n"));
6811 b
= buf
+ sizeof (*dsc
);
6812 for (i
= 0; i
< dsc
->dimct
; i
++)
6814 evax_bfd_print_indent (indent
+ 2, file
);
6815 /* xgettext:c-format */
6816 fprintf (file
, _("[%u]: Lower: %u, upper: %u\n"), i
+ 1,
6817 (unsigned)bfd_getl32 (b
+ 0),
6818 (unsigned)bfd_getl32 (b
+ 4));
6823 case DSC__K_CLASS_UBS
:
6825 const struct vms_dsc_ubs
*ubs
= (const void *)buf
;
6827 evax_bfd_print_indent (indent
, file
);
6828 fprintf (file
, _("unaligned bit-string of %s\n"),
6829 evax_bfd_get_dsc_name (ubs
->dtype
));
6830 evax_bfd_print_indent (indent
+ 1, file
);
6832 /* xgettext:c-format */
6833 _("base: %u, pos: %u\n"),
6834 (unsigned)bfd_getl32 (ubs
->base
),
6835 (unsigned)bfd_getl32 (ubs
->pos
));
6839 fprintf (file
, _("*unhandled*\n"));
6846 evax_bfd_print_valspec (const unsigned char *buf
, int indent
, FILE *file
)
6848 unsigned int vflags
= buf
[0];
6849 unsigned int value
= (unsigned)bfd_getl32 (buf
+ 1);
6850 unsigned int len
= 5;
6852 evax_bfd_print_indent (indent
, file
);
6853 /* xgettext:c-format */
6854 fprintf (file
, _("vflags: 0x%02x, value: 0x%08x "), vflags
, value
);
6859 case DST__K_VFLAGS_NOVAL
:
6860 fprintf (file
, _("(no value)\n"));
6862 case DST__K_VFLAGS_NOTACTIVE
:
6863 fprintf (file
, _("(not active)\n"));
6865 case DST__K_VFLAGS_UNALLOC
:
6866 fprintf (file
, _("(not allocated)\n"));
6868 case DST__K_VFLAGS_DSC
:
6869 fprintf (file
, _("(descriptor)\n"));
6870 evax_bfd_print_desc (buf
+ value
, indent
+ 1, file
);
6872 case DST__K_VFLAGS_TVS
:
6873 fprintf (file
, _("(trailing value)\n"));
6875 case DST__K_VS_FOLLOWS
:
6876 fprintf (file
, _("(value spec follows)\n"));
6878 case DST__K_VFLAGS_BITOFFS
:
6879 fprintf (file
, _("(at bit offset %u)\n"), value
);
6882 /* xgettext:c-format */
6883 fprintf (file
, _("(reg: %u, disp: %u, indir: %u, kind: "),
6884 (vflags
& DST__K_REGNUM_MASK
) >> DST__K_REGNUM_SHIFT
,
6885 vflags
& DST__K_DISP
? 1 : 0,
6886 vflags
& DST__K_INDIR
? 1 : 0);
6887 switch (vflags
& DST__K_VALKIND_MASK
)
6889 case DST__K_VALKIND_LITERAL
:
6890 fputs (_("literal"), file
);
6892 case DST__K_VALKIND_ADDR
:
6893 fputs (_("address"), file
);
6895 case DST__K_VALKIND_DESC
:
6896 fputs (_("desc"), file
);
6898 case DST__K_VALKIND_REG
:
6899 fputs (_("reg"), file
);
6902 fputs (")\n", file
);
6909 evax_bfd_print_typspec (const unsigned char *buf
, int indent
, FILE *file
)
6911 unsigned char kind
= buf
[2];
6912 unsigned int len
= (unsigned)bfd_getl16 (buf
);
6914 evax_bfd_print_indent (indent
, file
);
6915 /* xgettext:c-format */
6916 fprintf (file
, _("len: %2u, kind: %2u "), len
, kind
);
6920 case DST__K_TS_ATOM
:
6921 /* xgettext:c-format */
6922 fprintf (file
, _("atomic, type=0x%02x %s\n"),
6923 buf
[0], evax_bfd_get_dsc_name (buf
[0]));
6926 fprintf (file
, _("indirect, defined at 0x%08x\n"),
6927 (unsigned)bfd_getl32 (buf
));
6929 case DST__K_TS_TPTR
:
6930 fprintf (file
, _("typed pointer\n"));
6931 evax_bfd_print_typspec (buf
, indent
+ 1, file
);
6934 fprintf (file
, _("pointer\n"));
6936 case DST__K_TS_ARRAY
:
6938 const unsigned char *vs
;
6939 unsigned int vec_len
;
6942 fprintf (file
, _("array, dim: %u, bitmap: "), buf
[0]);
6943 vec_len
= (buf
[0] + 1 + 7) / 8;
6944 for (i
= 0; i
< vec_len
; i
++)
6945 fprintf (file
, " %02x", buf
[i
+ 1]);
6947 vs
= buf
+ 1 + vec_len
;
6948 evax_bfd_print_indent (indent
, file
);
6949 fprintf (file
, _("array descriptor:\n"));
6950 vs
+= evax_bfd_print_valspec (vs
, indent
+ 1, file
);
6951 for (i
= 0; i
< buf
[0] + 1U; i
++)
6952 if (buf
[1 + i
/ 8] & (1 << (i
% 8)))
6954 evax_bfd_print_indent (indent
, file
);
6956 fprintf (file
, _("type spec for element:\n"));
6958 fprintf (file
, _("type spec for subscript %u:\n"), i
);
6959 evax_bfd_print_typspec (vs
, indent
+ 1, file
);
6960 vs
+= bfd_getl16 (vs
);
6965 fprintf (file
, _("*unhandled*\n"));
6970 evax_bfd_print_dst (struct bfd
*abfd
, unsigned int dst_size
, FILE *file
)
6972 unsigned int off
= 0;
6973 unsigned int pc
= 0;
6974 unsigned int line
= 0;
6976 fprintf (file
, _("Debug symbol table:\n"));
6978 while (dst_size
> 0)
6980 struct vms_dst_header dsth
;
6985 if (bfd_bread (&dsth
, sizeof (dsth
), abfd
) != sizeof (dsth
))
6987 fprintf (file
, _("cannot read DST header\n"));
6990 len
= bfd_getl16 (dsth
.length
);
6991 type
= bfd_getl16 (dsth
.type
);
6992 /* xgettext:c-format */
6993 fprintf (file
, _(" type: %3u, len: %3u (at 0x%08x): "),
7003 len
-= sizeof (dsth
);
7004 buf
= bfd_malloc (len
);
7005 if (bfd_bread (buf
, len
, abfd
) != len
)
7007 fprintf (file
, _("cannot read DST symbol\n"));
7012 case DSC__K_DTYPE_V
:
7013 case DSC__K_DTYPE_BU
:
7014 case DSC__K_DTYPE_WU
:
7015 case DSC__K_DTYPE_LU
:
7016 case DSC__K_DTYPE_QU
:
7017 case DSC__K_DTYPE_B
:
7018 case DSC__K_DTYPE_W
:
7019 case DSC__K_DTYPE_L
:
7020 case DSC__K_DTYPE_Q
:
7021 case DSC__K_DTYPE_F
:
7022 case DSC__K_DTYPE_D
:
7023 case DSC__K_DTYPE_FC
:
7024 case DSC__K_DTYPE_DC
:
7025 case DSC__K_DTYPE_T
:
7026 case DSC__K_DTYPE_NU
:
7027 case DSC__K_DTYPE_NL
:
7028 case DSC__K_DTYPE_NLO
:
7029 case DSC__K_DTYPE_NR
:
7030 case DSC__K_DTYPE_NRO
:
7031 case DSC__K_DTYPE_NZ
:
7032 case DSC__K_DTYPE_P
:
7033 case DSC__K_DTYPE_ZI
:
7034 case DSC__K_DTYPE_ZEM
:
7035 case DSC__K_DTYPE_DSC
:
7036 case DSC__K_DTYPE_OU
:
7037 case DSC__K_DTYPE_O
:
7038 case DSC__K_DTYPE_G
:
7039 case DSC__K_DTYPE_H
:
7040 case DSC__K_DTYPE_GC
:
7041 case DSC__K_DTYPE_HC
:
7042 case DSC__K_DTYPE_CIT
:
7043 case DSC__K_DTYPE_BPV
:
7044 case DSC__K_DTYPE_BLV
:
7045 case DSC__K_DTYPE_VU
:
7046 case DSC__K_DTYPE_ADT
:
7047 case DSC__K_DTYPE_VT
:
7048 case DSC__K_DTYPE_T2
:
7049 case DSC__K_DTYPE_VT2
:
7050 fprintf (file
, _("standard data: %s\n"),
7051 evax_bfd_get_dsc_name (type
));
7052 evax_bfd_print_valspec (buf
, 4, file
);
7053 fprintf (file
, _(" name: %.*s\n"), buf
[5], buf
+ 6);
7057 struct vms_dst_modbeg
*dst
= (void *)buf
;
7058 const char *name
= (const char *)buf
+ sizeof (*dst
);
7060 fprintf (file
, _("modbeg\n"));
7061 /* xgettext:c-format */
7062 fprintf (file
, _(" flags: %d, language: %u, "
7063 "major: %u, minor: %u\n"),
7065 (unsigned)bfd_getl32 (dst
->language
),
7066 (unsigned)bfd_getl16 (dst
->major
),
7067 (unsigned)bfd_getl16 (dst
->minor
));
7068 fprintf (file
, _(" module name: %.*s\n"),
7070 name
+= name
[0] + 1;
7071 fprintf (file
, _(" compiler : %.*s\n"),
7076 fprintf (file
, _("modend\n"));
7080 struct vms_dst_rtnbeg
*dst
= (void *)buf
;
7081 const char *name
= (const char *)buf
+ sizeof (*dst
);
7083 fputs (_("rtnbeg\n"), file
);
7084 /* xgettext:c-format */
7085 fprintf (file
, _(" flags: %u, address: 0x%08x, "
7086 "pd-address: 0x%08x\n"),
7088 (unsigned)bfd_getl32 (dst
->address
),
7089 (unsigned)bfd_getl32 (dst
->pd_address
));
7090 fprintf (file
, _(" routine name: %.*s\n"),
7096 struct vms_dst_rtnend
*dst
= (void *)buf
;
7098 fprintf (file
, _("rtnend: size 0x%08x\n"),
7099 (unsigned)bfd_getl32 (dst
->size
));
7104 struct vms_dst_prolog
*dst
= (void *)buf
;
7106 fprintf (file
, _("prolog: bkpt address 0x%08x\n"),
7107 (unsigned)bfd_getl32 (dst
->bkpt_addr
));
7112 struct vms_dst_epilog
*dst
= (void *)buf
;
7114 /* xgettext:c-format */
7115 fprintf (file
, _("epilog: flags: %u, count: %u\n"),
7116 dst
->flags
, (unsigned)bfd_getl32 (dst
->count
));
7121 struct vms_dst_blkbeg
*dst
= (void *)buf
;
7122 const char *name
= (const char *)buf
+ sizeof (*dst
);
7124 /* xgettext:c-format */
7125 fprintf (file
, _("blkbeg: address: 0x%08x, name: %.*s\n"),
7126 (unsigned)bfd_getl32 (dst
->address
),
7132 struct vms_dst_blkend
*dst
= (void *)buf
;
7134 fprintf (file
, _("blkend: size: 0x%08x\n"),
7135 (unsigned)bfd_getl32 (dst
->size
));
7138 case DST__K_TYPSPEC
:
7140 fprintf (file
, _("typspec (len: %u)\n"), len
);
7141 fprintf (file
, _(" name: %.*s\n"), buf
[0], buf
+ 1);
7142 evax_bfd_print_typspec (buf
+ 1 + buf
[0], 5, file
);
7147 fprintf (file
, _("septyp, name: %.*s\n"), buf
[5], buf
+ 6);
7148 evax_bfd_print_valspec (buf
, 4, file
);
7153 struct vms_dst_recbeg
*recbeg
= (void *)buf
;
7154 const char *name
= (const char *)buf
+ sizeof (*recbeg
);
7156 fprintf (file
, _("recbeg: name: %.*s\n"), name
[0], name
+ 1);
7157 evax_bfd_print_valspec (buf
, 4, file
);
7158 fprintf (file
, _(" len: %u bits\n"),
7159 (unsigned)bfd_getl32 (name
+ 1 + name
[0]));
7163 fprintf (file
, _("recend\n"));
7165 case DST__K_ENUMBEG
:
7166 /* xgettext:c-format */
7167 fprintf (file
, _("enumbeg, len: %u, name: %.*s\n"),
7168 buf
[0], buf
[1], buf
+ 2);
7170 case DST__K_ENUMELT
:
7171 fprintf (file
, _("enumelt, name: %.*s\n"), buf
[5], buf
+ 6);
7172 evax_bfd_print_valspec (buf
, 4, file
);
7174 case DST__K_ENUMEND
:
7175 fprintf (file
, _("enumend\n"));
7179 struct vms_dst_label
*lab
= (void *)buf
;
7180 fprintf (file
, _("label, name: %.*s\n"),
7181 lab
->name
[0], lab
->name
+ 1);
7182 fprintf (file
, _(" address: 0x%08x\n"),
7183 (unsigned)bfd_getl32 (lab
->value
));
7186 case DST__K_DIS_RANGE
:
7188 unsigned int cnt
= bfd_getl32 (buf
);
7189 unsigned char *rng
= buf
+ 4;
7192 fprintf (file
, _("discontiguous range (nbr: %u)\n"), cnt
);
7193 for (i
= 0; i
< cnt
; i
++, rng
+= 8)
7194 /* xgettext:c-format */
7195 fprintf (file
, _(" address: 0x%08x, size: %u\n"),
7196 (unsigned)bfd_getl32 (rng
),
7197 (unsigned)bfd_getl32 (rng
+ 4));
7201 case DST__K_LINE_NUM
:
7203 unsigned char *buf_orig
= buf
;
7205 fprintf (file
, _("line num (len: %u)\n"), len
);
7210 unsigned char cmdlen
;
7220 case DST__K_DELTA_PC_W
:
7221 val
= bfd_getl16 (buf
+ 1);
7222 fprintf (file
, _("delta_pc_w %u\n"), val
);
7227 case DST__K_INCR_LINUM
:
7229 fprintf (file
, _("incr_linum(b): +%u\n"), val
);
7233 case DST__K_INCR_LINUM_W
:
7234 val
= bfd_getl16 (buf
+ 1);
7235 fprintf (file
, _("incr_linum_w: +%u\n"), val
);
7239 case DST__K_INCR_LINUM_L
:
7240 val
= bfd_getl32 (buf
+ 1);
7241 fprintf (file
, _("incr_linum_l: +%u\n"), val
);
7245 case DST__K_SET_LINUM
:
7246 line
= bfd_getl16 (buf
+ 1);
7247 fprintf (file
, _("set_line_num(w) %u\n"), line
);
7250 case DST__K_SET_LINUM_B
:
7252 fprintf (file
, _("set_line_num_b %u\n"), line
);
7255 case DST__K_SET_LINUM_L
:
7256 line
= bfd_getl32 (buf
+ 1);
7257 fprintf (file
, _("set_line_num_l %u\n"), line
);
7260 case DST__K_SET_ABS_PC
:
7261 pc
= bfd_getl32 (buf
+ 1);
7262 fprintf (file
, _("set_abs_pc: 0x%08x\n"), pc
);
7265 case DST__K_DELTA_PC_L
:
7266 fprintf (file
, _("delta_pc_l: +0x%08x\n"),
7267 (unsigned)bfd_getl32 (buf
+ 1));
7271 fprintf (file
, _("term(b): 0x%02x"), buf
[1]);
7273 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7277 val
= bfd_getl16 (buf
+ 1);
7278 fprintf (file
, _("term_w: 0x%04x"), val
);
7280 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7286 fprintf (file
, _("delta pc +%-4d"), -cmd
);
7287 line
++; /* FIXME: curr increment. */
7289 /* xgettext:c-format */
7290 fprintf (file
, _(" pc: 0x%08x line: %5u\n"),
7295 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7308 unsigned char *buf_orig
= buf
;
7310 fprintf (file
, _("source (len: %u)\n"), len
);
7314 signed char cmd
= buf
[0];
7315 unsigned char cmdlen
= 0;
7319 case DST__K_SRC_DECLFILE
:
7321 struct vms_dst_src_decl_src
*src
= (void *)(buf
+ 1);
7324 /* xgettext:c-format */
7325 fprintf (file
, _(" declfile: len: %u, flags: %u, "
7327 src
->length
, src
->flags
,
7328 (unsigned)bfd_getl16 (src
->fileid
));
7329 /* xgettext:c-format */
7330 fprintf (file
, _(" rms: cdt: 0x%08x %08x, "
7331 "ebk: 0x%08x, ffb: 0x%04x, "
7333 (unsigned)bfd_getl32 (src
->rms_cdt
+ 4),
7334 (unsigned)bfd_getl32 (src
->rms_cdt
+ 0),
7335 (unsigned)bfd_getl32 (src
->rms_ebk
),
7336 (unsigned)bfd_getl16 (src
->rms_ffb
),
7338 name
= (const char *)buf
+ 1 + sizeof (*src
);
7339 fprintf (file
, _(" filename : %.*s\n"),
7341 name
+= name
[0] + 1;
7342 fprintf (file
, _(" module name: %.*s\n"),
7344 cmdlen
= 2 + src
->length
;
7347 case DST__K_SRC_SETFILE
:
7348 fprintf (file
, _(" setfile %u\n"),
7349 (unsigned)bfd_getl16 (buf
+ 1));
7352 case DST__K_SRC_SETREC_W
:
7353 fprintf (file
, _(" setrec %u\n"),
7354 (unsigned)bfd_getl16 (buf
+ 1));
7357 case DST__K_SRC_SETREC_L
:
7358 fprintf (file
, _(" setrec %u\n"),
7359 (unsigned)bfd_getl32 (buf
+ 1));
7362 case DST__K_SRC_SETLNUM_W
:
7363 fprintf (file
, _(" setlnum %u\n"),
7364 (unsigned)bfd_getl16 (buf
+ 1));
7367 case DST__K_SRC_SETLNUM_L
:
7368 fprintf (file
, _(" setlnum %u\n"),
7369 (unsigned)bfd_getl32 (buf
+ 1));
7372 case DST__K_SRC_DEFLINES_W
:
7373 fprintf (file
, _(" deflines %u\n"),
7374 (unsigned)bfd_getl16 (buf
+ 1));
7377 case DST__K_SRC_DEFLINES_B
:
7378 fprintf (file
, _(" deflines %u\n"), buf
[1]);
7381 case DST__K_SRC_FORMFEED
:
7382 fprintf (file
, _(" formfeed\n"));
7386 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7398 fprintf (file
, _("*unhandled* dst type %u\n"), type
);
7406 evax_bfd_print_image (bfd
*abfd
, FILE *file
)
7408 struct vms_eihd eihd
;
7411 unsigned int eiha_off
;
7412 unsigned int eihi_off
;
7413 unsigned int eihs_off
;
7414 unsigned int eisd_off
;
7415 unsigned int eihef_off
= 0;
7416 unsigned int eihnp_off
= 0;
7417 unsigned int dmt_vbn
= 0;
7418 unsigned int dmt_size
= 0;
7419 unsigned int dst_vbn
= 0;
7420 unsigned int dst_size
= 0;
7421 unsigned int gst_vbn
= 0;
7422 unsigned int gst_size
= 0;
7423 unsigned int eiaf_vbn
= 0;
7424 unsigned int eiaf_size
= 0;
7425 unsigned int eihvn_off
;
7427 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
)
7428 || bfd_bread (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
7430 fprintf (file
, _("cannot read EIHD\n"));
7433 /* xgettext:c-format */
7434 fprintf (file
, _("EIHD: (size: %u, nbr blocks: %u)\n"),
7435 (unsigned)bfd_getl32 (eihd
.size
),
7436 (unsigned)bfd_getl32 (eihd
.hdrblkcnt
));
7437 /* xgettext:c-format */
7438 fprintf (file
, _(" majorid: %u, minorid: %u\n"),
7439 (unsigned)bfd_getl32 (eihd
.majorid
),
7440 (unsigned)bfd_getl32 (eihd
.minorid
));
7442 val
= (unsigned)bfd_getl32 (eihd
.imgtype
);
7446 name
= _("executable");
7449 name
= _("linkable image");
7452 name
= _("unknown");
7455 /* xgettext:c-format */
7456 fprintf (file
, _(" image type: %u (%s)"), val
, name
);
7458 val
= (unsigned)bfd_getl32 (eihd
.subtype
);
7461 case EIHD__C_NATIVE
:
7468 name
= _("unknown");
7471 /* xgettext:c-format */
7472 fprintf (file
, _(", subtype: %u (%s)\n"), val
, name
);
7474 eisd_off
= bfd_getl32 (eihd
.isdoff
);
7475 eiha_off
= bfd_getl32 (eihd
.activoff
);
7476 eihi_off
= bfd_getl32 (eihd
.imgidoff
);
7477 eihs_off
= bfd_getl32 (eihd
.symdbgoff
);
7478 /* xgettext:c-format */
7479 fprintf (file
, _(" offsets: isd: %u, activ: %u, symdbg: %u, "
7480 "imgid: %u, patch: %u\n"),
7481 eisd_off
, eiha_off
, eihs_off
, eihi_off
,
7482 (unsigned)bfd_getl32 (eihd
.patchoff
));
7483 fprintf (file
, _(" fixup info rva: "));
7484 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.iafva
));
7485 fprintf (file
, _(", symbol vector rva: "));
7486 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.symvva
));
7487 eihvn_off
= bfd_getl32 (eihd
.version_array_off
);
7488 fprintf (file
, _("\n"
7489 " version array off: %u\n"),
7492 /* xgettext:c-format */
7493 _(" img I/O count: %u, nbr channels: %u, req pri: %08x%08x\n"),
7494 (unsigned)bfd_getl32 (eihd
.imgiocnt
),
7495 (unsigned)bfd_getl32 (eihd
.iochancnt
),
7496 (unsigned)bfd_getl32 (eihd
.privreqs
+ 4),
7497 (unsigned)bfd_getl32 (eihd
.privreqs
+ 0));
7498 val
= (unsigned)bfd_getl32 (eihd
.lnkflags
);
7499 fprintf (file
, _(" linker flags: %08x:"), val
);
7500 if (val
& EIHD__M_LNKDEBUG
)
7501 fprintf (file
, " LNKDEBUG");
7502 if (val
& EIHD__M_LNKNOTFR
)
7503 fprintf (file
, " LNKNOTFR");
7504 if (val
& EIHD__M_NOP0BUFS
)
7505 fprintf (file
, " NOP0BUFS");
7506 if (val
& EIHD__M_PICIMG
)
7507 fprintf (file
, " PICIMG");
7508 if (val
& EIHD__M_P0IMAGE
)
7509 fprintf (file
, " P0IMAGE");
7510 if (val
& EIHD__M_DBGDMT
)
7511 fprintf (file
, " DBGDMT");
7512 if (val
& EIHD__M_INISHR
)
7513 fprintf (file
, " INISHR");
7514 if (val
& EIHD__M_XLATED
)
7515 fprintf (file
, " XLATED");
7516 if (val
& EIHD__M_BIND_CODE_SEC
)
7517 fprintf (file
, " BIND_CODE_SEC");
7518 if (val
& EIHD__M_BIND_DATA_SEC
)
7519 fprintf (file
, " BIND_DATA_SEC");
7520 if (val
& EIHD__M_MKTHREADS
)
7521 fprintf (file
, " MKTHREADS");
7522 if (val
& EIHD__M_UPCALLS
)
7523 fprintf (file
, " UPCALLS");
7524 if (val
& EIHD__M_OMV_READY
)
7525 fprintf (file
, " OMV_READY");
7526 if (val
& EIHD__M_EXT_BIND_SECT
)
7527 fprintf (file
, " EXT_BIND_SECT");
7528 fprintf (file
, "\n");
7529 /* xgettext:c-format */
7530 fprintf (file
, _(" ident: 0x%08x, sysver: 0x%08x, "
7531 "match ctrl: %u, symvect_size: %u\n"),
7532 (unsigned)bfd_getl32 (eihd
.ident
),
7533 (unsigned)bfd_getl32 (eihd
.sysver
),
7535 (unsigned)bfd_getl32 (eihd
.symvect_size
));
7536 fprintf (file
, _(" BPAGE: %u"),
7537 (unsigned)bfd_getl32 (eihd
.virt_mem_block_size
));
7538 if (val
& (EIHD__M_OMV_READY
| EIHD__M_EXT_BIND_SECT
))
7540 eihef_off
= bfd_getl32 (eihd
.ext_fixup_off
);
7541 eihnp_off
= bfd_getl32 (eihd
.noopt_psect_off
);
7542 /* xgettext:c-format */
7543 fprintf (file
, _(", ext fixup offset: %u, no_opt psect off: %u"),
7544 eihef_off
, eihnp_off
);
7546 fprintf (file
, _(", alias: %u\n"), (unsigned)bfd_getl16 (eihd
.alias
));
7550 struct vms_eihvn eihvn
;
7554 fprintf (file
, _("system version array information:\n"));
7555 if (bfd_seek (abfd
, (file_ptr
) eihvn_off
, SEEK_SET
)
7556 || bfd_bread (&eihvn
, sizeof (eihvn
), abfd
) != sizeof (eihvn
))
7558 fprintf (file
, _("cannot read EIHVN header\n"));
7561 mask
= bfd_getl32 (eihvn
.subsystem_mask
);
7562 for (j
= 0; j
< 32; j
++)
7563 if (mask
& (1 << j
))
7565 struct vms_eihvn_subversion ver
;
7566 if (bfd_bread (&ver
, sizeof (ver
), abfd
) != sizeof (ver
))
7568 fprintf (file
, _("cannot read EIHVN version\n"));
7571 fprintf (file
, _(" %02u "), j
);
7574 case EIHVN__BASE_IMAGE_BIT
:
7575 fputs (_("BASE_IMAGE "), file
);
7577 case EIHVN__MEMORY_MANAGEMENT_BIT
:
7578 fputs (_("MEMORY_MANAGEMENT"), file
);
7581 fputs (_("IO "), file
);
7583 case EIHVN__FILES_VOLUMES_BIT
:
7584 fputs (_("FILES_VOLUMES "), file
);
7586 case EIHVN__PROCESS_SCHED_BIT
:
7587 fputs (_("PROCESS_SCHED "), file
);
7589 case EIHVN__SYSGEN_BIT
:
7590 fputs (_("SYSGEN "), file
);
7592 case EIHVN__CLUSTERS_LOCKMGR_BIT
:
7593 fputs (_("CLUSTERS_LOCKMGR "), file
);
7595 case EIHVN__LOGICAL_NAMES_BIT
:
7596 fputs (_("LOGICAL_NAMES "), file
);
7598 case EIHVN__SECURITY_BIT
:
7599 fputs (_("SECURITY "), file
);
7601 case EIHVN__IMAGE_ACTIVATOR_BIT
:
7602 fputs (_("IMAGE_ACTIVATOR "), file
);
7604 case EIHVN__NETWORKS_BIT
:
7605 fputs (_("NETWORKS "), file
);
7607 case EIHVN__COUNTERS_BIT
:
7608 fputs (_("COUNTERS "), file
);
7610 case EIHVN__STABLE_BIT
:
7611 fputs (_("STABLE "), file
);
7613 case EIHVN__MISC_BIT
:
7614 fputs (_("MISC "), file
);
7616 case EIHVN__CPU_BIT
:
7617 fputs (_("CPU "), file
);
7619 case EIHVN__VOLATILE_BIT
:
7620 fputs (_("VOLATILE "), file
);
7622 case EIHVN__SHELL_BIT
:
7623 fputs (_("SHELL "), file
);
7625 case EIHVN__POSIX_BIT
:
7626 fputs (_("POSIX "), file
);
7628 case EIHVN__MULTI_PROCESSING_BIT
:
7629 fputs (_("MULTI_PROCESSING "), file
);
7631 case EIHVN__GALAXY_BIT
:
7632 fputs (_("GALAXY "), file
);
7635 fputs (_("*unknown* "), file
);
7638 fprintf (file
, ": %u.%u\n",
7639 (unsigned)bfd_getl16 (ver
.major
),
7640 (unsigned)bfd_getl16 (ver
.minor
));
7646 struct vms_eiha eiha
;
7648 if (bfd_seek (abfd
, (file_ptr
) eiha_off
, SEEK_SET
)
7649 || bfd_bread (&eiha
, sizeof (eiha
), abfd
) != sizeof (eiha
))
7651 fprintf (file
, _("cannot read EIHA\n"));
7654 fprintf (file
, _("Image activation: (size=%u)\n"),
7655 (unsigned)bfd_getl32 (eiha
.size
));
7656 /* xgettext:c-format */
7657 fprintf (file
, _(" First address : 0x%08x 0x%08x\n"),
7658 (unsigned)bfd_getl32 (eiha
.tfradr1_h
),
7659 (unsigned)bfd_getl32 (eiha
.tfradr1
));
7660 /* xgettext:c-format */
7661 fprintf (file
, _(" Second address: 0x%08x 0x%08x\n"),
7662 (unsigned)bfd_getl32 (eiha
.tfradr2_h
),
7663 (unsigned)bfd_getl32 (eiha
.tfradr2
));
7664 /* xgettext:c-format */
7665 fprintf (file
, _(" Third address : 0x%08x 0x%08x\n"),
7666 (unsigned)bfd_getl32 (eiha
.tfradr3_h
),
7667 (unsigned)bfd_getl32 (eiha
.tfradr3
));
7668 /* xgettext:c-format */
7669 fprintf (file
, _(" Fourth address: 0x%08x 0x%08x\n"),
7670 (unsigned)bfd_getl32 (eiha
.tfradr4_h
),
7671 (unsigned)bfd_getl32 (eiha
.tfradr4
));
7672 /* xgettext:c-format */
7673 fprintf (file
, _(" Shared image : 0x%08x 0x%08x\n"),
7674 (unsigned)bfd_getl32 (eiha
.inishr_h
),
7675 (unsigned)bfd_getl32 (eiha
.inishr
));
7679 struct vms_eihi eihi
;
7681 if (bfd_seek (abfd
, (file_ptr
) eihi_off
, SEEK_SET
)
7682 || bfd_bread (&eihi
, sizeof (eihi
), abfd
) != sizeof (eihi
))
7684 fprintf (file
, _("cannot read EIHI\n"));
7687 /* xgettext:c-format */
7688 fprintf (file
, _("Image identification: (major: %u, minor: %u)\n"),
7689 (unsigned)bfd_getl32 (eihi
.majorid
),
7690 (unsigned)bfd_getl32 (eihi
.minorid
));
7691 fprintf (file
, _(" image name : %.*s\n"),
7692 eihi
.imgnam
[0], eihi
.imgnam
+ 1);
7693 fprintf (file
, _(" link time : %s\n"),
7694 vms_time_to_str (eihi
.linktime
));
7695 fprintf (file
, _(" image ident : %.*s\n"),
7696 eihi
.imgid
[0], eihi
.imgid
+ 1);
7697 fprintf (file
, _(" linker ident : %.*s\n"),
7698 eihi
.linkid
[0], eihi
.linkid
+ 1);
7699 fprintf (file
, _(" image build ident: %.*s\n"),
7700 eihi
.imgbid
[0], eihi
.imgbid
+ 1);
7704 struct vms_eihs eihs
;
7706 if (bfd_seek (abfd
, (file_ptr
) eihs_off
, SEEK_SET
)
7707 || bfd_bread (&eihs
, sizeof (eihs
), abfd
) != sizeof (eihs
))
7709 fprintf (file
, _("cannot read EIHS\n"));
7712 /* xgettext:c-format */
7713 fprintf (file
, _("Image symbol & debug table: (major: %u, minor: %u)\n"),
7714 (unsigned)bfd_getl32 (eihs
.majorid
),
7715 (unsigned)bfd_getl32 (eihs
.minorid
));
7716 dst_vbn
= bfd_getl32 (eihs
.dstvbn
);
7717 dst_size
= bfd_getl32 (eihs
.dstsize
);
7718 /* xgettext:c-format */
7719 fprintf (file
, _(" debug symbol table : vbn: %u, size: %u (0x%x)\n"),
7720 dst_vbn
, dst_size
, dst_size
);
7721 gst_vbn
= bfd_getl32 (eihs
.gstvbn
);
7722 gst_size
= bfd_getl32 (eihs
.gstsize
);
7723 /* xgettext:c-format */
7724 fprintf (file
, _(" global symbol table: vbn: %u, records: %u\n"),
7726 dmt_vbn
= bfd_getl32 (eihs
.dmtvbn
);
7727 dmt_size
= bfd_getl32 (eihs
.dmtsize
);
7728 /* xgettext:c-format */
7729 fprintf (file
, _(" debug module table : vbn: %u, size: %u\n"),
7732 while (eisd_off
!= 0)
7734 struct vms_eisd eisd
;
7739 if (bfd_seek (abfd
, (file_ptr
) eisd_off
, SEEK_SET
)
7740 || bfd_bread (&eisd
, sizeof (eisd
), abfd
) != sizeof (eisd
))
7742 fprintf (file
, _("cannot read EISD\n"));
7745 len
= (unsigned)bfd_getl32 (eisd
.eisdsize
);
7746 if (len
!= (unsigned)-1)
7750 eisd_off
= (eisd_off
+ VMS_BLOCK_SIZE
) & ~(VMS_BLOCK_SIZE
- 1);
7752 /* xgettext:c-format */
7753 fprintf (file
, _("Image section descriptor: (major: %u, minor: %u, "
7754 "size: %u, offset: %u)\n"),
7755 (unsigned)bfd_getl32 (eisd
.majorid
),
7756 (unsigned)bfd_getl32 (eisd
.minorid
),
7760 /* xgettext:c-format */
7761 fprintf (file
, _(" section: base: 0x%08x%08x size: 0x%08x\n"),
7762 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 4),
7763 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 0),
7764 (unsigned)bfd_getl32 (eisd
.secsize
));
7765 val
= (unsigned)bfd_getl32 (eisd
.flags
);
7766 fprintf (file
, _(" flags: 0x%04x"), val
);
7767 if (val
& EISD__M_GBL
)
7768 fprintf (file
, " GBL");
7769 if (val
& EISD__M_CRF
)
7770 fprintf (file
, " CRF");
7771 if (val
& EISD__M_DZRO
)
7772 fprintf (file
, " DZRO");
7773 if (val
& EISD__M_WRT
)
7774 fprintf (file
, " WRT");
7775 if (val
& EISD__M_INITALCODE
)
7776 fprintf (file
, " INITALCODE");
7777 if (val
& EISD__M_BASED
)
7778 fprintf (file
, " BASED");
7779 if (val
& EISD__M_FIXUPVEC
)
7780 fprintf (file
, " FIXUPVEC");
7781 if (val
& EISD__M_RESIDENT
)
7782 fprintf (file
, " RESIDENT");
7783 if (val
& EISD__M_VECTOR
)
7784 fprintf (file
, " VECTOR");
7785 if (val
& EISD__M_PROTECT
)
7786 fprintf (file
, " PROTECT");
7787 if (val
& EISD__M_LASTCLU
)
7788 fprintf (file
, " LASTCLU");
7789 if (val
& EISD__M_EXE
)
7790 fprintf (file
, " EXE");
7791 if (val
& EISD__M_NONSHRADR
)
7792 fprintf (file
, " NONSHRADR");
7793 if (val
& EISD__M_QUAD_LENGTH
)
7794 fprintf (file
, " QUAD_LENGTH");
7795 if (val
& EISD__M_ALLOC_64BIT
)
7796 fprintf (file
, " ALLOC_64BIT");
7797 fprintf (file
, "\n");
7798 if (val
& EISD__M_FIXUPVEC
)
7800 eiaf_vbn
= bfd_getl32 (eisd
.vbn
);
7801 eiaf_size
= bfd_getl32 (eisd
.secsize
);
7803 /* xgettext:c-format */
7804 fprintf (file
, _(" vbn: %u, pfc: %u, matchctl: %u type: %u ("),
7805 (unsigned)bfd_getl32 (eisd
.vbn
),
7806 eisd
.pfc
, eisd
.matchctl
, eisd
.type
);
7809 case EISD__K_NORMAL
:
7810 fputs (_("NORMAL"), file
);
7812 case EISD__K_SHRFXD
:
7813 fputs (_("SHRFXD"), file
);
7815 case EISD__K_PRVFXD
:
7816 fputs (_("PRVFXD"), file
);
7818 case EISD__K_SHRPIC
:
7819 fputs (_("SHRPIC"), file
);
7821 case EISD__K_PRVPIC
:
7822 fputs (_("PRVPIC"), file
);
7824 case EISD__K_USRSTACK
:
7825 fputs (_("USRSTACK"), file
);
7828 fputs (_("*unknown*"), file
);
7831 fputs (_(")\n"), file
);
7832 if (val
& EISD__M_GBL
)
7833 /* xgettext:c-format */
7834 fprintf (file
, _(" ident: 0x%08x, name: %.*s\n"),
7835 (unsigned)bfd_getl32 (eisd
.ident
),
7836 eisd
.gblnam
[0], eisd
.gblnam
+ 1);
7842 if (bfd_seek (abfd
, (file_ptr
) (dmt_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7844 fprintf (file
, _("cannot read DMT\n"));
7848 fprintf (file
, _("Debug module table:\n"));
7850 while (dmt_size
> 0)
7852 struct vms_dmt_header dmth
;
7855 if (bfd_bread (&dmth
, sizeof (dmth
), abfd
) != sizeof (dmth
))
7857 fprintf (file
, _("cannot read DMT header\n"));
7860 count
= bfd_getl16 (dmth
.psect_count
);
7862 /* xgettext:c-format */
7863 _(" module offset: 0x%08x, size: 0x%08x, (%u psects)\n"),
7864 (unsigned)bfd_getl32 (dmth
.modbeg
),
7865 (unsigned)bfd_getl32 (dmth
.size
), count
);
7866 dmt_size
-= sizeof (dmth
);
7869 struct vms_dmt_psect dmtp
;
7871 if (bfd_bread (&dmtp
, sizeof (dmtp
), abfd
) != sizeof (dmtp
))
7873 fprintf (file
, _("cannot read DMT psect\n"));
7876 /* xgettext:c-format */
7877 fprintf (file
, _(" psect start: 0x%08x, length: %u\n"),
7878 (unsigned)bfd_getl32 (dmtp
.start
),
7879 (unsigned)bfd_getl32 (dmtp
.length
));
7881 dmt_size
-= sizeof (dmtp
);
7888 if (bfd_seek (abfd
, (file_ptr
) (dst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7890 fprintf (file
, _("cannot read DST\n"));
7894 evax_bfd_print_dst (abfd
, dst_size
, file
);
7898 if (bfd_seek (abfd
, (file_ptr
) (gst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7900 fprintf (file
, _("cannot read GST\n"));
7904 fprintf (file
, _("Global symbol table:\n"));
7905 evax_bfd_print_eobj (abfd
, file
);
7910 struct vms_eiaf
*eiaf
;
7911 unsigned int qrelfixoff
;
7912 unsigned int lrelfixoff
;
7913 unsigned int qdotadroff
;
7914 unsigned int ldotadroff
;
7915 unsigned int shrimgcnt
;
7916 unsigned int shlstoff
;
7917 unsigned int codeadroff
;
7918 unsigned int lpfixoff
;
7919 unsigned int chgprtoff
;
7921 buf
= bfd_malloc (eiaf_size
);
7923 if (bfd_seek (abfd
, (file_ptr
) (eiaf_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
)
7924 || bfd_bread (buf
, eiaf_size
, abfd
) != eiaf_size
)
7926 fprintf (file
, _("cannot read EIHA\n"));
7930 eiaf
= (struct vms_eiaf
*)buf
;
7932 /* xgettext:c-format */
7933 _("Image activator fixup: (major: %u, minor: %u)\n"),
7934 (unsigned)bfd_getl32 (eiaf
->majorid
),
7935 (unsigned)bfd_getl32 (eiaf
->minorid
));
7936 /* xgettext:c-format */
7937 fprintf (file
, _(" iaflink : 0x%08x %08x\n"),
7938 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 0),
7939 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 4));
7940 /* xgettext:c-format */
7941 fprintf (file
, _(" fixuplnk: 0x%08x %08x\n"),
7942 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 0),
7943 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 4));
7944 fprintf (file
, _(" size : %u\n"),
7945 (unsigned)bfd_getl32 (eiaf
->size
));
7946 fprintf (file
, _(" flags: 0x%08x\n"),
7947 (unsigned)bfd_getl32 (eiaf
->flags
));
7948 qrelfixoff
= bfd_getl32 (eiaf
->qrelfixoff
);
7949 lrelfixoff
= bfd_getl32 (eiaf
->lrelfixoff
);
7950 /* xgettext:c-format */
7951 fprintf (file
, _(" qrelfixoff: %5u, lrelfixoff: %5u\n"),
7952 qrelfixoff
, lrelfixoff
);
7953 qdotadroff
= bfd_getl32 (eiaf
->qdotadroff
);
7954 ldotadroff
= bfd_getl32 (eiaf
->ldotadroff
);
7955 /* xgettext:c-format */
7956 fprintf (file
, _(" qdotadroff: %5u, ldotadroff: %5u\n"),
7957 qdotadroff
, ldotadroff
);
7958 codeadroff
= bfd_getl32 (eiaf
->codeadroff
);
7959 lpfixoff
= bfd_getl32 (eiaf
->lpfixoff
);
7960 /* xgettext:c-format */
7961 fprintf (file
, _(" codeadroff: %5u, lpfixoff : %5u\n"),
7962 codeadroff
, lpfixoff
);
7963 chgprtoff
= bfd_getl32 (eiaf
->chgprtoff
);
7964 fprintf (file
, _(" chgprtoff : %5u\n"), chgprtoff
);
7965 shrimgcnt
= bfd_getl32 (eiaf
->shrimgcnt
);
7966 shlstoff
= bfd_getl32 (eiaf
->shlstoff
);
7967 /* xgettext:c-format */
7968 fprintf (file
, _(" shlstoff : %5u, shrimgcnt : %5u\n"),
7969 shlstoff
, shrimgcnt
);
7970 /* xgettext:c-format */
7971 fprintf (file
, _(" shlextra : %5u, permctx : %5u\n"),
7972 (unsigned)bfd_getl32 (eiaf
->shlextra
),
7973 (unsigned)bfd_getl32 (eiaf
->permctx
));
7974 fprintf (file
, _(" base_va : 0x%08x\n"),
7975 (unsigned)bfd_getl32 (eiaf
->base_va
));
7976 fprintf (file
, _(" lppsbfixoff: %5u\n"),
7977 (unsigned)bfd_getl32 (eiaf
->lppsbfixoff
));
7981 struct vms_shl
*shl
= (struct vms_shl
*)(buf
+ shlstoff
);
7984 fprintf (file
, _(" Shareable images:\n"));
7985 for (j
= 0; j
< shrimgcnt
; j
++, shl
++)
7988 /* xgettext:c-format */
7989 _(" %u: size: %u, flags: 0x%02x, name: %.*s\n"),
7990 j
, shl
->size
, shl
->flags
,
7991 shl
->imgnam
[0], shl
->imgnam
+ 1);
7994 if (qrelfixoff
!= 0)
7996 fprintf (file
, _(" quad-word relocation fixups:\n"));
7997 evax_bfd_print_relocation_records (file
, buf
+ qrelfixoff
, 8);
7999 if (lrelfixoff
!= 0)
8001 fprintf (file
, _(" long-word relocation fixups:\n"));
8002 evax_bfd_print_relocation_records (file
, buf
+ lrelfixoff
, 4);
8004 if (qdotadroff
!= 0)
8006 fprintf (file
, _(" quad-word .address reference fixups:\n"));
8007 evax_bfd_print_address_fixups (file
, buf
+ qdotadroff
);
8009 if (ldotadroff
!= 0)
8011 fprintf (file
, _(" long-word .address reference fixups:\n"));
8012 evax_bfd_print_address_fixups (file
, buf
+ ldotadroff
);
8014 if (codeadroff
!= 0)
8016 fprintf (file
, _(" Code Address Reference Fixups:\n"));
8017 evax_bfd_print_reference_fixups (file
, buf
+ codeadroff
);
8021 fprintf (file
, _(" Linkage Pairs Reference Fixups:\n"));
8022 evax_bfd_print_reference_fixups (file
, buf
+ lpfixoff
);
8026 unsigned int count
= (unsigned)bfd_getl32 (buf
+ chgprtoff
);
8027 struct vms_eicp
*eicp
= (struct vms_eicp
*)(buf
+ chgprtoff
+ 4);
8030 fprintf (file
, _(" Change Protection (%u entries):\n"), count
);
8031 for (j
= 0; j
< count
; j
++, eicp
++)
8033 unsigned int prot
= bfd_getl32 (eicp
->newprt
);
8035 /* xgettext:c-format */
8036 _(" base: 0x%08x %08x, size: 0x%08x, prot: 0x%08x "),
8037 (unsigned)bfd_getl32 (eicp
->baseva
+ 4),
8038 (unsigned)bfd_getl32 (eicp
->baseva
+ 0),
8039 (unsigned)bfd_getl32 (eicp
->size
),
8040 (unsigned)bfd_getl32 (eicp
->newprt
));
8044 fprintf (file
, "NA");
8046 case PRT__C_RESERVED
:
8047 fprintf (file
, "RES");
8050 fprintf (file
, "KW");
8053 fprintf (file
, "KR");
8056 fprintf (file
, "UW");
8059 fprintf (file
, "EW");
8062 fprintf (file
, "ERKW");
8065 fprintf (file
, "ER");
8068 fprintf (file
, "SW");
8071 fprintf (file
, "SREW");
8074 fprintf (file
, "SRKW");
8077 fprintf (file
, "SR");
8080 fprintf (file
, "URSW");
8083 fprintf (file
, "UREW");
8086 fprintf (file
, "URKW");
8089 fprintf (file
, "UR");
8103 vms_bfd_print_private_bfd_data (bfd
*abfd
, void *ptr
)
8105 FILE *file
= (FILE *)ptr
;
8107 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
8108 evax_bfd_print_image (abfd
, file
);
8111 if (bfd_seek (abfd
, 0, SEEK_SET
))
8113 evax_bfd_print_eobj (abfd
, file
);
8120 /* Slurp ETIR/EDBG/ETBT VMS object records. */
8123 alpha_vms_read_sections_content (bfd
*abfd
, struct bfd_link_info
*info
)
8125 asection
*cur_section
;
8126 file_ptr cur_offset
;
8127 asection
*dst_section
;
8128 file_ptr dst_offset
;
8130 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
8136 dst_section
= PRIV (dst_section
);
8140 if (info
->strip
== strip_all
|| info
->strip
== strip_debugger
)
8142 /* Discard the DST section. */
8146 else if (dst_section
)
8148 dst_offset
= dst_section
->output_offset
;
8149 dst_section
= dst_section
->output_section
;
8158 type
= _bfd_vms_get_object_record (abfd
);
8161 vms_debug2 ((2, "next_record failed\n"));
8167 PRIV (image_section
) = cur_section
;
8168 PRIV (image_offset
) = cur_offset
;
8169 res
= _bfd_vms_slurp_etir (abfd
, info
);
8170 cur_section
= PRIV (image_section
);
8171 cur_offset
= PRIV (image_offset
);
8175 if (dst_section
== NULL
)
8177 PRIV (image_section
) = dst_section
;
8178 PRIV (image_offset
) = dst_offset
;
8179 res
= _bfd_vms_slurp_etir (abfd
, info
);
8180 dst_offset
= PRIV (image_offset
);
8189 vms_debug2 ((2, "slurp eobj type %d failed\n", type
));
8196 alpha_vms_sizeof_headers (bfd
*abfd ATTRIBUTE_UNUSED
,
8197 struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8202 /* Add a linkage pair fixup at address SECT + OFFSET to SHLIB. */
8205 alpha_vms_add_fixup_lp (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
8207 struct alpha_vms_shlib_el
*sl
;
8208 asection
*sect
= PRIV2 (src
, image_section
);
8209 file_ptr offset
= PRIV2 (src
, image_offset
);
8211 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8212 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8213 sl
->has_fixups
= TRUE
;
8214 VEC_APPEND_EL (sl
->lp
, bfd_vma
,
8215 sect
->output_section
->vma
+ sect
->output_offset
+ offset
);
8216 sect
->output_section
->flags
|= SEC_RELOC
;
8219 /* Add a code address fixup at address SECT + OFFSET to SHLIB. */
8222 alpha_vms_add_fixup_ca (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
8224 struct alpha_vms_shlib_el
*sl
;
8225 asection
*sect
= PRIV2 (src
, image_section
);
8226 file_ptr offset
= PRIV2 (src
, image_offset
);
8228 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8229 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8230 sl
->has_fixups
= TRUE
;
8231 VEC_APPEND_EL (sl
->ca
, bfd_vma
,
8232 sect
->output_section
->vma
+ sect
->output_offset
+ offset
);
8233 sect
->output_section
->flags
|= SEC_RELOC
;
8236 /* Add a quad word relocation fixup at address SECT + OFFSET to SHLIB. */
8239 alpha_vms_add_fixup_qr (struct bfd_link_info
*info
, bfd
*src
,
8240 bfd
*shlib
, bfd_vma vec
)
8242 struct alpha_vms_shlib_el
*sl
;
8243 struct alpha_vms_vma_ref
*r
;
8244 asection
*sect
= PRIV2 (src
, image_section
);
8245 file_ptr offset
= PRIV2 (src
, image_offset
);
8247 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8248 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8249 sl
->has_fixups
= TRUE
;
8250 r
= VEC_APPEND (sl
->qr
, struct alpha_vms_vma_ref
);
8251 r
->vma
= sect
->output_section
->vma
+ sect
->output_offset
+ offset
;
8253 sect
->output_section
->flags
|= SEC_RELOC
;
8257 alpha_vms_add_fixup_lr (struct bfd_link_info
*info ATTRIBUTE_UNUSED
,
8258 unsigned int shr ATTRIBUTE_UNUSED
,
8259 bfd_vma vec ATTRIBUTE_UNUSED
)
8261 /* Not yet supported. */
8265 /* Add relocation. FIXME: Not yet emitted. */
8268 alpha_vms_add_lw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8273 alpha_vms_add_qw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8277 static struct bfd_hash_entry
*
8278 alpha_vms_link_hash_newfunc (struct bfd_hash_entry
*entry
,
8279 struct bfd_hash_table
*table
,
8282 struct alpha_vms_link_hash_entry
*ret
=
8283 (struct alpha_vms_link_hash_entry
*) entry
;
8285 /* Allocate the structure if it has not already been allocated by a
8288 ret
= ((struct alpha_vms_link_hash_entry
*)
8289 bfd_hash_allocate (table
,
8290 sizeof (struct alpha_vms_link_hash_entry
)));
8294 /* Call the allocation method of the superclass. */
8295 ret
= ((struct alpha_vms_link_hash_entry
*)
8296 _bfd_link_hash_newfunc ((struct bfd_hash_entry
*) ret
,
8301 return (struct bfd_hash_entry
*) ret
;
8304 /* Create an Alpha/VMS link hash table. */
8306 static struct bfd_link_hash_table
*
8307 alpha_vms_bfd_link_hash_table_create (bfd
*abfd
)
8309 struct alpha_vms_link_hash_table
*ret
;
8310 bfd_size_type amt
= sizeof (struct alpha_vms_link_hash_table
);
8312 ret
= (struct alpha_vms_link_hash_table
*) bfd_malloc (amt
);
8315 if (!_bfd_link_hash_table_init (&ret
->root
, abfd
,
8316 alpha_vms_link_hash_newfunc
,
8317 sizeof (struct alpha_vms_link_hash_entry
)))
8323 VEC_INIT (ret
->shrlibs
);
8330 alpha_vms_link_add_object_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8334 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
8336 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
8337 struct alpha_vms_link_hash_entry
*h
;
8338 struct bfd_link_hash_entry
*h_root
;
8341 if (!alpha_vms_convert_symbol (abfd
, e
, &sym
))
8344 if ((e
->flags
& EGSY__V_DEF
) && abfd
->selective_search
)
8346 /* In selective_search mode, only add definition that are
8348 h
= (struct alpha_vms_link_hash_entry
*)bfd_link_hash_lookup
8349 (info
->hash
, sym
.name
, FALSE
, FALSE
, FALSE
);
8350 if (h
== NULL
|| h
->root
.type
!= bfd_link_hash_undefined
)
8356 h_root
= (struct bfd_link_hash_entry
*) h
;
8357 if (!_bfd_generic_link_add_one_symbol (info
, abfd
, sym
.name
, sym
.flags
,
8358 sym
.section
, sym
.value
, NULL
,
8359 FALSE
, FALSE
, &h_root
))
8361 h
= (struct alpha_vms_link_hash_entry
*) h_root
;
8363 if ((e
->flags
& EGSY__V_DEF
)
8365 && abfd
->xvec
== info
->output_bfd
->xvec
)
8369 if (abfd
->flags
& DYNAMIC
)
8371 struct alpha_vms_shlib_el
*shlib
;
8373 /* We do not want to include any of the sections in a dynamic
8374 object in the output file. See comment in elflink.c. */
8375 bfd_section_list_clear (abfd
);
8377 shlib
= VEC_APPEND (alpha_vms_link_hash (info
)->shrlibs
,
8378 struct alpha_vms_shlib_el
);
8380 VEC_INIT (shlib
->ca
);
8381 VEC_INIT (shlib
->lp
);
8382 VEC_INIT (shlib
->qr
);
8383 PRIV (shr_index
) = VEC_COUNT (alpha_vms_link_hash (info
)->shrlibs
) - 1;
8390 alpha_vms_link_add_archive_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8393 struct bfd_link_hash_entry
**pundef
;
8394 struct bfd_link_hash_entry
**next_pundef
;
8396 /* We only accept VMS libraries. */
8397 if (info
->output_bfd
->xvec
!= abfd
->xvec
)
8399 bfd_set_error (bfd_error_wrong_format
);
8403 /* The archive_pass field in the archive itself is used to
8404 initialize PASS, since we may search the same archive multiple
8406 pass
= ++abfd
->archive_pass
;
8408 /* Look through the list of undefined symbols. */
8409 for (pundef
= &info
->hash
->undefs
; *pundef
!= NULL
; pundef
= next_pundef
)
8411 struct bfd_link_hash_entry
*h
;
8417 next_pundef
= &(*pundef
)->u
.undef
.next
;
8419 /* When a symbol is defined, it is not necessarily removed from
8421 if (h
->type
!= bfd_link_hash_undefined
8422 && h
->type
!= bfd_link_hash_common
)
8424 /* Remove this entry from the list, for general cleanliness
8425 and because we are going to look through the list again
8426 if we search any more libraries. We can't remove the
8427 entry if it is the tail, because that would lose any
8428 entries we add to the list later on. */
8429 if (*pundef
!= info
->hash
->undefs_tail
)
8431 *pundef
= *next_pundef
;
8432 next_pundef
= pundef
;
8437 /* Look for this symbol in the archive hash table. */
8438 symidx
= _bfd_vms_lib_find_symbol (abfd
, h
->root
.string
);
8439 if (symidx
== BFD_NO_MORE_SYMBOLS
)
8441 /* Nothing in this slot. */
8445 element
= bfd_get_elt_at_index (abfd
, symidx
);
8446 if (element
== NULL
)
8449 if (element
->archive_pass
== -1 || element
->archive_pass
== pass
)
8451 /* Next symbol if this archive is wrong or already handled. */
8455 if (! bfd_check_format (element
, bfd_object
))
8457 element
->archive_pass
= -1;
8461 orig_element
= element
;
8462 if (bfd_is_thin_archive (abfd
))
8464 element
= _bfd_vms_lib_get_imagelib_file (element
);
8465 if (element
== NULL
|| !bfd_check_format (element
, bfd_object
))
8467 orig_element
->archive_pass
= -1;
8472 /* Unlike the generic linker, we know that this element provides
8473 a definition for an undefined symbol and we know that we want
8474 to include it. We don't need to check anything. */
8475 if (!(*info
->callbacks
8476 ->add_archive_element
) (info
, element
, h
->root
.string
, &element
))
8478 if (!alpha_vms_link_add_object_symbols (element
, info
))
8481 orig_element
->archive_pass
= pass
;
8488 alpha_vms_bfd_link_add_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8490 switch (bfd_get_format (abfd
))
8493 vms_debug2 ((2, "vms_link_add_symbols for object %s\n",
8495 return alpha_vms_link_add_object_symbols (abfd
, info
);
8498 vms_debug2 ((2, "vms_link_add_symbols for archive %s\n",
8500 return alpha_vms_link_add_archive_symbols (abfd
, info
);
8503 bfd_set_error (bfd_error_wrong_format
);
8509 alpha_vms_build_fixups (struct bfd_link_info
*info
)
8511 struct alpha_vms_link_hash_table
*t
= alpha_vms_link_hash (info
);
8512 unsigned char *content
;
8514 unsigned int sz
= 0;
8515 unsigned int lp_sz
= 0;
8516 unsigned int ca_sz
= 0;
8517 unsigned int qr_sz
= 0;
8518 unsigned int shrimg_cnt
= 0;
8519 unsigned int chgprt_num
= 0;
8520 unsigned int chgprt_sz
= 0;
8521 struct vms_eiaf
*eiaf
;
8525 /* Shared libraries. */
8526 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8528 struct alpha_vms_shlib_el
*shlib
;
8530 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8532 if (!shlib
->has_fixups
)
8537 if (VEC_COUNT (shlib
->ca
) > 0)
8539 /* Header + entries. */
8541 ca_sz
+= VEC_COUNT (shlib
->ca
) * 4;
8543 if (VEC_COUNT (shlib
->lp
) > 0)
8545 /* Header + entries. */
8547 lp_sz
+= VEC_COUNT (shlib
->lp
) * 4;
8549 if (VEC_COUNT (shlib
->qr
) > 0)
8551 /* Header + entries. */
8553 qr_sz
+= VEC_COUNT (shlib
->qr
) * 8;
8564 /* Finish now if there is no content. */
8565 if (ca_sz
+ lp_sz
+ qr_sz
== 0)
8568 /* Add an eicp entry for the fixup itself. */
8570 for (sec
= info
->output_bfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
8572 /* This isect could be made RO or EXE after relocations are applied. */
8573 if ((sec
->flags
& SEC_RELOC
) != 0
8574 && (sec
->flags
& (SEC_CODE
| SEC_READONLY
)) != 0)
8577 chgprt_sz
= 4 + chgprt_num
* sizeof (struct vms_eicp
);
8579 /* Allocate section content (round-up size) */
8580 sz
= sizeof (struct vms_eiaf
) + shrimg_cnt
* sizeof (struct vms_shl
)
8581 + ca_sz
+ lp_sz
+ qr_sz
+ chgprt_sz
;
8582 sz
= (sz
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
8583 content
= bfd_zalloc (info
->output_bfd
, sz
);
8584 if (content
== NULL
)
8587 sec
= alpha_vms_link_hash (info
)->fixup
;
8588 sec
->contents
= content
;
8591 eiaf
= (struct vms_eiaf
*)content
;
8592 off
= sizeof (struct vms_eiaf
);
8593 bfd_putl32 (0, eiaf
->majorid
);
8594 bfd_putl32 (0, eiaf
->minorid
);
8595 bfd_putl32 (0, eiaf
->iaflink
);
8596 bfd_putl32 (0, eiaf
->fixuplnk
);
8597 bfd_putl32 (sizeof (struct vms_eiaf
), eiaf
->size
);
8598 bfd_putl32 (0, eiaf
->flags
);
8599 bfd_putl32 (0, eiaf
->qrelfixoff
);
8600 bfd_putl32 (0, eiaf
->lrelfixoff
);
8601 bfd_putl32 (0, eiaf
->qdotadroff
);
8602 bfd_putl32 (0, eiaf
->ldotadroff
);
8603 bfd_putl32 (0, eiaf
->codeadroff
);
8604 bfd_putl32 (0, eiaf
->lpfixoff
);
8605 bfd_putl32 (0, eiaf
->chgprtoff
);
8606 bfd_putl32 (shrimg_cnt
? off
: 0, eiaf
->shlstoff
);
8607 bfd_putl32 (shrimg_cnt
, eiaf
->shrimgcnt
);
8608 bfd_putl32 (0, eiaf
->shlextra
);
8609 bfd_putl32 (0, eiaf
->permctx
);
8610 bfd_putl32 (0, eiaf
->base_va
);
8611 bfd_putl32 (0, eiaf
->lppsbfixoff
);
8618 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8620 struct alpha_vms_shlib_el
*shlib
;
8621 struct vms_shl
*shl
;
8623 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8625 if (!shlib
->has_fixups
)
8628 /* Renumber shared images. */
8629 PRIV2 (shlib
->abfd
, shr_index
) = shrimg_cnt
++;
8631 shl
= (struct vms_shl
*)(content
+ off
);
8632 bfd_putl32 (0, shl
->baseva
);
8633 bfd_putl32 (0, shl
->shlptr
);
8634 bfd_putl32 (0, shl
->ident
);
8635 bfd_putl32 (0, shl
->permctx
);
8636 shl
->size
= sizeof (struct vms_shl
);
8637 bfd_putl16 (0, shl
->fill_1
);
8639 bfd_putl32 (0, shl
->icb
);
8640 shl
->imgnam
[0] = strlen (PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
));
8641 memcpy (shl
->imgnam
+ 1, PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
),
8644 off
+= sizeof (struct vms_shl
);
8650 bfd_putl32 (off
, eiaf
->codeadroff
);
8652 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8654 struct alpha_vms_shlib_el
*shlib
;
8657 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8659 if (VEC_COUNT (shlib
->ca
) == 0)
8662 bfd_putl32 (VEC_COUNT (shlib
->ca
), content
+ off
);
8663 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8666 for (j
= 0; j
< VEC_COUNT (shlib
->ca
); j
++)
8668 bfd_putl32 (VEC_EL (shlib
->ca
, bfd_vma
, j
) - t
->base_addr
,
8674 bfd_putl32 (0, content
+ off
);
8675 bfd_putl32 (0, content
+ off
+ 4);
8682 bfd_putl32 (off
, eiaf
->lpfixoff
);
8684 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8686 struct alpha_vms_shlib_el
*shlib
;
8689 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8691 if (VEC_COUNT (shlib
->lp
) == 0)
8694 bfd_putl32 (VEC_COUNT (shlib
->lp
), content
+ off
);
8695 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8698 for (j
= 0; j
< VEC_COUNT (shlib
->lp
); j
++)
8700 bfd_putl32 (VEC_EL (shlib
->lp
, bfd_vma
, j
) - t
->base_addr
,
8706 bfd_putl32 (0, content
+ off
);
8707 bfd_putl32 (0, content
+ off
+ 4);
8714 bfd_putl32 (off
, eiaf
->qdotadroff
);
8716 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8718 struct alpha_vms_shlib_el
*shlib
;
8721 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8723 if (VEC_COUNT (shlib
->qr
) == 0)
8726 bfd_putl32 (VEC_COUNT (shlib
->qr
), content
+ off
);
8727 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8730 for (j
= 0; j
< VEC_COUNT (shlib
->qr
); j
++)
8732 struct alpha_vms_vma_ref
*r
;
8733 r
= &VEC_EL (shlib
->qr
, struct alpha_vms_vma_ref
, j
);
8734 bfd_putl32 (r
->vma
- t
->base_addr
, content
+ off
);
8735 bfd_putl32 (r
->ref
, content
+ off
+ 4);
8740 bfd_putl32 (0, content
+ off
);
8741 bfd_putl32 (0, content
+ off
+ 4);
8746 /* Write the change protection table. */
8747 bfd_putl32 (off
, eiaf
->chgprtoff
);
8748 bfd_putl32 (chgprt_num
, content
+ off
);
8751 for (sec
= info
->output_bfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
8753 struct vms_eicp
*eicp
;
8756 if ((sec
->flags
& SEC_LINKER_CREATED
) != 0 &&
8757 strcmp (sec
->name
, "$FIXUP$") == 0)
8759 else if ((sec
->flags
& SEC_RELOC
) != 0
8760 && (sec
->flags
& (SEC_CODE
| SEC_READONLY
)) != 0)
8765 eicp
= (struct vms_eicp
*)(content
+ off
);
8766 bfd_putl64 (sec
->vma
- t
->base_addr
, eicp
->baseva
);
8767 bfd_putl32 ((sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1),
8769 bfd_putl32 (prot
, eicp
->newprt
);
8770 off
+= sizeof (struct vms_eicp
);
8776 /* Called by bfd_hash_traverse to fill the symbol table.
8777 Return FALSE in case of failure. */
8780 alpha_vms_link_output_symbol (struct bfd_hash_entry
*bh
, void *infov
)
8782 struct bfd_link_hash_entry
*hc
= (struct bfd_link_hash_entry
*) bh
;
8783 struct bfd_link_info
*info
= (struct bfd_link_info
*)infov
;
8784 struct alpha_vms_link_hash_entry
*h
;
8785 struct vms_symbol_entry
*sym
;
8787 if (hc
->type
== bfd_link_hash_warning
)
8790 if (hc
->type
== bfd_link_hash_new
)
8793 h
= (struct alpha_vms_link_hash_entry
*) hc
;
8795 switch (h
->root
.type
)
8797 case bfd_link_hash_undefined
:
8799 case bfd_link_hash_new
:
8800 case bfd_link_hash_warning
:
8802 case bfd_link_hash_undefweak
:
8804 case bfd_link_hash_defined
:
8805 case bfd_link_hash_defweak
:
8807 asection
*sec
= h
->root
.u
.def
.section
;
8809 /* FIXME: this is certainly a symbol from a dynamic library. */
8810 if (bfd_is_abs_section (sec
))
8813 if (sec
->owner
->flags
& DYNAMIC
)
8817 case bfd_link_hash_common
:
8819 case bfd_link_hash_indirect
:
8823 /* Do not write not kept symbols. */
8824 if (info
->strip
== strip_some
8825 && bfd_hash_lookup (info
->keep_hash
, h
->root
.root
.string
,
8826 FALSE
, FALSE
) != NULL
)
8831 /* This symbol doesn't come from a VMS object. So we suppose it is
8833 int len
= strlen (h
->root
.root
.string
);
8835 sym
= (struct vms_symbol_entry
*)bfd_zalloc (info
->output_bfd
,
8836 sizeof (*sym
) + len
);
8840 memcpy (sym
->name
, h
->root
.root
.string
, len
);
8842 sym
->owner
= info
->output_bfd
;
8844 sym
->typ
= EGSD__C_SYMG
;
8846 sym
->flags
= EGSY__V_DEF
| EGSY__V_REL
;
8847 sym
->symbol_vector
= h
->root
.u
.def
.value
;
8848 sym
->section
= h
->root
.u
.def
.section
;
8849 sym
->value
= h
->root
.u
.def
.value
;
8854 if (!add_symbol_entry (info
->output_bfd
, sym
))
8861 alpha_vms_bfd_final_link (bfd
*abfd
, struct bfd_link_info
*info
)
8864 struct bfd_link_order
*p
;
8872 if (bfd_link_relocatable (info
))
8874 /* FIXME: we do not yet support relocatable link. It is not obvious
8875 how to do it for debug infos. */
8876 (*info
->callbacks
->einfo
)(_("%P: relocatable link is not supported\n"));
8880 bfd_get_outsymbols (abfd
) = NULL
;
8881 bfd_get_symcount (abfd
) = 0;
8883 /* Mark all sections which will be included in the output file. */
8884 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8885 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
8886 if (p
->type
== bfd_indirect_link_order
)
8887 p
->u
.indirect
.section
->linker_mark
= TRUE
;
8890 /* Handle all the link order information for the sections. */
8891 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8893 printf ("For section %s (at 0x%08x, flags=0x%08x):\n",
8894 o
->name
, (unsigned)o
->vma
, (unsigned)o
->flags
);
8896 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
8898 printf (" at 0x%08x - 0x%08x: ",
8899 (unsigned)p
->offset
, (unsigned)(p
->offset
+ p
->size
- 1));
8902 case bfd_section_reloc_link_order
:
8903 case bfd_symbol_reloc_link_order
:
8904 printf (" section/symbol reloc\n");
8906 case bfd_indirect_link_order
:
8907 printf (" section %s of %s\n",
8908 p
->u
.indirect
.section
->name
,
8909 p
->u
.indirect
.section
->owner
->filename
);
8911 case bfd_data_link_order
:
8912 printf (" explicit data\n");
8915 printf (" *unknown* type %u\n", p
->type
);
8922 /* Generate the symbol table. */
8923 BFD_ASSERT (PRIV (syms
) == NULL
);
8924 if (info
->strip
!= strip_all
)
8925 bfd_hash_traverse (&info
->hash
->table
, alpha_vms_link_output_symbol
, info
);
8927 /* Find the entry point. */
8928 if (bfd_get_start_address (abfd
) == 0)
8930 bfd
*startbfd
= NULL
;
8932 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
8934 /* Consider only VMS object files. */
8935 if (sub
->xvec
!= abfd
->xvec
)
8938 if (!PRIV2 (sub
, eom_data
).eom_has_transfer
)
8940 if ((PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
) && startbfd
)
8942 if (startbfd
!= NULL
8943 && !(PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
))
8945 (*info
->callbacks
->einfo
)
8946 /* xgettext:c-format */
8947 (_("%P: multiple entry points: in modules %B and %B\n"),
8956 unsigned int ps_idx
= PRIV2 (startbfd
, eom_data
).eom_l_psindx
;
8957 bfd_vma tfradr
= PRIV2 (startbfd
, eom_data
).eom_l_tfradr
;
8960 sec
= PRIV2 (startbfd
, sections
)[ps_idx
];
8962 bfd_set_start_address
8963 (abfd
, sec
->output_section
->vma
+ sec
->output_offset
+ tfradr
);
8967 /* Set transfer addresses. */
8970 struct bfd_link_hash_entry
*h
;
8973 PRIV (transfer_address
[i
++]) = 0xffffffff00000340ULL
; /* SYS$IMGACT */
8974 h
= bfd_link_hash_lookup (info
->hash
, "LIB$INITIALIZE", FALSE
, FALSE
, TRUE
);
8975 if (h
!= NULL
&& h
->type
== bfd_link_hash_defined
)
8976 PRIV (transfer_address
[i
++]) =
8977 alpha_vms_get_sym_value (h
->u
.def
.section
, h
->u
.def
.value
);
8978 PRIV (transfer_address
[i
++]) = bfd_get_start_address (abfd
);
8980 PRIV (transfer_address
[i
++]) = 0;
8983 /* Allocate contents.
8984 Also compute the virtual base address. */
8985 base_addr
= (bfd_vma
)-1;
8987 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8989 if (o
->flags
& SEC_HAS_CONTENTS
)
8991 o
->contents
= bfd_alloc (abfd
, o
->size
);
8992 if (o
->contents
== NULL
)
8995 if (o
->flags
& SEC_LOAD
)
8997 if (o
->vma
< base_addr
)
8999 if (o
->vma
+ o
->size
> last_addr
)
9000 last_addr
= o
->vma
+ o
->size
;
9002 /* Clear the RELOC flags. Currently we don't support incremental
9003 linking. We use the RELOC flag for computing the eicp entries. */
9004 o
->flags
&= ~SEC_RELOC
;
9007 /* Create the fixup section. */
9008 fixupsec
= bfd_make_section_anyway_with_flags
9009 (info
->output_bfd
, "$FIXUP$",
9010 SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
9011 if (fixupsec
== NULL
)
9013 last_addr
= (last_addr
+ 0xffff) & ~0xffff;
9014 fixupsec
->vma
= last_addr
;
9016 alpha_vms_link_hash (info
)->fixup
= fixupsec
;
9017 alpha_vms_link_hash (info
)->base_addr
= base_addr
;
9019 /* Create the DMT section, if necessary. */
9020 BFD_ASSERT (PRIV (dst_section
) == NULL
);
9021 dst
= bfd_get_section_by_name (abfd
, "$DST$");
9022 if (dst
!= NULL
&& dst
->size
== 0)
9026 PRIV (dst_section
) = dst
;
9027 dmt
= bfd_make_section_anyway_with_flags
9028 (info
->output_bfd
, "$DMT$",
9029 SEC_DEBUGGING
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
9036 /* Read all sections from the inputs. */
9037 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9039 if (sub
->flags
& DYNAMIC
)
9041 alpha_vms_create_eisd_for_shared (abfd
, sub
);
9045 if (!alpha_vms_read_sections_content (sub
, info
))
9049 /* Handle all the link order information for the sections.
9050 Note: past this point, it is not possible to create new sections. */
9051 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9053 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
9057 case bfd_section_reloc_link_order
:
9058 case bfd_symbol_reloc_link_order
:
9061 case bfd_indirect_link_order
:
9065 if (! _bfd_default_link_order (abfd
, info
, o
, p
))
9072 /* Compute fixups. */
9073 if (!alpha_vms_build_fixups (info
))
9076 /* Compute the DMT. */
9080 unsigned char *contents
= NULL
;
9082 /* In pass 1, compute the size. In pass 2, write the DMT contents. */
9083 for (pass
= 0; pass
< 2; pass
++)
9085 unsigned int off
= 0;
9087 /* For each object file (ie for each module). */
9088 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9091 struct vms_dmt_header
*dmth
= NULL
;
9092 unsigned int psect_count
;
9094 /* Skip this module if it has no DST. */
9095 sub_dst
= PRIV2 (sub
, dst_section
);
9096 if (sub_dst
== NULL
|| sub_dst
->size
== 0)
9101 /* Write the header. */
9102 dmth
= (struct vms_dmt_header
*)(contents
+ off
);
9103 bfd_putl32 (sub_dst
->output_offset
, dmth
->modbeg
);
9104 bfd_putl32 (sub_dst
->size
, dmth
->size
);
9107 off
+= sizeof (struct vms_dmt_header
);
9110 /* For each section (ie for each psect). */
9111 for (o
= sub
->sections
; o
!= NULL
; o
= o
->next
)
9113 /* Only consider interesting sections. */
9114 if (!(o
->flags
& SEC_ALLOC
))
9116 if (o
->flags
& SEC_LINKER_CREATED
)
9121 /* Write an entry. */
9122 struct vms_dmt_psect
*dmtp
;
9124 dmtp
= (struct vms_dmt_psect
*)(contents
+ off
);
9125 bfd_putl32 (o
->output_offset
+ o
->output_section
->vma
,
9127 bfd_putl32 (o
->size
, dmtp
->length
);
9130 off
+= sizeof (struct vms_dmt_psect
);
9133 bfd_putl32 (psect_count
, dmth
->psect_count
);
9138 contents
= bfd_zalloc (info
->output_bfd
, off
);
9139 if (contents
== NULL
)
9141 dmt
->contents
= contents
;
9146 BFD_ASSERT (off
== dmt
->size
);
9154 /* Read the contents of a section.
9155 buf points to a buffer of buf_size bytes to be filled with
9156 section data (starting at offset into section) */
9159 alpha_vms_get_section_contents (bfd
*abfd
, asection
*section
,
9160 void *buf
, file_ptr offset
,
9161 bfd_size_type count
)
9165 /* Image are easy. */
9166 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
9167 return _bfd_generic_get_section_contents (abfd
, section
,
9168 buf
, offset
, count
);
9171 if (offset
+ count
< count
9172 || offset
+ count
> section
->size
)
9174 bfd_set_error (bfd_error_invalid_operation
);
9178 /* If the section is already in memory, just copy it. */
9179 if (section
->flags
& SEC_IN_MEMORY
)
9181 BFD_ASSERT (section
->contents
!= NULL
);
9182 memcpy (buf
, section
->contents
+ offset
, count
);
9185 if (section
->size
== 0)
9188 /* Alloc in memory and read ETIRs. */
9189 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
9191 BFD_ASSERT (sec
->contents
== NULL
);
9193 if (sec
->size
!= 0 && (sec
->flags
& SEC_HAS_CONTENTS
))
9195 sec
->contents
= bfd_alloc (abfd
, sec
->size
);
9196 if (sec
->contents
== NULL
)
9200 if (!alpha_vms_read_sections_content (abfd
, NULL
))
9202 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
9204 sec
->flags
|= SEC_IN_MEMORY
;
9205 memcpy (buf
, section
->contents
+ offset
, count
);
9210 /* Set the format of a file being written. */
9213 alpha_vms_mkobject (bfd
* abfd
)
9215 const bfd_arch_info_type
*arch
;
9217 vms_debug2 ((1, "alpha_vms_mkobject (%p)\n", abfd
));
9219 if (!vms_initialize (abfd
))
9222 PRIV (recwr
.buf
) = bfd_alloc (abfd
, MAX_OUTREC_SIZE
);
9223 if (PRIV (recwr
.buf
) == NULL
)
9226 arch
= bfd_scan_arch ("alpha");
9230 bfd_set_error (bfd_error_wrong_format
);
9234 abfd
->arch_info
= arch
;
9241 /* Called when the BFD is being closed to do any necessary cleanup. */
9244 vms_close_and_cleanup (bfd
* abfd
)
9246 vms_debug2 ((1, "vms_close_and_cleanup (%p)\n", abfd
));
9248 if (abfd
== NULL
|| abfd
->tdata
.any
== NULL
)
9251 if (abfd
->format
== bfd_archive
)
9253 bfd_release (abfd
, abfd
->tdata
.any
);
9254 abfd
->tdata
.any
= NULL
;
9258 if (PRIV (recrd
.buf
) != NULL
)
9259 free (PRIV (recrd
.buf
));
9261 if (PRIV (sections
) != NULL
)
9262 free (PRIV (sections
));
9264 bfd_release (abfd
, abfd
->tdata
.any
);
9265 abfd
->tdata
.any
= NULL
;
9268 if (abfd
->direction
== write_direction
)
9270 /* Last step on VMS is to convert the file to variable record length
9272 if (!bfd_cache_close (abfd
))
9274 if (!_bfd_vms_convert_to_var_unix_filename (abfd
->filename
))
9282 /* Called when a new section is created. */
9285 vms_new_section_hook (bfd
* abfd
, asection
*section
)
9289 vms_debug2 ((1, "vms_new_section_hook (%p, [%u]%s)\n",
9290 abfd
, section
->index
, section
->name
));
9292 if (! bfd_set_section_alignment (abfd
, section
, 0))
9295 vms_debug2 ((7, "%u: %s\n", section
->index
, section
->name
));
9297 amt
= sizeof (struct vms_section_data_struct
);
9298 section
->used_by_bfd
= bfd_zalloc (abfd
, amt
);
9299 if (section
->used_by_bfd
== NULL
)
9302 /* Create the section symbol. */
9303 return _bfd_generic_new_section_hook (abfd
, section
);
9306 /* Part 4.5, symbols. */
9308 /* Print symbol to file according to how. how is one of
9309 bfd_print_symbol_name just print the name
9310 bfd_print_symbol_more print more (???)
9311 bfd_print_symbol_all print all we know, which is not much right now :-). */
9314 vms_print_symbol (bfd
* abfd
,
9317 bfd_print_symbol_type how
)
9319 vms_debug2 ((1, "vms_print_symbol (%p, %p, %p, %d)\n",
9320 abfd
, file
, symbol
, how
));
9324 case bfd_print_symbol_name
:
9325 case bfd_print_symbol_more
:
9326 fprintf ((FILE *)file
," %s", symbol
->name
);
9329 case bfd_print_symbol_all
:
9331 const char *section_name
= symbol
->section
->name
;
9333 bfd_print_symbol_vandf (abfd
, file
, symbol
);
9335 fprintf ((FILE *) file
," %-8s %s", section_name
, symbol
->name
);
9341 /* Return information about symbol in ret.
9343 fill type, value and name
9346 B bss segment symbol
9348 D data segment symbol
9350 t a static function symbol
9351 T text segment symbol
9356 vms_get_symbol_info (bfd
* abfd ATTRIBUTE_UNUSED
,
9362 vms_debug2 ((1, "vms_get_symbol_info (%p, %p, %p)\n", abfd
, symbol
, ret
));
9364 sec
= symbol
->section
;
9371 else if (bfd_is_com_section (sec
))
9373 else if (bfd_is_abs_section (sec
))
9375 else if (bfd_is_und_section (sec
))
9377 else if (bfd_is_ind_section (sec
))
9379 else if ((symbol
->flags
& BSF_FUNCTION
)
9380 || (bfd_get_section_flags (abfd
, sec
) & SEC_CODE
))
9382 else if (bfd_get_section_flags (abfd
, sec
) & SEC_DATA
)
9384 else if (bfd_get_section_flags (abfd
, sec
) & SEC_ALLOC
)
9389 if (ret
->type
!= 'U')
9390 ret
->value
= symbol
->value
+ symbol
->section
->vma
;
9393 ret
->name
= symbol
->name
;
9396 /* Return TRUE if the given symbol sym in the BFD abfd is
9397 a compiler generated local label, else return FALSE. */
9400 vms_bfd_is_local_label_name (bfd
* abfd ATTRIBUTE_UNUSED
,
9403 return name
[0] == '$';
9406 /* Part 4.7, writing an object file. */
9408 /* Sets the contents of the section section in BFD abfd to the data starting
9409 in memory at LOCATION. The data is written to the output section starting
9410 at offset offset for count bytes.
9412 Normally TRUE is returned, else FALSE. Possible error returns are:
9413 o bfd_error_no_contents - The output section does not have the
9414 SEC_HAS_CONTENTS attribute, so nothing can be written to it.
9415 o and some more too */
9418 _bfd_vms_set_section_contents (bfd
* abfd
,
9420 const void * location
,
9422 bfd_size_type count
)
9424 if (section
->contents
== NULL
)
9426 section
->contents
= bfd_alloc (abfd
, section
->size
);
9427 if (section
->contents
== NULL
)
9430 memcpy (section
->contents
+ offset
, location
, (size_t) count
);
9436 /* Set the architecture and machine type in BFD abfd to arch and mach.
9437 Find the correct pointer to a structure and insert it into the arch_info
9441 alpha_vms_set_arch_mach (bfd
*abfd
,
9442 enum bfd_architecture arch
, unsigned long mach
)
9444 if (arch
!= bfd_arch_alpha
9445 && arch
!= bfd_arch_unknown
)
9448 return bfd_default_set_arch_mach (abfd
, arch
, mach
);
9451 /* Set section VMS flags. Clear NO_FLAGS and set FLAGS. */
9454 bfd_vms_set_section_flags (bfd
*abfd ATTRIBUTE_UNUSED
,
9455 asection
*sec
, flagword no_flags
, flagword flags
)
9457 vms_section_data (sec
)->no_flags
= no_flags
;
9458 vms_section_data (sec
)->flags
= flags
;
9461 struct vms_private_data_struct
*
9462 bfd_vms_get_data (bfd
*abfd
)
9464 return (struct vms_private_data_struct
*)abfd
->tdata
.any
;
9467 #define vms_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
9468 #define vms_bfd_link_just_syms _bfd_generic_link_just_syms
9469 #define vms_bfd_copy_link_hash_symbol_type \
9470 _bfd_generic_copy_link_hash_symbol_type
9471 #define vms_bfd_is_group_section bfd_generic_is_group_section
9472 #define vms_bfd_discard_group bfd_generic_discard_group
9473 #define vms_section_already_linked _bfd_generic_section_already_linked
9474 #define vms_bfd_define_common_symbol bfd_generic_define_common_symbol
9475 #define vms_bfd_define_start_stop bfd_generic_define_start_stop
9476 #define vms_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
9478 #define vms_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
9479 #define vms_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
9480 #define vms_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data
9481 #define vms_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
9482 #define vms_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
9483 #define vms_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
9485 /* Symbols table. */
9486 #define alpha_vms_make_empty_symbol _bfd_generic_make_empty_symbol
9487 #define alpha_vms_bfd_is_target_special_symbol \
9488 ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
9489 #define alpha_vms_print_symbol vms_print_symbol
9490 #define alpha_vms_get_symbol_info vms_get_symbol_info
9491 #define alpha_vms_get_symbol_version_string \
9492 _bfd_nosymbols_get_symbol_version_string
9494 #define alpha_vms_read_minisymbols _bfd_generic_read_minisymbols
9495 #define alpha_vms_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
9496 #define alpha_vms_get_lineno _bfd_nosymbols_get_lineno
9497 #define alpha_vms_find_inliner_info _bfd_nosymbols_find_inliner_info
9498 #define alpha_vms_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
9499 #define alpha_vms_find_nearest_line _bfd_vms_find_nearest_line
9500 #define alpha_vms_find_line _bfd_nosymbols_find_line
9501 #define alpha_vms_bfd_is_local_label_name vms_bfd_is_local_label_name
9503 /* Generic table. */
9504 #define alpha_vms_close_and_cleanup vms_close_and_cleanup
9505 #define alpha_vms_bfd_free_cached_info vms_bfd_free_cached_info
9506 #define alpha_vms_new_section_hook vms_new_section_hook
9507 #define alpha_vms_set_section_contents _bfd_vms_set_section_contents
9508 #define alpha_vms_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
9510 #define alpha_vms_bfd_get_relocated_section_contents \
9511 bfd_generic_get_relocated_section_contents
9513 #define alpha_vms_bfd_relax_section bfd_generic_relax_section
9514 #define alpha_vms_bfd_gc_sections bfd_generic_gc_sections
9515 #define alpha_vms_bfd_lookup_section_flags bfd_generic_lookup_section_flags
9516 #define alpha_vms_bfd_merge_sections bfd_generic_merge_sections
9517 #define alpha_vms_bfd_is_group_section bfd_generic_is_group_section
9518 #define alpha_vms_bfd_discard_group bfd_generic_discard_group
9519 #define alpha_vms_section_already_linked \
9520 _bfd_generic_section_already_linked
9522 #define alpha_vms_bfd_define_common_symbol bfd_generic_define_common_symbol
9523 #define alpha_vms_bfd_define_start_stop bfd_generic_define_start_stop
9524 #define alpha_vms_bfd_link_just_syms _bfd_generic_link_just_syms
9525 #define alpha_vms_bfd_copy_link_hash_symbol_type \
9526 _bfd_generic_copy_link_hash_symbol_type
9528 #define alpha_vms_bfd_link_split_section _bfd_generic_link_split_section
9530 #define alpha_vms_get_dynamic_symtab_upper_bound \
9531 _bfd_nodynamic_get_dynamic_symtab_upper_bound
9532 #define alpha_vms_canonicalize_dynamic_symtab \
9533 _bfd_nodynamic_canonicalize_dynamic_symtab
9534 #define alpha_vms_get_dynamic_reloc_upper_bound \
9535 _bfd_nodynamic_get_dynamic_reloc_upper_bound
9536 #define alpha_vms_canonicalize_dynamic_reloc \
9537 _bfd_nodynamic_canonicalize_dynamic_reloc
9538 #define alpha_vms_bfd_link_check_relocs _bfd_generic_link_check_relocs
9540 const bfd_target alpha_vms_vec
=
9542 "vms-alpha", /* Name. */
9543 bfd_target_evax_flavour
,
9544 BFD_ENDIAN_LITTLE
, /* Data byte order is little. */
9545 BFD_ENDIAN_LITTLE
, /* Header byte order is little. */
9547 (HAS_RELOC
| EXEC_P
| HAS_LINENO
| HAS_DEBUG
| HAS_SYMS
| HAS_LOCALS
9548 | WP_TEXT
| D_PAGED
), /* Object flags. */
9549 (SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
9550 | SEC_READONLY
| SEC_CODE
| SEC_DATA
9551 | SEC_HAS_CONTENTS
| SEC_IN_MEMORY
), /* Sect flags. */
9552 0, /* symbol_leading_char. */
9553 ' ', /* ar_pad_char. */
9554 15, /* ar_max_namelen. */
9555 0, /* match priority. */
9556 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
9557 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
9558 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
9559 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
9560 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
9561 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
9563 {_bfd_dummy_target
, alpha_vms_object_p
, /* bfd_check_format. */
9564 _bfd_vms_lib_alpha_archive_p
, _bfd_dummy_target
},
9565 {bfd_false
, alpha_vms_mkobject
, /* bfd_set_format. */
9566 _bfd_vms_lib_alpha_mkarchive
, bfd_false
},
9567 {bfd_false
, alpha_vms_write_object_contents
, /* bfd_write_contents. */
9568 _bfd_vms_lib_write_archive_contents
, bfd_false
},
9570 BFD_JUMP_TABLE_GENERIC (alpha_vms
),
9571 BFD_JUMP_TABLE_COPY (vms
),
9572 BFD_JUMP_TABLE_CORE (_bfd_nocore
),
9573 BFD_JUMP_TABLE_ARCHIVE (_bfd_vms_lib
),
9574 BFD_JUMP_TABLE_SYMBOLS (alpha_vms
),
9575 BFD_JUMP_TABLE_RELOCS (alpha_vms
),
9576 BFD_JUMP_TABLE_WRITE (alpha_vms
),
9577 BFD_JUMP_TABLE_LINK (alpha_vms
),
9578 BFD_JUMP_TABLE_DYNAMIC (alpha_vms
),