1 /* vms.c -- BFD back-end for EVAX (openVMS/Alpha) files.
2 Copyright (C) 1996-2019 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 (abfd
, eisd
->gblnam
,
599 rec_size
- offsetof (struct vms_eisd
, gblnam
));
601 name
= _bfd_vms_save_counted_string (abfd
, eisd
->gblnam
,
605 bfd_flags
|= SEC_COFF_SHARED_LIBRARY
;
606 bfd_flags
&= ~(SEC_ALLOC
| SEC_LOAD
);
608 else if (flags
& EISD__M_FIXUPVEC
)
610 else if (eisd
->type
== EISD__K_USRSTACK
)
616 name
= (char *) bfd_alloc (abfd
, 32);
619 if (flags
& EISD__M_DZRO
)
621 else if (flags
& EISD__M_EXE
)
623 else if (!(flags
& EISD__M_WRT
))
627 BFD_ASSERT (section_count
< 999);
628 sprintf (name
, "$%s_%03d$", pfx
, section_count
++);
631 section
= bfd_make_section (abfd
, name
);
636 section
->filepos
= vbn
? VMS_BLOCK_SIZE
* (vbn
- 1) : 0;
637 section
->size
= size
;
638 section
->vma
= vaddr
;
640 if (!bfd_set_section_flags (section
, bfd_flags
))
647 /* Read & process EIHS record.
648 Return TRUE on success, FALSE on error. */
651 _bfd_vms_slurp_eihs (bfd
*abfd
, unsigned int offset
)
653 unsigned char *p
= PRIV (recrd
.rec
) + offset
;
655 unsigned int gstsize ATTRIBUTE_UNUSED
;
657 unsigned int dstsize
;
659 unsigned int dmtbytes
;
662 /* PR 21611: Check that offset is valid. */
663 if (offset
> PRIV (recrd
.rec_size
) - (EIHS__L_DMTBYTES
+ 4))
665 _bfd_error_handler (_("unable to read EIHS record at offset %#x"),
667 bfd_set_error (bfd_error_file_truncated
);
671 gstvbn
= bfd_getl32 (p
+ EIHS__L_GSTVBN
);
672 gstsize
= bfd_getl32 (p
+ EIHS__L_GSTSIZE
);
673 dstvbn
= bfd_getl32 (p
+ EIHS__L_DSTVBN
);
674 dstsize
= bfd_getl32 (p
+ EIHS__L_DSTSIZE
);
675 dmtvbn
= bfd_getl32 (p
+ EIHS__L_DMTVBN
);
676 dmtbytes
= bfd_getl32 (p
+ EIHS__L_DMTBYTES
);
679 vms_debug (8, "_bfd_vms_slurp_ihs\n");
680 vms_debug (4, "EIHS record gstvbn %d gstsize %d dstvbn %d dstsize %d dmtvbn %d dmtbytes %d\n",
681 gstvbn
, gstsize
, dstvbn
, dstsize
, dmtvbn
, dmtbytes
);
686 flagword bfd_flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
;
688 section
= bfd_make_section (abfd
, "$DST$");
692 section
->size
= dstsize
;
693 section
->filepos
= VMS_BLOCK_SIZE
* (dstvbn
- 1);
695 if (!bfd_set_section_flags (section
, bfd_flags
))
698 PRIV (dst_section
) = section
;
699 abfd
->flags
|= (HAS_DEBUG
| HAS_LINENO
);
704 flagword bfd_flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
;
706 section
= bfd_make_section (abfd
, "$DMT$");
710 section
->size
= dmtbytes
;
711 section
->filepos
= VMS_BLOCK_SIZE
* (dmtvbn
- 1);
713 if (!bfd_set_section_flags (section
, bfd_flags
))
719 if (bfd_seek (abfd
, VMS_BLOCK_SIZE
* (gstvbn
- 1), SEEK_SET
))
721 bfd_set_error (bfd_error_file_truncated
);
725 if (!_bfd_vms_slurp_object_records (abfd
))
728 abfd
->flags
|= HAS_SYMS
;
734 /* Object file reading. */
736 /* Object file input functions. */
738 /* Get next record from object file to vms_buf.
739 Set PRIV(buf_size) and return it
741 This is a little tricky since it should be portable.
743 The openVMS object file has 'variable length' which means that
744 read() returns data in chunks of (hopefully) correct and expected
745 size. The linker (and other tools on VMS) depend on that. Unix
746 doesn't know about 'formatted' files, so reading and writing such
747 an object file in a Unix environment is not trivial.
749 With the tool 'file' (available on all VMS FTP sites), one
750 can view and change the attributes of a file. Changing from
751 'variable length' to 'fixed length, 512 bytes' reveals the
752 record size at the first 2 bytes of every record. The same
753 may happen during the transfer of object files from VMS to Unix,
754 at least with UCX, the DEC implementation of TCP/IP.
756 The VMS format repeats the size at bytes 2 & 3 of every record.
758 On the first call (file_format == FF_UNKNOWN) we check if
759 the first and the third byte pair (!) of the record match.
760 If they do it's an object file in an Unix environment or with
761 wrong attributes (FF_FOREIGN), else we should be in a VMS
762 environment where read() returns the record size (FF_NATIVE).
764 Reading is always done in 2 steps:
765 1. first just the record header is read and the size extracted,
766 2. then the read buffer is adjusted and the remaining bytes are
769 All file I/O is done on even file positions. */
771 #define VMS_OBJECT_ADJUSTMENT 2
774 maybe_adjust_record_pointer_for_object (bfd
*abfd
)
776 /* Set the file format once for all on the first invocation. */
777 if (PRIV (recrd
.file_format
) == FF_UNKNOWN
)
779 if (PRIV (recrd
.rec
)[0] == PRIV (recrd
.rec
)[4]
780 && PRIV (recrd
.rec
)[1] == PRIV (recrd
.rec
)[5])
781 PRIV (recrd
.file_format
) = FF_FOREIGN
;
783 PRIV (recrd
.file_format
) = FF_NATIVE
;
786 /* The adjustment is needed only in an Unix environment. */
787 if (PRIV (recrd
.file_format
) == FF_FOREIGN
)
788 PRIV (recrd
.rec
) += VMS_OBJECT_ADJUSTMENT
;
791 /* Implement step #1 of the object record reading procedure.
792 Return the record type or -1 on failure. */
795 _bfd_vms_get_object_record (bfd
*abfd
)
797 unsigned int test_len
= 6;
800 vms_debug2 ((8, "_bfd_vms_get_obj_record\n"));
802 /* Skip alignment byte if the current position is odd. */
803 if (PRIV (recrd
.file_format
) == FF_FOREIGN
&& (bfd_tell (abfd
) & 1))
805 if (bfd_bread (PRIV (recrd
.buf
), 1, abfd
) != 1)
807 bfd_set_error (bfd_error_file_truncated
);
812 /* Read the record header */
813 if (bfd_bread (PRIV (recrd
.buf
), test_len
, abfd
) != test_len
)
815 bfd_set_error (bfd_error_file_truncated
);
819 /* Reset the record pointer. */
820 PRIV (recrd
.rec
) = PRIV (recrd
.buf
);
821 maybe_adjust_record_pointer_for_object (abfd
);
823 if (vms_get_remaining_object_record (abfd
, test_len
) <= 0)
826 type
= bfd_getl16 (PRIV (recrd
.rec
));
828 vms_debug2 ((8, "_bfd_vms_get_obj_record: rec %p, size %d, type %d\n",
829 PRIV (recrd
.rec
), PRIV (recrd
.rec_size
), type
));
834 /* Implement step #2 of the object record reading procedure.
835 Return the size of the record or 0 on failure. */
838 vms_get_remaining_object_record (bfd
*abfd
, unsigned int read_so_far
)
840 unsigned int to_read
;
842 vms_debug2 ((8, "vms_get_remaining_obj_record\n"));
844 /* Extract record size. */
845 PRIV (recrd
.rec_size
) = bfd_getl16 (PRIV (recrd
.rec
) + 2);
847 if (PRIV (recrd
.rec_size
) == 0)
849 bfd_set_error (bfd_error_file_truncated
);
853 /* That's what the linker manual says. */
854 if (PRIV (recrd
.rec_size
) > EOBJ__C_MAXRECSIZ
)
856 bfd_set_error (bfd_error_file_truncated
);
860 /* Take into account object adjustment. */
861 to_read
= PRIV (recrd
.rec_size
);
862 if (PRIV (recrd
.file_format
) == FF_FOREIGN
)
863 to_read
+= VMS_OBJECT_ADJUSTMENT
;
865 /* Adjust the buffer. */
866 if (to_read
> PRIV (recrd
.buf_size
))
869 = (unsigned char *) bfd_realloc (PRIV (recrd
.buf
), to_read
);
870 if (PRIV (recrd
.buf
) == NULL
)
872 PRIV (recrd
.buf_size
) = to_read
;
874 /* PR 17512: file: 025-1974-0.004. */
875 else if (to_read
<= read_so_far
)
878 /* Read the remaining record. */
879 to_read
-= read_so_far
;
881 vms_debug2 ((8, "vms_get_remaining_obj_record: to_read %d\n", to_read
));
883 if (bfd_bread (PRIV (recrd
.buf
) + read_so_far
, to_read
, abfd
) != to_read
)
885 bfd_set_error (bfd_error_file_truncated
);
889 /* Reset the record pointer. */
890 PRIV (recrd
.rec
) = PRIV (recrd
.buf
);
891 maybe_adjust_record_pointer_for_object (abfd
);
893 vms_debug2 ((8, "vms_get_remaining_obj_record: size %d\n",
894 PRIV (recrd
.rec_size
)));
896 return PRIV (recrd
.rec_size
);
899 /* Read and process emh record.
900 Return TRUE on success, FALSE on error. */
903 _bfd_vms_slurp_ehdr (bfd
*abfd
)
906 unsigned char *vms_rec
;
910 vms_rec
= PRIV (recrd
.rec
);
911 /* PR 17512: file: 62736583. */
912 end
= PRIV (recrd
.buf
) + PRIV (recrd
.buf_size
);
914 vms_debug2 ((2, "HDR/EMH\n"));
916 subtype
= bfd_getl16 (vms_rec
+ 4);
918 vms_debug2 ((3, "subtype %d\n", subtype
));
924 if (vms_rec
+ 21 >= end
)
926 PRIV (hdr_data
).hdr_b_strlvl
= vms_rec
[6];
927 PRIV (hdr_data
).hdr_l_arch1
= bfd_getl32 (vms_rec
+ 8);
928 PRIV (hdr_data
).hdr_l_arch2
= bfd_getl32 (vms_rec
+ 12);
929 PRIV (hdr_data
).hdr_l_recsiz
= bfd_getl32 (vms_rec
+ 16);
930 if ((vms_rec
+ 20 + vms_rec
[20] + 1) >= end
)
932 PRIV (hdr_data
).hdr_t_name
933 = _bfd_vms_save_counted_string (abfd
, vms_rec
+ 20, vms_rec
[20]);
934 ptr
= vms_rec
+ 20 + vms_rec
[20] + 1;
935 if ((ptr
+ *ptr
+ 1) >= end
)
937 PRIV (hdr_data
).hdr_t_version
938 = _bfd_vms_save_counted_string (abfd
, ptr
, *ptr
);
942 PRIV (hdr_data
).hdr_t_date
943 = _bfd_vms_save_sized_string (abfd
, ptr
, 17);
947 if (vms_rec
+ PRIV (recrd
.rec_size
- 6) > end
)
949 PRIV (hdr_data
).hdr_c_lnm
950 = _bfd_vms_save_sized_string (abfd
, vms_rec
, PRIV (recrd
.rec_size
- 6));
954 if (vms_rec
+ PRIV (recrd
.rec_size
- 6) > end
)
956 PRIV (hdr_data
).hdr_c_src
957 = _bfd_vms_save_sized_string (abfd
, vms_rec
, PRIV (recrd
.rec_size
- 6));
961 if (vms_rec
+ PRIV (recrd
.rec_size
- 6) > end
)
963 PRIV (hdr_data
).hdr_c_ttl
964 = _bfd_vms_save_sized_string (abfd
, vms_rec
, PRIV (recrd
.rec_size
- 6));
974 bfd_set_error (bfd_error_wrong_format
);
981 /* Typical sections for evax object files. */
983 #define EVAX_ABS_NAME "$ABS$"
984 #define EVAX_CODE_NAME "$CODE$"
985 #define EVAX_LINK_NAME "$LINK$"
986 #define EVAX_DATA_NAME "$DATA$"
987 #define EVAX_BSS_NAME "$BSS$"
988 #define EVAX_READONLYADDR_NAME "$READONLY_ADDR$"
989 #define EVAX_READONLY_NAME "$READONLY$"
990 #define EVAX_LITERAL_NAME "$LITERAL$"
991 #define EVAX_LITERALS_NAME "$LITERALS"
992 #define EVAX_COMMON_NAME "$COMMON$"
993 #define EVAX_LOCAL_NAME "$LOCAL$"
995 struct sec_flags_struct
997 const char *name
; /* Name of section. */
999 flagword flags_always
; /* Flags we set always. */
1001 flagword flags_hassize
; /* Flags we set if the section has a size > 0. */
1004 /* These flags are deccrtl/vaxcrtl (openVMS 6.2 Alpha) compatible. */
1006 static const struct sec_flags_struct evax_section_flags
[] =
1014 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_EXE
,
1015 SEC_CODE
| SEC_READONLY
,
1016 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_EXE
,
1017 SEC_CODE
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1018 { EVAX_LITERAL_NAME
,
1019 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
| EGPS__V_NOMOD
,
1020 SEC_DATA
| SEC_READONLY
,
1021 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
,
1022 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1024 EGPS__V_REL
| EGPS__V_RD
,
1025 SEC_DATA
| SEC_READONLY
,
1026 EGPS__V_REL
| EGPS__V_RD
,
1027 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1029 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
,
1031 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1032 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1034 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
,
1036 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
,
1038 { EVAX_READONLYADDR_NAME
,
1039 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_RD
,
1040 SEC_DATA
| SEC_READONLY
,
1041 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_RD
,
1042 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1043 { EVAX_READONLY_NAME
,
1044 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
| EGPS__V_NOMOD
,
1045 SEC_DATA
| SEC_READONLY
,
1046 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
,
1047 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1049 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1051 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1052 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1053 { EVAX_LITERALS_NAME
,
1054 EGPS__V_PIC
| EGPS__V_OVR
,
1055 SEC_DATA
| SEC_READONLY
,
1056 EGPS__V_PIC
| EGPS__V_OVR
,
1057 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1059 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1061 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1062 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
}
1065 /* Retrieve BFD section flags by name and size. */
1068 vms_secflag_by_name (const struct sec_flags_struct
*section_flags
,
1074 while (section_flags
[i
].name
!= NULL
)
1076 if (strcmp (name
, section_flags
[i
].name
) == 0)
1079 return section_flags
[i
].flags_hassize
;
1081 return section_flags
[i
].flags_always
;
1086 return section_flags
[i
].flags_hassize
;
1087 return section_flags
[i
].flags_always
;
1090 /* Retrieve VMS section flags by name and size. */
1093 vms_esecflag_by_name (const struct sec_flags_struct
*section_flags
,
1099 while (section_flags
[i
].name
!= NULL
)
1101 if (strcmp (name
, section_flags
[i
].name
) == 0)
1104 return section_flags
[i
].vflags_hassize
;
1106 return section_flags
[i
].vflags_always
;
1111 return section_flags
[i
].vflags_hassize
;
1112 return section_flags
[i
].vflags_always
;
1115 /* Add SYM to the symbol table of ABFD.
1116 Return FALSE in case of error. */
1119 add_symbol_entry (bfd
*abfd
, struct vms_symbol_entry
*sym
)
1121 if (PRIV (gsd_sym_count
) >= PRIV (max_sym_count
))
1123 if (PRIV (max_sym_count
) == 0)
1125 PRIV (max_sym_count
) = 128;
1126 PRIV (syms
) = bfd_malloc
1127 (PRIV (max_sym_count
) * sizeof (struct vms_symbol_entry
*));
1131 PRIV (max_sym_count
) *= 2;
1132 PRIV (syms
) = bfd_realloc
1134 (PRIV (max_sym_count
) * sizeof (struct vms_symbol_entry
*)));
1136 if (PRIV (syms
) == NULL
)
1140 PRIV (syms
)[PRIV (gsd_sym_count
)++] = sym
;
1144 /* Create a symbol whose name is ASCIC and add it to ABFD.
1145 Return NULL in case of error. */
1147 static struct vms_symbol_entry
*
1148 add_symbol (bfd
*abfd
, const unsigned char *ascic
, unsigned int max
)
1150 struct vms_symbol_entry
*entry
;
1157 _bfd_error_handler (_("record is too small for symbol name length"));
1158 bfd_set_error (bfd_error_bad_value
);
1162 entry
= (struct vms_symbol_entry
*)bfd_zalloc (abfd
, sizeof (*entry
) + len
);
1165 entry
->namelen
= len
;
1166 memcpy (entry
->name
, ascic
, len
);
1167 entry
->name
[len
] = 0;
1168 entry
->owner
= abfd
;
1170 if (!add_symbol_entry (abfd
, entry
))
1175 /* Read and process EGSD. Return FALSE on failure. */
1178 _bfd_vms_slurp_egsd (bfd
*abfd
)
1181 unsigned int gsd_size
;
1182 unsigned char *vms_rec
;
1183 unsigned long base_addr
;
1185 vms_debug2 ((2, "EGSD\n"));
1187 if (PRIV (recrd
.rec_size
) < 8)
1189 _bfd_error_handler (_("corrupt EGSD record: its size (%#x) is too small"),
1190 PRIV (recrd
.rec_size
));
1191 bfd_set_error (bfd_error_bad_value
);
1195 PRIV (recrd
.rec
) += 8; /* Skip type, size, align pad. */
1196 PRIV (recrd
.rec_size
) -= 8;
1198 /* Calculate base address for each section. */
1201 while (PRIV (recrd
.rec_size
) > 4)
1203 vms_rec
= PRIV (recrd
.rec
);
1205 gsd_type
= bfd_getl16 (vms_rec
);
1206 gsd_size
= bfd_getl16 (vms_rec
+ 2);
1208 vms_debug2 ((3, "egsd_type %d\n", gsd_type
));
1210 /* PR 21615: Check for size overflow. */
1211 if (PRIV (recrd
.rec_size
) < gsd_size
)
1213 _bfd_error_handler (_("corrupt EGSD record: size (%#x) is larger than remaining space (%#x)"),
1214 gsd_size
, PRIV (recrd
.rec_size
));
1215 bfd_set_error (bfd_error_bad_value
);
1221 _bfd_error_handler (_("corrupt EGSD record: size (%#x) is too small"),
1223 bfd_set_error (bfd_error_bad_value
);
1230 /* Program section definition. */
1232 struct vms_egps
*egps
= (struct vms_egps
*)vms_rec
;
1233 flagword new_flags
, vms_flags
;
1236 vms_flags
= bfd_getl16 (egps
->flags
);
1238 if ((vms_flags
& EGPS__V_REL
) == 0)
1240 /* Use the global absolute section for all
1241 absolute sections. */
1242 section
= bfd_abs_section_ptr
;
1247 unsigned long align_addr
;
1249 name
= _bfd_vms_save_counted_string (abfd
, &egps
->namlng
,
1252 section
= bfd_make_section (abfd
, name
);
1256 section
->filepos
= 0;
1257 section
->size
= bfd_getl32 (egps
->alloc
);
1258 section
->alignment_power
= egps
->align
;
1260 vms_section_data (section
)->flags
= vms_flags
;
1261 vms_section_data (section
)->no_flags
= 0;
1263 new_flags
= vms_secflag_by_name (evax_section_flags
,
1266 if (section
->size
> 0)
1267 new_flags
|= SEC_LOAD
;
1268 if (!(vms_flags
& EGPS__V_NOMOD
) && section
->size
> 0)
1270 /* Set RELOC and HAS_CONTENTS if the section is not
1271 demand-zero and not empty. */
1272 new_flags
|= SEC_HAS_CONTENTS
;
1273 if (vms_flags
& EGPS__V_REL
)
1274 new_flags
|= SEC_RELOC
;
1276 if (vms_flags
& EGPS__V_EXE
)
1278 /* Set CODE if section is executable. */
1279 new_flags
|= SEC_CODE
;
1280 new_flags
&= ~SEC_DATA
;
1282 if (!bfd_set_section_flags (section
, new_flags
))
1285 /* Give a non-overlapping vma to non absolute sections. */
1286 align_addr
= (1 << section
->alignment_power
);
1287 if ((base_addr
% align_addr
) != 0)
1288 base_addr
+= (align_addr
- (base_addr
% align_addr
));
1289 section
->vma
= (bfd_vma
)base_addr
;
1290 base_addr
+= section
->size
;
1293 /* Append it to the section array. */
1294 if (PRIV (section_count
) >= PRIV (section_max
))
1296 if (PRIV (section_max
) == 0)
1297 PRIV (section_max
) = 16;
1299 PRIV (section_max
) *= 2;
1300 PRIV (sections
) = bfd_realloc_or_free
1301 (PRIV (sections
), PRIV (section_max
) * sizeof (asection
*));
1302 if (PRIV (sections
) == NULL
)
1306 PRIV (sections
)[PRIV (section_count
)] = section
;
1307 PRIV (section_count
)++;
1313 unsigned int nameoff
;
1314 struct vms_symbol_entry
*entry
;
1315 struct vms_egsy
*egsy
= (struct vms_egsy
*) vms_rec
;
1318 old_flags
= bfd_getl16 (egsy
->flags
);
1319 if (old_flags
& EGSY__V_DEF
)
1320 nameoff
= ESDF__B_NAMLNG
;
1322 nameoff
= ESRF__B_NAMLNG
;
1324 if (nameoff
>= gsd_size
)
1326 _bfd_error_handler (_("ECSD__C_SYM record is too small"));
1327 bfd_set_error (bfd_error_bad_value
);
1330 entry
= add_symbol (abfd
, vms_rec
+ nameoff
, gsd_size
- nameoff
);
1334 /* Allow only duplicate reference. */
1335 if ((entry
->flags
& EGSY__V_DEF
) && (old_flags
& EGSY__V_DEF
))
1338 if (entry
->typ
== 0)
1340 entry
->typ
= gsd_type
;
1341 entry
->data_type
= egsy
->datyp
;
1342 entry
->flags
= old_flags
;
1345 if (old_flags
& EGSY__V_DEF
)
1347 struct vms_esdf
*esdf
= (struct vms_esdf
*)vms_rec
;
1350 entry
->value
= bfd_getl64 (esdf
->value
);
1351 if (PRIV (sections
) == NULL
)
1354 psindx
= bfd_getl32 (esdf
->psindx
);
1355 /* PR 21813: Check for an out of range index. */
1356 if (psindx
< 0 || psindx
>= (int) PRIV (section_count
))
1358 _bfd_error_handler (_("corrupt EGSD record: its psindx field is too big (%#lx)"),
1360 bfd_set_error (bfd_error_bad_value
);
1363 entry
->section
= PRIV (sections
)[psindx
];
1365 if (old_flags
& EGSY__V_NORM
)
1367 PRIV (norm_sym_count
)++;
1369 entry
->code_value
= bfd_getl64 (esdf
->code_address
);
1370 psindx
= bfd_getl32 (esdf
->ca_psindx
);
1371 /* PR 21813: Check for an out of range index. */
1372 if (psindx
< 0 || psindx
>= (int) PRIV (section_count
))
1374 _bfd_error_handler (_("corrupt EGSD record: its psindx field is too big (%#lx)"),
1376 bfd_set_error (bfd_error_bad_value
);
1379 entry
->code_section
= PRIV (sections
)[psindx
];
1387 struct vms_symbol_entry
*entry
;
1388 struct vms_egst
*egst
= (struct vms_egst
*)vms_rec
;
1390 unsigned int nameoff
= offsetof (struct vms_egst
, namlng
);
1392 old_flags
= bfd_getl16 (egst
->header
.flags
);
1394 if (nameoff
>= gsd_size
)
1396 _bfd_error_handler (_("ECSD__C_SYMG record is too small"));
1397 bfd_set_error (bfd_error_bad_value
);
1400 entry
= add_symbol (abfd
, &egst
->namlng
, gsd_size
- nameoff
);
1404 entry
->typ
= gsd_type
;
1405 entry
->data_type
= egst
->header
.datyp
;
1406 entry
->flags
= old_flags
;
1408 entry
->symbol_vector
= bfd_getl32 (egst
->value
);
1410 if (old_flags
& EGSY__V_REL
)
1414 if (PRIV (sections
) == NULL
)
1416 psindx
= bfd_getl32 (egst
->psindx
);
1417 /* PR 21813: Check for an out of range index. */
1418 if (psindx
< 0 || psindx
>= (int) PRIV (section_count
))
1420 _bfd_error_handler (_("corrupt EGSD record: its psindx field is too big (%#lx)"),
1422 bfd_set_error (bfd_error_bad_value
);
1425 entry
->section
= PRIV (sections
)[psindx
];
1428 entry
->section
= bfd_abs_section_ptr
;
1430 entry
->value
= bfd_getl64 (egst
->lp_2
);
1432 if (old_flags
& EGSY__V_NORM
)
1434 PRIV (norm_sym_count
)++;
1436 entry
->code_value
= bfd_getl64 (egst
->lp_1
);
1437 entry
->code_section
= bfd_abs_section_ptr
;
1444 /* Currently ignored. */
1449 _bfd_error_handler (_("unknown EGSD subtype %d"), gsd_type
);
1450 bfd_set_error (bfd_error_bad_value
);
1454 PRIV (recrd
.rec_size
) -= gsd_size
;
1455 PRIV (recrd
.rec
) += gsd_size
;
1458 /* FIXME: Should we complain if PRIV (recrd.rec_size) is not zero ? */
1460 if (PRIV (gsd_sym_count
) > 0)
1461 abfd
->flags
|= HAS_SYMS
;
1466 /* Stack routines for vms ETIR commands. */
1468 /* Push value and section index. */
1471 _bfd_vms_push (bfd
*abfd
, bfd_vma val
, unsigned int reloc
)
1473 vms_debug2 ((4, "<push %08lx (0x%08x) at %d>\n",
1474 (unsigned long)val
, reloc
, PRIV (stackptr
)));
1476 PRIV (stack
[PRIV (stackptr
)]).value
= val
;
1477 PRIV (stack
[PRIV (stackptr
)]).reloc
= reloc
;
1479 if (PRIV (stackptr
) >= STACKSIZE
)
1481 bfd_set_error (bfd_error_bad_value
);
1482 _bfd_error_handler (_("stack overflow (%d) in _bfd_vms_push"), PRIV (stackptr
));
1487 /* Pop value and section index. */
1490 _bfd_vms_pop (bfd
*abfd
, bfd_vma
*val
, unsigned int *rel
)
1492 if (PRIV (stackptr
) == 0)
1494 bfd_set_error (bfd_error_bad_value
);
1495 _bfd_error_handler (_("stack underflow in _bfd_vms_pop"));
1499 *val
= PRIV (stack
[PRIV (stackptr
)]).value
;
1500 *rel
= PRIV (stack
[PRIV (stackptr
)]).reloc
;
1502 vms_debug2 ((4, "<pop %08lx (0x%08x)>\n", (unsigned long)*val
, *rel
));
1505 /* Routines to fill sections contents during tir/etir read. */
1507 /* Initialize image buffer pointer to be filled. */
1510 image_set_ptr (bfd
*abfd
, bfd_vma vma
, int sect
, struct bfd_link_info
*info
)
1514 vms_debug2 ((4, "image_set_ptr (0x%08x, sect=%d)\n", (unsigned)vma
, sect
));
1516 if (PRIV (sections
) == NULL
)
1518 if (sect
< 0 || sect
>= (int) PRIV (section_count
))
1521 sec
= PRIV (sections
)[sect
];
1525 /* Reading contents to an output bfd. */
1527 if (sec
->output_section
== NULL
)
1529 /* Section discarded. */
1530 vms_debug2 ((5, " section %s discarded\n", sec
->name
));
1532 /* This is not used. */
1533 PRIV (image_section
) = NULL
;
1534 PRIV (image_offset
) = 0;
1537 PRIV (image_offset
) = sec
->output_offset
+ vma
;
1538 PRIV (image_section
) = sec
->output_section
;
1542 PRIV (image_offset
) = vma
;
1543 PRIV (image_section
) = sec
;
1547 /* Increment image buffer pointer by offset. */
1550 image_inc_ptr (bfd
*abfd
, bfd_vma offset
)
1552 vms_debug2 ((4, "image_inc_ptr (%u)\n", (unsigned)offset
));
1554 PRIV (image_offset
) += offset
;
1557 /* Save current DST location counter under specified index. */
1560 dst_define_location (bfd
*abfd
, unsigned int loc
)
1562 vms_debug2 ((4, "dst_define_location (%d)\n", (int)loc
));
1564 /* Grow the ptr offset table if necessary. */
1565 if (loc
+ 1 > PRIV (dst_ptr_offsets_count
))
1567 PRIV (dst_ptr_offsets
) = bfd_realloc (PRIV (dst_ptr_offsets
),
1568 (loc
+ 1) * sizeof (unsigned int));
1569 PRIV (dst_ptr_offsets_count
) = loc
+ 1;
1572 PRIV (dst_ptr_offsets
)[loc
] = PRIV (image_offset
);
1575 /* Restore saved DST location counter from specified index. */
1578 dst_restore_location (bfd
*abfd
, unsigned int loc
)
1580 vms_debug2 ((4, "dst_restore_location (%d)\n", (int)loc
));
1582 PRIV (image_offset
) = PRIV (dst_ptr_offsets
)[loc
];
1585 /* Retrieve saved DST location counter from specified index. */
1588 dst_retrieve_location (bfd
*abfd
, unsigned int loc
)
1590 vms_debug2 ((4, "dst_retrieve_location (%d)\n", (int)loc
));
1592 return PRIV (dst_ptr_offsets
)[loc
];
1595 /* Write multiple bytes to section image. */
1598 image_write (bfd
*abfd
, unsigned char *ptr
, unsigned int size
)
1601 _bfd_vms_debug (8, "image_write from (%p, %d) to (%ld)\n", ptr
, size
,
1602 (long)PRIV (image_offset
));
1603 _bfd_hexdump (9, ptr
, size
, 0);
1606 if (PRIV (image_section
)->contents
!= NULL
)
1608 asection
*sec
= PRIV (image_section
);
1609 file_ptr off
= PRIV (image_offset
);
1612 if (off
> (file_ptr
)sec
->size
1613 || size
> (file_ptr
)sec
->size
1614 || off
+ size
> (file_ptr
)sec
->size
)
1616 bfd_set_error (bfd_error_bad_value
);
1620 memcpy (sec
->contents
+ off
, ptr
, size
);
1623 PRIV (image_offset
) += size
;
1627 /* Write byte to section image. */
1630 image_write_b (bfd
* abfd
, unsigned int value
)
1632 unsigned char data
[1];
1634 vms_debug2 ((6, "image_write_b (%02x)\n", (int) value
));
1638 return image_write (abfd
, data
, sizeof (data
));
1641 /* Write 2-byte word to image. */
1644 image_write_w (bfd
* abfd
, unsigned int value
)
1646 unsigned char data
[2];
1648 vms_debug2 ((6, "image_write_w (%04x)\n", (int) value
));
1650 bfd_putl16 (value
, data
);
1651 return image_write (abfd
, data
, sizeof (data
));
1654 /* Write 4-byte long to image. */
1657 image_write_l (bfd
* abfd
, unsigned long value
)
1659 unsigned char data
[4];
1661 vms_debug2 ((6, "image_write_l (%08lx)\n", value
));
1663 bfd_putl32 (value
, data
);
1664 return image_write (abfd
, data
, sizeof (data
));
1667 /* Write 8-byte quad to image. */
1670 image_write_q (bfd
* abfd
, bfd_vma value
)
1672 unsigned char data
[8];
1674 vms_debug2 ((6, "image_write_q (%08lx)\n", (unsigned long)value
));
1676 bfd_putl64 (value
, data
);
1677 return image_write (abfd
, data
, sizeof (data
));
1681 _bfd_vms_etir_name (int cmd
)
1685 case ETIR__C_STA_GBL
: return "ETIR__C_STA_GBL";
1686 case ETIR__C_STA_LW
: return "ETIR__C_STA_LW";
1687 case ETIR__C_STA_QW
: return "ETIR__C_STA_QW";
1688 case ETIR__C_STA_PQ
: return "ETIR__C_STA_PQ";
1689 case ETIR__C_STA_LI
: return "ETIR__C_STA_LI";
1690 case ETIR__C_STA_MOD
: return "ETIR__C_STA_MOD";
1691 case ETIR__C_STA_CKARG
: return "ETIR__C_STA_CKARG";
1692 case ETIR__C_STO_B
: return "ETIR__C_STO_B";
1693 case ETIR__C_STO_W
: return "ETIR__C_STO_W";
1694 case ETIR__C_STO_GBL
: return "ETIR__C_STO_GBL";
1695 case ETIR__C_STO_CA
: return "ETIR__C_STO_CA";
1696 case ETIR__C_STO_RB
: return "ETIR__C_STO_RB";
1697 case ETIR__C_STO_AB
: return "ETIR__C_STO_AB";
1698 case ETIR__C_STO_OFF
: return "ETIR__C_STO_OFF";
1699 case ETIR__C_STO_IMM
: return "ETIR__C_STO_IMM";
1700 case ETIR__C_STO_IMMR
: return "ETIR__C_STO_IMMR";
1701 case ETIR__C_STO_LW
: return "ETIR__C_STO_LW";
1702 case ETIR__C_STO_QW
: return "ETIR__C_STO_QW";
1703 case ETIR__C_STO_GBL_LW
: return "ETIR__C_STO_GBL_LW";
1704 case ETIR__C_STO_LP_PSB
: return "ETIR__C_STO_LP_PSB";
1705 case ETIR__C_STO_HINT_GBL
: return "ETIR__C_STO_HINT_GBL";
1706 case ETIR__C_STO_HINT_PS
: return "ETIR__C_STO_HINT_PS";
1707 case ETIR__C_OPR_ADD
: return "ETIR__C_OPR_ADD";
1708 case ETIR__C_OPR_SUB
: return "ETIR__C_OPR_SUB";
1709 case ETIR__C_OPR_INSV
: return "ETIR__C_OPR_INSV";
1710 case ETIR__C_OPR_USH
: return "ETIR__C_OPR_USH";
1711 case ETIR__C_OPR_ROT
: return "ETIR__C_OPR_ROT";
1712 case ETIR__C_OPR_REDEF
: return "ETIR__C_OPR_REDEF";
1713 case ETIR__C_OPR_DFLIT
: return "ETIR__C_OPR_DFLIT";
1714 case ETIR__C_STC_LP
: return "ETIR__C_STC_LP";
1715 case ETIR__C_STC_GBL
: return "ETIR__C_STC_GBL";
1716 case ETIR__C_STC_GCA
: return "ETIR__C_STC_GCA";
1717 case ETIR__C_STC_PS
: return "ETIR__C_STC_PS";
1718 case ETIR__C_STC_NBH_PS
: return "ETIR__C_STC_NBH_PS";
1719 case ETIR__C_STC_NOP_GBL
: return "ETIR__C_STC_NOP_GBL";
1720 case ETIR__C_STC_NOP_PS
: return "ETIR__C_STC_NOP_PS";
1721 case ETIR__C_STC_BSR_GBL
: return "ETIR__C_STC_BSR_GBL";
1722 case ETIR__C_STC_BSR_PS
: return "ETIR__C_STC_BSR_PS";
1723 case ETIR__C_STC_LDA_GBL
: return "ETIR__C_STC_LDA_GBL";
1724 case ETIR__C_STC_LDA_PS
: return "ETIR__C_STC_LDA_PS";
1725 case ETIR__C_STC_BOH_GBL
: return "ETIR__C_STC_BOH_GBL";
1726 case ETIR__C_STC_BOH_PS
: return "ETIR__C_STC_BOH_PS";
1727 case ETIR__C_STC_NBH_GBL
: return "ETIR__C_STC_NBH_GBL";
1728 case ETIR__C_STC_LP_PSB
: return "ETIR__C_STC_LP_PSB";
1729 case ETIR__C_CTL_SETRB
: return "ETIR__C_CTL_SETRB";
1730 case ETIR__C_CTL_AUGRB
: return "ETIR__C_CTL_AUGRB";
1731 case ETIR__C_CTL_DFLOC
: return "ETIR__C_CTL_DFLOC";
1732 case ETIR__C_CTL_STLOC
: return "ETIR__C_CTL_STLOC";
1733 case ETIR__C_CTL_STKDL
: return "ETIR__C_CTL_STKDL";
1736 /* These names have not yet been added to this switch statement. */
1737 _bfd_error_handler (_("unknown ETIR command %d"), cmd
);
1742 #define HIGHBIT(op) ((op & 0x80000000L) == 0x80000000L)
1745 _bfd_vms_get_value (bfd
*abfd
,
1746 const unsigned char *ascic
,
1747 const unsigned char *max_ascic
,
1748 struct bfd_link_info
*info
,
1750 struct alpha_vms_link_hash_entry
**hp
)
1755 struct alpha_vms_link_hash_entry
*h
;
1757 /* Not linking. Do not try to resolve the symbol. */
1766 if (ascic
+ len
>= max_ascic
)
1768 _bfd_error_handler (_("corrupt vms value"));
1774 for (i
= 0; i
< len
; i
++)
1775 name
[i
] = ascic
[i
+ 1];
1778 h
= (struct alpha_vms_link_hash_entry
*)
1779 bfd_link_hash_lookup (info
->hash
, name
, FALSE
, FALSE
, TRUE
);
1784 && (h
->root
.type
== bfd_link_hash_defined
1785 || h
->root
.type
== bfd_link_hash_defweak
))
1786 *vma
= h
->root
.u
.def
.value
1787 + h
->root
.u
.def
.section
->output_offset
1788 + h
->root
.u
.def
.section
->output_section
->vma
;
1789 else if (h
&& h
->root
.type
== bfd_link_hash_undefweak
)
1793 (*info
->callbacks
->undefined_symbol
)
1794 (info
, name
, abfd
, PRIV (image_section
), PRIV (image_offset
), TRUE
);
1801 #define RELC_SHR_BASE 0x10000
1802 #define RELC_SEC_BASE 0x20000
1803 #define RELC_MASK 0x0ffff
1806 alpha_vms_sym_to_ctxt (struct alpha_vms_link_hash_entry
*h
)
1808 /* Handle undefined symbols. */
1809 if (h
== NULL
|| h
->sym
== NULL
)
1812 if (h
->sym
->typ
== EGSD__C_SYMG
)
1814 if (h
->sym
->flags
& EGSY__V_REL
)
1815 return RELC_SHR_BASE
+ PRIV2 (h
->sym
->owner
, shr_index
);
1818 /* Can this happen (non-relocatable symg) ? I'd like to see
1823 if (h
->sym
->typ
== EGSD__C_SYM
)
1825 if (h
->sym
->flags
& EGSY__V_REL
)
1834 alpha_vms_get_sym_value (asection
*sect
, bfd_vma addr
)
1836 return sect
->output_section
->vma
+ sect
->output_offset
+ addr
;
1840 alpha_vms_fix_sec_rel (bfd
*abfd
, struct bfd_link_info
*info
,
1841 unsigned int rel
, bfd_vma vma
)
1845 if (PRIV (sections
) == NULL
)
1848 sec
= PRIV (sections
)[rel
& RELC_MASK
];
1852 if (sec
->output_section
== NULL
)
1854 return vma
+ sec
->output_section
->vma
+ sec
->output_offset
;
1857 return vma
+ sec
->vma
;
1860 /* Read an ETIR record from ABFD. If INFO is not null, put the content into
1861 the output section (used during linking).
1862 Return FALSE in case of error. */
1865 _bfd_vms_slurp_etir (bfd
*abfd
, struct bfd_link_info
*info
)
1868 unsigned int length
;
1869 unsigned char *maxptr
;
1874 struct alpha_vms_link_hash_entry
*h
;
1876 PRIV (recrd
.rec
) += ETIR__C_HEADER_SIZE
;
1877 PRIV (recrd
.rec_size
) -= ETIR__C_HEADER_SIZE
;
1879 ptr
= PRIV (recrd
.rec
);
1880 length
= PRIV (recrd
.rec_size
);
1881 maxptr
= ptr
+ length
;
1883 vms_debug2 ((2, "ETIR: %d bytes\n", length
));
1885 while (ptr
< maxptr
)
1887 int cmd
, cmd_length
;
1889 if (ptr
+ 4 > maxptr
)
1892 cmd
= bfd_getl16 (ptr
);
1893 cmd_length
= bfd_getl16 (ptr
+ 2);
1895 /* PR 21589 and 21579: Check for a corrupt ETIR record. */
1896 if (cmd_length
< 4 || ptr
+ cmd_length
> maxptr
)
1899 _bfd_error_handler (_("corrupt ETIR record encountered"));
1900 bfd_set_error (bfd_error_bad_value
);
1906 _bfd_vms_debug (4, "etir: %s(%d)\n",
1907 _bfd_vms_etir_name (cmd
), cmd
);
1908 _bfd_hexdump (8, ptr
, cmd_length
- 4, 0);
1916 stack 32 bit value of symbol (high bits set to 0). */
1917 case ETIR__C_STA_GBL
:
1918 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
1919 _bfd_vms_push (abfd
, op1
, alpha_vms_sym_to_ctxt (h
));
1925 stack 32 bit value, sign extend to 64 bit. */
1926 case ETIR__C_STA_LW
:
1927 if (ptr
+ 4 > maxptr
)
1929 _bfd_vms_push (abfd
, bfd_getl32 (ptr
), RELC_NONE
);
1935 stack 64 bit value of symbol. */
1936 case ETIR__C_STA_QW
:
1937 if (ptr
+ 8 > maxptr
)
1939 _bfd_vms_push (abfd
, bfd_getl64 (ptr
), RELC_NONE
);
1942 /* Stack psect base plus quadword offset
1943 arg: lw section index
1944 qw signed quadword offset (low 32 bits)
1946 Stack qw argument and section index
1947 (see ETIR__C_STO_OFF, ETIR__C_CTL_SETRB). */
1948 case ETIR__C_STA_PQ
:
1952 if (ptr
+ 12 > maxptr
)
1954 psect
= bfd_getl32 (ptr
);
1955 if ((unsigned int) psect
>= PRIV (section_count
))
1957 _bfd_error_handler (_("bad section index in %s"),
1958 _bfd_vms_etir_name (cmd
));
1959 bfd_set_error (bfd_error_bad_value
);
1962 op1
= bfd_getl64 (ptr
+ 4);
1963 _bfd_vms_push (abfd
, op1
, psect
| RELC_SEC_BASE
);
1967 case ETIR__C_STA_LI
:
1968 case ETIR__C_STA_MOD
:
1969 case ETIR__C_STA_CKARG
:
1970 _bfd_error_handler (_("unsupported STA cmd %s"),
1971 _bfd_vms_etir_name (cmd
));
1975 /* Store byte: pop stack, write byte
1978 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1979 if (rel1
!= RELC_NONE
)
1981 image_write_b (abfd
, (unsigned int) op1
& 0xff);
1984 /* Store word: pop stack, write word
1987 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1988 if (rel1
!= RELC_NONE
)
1990 image_write_w (abfd
, (unsigned int) op1
& 0xffff);
1993 /* Store longword: pop stack, write longword
1995 case ETIR__C_STO_LW
:
1996 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1997 if (rel1
& RELC_SEC_BASE
)
1999 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2002 else if (rel1
& RELC_SHR_BASE
)
2004 alpha_vms_add_fixup_lr (info
, rel1
& RELC_MASK
, op1
);
2007 if (rel1
!= RELC_NONE
)
2009 if (rel1
!= RELC_REL
)
2011 alpha_vms_add_lw_reloc (info
);
2013 image_write_l (abfd
, op1
);
2016 /* Store quadword: pop stack, write quadword
2018 case ETIR__C_STO_QW
:
2019 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2020 if (rel1
& RELC_SEC_BASE
)
2022 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2025 else if (rel1
& RELC_SHR_BASE
)
2027 if (rel1
!= RELC_NONE
)
2029 if (rel1
!= RELC_REL
)
2031 alpha_vms_add_qw_reloc (info
);
2033 image_write_q (abfd
, op1
);
2036 /* Store immediate repeated: pop stack for repeat count
2039 case ETIR__C_STO_IMMR
:
2043 if (ptr
+ 4 > maxptr
)
2045 size
= bfd_getl32 (ptr
);
2046 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2047 if (rel1
!= RELC_NONE
)
2050 image_write (abfd
, ptr
+ 4, size
);
2054 /* Store global: write symbol value
2055 arg: cs global symbol name. */
2056 case ETIR__C_STO_GBL
:
2057 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
2060 if (h
->sym
->typ
== EGSD__C_SYMG
)
2062 alpha_vms_add_fixup_qr
2063 (info
, abfd
, h
->sym
->owner
, h
->sym
->symbol_vector
);
2068 op1
= alpha_vms_get_sym_value (h
->sym
->section
,
2070 alpha_vms_add_qw_reloc (info
);
2073 image_write_q (abfd
, op1
);
2076 /* Store code address: write address of entry point
2077 arg: cs global symbol name (procedure). */
2078 case ETIR__C_STO_CA
:
2079 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
2082 if (h
->sym
->flags
& EGSY__V_NORM
)
2084 /* That's really a procedure. */
2085 if (h
->sym
->typ
== EGSD__C_SYMG
)
2087 alpha_vms_add_fixup_ca (info
, abfd
, h
->sym
->owner
);
2088 op1
= h
->sym
->symbol_vector
;
2092 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
2093 h
->sym
->code_value
);
2094 alpha_vms_add_qw_reloc (info
);
2099 /* Symbol is not a procedure. */
2103 image_write_q (abfd
, op1
);
2106 /* Store offset to psect: pop stack, add low 32 bits to base of psect
2108 case ETIR__C_STO_OFF
:
2109 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2111 if (!(rel1
& RELC_SEC_BASE
))
2114 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2116 image_write_q (abfd
, op1
);
2120 arg: lw count of bytes
2122 case ETIR__C_STO_IMM
:
2126 if (ptr
+ 4 > maxptr
)
2128 size
= bfd_getl32 (ptr
);
2129 image_write (abfd
, ptr
+ 4, size
);
2133 /* This code is 'reserved to digital' according to the openVMS
2134 linker manual, however it is generated by the DEC C compiler
2135 and defined in the include file.
2136 FIXME, since the following is just a guess
2137 store global longword: store 32bit value of symbol
2138 arg: cs symbol name. */
2139 case ETIR__C_STO_GBL_LW
:
2140 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
2144 image_write_l (abfd
, op1
);
2147 case ETIR__C_STO_RB
:
2148 case ETIR__C_STO_AB
:
2149 case ETIR__C_STO_LP_PSB
:
2150 _bfd_error_handler (_("%s: not supported"),
2151 _bfd_vms_etir_name (cmd
));
2154 case ETIR__C_STO_HINT_GBL
:
2155 case ETIR__C_STO_HINT_PS
:
2156 _bfd_error_handler (_("%s: not implemented"),
2157 _bfd_vms_etir_name (cmd
));
2161 /* 200 Store-conditional Linkage Pair
2163 case ETIR__C_STC_LP
:
2165 /* 202 Store-conditional Address at global address
2169 case ETIR__C_STC_GBL
:
2171 /* 203 Store-conditional Code Address at global address
2173 cs procedure name. */
2174 case ETIR__C_STC_GCA
:
2176 /* 204 Store-conditional Address at psect + offset
2180 case ETIR__C_STC_PS
:
2181 _bfd_error_handler (_("%s: not supported"),
2182 _bfd_vms_etir_name (cmd
));
2186 /* 201 Store-conditional Linkage Pair with Procedure Signature
2192 case ETIR__C_STC_LP_PSB
:
2193 _bfd_vms_get_value (abfd
, ptr
+ 4, maxptr
, info
, &op1
, &h
);
2196 if (h
->sym
->typ
== EGSD__C_SYMG
)
2198 alpha_vms_add_fixup_lp (info
, abfd
, h
->sym
->owner
);
2199 op1
= h
->sym
->symbol_vector
;
2204 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
2205 h
->sym
->code_value
);
2206 op2
= alpha_vms_get_sym_value (h
->sym
->section
,
2212 /* Undefined symbol. */
2216 image_write_q (abfd
, op1
);
2217 image_write_q (abfd
, op2
);
2220 /* 205 Store-conditional NOP at address of global
2222 case ETIR__C_STC_NOP_GBL
:
2225 /* 207 Store-conditional BSR at global address
2228 case ETIR__C_STC_BSR_GBL
:
2231 /* 209 Store-conditional LDA at global address
2234 case ETIR__C_STC_LDA_GBL
:
2237 /* 211 Store-conditional BSR or Hint at global address
2240 case ETIR__C_STC_BOH_GBL
:
2241 /* Currentl ignored. */
2244 /* 213 Store-conditional NOP,BSR or HINT at global address
2247 case ETIR__C_STC_NBH_GBL
:
2249 /* 206 Store-conditional NOP at pect + offset
2252 case ETIR__C_STC_NOP_PS
:
2254 /* 208 Store-conditional BSR at pect + offset
2257 case ETIR__C_STC_BSR_PS
:
2259 /* 210 Store-conditional LDA at psect + offset
2262 case ETIR__C_STC_LDA_PS
:
2264 /* 212 Store-conditional BSR or Hint at pect + offset
2267 case ETIR__C_STC_BOH_PS
:
2269 /* 214 Store-conditional NOP, BSR or HINT at psect + offset
2271 case ETIR__C_STC_NBH_PS
:
2272 _bfd_error_handler (_("%s: not supported"),
2273 _bfd_vms_etir_name (cmd
));
2277 /* Det relocation base: pop stack, set image location counter
2279 case ETIR__C_CTL_SETRB
:
2280 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2281 if (!(rel1
& RELC_SEC_BASE
))
2283 image_set_ptr (abfd
, op1
, rel1
& RELC_MASK
, info
);
2286 /* Augment relocation base: increment image location counter by offset
2287 arg: lw offset value. */
2288 case ETIR__C_CTL_AUGRB
:
2289 if (ptr
+ 4 > maxptr
)
2291 op1
= bfd_getl32 (ptr
);
2292 image_inc_ptr (abfd
, op1
);
2295 /* Define location: pop index, save location counter under index
2297 case ETIR__C_CTL_DFLOC
:
2298 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2299 if (rel1
!= RELC_NONE
)
2301 dst_define_location (abfd
, op1
);
2304 /* Set location: pop index, restore location counter from index
2306 case ETIR__C_CTL_STLOC
:
2307 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2308 if (rel1
!= RELC_NONE
)
2310 dst_restore_location (abfd
, op1
);
2313 /* Stack defined location: pop index, push location counter from index
2315 case ETIR__C_CTL_STKDL
:
2316 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2317 if (rel1
!= RELC_NONE
)
2319 _bfd_vms_push (abfd
, dst_retrieve_location (abfd
, op1
), RELC_NONE
);
2322 case ETIR__C_OPR_NOP
: /* No-op. */
2325 case ETIR__C_OPR_ADD
: /* Add. */
2326 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2327 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2328 if (rel1
== RELC_NONE
&& rel2
!= RELC_NONE
)
2330 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2332 _bfd_vms_push (abfd
, op1
+ op2
, rel1
);
2335 case ETIR__C_OPR_SUB
: /* Subtract. */
2336 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2337 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2338 if (rel1
== RELC_NONE
&& rel2
!= RELC_NONE
)
2340 else if ((rel1
& RELC_SEC_BASE
) && (rel2
& RELC_SEC_BASE
))
2342 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2343 op2
= alpha_vms_fix_sec_rel (abfd
, info
, rel2
, op2
);
2346 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2348 _bfd_vms_push (abfd
, op2
- op1
, rel1
);
2351 case ETIR__C_OPR_MUL
: /* Multiply. */
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_DIV
: /* Divide. */
2360 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2361 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2362 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2365 _bfd_vms_push (abfd
, 0, RELC_NONE
);
2367 _bfd_vms_push (abfd
, op2
/ op1
, RELC_NONE
);
2370 case ETIR__C_OPR_AND
: /* Logical AND. */
2371 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2372 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2373 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2375 _bfd_vms_push (abfd
, op1
& op2
, RELC_NONE
);
2378 case ETIR__C_OPR_IOR
: /* Logical inclusive OR. */
2379 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2380 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2381 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2383 _bfd_vms_push (abfd
, op1
| op2
, RELC_NONE
);
2386 case ETIR__C_OPR_EOR
: /* Logical exclusive OR. */
2387 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2388 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2389 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2391 _bfd_vms_push (abfd
, op1
^ op2
, RELC_NONE
);
2394 case ETIR__C_OPR_NEG
: /* Negate. */
2395 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2396 if (rel1
!= RELC_NONE
)
2398 _bfd_vms_push (abfd
, -op1
, RELC_NONE
);
2401 case ETIR__C_OPR_COM
: /* Complement. */
2402 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2403 if (rel1
!= RELC_NONE
)
2405 _bfd_vms_push (abfd
, ~op1
, RELC_NONE
);
2408 case ETIR__C_OPR_ASH
: /* Arithmetic shift. */
2409 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2410 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2411 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2414 _bfd_error_handler (_("invalid use of %s with contexts"),
2415 _bfd_vms_etir_name (cmd
));
2418 if ((int)op2
< 0) /* Shift right. */
2420 else /* Shift left. */
2422 _bfd_vms_push (abfd
, op1
, RELC_NONE
); /* FIXME: sym. */
2425 case ETIR__C_OPR_INSV
: /* Insert field. */
2426 case ETIR__C_OPR_USH
: /* Unsigned shift. */
2427 case ETIR__C_OPR_ROT
: /* Rotate. */
2428 case ETIR__C_OPR_REDEF
: /* Redefine symbol to current location. */
2429 case ETIR__C_OPR_DFLIT
: /* Define a literal. */
2430 _bfd_error_handler (_("%s: not supported"),
2431 _bfd_vms_etir_name (cmd
));
2435 case ETIR__C_OPR_SEL
: /* Select. */
2436 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2438 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2441 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2442 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2443 _bfd_vms_push (abfd
, op1
, rel1
);
2448 _bfd_error_handler (_("reserved cmd %d"), cmd
);
2453 ptr
+= cmd_length
- 4;
2459 /* Process EDBG/ETBT record.
2460 Return TRUE on success, FALSE on error */
2463 vms_slurp_debug (bfd
*abfd
)
2465 asection
*section
= PRIV (dst_section
);
2467 if (section
== NULL
)
2469 /* We have no way to find out beforehand how much debug info there
2470 is in an object file, so pick an initial amount and grow it as
2472 flagword flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
| SEC_RELOC
2475 section
= bfd_make_section (abfd
, "$DST$");
2478 if (!bfd_set_section_flags (section
, flags
))
2480 PRIV (dst_section
) = section
;
2483 PRIV (image_section
) = section
;
2484 PRIV (image_offset
) = section
->size
;
2486 if (!_bfd_vms_slurp_etir (abfd
, NULL
))
2489 section
->size
= PRIV (image_offset
);
2493 /* Process EDBG record.
2494 Return TRUE on success, FALSE on error. */
2497 _bfd_vms_slurp_edbg (bfd
*abfd
)
2499 vms_debug2 ((2, "EDBG\n"));
2501 abfd
->flags
|= HAS_DEBUG
| HAS_LINENO
;
2503 return vms_slurp_debug (abfd
);
2506 /* Process ETBT record.
2507 Return TRUE on success, FALSE on error. */
2510 _bfd_vms_slurp_etbt (bfd
*abfd
)
2512 vms_debug2 ((2, "ETBT\n"));
2514 abfd
->flags
|= HAS_LINENO
;
2516 return vms_slurp_debug (abfd
);
2519 /* Process EEOM record.
2520 Return TRUE on success, FALSE on error. */
2523 _bfd_vms_slurp_eeom (bfd
*abfd
)
2525 struct vms_eeom
*eeom
= (struct vms_eeom
*) PRIV (recrd
.rec
);
2527 vms_debug2 ((2, "EEOM\n"));
2529 /* PR 21813: Check for an undersized record. */
2530 if (PRIV (recrd
.buf_size
) < sizeof (* eeom
))
2532 _bfd_error_handler (_("corrupt EEOM record - size is too small"));
2533 bfd_set_error (bfd_error_bad_value
);
2537 PRIV (eom_data
).eom_l_total_lps
= bfd_getl32 (eeom
->total_lps
);
2538 PRIV (eom_data
).eom_w_comcod
= bfd_getl16 (eeom
->comcod
);
2539 if (PRIV (eom_data
).eom_w_comcod
> 1)
2541 _bfd_error_handler (_("object module not error-free !"));
2542 bfd_set_error (bfd_error_bad_value
);
2546 PRIV (eom_data
).eom_has_transfer
= FALSE
;
2547 if (PRIV (recrd
.rec_size
) > 10)
2549 PRIV (eom_data
).eom_has_transfer
= TRUE
;
2550 PRIV (eom_data
).eom_b_tfrflg
= eeom
->tfrflg
;
2551 PRIV (eom_data
).eom_l_psindx
= bfd_getl32 (eeom
->psindx
);
2552 PRIV (eom_data
).eom_l_tfradr
= bfd_getl32 (eeom
->tfradr
);
2554 abfd
->start_address
= PRIV (eom_data
).eom_l_tfradr
;
2559 /* Slurp an ordered set of VMS object records. Return FALSE on error. */
2562 _bfd_vms_slurp_object_records (bfd
* abfd
)
2569 vms_debug2 ((7, "reading at %08lx\n", (unsigned long)bfd_tell (abfd
)));
2571 type
= _bfd_vms_get_object_record (abfd
);
2574 vms_debug2 ((2, "next_record failed\n"));
2581 err
= _bfd_vms_slurp_ehdr (abfd
);
2584 err
= _bfd_vms_slurp_eeom (abfd
);
2587 err
= _bfd_vms_slurp_egsd (abfd
);
2590 err
= TRUE
; /* _bfd_vms_slurp_etir (abfd); */
2593 err
= _bfd_vms_slurp_edbg (abfd
);
2596 err
= _bfd_vms_slurp_etbt (abfd
);
2603 vms_debug2 ((2, "slurp type %d failed\n", type
));
2607 while (type
!= EOBJ__C_EEOM
);
2612 /* Initialize private data */
2614 vms_initialize (bfd
* abfd
)
2618 amt
= sizeof (struct vms_private_data_struct
);
2619 abfd
->tdata
.any
= bfd_zalloc (abfd
, amt
);
2620 if (abfd
->tdata
.any
== NULL
)
2623 PRIV (recrd
.file_format
) = FF_UNKNOWN
;
2625 amt
= sizeof (struct stack_struct
) * STACKSIZE
;
2626 PRIV (stack
) = bfd_alloc (abfd
, amt
);
2627 if (PRIV (stack
) == NULL
)
2633 bfd_release (abfd
, abfd
->tdata
.any
);
2634 abfd
->tdata
.any
= NULL
;
2638 /* Check the format for a file being read.
2639 Return a (bfd_target *) if it's an object file or zero if not. */
2641 static const struct bfd_target
*
2642 alpha_vms_object_p (bfd
*abfd
)
2644 void *tdata_save
= abfd
->tdata
.any
;
2645 unsigned int test_len
;
2648 vms_debug2 ((1, "vms_object_p(%p)\n", abfd
));
2650 /* Allocate alpha-vms specific data. */
2651 if (!vms_initialize (abfd
))
2654 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
))
2655 goto err_wrong_format
;
2657 /* The first challenge with VMS is to discover the kind of the file.
2659 Image files (executable or shared images) are stored as a raw
2660 stream of bytes (like on UNIX), but there is no magic number.
2662 Object files are written with RMS (record management service), ie
2663 each records are preceeded by its length (on a word - 2 bytes), and
2664 padded for word-alignment. That would be simple but when files
2665 are transfered to a UNIX filesystem (using ftp), records are lost.
2666 Only the raw content of the records are transfered. Fortunately,
2667 the Alpha Object file format also store the length of the record
2668 in the records. Is that clear ? */
2670 /* Minimum is 6 bytes for objects (2 bytes size, 2 bytes record id,
2671 2 bytes size repeated) and 12 bytes for images (4 bytes major id,
2672 4 bytes minor id, 4 bytes length). */
2675 /* Size the main buffer. */
2676 buf
= (unsigned char *) bfd_malloc (test_len
);
2679 PRIV (recrd
.buf
) = buf
;
2680 PRIV (recrd
.buf_size
) = test_len
;
2682 /* Initialize the record pointer. */
2683 PRIV (recrd
.rec
) = buf
;
2685 if (bfd_bread (buf
, test_len
, abfd
) != test_len
)
2686 goto err_wrong_format
;
2688 /* Is it an image? */
2689 if ((bfd_getl32 (buf
) == EIHD__K_MAJORID
)
2690 && (bfd_getl32 (buf
+ 4) == EIHD__K_MINORID
))
2692 unsigned int to_read
;
2693 unsigned int read_so_far
;
2694 unsigned int remaining
;
2695 unsigned int eisd_offset
, eihs_offset
;
2697 /* Extract the header size. */
2698 PRIV (recrd
.rec_size
) = bfd_getl32 (buf
+ EIHD__L_SIZE
);
2700 /* The header size is 0 for DSF files. */
2701 if (PRIV (recrd
.rec_size
) == 0)
2702 PRIV (recrd
.rec_size
) = sizeof (struct vms_eihd
);
2704 if (PRIV (recrd
.rec_size
) > PRIV (recrd
.buf_size
))
2706 buf
= bfd_realloc_or_free (buf
, PRIV (recrd
.rec_size
));
2710 PRIV (recrd
.buf
) = NULL
;
2713 PRIV (recrd
.buf
) = buf
;
2714 PRIV (recrd
.buf_size
) = PRIV (recrd
.rec_size
);
2717 /* PR 21813: Check for a truncated record. */
2718 if (PRIV (recrd
.rec_size
< test_len
))
2720 /* Read the remaining record. */
2721 remaining
= PRIV (recrd
.rec_size
) - test_len
;
2722 to_read
= MIN (VMS_BLOCK_SIZE
- test_len
, remaining
);
2723 read_so_far
= test_len
;
2725 while (remaining
> 0)
2727 if (bfd_bread (buf
+ read_so_far
, to_read
, abfd
) != to_read
)
2728 goto err_wrong_format
;
2730 read_so_far
+= to_read
;
2731 remaining
-= to_read
;
2733 to_read
= MIN (VMS_BLOCK_SIZE
, remaining
);
2736 /* Reset the record pointer. */
2737 PRIV (recrd
.rec
) = buf
;
2739 /* PR 17512: file: 7d7c57c2. */
2740 if (PRIV (recrd
.rec_size
) < sizeof (struct vms_eihd
))
2742 vms_debug2 ((2, "file type is image\n"));
2744 if (!_bfd_vms_slurp_eihd (abfd
, &eisd_offset
, &eihs_offset
))
2745 goto err_wrong_format
;
2747 if (!_bfd_vms_slurp_eisd (abfd
, eisd_offset
))
2748 goto err_wrong_format
;
2750 /* EIHS is optional. */
2751 if (eihs_offset
!= 0 && !_bfd_vms_slurp_eihs (abfd
, eihs_offset
))
2752 goto err_wrong_format
;
2758 /* Assume it's a module and adjust record pointer if necessary. */
2759 maybe_adjust_record_pointer_for_object (abfd
);
2761 /* But is it really a module? */
2762 if (bfd_getl16 (PRIV (recrd
.rec
)) <= EOBJ__C_MAXRECTYP
2763 && bfd_getl16 (PRIV (recrd
.rec
) + 2) <= EOBJ__C_MAXRECSIZ
)
2765 if (vms_get_remaining_object_record (abfd
, test_len
) <= 0)
2766 goto err_wrong_format
;
2768 vms_debug2 ((2, "file type is module\n"));
2770 type
= bfd_getl16 (PRIV (recrd
.rec
));
2771 if (type
!= EOBJ__C_EMH
|| !_bfd_vms_slurp_ehdr (abfd
))
2772 goto err_wrong_format
;
2774 if (!_bfd_vms_slurp_object_records (abfd
))
2775 goto err_wrong_format
;
2778 goto err_wrong_format
;
2781 /* Set arch_info to alpha. */
2783 if (! bfd_default_set_arch_mach (abfd
, bfd_arch_alpha
, 0))
2784 goto err_wrong_format
;
2789 bfd_set_error (bfd_error_wrong_format
);
2792 if (PRIV (recrd
.buf
))
2793 free (PRIV (recrd
.buf
));
2794 if (abfd
->tdata
.any
!= tdata_save
&& abfd
->tdata
.any
!= NULL
)
2795 bfd_release (abfd
, abfd
->tdata
.any
);
2796 abfd
->tdata
.any
= tdata_save
;
2802 /* Write an EMH/MHD record. */
2805 _bfd_vms_write_emh (bfd
*abfd
)
2807 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2809 _bfd_vms_output_alignment (recwr
, 2);
2812 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
2813 _bfd_vms_output_short (recwr
, EMH__C_MHD
);
2814 _bfd_vms_output_short (recwr
, EOBJ__C_STRLVL
);
2815 _bfd_vms_output_long (recwr
, 0);
2816 _bfd_vms_output_long (recwr
, 0);
2817 _bfd_vms_output_long (recwr
, MAX_OUTREC_SIZE
);
2819 /* Create module name from filename. */
2820 if (bfd_get_filename (abfd
) != 0)
2822 char *module
= vms_get_module_name (bfd_get_filename (abfd
), TRUE
);
2823 _bfd_vms_output_counted (recwr
, module
);
2827 _bfd_vms_output_counted (recwr
, "NONAME");
2829 _bfd_vms_output_counted (recwr
, BFD_VERSION_STRING
);
2830 _bfd_vms_output_dump (recwr
, get_vms_time_string (), EMH_DATE_LENGTH
);
2831 _bfd_vms_output_fill (recwr
, 0, EMH_DATE_LENGTH
);
2832 _bfd_vms_output_end (abfd
, recwr
);
2835 /* Write an EMH/LMN record. */
2838 _bfd_vms_write_lmn (bfd
*abfd
, const char *name
)
2841 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2842 unsigned int ver
= BFD_VERSION
/ 10000;
2845 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
2846 _bfd_vms_output_short (recwr
, EMH__C_LNM
);
2847 snprintf (version
, sizeof (version
), "%s %d.%d.%d", name
,
2848 ver
/ 10000, (ver
/ 100) % 100, ver
% 100);
2849 _bfd_vms_output_dump (recwr
, (unsigned char *)version
, strlen (version
));
2850 _bfd_vms_output_end (abfd
, recwr
);
2854 /* Write eom record for bfd abfd. Return FALSE on error. */
2857 _bfd_vms_write_eeom (bfd
*abfd
)
2859 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2861 vms_debug2 ((2, "vms_write_eeom\n"));
2863 _bfd_vms_output_alignment (recwr
, 2);
2865 _bfd_vms_output_begin (recwr
, EOBJ__C_EEOM
);
2866 _bfd_vms_output_long (recwr
, PRIV (vms_linkage_index
+ 1) >> 1);
2867 _bfd_vms_output_byte (recwr
, 0); /* Completion code. */
2868 _bfd_vms_output_byte (recwr
, 0); /* Fill byte. */
2870 if ((abfd
->flags
& EXEC_P
) == 0
2871 && bfd_get_start_address (abfd
) != (bfd_vma
)-1)
2875 section
= bfd_get_section_by_name (abfd
, ".link");
2878 bfd_set_error (bfd_error_nonrepresentable_section
);
2881 _bfd_vms_output_short (recwr
, 0);
2882 _bfd_vms_output_long (recwr
, (unsigned long) section
->target_index
);
2883 _bfd_vms_output_long (recwr
,
2884 (unsigned long) bfd_get_start_address (abfd
));
2885 _bfd_vms_output_long (recwr
, 0);
2888 _bfd_vms_output_end (abfd
, recwr
);
2893 vector_grow1 (struct vector_type
*vec
, size_t elsz
)
2895 if (vec
->nbr_el
+ 1 < vec
->max_el
)
2898 if (vec
->max_el
== 0)
2901 vec
->els
= bfd_malloc2 (vec
->max_el
, elsz
);
2906 vec
->els
= bfd_realloc2 (vec
->els
, vec
->max_el
, elsz
);
2910 /* Bump ABFD file position to next block. */
2913 alpha_vms_file_position_block (bfd
*abfd
)
2916 PRIV (file_pos
) += VMS_BLOCK_SIZE
- 1;
2917 PRIV (file_pos
) -= (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
2920 /* Convert from internal structure SRC to external structure DST. */
2923 alpha_vms_swap_eisd_out (struct vms_internal_eisd_map
*src
,
2924 struct vms_eisd
*dst
)
2926 bfd_putl32 (src
->u
.eisd
.majorid
, dst
->majorid
);
2927 bfd_putl32 (src
->u
.eisd
.minorid
, dst
->minorid
);
2928 bfd_putl32 (src
->u
.eisd
.eisdsize
, dst
->eisdsize
);
2929 if (src
->u
.eisd
.eisdsize
<= EISD__K_LENEND
)
2931 bfd_putl32 (src
->u
.eisd
.secsize
, dst
->secsize
);
2932 bfd_putl64 (src
->u
.eisd
.virt_addr
, dst
->virt_addr
);
2933 bfd_putl32 (src
->u
.eisd
.flags
, dst
->flags
);
2934 bfd_putl32 (src
->u
.eisd
.vbn
, dst
->vbn
);
2935 dst
->pfc
= src
->u
.eisd
.pfc
;
2936 dst
->matchctl
= src
->u
.eisd
.matchctl
;
2937 dst
->type
= src
->u
.eisd
.type
;
2939 if (src
->u
.eisd
.flags
& EISD__M_GBL
)
2941 bfd_putl32 (src
->u
.gbl_eisd
.ident
, dst
->ident
);
2942 memcpy (dst
->gblnam
, src
->u
.gbl_eisd
.gblnam
,
2943 src
->u
.gbl_eisd
.gblnam
[0] + 1);
2947 /* Append EISD to the list of extra eisd for ABFD. */
2950 alpha_vms_append_extra_eisd (bfd
*abfd
, struct vms_internal_eisd_map
*eisd
)
2953 if (PRIV (gbl_eisd_head
) == NULL
)
2954 PRIV (gbl_eisd_head
) = eisd
;
2956 PRIV (gbl_eisd_tail
)->next
= eisd
;
2957 PRIV (gbl_eisd_tail
) = eisd
;
2960 /* Create an EISD for shared image SHRIMG.
2961 Return FALSE in case of error. */
2964 alpha_vms_create_eisd_for_shared (bfd
*abfd
, bfd
*shrimg
)
2966 struct vms_internal_eisd_map
*eisd
;
2969 namlen
= strlen (PRIV2 (shrimg
, hdr_data
.hdr_t_name
));
2970 if (namlen
+ 5 > EISD__K_GBLNAMLEN
)
2976 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
2980 /* Fill the fields. */
2981 eisd
->u
.gbl_eisd
.common
.majorid
= EISD__K_MAJORID
;
2982 eisd
->u
.gbl_eisd
.common
.minorid
= EISD__K_MINORID
;
2983 eisd
->u
.gbl_eisd
.common
.eisdsize
= (EISD__K_LEN
+ 4 + namlen
+ 5 + 3) & ~3;
2984 eisd
->u
.gbl_eisd
.common
.secsize
= VMS_BLOCK_SIZE
; /* Must not be 0. */
2985 eisd
->u
.gbl_eisd
.common
.virt_addr
= 0;
2986 eisd
->u
.gbl_eisd
.common
.flags
= EISD__M_GBL
;
2987 eisd
->u
.gbl_eisd
.common
.vbn
= 0;
2988 eisd
->u
.gbl_eisd
.common
.pfc
= 0;
2989 eisd
->u
.gbl_eisd
.common
.matchctl
= PRIV2 (shrimg
, matchctl
);
2990 eisd
->u
.gbl_eisd
.common
.type
= EISD__K_SHRPIC
;
2992 eisd
->u
.gbl_eisd
.ident
= PRIV2 (shrimg
, ident
);
2993 eisd
->u
.gbl_eisd
.gblnam
[0] = namlen
+ 4;
2994 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1, PRIV2 (shrimg
, hdr_data
.hdr_t_name
),
2996 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1 + namlen
, "_001", 4);
2998 /* Append it to the list. */
2999 alpha_vms_append_extra_eisd (abfd
, eisd
);
3004 /* Create an EISD for section SEC.
3005 Return FALSE in case of failure. */
3008 alpha_vms_create_eisd_for_section (bfd
*abfd
, asection
*sec
)
3010 struct vms_internal_eisd_map
*eisd
;
3012 /* Only for allocating section. */
3013 if (!(sec
->flags
& SEC_ALLOC
))
3016 BFD_ASSERT (vms_section_data (sec
)->eisd
== NULL
);
3017 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
3020 vms_section_data (sec
)->eisd
= eisd
;
3022 /* Fill the fields. */
3023 eisd
->u
.eisd
.majorid
= EISD__K_MAJORID
;
3024 eisd
->u
.eisd
.minorid
= EISD__K_MINORID
;
3025 eisd
->u
.eisd
.eisdsize
= EISD__K_LEN
;
3026 eisd
->u
.eisd
.secsize
=
3027 (sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
3028 eisd
->u
.eisd
.virt_addr
= sec
->vma
;
3029 eisd
->u
.eisd
.flags
= 0;
3030 eisd
->u
.eisd
.vbn
= 0; /* To be later defined. */
3031 eisd
->u
.eisd
.pfc
= 0; /* Default. */
3032 eisd
->u
.eisd
.matchctl
= EISD__K_MATALL
;
3033 eisd
->u
.eisd
.type
= EISD__K_NORMAL
;
3035 if (sec
->flags
& SEC_CODE
)
3036 eisd
->u
.eisd
.flags
|= EISD__M_EXE
;
3037 if (!(sec
->flags
& SEC_READONLY
))
3038 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
3040 /* If relocations or fixup will be applied, make this isect writeable. */
3041 if (sec
->flags
& SEC_RELOC
)
3042 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
3044 if (!(sec
->flags
& SEC_HAS_CONTENTS
))
3046 eisd
->u
.eisd
.flags
|= EISD__M_DZRO
;
3047 eisd
->u
.eisd
.flags
&= ~EISD__M_CRF
;
3049 if (sec
->flags
& SEC_LINKER_CREATED
)
3051 if (strcmp (sec
->name
, "$FIXUP$") == 0)
3052 eisd
->u
.eisd
.flags
|= EISD__M_FIXUPVEC
;
3055 /* Append it to the list. */
3057 if (PRIV (eisd_head
) == NULL
)
3058 PRIV (eisd_head
) = eisd
;
3060 PRIV (eisd_tail
)->next
= eisd
;
3061 PRIV (eisd_tail
) = eisd
;
3066 /* Layout executable ABFD and write it to the disk.
3067 Return FALSE in case of failure. */
3070 alpha_vms_write_exec (bfd
*abfd
)
3072 struct vms_eihd eihd
;
3073 struct vms_eiha
*eiha
;
3074 struct vms_eihi
*eihi
;
3075 struct vms_eihs
*eihs
= NULL
;
3077 struct vms_internal_eisd_map
*first_eisd
;
3078 struct vms_internal_eisd_map
*eisd
;
3081 file_ptr gst_filepos
= 0;
3082 unsigned int lnkflags
= 0;
3084 /* Build the EIHD. */
3085 PRIV (file_pos
) = EIHD__C_LENGTH
;
3087 memset (&eihd
, 0, sizeof (eihd
));
3088 memset (eihd
.fill_2
, 0xff, sizeof (eihd
.fill_2
));
3090 bfd_putl32 (EIHD__K_MAJORID
, eihd
.majorid
);
3091 bfd_putl32 (EIHD__K_MINORID
, eihd
.minorid
);
3093 bfd_putl32 (sizeof (eihd
), eihd
.size
);
3094 bfd_putl32 (0, eihd
.isdoff
);
3095 bfd_putl32 (0, eihd
.activoff
);
3096 bfd_putl32 (0, eihd
.symdbgoff
);
3097 bfd_putl32 (0, eihd
.imgidoff
);
3098 bfd_putl32 (0, eihd
.patchoff
);
3099 bfd_putl64 (0, eihd
.iafva
);
3100 bfd_putl32 (0, eihd
.version_array_off
);
3102 bfd_putl32 (EIHD__K_EXE
, eihd
.imgtype
);
3103 bfd_putl32 (0, eihd
.subtype
);
3105 bfd_putl32 (0, eihd
.imgiocnt
);
3106 bfd_putl32 (-1, eihd
.privreqs
);
3107 bfd_putl32 (-1, eihd
.privreqs
+ 4);
3109 bfd_putl32 ((sizeof (eihd
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
3111 bfd_putl32 (0, eihd
.ident
);
3112 bfd_putl32 (0, eihd
.sysver
);
3115 bfd_putl32 (0, eihd
.symvect_size
);
3116 bfd_putl32 (16, eihd
.virt_mem_block_size
);
3117 bfd_putl32 (0, eihd
.ext_fixup_off
);
3118 bfd_putl32 (0, eihd
.noopt_psect_off
);
3119 bfd_putl32 (-1, eihd
.alias
);
3122 eiha
= (struct vms_eiha
*)((char *) &eihd
+ PRIV (file_pos
));
3123 bfd_putl32 (PRIV (file_pos
), eihd
.activoff
);
3124 PRIV (file_pos
) += sizeof (struct vms_eiha
);
3126 bfd_putl32 (sizeof (struct vms_eiha
), eiha
->size
);
3127 bfd_putl32 (0, eiha
->spare
);
3128 bfd_putl64 (PRIV (transfer_address
[0]), eiha
->tfradr1
);
3129 bfd_putl64 (PRIV (transfer_address
[1]), eiha
->tfradr2
);
3130 bfd_putl64 (PRIV (transfer_address
[2]), eiha
->tfradr3
);
3131 bfd_putl64 (PRIV (transfer_address
[3]), eiha
->tfradr4
);
3132 bfd_putl64 (0, eiha
->inishr
);
3135 eihi
= (struct vms_eihi
*)((char *) &eihd
+ PRIV (file_pos
));
3136 bfd_putl32 (PRIV (file_pos
), eihd
.imgidoff
);
3137 PRIV (file_pos
) += sizeof (struct vms_eihi
);
3139 bfd_putl32 (EIHI__K_MAJORID
, eihi
->majorid
);
3140 bfd_putl32 (EIHI__K_MINORID
, eihi
->minorid
);
3145 /* Set module name. */
3146 module
= vms_get_module_name (bfd_get_filename (abfd
), TRUE
);
3147 len
= strlen (module
);
3148 if (len
> sizeof (eihi
->imgnam
) - 1)
3149 len
= sizeof (eihi
->imgnam
) - 1;
3150 eihi
->imgnam
[0] = len
;
3151 memcpy (eihi
->imgnam
+ 1, module
, len
);
3159 vms_get_time (&hi
, &lo
);
3160 bfd_putl32 (lo
, eihi
->linktime
+ 0);
3161 bfd_putl32 (hi
, eihi
->linktime
+ 4);
3164 eihi
->linkid
[0] = 0;
3165 eihi
->imgbid
[0] = 0;
3168 dst
= PRIV (dst_section
);
3169 dmt
= bfd_get_section_by_name (abfd
, "$DMT$");
3170 if (dst
!= NULL
&& dst
->size
!= 0)
3172 eihs
= (struct vms_eihs
*)((char *) &eihd
+ PRIV (file_pos
));
3173 bfd_putl32 (PRIV (file_pos
), eihd
.symdbgoff
);
3174 PRIV (file_pos
) += sizeof (struct vms_eihs
);
3176 bfd_putl32 (EIHS__K_MAJORID
, eihs
->majorid
);
3177 bfd_putl32 (EIHS__K_MINORID
, eihs
->minorid
);
3178 bfd_putl32 (0, eihs
->dstvbn
);
3179 bfd_putl32 (0, eihs
->dstsize
);
3180 bfd_putl32 (0, eihs
->gstvbn
);
3181 bfd_putl32 (0, eihs
->gstsize
);
3182 bfd_putl32 (0, eihs
->dmtvbn
);
3183 bfd_putl32 (0, eihs
->dmtsize
);
3186 /* One EISD per section. */
3187 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3189 if (!alpha_vms_create_eisd_for_section (abfd
, sec
))
3193 /* Merge section EIDS which extra ones. */
3194 if (PRIV (eisd_tail
))
3195 PRIV (eisd_tail
)->next
= PRIV (gbl_eisd_head
);
3197 PRIV (eisd_head
) = PRIV (gbl_eisd_head
);
3198 if (PRIV (gbl_eisd_tail
))
3199 PRIV (eisd_tail
) = PRIV (gbl_eisd_tail
);
3201 first_eisd
= PRIV (eisd_head
);
3203 /* Add end of eisd. */
3206 eisd
= bfd_zalloc (abfd
, sizeof (*eisd
));
3209 eisd
->u
.eisd
.majorid
= 0;
3210 eisd
->u
.eisd
.minorid
= 0;
3211 eisd
->u
.eisd
.eisdsize
= 0;
3212 alpha_vms_append_extra_eisd (abfd
, eisd
);
3215 /* Place EISD in the file. */
3216 for (eisd
= first_eisd
; eisd
; eisd
= eisd
->next
)
3218 file_ptr room
= VMS_BLOCK_SIZE
- (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
3220 /* First block is a little bit special: there is a word at the end. */
3221 if (PRIV (file_pos
) < VMS_BLOCK_SIZE
&& room
> 2)
3223 if (room
< eisd
->u
.eisd
.eisdsize
+ EISD__K_LENEND
)
3224 alpha_vms_file_position_block (abfd
);
3226 eisd
->file_pos
= PRIV (file_pos
);
3227 PRIV (file_pos
) += eisd
->u
.eisd
.eisdsize
;
3229 if (eisd
->u
.eisd
.flags
& EISD__M_FIXUPVEC
)
3230 bfd_putl64 (eisd
->u
.eisd
.virt_addr
, eihd
.iafva
);
3233 if (first_eisd
!= NULL
)
3235 bfd_putl32 (first_eisd
->file_pos
, eihd
.isdoff
);
3236 /* Real size of end of eisd marker. */
3237 PRIV (file_pos
) += EISD__K_LENEND
;
3240 bfd_putl32 (PRIV (file_pos
), eihd
.size
);
3241 bfd_putl32 ((PRIV (file_pos
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
3244 /* Place sections. */
3245 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3247 if (!(sec
->flags
& SEC_HAS_CONTENTS
))
3250 eisd
= vms_section_data (sec
)->eisd
;
3252 /* Align on a block. */
3253 alpha_vms_file_position_block (abfd
);
3254 sec
->filepos
= PRIV (file_pos
);
3257 eisd
->u
.eisd
.vbn
= (sec
->filepos
/ VMS_BLOCK_SIZE
) + 1;
3259 PRIV (file_pos
) += sec
->size
;
3263 if (eihs
!= NULL
&& dst
!= NULL
)
3265 bfd_putl32 ((dst
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dstvbn
);
3266 bfd_putl32 (dst
->size
, eihs
->dstsize
);
3270 lnkflags
|= EIHD__M_DBGDMT
;
3271 bfd_putl32 ((dmt
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dmtvbn
);
3272 bfd_putl32 (dmt
->size
, eihs
->dmtsize
);
3274 if (PRIV (gsd_sym_count
) != 0)
3276 alpha_vms_file_position_block (abfd
);
3277 gst_filepos
= PRIV (file_pos
);
3278 bfd_putl32 ((gst_filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->gstvbn
);
3279 bfd_putl32 ((PRIV (gsd_sym_count
) + 4) / 5 + 4, eihs
->gstsize
);
3283 /* Write EISD in hdr. */
3284 for (eisd
= first_eisd
; eisd
&& eisd
->file_pos
< VMS_BLOCK_SIZE
;
3286 alpha_vms_swap_eisd_out
3287 (eisd
, (struct vms_eisd
*)((char *)&eihd
+ eisd
->file_pos
));
3289 /* Write first block. */
3290 bfd_putl32 (lnkflags
, eihd
.lnkflags
);
3291 if (bfd_bwrite (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
3294 /* Write remaining eisd. */
3297 unsigned char blk
[VMS_BLOCK_SIZE
];
3298 struct vms_internal_eisd_map
*next_eisd
;
3300 memset (blk
, 0xff, sizeof (blk
));
3301 while (eisd
!= NULL
)
3303 alpha_vms_swap_eisd_out
3305 (struct vms_eisd
*)(blk
+ (eisd
->file_pos
% VMS_BLOCK_SIZE
)));
3307 next_eisd
= eisd
->next
;
3308 if (next_eisd
== NULL
3309 || (next_eisd
->file_pos
/ VMS_BLOCK_SIZE
3310 != eisd
->file_pos
/ VMS_BLOCK_SIZE
))
3312 if (bfd_bwrite (blk
, sizeof (blk
), abfd
) != sizeof (blk
))
3315 memset (blk
, 0xff, sizeof (blk
));
3321 /* Write sections. */
3322 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3324 unsigned char blk
[VMS_BLOCK_SIZE
];
3327 if (sec
->size
== 0 || !(sec
->flags
& SEC_HAS_CONTENTS
))
3329 if (bfd_bwrite (sec
->contents
, sec
->size
, abfd
) != sec
->size
)
3333 len
= VMS_BLOCK_SIZE
- sec
->size
% VMS_BLOCK_SIZE
;
3334 if (len
!= VMS_BLOCK_SIZE
)
3336 memset (blk
, 0, len
);
3337 if (bfd_bwrite (blk
, len
, abfd
) != len
)
3343 if (gst_filepos
!= 0)
3345 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3348 _bfd_vms_write_emh (abfd
);
3349 _bfd_vms_write_lmn (abfd
, "GNU LD");
3351 /* PSC for the absolute section. */
3352 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3353 _bfd_vms_output_long (recwr
, 0);
3354 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3355 _bfd_vms_output_short (recwr
, 0);
3356 _bfd_vms_output_short (recwr
, EGPS__V_PIC
| EGPS__V_LIB
| EGPS__V_RD
);
3357 _bfd_vms_output_long (recwr
, 0);
3358 _bfd_vms_output_counted (recwr
, ".$$ABS$$.");
3359 _bfd_vms_output_end_subrec (recwr
);
3360 _bfd_vms_output_end (abfd
, recwr
);
3362 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
3364 struct vms_symbol_entry
*sym
= PRIV (syms
)[i
];
3370 _bfd_vms_output_alignment (recwr
, 8);
3371 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3372 _bfd_vms_output_long (recwr
, 0);
3374 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYMG
);
3375 _bfd_vms_output_short (recwr
, 0); /* Data type, alignment. */
3376 _bfd_vms_output_short (recwr
, sym
->flags
);
3378 if (sym
->code_section
)
3379 ep
= alpha_vms_get_sym_value (sym
->code_section
, sym
->code_value
);
3382 BFD_ASSERT (sym
->code_value
== 0);
3385 val
= alpha_vms_get_sym_value (sym
->section
, sym
->value
);
3386 _bfd_vms_output_quad
3387 (recwr
, sym
->typ
== EGSD__C_SYMG
? sym
->symbol_vector
: val
);
3388 _bfd_vms_output_quad (recwr
, ep
);
3389 _bfd_vms_output_quad (recwr
, val
);
3390 _bfd_vms_output_long (recwr
, 0);
3391 _bfd_vms_output_counted (recwr
, sym
->name
);
3392 _bfd_vms_output_end_subrec (recwr
);
3394 _bfd_vms_output_end (abfd
, recwr
);
3397 _bfd_vms_output_end (abfd
, recwr
);
3399 if (!_bfd_vms_write_eeom (abfd
))
3407 /* Write section and symbol directory of bfd abfd. Return FALSE on error. */
3410 _bfd_vms_write_egsd (bfd
*abfd
)
3414 unsigned int symnum
;
3416 flagword new_flags
, old_flags
;
3417 int abs_section_index
= -1;
3418 unsigned int target_index
= 0;
3419 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3421 vms_debug2 ((2, "vms_write_egsd\n"));
3423 /* Egsd is quadword aligned. */
3424 _bfd_vms_output_alignment (recwr
, 8);
3426 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3427 _bfd_vms_output_long (recwr
, 0);
3429 /* Number sections. */
3430 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3432 if (section
->flags
& SEC_DEBUGGING
)
3434 if (!strcmp (section
->name
, ".vmsdebug"))
3436 section
->flags
|= SEC_DEBUGGING
;
3439 section
->target_index
= target_index
++;
3442 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3444 vms_debug2 ((3, "Section #%d %s, %d bytes\n",
3445 section
->target_index
, section
->name
, (int)section
->size
));
3447 /* Don't write out the VMS debug info section since it is in the
3448 ETBT and EDBG sections in etir. */
3449 if (section
->flags
& SEC_DEBUGGING
)
3452 /* 13 bytes egsd, max 31 chars name -> should be 44 bytes. */
3453 if (_bfd_vms_output_check (recwr
, 64) < 0)
3455 _bfd_vms_output_end (abfd
, recwr
);
3456 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3457 _bfd_vms_output_long (recwr
, 0);
3460 /* Don't know if this is necessary for the linker but for now it keeps
3461 vms_slurp_gsd happy. */
3462 sname
= section
->name
;
3465 /* Remove leading dot. */
3467 if ((*sname
== 't') && (strcmp (sname
, "text") == 0))
3468 sname
= EVAX_CODE_NAME
;
3469 else if ((*sname
== 'd') && (strcmp (sname
, "data") == 0))
3470 sname
= EVAX_DATA_NAME
;
3471 else if ((*sname
== 'b') && (strcmp (sname
, "bss") == 0))
3472 sname
= EVAX_BSS_NAME
;
3473 else if ((*sname
== 'l') && (strcmp (sname
, "link") == 0))
3474 sname
= EVAX_LINK_NAME
;
3475 else if ((*sname
== 'r') && (strcmp (sname
, "rdata") == 0))
3476 sname
= EVAX_READONLY_NAME
;
3477 else if ((*sname
== 'l') && (strcmp (sname
, "literal") == 0))
3478 sname
= EVAX_LITERAL_NAME
;
3479 else if ((*sname
== 'l') && (strcmp (sname
, "literals") == 0))
3480 sname
= EVAX_LITERALS_NAME
;
3481 else if ((*sname
== 'c') && (strcmp (sname
, "comm") == 0))
3482 sname
= EVAX_COMMON_NAME
;
3483 else if ((*sname
== 'l') && (strcmp (sname
, "lcomm") == 0))
3484 sname
= EVAX_LOCAL_NAME
;
3487 if (bfd_is_com_section (section
))
3488 new_flags
= (EGPS__V_OVR
| EGPS__V_REL
| EGPS__V_GBL
| EGPS__V_RD
3489 | EGPS__V_WRT
| EGPS__V_NOMOD
| EGPS__V_COM
);
3491 new_flags
= vms_esecflag_by_name (evax_section_flags
, sname
,
3494 /* Modify them as directed. */
3495 if (section
->flags
& SEC_READONLY
)
3496 new_flags
&= ~EGPS__V_WRT
;
3498 new_flags
&= ~vms_section_data (section
)->no_flags
;
3499 new_flags
|= vms_section_data (section
)->flags
;
3501 vms_debug2 ((3, "sec flags %x\n", section
->flags
));
3502 vms_debug2 ((3, "new_flags %x, _raw_size %lu\n",
3503 new_flags
, (unsigned long)section
->size
));
3505 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3506 _bfd_vms_output_short (recwr
, section
->alignment_power
& 0xff);
3507 _bfd_vms_output_short (recwr
, new_flags
);
3508 _bfd_vms_output_long (recwr
, (unsigned long) section
->size
);
3509 _bfd_vms_output_counted (recwr
, sname
);
3510 _bfd_vms_output_end_subrec (recwr
);
3512 /* If the section is an obsolute one, remind its index as it will be
3513 used later for absolute symbols. */
3514 if ((new_flags
& EGPS__V_REL
) == 0 && abs_section_index
< 0)
3515 abs_section_index
= section
->target_index
;
3518 /* Output symbols. */
3519 vms_debug2 ((3, "%d symbols found\n", abfd
->symcount
));
3521 bfd_set_start_address (abfd
, (bfd_vma
) -1);
3523 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3525 symbol
= abfd
->outsymbols
[symnum
];
3526 old_flags
= symbol
->flags
;
3528 /* Work-around a missing feature: consider __main as the main entry
3530 if (symbol
->name
[0] == '_' && strcmp (symbol
->name
, "__main") == 0)
3531 bfd_set_start_address (abfd
, (bfd_vma
)symbol
->value
);
3533 /* Only put in the GSD the global and the undefined symbols. */
3534 if (old_flags
& BSF_FILE
)
3537 if ((old_flags
& BSF_GLOBAL
) == 0 && !bfd_is_und_section (symbol
->section
))
3539 /* If the LIB$INITIIALIZE section is present, add a reference to
3540 LIB$INITIALIZE symbol. FIXME: this should be done explicitely
3541 in the assembly file. */
3542 if (!((old_flags
& BSF_SECTION_SYM
) != 0
3543 && strcmp (symbol
->section
->name
, "LIB$INITIALIZE") == 0))
3547 /* 13 bytes egsd, max 64 chars name -> should be 77 bytes. Add 16 more
3548 bytes for a possible ABS section. */
3549 if (_bfd_vms_output_check (recwr
, 80 + 16) < 0)
3551 _bfd_vms_output_end (abfd
, recwr
);
3552 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3553 _bfd_vms_output_long (recwr
, 0);
3556 if ((old_flags
& BSF_GLOBAL
) != 0
3557 && bfd_is_abs_section (symbol
->section
)
3558 && abs_section_index
<= 0)
3560 /* Create an absolute section if none was defined. It is highly
3561 unlikely that the name $ABS$ clashes with a user defined
3562 non-absolute section name. */
3563 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3564 _bfd_vms_output_short (recwr
, 4);
3565 _bfd_vms_output_short (recwr
, EGPS__V_SHR
);
3566 _bfd_vms_output_long (recwr
, 0);
3567 _bfd_vms_output_counted (recwr
, "$ABS$");
3568 _bfd_vms_output_end_subrec (recwr
);
3570 abs_section_index
= target_index
++;
3573 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYM
);
3575 /* Data type, alignment. */
3576 _bfd_vms_output_short (recwr
, 0);
3580 if (old_flags
& BSF_WEAK
)
3581 new_flags
|= EGSY__V_WEAK
;
3582 if (bfd_is_com_section (symbol
->section
)) /* .comm */
3583 new_flags
|= (EGSY__V_WEAK
| EGSY__V_COMM
);
3585 if (old_flags
& BSF_FUNCTION
)
3587 new_flags
|= EGSY__V_NORM
;
3588 new_flags
|= EGSY__V_REL
;
3590 if (old_flags
& BSF_GLOBAL
)
3592 new_flags
|= EGSY__V_DEF
;
3593 if (!bfd_is_abs_section (symbol
->section
))
3594 new_flags
|= EGSY__V_REL
;
3596 _bfd_vms_output_short (recwr
, new_flags
);
3598 if (old_flags
& BSF_GLOBAL
)
3600 /* Symbol definition. */
3601 bfd_vma code_address
= 0;
3602 unsigned long ca_psindx
= 0;
3603 unsigned long psindx
;
3605 if ((old_flags
& BSF_FUNCTION
) && symbol
->udata
.p
!= NULL
)
3610 ((struct evax_private_udata_struct
*)symbol
->udata
.p
)->enbsym
;
3611 code_address
= sym
->value
;
3612 ca_psindx
= sym
->section
->target_index
;
3614 if (bfd_is_abs_section (symbol
->section
))
3615 psindx
= abs_section_index
;
3617 psindx
= symbol
->section
->target_index
;
3619 _bfd_vms_output_quad (recwr
, symbol
->value
);
3620 _bfd_vms_output_quad (recwr
, code_address
);
3621 _bfd_vms_output_long (recwr
, ca_psindx
);
3622 _bfd_vms_output_long (recwr
, psindx
);
3624 _bfd_vms_output_counted (recwr
, symbol
->name
);
3626 _bfd_vms_output_end_subrec (recwr
);
3629 _bfd_vms_output_alignment (recwr
, 8);
3630 _bfd_vms_output_end (abfd
, recwr
);
3635 /* Write object header for bfd abfd. Return FALSE on error. */
3638 _bfd_vms_write_ehdr (bfd
*abfd
)
3641 unsigned int symnum
;
3642 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3644 vms_debug2 ((2, "vms_write_ehdr (%p)\n", abfd
));
3646 _bfd_vms_output_alignment (recwr
, 2);
3648 _bfd_vms_write_emh (abfd
);
3649 _bfd_vms_write_lmn (abfd
, "GNU AS");
3652 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3653 _bfd_vms_output_short (recwr
, EMH__C_SRC
);
3655 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3657 symbol
= abfd
->outsymbols
[symnum
];
3659 if (symbol
->flags
& BSF_FILE
)
3661 _bfd_vms_output_dump (recwr
, (unsigned char *) symbol
->name
,
3662 (int) strlen (symbol
->name
));
3667 if (symnum
== abfd
->symcount
)
3668 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("noname"));
3670 _bfd_vms_output_end (abfd
, recwr
);
3673 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3674 _bfd_vms_output_short (recwr
, EMH__C_TTL
);
3675 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("TTL"));
3676 _bfd_vms_output_end (abfd
, recwr
);
3679 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3680 _bfd_vms_output_short (recwr
, EMH__C_CPR
);
3681 _bfd_vms_output_dump (recwr
,
3682 (unsigned char *)"GNU BFD ported by Klaus Kämpf 1994-1996",
3684 _bfd_vms_output_end (abfd
, recwr
);
3689 /* Part 4.6, relocations. */
3692 /* WRITE ETIR SECTION
3694 This is still under construction and therefore not documented. */
3696 /* Close the etir/etbt record. */
3699 end_etir_record (bfd
* abfd
)
3701 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3703 _bfd_vms_output_end (abfd
, recwr
);
3707 start_etir_or_etbt_record (bfd
*abfd
, asection
*section
, bfd_vma offset
)
3709 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3711 if (section
->flags
& SEC_DEBUGGING
)
3713 _bfd_vms_output_begin (recwr
, EOBJ__C_ETBT
);
3717 /* Push start offset. */
3718 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3719 _bfd_vms_output_long (recwr
, (unsigned long) 0);
3720 _bfd_vms_output_end_subrec (recwr
);
3723 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_DFLOC
);
3724 _bfd_vms_output_end_subrec (recwr
);
3729 _bfd_vms_output_begin (recwr
, EOBJ__C_ETIR
);
3733 /* Push start offset. */
3734 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3735 _bfd_vms_output_long (recwr
, (unsigned long) section
->target_index
);
3736 _bfd_vms_output_quad (recwr
, offset
);
3737 _bfd_vms_output_end_subrec (recwr
);
3739 /* Start = pop (). */
3740 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_SETRB
);
3741 _bfd_vms_output_end_subrec (recwr
);
3746 /* Output a STO_IMM command for SSIZE bytes of data from CPR at virtual
3747 address VADDR in section specified by SEC_INDEX and NAME. */
3750 sto_imm (bfd
*abfd
, asection
*section
,
3751 bfd_size_type ssize
, unsigned char *cptr
, bfd_vma vaddr
)
3754 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3757 _bfd_vms_debug (8, "sto_imm %d bytes\n", (int) ssize
);
3758 _bfd_hexdump (9, cptr
, (int) ssize
, (int) vaddr
);
3763 /* Try all the rest. */
3766 if (_bfd_vms_output_check (recwr
, size
) < 0)
3768 /* Doesn't fit, split ! */
3769 end_etir_record (abfd
);
3771 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3773 size
= _bfd_vms_output_check (recwr
, 0); /* get max size */
3774 if (size
> ssize
) /* more than what's left ? */
3778 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_IMM
);
3779 _bfd_vms_output_long (recwr
, (unsigned long) (size
));
3780 _bfd_vms_output_dump (recwr
, cptr
, size
);
3781 _bfd_vms_output_end_subrec (recwr
);
3784 _bfd_vms_debug (10, "dumped %d bytes\n", (int) size
);
3785 _bfd_hexdump (10, cptr
, (int) size
, (int) vaddr
);
3795 etir_output_check (bfd
*abfd
, asection
*section
, bfd_vma vaddr
, int checklen
)
3797 if (_bfd_vms_output_check (&PRIV (recwr
), checklen
) < 0)
3799 /* Not enough room in this record. Close it and open a new one. */
3800 end_etir_record (abfd
);
3801 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3805 /* Return whether RELOC must be deferred till the end. */
3808 defer_reloc_p (arelent
*reloc
)
3810 switch (reloc
->howto
->type
)
3823 /* Write section contents for bfd abfd. Return FALSE on error. */
3826 _bfd_vms_write_etir (bfd
* abfd
, int objtype ATTRIBUTE_UNUSED
)
3829 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3831 vms_debug2 ((2, "vms_write_tir (%p, %d)\n", abfd
, objtype
));
3833 _bfd_vms_output_alignment (recwr
, 4);
3835 PRIV (vms_linkage_index
) = 0;
3837 for (section
= abfd
->sections
; section
; section
= section
->next
)
3839 vms_debug2 ((4, "writing %d. section '%s' (%d bytes)\n",
3840 section
->target_index
, section
->name
, (int) (section
->size
)));
3842 if (!(section
->flags
& SEC_HAS_CONTENTS
)
3843 || bfd_is_com_section (section
))
3846 if (!section
->contents
)
3848 bfd_set_error (bfd_error_no_contents
);
3852 start_etir_or_etbt_record (abfd
, section
, 0);
3854 if (section
->flags
& SEC_RELOC
)
3856 bfd_vma curr_addr
= 0;
3857 unsigned char *curr_data
= section
->contents
;
3859 int pass2_needed
= 0;
3860 int pass2_in_progress
= 0;
3863 if (section
->reloc_count
== 0)
3865 (_("SEC_RELOC with no relocs in section %pA"), section
);
3870 int i
= section
->reloc_count
;
3871 arelent
**rptr
= section
->orelocation
;
3872 _bfd_vms_debug (4, "%d relocations:\n", i
);
3875 _bfd_vms_debug (4, "sym %s in sec %s, value %08lx, "
3876 "addr %08lx, off %08lx, len %d: %s\n",
3877 (*(*rptr
)->sym_ptr_ptr
)->name
,
3878 (*(*rptr
)->sym_ptr_ptr
)->section
->name
,
3879 (long) (*(*rptr
)->sym_ptr_ptr
)->value
,
3880 (unsigned long)(*rptr
)->address
,
3881 (unsigned long)(*rptr
)->addend
,
3882 bfd_get_reloc_size ((*rptr
)->howto
),
3883 ( *rptr
)->howto
->name
);
3890 for (irel
= 0; irel
< section
->reloc_count
; irel
++)
3892 struct evax_private_udata_struct
*udata
;
3893 arelent
*rptr
= section
->orelocation
[irel
];
3894 bfd_vma addr
= rptr
->address
;
3895 asymbol
*sym
= *rptr
->sym_ptr_ptr
;
3896 asection
*sec
= sym
->section
;
3897 bfd_boolean defer
= defer_reloc_p (rptr
);
3900 if (pass2_in_progress
)
3902 /* Non-deferred relocs have already been output. */
3908 /* Deferred relocs must be output at the very end. */
3915 /* Regular relocs are intertwined with binary data. */
3916 if (curr_addr
> addr
)
3917 _bfd_error_handler (_("size error in section %pA"),
3919 size
= addr
- curr_addr
;
3920 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
3925 size
= bfd_get_reloc_size (rptr
->howto
);
3927 switch (rptr
->howto
->type
)
3929 case ALPHA_R_IGNORE
:
3932 case ALPHA_R_REFLONG
:
3933 if (bfd_is_und_section (sym
->section
))
3935 bfd_vma addend
= rptr
->addend
;
3936 slen
= strlen ((char *) sym
->name
);
3937 etir_output_check (abfd
, section
, curr_addr
, slen
);
3940 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
3941 _bfd_vms_output_counted (recwr
, sym
->name
);
3942 _bfd_vms_output_end_subrec (recwr
);
3943 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3944 _bfd_vms_output_long (recwr
, (unsigned long) addend
);
3945 _bfd_vms_output_end_subrec (recwr
);
3946 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
3947 _bfd_vms_output_end_subrec (recwr
);
3948 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3949 _bfd_vms_output_end_subrec (recwr
);
3953 _bfd_vms_output_begin_subrec
3954 (recwr
, ETIR__C_STO_GBL_LW
);
3955 _bfd_vms_output_counted (recwr
, sym
->name
);
3956 _bfd_vms_output_end_subrec (recwr
);
3959 else if (bfd_is_abs_section (sym
->section
))
3961 etir_output_check (abfd
, section
, curr_addr
, 16);
3962 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3963 _bfd_vms_output_long (recwr
, (unsigned long) sym
->value
);
3964 _bfd_vms_output_end_subrec (recwr
);
3965 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3966 _bfd_vms_output_end_subrec (recwr
);
3970 etir_output_check (abfd
, section
, curr_addr
, 32);
3971 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3972 _bfd_vms_output_long (recwr
,
3973 (unsigned long) sec
->target_index
);
3974 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
3975 _bfd_vms_output_end_subrec (recwr
);
3976 /* ??? Table B-8 of the OpenVMS Linker Utilily Manual
3977 says that we should have a ETIR__C_STO_OFF here.
3978 But the relocation would not be BFD_RELOC_32 then.
3979 This case is very likely unreachable. */
3980 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3981 _bfd_vms_output_end_subrec (recwr
);
3985 case ALPHA_R_REFQUAD
:
3986 if (bfd_is_und_section (sym
->section
))
3988 bfd_vma addend
= rptr
->addend
;
3989 slen
= strlen ((char *) sym
->name
);
3990 etir_output_check (abfd
, section
, curr_addr
, slen
);
3993 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
3994 _bfd_vms_output_counted (recwr
, sym
->name
);
3995 _bfd_vms_output_end_subrec (recwr
);
3996 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
3997 _bfd_vms_output_quad (recwr
, addend
);
3998 _bfd_vms_output_end_subrec (recwr
);
3999 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
4000 _bfd_vms_output_end_subrec (recwr
);
4001 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
4002 _bfd_vms_output_end_subrec (recwr
);
4006 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_GBL
);
4007 _bfd_vms_output_counted (recwr
, sym
->name
);
4008 _bfd_vms_output_end_subrec (recwr
);
4011 else if (bfd_is_abs_section (sym
->section
))
4013 etir_output_check (abfd
, section
, curr_addr
, 16);
4014 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
4015 _bfd_vms_output_quad (recwr
, sym
->value
);
4016 _bfd_vms_output_end_subrec (recwr
);
4017 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
4018 _bfd_vms_output_end_subrec (recwr
);
4022 etir_output_check (abfd
, section
, curr_addr
, 32);
4023 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
4024 _bfd_vms_output_long (recwr
,
4025 (unsigned long) sec
->target_index
);
4026 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
4027 _bfd_vms_output_end_subrec (recwr
);
4028 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_OFF
);
4029 _bfd_vms_output_end_subrec (recwr
);
4034 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
4037 case ALPHA_R_LINKAGE
:
4039 etir_output_check (abfd
, section
, curr_addr
, 64);
4040 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LP_PSB
);
4041 _bfd_vms_output_long
4042 (recwr
, (unsigned long) rptr
->addend
);
4043 if (rptr
->addend
> PRIV (vms_linkage_index
))
4044 PRIV (vms_linkage_index
) = rptr
->addend
;
4045 _bfd_vms_output_counted (recwr
, sym
->name
);
4046 _bfd_vms_output_byte (recwr
, 0);
4047 _bfd_vms_output_end_subrec (recwr
);
4050 case ALPHA_R_CODEADDR
:
4051 slen
= strlen ((char *) sym
->name
);
4052 etir_output_check (abfd
, section
, curr_addr
, slen
);
4053 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_CA
);
4054 _bfd_vms_output_counted (recwr
, sym
->name
);
4055 _bfd_vms_output_end_subrec (recwr
);
4060 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4061 etir_output_check (abfd
, section
, curr_addr
,
4062 32 + 1 + strlen (udata
->origname
));
4063 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_NOP_GBL
);
4064 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
4065 _bfd_vms_output_long
4066 (recwr
, (unsigned long) section
->target_index
);
4067 _bfd_vms_output_quad (recwr
, rptr
->address
);
4068 _bfd_vms_output_long (recwr
, (unsigned long) 0x47ff041f);
4069 _bfd_vms_output_long
4070 (recwr
, (unsigned long) section
->target_index
);
4071 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4072 _bfd_vms_output_counted (recwr
, udata
->origname
);
4073 _bfd_vms_output_end_subrec (recwr
);
4077 _bfd_error_handler (_("spurious ALPHA_R_BSR reloc"));
4082 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4083 etir_output_check (abfd
, section
, curr_addr
,
4084 32 + 1 + strlen (udata
->origname
));
4085 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LDA_GBL
);
4086 _bfd_vms_output_long
4087 (recwr
, (unsigned long) udata
->lkindex
+ 1);
4088 _bfd_vms_output_long
4089 (recwr
, (unsigned long) section
->target_index
);
4090 _bfd_vms_output_quad (recwr
, rptr
->address
);
4091 _bfd_vms_output_long (recwr
, (unsigned long) 0x237B0000);
4092 _bfd_vms_output_long
4093 (recwr
, (unsigned long) udata
->bsym
->section
->target_index
);
4094 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4095 _bfd_vms_output_counted (recwr
, udata
->origname
);
4096 _bfd_vms_output_end_subrec (recwr
);
4101 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4102 etir_output_check (abfd
, section
, curr_addr
,
4103 32 + 1 + strlen (udata
->origname
));
4104 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_BOH_GBL
);
4105 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
4106 _bfd_vms_output_long
4107 (recwr
, (unsigned long) section
->target_index
);
4108 _bfd_vms_output_quad (recwr
, rptr
->address
);
4109 _bfd_vms_output_long (recwr
, (unsigned long) 0xD3400000);
4110 _bfd_vms_output_long
4111 (recwr
, (unsigned long) section
->target_index
);
4112 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4113 _bfd_vms_output_counted (recwr
, udata
->origname
);
4114 _bfd_vms_output_end_subrec (recwr
);
4118 _bfd_error_handler (_("unhandled relocation %s"),
4125 } /* End of relocs loop. */
4127 if (!pass2_in_progress
)
4129 /* Output rest of section. */
4130 if (curr_addr
> section
->size
)
4132 _bfd_error_handler (_("size error in section %pA"), section
);
4135 size
= section
->size
- curr_addr
;
4136 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
4142 pass2_in_progress
= 1;
4148 else /* (section->flags & SEC_RELOC) */
4149 sto_imm (abfd
, section
, section
->size
, section
->contents
, 0);
4151 end_etir_record (abfd
);
4154 _bfd_vms_output_alignment (recwr
, 2);
4158 /* Write cached information into a file being written, at bfd_close. */
4161 alpha_vms_write_object_contents (bfd
*abfd
)
4163 vms_debug2 ((1, "vms_write_object_contents (%p)\n", abfd
));
4165 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
4167 return alpha_vms_write_exec (abfd
);
4171 if (abfd
->section_count
> 0) /* we have sections */
4173 if (!_bfd_vms_write_ehdr (abfd
))
4175 if (!_bfd_vms_write_egsd (abfd
))
4177 if (!_bfd_vms_write_etir (abfd
, EOBJ__C_ETIR
))
4179 if (!_bfd_vms_write_eeom (abfd
))
4186 /* Debug stuff: nearest line. */
4188 #define SET_MODULE_PARSED(m) \
4189 do { if ((m)->name == NULL) (m)->name = ""; } while (0)
4190 #define IS_MODULE_PARSED(m) ((m)->name != NULL)
4192 /* Build a new module for the specified BFD. */
4194 static struct module
*
4195 new_module (bfd
*abfd
)
4197 struct module
*module
4198 = (struct module
*) bfd_zalloc (abfd
, sizeof (struct module
));
4199 module
->file_table_count
= 16; /* Arbitrary. */
4201 = bfd_malloc (module
->file_table_count
* sizeof (struct fileinfo
));
4205 /* Parse debug info for a module and internalize it. */
4208 parse_module (bfd
*abfd
, struct module
*module
, unsigned char *ptr
,
4211 unsigned char *maxptr
= ptr
+ length
;
4212 unsigned char *src_ptr
, *pcl_ptr
;
4213 unsigned int prev_linum
= 0, curr_linenum
= 0;
4214 bfd_vma prev_pc
= 0, curr_pc
= 0;
4215 struct srecinfo
*curr_srec
, *srec
;
4216 struct lineinfo
*curr_line
, *line
;
4217 struct funcinfo
*funcinfo
;
4219 /* Initialize tables with zero element. */
4220 curr_srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4221 module
->srec_table
= curr_srec
;
4223 curr_line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4224 module
->line_table
= curr_line
;
4226 while (length
== -1 || ptr
< maxptr
)
4228 /* The first byte is not counted in the recorded length. */
4229 int rec_length
= bfd_getl16 (ptr
) + 1;
4230 int rec_type
= bfd_getl16 (ptr
+ 2);
4232 vms_debug2 ((2, "DST record: leng %d, type %d\n", rec_length
, rec_type
));
4234 if (length
== -1 && rec_type
== DST__K_MODEND
)
4241 = _bfd_vms_save_counted_string (abfd
, ptr
+ DST_S_B_MODBEG_NAME
,
4242 maxptr
- (ptr
+ DST_S_B_MODBEG_NAME
));
4249 vms_debug2 ((3, "module: %s\n", module
->name
));
4256 funcinfo
= (struct funcinfo
*)
4257 bfd_zalloc (abfd
, sizeof (struct funcinfo
));
4259 = _bfd_vms_save_counted_string (abfd
, ptr
+ DST_S_B_RTNBEG_NAME
,
4260 maxptr
- (ptr
+ DST_S_B_RTNBEG_NAME
));
4261 funcinfo
->low
= bfd_getl32 (ptr
+ DST_S_L_RTNBEG_ADDRESS
);
4262 funcinfo
->next
= module
->func_table
;
4263 module
->func_table
= funcinfo
;
4265 vms_debug2 ((3, "routine: %s at 0x%lx\n",
4266 funcinfo
->name
, (unsigned long) funcinfo
->low
));
4270 module
->func_table
->high
= module
->func_table
->low
4271 + bfd_getl32 (ptr
+ DST_S_L_RTNEND_SIZE
) - 1;
4273 if (module
->func_table
->high
> module
->high
)
4274 module
->high
= module
->func_table
->high
;
4276 vms_debug2 ((3, "end routine\n"));
4280 vms_debug2 ((3, "prologue\n"));
4284 vms_debug2 ((3, "epilog\n"));
4288 vms_debug2 ((3, "block\n"));
4292 vms_debug2 ((3, "end block\n"));
4296 src_ptr
= ptr
+ DST_S_C_SOURCE_HEADER_SIZE
;
4298 vms_debug2 ((3, "source info\n"));
4300 while (src_ptr
< ptr
+ rec_length
)
4302 int cmd
= src_ptr
[0], cmd_length
, data
;
4306 case DST__K_SRC_DECLFILE
:
4309 = bfd_getl16 (src_ptr
+ DST_S_W_SRC_DF_FILEID
);
4310 char *filename
= _bfd_vms_save_counted_string
4312 src_ptr
+ DST_S_B_SRC_DF_FILENAME
,
4313 ptr
+ rec_length
- (src_ptr
+ DST_S_B_SRC_DF_FILENAME
));
4315 while (fileid
>= module
->file_table_count
)
4317 module
->file_table_count
*= 2;
4319 = bfd_realloc (module
->file_table
,
4320 module
->file_table_count
4321 * sizeof (struct fileinfo
));
4324 module
->file_table
[fileid
].name
= filename
;
4325 module
->file_table
[fileid
].srec
= 1;
4326 cmd_length
= src_ptr
[DST_S_B_SRC_DF_LENGTH
] + 2;
4327 vms_debug2 ((4, "DST_S_C_SRC_DECLFILE: %d, %s\n",
4328 fileid
, module
->file_table
[fileid
].name
));
4332 case DST__K_SRC_DEFLINES_B
:
4333 /* Perform the association and set the next higher index
4335 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4336 srec
= (struct srecinfo
*)
4337 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4338 srec
->line
= curr_srec
->line
+ data
;
4339 srec
->srec
= curr_srec
->srec
+ data
;
4340 srec
->sfile
= curr_srec
->sfile
;
4341 curr_srec
->next
= srec
;
4344 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_B: %d\n", data
));
4347 case DST__K_SRC_DEFLINES_W
:
4348 /* Perform the association and set the next higher index
4350 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4351 srec
= (struct srecinfo
*)
4352 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4353 srec
->line
= curr_srec
->line
+ data
;
4354 srec
->srec
= curr_srec
->srec
+ data
,
4355 srec
->sfile
= curr_srec
->sfile
;
4356 curr_srec
->next
= srec
;
4359 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_W: %d\n", data
));
4362 case DST__K_SRC_INCRLNUM_B
:
4363 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4364 curr_srec
->line
+= data
;
4366 vms_debug2 ((4, "DST_S_C_SRC_INCRLNUM_B: %d\n", data
));
4369 case DST__K_SRC_SETFILE
:
4370 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4371 curr_srec
->sfile
= data
;
4372 curr_srec
->srec
= module
->file_table
[data
].srec
;
4374 vms_debug2 ((4, "DST_S_C_SRC_SETFILE: %d\n", data
));
4377 case DST__K_SRC_SETLNUM_L
:
4378 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4379 curr_srec
->line
= data
;
4381 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_L: %d\n", data
));
4384 case DST__K_SRC_SETLNUM_W
:
4385 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4386 curr_srec
->line
= data
;
4388 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_W: %d\n", data
));
4391 case DST__K_SRC_SETREC_L
:
4392 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4393 curr_srec
->srec
= data
;
4394 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4396 vms_debug2 ((4, "DST_S_C_SRC_SETREC_L: %d\n", data
));
4399 case DST__K_SRC_SETREC_W
:
4400 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4401 curr_srec
->srec
= data
;
4402 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4404 vms_debug2 ((4, "DST_S_C_SRC_SETREC_W: %d\n", data
));
4407 case DST__K_SRC_FORMFEED
:
4409 vms_debug2 ((4, "DST_S_C_SRC_FORMFEED\n"));
4413 _bfd_error_handler (_("unknown source command %d"),
4419 src_ptr
+= cmd_length
;
4423 case DST__K_LINE_NUM
:
4424 pcl_ptr
= ptr
+ DST_S_C_LINE_NUM_HEADER_SIZE
;
4426 vms_debug2 ((3, "line info\n"));
4428 while (pcl_ptr
< ptr
+ rec_length
)
4430 /* The command byte is signed so we must sign-extend it. */
4431 int cmd
= ((signed char *)pcl_ptr
)[0], cmd_length
, data
;
4435 case DST__K_DELTA_PC_W
:
4436 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4440 vms_debug2 ((4, "DST__K_DELTA_PC_W: %d\n", data
));
4443 case DST__K_DELTA_PC_L
:
4444 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4448 vms_debug2 ((4, "DST__K_DELTA_PC_L: %d\n", data
));
4451 case DST__K_INCR_LINUM
:
4452 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4453 curr_linenum
+= data
;
4455 vms_debug2 ((4, "DST__K_INCR_LINUM: %d\n", data
));
4458 case DST__K_INCR_LINUM_W
:
4459 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4460 curr_linenum
+= data
;
4462 vms_debug2 ((4, "DST__K_INCR_LINUM_W: %d\n", data
));
4465 case DST__K_INCR_LINUM_L
:
4466 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4467 curr_linenum
+= data
;
4469 vms_debug2 ((4, "DST__K_INCR_LINUM_L: %d\n", data
));
4472 case DST__K_SET_LINUM_INCR
:
4474 (_("%s not implemented"), "DST__K_SET_LINUM_INCR");
4478 case DST__K_SET_LINUM_INCR_W
:
4480 (_("%s not implemented"), "DST__K_SET_LINUM_INCR_W");
4484 case DST__K_RESET_LINUM_INCR
:
4486 (_("%s not implemented"), "DST__K_RESET_LINUM_INCR");
4490 case DST__K_BEG_STMT_MODE
:
4492 (_("%s not implemented"), "DST__K_BEG_STMT_MODE");
4496 case DST__K_END_STMT_MODE
:
4498 (_("%s not implemented"), "DST__K_END_STMT_MODE");
4502 case DST__K_SET_LINUM_B
:
4503 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4504 curr_linenum
= data
;
4506 vms_debug2 ((4, "DST__K_SET_LINUM_B: %d\n", data
));
4509 case DST__K_SET_LINUM
:
4510 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4511 curr_linenum
= data
;
4513 vms_debug2 ((4, "DST__K_SET_LINE_NUM: %d\n", data
));
4516 case DST__K_SET_LINUM_L
:
4517 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4518 curr_linenum
= data
;
4520 vms_debug2 ((4, "DST__K_SET_LINUM_L: %d\n", data
));
4525 (_("%s not implemented"), "DST__K_SET_PC");
4529 case DST__K_SET_PC_W
:
4531 (_("%s not implemented"), "DST__K_SET_PC_W");
4535 case DST__K_SET_PC_L
:
4537 (_("%s not implemented"), "DST__K_SET_PC_L");
4541 case DST__K_SET_STMTNUM
:
4543 (_("%s not implemented"), "DST__K_SET_STMTNUM");
4548 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4551 vms_debug2 ((4, "DST__K_TERM: %d\n", data
));
4555 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4558 vms_debug2 ((4, "DST__K_TERM_W: %d\n", data
));
4562 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4565 vms_debug2 ((4, "DST__K_TERM_L: %d\n", data
));
4568 case DST__K_SET_ABS_PC
:
4569 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4572 vms_debug2 ((4, "DST__K_SET_ABS_PC: 0x%x\n", data
));
4581 vms_debug2 ((4, "bump pc to 0x%lx and line to %d\n",
4582 (unsigned long)curr_pc
, curr_linenum
));
4586 _bfd_error_handler (_("unknown line command %d"), cmd
);
4592 if ((curr_linenum
!= prev_linum
&& curr_pc
!= prev_pc
)
4594 || cmd
== DST__K_DELTA_PC_L
4595 || cmd
== DST__K_DELTA_PC_W
)
4597 line
= (struct lineinfo
*)
4598 bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4599 line
->address
= curr_pc
;
4600 line
->line
= curr_linenum
;
4602 curr_line
->next
= line
;
4605 prev_linum
= curr_linenum
;
4607 vms_debug2 ((4, "-> correlate pc 0x%lx with line %d\n",
4608 (unsigned long)curr_pc
, curr_linenum
));
4611 pcl_ptr
+= cmd_length
;
4615 case 0x17: /* Undocumented type used by DEC C to declare equates. */
4616 vms_debug2 ((3, "undocumented type 0x17\n"));
4620 vms_debug2 ((3, "ignoring record\n"));
4628 /* Finalize tables with EOL marker. */
4629 srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4630 srec
->line
= (unsigned int) -1;
4631 srec
->srec
= (unsigned int) -1;
4632 curr_srec
->next
= srec
;
4634 line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4635 line
->line
= (unsigned int) -1;
4636 line
->address
= (bfd_vma
) -1;
4637 curr_line
->next
= line
;
4639 /* Advertise that this module has been parsed. This is needed
4640 because parsing can be either performed at module creation
4641 or deferred until debug info is consumed. */
4642 SET_MODULE_PARSED (module
);
4645 /* Build the list of modules for the specified BFD. */
4647 static struct module
*
4648 build_module_list (bfd
*abfd
)
4650 struct module
*module
, *list
= NULL
;
4653 if ((dmt
= bfd_get_section_by_name (abfd
, "$DMT$")))
4655 /* We have a DMT section so this must be an image. Parse the
4656 section and build the list of modules. This is sufficient
4657 since we can compute the start address and the end address
4658 of every module from the section contents. */
4659 bfd_size_type size
= bfd_section_size (dmt
);
4660 unsigned char *ptr
, *end
;
4662 ptr
= (unsigned char *) bfd_alloc (abfd
, size
);
4666 if (! bfd_get_section_contents (abfd
, dmt
, ptr
, 0, size
))
4669 vms_debug2 ((2, "DMT\n"));
4675 /* Each header declares a module with its start offset and size
4676 of debug info in the DST section, as well as the count of
4677 program sections (i.e. address spans) it contains. */
4678 int modbeg
= bfd_getl32 (ptr
+ DBG_S_L_DMT_MODBEG
);
4679 int msize
= bfd_getl32 (ptr
+ DBG_S_L_DST_SIZE
);
4680 int count
= bfd_getl16 (ptr
+ DBG_S_W_DMT_PSECT_COUNT
);
4681 ptr
+= DBG_S_C_DMT_HEADER_SIZE
;
4683 vms_debug2 ((3, "module: modbeg = %d, size = %d, count = %d\n",
4684 modbeg
, msize
, count
));
4686 /* We create a 'module' structure for each program section since
4687 we only support contiguous addresses in a 'module' structure.
4688 As a consequence, the actual debug info in the DST section is
4689 shared and can be parsed multiple times; that doesn't seem to
4690 cause problems in practice. */
4693 int start
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_START
);
4694 int length
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_LENGTH
);
4695 module
= new_module (abfd
);
4696 module
->modbeg
= modbeg
;
4697 module
->size
= msize
;
4698 module
->low
= start
;
4699 module
->high
= start
+ length
;
4700 module
->next
= list
;
4702 ptr
+= DBG_S_C_DMT_PSECT_SIZE
;
4704 vms_debug2 ((4, "section: start = 0x%x, length = %d\n",
4711 /* We don't have a DMT section so this must be an object. Parse
4712 the module right now in order to compute its start address and
4714 void *dst
= PRIV (dst_section
)->contents
;
4719 module
= new_module (abfd
);
4720 parse_module (abfd
, module
, PRIV (dst_section
)->contents
, -1);
4727 /* Calculate and return the name of the source file and the line nearest
4728 to the wanted location in the specified module. */
4731 module_find_nearest_line (bfd
*abfd
, struct module
*module
, bfd_vma addr
,
4732 const char **file
, const char **func
,
4735 struct funcinfo
*funcinfo
;
4736 struct lineinfo
*lineinfo
;
4737 struct srecinfo
*srecinfo
;
4738 bfd_boolean ret
= FALSE
;
4740 /* Parse this module if that was not done at module creation. */
4741 if (! IS_MODULE_PARSED (module
))
4743 unsigned int size
= module
->size
;
4744 unsigned int modbeg
= PRIV (dst_section
)->filepos
+ module
->modbeg
;
4745 unsigned char *buffer
= (unsigned char *) bfd_malloc (module
->size
);
4747 if (bfd_seek (abfd
, modbeg
, SEEK_SET
) != 0
4748 || bfd_bread (buffer
, size
, abfd
) != size
)
4750 bfd_set_error (bfd_error_no_debug_section
);
4754 parse_module (abfd
, module
, buffer
, size
);
4758 /* Find out the function (if any) that contains the address. */
4759 for (funcinfo
= module
->func_table
; funcinfo
; funcinfo
= funcinfo
->next
)
4760 if (addr
>= funcinfo
->low
&& addr
<= funcinfo
->high
)
4762 *func
= funcinfo
->name
;
4767 /* Find out the source file and the line nearest to the address. */
4768 for (lineinfo
= module
->line_table
; lineinfo
; lineinfo
= lineinfo
->next
)
4769 if (lineinfo
->next
&& addr
< lineinfo
->next
->address
)
4771 for (srecinfo
= module
->srec_table
; srecinfo
; srecinfo
= srecinfo
->next
)
4772 if (srecinfo
->next
&& lineinfo
->line
< srecinfo
->next
->line
)
4774 if (srecinfo
->sfile
> 0)
4776 *file
= module
->file_table
[srecinfo
->sfile
].name
;
4777 *line
= srecinfo
->srec
+ lineinfo
->line
- srecinfo
->line
;
4781 *file
= module
->name
;
4782 *line
= lineinfo
->line
;
4793 /* Provided a BFD, a section and an offset into the section, calculate and
4794 return the name of the source file and the line nearest to the wanted
4798 _bfd_vms_find_nearest_line (bfd
*abfd
,
4799 asymbol
**symbols ATTRIBUTE_UNUSED
,
4805 unsigned int *discriminator
)
4807 struct module
*module
;
4809 /* What address are we looking for? */
4810 bfd_vma addr
= section
->vma
+ offset
;
4818 /* We can't do anything if there is no DST (debug symbol table). */
4819 if (PRIV (dst_section
) == NULL
)
4822 /* Create the module list - if not already done. */
4823 if (PRIV (modules
) == NULL
)
4825 PRIV (modules
) = build_module_list (abfd
);
4826 if (PRIV (modules
) == NULL
)
4830 for (module
= PRIV (modules
); module
; module
= module
->next
)
4831 if (addr
>= module
->low
&& addr
<= module
->high
)
4832 return module_find_nearest_line (abfd
, module
, addr
, file
, func
, line
);
4837 /* Canonicalizations. */
4838 /* Set name, value, section and flags of SYM from E. */
4841 alpha_vms_convert_symbol (bfd
*abfd
, struct vms_symbol_entry
*e
, asymbol
*sym
)
4850 flags
= BSF_NO_FLAGS
;
4856 if (e
->flags
& EGSY__V_WEAK
)
4859 if (e
->flags
& EGSY__V_DEF
)
4861 /* Symbol definition. */
4862 flags
|= BSF_GLOBAL
;
4863 if (e
->flags
& EGSY__V_NORM
)
4864 flags
|= BSF_FUNCTION
;
4870 /* Symbol reference. */
4871 sec
= bfd_und_section_ptr
;
4876 /* A universal symbol is by definition global... */
4877 flags
|= BSF_GLOBAL
;
4879 /* ...and dynamic in shared libraries. */
4880 if (abfd
->flags
& DYNAMIC
)
4881 flags
|= BSF_DYNAMIC
;
4883 if (e
->flags
& EGSY__V_WEAK
)
4886 if (!(e
->flags
& EGSY__V_DEF
))
4889 if (e
->flags
& EGSY__V_NORM
)
4890 flags
|= BSF_FUNCTION
;
4893 /* sec = e->section; */
4894 sec
= bfd_abs_section_ptr
;
4909 /* Return the number of bytes required to store a vector of pointers
4910 to asymbols for all the symbols in the BFD abfd, including a
4911 terminal NULL pointer. If there are no symbols in the BFD,
4912 then return 0. If an error occurs, return -1. */
4915 alpha_vms_get_symtab_upper_bound (bfd
*abfd
)
4917 vms_debug2 ((1, "alpha_vms_get_symtab_upper_bound (%p), %d symbols\n",
4918 abfd
, PRIV (gsd_sym_count
)));
4920 return (PRIV (gsd_sym_count
) + 1) * sizeof (asymbol
*);
4923 /* Read the symbols from the BFD abfd, and fills in the vector
4924 location with pointers to the symbols and a trailing NULL.
4926 Return number of symbols read. */
4929 alpha_vms_canonicalize_symtab (bfd
*abfd
, asymbol
**symbols
)
4933 vms_debug2 ((1, "alpha_vms_canonicalize_symtab (%p, <ret>)\n", abfd
));
4935 if (PRIV (csymbols
) == NULL
)
4937 PRIV (csymbols
) = (asymbol
**) bfd_alloc
4938 (abfd
, PRIV (gsd_sym_count
) * sizeof (asymbol
*));
4940 /* Traverse table and fill symbols vector. */
4941 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
4943 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
4946 sym
= bfd_make_empty_symbol (abfd
);
4947 if (sym
== NULL
|| !alpha_vms_convert_symbol (abfd
, e
, sym
))
4949 bfd_release (abfd
, PRIV (csymbols
));
4950 PRIV (csymbols
) = NULL
;
4954 PRIV (csymbols
)[i
] = sym
;
4958 if (symbols
!= NULL
)
4960 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
4961 symbols
[i
] = PRIV (csymbols
)[i
];
4965 return PRIV (gsd_sym_count
);
4968 /* Read and convert relocations from ETIR. We do it once for all sections. */
4971 alpha_vms_slurp_relocs (bfd
*abfd
)
4975 vms_debug2 ((3, "alpha_vms_slurp_relocs\n"));
4977 /* We slurp relocs only once, for all sections. */
4978 if (PRIV (reloc_done
))
4980 PRIV (reloc_done
) = TRUE
;
4982 if (alpha_vms_canonicalize_symtab (abfd
, NULL
) < 0)
4985 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
4990 unsigned char *begin
;
4993 bfd_reloc_code_real_type reloc_code
;
4999 bfd_vma cur_address
;
5001 unsigned char *cur_sym
= NULL
;
5003 bfd_vma cur_addend
= 0;
5005 /* Skip non-ETIR records. */
5006 type
= _bfd_vms_get_object_record (abfd
);
5007 if (type
== EOBJ__C_EEOM
)
5009 if (type
!= EOBJ__C_ETIR
)
5012 begin
= PRIV (recrd
.rec
) + 4;
5013 end
= PRIV (recrd
.rec
) + PRIV (recrd
.rec_size
);
5015 for (ptr
= begin
; ptr
< end
; ptr
+= length
)
5019 cmd
= bfd_getl16 (ptr
);
5020 length
= bfd_getl16 (ptr
+ 2);
5022 cur_address
= vaddr
;
5024 vms_debug2 ((4, "alpha_vms_slurp_relocs: etir %s\n",
5025 _bfd_vms_etir_name (cmd
)));
5029 case ETIR__C_STA_GBL
: /* ALPHA_R_REFLONG und_section, step 1 */
5030 /* ALPHA_R_REFQUAD und_section, step 1 */
5035 case ETIR__C_STA_PQ
: /* ALPHA_R_REF{LONG|QUAD}, others part 1 */
5036 cur_psidx
= bfd_getl32 (ptr
+ 4);
5037 cur_addend
= bfd_getl64 (ptr
+ 8);
5041 case ETIR__C_CTL_SETRB
:
5042 if (prev_cmd
!= ETIR__C_STA_PQ
)
5045 /* xgettext:c-format */
5046 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (prev_cmd
),
5047 _bfd_vms_etir_name (cmd
));
5050 cur_psect
= cur_psidx
;
5056 case ETIR__C_STA_LW
: /* ALPHA_R_REFLONG abs_section, step 1 */
5057 /* ALPHA_R_REFLONG und_section, step 2 */
5060 if (prev_cmd
!= ETIR__C_STA_GBL
)
5063 /* xgettext:c-format */
5064 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
5065 _bfd_vms_etir_name (ETIR__C_STA_LW
));
5069 cur_addend
= bfd_getl32 (ptr
+ 4);
5073 case ETIR__C_STA_QW
: /* ALPHA_R_REFQUAD abs_section, step 1 */
5074 /* ALPHA_R_REFQUAD und_section, step 2 */
5075 if (prev_cmd
!= -1 && prev_cmd
!= ETIR__C_STA_GBL
)
5078 /* xgettext:c-format */
5079 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
5080 _bfd_vms_etir_name (ETIR__C_STA_QW
));
5083 cur_addend
= bfd_getl64 (ptr
+ 4);
5087 case ETIR__C_STO_LW
: /* ALPHA_R_REFLONG und_section, step 4 */
5088 /* ALPHA_R_REFLONG abs_section, step 2 */
5089 /* ALPHA_R_REFLONG others, step 2 */
5090 if (prev_cmd
!= ETIR__C_OPR_ADD
5091 && prev_cmd
!= ETIR__C_STA_LW
5092 && prev_cmd
!= ETIR__C_STA_PQ
)
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_STO_LW
));
5100 reloc_code
= BFD_RELOC_32
;
5103 case ETIR__C_STO_QW
: /* ALPHA_R_REFQUAD und_section, step 4 */
5104 /* ALPHA_R_REFQUAD abs_section, step 2 */
5105 if (prev_cmd
!= ETIR__C_OPR_ADD
&& prev_cmd
!= ETIR__C_STA_QW
)
5107 /* xgettext:c-format */
5108 _bfd_error_handler (_("unknown reloc %s + %s"),
5109 _bfd_vms_etir_name (prev_cmd
),
5110 _bfd_vms_etir_name (ETIR__C_STO_QW
));
5113 reloc_code
= BFD_RELOC_64
;
5116 case ETIR__C_STO_OFF
: /* ALPHA_R_REFQUAD others, step 2 */
5117 if (prev_cmd
!= ETIR__C_STA_PQ
)
5119 /* xgettext:c-format */
5120 _bfd_error_handler (_("unknown reloc %s + %s"),
5121 _bfd_vms_etir_name (prev_cmd
),
5122 _bfd_vms_etir_name (ETIR__C_STO_OFF
));
5125 reloc_code
= BFD_RELOC_64
;
5128 case ETIR__C_OPR_ADD
: /* ALPHA_R_REFLONG und_section, step 3 */
5129 /* ALPHA_R_REFQUAD und_section, step 3 */
5130 if (prev_cmd
!= ETIR__C_STA_LW
&& prev_cmd
!= ETIR__C_STA_QW
)
5132 /* xgettext:c-format */
5133 _bfd_error_handler (_("unknown reloc %s + %s"),
5134 _bfd_vms_etir_name (prev_cmd
),
5135 _bfd_vms_etir_name (ETIR__C_OPR_ADD
));
5138 prev_cmd
= ETIR__C_OPR_ADD
;
5141 case ETIR__C_STO_CA
: /* ALPHA_R_CODEADDR */
5142 reloc_code
= BFD_RELOC_ALPHA_CODEADDR
;
5146 case ETIR__C_STO_GBL
: /* ALPHA_R_REFQUAD und_section */
5147 reloc_code
= BFD_RELOC_64
;
5151 case ETIR__C_STO_GBL_LW
: /* ALPHA_R_REFLONG und_section */
5152 reloc_code
= BFD_RELOC_32
;
5156 case ETIR__C_STC_LP_PSB
: /* ALPHA_R_LINKAGE */
5157 reloc_code
= BFD_RELOC_ALPHA_LINKAGE
;
5161 case ETIR__C_STC_NOP_GBL
: /* ALPHA_R_NOP */
5162 reloc_code
= BFD_RELOC_ALPHA_NOP
;
5165 case ETIR__C_STC_BSR_GBL
: /* ALPHA_R_BSR */
5166 reloc_code
= BFD_RELOC_ALPHA_BSR
;
5169 case ETIR__C_STC_LDA_GBL
: /* ALPHA_R_LDA */
5170 reloc_code
= BFD_RELOC_ALPHA_LDA
;
5173 case ETIR__C_STC_BOH_GBL
: /* ALPHA_R_BOH */
5174 reloc_code
= BFD_RELOC_ALPHA_BOH
;
5178 cur_sym
= ptr
+ 4 + 32;
5179 cur_address
= bfd_getl64 (ptr
+ 4 + 8);
5180 cur_addend
= bfd_getl64 (ptr
+ 4 + 24);
5183 case ETIR__C_STO_IMM
:
5184 vaddr
+= bfd_getl32 (ptr
+ 4);
5188 _bfd_error_handler (_("unknown reloc %s"),
5189 _bfd_vms_etir_name (cmd
));
5195 struct vms_section_data_struct
*vms_sec
;
5199 /* Get section to which the relocation applies. */
5200 if (cur_psect
< 0 || cur_psect
> (int)PRIV (section_count
))
5202 _bfd_error_handler (_("invalid section index in ETIR"));
5206 if (PRIV (sections
) == NULL
)
5208 sec
= PRIV (sections
)[cur_psect
];
5209 if (sec
== bfd_abs_section_ptr
)
5211 _bfd_error_handler (_("relocation for non-REL psect"));
5215 vms_sec
= vms_section_data (sec
);
5217 /* Allocate a reloc entry. */
5218 if (sec
->reloc_count
>= vms_sec
->reloc_max
)
5220 if (vms_sec
->reloc_max
== 0)
5222 vms_sec
->reloc_max
= 64;
5223 sec
->relocation
= bfd_zmalloc
5224 (vms_sec
->reloc_max
* sizeof (arelent
));
5228 vms_sec
->reloc_max
*= 2;
5229 sec
->relocation
= bfd_realloc
5230 (sec
->relocation
, vms_sec
->reloc_max
* sizeof (arelent
));
5233 reloc
= &sec
->relocation
[sec
->reloc_count
];
5236 reloc
->howto
= bfd_reloc_type_lookup (abfd
, reloc_code
);
5238 if (cur_sym
!= NULL
)
5241 unsigned int symlen
= *cur_sym
;
5244 /* Linear search. */
5249 for (j
= 0; j
< PRIV (gsd_sym_count
); j
++)
5250 if (PRIV (syms
)[j
]->namelen
== symlen
5251 && memcmp (PRIV (syms
)[j
]->name
, cur_sym
, symlen
) == 0)
5253 sym
= &PRIV (csymbols
)[j
];
5258 _bfd_error_handler (_("unknown symbol in command %s"),
5259 _bfd_vms_etir_name (cmd
));
5260 reloc
->sym_ptr_ptr
= NULL
;
5263 reloc
->sym_ptr_ptr
= sym
;
5265 else if (cur_psidx
>= 0)
5267 if (PRIV (sections
) == NULL
|| cur_psidx
>= (int) PRIV (section_count
))
5269 reloc
->sym_ptr_ptr
=
5270 PRIV (sections
)[cur_psidx
]->symbol_ptr_ptr
;
5273 reloc
->sym_ptr_ptr
= NULL
;
5275 reloc
->address
= cur_address
;
5276 reloc
->addend
= cur_addend
;
5278 if (reloc_code
== ALPHA_R_LINKAGE
)
5281 size
= bfd_get_reloc_size (reloc
->howto
);
5291 vms_debug2 ((3, "alpha_vms_slurp_relocs: result = TRUE\n"));
5296 /* Return the number of bytes required to store the relocation
5297 information associated with the given section. */
5300 alpha_vms_get_reloc_upper_bound (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*section
)
5302 alpha_vms_slurp_relocs (abfd
);
5304 return (section
->reloc_count
+ 1) * sizeof (arelent
*);
5307 /* Convert relocations from VMS (external) form into BFD internal
5308 form. Return the number of relocations. */
5311 alpha_vms_canonicalize_reloc (bfd
*abfd
, asection
*section
, arelent
**relptr
,
5312 asymbol
**symbols ATTRIBUTE_UNUSED
)
5317 if (!alpha_vms_slurp_relocs (abfd
))
5320 count
= section
->reloc_count
;
5321 tblptr
= section
->relocation
;
5324 *relptr
++ = tblptr
++;
5326 *relptr
= (arelent
*) NULL
;
5327 return section
->reloc_count
;
5330 /* Install a new set of internal relocs. */
5332 #define alpha_vms_set_reloc _bfd_generic_set_reloc
5335 /* This is just copied from ecoff-alpha, needs to be fixed probably. */
5337 /* How to process the various reloc types. */
5339 static bfd_reloc_status_type
5340 reloc_nil (bfd
* abfd ATTRIBUTE_UNUSED
,
5341 arelent
*reloc ATTRIBUTE_UNUSED
,
5342 asymbol
*sym ATTRIBUTE_UNUSED
,
5343 void * data ATTRIBUTE_UNUSED
,
5344 asection
*sec ATTRIBUTE_UNUSED
,
5345 bfd
*output_bfd ATTRIBUTE_UNUSED
,
5346 char **error_message ATTRIBUTE_UNUSED
)
5349 vms_debug (1, "reloc_nil (abfd %p, output_bfd %p)\n", abfd
, output_bfd
);
5350 vms_debug (2, "In section %s, symbol %s\n",
5351 sec
->name
, sym
->name
);
5352 vms_debug (2, "reloc sym %s, addr %08lx, addend %08lx, reloc is a %s\n",
5353 reloc
->sym_ptr_ptr
[0]->name
,
5354 (unsigned long)reloc
->address
,
5355 (unsigned long)reloc
->addend
, reloc
->howto
->name
);
5356 vms_debug (2, "data at %p\n", data
);
5357 /* _bfd_hexdump (2, data, bfd_get_reloc_size (reloc->howto), 0); */
5360 return bfd_reloc_ok
;
5363 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
5364 from smaller values. Start with zero, widen, *then* decrement. */
5365 #define MINUS_ONE (((bfd_vma)0) - 1)
5367 static reloc_howto_type alpha_howto_table
[] =
5369 HOWTO (ALPHA_R_IGNORE
, /* Type. */
5370 0, /* Rightshift. */
5371 0, /* Size (0 = byte, 1 = short, 2 = long). */
5373 TRUE
, /* PC relative. */
5375 complain_overflow_dont
,/* Complain_on_overflow. */
5376 reloc_nil
, /* Special_function. */
5377 "IGNORE", /* Name. */
5378 TRUE
, /* Partial_inplace. */
5379 0, /* Source mask */
5381 TRUE
), /* PC rel offset. */
5383 /* A 64 bit reference to a symbol. */
5384 HOWTO (ALPHA_R_REFQUAD
, /* Type. */
5385 0, /* Rightshift. */
5386 4, /* Size (0 = byte, 1 = short, 2 = long). */
5388 FALSE
, /* PC relative. */
5390 complain_overflow_bitfield
, /* Complain_on_overflow. */
5391 reloc_nil
, /* Special_function. */
5392 "REFQUAD", /* Name. */
5393 TRUE
, /* Partial_inplace. */
5394 MINUS_ONE
, /* Source mask. */
5395 MINUS_ONE
, /* Dest mask. */
5396 FALSE
), /* PC rel offset. */
5398 /* A 21 bit branch. The native assembler generates these for
5399 branches within the text segment, and also fills in the PC
5400 relative offset in the instruction. */
5401 HOWTO (ALPHA_R_BRADDR
, /* Type. */
5402 2, /* Rightshift. */
5403 2, /* Size (0 = byte, 1 = short, 2 = long). */
5405 TRUE
, /* PC relative. */
5407 complain_overflow_signed
, /* Complain_on_overflow. */
5408 reloc_nil
, /* Special_function. */
5409 "BRADDR", /* Name. */
5410 TRUE
, /* Partial_inplace. */
5411 0x1fffff, /* Source mask. */
5412 0x1fffff, /* Dest mask. */
5413 FALSE
), /* PC rel offset. */
5415 /* A hint for a jump to a register. */
5416 HOWTO (ALPHA_R_HINT
, /* Type. */
5417 2, /* Rightshift. */
5418 1, /* Size (0 = byte, 1 = short, 2 = long). */
5420 TRUE
, /* PC relative. */
5422 complain_overflow_dont
,/* Complain_on_overflow. */
5423 reloc_nil
, /* Special_function. */
5425 TRUE
, /* Partial_inplace. */
5426 0x3fff, /* Source mask. */
5427 0x3fff, /* Dest mask. */
5428 FALSE
), /* PC rel offset. */
5430 /* 16 bit PC relative offset. */
5431 HOWTO (ALPHA_R_SREL16
, /* Type. */
5432 0, /* Rightshift. */
5433 1, /* Size (0 = byte, 1 = short, 2 = long). */
5435 TRUE
, /* PC relative. */
5437 complain_overflow_signed
, /* Complain_on_overflow. */
5438 reloc_nil
, /* Special_function. */
5439 "SREL16", /* Name. */
5440 TRUE
, /* Partial_inplace. */
5441 0xffff, /* Source mask. */
5442 0xffff, /* Dest mask. */
5443 FALSE
), /* PC rel offset. */
5445 /* 32 bit PC relative offset. */
5446 HOWTO (ALPHA_R_SREL32
, /* Type. */
5447 0, /* Rightshift. */
5448 2, /* Size (0 = byte, 1 = short, 2 = long). */
5450 TRUE
, /* PC relative. */
5452 complain_overflow_signed
, /* Complain_on_overflow. */
5453 reloc_nil
, /* Special_function. */
5454 "SREL32", /* Name. */
5455 TRUE
, /* Partial_inplace. */
5456 0xffffffff, /* Source mask. */
5457 0xffffffff, /* Dest mask. */
5458 FALSE
), /* PC rel offset. */
5460 /* A 64 bit PC relative offset. */
5461 HOWTO (ALPHA_R_SREL64
, /* Type. */
5462 0, /* Rightshift. */
5463 4, /* Size (0 = byte, 1 = short, 2 = long). */
5465 TRUE
, /* PC relative. */
5467 complain_overflow_signed
, /* Complain_on_overflow. */
5468 reloc_nil
, /* Special_function. */
5469 "SREL64", /* Name. */
5470 TRUE
, /* Partial_inplace. */
5471 MINUS_ONE
, /* Source mask. */
5472 MINUS_ONE
, /* Dest mask. */
5473 FALSE
), /* PC rel offset. */
5475 /* Push a value on the reloc evaluation stack. */
5476 HOWTO (ALPHA_R_OP_PUSH
, /* Type. */
5477 0, /* Rightshift. */
5478 0, /* Size (0 = byte, 1 = short, 2 = long). */
5480 FALSE
, /* PC relative. */
5482 complain_overflow_dont
,/* Complain_on_overflow. */
5483 reloc_nil
, /* Special_function. */
5484 "OP_PUSH", /* Name. */
5485 FALSE
, /* Partial_inplace. */
5486 0, /* Source mask. */
5488 FALSE
), /* PC rel offset. */
5490 /* Store the value from the stack at the given address. Store it in
5491 a bitfield of size r_size starting at bit position r_offset. */
5492 HOWTO (ALPHA_R_OP_STORE
, /* Type. */
5493 0, /* Rightshift. */
5494 4, /* Size (0 = byte, 1 = short, 2 = long). */
5496 FALSE
, /* PC relative. */
5498 complain_overflow_dont
,/* Complain_on_overflow. */
5499 reloc_nil
, /* Special_function. */
5500 "OP_STORE", /* Name. */
5501 FALSE
, /* Partial_inplace. */
5502 0, /* Source mask. */
5503 MINUS_ONE
, /* Dest mask. */
5504 FALSE
), /* PC rel offset. */
5506 /* Subtract the reloc address from the value on the top of the
5507 relocation stack. */
5508 HOWTO (ALPHA_R_OP_PSUB
, /* Type. */
5509 0, /* Rightshift. */
5510 0, /* Size (0 = byte, 1 = short, 2 = long). */
5512 FALSE
, /* PC relative. */
5514 complain_overflow_dont
,/* Complain_on_overflow. */
5515 reloc_nil
, /* Special_function. */
5516 "OP_PSUB", /* Name. */
5517 FALSE
, /* Partial_inplace. */
5518 0, /* Source mask. */
5520 FALSE
), /* PC rel offset. */
5522 /* Shift the value on the top of the relocation stack right by the
5524 HOWTO (ALPHA_R_OP_PRSHIFT
, /* Type. */
5525 0, /* Rightshift. */
5526 0, /* Size (0 = byte, 1 = short, 2 = long). */
5528 FALSE
, /* PC relative. */
5530 complain_overflow_dont
,/* Complain_on_overflow. */
5531 reloc_nil
, /* Special_function. */
5532 "OP_PRSHIFT", /* Name. */
5533 FALSE
, /* Partial_inplace. */
5534 0, /* Source mask. */
5536 FALSE
), /* PC rel offset. */
5538 /* Hack. Linkage is done by linker. */
5539 HOWTO (ALPHA_R_LINKAGE
, /* Type. */
5540 0, /* Rightshift. */
5541 0, /* Size (0 = byte, 1 = short, 2 = long). */
5543 FALSE
, /* PC relative. */
5545 complain_overflow_dont
,/* Complain_on_overflow. */
5546 reloc_nil
, /* Special_function. */
5547 "LINKAGE", /* Name. */
5548 FALSE
, /* Partial_inplace. */
5549 0, /* Source mask. */
5551 FALSE
), /* PC rel offset. */
5553 /* A 32 bit reference to a symbol. */
5554 HOWTO (ALPHA_R_REFLONG
, /* Type. */
5555 0, /* Rightshift. */
5556 2, /* Size (0 = byte, 1 = short, 2 = long). */
5558 FALSE
, /* PC relative. */
5560 complain_overflow_bitfield
, /* Complain_on_overflow. */
5561 reloc_nil
, /* Special_function. */
5562 "REFLONG", /* Name. */
5563 TRUE
, /* Partial_inplace. */
5564 0xffffffff, /* Source mask. */
5565 0xffffffff, /* Dest mask. */
5566 FALSE
), /* PC rel offset. */
5568 /* A 64 bit reference to a procedure, written as 32 bit value. */
5569 HOWTO (ALPHA_R_CODEADDR
, /* Type. */
5570 0, /* Rightshift. */
5571 4, /* Size (0 = byte, 1 = short, 2 = long). */
5573 FALSE
, /* PC relative. */
5575 complain_overflow_signed
,/* Complain_on_overflow. */
5576 reloc_nil
, /* Special_function. */
5577 "CODEADDR", /* Name. */
5578 FALSE
, /* Partial_inplace. */
5579 0xffffffff, /* Source mask. */
5580 0xffffffff, /* Dest mask. */
5581 FALSE
), /* PC rel offset. */
5583 HOWTO (ALPHA_R_NOP
, /* Type. */
5584 0, /* Rightshift. */
5585 3, /* Size (0 = byte, 1 = short, 2 = long). */
5587 /* The following value must match that of ALPHA_R_BSR/ALPHA_R_BOH
5588 because the calculations for the 3 relocations are the same.
5589 See B.4.5.2 of the OpenVMS Linker Utility Manual. */
5590 TRUE
, /* PC relative. */
5592 complain_overflow_dont
,/* Complain_on_overflow. */
5593 reloc_nil
, /* Special_function. */
5595 FALSE
, /* Partial_inplace. */
5596 0xffffffff, /* Source mask. */
5597 0xffffffff, /* Dest mask. */
5598 FALSE
), /* PC rel offset. */
5600 HOWTO (ALPHA_R_BSR
, /* Type. */
5601 0, /* Rightshift. */
5602 3, /* Size (0 = byte, 1 = short, 2 = long). */
5604 TRUE
, /* PC relative. */
5606 complain_overflow_dont
,/* Complain_on_overflow. */
5607 reloc_nil
, /* Special_function. */
5609 FALSE
, /* Partial_inplace. */
5610 0xffffffff, /* Source mask. */
5611 0xffffffff, /* Dest mask. */
5612 FALSE
), /* PC rel offset. */
5614 HOWTO (ALPHA_R_LDA
, /* Type. */
5615 0, /* Rightshift. */
5616 3, /* Size (0 = byte, 1 = short, 2 = long). */
5618 FALSE
, /* PC relative. */
5620 complain_overflow_dont
,/* Complain_on_overflow. */
5621 reloc_nil
, /* Special_function. */
5623 FALSE
, /* Partial_inplace. */
5624 0xffffffff, /* Source mask. */
5625 0xffffffff, /* Dest mask. */
5626 FALSE
), /* PC rel offset. */
5628 HOWTO (ALPHA_R_BOH
, /* Type. */
5629 0, /* Rightshift. */
5630 3, /* Size (0 = byte, 1 = short, 2 = long, 3 = nil). */
5632 TRUE
, /* PC relative. */
5634 complain_overflow_dont
,/* Complain_on_overflow. */
5635 reloc_nil
, /* Special_function. */
5637 FALSE
, /* Partial_inplace. */
5638 0xffffffff, /* Source mask. */
5639 0xffffffff, /* Dest mask. */
5640 FALSE
), /* PC rel offset. */
5643 /* Return a pointer to a howto structure which, when invoked, will perform
5644 the relocation code on data from the architecture noted. */
5646 static reloc_howto_type
*
5647 alpha_vms_bfd_reloc_type_lookup (bfd
* abfd ATTRIBUTE_UNUSED
,
5648 bfd_reloc_code_real_type code
)
5652 vms_debug2 ((1, "vms_bfd_reloc_type_lookup (%p, %d)\t", abfd
, code
));
5656 case BFD_RELOC_16
: alpha_type
= ALPHA_R_SREL16
; break;
5657 case BFD_RELOC_32
: alpha_type
= ALPHA_R_REFLONG
; break;
5658 case BFD_RELOC_64
: alpha_type
= ALPHA_R_REFQUAD
; break;
5659 case BFD_RELOC_CTOR
: alpha_type
= ALPHA_R_REFQUAD
; break;
5660 case BFD_RELOC_23_PCREL_S2
: alpha_type
= ALPHA_R_BRADDR
; break;
5661 case BFD_RELOC_ALPHA_HINT
: alpha_type
= ALPHA_R_HINT
; break;
5662 case BFD_RELOC_16_PCREL
: alpha_type
= ALPHA_R_SREL16
; break;
5663 case BFD_RELOC_32_PCREL
: alpha_type
= ALPHA_R_SREL32
; break;
5664 case BFD_RELOC_64_PCREL
: alpha_type
= ALPHA_R_SREL64
; break;
5665 case BFD_RELOC_ALPHA_LINKAGE
: alpha_type
= ALPHA_R_LINKAGE
; break;
5666 case BFD_RELOC_ALPHA_CODEADDR
: alpha_type
= ALPHA_R_CODEADDR
; break;
5667 case BFD_RELOC_ALPHA_NOP
: alpha_type
= ALPHA_R_NOP
; break;
5668 case BFD_RELOC_ALPHA_BSR
: alpha_type
= ALPHA_R_BSR
; break;
5669 case BFD_RELOC_ALPHA_LDA
: alpha_type
= ALPHA_R_LDA
; break;
5670 case BFD_RELOC_ALPHA_BOH
: alpha_type
= ALPHA_R_BOH
; break;
5672 _bfd_error_handler (_("reloc (%d) is *UNKNOWN*"), code
);
5675 vms_debug2 ((2, "reloc is %s\n", alpha_howto_table
[alpha_type
].name
));
5676 return & alpha_howto_table
[alpha_type
];
5679 static reloc_howto_type
*
5680 alpha_vms_bfd_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
5686 i
< sizeof (alpha_howto_table
) / sizeof (alpha_howto_table
[0]);
5688 if (alpha_howto_table
[i
].name
!= NULL
5689 && strcasecmp (alpha_howto_table
[i
].name
, r_name
) == 0)
5690 return &alpha_howto_table
[i
];
5696 alpha_vms_get_synthetic_symtab (bfd
*abfd
,
5697 long symcount ATTRIBUTE_UNUSED
,
5698 asymbol
**usyms ATTRIBUTE_UNUSED
,
5699 long dynsymcount ATTRIBUTE_UNUSED
,
5700 asymbol
**dynsyms ATTRIBUTE_UNUSED
,
5707 syms
= (asymbol
*) bfd_malloc (PRIV (norm_sym_count
) * sizeof (asymbol
));
5712 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
5714 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
5725 flags
= BSF_LOCAL
| BSF_SYNTHETIC
;
5732 if ((e
->flags
& EGSY__V_DEF
) && (e
->flags
& EGSY__V_NORM
))
5734 value
= e
->code_value
;
5735 sec
= e
->code_section
;
5746 sname
= bfd_alloc (abfd
, l
+ 5);
5749 memcpy (sname
, name
, l
);
5750 memcpy (sname
+ l
, "..en", 5);
5757 sym
->udata
.p
= NULL
;
5766 vms_time_to_str (unsigned char *buf
)
5768 time_t t
= vms_rawtime_to_time_t (buf
);
5769 char *res
= ctime (&t
);
5772 res
= "*invalid time*";
5779 evax_bfd_print_emh (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5781 struct vms_emh_common
*emh
= (struct vms_emh_common
*)rec
;
5782 unsigned int subtype
;
5785 subtype
= (unsigned) bfd_getl16 (emh
->subtyp
);
5787 /* xgettext:c-format */
5788 fprintf (file
, _(" EMH %u (len=%u): "), subtype
, rec_len
);
5790 /* PR 21618: Check for invalid lengths. */
5791 if (rec_len
< sizeof (* emh
))
5793 fprintf (file
, _(" Error: The length is less than the length of an EMH record\n"));
5796 extra
= rec_len
- sizeof (struct vms_emh_common
);
5802 struct vms_emh_mhd
*mhd
= (struct vms_emh_mhd
*) rec
;
5804 const char * nextname
;
5805 const char * maxname
;
5807 /* PR 21840: Check for invalid lengths. */
5808 if (rec_len
< sizeof (* mhd
))
5810 fprintf (file
, _(" Error: The record length is less than the size of an EMH_MHD record\n"));
5813 fprintf (file
, _("Module header\n"));
5814 fprintf (file
, _(" structure level: %u\n"), mhd
->strlvl
);
5815 fprintf (file
, _(" max record size: %u\n"),
5816 (unsigned) bfd_getl32 (mhd
->recsiz
));
5817 name
= (char *)(mhd
+ 1);
5818 maxname
= (char *) rec
+ rec_len
;
5819 if (name
> maxname
- 2)
5821 fprintf (file
, _(" Error: The module name is missing\n"));
5824 nextname
= name
+ name
[0] + 1;
5825 if (nextname
>= maxname
)
5827 fprintf (file
, _(" Error: The module name is too long\n"));
5830 fprintf (file
, _(" module name : %.*s\n"), name
[0], name
+ 1);
5832 if (name
> maxname
- 2)
5834 fprintf (file
, _(" Error: The module version is missing\n"));
5837 nextname
= name
+ name
[0] + 1;
5838 if (nextname
>= maxname
)
5840 fprintf (file
, _(" Error: The module version is too long\n"));
5843 fprintf (file
, _(" module version : %.*s\n"), name
[0], name
+ 1);
5845 if ((maxname
- name
) < 17 && maxname
[-1] != 0)
5846 fprintf (file
, _(" Error: The compile date is truncated\n"));
5848 fprintf (file
, _(" compile date : %.17s\n"), name
);
5853 fprintf (file
, _("Language Processor Name\n"));
5854 fprintf (file
, _(" language name: %.*s\n"), extra
, (char *)(emh
+ 1));
5858 fprintf (file
, _("Source Files Header\n"));
5859 fprintf (file
, _(" file: %.*s\n"), extra
, (char *)(emh
+ 1));
5863 fprintf (file
, _("Title Text Header\n"));
5864 fprintf (file
, _(" title: %.*s\n"), extra
, (char *)(emh
+ 1));
5868 fprintf (file
, _("Copyright Header\n"));
5869 fprintf (file
, _(" copyright: %.*s\n"), extra
, (char *)(emh
+ 1));
5873 fprintf (file
, _("unhandled emh subtype %u\n"), subtype
);
5879 evax_bfd_print_eeom (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5881 struct vms_eeom
*eeom
= (struct vms_eeom
*)rec
;
5883 fprintf (file
, _(" EEOM (len=%u):\n"), rec_len
);
5885 /* PR 21618: Check for invalid lengths. */
5886 if (rec_len
< sizeof (* eeom
))
5888 fprintf (file
, _(" Error: The length is less than the length of an EEOM record\n"));
5892 fprintf (file
, _(" number of cond linkage pairs: %u\n"),
5893 (unsigned)bfd_getl32 (eeom
->total_lps
));
5894 fprintf (file
, _(" completion code: %u\n"),
5895 (unsigned)bfd_getl16 (eeom
->comcod
));
5898 fprintf (file
, _(" transfer addr flags: 0x%02x\n"), eeom
->tfrflg
);
5899 fprintf (file
, _(" transfer addr psect: %u\n"),
5900 (unsigned)bfd_getl32 (eeom
->psindx
));
5901 fprintf (file
, _(" transfer address : 0x%08x\n"),
5902 (unsigned)bfd_getl32 (eeom
->tfradr
));
5907 exav_bfd_print_egsy_flags (unsigned int flags
, FILE *file
)
5909 if (flags
& EGSY__V_WEAK
)
5910 fputs (_(" WEAK"), file
);
5911 if (flags
& EGSY__V_DEF
)
5912 fputs (_(" DEF"), file
);
5913 if (flags
& EGSY__V_UNI
)
5914 fputs (_(" UNI"), file
);
5915 if (flags
& EGSY__V_REL
)
5916 fputs (_(" REL"), file
);
5917 if (flags
& EGSY__V_COMM
)
5918 fputs (_(" COMM"), file
);
5919 if (flags
& EGSY__V_VECEP
)
5920 fputs (_(" VECEP"), file
);
5921 if (flags
& EGSY__V_NORM
)
5922 fputs (_(" NORM"), file
);
5923 if (flags
& EGSY__V_QUAD_VAL
)
5924 fputs (_(" QVAL"), file
);
5928 evax_bfd_print_egsd_flags (FILE *file
, unsigned int flags
)
5930 if (flags
& EGPS__V_PIC
)
5931 fputs (_(" PIC"), file
);
5932 if (flags
& EGPS__V_LIB
)
5933 fputs (_(" LIB"), file
);
5934 if (flags
& EGPS__V_OVR
)
5935 fputs (_(" OVR"), file
);
5936 if (flags
& EGPS__V_REL
)
5937 fputs (_(" REL"), file
);
5938 if (flags
& EGPS__V_GBL
)
5939 fputs (_(" GBL"), file
);
5940 if (flags
& EGPS__V_SHR
)
5941 fputs (_(" SHR"), file
);
5942 if (flags
& EGPS__V_EXE
)
5943 fputs (_(" EXE"), file
);
5944 if (flags
& EGPS__V_RD
)
5945 fputs (_(" RD"), file
);
5946 if (flags
& EGPS__V_WRT
)
5947 fputs (_(" WRT"), file
);
5948 if (flags
& EGPS__V_VEC
)
5949 fputs (_(" VEC"), file
);
5950 if (flags
& EGPS__V_NOMOD
)
5951 fputs (_(" NOMOD"), file
);
5952 if (flags
& EGPS__V_COM
)
5953 fputs (_(" COM"), file
);
5954 if (flags
& EGPS__V_ALLOC_64BIT
)
5955 fputs (_(" 64B"), file
);
5959 evax_bfd_print_egsd (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5961 unsigned int off
= sizeof (struct vms_egsd
);
5964 fprintf (file
, _(" EGSD (len=%u):\n"), rec_len
);
5967 for (off
= sizeof (struct vms_egsd
); off
< rec_len
; )
5969 struct vms_egsd_entry
*e
= (struct vms_egsd_entry
*)(rec
+ off
);
5973 type
= (unsigned)bfd_getl16 (e
->gsdtyp
);
5974 len
= (unsigned)bfd_getl16 (e
->gsdsiz
);
5976 /* xgettext:c-format */
5977 fprintf (file
, _(" EGSD entry %2u (type: %u, len: %u): "),
5981 if (off
+ len
> rec_len
|| off
+ len
< off
)
5983 fprintf (file
, _(" Error: length larger than remaining space in record\n"));
5991 struct vms_egps
*egps
= (struct vms_egps
*)e
;
5992 unsigned int flags
= bfd_getl16 (egps
->flags
);
5995 fprintf (file
, _("PSC - Program section definition\n"));
5996 fprintf (file
, _(" alignment : 2**%u\n"), egps
->align
);
5997 fprintf (file
, _(" flags : 0x%04x"), flags
);
5998 evax_bfd_print_egsd_flags (file
, flags
);
6000 l
= bfd_getl32 (egps
->alloc
);
6001 fprintf (file
, _(" alloc (len): %u (0x%08x)\n"), l
, l
);
6002 fprintf (file
, _(" name : %.*s\n"),
6003 egps
->namlng
, egps
->name
);
6008 struct vms_esgps
*esgps
= (struct vms_esgps
*)e
;
6009 unsigned int flags
= bfd_getl16 (esgps
->flags
);
6012 fprintf (file
, _("SPSC - Shared Image Program section def\n"));
6013 fprintf (file
, _(" alignment : 2**%u\n"), esgps
->align
);
6014 fprintf (file
, _(" flags : 0x%04x"), flags
);
6015 evax_bfd_print_egsd_flags (file
, flags
);
6017 l
= bfd_getl32 (esgps
->alloc
);
6018 fprintf (file
, _(" alloc (len) : %u (0x%08x)\n"), l
, l
);
6019 fprintf (file
, _(" image offset : 0x%08x\n"),
6020 (unsigned int)bfd_getl32 (esgps
->base
));
6021 fprintf (file
, _(" symvec offset : 0x%08x\n"),
6022 (unsigned int)bfd_getl32 (esgps
->value
));
6023 fprintf (file
, _(" name : %.*s\n"),
6024 esgps
->namlng
, esgps
->name
);
6029 struct vms_egsy
*egsy
= (struct vms_egsy
*)e
;
6030 unsigned int flags
= bfd_getl16 (egsy
->flags
);
6032 if (flags
& EGSY__V_DEF
)
6034 struct vms_esdf
*esdf
= (struct vms_esdf
*)e
;
6036 fprintf (file
, _("SYM - Global symbol definition\n"));
6037 fprintf (file
, _(" flags: 0x%04x"), flags
);
6038 exav_bfd_print_egsy_flags (flags
, file
);
6040 fprintf (file
, _(" psect offset: 0x%08x\n"),
6041 (unsigned)bfd_getl32 (esdf
->value
));
6042 if (flags
& EGSY__V_NORM
)
6044 fprintf (file
, _(" code address: 0x%08x\n"),
6045 (unsigned)bfd_getl32 (esdf
->code_address
));
6046 fprintf (file
, _(" psect index for entry point : %u\n"),
6047 (unsigned)bfd_getl32 (esdf
->ca_psindx
));
6049 fprintf (file
, _(" psect index : %u\n"),
6050 (unsigned)bfd_getl32 (esdf
->psindx
));
6051 fprintf (file
, _(" name : %.*s\n"),
6052 esdf
->namlng
, esdf
->name
);
6056 struct vms_esrf
*esrf
= (struct vms_esrf
*)e
;
6058 fprintf (file
, _("SYM - Global symbol reference\n"));
6059 fprintf (file
, _(" name : %.*s\n"),
6060 esrf
->namlng
, esrf
->name
);
6066 struct vms_eidc
*eidc
= (struct vms_eidc
*)e
;
6067 unsigned int flags
= bfd_getl32 (eidc
->flags
);
6070 fprintf (file
, _("IDC - Ident Consistency check\n"));
6071 fprintf (file
, _(" flags : 0x%08x"), flags
);
6072 if (flags
& EIDC__V_BINIDENT
)
6073 fputs (" BINDENT", file
);
6075 fprintf (file
, _(" id match : %x\n"),
6076 (flags
>> EIDC__V_IDMATCH_SH
) & EIDC__V_IDMATCH_MASK
);
6077 fprintf (file
, _(" error severity: %x\n"),
6078 (flags
>> EIDC__V_ERRSEV_SH
) & EIDC__V_ERRSEV_MASK
);
6080 fprintf (file
, _(" entity name : %.*s\n"), p
[0], p
+ 1);
6082 fprintf (file
, _(" object name : %.*s\n"), p
[0], p
+ 1);
6084 if (flags
& EIDC__V_BINIDENT
)
6085 fprintf (file
, _(" binary ident : 0x%08x\n"),
6086 (unsigned)bfd_getl32 (p
+ 1));
6088 fprintf (file
, _(" ascii ident : %.*s\n"), p
[0], p
+ 1);
6093 struct vms_egst
*egst
= (struct vms_egst
*)e
;
6094 unsigned int flags
= bfd_getl16 (egst
->header
.flags
);
6096 fprintf (file
, _("SYMG - Universal symbol definition\n"));
6097 fprintf (file
, _(" flags: 0x%04x"), flags
);
6098 exav_bfd_print_egsy_flags (flags
, file
);
6100 fprintf (file
, _(" symbol vector offset: 0x%08x\n"),
6101 (unsigned)bfd_getl32 (egst
->value
));
6102 fprintf (file
, _(" entry point: 0x%08x\n"),
6103 (unsigned)bfd_getl32 (egst
->lp_1
));
6104 fprintf (file
, _(" proc descr : 0x%08x\n"),
6105 (unsigned)bfd_getl32 (egst
->lp_2
));
6106 fprintf (file
, _(" psect index: %u\n"),
6107 (unsigned)bfd_getl32 (egst
->psindx
));
6108 fprintf (file
, _(" name : %.*s\n"),
6109 egst
->namlng
, egst
->name
);
6114 struct vms_esdfv
*esdfv
= (struct vms_esdfv
*)e
;
6115 unsigned int flags
= bfd_getl16 (esdfv
->flags
);
6117 fprintf (file
, _("SYMV - Vectored symbol definition\n"));
6118 fprintf (file
, _(" flags: 0x%04x"), flags
);
6119 exav_bfd_print_egsy_flags (flags
, file
);
6121 fprintf (file
, _(" vector : 0x%08x\n"),
6122 (unsigned)bfd_getl32 (esdfv
->vector
));
6123 fprintf (file
, _(" psect offset: %u\n"),
6124 (unsigned)bfd_getl32 (esdfv
->value
));
6125 fprintf (file
, _(" psect index : %u\n"),
6126 (unsigned)bfd_getl32 (esdfv
->psindx
));
6127 fprintf (file
, _(" name : %.*s\n"),
6128 esdfv
->namlng
, esdfv
->name
);
6133 struct vms_esdfm
*esdfm
= (struct vms_esdfm
*)e
;
6134 unsigned int flags
= bfd_getl16 (esdfm
->flags
);
6136 fprintf (file
, _("SYMM - Global symbol definition with version\n"));
6137 fprintf (file
, _(" flags: 0x%04x"), flags
);
6138 exav_bfd_print_egsy_flags (flags
, file
);
6140 fprintf (file
, _(" version mask: 0x%08x\n"),
6141 (unsigned)bfd_getl32 (esdfm
->version_mask
));
6142 fprintf (file
, _(" psect offset: %u\n"),
6143 (unsigned)bfd_getl32 (esdfm
->value
));
6144 fprintf (file
, _(" psect index : %u\n"),
6145 (unsigned)bfd_getl32 (esdfm
->psindx
));
6146 fprintf (file
, _(" name : %.*s\n"),
6147 esdfm
->namlng
, esdfm
->name
);
6151 fprintf (file
, _("unhandled egsd entry type %u\n"), type
);
6159 evax_bfd_print_hex (FILE *file
, const char *pfx
,
6160 const unsigned char *buf
, unsigned int len
)
6166 for (i
= 0; i
< len
; i
++)
6170 fprintf (file
, " %02x", buf
[i
]);
6183 evax_bfd_print_etir_stc_ir (FILE *file
, const unsigned char *buf
, int is_ps
)
6185 /* xgettext:c-format */
6186 fprintf (file
, _(" linkage index: %u, replacement insn: 0x%08x\n"),
6187 (unsigned)bfd_getl32 (buf
),
6188 (unsigned)bfd_getl32 (buf
+ 16));
6189 /* xgettext:c-format */
6190 fprintf (file
, _(" psect idx 1: %u, offset 1: 0x%08x %08x\n"),
6191 (unsigned)bfd_getl32 (buf
+ 4),
6192 (unsigned)bfd_getl32 (buf
+ 12),
6193 (unsigned)bfd_getl32 (buf
+ 8));
6194 /* xgettext:c-format */
6195 fprintf (file
, _(" psect idx 2: %u, offset 2: 0x%08x %08x\n"),
6196 (unsigned)bfd_getl32 (buf
+ 20),
6197 (unsigned)bfd_getl32 (buf
+ 28),
6198 (unsigned)bfd_getl32 (buf
+ 24));
6200 /* xgettext:c-format */
6201 fprintf (file
, _(" psect idx 3: %u, offset 3: 0x%08x %08x\n"),
6202 (unsigned)bfd_getl32 (buf
+ 32),
6203 (unsigned)bfd_getl32 (buf
+ 40),
6204 (unsigned)bfd_getl32 (buf
+ 36));
6206 fprintf (file
, _(" global name: %.*s\n"), buf
[32], buf
+ 33);
6210 evax_bfd_print_etir (FILE *file
, const char *name
,
6211 unsigned char *rec
, unsigned int rec_len
)
6213 unsigned int off
= sizeof (struct vms_egsd
);
6214 unsigned int sec_len
= 0;
6216 /* xgettext:c-format */
6217 fprintf (file
, _(" %s (len=%u+%u):\n"), name
,
6218 (unsigned)(rec_len
- sizeof (struct vms_eobjrec
)),
6219 (unsigned)sizeof (struct vms_eobjrec
));
6221 for (off
= sizeof (struct vms_eobjrec
); off
< rec_len
; )
6223 struct vms_etir
*etir
= (struct vms_etir
*)(rec
+ off
);
6228 type
= bfd_getl16 (etir
->rectyp
);
6229 size
= bfd_getl16 (etir
->size
);
6230 buf
= rec
+ off
+ sizeof (struct vms_etir
);
6232 if (off
+ size
> rec_len
|| off
+ size
< off
)
6234 fprintf (file
, _(" Error: length larger than remaining space in record\n"));
6238 /* xgettext:c-format */
6239 fprintf (file
, _(" (type: %3u, size: 4+%3u): "), type
, size
- 4);
6242 case ETIR__C_STA_GBL
:
6243 fprintf (file
, _("STA_GBL (stack global) %.*s\n"),
6246 case ETIR__C_STA_LW
:
6247 fprintf (file
, _("STA_LW (stack longword) 0x%08x\n"),
6248 (unsigned)bfd_getl32 (buf
));
6250 case ETIR__C_STA_QW
:
6251 fprintf (file
, _("STA_QW (stack quadword) 0x%08x %08x\n"),
6252 (unsigned)bfd_getl32 (buf
+ 4),
6253 (unsigned)bfd_getl32 (buf
+ 0));
6255 case ETIR__C_STA_PQ
:
6256 fprintf (file
, _("STA_PQ (stack psect base + offset)\n"));
6257 /* xgettext:c-format */
6258 fprintf (file
, _(" psect: %u, offset: 0x%08x %08x\n"),
6259 (unsigned)bfd_getl32 (buf
+ 0),
6260 (unsigned)bfd_getl32 (buf
+ 8),
6261 (unsigned)bfd_getl32 (buf
+ 4));
6263 case ETIR__C_STA_LI
:
6264 fprintf (file
, _("STA_LI (stack literal)\n"));
6266 case ETIR__C_STA_MOD
:
6267 fprintf (file
, _("STA_MOD (stack module)\n"));
6269 case ETIR__C_STA_CKARG
:
6270 fprintf (file
, _("STA_CKARG (compare procedure argument)\n"));
6274 fprintf (file
, _("STO_B (store byte)\n"));
6277 fprintf (file
, _("STO_W (store word)\n"));
6279 case ETIR__C_STO_LW
:
6280 fprintf (file
, _("STO_LW (store longword)\n"));
6282 case ETIR__C_STO_QW
:
6283 fprintf (file
, _("STO_QW (store quadword)\n"));
6285 case ETIR__C_STO_IMMR
:
6287 unsigned int len
= bfd_getl32 (buf
);
6289 _("STO_IMMR (store immediate repeat) %u bytes\n"),
6291 evax_bfd_print_hex (file
, " ", buf
+ 4, len
);
6295 case ETIR__C_STO_GBL
:
6296 fprintf (file
, _("STO_GBL (store global) %.*s\n"),
6299 case ETIR__C_STO_CA
:
6300 fprintf (file
, _("STO_CA (store code address) %.*s\n"),
6303 case ETIR__C_STO_RB
:
6304 fprintf (file
, _("STO_RB (store relative branch)\n"));
6306 case ETIR__C_STO_AB
:
6307 fprintf (file
, _("STO_AB (store absolute branch)\n"));
6309 case ETIR__C_STO_OFF
:
6310 fprintf (file
, _("STO_OFF (store offset to psect)\n"));
6312 case ETIR__C_STO_IMM
:
6314 unsigned int len
= bfd_getl32 (buf
);
6316 _("STO_IMM (store immediate) %u bytes\n"),
6318 evax_bfd_print_hex (file
, " ", buf
+ 4, len
);
6322 case ETIR__C_STO_GBL_LW
:
6323 fprintf (file
, _("STO_GBL_LW (store global longword) %.*s\n"),
6326 case ETIR__C_STO_LP_PSB
:
6327 fprintf (file
, _("STO_OFF (store LP with procedure signature)\n"));
6329 case ETIR__C_STO_HINT_GBL
:
6330 fprintf (file
, _("STO_BR_GBL (store branch global) *todo*\n"));
6332 case ETIR__C_STO_HINT_PS
:
6333 fprintf (file
, _("STO_BR_PS (store branch psect + offset) *todo*\n"));
6336 case ETIR__C_OPR_NOP
:
6337 fprintf (file
, _("OPR_NOP (no-operation)\n"));
6339 case ETIR__C_OPR_ADD
:
6340 fprintf (file
, _("OPR_ADD (add)\n"));
6342 case ETIR__C_OPR_SUB
:
6343 fprintf (file
, _("OPR_SUB (subtract)\n"));
6345 case ETIR__C_OPR_MUL
:
6346 fprintf (file
, _("OPR_MUL (multiply)\n"));
6348 case ETIR__C_OPR_DIV
:
6349 fprintf (file
, _("OPR_DIV (divide)\n"));
6351 case ETIR__C_OPR_AND
:
6352 fprintf (file
, _("OPR_AND (logical and)\n"));
6354 case ETIR__C_OPR_IOR
:
6355 fprintf (file
, _("OPR_IOR (logical inclusive or)\n"));
6357 case ETIR__C_OPR_EOR
:
6358 fprintf (file
, _("OPR_EOR (logical exclusive or)\n"));
6360 case ETIR__C_OPR_NEG
:
6361 fprintf (file
, _("OPR_NEG (negate)\n"));
6363 case ETIR__C_OPR_COM
:
6364 fprintf (file
, _("OPR_COM (complement)\n"));
6366 case ETIR__C_OPR_INSV
:
6367 fprintf (file
, _("OPR_INSV (insert field)\n"));
6369 case ETIR__C_OPR_ASH
:
6370 fprintf (file
, _("OPR_ASH (arithmetic shift)\n"));
6372 case ETIR__C_OPR_USH
:
6373 fprintf (file
, _("OPR_USH (unsigned shift)\n"));
6375 case ETIR__C_OPR_ROT
:
6376 fprintf (file
, _("OPR_ROT (rotate)\n"));
6378 case ETIR__C_OPR_SEL
:
6379 fprintf (file
, _("OPR_SEL (select)\n"));
6381 case ETIR__C_OPR_REDEF
:
6382 fprintf (file
, _("OPR_REDEF (redefine symbol to curr location)\n"));
6384 case ETIR__C_OPR_DFLIT
:
6385 fprintf (file
, _("OPR_REDEF (define a literal)\n"));
6388 case ETIR__C_STC_LP
:
6389 fprintf (file
, _("STC_LP (store cond linkage pair)\n"));
6391 case ETIR__C_STC_LP_PSB
:
6393 _("STC_LP_PSB (store cond linkage pair + signature)\n"));
6394 /* xgettext:c-format */
6395 fprintf (file
, _(" linkage index: %u, procedure: %.*s\n"),
6396 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6397 buf
+= 4 + 1 + buf
[4];
6398 fprintf (file
, _(" signature: %.*s\n"), buf
[0], buf
+ 1);
6400 case ETIR__C_STC_GBL
:
6401 fprintf (file
, _("STC_GBL (store cond global)\n"));
6402 /* xgettext:c-format */
6403 fprintf (file
, _(" linkage index: %u, global: %.*s\n"),
6404 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6406 case ETIR__C_STC_GCA
:
6407 fprintf (file
, _("STC_GCA (store cond code address)\n"));
6408 /* xgettext:c-format */
6409 fprintf (file
, _(" linkage index: %u, procedure name: %.*s\n"),
6410 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6412 case ETIR__C_STC_PS
:
6413 fprintf (file
, _("STC_PS (store cond psect + offset)\n"));
6415 /* xgettext:c-format */
6416 _(" linkage index: %u, psect: %u, offset: 0x%08x %08x\n"),
6417 (unsigned)bfd_getl32 (buf
),
6418 (unsigned)bfd_getl32 (buf
+ 4),
6419 (unsigned)bfd_getl32 (buf
+ 12),
6420 (unsigned)bfd_getl32 (buf
+ 8));
6422 case ETIR__C_STC_NOP_GBL
:
6423 fprintf (file
, _("STC_NOP_GBL (store cond NOP at global addr)\n"));
6424 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6426 case ETIR__C_STC_NOP_PS
:
6427 fprintf (file
, _("STC_NOP_PS (store cond NOP at psect + offset)\n"));
6428 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6430 case ETIR__C_STC_BSR_GBL
:
6431 fprintf (file
, _("STC_BSR_GBL (store cond BSR at global addr)\n"));
6432 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6434 case ETIR__C_STC_BSR_PS
:
6435 fprintf (file
, _("STC_BSR_PS (store cond BSR at psect + offset)\n"));
6436 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6438 case ETIR__C_STC_LDA_GBL
:
6439 fprintf (file
, _("STC_LDA_GBL (store cond LDA at global addr)\n"));
6440 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6442 case ETIR__C_STC_LDA_PS
:
6443 fprintf (file
, _("STC_LDA_PS (store cond LDA at psect + offset)\n"));
6444 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6446 case ETIR__C_STC_BOH_GBL
:
6447 fprintf (file
, _("STC_BOH_GBL (store cond BOH at global addr)\n"));
6448 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6450 case ETIR__C_STC_BOH_PS
:
6451 fprintf (file
, _("STC_BOH_PS (store cond BOH at psect + offset)\n"));
6452 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6454 case ETIR__C_STC_NBH_GBL
:
6456 _("STC_NBH_GBL (store cond or hint at global addr)\n"));
6458 case ETIR__C_STC_NBH_PS
:
6460 _("STC_NBH_PS (store cond or hint at psect + offset)\n"));
6463 case ETIR__C_CTL_SETRB
:
6464 fprintf (file
, _("CTL_SETRB (set relocation base)\n"));
6467 case ETIR__C_CTL_AUGRB
:
6469 unsigned int val
= bfd_getl32 (buf
);
6470 fprintf (file
, _("CTL_AUGRB (augment relocation base) %u\n"), val
);
6473 case ETIR__C_CTL_DFLOC
:
6474 fprintf (file
, _("CTL_DFLOC (define location)\n"));
6476 case ETIR__C_CTL_STLOC
:
6477 fprintf (file
, _("CTL_STLOC (set location)\n"));
6479 case ETIR__C_CTL_STKDL
:
6480 fprintf (file
, _("CTL_STKDL (stack defined location)\n"));
6483 fprintf (file
, _("*unhandled*\n"));
6491 evax_bfd_print_eobj (struct bfd
*abfd
, FILE *file
)
6493 bfd_boolean is_first
= TRUE
;
6494 bfd_boolean has_records
= FALSE
;
6498 unsigned int rec_len
;
6499 unsigned int pad_len
;
6501 unsigned int hdr_size
;
6506 unsigned char buf
[6];
6511 if (bfd_bread (buf
, sizeof (buf
), abfd
) != sizeof (buf
))
6513 fprintf (file
, _("cannot read GST record length\n"));
6516 rec_len
= bfd_getl16 (buf
+ 0);
6517 if (rec_len
== bfd_getl16 (buf
+ 4)
6518 && bfd_getl16 (buf
+ 2) == EOBJ__C_EMH
)
6520 /* The format is raw: record-size, type, record-size. */
6522 pad_len
= (rec_len
+ 1) & ~1U;
6525 else if (rec_len
== EOBJ__C_EMH
)
6527 has_records
= FALSE
;
6528 pad_len
= bfd_getl16 (buf
+ 2);
6534 fprintf (file
, _("cannot find EMH in first GST record\n"));
6537 rec
= bfd_malloc (pad_len
);
6538 memcpy (rec
, buf
+ sizeof (buf
) - hdr_size
, hdr_size
);
6542 unsigned int rec_len2
= 0;
6543 unsigned char hdr
[4];
6547 unsigned char buf_len
[2];
6549 if (bfd_bread (buf_len
, sizeof (buf_len
), abfd
)
6550 != sizeof (buf_len
))
6552 fprintf (file
, _("cannot read GST record length\n"));
6555 rec_len2
= (unsigned)bfd_getl16 (buf_len
);
6558 if (bfd_bread (hdr
, sizeof (hdr
), abfd
) != sizeof (hdr
))
6560 fprintf (file
, _("cannot read GST record header\n"));
6563 rec_len
= (unsigned)bfd_getl16 (hdr
+ 2);
6565 pad_len
= (rec_len
+ 1) & ~1U;
6568 rec
= bfd_malloc (pad_len
);
6569 memcpy (rec
, hdr
, sizeof (hdr
));
6570 hdr_size
= sizeof (hdr
);
6571 if (has_records
&& rec_len2
!= rec_len
)
6573 fprintf (file
, _(" corrupted GST\n"));
6578 if (bfd_bread (rec
+ hdr_size
, pad_len
- hdr_size
, abfd
)
6579 != pad_len
- hdr_size
)
6581 fprintf (file
, _("cannot read GST record\n"));
6585 type
= (unsigned)bfd_getl16 (rec
);
6590 evax_bfd_print_emh (file
, rec
, rec_len
);
6593 evax_bfd_print_egsd (file
, rec
, rec_len
);
6596 evax_bfd_print_eeom (file
, rec
, rec_len
);
6601 evax_bfd_print_etir (file
, "ETIR", rec
, rec_len
);
6604 evax_bfd_print_etir (file
, "EDBG", rec
, rec_len
);
6607 evax_bfd_print_etir (file
, "ETBT", rec
, rec_len
);
6610 fprintf (file
, _(" unhandled EOBJ record type %u\n"), type
);
6618 evax_bfd_print_relocation_records (FILE *file
, const unsigned char *rel
,
6619 unsigned int stride
)
6627 count
= bfd_getl32 (rel
+ 0);
6631 base
= bfd_getl32 (rel
+ 4);
6633 /* xgettext:c-format */
6634 fprintf (file
, _(" bitcount: %u, base addr: 0x%08x\n"),
6638 for (j
= 0; count
> 0; j
+= 4, count
-= 32)
6644 val
= bfd_getl32 (rel
);
6647 /* xgettext:c-format */
6648 fprintf (file
, _(" bitmap: 0x%08x (count: %u):\n"), val
, count
);
6650 for (k
= 0; k
< 32; k
++)
6655 fprintf (file
, _(" %08x"), base
+ (j
* 8 + k
) * stride
);
6670 evax_bfd_print_address_fixups (FILE *file
, const unsigned char *rel
)
6677 count
= bfd_getl32 (rel
+ 0);
6680 /* xgettext:c-format */
6681 fprintf (file
, _(" image %u (%u entries)\n"),
6682 (unsigned)bfd_getl32 (rel
+ 4), count
);
6684 for (j
= 0; j
< count
; j
++)
6686 /* xgettext:c-format */
6687 fprintf (file
, _(" offset: 0x%08x, val: 0x%08x\n"),
6688 (unsigned)bfd_getl32 (rel
+ 0),
6689 (unsigned)bfd_getl32 (rel
+ 4));
6696 evax_bfd_print_reference_fixups (FILE *file
, const unsigned char *rel
)
6705 count
= bfd_getl32 (rel
+ 0);
6708 /* xgettext:c-format */
6709 fprintf (file
, _(" image %u (%u entries), offsets:\n"),
6710 (unsigned)bfd_getl32 (rel
+ 4), count
);
6712 for (j
= 0; j
< count
; j
++)
6716 fprintf (file
, _(" 0x%08x"), (unsigned)bfd_getl32 (rel
));
6731 evax_bfd_print_indent (int indent
, FILE *file
)
6733 for (; indent
; indent
--)
6738 evax_bfd_get_dsc_name (unsigned int v
)
6742 case DSC__K_DTYPE_Z
:
6743 return "Z (Unspecified)";
6744 case DSC__K_DTYPE_V
:
6746 case DSC__K_DTYPE_BU
:
6747 return "BU (Byte logical)";
6748 case DSC__K_DTYPE_WU
:
6749 return "WU (Word logical)";
6750 case DSC__K_DTYPE_LU
:
6751 return "LU (Longword logical)";
6752 case DSC__K_DTYPE_QU
:
6753 return "QU (Quadword logical)";
6754 case DSC__K_DTYPE_B
:
6755 return "B (Byte integer)";
6756 case DSC__K_DTYPE_W
:
6757 return "W (Word integer)";
6758 case DSC__K_DTYPE_L
:
6759 return "L (Longword integer)";
6760 case DSC__K_DTYPE_Q
:
6761 return "Q (Quadword integer)";
6762 case DSC__K_DTYPE_F
:
6763 return "F (Single-precision floating)";
6764 case DSC__K_DTYPE_D
:
6765 return "D (Double-precision floating)";
6766 case DSC__K_DTYPE_FC
:
6767 return "FC (Complex)";
6768 case DSC__K_DTYPE_DC
:
6769 return "DC (Double-precision Complex)";
6770 case DSC__K_DTYPE_T
:
6771 return "T (ASCII text string)";
6772 case DSC__K_DTYPE_NU
:
6773 return "NU (Numeric string, unsigned)";
6774 case DSC__K_DTYPE_NL
:
6775 return "NL (Numeric string, left separate sign)";
6776 case DSC__K_DTYPE_NLO
:
6777 return "NLO (Numeric string, left overpunched sign)";
6778 case DSC__K_DTYPE_NR
:
6779 return "NR (Numeric string, right separate sign)";
6780 case DSC__K_DTYPE_NRO
:
6781 return "NRO (Numeric string, right overpunched sig)";
6782 case DSC__K_DTYPE_NZ
:
6783 return "NZ (Numeric string, zoned sign)";
6784 case DSC__K_DTYPE_P
:
6785 return "P (Packed decimal string)";
6786 case DSC__K_DTYPE_ZI
:
6787 return "ZI (Sequence of instructions)";
6788 case DSC__K_DTYPE_ZEM
:
6789 return "ZEM (Procedure entry mask)";
6790 case DSC__K_DTYPE_DSC
:
6791 return "DSC (Descriptor, used for arrays of dyn strings)";
6792 case DSC__K_DTYPE_OU
:
6793 return "OU (Octaword logical)";
6794 case DSC__K_DTYPE_O
:
6795 return "O (Octaword integer)";
6796 case DSC__K_DTYPE_G
:
6797 return "G (Double precision G floating, 64 bit)";
6798 case DSC__K_DTYPE_H
:
6799 return "H (Quadruple precision floating, 128 bit)";
6800 case DSC__K_DTYPE_GC
:
6801 return "GC (Double precision complex, G floating)";
6802 case DSC__K_DTYPE_HC
:
6803 return "HC (Quadruple precision complex, H floating)";
6804 case DSC__K_DTYPE_CIT
:
6805 return "CIT (COBOL intermediate temporary)";
6806 case DSC__K_DTYPE_BPV
:
6807 return "BPV (Bound Procedure Value)";
6808 case DSC__K_DTYPE_BLV
:
6809 return "BLV (Bound Label Value)";
6810 case DSC__K_DTYPE_VU
:
6811 return "VU (Bit Unaligned)";
6812 case DSC__K_DTYPE_ADT
:
6813 return "ADT (Absolute Date-Time)";
6814 case DSC__K_DTYPE_VT
:
6815 return "VT (Varying Text)";
6816 case DSC__K_DTYPE_T2
:
6817 return "T2 (16-bit char)";
6818 case DSC__K_DTYPE_VT2
:
6819 return "VT2 (16-bit varying char)";
6821 return "?? (unknown)";
6826 evax_bfd_print_desc (const unsigned char *buf
, int indent
, FILE *file
)
6828 unsigned char bclass
= buf
[3];
6829 unsigned char dtype
= buf
[2];
6830 unsigned int len
= (unsigned)bfd_getl16 (buf
);
6831 unsigned int pointer
= (unsigned)bfd_getl32 (buf
+ 4);
6833 evax_bfd_print_indent (indent
, file
);
6835 if (len
== 1 && pointer
== 0xffffffffUL
)
6838 fprintf (file
, _("64 bits *unhandled*\n"));
6842 /* xgettext:c-format */
6843 fprintf (file
, _("class: %u, dtype: %u, length: %u, pointer: 0x%08x\n"),
6844 bclass
, dtype
, len
, pointer
);
6847 case DSC__K_CLASS_NCA
:
6849 const struct vms_dsc_nca
*dsc
= (const void *)buf
;
6851 const unsigned char *b
;
6853 evax_bfd_print_indent (indent
, file
);
6854 fprintf (file
, _("non-contiguous array of %s\n"),
6855 evax_bfd_get_dsc_name (dsc
->dtype
));
6856 evax_bfd_print_indent (indent
+ 1, file
);
6858 /* xgettext:c-format */
6859 _("dimct: %u, aflags: 0x%02x, digits: %u, scale: %u\n"),
6860 dsc
->dimct
, dsc
->aflags
, dsc
->digits
, dsc
->scale
);
6861 evax_bfd_print_indent (indent
+ 1, file
);
6863 /* xgettext:c-format */
6864 _("arsize: %u, a0: 0x%08x\n"),
6865 (unsigned)bfd_getl32 (dsc
->arsize
),
6866 (unsigned)bfd_getl32 (dsc
->a0
));
6867 evax_bfd_print_indent (indent
+ 1, file
);
6868 fprintf (file
, _("Strides:\n"));
6869 b
= buf
+ sizeof (*dsc
);
6870 for (i
= 0; i
< dsc
->dimct
; i
++)
6872 evax_bfd_print_indent (indent
+ 2, file
);
6873 fprintf (file
, "[%u]: %u\n", i
+ 1,
6874 (unsigned)bfd_getl32 (b
));
6877 evax_bfd_print_indent (indent
+ 1, file
);
6878 fprintf (file
, _("Bounds:\n"));
6879 b
= buf
+ sizeof (*dsc
);
6880 for (i
= 0; i
< dsc
->dimct
; i
++)
6882 evax_bfd_print_indent (indent
+ 2, file
);
6883 /* xgettext:c-format */
6884 fprintf (file
, _("[%u]: Lower: %u, upper: %u\n"), i
+ 1,
6885 (unsigned)bfd_getl32 (b
+ 0),
6886 (unsigned)bfd_getl32 (b
+ 4));
6891 case DSC__K_CLASS_UBS
:
6893 const struct vms_dsc_ubs
*ubs
= (const void *)buf
;
6895 evax_bfd_print_indent (indent
, file
);
6896 fprintf (file
, _("unaligned bit-string of %s\n"),
6897 evax_bfd_get_dsc_name (ubs
->dtype
));
6898 evax_bfd_print_indent (indent
+ 1, file
);
6900 /* xgettext:c-format */
6901 _("base: %u, pos: %u\n"),
6902 (unsigned)bfd_getl32 (ubs
->base
),
6903 (unsigned)bfd_getl32 (ubs
->pos
));
6907 fprintf (file
, _("*unhandled*\n"));
6914 evax_bfd_print_valspec (const unsigned char *buf
, int indent
, FILE *file
)
6916 unsigned int vflags
= buf
[0];
6917 unsigned int value
= (unsigned)bfd_getl32 (buf
+ 1);
6918 unsigned int len
= 5;
6920 evax_bfd_print_indent (indent
, file
);
6921 /* xgettext:c-format */
6922 fprintf (file
, _("vflags: 0x%02x, value: 0x%08x "), vflags
, value
);
6927 case DST__K_VFLAGS_NOVAL
:
6928 fprintf (file
, _("(no value)\n"));
6930 case DST__K_VFLAGS_NOTACTIVE
:
6931 fprintf (file
, _("(not active)\n"));
6933 case DST__K_VFLAGS_UNALLOC
:
6934 fprintf (file
, _("(not allocated)\n"));
6936 case DST__K_VFLAGS_DSC
:
6937 fprintf (file
, _("(descriptor)\n"));
6938 evax_bfd_print_desc (buf
+ value
, indent
+ 1, file
);
6940 case DST__K_VFLAGS_TVS
:
6941 fprintf (file
, _("(trailing value)\n"));
6943 case DST__K_VS_FOLLOWS
:
6944 fprintf (file
, _("(value spec follows)\n"));
6946 case DST__K_VFLAGS_BITOFFS
:
6947 fprintf (file
, _("(at bit offset %u)\n"), value
);
6950 /* xgettext:c-format */
6951 fprintf (file
, _("(reg: %u, disp: %u, indir: %u, kind: "),
6952 (vflags
& DST__K_REGNUM_MASK
) >> DST__K_REGNUM_SHIFT
,
6953 vflags
& DST__K_DISP
? 1 : 0,
6954 vflags
& DST__K_INDIR
? 1 : 0);
6955 switch (vflags
& DST__K_VALKIND_MASK
)
6957 case DST__K_VALKIND_LITERAL
:
6958 fputs (_("literal"), file
);
6960 case DST__K_VALKIND_ADDR
:
6961 fputs (_("address"), file
);
6963 case DST__K_VALKIND_DESC
:
6964 fputs (_("desc"), file
);
6966 case DST__K_VALKIND_REG
:
6967 fputs (_("reg"), file
);
6970 fputs (")\n", file
);
6977 evax_bfd_print_typspec (const unsigned char *buf
, int indent
, FILE *file
)
6979 unsigned char kind
= buf
[2];
6980 unsigned int len
= (unsigned)bfd_getl16 (buf
);
6982 evax_bfd_print_indent (indent
, file
);
6983 /* xgettext:c-format */
6984 fprintf (file
, _("len: %2u, kind: %2u "), len
, kind
);
6988 case DST__K_TS_ATOM
:
6989 /* xgettext:c-format */
6990 fprintf (file
, _("atomic, type=0x%02x %s\n"),
6991 buf
[0], evax_bfd_get_dsc_name (buf
[0]));
6994 fprintf (file
, _("indirect, defined at 0x%08x\n"),
6995 (unsigned)bfd_getl32 (buf
));
6997 case DST__K_TS_TPTR
:
6998 fprintf (file
, _("typed pointer\n"));
6999 evax_bfd_print_typspec (buf
, indent
+ 1, file
);
7002 fprintf (file
, _("pointer\n"));
7004 case DST__K_TS_ARRAY
:
7006 const unsigned char *vs
;
7007 unsigned int vec_len
;
7010 fprintf (file
, _("array, dim: %u, bitmap: "), buf
[0]);
7011 vec_len
= (buf
[0] + 1 + 7) / 8;
7012 for (i
= 0; i
< vec_len
; i
++)
7013 fprintf (file
, " %02x", buf
[i
+ 1]);
7015 vs
= buf
+ 1 + vec_len
;
7016 evax_bfd_print_indent (indent
, file
);
7017 fprintf (file
, _("array descriptor:\n"));
7018 vs
+= evax_bfd_print_valspec (vs
, indent
+ 1, file
);
7019 for (i
= 0; i
< buf
[0] + 1U; i
++)
7020 if (buf
[1 + i
/ 8] & (1 << (i
% 8)))
7022 evax_bfd_print_indent (indent
, file
);
7024 fprintf (file
, _("type spec for element:\n"));
7026 fprintf (file
, _("type spec for subscript %u:\n"), i
);
7027 evax_bfd_print_typspec (vs
, indent
+ 1, file
);
7028 vs
+= bfd_getl16 (vs
);
7033 fprintf (file
, _("*unhandled*\n"));
7038 evax_bfd_print_dst (struct bfd
*abfd
, unsigned int dst_size
, FILE *file
)
7040 unsigned int off
= 0;
7041 unsigned int pc
= 0;
7042 unsigned int line
= 0;
7044 fprintf (file
, _("Debug symbol table:\n"));
7046 while (dst_size
> 0)
7048 struct vms_dst_header dsth
;
7053 if (bfd_bread (&dsth
, sizeof (dsth
), abfd
) != sizeof (dsth
))
7055 fprintf (file
, _("cannot read DST header\n"));
7058 len
= bfd_getl16 (dsth
.length
);
7059 type
= bfd_getl16 (dsth
.type
);
7060 /* xgettext:c-format */
7061 fprintf (file
, _(" type: %3u, len: %3u (at 0x%08x): "),
7071 len
-= sizeof (dsth
);
7072 buf
= bfd_malloc (len
);
7073 if (bfd_bread (buf
, len
, abfd
) != len
)
7075 fprintf (file
, _("cannot read DST symbol\n"));
7080 case DSC__K_DTYPE_V
:
7081 case DSC__K_DTYPE_BU
:
7082 case DSC__K_DTYPE_WU
:
7083 case DSC__K_DTYPE_LU
:
7084 case DSC__K_DTYPE_QU
:
7085 case DSC__K_DTYPE_B
:
7086 case DSC__K_DTYPE_W
:
7087 case DSC__K_DTYPE_L
:
7088 case DSC__K_DTYPE_Q
:
7089 case DSC__K_DTYPE_F
:
7090 case DSC__K_DTYPE_D
:
7091 case DSC__K_DTYPE_FC
:
7092 case DSC__K_DTYPE_DC
:
7093 case DSC__K_DTYPE_T
:
7094 case DSC__K_DTYPE_NU
:
7095 case DSC__K_DTYPE_NL
:
7096 case DSC__K_DTYPE_NLO
:
7097 case DSC__K_DTYPE_NR
:
7098 case DSC__K_DTYPE_NRO
:
7099 case DSC__K_DTYPE_NZ
:
7100 case DSC__K_DTYPE_P
:
7101 case DSC__K_DTYPE_ZI
:
7102 case DSC__K_DTYPE_ZEM
:
7103 case DSC__K_DTYPE_DSC
:
7104 case DSC__K_DTYPE_OU
:
7105 case DSC__K_DTYPE_O
:
7106 case DSC__K_DTYPE_G
:
7107 case DSC__K_DTYPE_H
:
7108 case DSC__K_DTYPE_GC
:
7109 case DSC__K_DTYPE_HC
:
7110 case DSC__K_DTYPE_CIT
:
7111 case DSC__K_DTYPE_BPV
:
7112 case DSC__K_DTYPE_BLV
:
7113 case DSC__K_DTYPE_VU
:
7114 case DSC__K_DTYPE_ADT
:
7115 case DSC__K_DTYPE_VT
:
7116 case DSC__K_DTYPE_T2
:
7117 case DSC__K_DTYPE_VT2
:
7118 fprintf (file
, _("standard data: %s\n"),
7119 evax_bfd_get_dsc_name (type
));
7120 evax_bfd_print_valspec (buf
, 4, file
);
7121 fprintf (file
, _(" name: %.*s\n"), buf
[5], buf
+ 6);
7125 struct vms_dst_modbeg
*dst
= (void *)buf
;
7126 const char *name
= (const char *)buf
+ sizeof (*dst
);
7128 fprintf (file
, _("modbeg\n"));
7129 /* xgettext:c-format */
7130 fprintf (file
, _(" flags: %d, language: %u, "
7131 "major: %u, minor: %u\n"),
7133 (unsigned)bfd_getl32 (dst
->language
),
7134 (unsigned)bfd_getl16 (dst
->major
),
7135 (unsigned)bfd_getl16 (dst
->minor
));
7136 fprintf (file
, _(" module name: %.*s\n"),
7138 name
+= name
[0] + 1;
7139 fprintf (file
, _(" compiler : %.*s\n"),
7144 fprintf (file
, _("modend\n"));
7148 struct vms_dst_rtnbeg
*dst
= (void *)buf
;
7149 const char *name
= (const char *)buf
+ sizeof (*dst
);
7151 fputs (_("rtnbeg\n"), file
);
7152 /* xgettext:c-format */
7153 fprintf (file
, _(" flags: %u, address: 0x%08x, "
7154 "pd-address: 0x%08x\n"),
7156 (unsigned)bfd_getl32 (dst
->address
),
7157 (unsigned)bfd_getl32 (dst
->pd_address
));
7158 fprintf (file
, _(" routine name: %.*s\n"),
7164 struct vms_dst_rtnend
*dst
= (void *)buf
;
7166 fprintf (file
, _("rtnend: size 0x%08x\n"),
7167 (unsigned)bfd_getl32 (dst
->size
));
7172 struct vms_dst_prolog
*dst
= (void *)buf
;
7174 fprintf (file
, _("prolog: bkpt address 0x%08x\n"),
7175 (unsigned)bfd_getl32 (dst
->bkpt_addr
));
7180 struct vms_dst_epilog
*dst
= (void *)buf
;
7182 /* xgettext:c-format */
7183 fprintf (file
, _("epilog: flags: %u, count: %u\n"),
7184 dst
->flags
, (unsigned)bfd_getl32 (dst
->count
));
7189 struct vms_dst_blkbeg
*dst
= (void *)buf
;
7190 const char *name
= (const char *)buf
+ sizeof (*dst
);
7192 /* xgettext:c-format */
7193 fprintf (file
, _("blkbeg: address: 0x%08x, name: %.*s\n"),
7194 (unsigned)bfd_getl32 (dst
->address
),
7200 struct vms_dst_blkend
*dst
= (void *)buf
;
7202 fprintf (file
, _("blkend: size: 0x%08x\n"),
7203 (unsigned)bfd_getl32 (dst
->size
));
7206 case DST__K_TYPSPEC
:
7208 fprintf (file
, _("typspec (len: %u)\n"), len
);
7209 fprintf (file
, _(" name: %.*s\n"), buf
[0], buf
+ 1);
7210 evax_bfd_print_typspec (buf
+ 1 + buf
[0], 5, file
);
7215 fprintf (file
, _("septyp, name: %.*s\n"), buf
[5], buf
+ 6);
7216 evax_bfd_print_valspec (buf
, 4, file
);
7221 struct vms_dst_recbeg
*recbeg
= (void *)buf
;
7222 const char *name
= (const char *)buf
+ sizeof (*recbeg
);
7224 fprintf (file
, _("recbeg: name: %.*s\n"), name
[0], name
+ 1);
7225 evax_bfd_print_valspec (buf
, 4, file
);
7226 fprintf (file
, _(" len: %u bits\n"),
7227 (unsigned)bfd_getl32 (name
+ 1 + name
[0]));
7231 fprintf (file
, _("recend\n"));
7233 case DST__K_ENUMBEG
:
7234 /* xgettext:c-format */
7235 fprintf (file
, _("enumbeg, len: %u, name: %.*s\n"),
7236 buf
[0], buf
[1], buf
+ 2);
7238 case DST__K_ENUMELT
:
7239 fprintf (file
, _("enumelt, name: %.*s\n"), buf
[5], buf
+ 6);
7240 evax_bfd_print_valspec (buf
, 4, file
);
7242 case DST__K_ENUMEND
:
7243 fprintf (file
, _("enumend\n"));
7247 struct vms_dst_label
*lab
= (void *)buf
;
7248 fprintf (file
, _("label, name: %.*s\n"),
7249 lab
->name
[0], lab
->name
+ 1);
7250 fprintf (file
, _(" address: 0x%08x\n"),
7251 (unsigned)bfd_getl32 (lab
->value
));
7254 case DST__K_DIS_RANGE
:
7256 unsigned int cnt
= bfd_getl32 (buf
);
7257 unsigned char *rng
= buf
+ 4;
7260 fprintf (file
, _("discontiguous range (nbr: %u)\n"), cnt
);
7261 for (i
= 0; i
< cnt
; i
++, rng
+= 8)
7262 /* xgettext:c-format */
7263 fprintf (file
, _(" address: 0x%08x, size: %u\n"),
7264 (unsigned)bfd_getl32 (rng
),
7265 (unsigned)bfd_getl32 (rng
+ 4));
7269 case DST__K_LINE_NUM
:
7271 unsigned char *buf_orig
= buf
;
7273 fprintf (file
, _("line num (len: %u)\n"), len
);
7278 unsigned char cmdlen
;
7288 case DST__K_DELTA_PC_W
:
7289 val
= bfd_getl16 (buf
+ 1);
7290 fprintf (file
, _("delta_pc_w %u\n"), val
);
7295 case DST__K_INCR_LINUM
:
7297 fprintf (file
, _("incr_linum(b): +%u\n"), val
);
7301 case DST__K_INCR_LINUM_W
:
7302 val
= bfd_getl16 (buf
+ 1);
7303 fprintf (file
, _("incr_linum_w: +%u\n"), val
);
7307 case DST__K_INCR_LINUM_L
:
7308 val
= bfd_getl32 (buf
+ 1);
7309 fprintf (file
, _("incr_linum_l: +%u\n"), val
);
7313 case DST__K_SET_LINUM
:
7314 line
= bfd_getl16 (buf
+ 1);
7315 fprintf (file
, _("set_line_num(w) %u\n"), line
);
7318 case DST__K_SET_LINUM_B
:
7320 fprintf (file
, _("set_line_num_b %u\n"), line
);
7323 case DST__K_SET_LINUM_L
:
7324 line
= bfd_getl32 (buf
+ 1);
7325 fprintf (file
, _("set_line_num_l %u\n"), line
);
7328 case DST__K_SET_ABS_PC
:
7329 pc
= bfd_getl32 (buf
+ 1);
7330 fprintf (file
, _("set_abs_pc: 0x%08x\n"), pc
);
7333 case DST__K_DELTA_PC_L
:
7334 fprintf (file
, _("delta_pc_l: +0x%08x\n"),
7335 (unsigned)bfd_getl32 (buf
+ 1));
7339 fprintf (file
, _("term(b): 0x%02x"), buf
[1]);
7341 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7345 val
= bfd_getl16 (buf
+ 1);
7346 fprintf (file
, _("term_w: 0x%04x"), val
);
7348 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7354 fprintf (file
, _("delta pc +%-4d"), -cmd
);
7355 line
++; /* FIXME: curr increment. */
7357 /* xgettext:c-format */
7358 fprintf (file
, _(" pc: 0x%08x line: %5u\n"),
7363 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7376 unsigned char *buf_orig
= buf
;
7378 fprintf (file
, _("source (len: %u)\n"), len
);
7382 signed char cmd
= buf
[0];
7383 unsigned char cmdlen
= 0;
7387 case DST__K_SRC_DECLFILE
:
7389 struct vms_dst_src_decl_src
*src
= (void *)(buf
+ 1);
7392 /* xgettext:c-format */
7393 fprintf (file
, _(" declfile: len: %u, flags: %u, "
7395 src
->length
, src
->flags
,
7396 (unsigned)bfd_getl16 (src
->fileid
));
7397 /* xgettext:c-format */
7398 fprintf (file
, _(" rms: cdt: 0x%08x %08x, "
7399 "ebk: 0x%08x, ffb: 0x%04x, "
7401 (unsigned)bfd_getl32 (src
->rms_cdt
+ 4),
7402 (unsigned)bfd_getl32 (src
->rms_cdt
+ 0),
7403 (unsigned)bfd_getl32 (src
->rms_ebk
),
7404 (unsigned)bfd_getl16 (src
->rms_ffb
),
7406 name
= (const char *)buf
+ 1 + sizeof (*src
);
7407 fprintf (file
, _(" filename : %.*s\n"),
7409 name
+= name
[0] + 1;
7410 fprintf (file
, _(" module name: %.*s\n"),
7412 cmdlen
= 2 + src
->length
;
7415 case DST__K_SRC_SETFILE
:
7416 fprintf (file
, _(" setfile %u\n"),
7417 (unsigned)bfd_getl16 (buf
+ 1));
7420 case DST__K_SRC_SETREC_W
:
7421 fprintf (file
, _(" setrec %u\n"),
7422 (unsigned)bfd_getl16 (buf
+ 1));
7425 case DST__K_SRC_SETREC_L
:
7426 fprintf (file
, _(" setrec %u\n"),
7427 (unsigned)bfd_getl32 (buf
+ 1));
7430 case DST__K_SRC_SETLNUM_W
:
7431 fprintf (file
, _(" setlnum %u\n"),
7432 (unsigned)bfd_getl16 (buf
+ 1));
7435 case DST__K_SRC_SETLNUM_L
:
7436 fprintf (file
, _(" setlnum %u\n"),
7437 (unsigned)bfd_getl32 (buf
+ 1));
7440 case DST__K_SRC_DEFLINES_W
:
7441 fprintf (file
, _(" deflines %u\n"),
7442 (unsigned)bfd_getl16 (buf
+ 1));
7445 case DST__K_SRC_DEFLINES_B
:
7446 fprintf (file
, _(" deflines %u\n"), buf
[1]);
7449 case DST__K_SRC_FORMFEED
:
7450 fprintf (file
, _(" formfeed\n"));
7454 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7466 fprintf (file
, _("*unhandled* dst type %u\n"), type
);
7474 evax_bfd_print_image (bfd
*abfd
, FILE *file
)
7476 struct vms_eihd eihd
;
7479 unsigned int eiha_off
;
7480 unsigned int eihi_off
;
7481 unsigned int eihs_off
;
7482 unsigned int eisd_off
;
7483 unsigned int eihef_off
= 0;
7484 unsigned int eihnp_off
= 0;
7485 unsigned int dmt_vbn
= 0;
7486 unsigned int dmt_size
= 0;
7487 unsigned int dst_vbn
= 0;
7488 unsigned int dst_size
= 0;
7489 unsigned int gst_vbn
= 0;
7490 unsigned int gst_size
= 0;
7491 unsigned int eiaf_vbn
= 0;
7492 unsigned int eiaf_size
= 0;
7493 unsigned int eihvn_off
;
7495 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
)
7496 || bfd_bread (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
7498 fprintf (file
, _("cannot read EIHD\n"));
7501 /* xgettext:c-format */
7502 fprintf (file
, _("EIHD: (size: %u, nbr blocks: %u)\n"),
7503 (unsigned)bfd_getl32 (eihd
.size
),
7504 (unsigned)bfd_getl32 (eihd
.hdrblkcnt
));
7505 /* xgettext:c-format */
7506 fprintf (file
, _(" majorid: %u, minorid: %u\n"),
7507 (unsigned)bfd_getl32 (eihd
.majorid
),
7508 (unsigned)bfd_getl32 (eihd
.minorid
));
7510 val
= (unsigned)bfd_getl32 (eihd
.imgtype
);
7514 name
= _("executable");
7517 name
= _("linkable image");
7520 name
= _("unknown");
7523 /* xgettext:c-format */
7524 fprintf (file
, _(" image type: %u (%s)"), val
, name
);
7526 val
= (unsigned)bfd_getl32 (eihd
.subtype
);
7529 case EIHD__C_NATIVE
:
7536 name
= _("unknown");
7539 /* xgettext:c-format */
7540 fprintf (file
, _(", subtype: %u (%s)\n"), val
, name
);
7542 eisd_off
= bfd_getl32 (eihd
.isdoff
);
7543 eiha_off
= bfd_getl32 (eihd
.activoff
);
7544 eihi_off
= bfd_getl32 (eihd
.imgidoff
);
7545 eihs_off
= bfd_getl32 (eihd
.symdbgoff
);
7546 /* xgettext:c-format */
7547 fprintf (file
, _(" offsets: isd: %u, activ: %u, symdbg: %u, "
7548 "imgid: %u, patch: %u\n"),
7549 eisd_off
, eiha_off
, eihs_off
, eihi_off
,
7550 (unsigned)bfd_getl32 (eihd
.patchoff
));
7551 fprintf (file
, _(" fixup info rva: "));
7552 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.iafva
));
7553 fprintf (file
, _(", symbol vector rva: "));
7554 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.symvva
));
7555 eihvn_off
= bfd_getl32 (eihd
.version_array_off
);
7556 fprintf (file
, _("\n"
7557 " version array off: %u\n"),
7560 /* xgettext:c-format */
7561 _(" img I/O count: %u, nbr channels: %u, req pri: %08x%08x\n"),
7562 (unsigned)bfd_getl32 (eihd
.imgiocnt
),
7563 (unsigned)bfd_getl32 (eihd
.iochancnt
),
7564 (unsigned)bfd_getl32 (eihd
.privreqs
+ 4),
7565 (unsigned)bfd_getl32 (eihd
.privreqs
+ 0));
7566 val
= (unsigned)bfd_getl32 (eihd
.lnkflags
);
7567 fprintf (file
, _(" linker flags: %08x:"), val
);
7568 if (val
& EIHD__M_LNKDEBUG
)
7569 fprintf (file
, " LNKDEBUG");
7570 if (val
& EIHD__M_LNKNOTFR
)
7571 fprintf (file
, " LNKNOTFR");
7572 if (val
& EIHD__M_NOP0BUFS
)
7573 fprintf (file
, " NOP0BUFS");
7574 if (val
& EIHD__M_PICIMG
)
7575 fprintf (file
, " PICIMG");
7576 if (val
& EIHD__M_P0IMAGE
)
7577 fprintf (file
, " P0IMAGE");
7578 if (val
& EIHD__M_DBGDMT
)
7579 fprintf (file
, " DBGDMT");
7580 if (val
& EIHD__M_INISHR
)
7581 fprintf (file
, " INISHR");
7582 if (val
& EIHD__M_XLATED
)
7583 fprintf (file
, " XLATED");
7584 if (val
& EIHD__M_BIND_CODE_SEC
)
7585 fprintf (file
, " BIND_CODE_SEC");
7586 if (val
& EIHD__M_BIND_DATA_SEC
)
7587 fprintf (file
, " BIND_DATA_SEC");
7588 if (val
& EIHD__M_MKTHREADS
)
7589 fprintf (file
, " MKTHREADS");
7590 if (val
& EIHD__M_UPCALLS
)
7591 fprintf (file
, " UPCALLS");
7592 if (val
& EIHD__M_OMV_READY
)
7593 fprintf (file
, " OMV_READY");
7594 if (val
& EIHD__M_EXT_BIND_SECT
)
7595 fprintf (file
, " EXT_BIND_SECT");
7596 fprintf (file
, "\n");
7597 /* xgettext:c-format */
7598 fprintf (file
, _(" ident: 0x%08x, sysver: 0x%08x, "
7599 "match ctrl: %u, symvect_size: %u\n"),
7600 (unsigned)bfd_getl32 (eihd
.ident
),
7601 (unsigned)bfd_getl32 (eihd
.sysver
),
7603 (unsigned)bfd_getl32 (eihd
.symvect_size
));
7604 fprintf (file
, _(" BPAGE: %u"),
7605 (unsigned)bfd_getl32 (eihd
.virt_mem_block_size
));
7606 if (val
& (EIHD__M_OMV_READY
| EIHD__M_EXT_BIND_SECT
))
7608 eihef_off
= bfd_getl32 (eihd
.ext_fixup_off
);
7609 eihnp_off
= bfd_getl32 (eihd
.noopt_psect_off
);
7610 /* xgettext:c-format */
7611 fprintf (file
, _(", ext fixup offset: %u, no_opt psect off: %u"),
7612 eihef_off
, eihnp_off
);
7614 fprintf (file
, _(", alias: %u\n"), (unsigned)bfd_getl16 (eihd
.alias
));
7618 struct vms_eihvn eihvn
;
7622 fprintf (file
, _("system version array information:\n"));
7623 if (bfd_seek (abfd
, (file_ptr
) eihvn_off
, SEEK_SET
)
7624 || bfd_bread (&eihvn
, sizeof (eihvn
), abfd
) != sizeof (eihvn
))
7626 fprintf (file
, _("cannot read EIHVN header\n"));
7629 mask
= bfd_getl32 (eihvn
.subsystem_mask
);
7630 for (j
= 0; j
< 32; j
++)
7631 if (mask
& (1 << j
))
7633 struct vms_eihvn_subversion ver
;
7634 if (bfd_bread (&ver
, sizeof (ver
), abfd
) != sizeof (ver
))
7636 fprintf (file
, _("cannot read EIHVN version\n"));
7639 fprintf (file
, _(" %02u "), j
);
7642 case EIHVN__BASE_IMAGE_BIT
:
7643 fputs (_("BASE_IMAGE "), file
);
7645 case EIHVN__MEMORY_MANAGEMENT_BIT
:
7646 fputs (_("MEMORY_MANAGEMENT"), file
);
7649 fputs (_("IO "), file
);
7651 case EIHVN__FILES_VOLUMES_BIT
:
7652 fputs (_("FILES_VOLUMES "), file
);
7654 case EIHVN__PROCESS_SCHED_BIT
:
7655 fputs (_("PROCESS_SCHED "), file
);
7657 case EIHVN__SYSGEN_BIT
:
7658 fputs (_("SYSGEN "), file
);
7660 case EIHVN__CLUSTERS_LOCKMGR_BIT
:
7661 fputs (_("CLUSTERS_LOCKMGR "), file
);
7663 case EIHVN__LOGICAL_NAMES_BIT
:
7664 fputs (_("LOGICAL_NAMES "), file
);
7666 case EIHVN__SECURITY_BIT
:
7667 fputs (_("SECURITY "), file
);
7669 case EIHVN__IMAGE_ACTIVATOR_BIT
:
7670 fputs (_("IMAGE_ACTIVATOR "), file
);
7672 case EIHVN__NETWORKS_BIT
:
7673 fputs (_("NETWORKS "), file
);
7675 case EIHVN__COUNTERS_BIT
:
7676 fputs (_("COUNTERS "), file
);
7678 case EIHVN__STABLE_BIT
:
7679 fputs (_("STABLE "), file
);
7681 case EIHVN__MISC_BIT
:
7682 fputs (_("MISC "), file
);
7684 case EIHVN__CPU_BIT
:
7685 fputs (_("CPU "), file
);
7687 case EIHVN__VOLATILE_BIT
:
7688 fputs (_("VOLATILE "), file
);
7690 case EIHVN__SHELL_BIT
:
7691 fputs (_("SHELL "), file
);
7693 case EIHVN__POSIX_BIT
:
7694 fputs (_("POSIX "), file
);
7696 case EIHVN__MULTI_PROCESSING_BIT
:
7697 fputs (_("MULTI_PROCESSING "), file
);
7699 case EIHVN__GALAXY_BIT
:
7700 fputs (_("GALAXY "), file
);
7703 fputs (_("*unknown* "), file
);
7706 fprintf (file
, ": %u.%u\n",
7707 (unsigned)bfd_getl16 (ver
.major
),
7708 (unsigned)bfd_getl16 (ver
.minor
));
7714 struct vms_eiha eiha
;
7716 if (bfd_seek (abfd
, (file_ptr
) eiha_off
, SEEK_SET
)
7717 || bfd_bread (&eiha
, sizeof (eiha
), abfd
) != sizeof (eiha
))
7719 fprintf (file
, _("cannot read EIHA\n"));
7722 fprintf (file
, _("Image activation: (size=%u)\n"),
7723 (unsigned)bfd_getl32 (eiha
.size
));
7724 /* xgettext:c-format */
7725 fprintf (file
, _(" First address : 0x%08x 0x%08x\n"),
7726 (unsigned)bfd_getl32 (eiha
.tfradr1_h
),
7727 (unsigned)bfd_getl32 (eiha
.tfradr1
));
7728 /* xgettext:c-format */
7729 fprintf (file
, _(" Second address: 0x%08x 0x%08x\n"),
7730 (unsigned)bfd_getl32 (eiha
.tfradr2_h
),
7731 (unsigned)bfd_getl32 (eiha
.tfradr2
));
7732 /* xgettext:c-format */
7733 fprintf (file
, _(" Third address : 0x%08x 0x%08x\n"),
7734 (unsigned)bfd_getl32 (eiha
.tfradr3_h
),
7735 (unsigned)bfd_getl32 (eiha
.tfradr3
));
7736 /* xgettext:c-format */
7737 fprintf (file
, _(" Fourth address: 0x%08x 0x%08x\n"),
7738 (unsigned)bfd_getl32 (eiha
.tfradr4_h
),
7739 (unsigned)bfd_getl32 (eiha
.tfradr4
));
7740 /* xgettext:c-format */
7741 fprintf (file
, _(" Shared image : 0x%08x 0x%08x\n"),
7742 (unsigned)bfd_getl32 (eiha
.inishr_h
),
7743 (unsigned)bfd_getl32 (eiha
.inishr
));
7747 struct vms_eihi eihi
;
7749 if (bfd_seek (abfd
, (file_ptr
) eihi_off
, SEEK_SET
)
7750 || bfd_bread (&eihi
, sizeof (eihi
), abfd
) != sizeof (eihi
))
7752 fprintf (file
, _("cannot read EIHI\n"));
7755 /* xgettext:c-format */
7756 fprintf (file
, _("Image identification: (major: %u, minor: %u)\n"),
7757 (unsigned)bfd_getl32 (eihi
.majorid
),
7758 (unsigned)bfd_getl32 (eihi
.minorid
));
7759 fprintf (file
, _(" image name : %.*s\n"),
7760 eihi
.imgnam
[0], eihi
.imgnam
+ 1);
7761 fprintf (file
, _(" link time : %s\n"),
7762 vms_time_to_str (eihi
.linktime
));
7763 fprintf (file
, _(" image ident : %.*s\n"),
7764 eihi
.imgid
[0], eihi
.imgid
+ 1);
7765 fprintf (file
, _(" linker ident : %.*s\n"),
7766 eihi
.linkid
[0], eihi
.linkid
+ 1);
7767 fprintf (file
, _(" image build ident: %.*s\n"),
7768 eihi
.imgbid
[0], eihi
.imgbid
+ 1);
7772 struct vms_eihs eihs
;
7774 if (bfd_seek (abfd
, (file_ptr
) eihs_off
, SEEK_SET
)
7775 || bfd_bread (&eihs
, sizeof (eihs
), abfd
) != sizeof (eihs
))
7777 fprintf (file
, _("cannot read EIHS\n"));
7780 /* xgettext:c-format */
7781 fprintf (file
, _("Image symbol & debug table: (major: %u, minor: %u)\n"),
7782 (unsigned)bfd_getl32 (eihs
.majorid
),
7783 (unsigned)bfd_getl32 (eihs
.minorid
));
7784 dst_vbn
= bfd_getl32 (eihs
.dstvbn
);
7785 dst_size
= bfd_getl32 (eihs
.dstsize
);
7786 /* xgettext:c-format */
7787 fprintf (file
, _(" debug symbol table : vbn: %u, size: %u (0x%x)\n"),
7788 dst_vbn
, dst_size
, dst_size
);
7789 gst_vbn
= bfd_getl32 (eihs
.gstvbn
);
7790 gst_size
= bfd_getl32 (eihs
.gstsize
);
7791 /* xgettext:c-format */
7792 fprintf (file
, _(" global symbol table: vbn: %u, records: %u\n"),
7794 dmt_vbn
= bfd_getl32 (eihs
.dmtvbn
);
7795 dmt_size
= bfd_getl32 (eihs
.dmtsize
);
7796 /* xgettext:c-format */
7797 fprintf (file
, _(" debug module table : vbn: %u, size: %u\n"),
7800 while (eisd_off
!= 0)
7802 struct vms_eisd eisd
;
7807 if (bfd_seek (abfd
, (file_ptr
) eisd_off
, SEEK_SET
)
7808 || bfd_bread (&eisd
, sizeof (eisd
), abfd
) != sizeof (eisd
))
7810 fprintf (file
, _("cannot read EISD\n"));
7813 len
= (unsigned)bfd_getl32 (eisd
.eisdsize
);
7814 if (len
!= (unsigned)-1)
7818 eisd_off
= (eisd_off
+ VMS_BLOCK_SIZE
) & ~(VMS_BLOCK_SIZE
- 1);
7820 /* xgettext:c-format */
7821 fprintf (file
, _("Image section descriptor: (major: %u, minor: %u, "
7822 "size: %u, offset: %u)\n"),
7823 (unsigned)bfd_getl32 (eisd
.majorid
),
7824 (unsigned)bfd_getl32 (eisd
.minorid
),
7828 /* xgettext:c-format */
7829 fprintf (file
, _(" section: base: 0x%08x%08x size: 0x%08x\n"),
7830 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 4),
7831 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 0),
7832 (unsigned)bfd_getl32 (eisd
.secsize
));
7833 val
= (unsigned)bfd_getl32 (eisd
.flags
);
7834 fprintf (file
, _(" flags: 0x%04x"), val
);
7835 if (val
& EISD__M_GBL
)
7836 fprintf (file
, " GBL");
7837 if (val
& EISD__M_CRF
)
7838 fprintf (file
, " CRF");
7839 if (val
& EISD__M_DZRO
)
7840 fprintf (file
, " DZRO");
7841 if (val
& EISD__M_WRT
)
7842 fprintf (file
, " WRT");
7843 if (val
& EISD__M_INITALCODE
)
7844 fprintf (file
, " INITALCODE");
7845 if (val
& EISD__M_BASED
)
7846 fprintf (file
, " BASED");
7847 if (val
& EISD__M_FIXUPVEC
)
7848 fprintf (file
, " FIXUPVEC");
7849 if (val
& EISD__M_RESIDENT
)
7850 fprintf (file
, " RESIDENT");
7851 if (val
& EISD__M_VECTOR
)
7852 fprintf (file
, " VECTOR");
7853 if (val
& EISD__M_PROTECT
)
7854 fprintf (file
, " PROTECT");
7855 if (val
& EISD__M_LASTCLU
)
7856 fprintf (file
, " LASTCLU");
7857 if (val
& EISD__M_EXE
)
7858 fprintf (file
, " EXE");
7859 if (val
& EISD__M_NONSHRADR
)
7860 fprintf (file
, " NONSHRADR");
7861 if (val
& EISD__M_QUAD_LENGTH
)
7862 fprintf (file
, " QUAD_LENGTH");
7863 if (val
& EISD__M_ALLOC_64BIT
)
7864 fprintf (file
, " ALLOC_64BIT");
7865 fprintf (file
, "\n");
7866 if (val
& EISD__M_FIXUPVEC
)
7868 eiaf_vbn
= bfd_getl32 (eisd
.vbn
);
7869 eiaf_size
= bfd_getl32 (eisd
.secsize
);
7871 /* xgettext:c-format */
7872 fprintf (file
, _(" vbn: %u, pfc: %u, matchctl: %u type: %u ("),
7873 (unsigned)bfd_getl32 (eisd
.vbn
),
7874 eisd
.pfc
, eisd
.matchctl
, eisd
.type
);
7877 case EISD__K_NORMAL
:
7878 fputs (_("NORMAL"), file
);
7880 case EISD__K_SHRFXD
:
7881 fputs (_("SHRFXD"), file
);
7883 case EISD__K_PRVFXD
:
7884 fputs (_("PRVFXD"), file
);
7886 case EISD__K_SHRPIC
:
7887 fputs (_("SHRPIC"), file
);
7889 case EISD__K_PRVPIC
:
7890 fputs (_("PRVPIC"), file
);
7892 case EISD__K_USRSTACK
:
7893 fputs (_("USRSTACK"), file
);
7896 fputs (_("*unknown*"), file
);
7899 fputs (_(")\n"), file
);
7900 if (val
& EISD__M_GBL
)
7901 /* xgettext:c-format */
7902 fprintf (file
, _(" ident: 0x%08x, name: %.*s\n"),
7903 (unsigned)bfd_getl32 (eisd
.ident
),
7904 eisd
.gblnam
[0], eisd
.gblnam
+ 1);
7910 if (bfd_seek (abfd
, (file_ptr
) (dmt_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7912 fprintf (file
, _("cannot read DMT\n"));
7916 fprintf (file
, _("Debug module table:\n"));
7918 while (dmt_size
> 0)
7920 struct vms_dmt_header dmth
;
7923 if (bfd_bread (&dmth
, sizeof (dmth
), abfd
) != sizeof (dmth
))
7925 fprintf (file
, _("cannot read DMT header\n"));
7928 count
= bfd_getl16 (dmth
.psect_count
);
7930 /* xgettext:c-format */
7931 _(" module offset: 0x%08x, size: 0x%08x, (%u psects)\n"),
7932 (unsigned)bfd_getl32 (dmth
.modbeg
),
7933 (unsigned)bfd_getl32 (dmth
.size
), count
);
7934 dmt_size
-= sizeof (dmth
);
7937 struct vms_dmt_psect dmtp
;
7939 if (bfd_bread (&dmtp
, sizeof (dmtp
), abfd
) != sizeof (dmtp
))
7941 fprintf (file
, _("cannot read DMT psect\n"));
7944 /* xgettext:c-format */
7945 fprintf (file
, _(" psect start: 0x%08x, length: %u\n"),
7946 (unsigned)bfd_getl32 (dmtp
.start
),
7947 (unsigned)bfd_getl32 (dmtp
.length
));
7949 dmt_size
-= sizeof (dmtp
);
7956 if (bfd_seek (abfd
, (file_ptr
) (dst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7958 fprintf (file
, _("cannot read DST\n"));
7962 evax_bfd_print_dst (abfd
, dst_size
, file
);
7966 if (bfd_seek (abfd
, (file_ptr
) (gst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7968 fprintf (file
, _("cannot read GST\n"));
7972 fprintf (file
, _("Global symbol table:\n"));
7973 evax_bfd_print_eobj (abfd
, file
);
7978 struct vms_eiaf
*eiaf
;
7979 unsigned int qrelfixoff
;
7980 unsigned int lrelfixoff
;
7981 unsigned int qdotadroff
;
7982 unsigned int ldotadroff
;
7983 unsigned int shrimgcnt
;
7984 unsigned int shlstoff
;
7985 unsigned int codeadroff
;
7986 unsigned int lpfixoff
;
7987 unsigned int chgprtoff
;
7989 buf
= bfd_malloc (eiaf_size
);
7991 if (bfd_seek (abfd
, (file_ptr
) (eiaf_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
)
7992 || bfd_bread (buf
, eiaf_size
, abfd
) != eiaf_size
)
7994 fprintf (file
, _("cannot read EIHA\n"));
7998 eiaf
= (struct vms_eiaf
*)buf
;
8000 /* xgettext:c-format */
8001 _("Image activator fixup: (major: %u, minor: %u)\n"),
8002 (unsigned)bfd_getl32 (eiaf
->majorid
),
8003 (unsigned)bfd_getl32 (eiaf
->minorid
));
8004 /* xgettext:c-format */
8005 fprintf (file
, _(" iaflink : 0x%08x %08x\n"),
8006 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 0),
8007 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 4));
8008 /* xgettext:c-format */
8009 fprintf (file
, _(" fixuplnk: 0x%08x %08x\n"),
8010 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 0),
8011 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 4));
8012 fprintf (file
, _(" size : %u\n"),
8013 (unsigned)bfd_getl32 (eiaf
->size
));
8014 fprintf (file
, _(" flags: 0x%08x\n"),
8015 (unsigned)bfd_getl32 (eiaf
->flags
));
8016 qrelfixoff
= bfd_getl32 (eiaf
->qrelfixoff
);
8017 lrelfixoff
= bfd_getl32 (eiaf
->lrelfixoff
);
8018 /* xgettext:c-format */
8019 fprintf (file
, _(" qrelfixoff: %5u, lrelfixoff: %5u\n"),
8020 qrelfixoff
, lrelfixoff
);
8021 qdotadroff
= bfd_getl32 (eiaf
->qdotadroff
);
8022 ldotadroff
= bfd_getl32 (eiaf
->ldotadroff
);
8023 /* xgettext:c-format */
8024 fprintf (file
, _(" qdotadroff: %5u, ldotadroff: %5u\n"),
8025 qdotadroff
, ldotadroff
);
8026 codeadroff
= bfd_getl32 (eiaf
->codeadroff
);
8027 lpfixoff
= bfd_getl32 (eiaf
->lpfixoff
);
8028 /* xgettext:c-format */
8029 fprintf (file
, _(" codeadroff: %5u, lpfixoff : %5u\n"),
8030 codeadroff
, lpfixoff
);
8031 chgprtoff
= bfd_getl32 (eiaf
->chgprtoff
);
8032 fprintf (file
, _(" chgprtoff : %5u\n"), chgprtoff
);
8033 shrimgcnt
= bfd_getl32 (eiaf
->shrimgcnt
);
8034 shlstoff
= bfd_getl32 (eiaf
->shlstoff
);
8035 /* xgettext:c-format */
8036 fprintf (file
, _(" shlstoff : %5u, shrimgcnt : %5u\n"),
8037 shlstoff
, shrimgcnt
);
8038 /* xgettext:c-format */
8039 fprintf (file
, _(" shlextra : %5u, permctx : %5u\n"),
8040 (unsigned)bfd_getl32 (eiaf
->shlextra
),
8041 (unsigned)bfd_getl32 (eiaf
->permctx
));
8042 fprintf (file
, _(" base_va : 0x%08x\n"),
8043 (unsigned)bfd_getl32 (eiaf
->base_va
));
8044 fprintf (file
, _(" lppsbfixoff: %5u\n"),
8045 (unsigned)bfd_getl32 (eiaf
->lppsbfixoff
));
8049 struct vms_shl
*shl
= (struct vms_shl
*)(buf
+ shlstoff
);
8052 fprintf (file
, _(" Shareable images:\n"));
8053 for (j
= 0; j
< shrimgcnt
; j
++, shl
++)
8056 /* xgettext:c-format */
8057 _(" %u: size: %u, flags: 0x%02x, name: %.*s\n"),
8058 j
, shl
->size
, shl
->flags
,
8059 shl
->imgnam
[0], shl
->imgnam
+ 1);
8062 if (qrelfixoff
!= 0)
8064 fprintf (file
, _(" quad-word relocation fixups:\n"));
8065 evax_bfd_print_relocation_records (file
, buf
+ qrelfixoff
, 8);
8067 if (lrelfixoff
!= 0)
8069 fprintf (file
, _(" long-word relocation fixups:\n"));
8070 evax_bfd_print_relocation_records (file
, buf
+ lrelfixoff
, 4);
8072 if (qdotadroff
!= 0)
8074 fprintf (file
, _(" quad-word .address reference fixups:\n"));
8075 evax_bfd_print_address_fixups (file
, buf
+ qdotadroff
);
8077 if (ldotadroff
!= 0)
8079 fprintf (file
, _(" long-word .address reference fixups:\n"));
8080 evax_bfd_print_address_fixups (file
, buf
+ ldotadroff
);
8082 if (codeadroff
!= 0)
8084 fprintf (file
, _(" Code Address Reference Fixups:\n"));
8085 evax_bfd_print_reference_fixups (file
, buf
+ codeadroff
);
8089 fprintf (file
, _(" Linkage Pairs Reference Fixups:\n"));
8090 evax_bfd_print_reference_fixups (file
, buf
+ lpfixoff
);
8094 unsigned int count
= (unsigned)bfd_getl32 (buf
+ chgprtoff
);
8095 struct vms_eicp
*eicp
= (struct vms_eicp
*)(buf
+ chgprtoff
+ 4);
8098 fprintf (file
, _(" Change Protection (%u entries):\n"), count
);
8099 for (j
= 0; j
< count
; j
++, eicp
++)
8101 unsigned int prot
= bfd_getl32 (eicp
->newprt
);
8103 /* xgettext:c-format */
8104 _(" base: 0x%08x %08x, size: 0x%08x, prot: 0x%08x "),
8105 (unsigned)bfd_getl32 (eicp
->baseva
+ 4),
8106 (unsigned)bfd_getl32 (eicp
->baseva
+ 0),
8107 (unsigned)bfd_getl32 (eicp
->size
),
8108 (unsigned)bfd_getl32 (eicp
->newprt
));
8112 fprintf (file
, "NA");
8114 case PRT__C_RESERVED
:
8115 fprintf (file
, "RES");
8118 fprintf (file
, "KW");
8121 fprintf (file
, "KR");
8124 fprintf (file
, "UW");
8127 fprintf (file
, "EW");
8130 fprintf (file
, "ERKW");
8133 fprintf (file
, "ER");
8136 fprintf (file
, "SW");
8139 fprintf (file
, "SREW");
8142 fprintf (file
, "SRKW");
8145 fprintf (file
, "SR");
8148 fprintf (file
, "URSW");
8151 fprintf (file
, "UREW");
8154 fprintf (file
, "URKW");
8157 fprintf (file
, "UR");
8171 vms_bfd_print_private_bfd_data (bfd
*abfd
, void *ptr
)
8173 FILE *file
= (FILE *)ptr
;
8175 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
8176 evax_bfd_print_image (abfd
, file
);
8179 if (bfd_seek (abfd
, 0, SEEK_SET
))
8181 evax_bfd_print_eobj (abfd
, file
);
8188 /* Slurp ETIR/EDBG/ETBT VMS object records. */
8191 alpha_vms_read_sections_content (bfd
*abfd
, struct bfd_link_info
*info
)
8193 asection
*cur_section
;
8194 file_ptr cur_offset
;
8195 asection
*dst_section
;
8196 file_ptr dst_offset
;
8198 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
8204 dst_section
= PRIV (dst_section
);
8208 if (info
->strip
== strip_all
|| info
->strip
== strip_debugger
)
8210 /* Discard the DST section. */
8214 else if (dst_section
)
8216 dst_offset
= dst_section
->output_offset
;
8217 dst_section
= dst_section
->output_section
;
8226 type
= _bfd_vms_get_object_record (abfd
);
8229 vms_debug2 ((2, "next_record failed\n"));
8235 PRIV (image_section
) = cur_section
;
8236 PRIV (image_offset
) = cur_offset
;
8237 res
= _bfd_vms_slurp_etir (abfd
, info
);
8238 cur_section
= PRIV (image_section
);
8239 cur_offset
= PRIV (image_offset
);
8243 if (dst_section
== NULL
)
8245 PRIV (image_section
) = dst_section
;
8246 PRIV (image_offset
) = dst_offset
;
8247 res
= _bfd_vms_slurp_etir (abfd
, info
);
8248 dst_offset
= PRIV (image_offset
);
8257 vms_debug2 ((2, "slurp eobj type %d failed\n", type
));
8264 alpha_vms_sizeof_headers (bfd
*abfd ATTRIBUTE_UNUSED
,
8265 struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8270 /* Add a linkage pair fixup at address SECT + OFFSET to SHLIB. */
8273 alpha_vms_add_fixup_lp (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
8275 struct alpha_vms_shlib_el
*sl
;
8276 asection
*sect
= PRIV2 (src
, image_section
);
8277 file_ptr offset
= PRIV2 (src
, image_offset
);
8279 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8280 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8281 sl
->has_fixups
= TRUE
;
8282 VEC_APPEND_EL (sl
->lp
, bfd_vma
,
8283 sect
->output_section
->vma
+ sect
->output_offset
+ offset
);
8284 sect
->output_section
->flags
|= SEC_RELOC
;
8287 /* Add a code address fixup at address SECT + OFFSET to SHLIB. */
8290 alpha_vms_add_fixup_ca (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
8292 struct alpha_vms_shlib_el
*sl
;
8293 asection
*sect
= PRIV2 (src
, image_section
);
8294 file_ptr offset
= PRIV2 (src
, image_offset
);
8296 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8297 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8298 sl
->has_fixups
= TRUE
;
8299 VEC_APPEND_EL (sl
->ca
, bfd_vma
,
8300 sect
->output_section
->vma
+ sect
->output_offset
+ offset
);
8301 sect
->output_section
->flags
|= SEC_RELOC
;
8304 /* Add a quad word relocation fixup at address SECT + OFFSET to SHLIB. */
8307 alpha_vms_add_fixup_qr (struct bfd_link_info
*info
, bfd
*src
,
8308 bfd
*shlib
, bfd_vma vec
)
8310 struct alpha_vms_shlib_el
*sl
;
8311 struct alpha_vms_vma_ref
*r
;
8312 asection
*sect
= PRIV2 (src
, image_section
);
8313 file_ptr offset
= PRIV2 (src
, image_offset
);
8315 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8316 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8317 sl
->has_fixups
= TRUE
;
8318 r
= VEC_APPEND (sl
->qr
, struct alpha_vms_vma_ref
);
8319 r
->vma
= sect
->output_section
->vma
+ sect
->output_offset
+ offset
;
8321 sect
->output_section
->flags
|= SEC_RELOC
;
8325 alpha_vms_add_fixup_lr (struct bfd_link_info
*info ATTRIBUTE_UNUSED
,
8326 unsigned int shr ATTRIBUTE_UNUSED
,
8327 bfd_vma vec ATTRIBUTE_UNUSED
)
8329 /* Not yet supported. */
8333 /* Add relocation. FIXME: Not yet emitted. */
8336 alpha_vms_add_lw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8341 alpha_vms_add_qw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8345 static struct bfd_hash_entry
*
8346 alpha_vms_link_hash_newfunc (struct bfd_hash_entry
*entry
,
8347 struct bfd_hash_table
*table
,
8350 struct alpha_vms_link_hash_entry
*ret
=
8351 (struct alpha_vms_link_hash_entry
*) entry
;
8353 /* Allocate the structure if it has not already been allocated by a
8356 ret
= ((struct alpha_vms_link_hash_entry
*)
8357 bfd_hash_allocate (table
,
8358 sizeof (struct alpha_vms_link_hash_entry
)));
8362 /* Call the allocation method of the superclass. */
8363 ret
= ((struct alpha_vms_link_hash_entry
*)
8364 _bfd_link_hash_newfunc ((struct bfd_hash_entry
*) ret
,
8369 return (struct bfd_hash_entry
*) ret
;
8373 alpha_vms_bfd_link_hash_table_free (bfd
*abfd
)
8375 struct alpha_vms_link_hash_table
*t
;
8378 t
= (struct alpha_vms_link_hash_table
*) abfd
->link
.hash
;
8379 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8381 struct alpha_vms_shlib_el
*shlib
;
8383 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8384 free (&VEC_EL (shlib
->ca
, bfd_vma
, 0));
8385 free (&VEC_EL (shlib
->lp
, bfd_vma
, 0));
8386 free (&VEC_EL (shlib
->qr
, struct alpha_vms_vma_ref
, 0));
8388 free (&VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, 0));
8390 _bfd_generic_link_hash_table_free (abfd
);
8393 /* Create an Alpha/VMS link hash table. */
8395 static struct bfd_link_hash_table
*
8396 alpha_vms_bfd_link_hash_table_create (bfd
*abfd
)
8398 struct alpha_vms_link_hash_table
*ret
;
8399 bfd_size_type amt
= sizeof (struct alpha_vms_link_hash_table
);
8401 ret
= (struct alpha_vms_link_hash_table
*) bfd_malloc (amt
);
8404 if (!_bfd_link_hash_table_init (&ret
->root
, abfd
,
8405 alpha_vms_link_hash_newfunc
,
8406 sizeof (struct alpha_vms_link_hash_entry
)))
8412 VEC_INIT (ret
->shrlibs
);
8414 ret
->root
.hash_table_free
= alpha_vms_bfd_link_hash_table_free
;
8420 alpha_vms_link_add_object_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8424 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
8426 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
8427 struct alpha_vms_link_hash_entry
*h
;
8428 struct bfd_link_hash_entry
*h_root
;
8431 if (!alpha_vms_convert_symbol (abfd
, e
, &sym
))
8434 if ((e
->flags
& EGSY__V_DEF
) && abfd
->selective_search
)
8436 /* In selective_search mode, only add definition that are
8438 h
= (struct alpha_vms_link_hash_entry
*)bfd_link_hash_lookup
8439 (info
->hash
, sym
.name
, FALSE
, FALSE
, FALSE
);
8440 if (h
== NULL
|| h
->root
.type
!= bfd_link_hash_undefined
)
8446 h_root
= (struct bfd_link_hash_entry
*) h
;
8447 if (!_bfd_generic_link_add_one_symbol (info
, abfd
, sym
.name
, sym
.flags
,
8448 sym
.section
, sym
.value
, NULL
,
8449 FALSE
, FALSE
, &h_root
))
8451 h
= (struct alpha_vms_link_hash_entry
*) h_root
;
8453 if ((e
->flags
& EGSY__V_DEF
)
8455 && abfd
->xvec
== info
->output_bfd
->xvec
)
8459 if (abfd
->flags
& DYNAMIC
)
8461 struct alpha_vms_shlib_el
*shlib
;
8463 /* We do not want to include any of the sections in a dynamic
8464 object in the output file. See comment in elflink.c. */
8465 bfd_section_list_clear (abfd
);
8467 shlib
= VEC_APPEND (alpha_vms_link_hash (info
)->shrlibs
,
8468 struct alpha_vms_shlib_el
);
8470 VEC_INIT (shlib
->ca
);
8471 VEC_INIT (shlib
->lp
);
8472 VEC_INIT (shlib
->qr
);
8473 PRIV (shr_index
) = VEC_COUNT (alpha_vms_link_hash (info
)->shrlibs
) - 1;
8480 alpha_vms_link_add_archive_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8483 struct bfd_link_hash_entry
**pundef
;
8484 struct bfd_link_hash_entry
**next_pundef
;
8486 /* We only accept VMS libraries. */
8487 if (info
->output_bfd
->xvec
!= abfd
->xvec
)
8489 bfd_set_error (bfd_error_wrong_format
);
8493 /* The archive_pass field in the archive itself is used to
8494 initialize PASS, since we may search the same archive multiple
8496 pass
= ++abfd
->archive_pass
;
8498 /* Look through the list of undefined symbols. */
8499 for (pundef
= &info
->hash
->undefs
; *pundef
!= NULL
; pundef
= next_pundef
)
8501 struct bfd_link_hash_entry
*h
;
8507 next_pundef
= &(*pundef
)->u
.undef
.next
;
8509 /* When a symbol is defined, it is not necessarily removed from
8511 if (h
->type
!= bfd_link_hash_undefined
8512 && h
->type
!= bfd_link_hash_common
)
8514 /* Remove this entry from the list, for general cleanliness
8515 and because we are going to look through the list again
8516 if we search any more libraries. We can't remove the
8517 entry if it is the tail, because that would lose any
8518 entries we add to the list later on. */
8519 if (*pundef
!= info
->hash
->undefs_tail
)
8521 *pundef
= *next_pundef
;
8522 next_pundef
= pundef
;
8527 /* Look for this symbol in the archive hash table. */
8528 symidx
= _bfd_vms_lib_find_symbol (abfd
, h
->root
.string
);
8529 if (symidx
== BFD_NO_MORE_SYMBOLS
)
8531 /* Nothing in this slot. */
8535 element
= bfd_get_elt_at_index (abfd
, symidx
);
8536 if (element
== NULL
)
8539 if (element
->archive_pass
== -1 || element
->archive_pass
== pass
)
8541 /* Next symbol if this archive is wrong or already handled. */
8545 if (! bfd_check_format (element
, bfd_object
))
8547 element
->archive_pass
= -1;
8551 orig_element
= element
;
8552 if (bfd_is_thin_archive (abfd
))
8554 element
= _bfd_vms_lib_get_imagelib_file (element
);
8555 if (element
== NULL
|| !bfd_check_format (element
, bfd_object
))
8557 orig_element
->archive_pass
= -1;
8562 /* Unlike the generic linker, we know that this element provides
8563 a definition for an undefined symbol and we know that we want
8564 to include it. We don't need to check anything. */
8565 if (!(*info
->callbacks
8566 ->add_archive_element
) (info
, element
, h
->root
.string
, &element
))
8568 if (!alpha_vms_link_add_object_symbols (element
, info
))
8571 orig_element
->archive_pass
= pass
;
8578 alpha_vms_bfd_link_add_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8580 switch (bfd_get_format (abfd
))
8583 vms_debug2 ((2, "vms_link_add_symbols for object %s\n",
8585 return alpha_vms_link_add_object_symbols (abfd
, info
);
8588 vms_debug2 ((2, "vms_link_add_symbols for archive %s\n",
8590 return alpha_vms_link_add_archive_symbols (abfd
, info
);
8593 bfd_set_error (bfd_error_wrong_format
);
8599 alpha_vms_build_fixups (struct bfd_link_info
*info
)
8601 struct alpha_vms_link_hash_table
*t
= alpha_vms_link_hash (info
);
8602 unsigned char *content
;
8604 unsigned int sz
= 0;
8605 unsigned int lp_sz
= 0;
8606 unsigned int ca_sz
= 0;
8607 unsigned int qr_sz
= 0;
8608 unsigned int shrimg_cnt
= 0;
8609 unsigned int chgprt_num
= 0;
8610 unsigned int chgprt_sz
= 0;
8611 struct vms_eiaf
*eiaf
;
8615 /* Shared libraries. */
8616 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8618 struct alpha_vms_shlib_el
*shlib
;
8620 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8622 if (!shlib
->has_fixups
)
8627 if (VEC_COUNT (shlib
->ca
) > 0)
8629 /* Header + entries. */
8631 ca_sz
+= VEC_COUNT (shlib
->ca
) * 4;
8633 if (VEC_COUNT (shlib
->lp
) > 0)
8635 /* Header + entries. */
8637 lp_sz
+= VEC_COUNT (shlib
->lp
) * 4;
8639 if (VEC_COUNT (shlib
->qr
) > 0)
8641 /* Header + entries. */
8643 qr_sz
+= VEC_COUNT (shlib
->qr
) * 8;
8654 /* Finish now if there is no content. */
8655 if (ca_sz
+ lp_sz
+ qr_sz
== 0)
8658 /* Add an eicp entry for the fixup itself. */
8660 for (sec
= info
->output_bfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
8662 /* This isect could be made RO or EXE after relocations are applied. */
8663 if ((sec
->flags
& SEC_RELOC
) != 0
8664 && (sec
->flags
& (SEC_CODE
| SEC_READONLY
)) != 0)
8667 chgprt_sz
= 4 + chgprt_num
* sizeof (struct vms_eicp
);
8669 /* Allocate section content (round-up size) */
8670 sz
= sizeof (struct vms_eiaf
) + shrimg_cnt
* sizeof (struct vms_shl
)
8671 + ca_sz
+ lp_sz
+ qr_sz
+ chgprt_sz
;
8672 sz
= (sz
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
8673 content
= bfd_zalloc (info
->output_bfd
, sz
);
8674 if (content
== NULL
)
8677 sec
= alpha_vms_link_hash (info
)->fixup
;
8678 sec
->contents
= content
;
8681 eiaf
= (struct vms_eiaf
*)content
;
8682 off
= sizeof (struct vms_eiaf
);
8683 bfd_putl32 (0, eiaf
->majorid
);
8684 bfd_putl32 (0, eiaf
->minorid
);
8685 bfd_putl32 (0, eiaf
->iaflink
);
8686 bfd_putl32 (0, eiaf
->fixuplnk
);
8687 bfd_putl32 (sizeof (struct vms_eiaf
), eiaf
->size
);
8688 bfd_putl32 (0, eiaf
->flags
);
8689 bfd_putl32 (0, eiaf
->qrelfixoff
);
8690 bfd_putl32 (0, eiaf
->lrelfixoff
);
8691 bfd_putl32 (0, eiaf
->qdotadroff
);
8692 bfd_putl32 (0, eiaf
->ldotadroff
);
8693 bfd_putl32 (0, eiaf
->codeadroff
);
8694 bfd_putl32 (0, eiaf
->lpfixoff
);
8695 bfd_putl32 (0, eiaf
->chgprtoff
);
8696 bfd_putl32 (shrimg_cnt
? off
: 0, eiaf
->shlstoff
);
8697 bfd_putl32 (shrimg_cnt
, eiaf
->shrimgcnt
);
8698 bfd_putl32 (0, eiaf
->shlextra
);
8699 bfd_putl32 (0, eiaf
->permctx
);
8700 bfd_putl32 (0, eiaf
->base_va
);
8701 bfd_putl32 (0, eiaf
->lppsbfixoff
);
8708 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8710 struct alpha_vms_shlib_el
*shlib
;
8711 struct vms_shl
*shl
;
8713 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8715 if (!shlib
->has_fixups
)
8718 /* Renumber shared images. */
8719 PRIV2 (shlib
->abfd
, shr_index
) = shrimg_cnt
++;
8721 shl
= (struct vms_shl
*)(content
+ off
);
8722 bfd_putl32 (0, shl
->baseva
);
8723 bfd_putl32 (0, shl
->shlptr
);
8724 bfd_putl32 (0, shl
->ident
);
8725 bfd_putl32 (0, shl
->permctx
);
8726 shl
->size
= sizeof (struct vms_shl
);
8727 bfd_putl16 (0, shl
->fill_1
);
8729 bfd_putl32 (0, shl
->icb
);
8730 shl
->imgnam
[0] = strlen (PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
));
8731 memcpy (shl
->imgnam
+ 1, PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
),
8734 off
+= sizeof (struct vms_shl
);
8740 bfd_putl32 (off
, eiaf
->codeadroff
);
8742 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8744 struct alpha_vms_shlib_el
*shlib
;
8747 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8749 if (VEC_COUNT (shlib
->ca
) == 0)
8752 bfd_putl32 (VEC_COUNT (shlib
->ca
), content
+ off
);
8753 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8756 for (j
= 0; j
< VEC_COUNT (shlib
->ca
); j
++)
8758 bfd_putl32 (VEC_EL (shlib
->ca
, bfd_vma
, j
) - t
->base_addr
,
8764 bfd_putl32 (0, content
+ off
);
8765 bfd_putl32 (0, content
+ off
+ 4);
8772 bfd_putl32 (off
, eiaf
->lpfixoff
);
8774 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8776 struct alpha_vms_shlib_el
*shlib
;
8779 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8781 if (VEC_COUNT (shlib
->lp
) == 0)
8784 bfd_putl32 (VEC_COUNT (shlib
->lp
), content
+ off
);
8785 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8788 for (j
= 0; j
< VEC_COUNT (shlib
->lp
); j
++)
8790 bfd_putl32 (VEC_EL (shlib
->lp
, bfd_vma
, j
) - t
->base_addr
,
8796 bfd_putl32 (0, content
+ off
);
8797 bfd_putl32 (0, content
+ off
+ 4);
8804 bfd_putl32 (off
, eiaf
->qdotadroff
);
8806 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8808 struct alpha_vms_shlib_el
*shlib
;
8811 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8813 if (VEC_COUNT (shlib
->qr
) == 0)
8816 bfd_putl32 (VEC_COUNT (shlib
->qr
), content
+ off
);
8817 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8820 for (j
= 0; j
< VEC_COUNT (shlib
->qr
); j
++)
8822 struct alpha_vms_vma_ref
*r
;
8823 r
= &VEC_EL (shlib
->qr
, struct alpha_vms_vma_ref
, j
);
8824 bfd_putl32 (r
->vma
- t
->base_addr
, content
+ off
);
8825 bfd_putl32 (r
->ref
, content
+ off
+ 4);
8830 bfd_putl32 (0, content
+ off
);
8831 bfd_putl32 (0, content
+ off
+ 4);
8836 /* Write the change protection table. */
8837 bfd_putl32 (off
, eiaf
->chgprtoff
);
8838 bfd_putl32 (chgprt_num
, content
+ off
);
8841 for (sec
= info
->output_bfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
8843 struct vms_eicp
*eicp
;
8846 if ((sec
->flags
& SEC_LINKER_CREATED
) != 0 &&
8847 strcmp (sec
->name
, "$FIXUP$") == 0)
8849 else if ((sec
->flags
& SEC_RELOC
) != 0
8850 && (sec
->flags
& (SEC_CODE
| SEC_READONLY
)) != 0)
8855 eicp
= (struct vms_eicp
*)(content
+ off
);
8856 bfd_putl64 (sec
->vma
- t
->base_addr
, eicp
->baseva
);
8857 bfd_putl32 ((sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1),
8859 bfd_putl32 (prot
, eicp
->newprt
);
8860 off
+= sizeof (struct vms_eicp
);
8866 /* Called by bfd_hash_traverse to fill the symbol table.
8867 Return FALSE in case of failure. */
8870 alpha_vms_link_output_symbol (struct bfd_hash_entry
*bh
, void *infov
)
8872 struct bfd_link_hash_entry
*hc
= (struct bfd_link_hash_entry
*) bh
;
8873 struct bfd_link_info
*info
= (struct bfd_link_info
*)infov
;
8874 struct alpha_vms_link_hash_entry
*h
;
8875 struct vms_symbol_entry
*sym
;
8877 if (hc
->type
== bfd_link_hash_warning
)
8880 if (hc
->type
== bfd_link_hash_new
)
8883 h
= (struct alpha_vms_link_hash_entry
*) hc
;
8885 switch (h
->root
.type
)
8887 case bfd_link_hash_undefined
:
8889 case bfd_link_hash_new
:
8890 case bfd_link_hash_warning
:
8892 case bfd_link_hash_undefweak
:
8894 case bfd_link_hash_defined
:
8895 case bfd_link_hash_defweak
:
8897 asection
*sec
= h
->root
.u
.def
.section
;
8899 /* FIXME: this is certainly a symbol from a dynamic library. */
8900 if (bfd_is_abs_section (sec
))
8903 if (sec
->owner
->flags
& DYNAMIC
)
8907 case bfd_link_hash_common
:
8909 case bfd_link_hash_indirect
:
8913 /* Do not write not kept symbols. */
8914 if (info
->strip
== strip_some
8915 && bfd_hash_lookup (info
->keep_hash
, h
->root
.root
.string
,
8916 FALSE
, FALSE
) != NULL
)
8921 /* This symbol doesn't come from a VMS object. So we suppose it is
8923 int len
= strlen (h
->root
.root
.string
);
8925 sym
= (struct vms_symbol_entry
*)bfd_zalloc (info
->output_bfd
,
8926 sizeof (*sym
) + len
);
8930 memcpy (sym
->name
, h
->root
.root
.string
, len
);
8932 sym
->owner
= info
->output_bfd
;
8934 sym
->typ
= EGSD__C_SYMG
;
8936 sym
->flags
= EGSY__V_DEF
| EGSY__V_REL
;
8937 sym
->symbol_vector
= h
->root
.u
.def
.value
;
8938 sym
->section
= h
->root
.u
.def
.section
;
8939 sym
->value
= h
->root
.u
.def
.value
;
8944 if (!add_symbol_entry (info
->output_bfd
, sym
))
8951 alpha_vms_bfd_final_link (bfd
*abfd
, struct bfd_link_info
*info
)
8954 struct bfd_link_order
*p
;
8962 if (bfd_link_relocatable (info
))
8964 /* FIXME: we do not yet support relocatable link. It is not obvious
8965 how to do it for debug infos. */
8966 (*info
->callbacks
->einfo
)(_("%P: relocatable link is not supported\n"));
8970 abfd
->outsymbols
= NULL
;
8973 /* Mark all sections which will be included in the output file. */
8974 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8975 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
8976 if (p
->type
== bfd_indirect_link_order
)
8977 p
->u
.indirect
.section
->linker_mark
= TRUE
;
8980 /* Handle all the link order information for the sections. */
8981 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8983 printf ("For section %s (at 0x%08x, flags=0x%08x):\n",
8984 o
->name
, (unsigned)o
->vma
, (unsigned)o
->flags
);
8986 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
8988 printf (" at 0x%08x - 0x%08x: ",
8989 (unsigned)p
->offset
, (unsigned)(p
->offset
+ p
->size
- 1));
8992 case bfd_section_reloc_link_order
:
8993 case bfd_symbol_reloc_link_order
:
8994 printf (" section/symbol reloc\n");
8996 case bfd_indirect_link_order
:
8997 printf (" section %s of %s\n",
8998 p
->u
.indirect
.section
->name
,
8999 p
->u
.indirect
.section
->owner
->filename
);
9001 case bfd_data_link_order
:
9002 printf (" explicit data\n");
9005 printf (" *unknown* type %u\n", p
->type
);
9012 /* Generate the symbol table. */
9013 BFD_ASSERT (PRIV (syms
) == NULL
);
9014 if (info
->strip
!= strip_all
)
9015 bfd_hash_traverse (&info
->hash
->table
, alpha_vms_link_output_symbol
, info
);
9017 /* Find the entry point. */
9018 if (bfd_get_start_address (abfd
) == 0)
9020 bfd
*startbfd
= NULL
;
9022 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9024 /* Consider only VMS object files. */
9025 if (sub
->xvec
!= abfd
->xvec
)
9028 if (!PRIV2 (sub
, eom_data
).eom_has_transfer
)
9030 if ((PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
) && startbfd
)
9032 if (startbfd
!= NULL
9033 && !(PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
))
9035 (*info
->callbacks
->einfo
)
9036 /* xgettext:c-format */
9037 (_("%P: multiple entry points: in modules %pB and %pB\n"),
9046 unsigned int ps_idx
= PRIV2 (startbfd
, eom_data
).eom_l_psindx
;
9047 bfd_vma tfradr
= PRIV2 (startbfd
, eom_data
).eom_l_tfradr
;
9050 sec
= PRIV2 (startbfd
, sections
)[ps_idx
];
9052 bfd_set_start_address
9053 (abfd
, sec
->output_section
->vma
+ sec
->output_offset
+ tfradr
);
9057 /* Set transfer addresses. */
9060 struct bfd_link_hash_entry
*h
;
9063 PRIV (transfer_address
[i
++]) = 0xffffffff00000340ULL
; /* SYS$IMGACT */
9064 h
= bfd_link_hash_lookup (info
->hash
, "LIB$INITIALIZE", FALSE
, FALSE
, TRUE
);
9065 if (h
!= NULL
&& h
->type
== bfd_link_hash_defined
)
9066 PRIV (transfer_address
[i
++]) =
9067 alpha_vms_get_sym_value (h
->u
.def
.section
, h
->u
.def
.value
);
9068 PRIV (transfer_address
[i
++]) = bfd_get_start_address (abfd
);
9070 PRIV (transfer_address
[i
++]) = 0;
9073 /* Allocate contents.
9074 Also compute the virtual base address. */
9075 base_addr
= (bfd_vma
)-1;
9077 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9079 if (o
->flags
& SEC_HAS_CONTENTS
)
9081 o
->contents
= bfd_alloc (abfd
, o
->size
);
9082 if (o
->contents
== NULL
)
9085 if (o
->flags
& SEC_LOAD
)
9087 if (o
->vma
< base_addr
)
9089 if (o
->vma
+ o
->size
> last_addr
)
9090 last_addr
= o
->vma
+ o
->size
;
9092 /* Clear the RELOC flags. Currently we don't support incremental
9093 linking. We use the RELOC flag for computing the eicp entries. */
9094 o
->flags
&= ~SEC_RELOC
;
9097 /* Create the fixup section. */
9098 fixupsec
= bfd_make_section_anyway_with_flags
9099 (info
->output_bfd
, "$FIXUP$",
9100 SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
9101 if (fixupsec
== NULL
)
9103 last_addr
= (last_addr
+ 0xffff) & ~0xffff;
9104 fixupsec
->vma
= last_addr
;
9106 alpha_vms_link_hash (info
)->fixup
= fixupsec
;
9107 alpha_vms_link_hash (info
)->base_addr
= base_addr
;
9109 /* Create the DMT section, if necessary. */
9110 BFD_ASSERT (PRIV (dst_section
) == NULL
);
9111 dst
= bfd_get_section_by_name (abfd
, "$DST$");
9112 if (dst
!= NULL
&& dst
->size
== 0)
9116 PRIV (dst_section
) = dst
;
9117 dmt
= bfd_make_section_anyway_with_flags
9118 (info
->output_bfd
, "$DMT$",
9119 SEC_DEBUGGING
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
9126 /* Read all sections from the inputs. */
9127 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9129 if (sub
->flags
& DYNAMIC
)
9131 alpha_vms_create_eisd_for_shared (abfd
, sub
);
9135 if (!alpha_vms_read_sections_content (sub
, info
))
9139 /* Handle all the link order information for the sections.
9140 Note: past this point, it is not possible to create new sections. */
9141 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9143 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
9147 case bfd_section_reloc_link_order
:
9148 case bfd_symbol_reloc_link_order
:
9151 case bfd_indirect_link_order
:
9155 if (! _bfd_default_link_order (abfd
, info
, o
, p
))
9162 /* Compute fixups. */
9163 if (!alpha_vms_build_fixups (info
))
9166 /* Compute the DMT. */
9170 unsigned char *contents
= NULL
;
9172 /* In pass 1, compute the size. In pass 2, write the DMT contents. */
9173 for (pass
= 0; pass
< 2; pass
++)
9175 unsigned int off
= 0;
9177 /* For each object file (ie for each module). */
9178 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9181 struct vms_dmt_header
*dmth
= NULL
;
9182 unsigned int psect_count
;
9184 /* Skip this module if it has no DST. */
9185 sub_dst
= PRIV2 (sub
, dst_section
);
9186 if (sub_dst
== NULL
|| sub_dst
->size
== 0)
9191 /* Write the header. */
9192 dmth
= (struct vms_dmt_header
*)(contents
+ off
);
9193 bfd_putl32 (sub_dst
->output_offset
, dmth
->modbeg
);
9194 bfd_putl32 (sub_dst
->size
, dmth
->size
);
9197 off
+= sizeof (struct vms_dmt_header
);
9200 /* For each section (ie for each psect). */
9201 for (o
= sub
->sections
; o
!= NULL
; o
= o
->next
)
9203 /* Only consider interesting sections. */
9204 if (!(o
->flags
& SEC_ALLOC
))
9206 if (o
->flags
& SEC_LINKER_CREATED
)
9211 /* Write an entry. */
9212 struct vms_dmt_psect
*dmtp
;
9214 dmtp
= (struct vms_dmt_psect
*)(contents
+ off
);
9215 bfd_putl32 (o
->output_offset
+ o
->output_section
->vma
,
9217 bfd_putl32 (o
->size
, dmtp
->length
);
9220 off
+= sizeof (struct vms_dmt_psect
);
9223 bfd_putl32 (psect_count
, dmth
->psect_count
);
9228 contents
= bfd_zalloc (info
->output_bfd
, off
);
9229 if (contents
== NULL
)
9231 dmt
->contents
= contents
;
9236 BFD_ASSERT (off
== dmt
->size
);
9244 /* Read the contents of a section.
9245 buf points to a buffer of buf_size bytes to be filled with
9246 section data (starting at offset into section) */
9249 alpha_vms_get_section_contents (bfd
*abfd
, asection
*section
,
9250 void *buf
, file_ptr offset
,
9251 bfd_size_type count
)
9255 /* Image are easy. */
9256 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
9257 return _bfd_generic_get_section_contents (abfd
, section
,
9258 buf
, offset
, count
);
9261 if (offset
+ count
< count
9262 || offset
+ count
> section
->size
)
9264 bfd_set_error (bfd_error_invalid_operation
);
9268 /* If the section is already in memory, just copy it. */
9269 if (section
->flags
& SEC_IN_MEMORY
)
9271 BFD_ASSERT (section
->contents
!= NULL
);
9272 memcpy (buf
, section
->contents
+ offset
, count
);
9275 if (section
->size
== 0)
9278 /* Alloc in memory and read ETIRs. */
9279 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
9281 BFD_ASSERT (sec
->contents
== NULL
);
9283 if (sec
->size
!= 0 && (sec
->flags
& SEC_HAS_CONTENTS
))
9285 sec
->contents
= bfd_alloc (abfd
, sec
->size
);
9286 if (sec
->contents
== NULL
)
9290 if (!alpha_vms_read_sections_content (abfd
, NULL
))
9292 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
9294 sec
->flags
|= SEC_IN_MEMORY
;
9295 memcpy (buf
, section
->contents
+ offset
, count
);
9300 /* Set the format of a file being written. */
9303 alpha_vms_mkobject (bfd
* abfd
)
9305 const bfd_arch_info_type
*arch
;
9307 vms_debug2 ((1, "alpha_vms_mkobject (%p)\n", abfd
));
9309 if (!vms_initialize (abfd
))
9312 PRIV (recwr
.buf
) = bfd_alloc (abfd
, MAX_OUTREC_SIZE
);
9313 if (PRIV (recwr
.buf
) == NULL
)
9316 arch
= bfd_scan_arch ("alpha");
9320 bfd_set_error (bfd_error_wrong_format
);
9324 abfd
->arch_info
= arch
;
9331 /* Called when the BFD is being closed to do any necessary cleanup. */
9334 vms_close_and_cleanup (bfd
* abfd
)
9336 vms_debug2 ((1, "vms_close_and_cleanup (%p)\n", abfd
));
9338 if (abfd
== NULL
|| abfd
->tdata
.any
== NULL
)
9341 if (abfd
->format
== bfd_object
)
9343 struct module
*module
;
9345 free (PRIV (recrd
.buf
));
9346 free (PRIV (sections
));
9348 free (PRIV (dst_ptr_offsets
));
9350 for (module
= PRIV (modules
); module
; module
= module
->next
)
9351 free (module
->file_table
);
9354 if (abfd
->direction
== write_direction
)
9356 /* Last step on VMS is to convert the file to variable record length
9358 if (!bfd_cache_close (abfd
))
9360 if (!_bfd_vms_convert_to_var_unix_filename (abfd
->filename
))
9366 return _bfd_generic_close_and_cleanup (abfd
);
9369 /* Called when a new section is created. */
9372 vms_new_section_hook (bfd
* abfd
, asection
*section
)
9376 vms_debug2 ((1, "vms_new_section_hook (%p, [%u]%s)\n",
9377 abfd
, section
->index
, section
->name
));
9379 if (!bfd_set_section_alignment (section
, 0))
9382 vms_debug2 ((7, "%u: %s\n", section
->index
, section
->name
));
9384 amt
= sizeof (struct vms_section_data_struct
);
9385 section
->used_by_bfd
= bfd_zalloc (abfd
, amt
);
9386 if (section
->used_by_bfd
== NULL
)
9389 /* Create the section symbol. */
9390 return _bfd_generic_new_section_hook (abfd
, section
);
9393 /* Part 4.5, symbols. */
9395 /* Print symbol to file according to how. how is one of
9396 bfd_print_symbol_name just print the name
9397 bfd_print_symbol_more print more (???)
9398 bfd_print_symbol_all print all we know, which is not much right now :-). */
9401 vms_print_symbol (bfd
* abfd
,
9404 bfd_print_symbol_type how
)
9406 vms_debug2 ((1, "vms_print_symbol (%p, %p, %p, %d)\n",
9407 abfd
, file
, symbol
, how
));
9411 case bfd_print_symbol_name
:
9412 case bfd_print_symbol_more
:
9413 fprintf ((FILE *)file
," %s", symbol
->name
);
9416 case bfd_print_symbol_all
:
9418 const char *section_name
= symbol
->section
->name
;
9420 bfd_print_symbol_vandf (abfd
, file
, symbol
);
9422 fprintf ((FILE *) file
," %-8s %s", section_name
, symbol
->name
);
9428 /* Return information about symbol in ret.
9430 fill type, value and name
9433 B bss segment symbol
9435 D data segment symbol
9437 t a static function symbol
9438 T text segment symbol
9443 vms_get_symbol_info (bfd
* abfd ATTRIBUTE_UNUSED
,
9449 vms_debug2 ((1, "vms_get_symbol_info (%p, %p, %p)\n", abfd
, symbol
, ret
));
9451 sec
= symbol
->section
;
9458 else if (bfd_is_com_section (sec
))
9460 else if (bfd_is_abs_section (sec
))
9462 else if (bfd_is_und_section (sec
))
9464 else if (bfd_is_ind_section (sec
))
9466 else if ((symbol
->flags
& BSF_FUNCTION
)
9467 || (bfd_section_flags (sec
) & SEC_CODE
))
9469 else if (bfd_section_flags (sec
) & SEC_DATA
)
9471 else if (bfd_section_flags (sec
) & SEC_ALLOC
)
9476 if (ret
->type
!= 'U')
9477 ret
->value
= symbol
->value
+ symbol
->section
->vma
;
9480 ret
->name
= symbol
->name
;
9483 /* Return TRUE if the given symbol sym in the BFD abfd is
9484 a compiler generated local label, else return FALSE. */
9487 vms_bfd_is_local_label_name (bfd
* abfd ATTRIBUTE_UNUSED
,
9490 return name
[0] == '$';
9493 /* Part 4.7, writing an object file. */
9495 /* Sets the contents of the section section in BFD abfd to the data starting
9496 in memory at LOCATION. The data is written to the output section starting
9497 at offset offset for count bytes.
9499 Normally TRUE is returned, else FALSE. Possible error returns are:
9500 o bfd_error_no_contents - The output section does not have the
9501 SEC_HAS_CONTENTS attribute, so nothing can be written to it.
9502 o and some more too */
9505 _bfd_vms_set_section_contents (bfd
* abfd
,
9507 const void * location
,
9509 bfd_size_type count
)
9511 if (section
->contents
== NULL
)
9513 section
->contents
= bfd_alloc (abfd
, section
->size
);
9514 if (section
->contents
== NULL
)
9517 memcpy (section
->contents
+ offset
, location
, (size_t) count
);
9523 /* Set the architecture and machine type in BFD abfd to arch and mach.
9524 Find the correct pointer to a structure and insert it into the arch_info
9528 alpha_vms_set_arch_mach (bfd
*abfd
,
9529 enum bfd_architecture arch
, unsigned long mach
)
9531 if (arch
!= bfd_arch_alpha
9532 && arch
!= bfd_arch_unknown
)
9535 return bfd_default_set_arch_mach (abfd
, arch
, mach
);
9538 /* Set section VMS flags. Clear NO_FLAGS and set FLAGS. */
9541 bfd_vms_set_section_flags (bfd
*abfd ATTRIBUTE_UNUSED
,
9542 asection
*sec
, flagword no_flags
, flagword flags
)
9544 vms_section_data (sec
)->no_flags
= no_flags
;
9545 vms_section_data (sec
)->flags
= flags
;
9548 struct vms_private_data_struct
*
9549 bfd_vms_get_data (bfd
*abfd
)
9551 return (struct vms_private_data_struct
*)abfd
->tdata
.any
;
9554 #define vms_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false
9555 #define vms_bfd_link_just_syms _bfd_generic_link_just_syms
9556 #define vms_bfd_copy_link_hash_symbol_type \
9557 _bfd_generic_copy_link_hash_symbol_type
9558 #define vms_bfd_is_group_section bfd_generic_is_group_section
9559 #define vms_bfd_group_name bfd_generic_group_name
9560 #define vms_bfd_discard_group bfd_generic_discard_group
9561 #define vms_section_already_linked _bfd_generic_section_already_linked
9562 #define vms_bfd_define_common_symbol bfd_generic_define_common_symbol
9563 #define vms_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
9564 #define vms_bfd_define_start_stop bfd_generic_define_start_stop
9565 #define vms_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
9567 #define vms_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
9568 #define vms_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
9569 #define vms_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data
9570 #define vms_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
9571 #define vms_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
9572 #define vms_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
9574 /* Symbols table. */
9575 #define alpha_vms_make_empty_symbol _bfd_generic_make_empty_symbol
9576 #define alpha_vms_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false
9577 #define alpha_vms_print_symbol vms_print_symbol
9578 #define alpha_vms_get_symbol_info vms_get_symbol_info
9579 #define alpha_vms_get_symbol_version_string \
9580 _bfd_nosymbols_get_symbol_version_string
9582 #define alpha_vms_read_minisymbols _bfd_generic_read_minisymbols
9583 #define alpha_vms_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
9584 #define alpha_vms_get_lineno _bfd_nosymbols_get_lineno
9585 #define alpha_vms_find_inliner_info _bfd_nosymbols_find_inliner_info
9586 #define alpha_vms_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
9587 #define alpha_vms_find_nearest_line _bfd_vms_find_nearest_line
9588 #define alpha_vms_find_line _bfd_nosymbols_find_line
9589 #define alpha_vms_bfd_is_local_label_name vms_bfd_is_local_label_name
9591 /* Generic table. */
9592 #define alpha_vms_close_and_cleanup vms_close_and_cleanup
9593 #define alpha_vms_bfd_free_cached_info vms_bfd_free_cached_info
9594 #define alpha_vms_new_section_hook vms_new_section_hook
9595 #define alpha_vms_set_section_contents _bfd_vms_set_section_contents
9596 #define alpha_vms_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
9598 #define alpha_vms_bfd_get_relocated_section_contents \
9599 bfd_generic_get_relocated_section_contents
9601 #define alpha_vms_bfd_relax_section bfd_generic_relax_section
9602 #define alpha_vms_bfd_gc_sections bfd_generic_gc_sections
9603 #define alpha_vms_bfd_lookup_section_flags bfd_generic_lookup_section_flags
9604 #define alpha_vms_bfd_merge_sections bfd_generic_merge_sections
9605 #define alpha_vms_bfd_is_group_section bfd_generic_is_group_section
9606 #define alpha_vms_bfd_group_name bfd_generic_group_name
9607 #define alpha_vms_bfd_discard_group bfd_generic_discard_group
9608 #define alpha_vms_section_already_linked \
9609 _bfd_generic_section_already_linked
9611 #define alpha_vms_bfd_define_common_symbol bfd_generic_define_common_symbol
9612 #define alpha_vms_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
9613 #define alpha_vms_bfd_define_start_stop bfd_generic_define_start_stop
9614 #define alpha_vms_bfd_link_just_syms _bfd_generic_link_just_syms
9615 #define alpha_vms_bfd_copy_link_hash_symbol_type \
9616 _bfd_generic_copy_link_hash_symbol_type
9618 #define alpha_vms_bfd_link_split_section _bfd_generic_link_split_section
9620 #define alpha_vms_get_dynamic_symtab_upper_bound \
9621 _bfd_nodynamic_get_dynamic_symtab_upper_bound
9622 #define alpha_vms_canonicalize_dynamic_symtab \
9623 _bfd_nodynamic_canonicalize_dynamic_symtab
9624 #define alpha_vms_get_dynamic_reloc_upper_bound \
9625 _bfd_nodynamic_get_dynamic_reloc_upper_bound
9626 #define alpha_vms_canonicalize_dynamic_reloc \
9627 _bfd_nodynamic_canonicalize_dynamic_reloc
9628 #define alpha_vms_bfd_link_check_relocs _bfd_generic_link_check_relocs
9630 const bfd_target alpha_vms_vec
=
9632 "vms-alpha", /* Name. */
9633 bfd_target_evax_flavour
,
9634 BFD_ENDIAN_LITTLE
, /* Data byte order is little. */
9635 BFD_ENDIAN_LITTLE
, /* Header byte order is little. */
9637 (HAS_RELOC
| EXEC_P
| HAS_LINENO
| HAS_DEBUG
| HAS_SYMS
| HAS_LOCALS
9638 | WP_TEXT
| D_PAGED
), /* Object flags. */
9639 (SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
9640 | SEC_READONLY
| SEC_CODE
| SEC_DATA
9641 | SEC_HAS_CONTENTS
| SEC_IN_MEMORY
), /* Sect flags. */
9642 0, /* symbol_leading_char. */
9643 ' ', /* ar_pad_char. */
9644 15, /* ar_max_namelen. */
9645 0, /* match priority. */
9646 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
9647 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
9648 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
9649 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
9650 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
9651 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
9653 { /* bfd_check_format. */
9656 _bfd_vms_lib_alpha_archive_p
,
9659 { /* bfd_set_format. */
9660 _bfd_bool_bfd_false_error
,
9662 _bfd_vms_lib_alpha_mkarchive
,
9663 _bfd_bool_bfd_false_error
9665 { /* bfd_write_contents. */
9666 _bfd_bool_bfd_false_error
,
9667 alpha_vms_write_object_contents
,
9668 _bfd_vms_lib_write_archive_contents
,
9669 _bfd_bool_bfd_false_error
9672 BFD_JUMP_TABLE_GENERIC (alpha_vms
),
9673 BFD_JUMP_TABLE_COPY (vms
),
9674 BFD_JUMP_TABLE_CORE (_bfd_nocore
),
9675 BFD_JUMP_TABLE_ARCHIVE (_bfd_vms_lib
),
9676 BFD_JUMP_TABLE_SYMBOLS (alpha_vms
),
9677 BFD_JUMP_TABLE_RELOCS (alpha_vms
),
9678 BFD_JUMP_TABLE_WRITE (alpha_vms
),
9679 BFD_JUMP_TABLE_LINK (alpha_vms
),
9680 BFD_JUMP_TABLE_DYNAMIC (alpha_vms
),