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
;
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
;
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
& 31;
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
= (bfd_vma
) 1 << section
->alignment_power
;
1287 base_addr
= (base_addr
+ align_addr
- 1) & -align_addr
;
1288 section
->vma
= base_addr
;
1289 base_addr
+= section
->size
;
1292 /* Append it to the section array. */
1293 if (PRIV (section_count
) >= PRIV (section_max
))
1295 if (PRIV (section_max
) == 0)
1296 PRIV (section_max
) = 16;
1298 PRIV (section_max
) *= 2;
1299 PRIV (sections
) = bfd_realloc_or_free
1300 (PRIV (sections
), PRIV (section_max
) * sizeof (asection
*));
1301 if (PRIV (sections
) == NULL
)
1305 PRIV (sections
)[PRIV (section_count
)] = section
;
1306 PRIV (section_count
)++;
1312 unsigned int nameoff
;
1313 struct vms_symbol_entry
*entry
;
1314 struct vms_egsy
*egsy
= (struct vms_egsy
*) vms_rec
;
1317 old_flags
= bfd_getl16 (egsy
->flags
);
1318 if (old_flags
& EGSY__V_DEF
)
1319 nameoff
= ESDF__B_NAMLNG
;
1321 nameoff
= ESRF__B_NAMLNG
;
1323 if (nameoff
>= gsd_size
)
1325 _bfd_error_handler (_("ECSD__C_SYM record is too small"));
1326 bfd_set_error (bfd_error_bad_value
);
1329 entry
= add_symbol (abfd
, vms_rec
+ nameoff
, gsd_size
- nameoff
);
1333 /* Allow only duplicate reference. */
1334 if ((entry
->flags
& EGSY__V_DEF
) && (old_flags
& EGSY__V_DEF
))
1337 if (entry
->typ
== 0)
1339 entry
->typ
= gsd_type
;
1340 entry
->data_type
= egsy
->datyp
;
1341 entry
->flags
= old_flags
;
1344 if (old_flags
& EGSY__V_DEF
)
1346 struct vms_esdf
*esdf
= (struct vms_esdf
*)vms_rec
;
1349 entry
->value
= bfd_getl64 (esdf
->value
);
1350 if (PRIV (sections
) == NULL
)
1353 psindx
= bfd_getl32 (esdf
->psindx
);
1354 /* PR 21813: Check for an out of range index. */
1355 if (psindx
< 0 || psindx
>= (int) PRIV (section_count
))
1357 _bfd_error_handler (_("corrupt EGSD record: its psindx field is too big (%#lx)"),
1359 bfd_set_error (bfd_error_bad_value
);
1362 entry
->section
= PRIV (sections
)[psindx
];
1364 if (old_flags
& EGSY__V_NORM
)
1366 PRIV (norm_sym_count
)++;
1368 entry
->code_value
= bfd_getl64 (esdf
->code_address
);
1369 psindx
= bfd_getl32 (esdf
->ca_psindx
);
1370 /* PR 21813: Check for an out of range index. */
1371 if (psindx
< 0 || psindx
>= (int) PRIV (section_count
))
1373 _bfd_error_handler (_("corrupt EGSD record: its psindx field is too big (%#lx)"),
1375 bfd_set_error (bfd_error_bad_value
);
1378 entry
->code_section
= PRIV (sections
)[psindx
];
1386 struct vms_symbol_entry
*entry
;
1387 struct vms_egst
*egst
= (struct vms_egst
*)vms_rec
;
1389 unsigned int nameoff
= offsetof (struct vms_egst
, namlng
);
1391 old_flags
= bfd_getl16 (egst
->header
.flags
);
1393 if (nameoff
>= gsd_size
)
1395 _bfd_error_handler (_("ECSD__C_SYMG record is too small"));
1396 bfd_set_error (bfd_error_bad_value
);
1399 entry
= add_symbol (abfd
, &egst
->namlng
, gsd_size
- nameoff
);
1403 entry
->typ
= gsd_type
;
1404 entry
->data_type
= egst
->header
.datyp
;
1405 entry
->flags
= old_flags
;
1407 entry
->symbol_vector
= bfd_getl32 (egst
->value
);
1409 if (old_flags
& EGSY__V_REL
)
1413 if (PRIV (sections
) == NULL
)
1415 psindx
= bfd_getl32 (egst
->psindx
);
1416 /* PR 21813: Check for an out of range index. */
1417 if (psindx
< 0 || psindx
>= (int) PRIV (section_count
))
1419 _bfd_error_handler (_("corrupt EGSD record: its psindx field is too big (%#lx)"),
1421 bfd_set_error (bfd_error_bad_value
);
1424 entry
->section
= PRIV (sections
)[psindx
];
1427 entry
->section
= bfd_abs_section_ptr
;
1429 entry
->value
= bfd_getl64 (egst
->lp_2
);
1431 if (old_flags
& EGSY__V_NORM
)
1433 PRIV (norm_sym_count
)++;
1435 entry
->code_value
= bfd_getl64 (egst
->lp_1
);
1436 entry
->code_section
= bfd_abs_section_ptr
;
1443 /* Currently ignored. */
1448 _bfd_error_handler (_("unknown EGSD subtype %d"), gsd_type
);
1449 bfd_set_error (bfd_error_bad_value
);
1453 PRIV (recrd
.rec_size
) -= gsd_size
;
1454 PRIV (recrd
.rec
) += gsd_size
;
1457 /* FIXME: Should we complain if PRIV (recrd.rec_size) is not zero ? */
1459 if (PRIV (gsd_sym_count
) > 0)
1460 abfd
->flags
|= HAS_SYMS
;
1465 /* Stack routines for vms ETIR commands. */
1467 /* Push value and section index. */
1470 _bfd_vms_push (bfd
*abfd
, bfd_vma val
, unsigned int reloc
)
1472 vms_debug2 ((4, "<push %08lx (0x%08x) at %d>\n",
1473 (unsigned long)val
, reloc
, PRIV (stackptr
)));
1475 PRIV (stack
[PRIV (stackptr
)]).value
= val
;
1476 PRIV (stack
[PRIV (stackptr
)]).reloc
= reloc
;
1478 if (PRIV (stackptr
) >= STACKSIZE
)
1480 bfd_set_error (bfd_error_bad_value
);
1481 _bfd_error_handler (_("stack overflow (%d) in _bfd_vms_push"), PRIV (stackptr
));
1486 /* Pop value and section index. */
1489 _bfd_vms_pop (bfd
*abfd
, bfd_vma
*val
, unsigned int *rel
)
1491 if (PRIV (stackptr
) == 0)
1493 bfd_set_error (bfd_error_bad_value
);
1494 _bfd_error_handler (_("stack underflow in _bfd_vms_pop"));
1498 *val
= PRIV (stack
[PRIV (stackptr
)]).value
;
1499 *rel
= PRIV (stack
[PRIV (stackptr
)]).reloc
;
1501 vms_debug2 ((4, "<pop %08lx (0x%08x)>\n", (unsigned long)*val
, *rel
));
1504 /* Routines to fill sections contents during tir/etir read. */
1506 /* Initialize image buffer pointer to be filled. */
1509 image_set_ptr (bfd
*abfd
, bfd_vma vma
, int sect
, struct bfd_link_info
*info
)
1513 vms_debug2 ((4, "image_set_ptr (0x%08x, sect=%d)\n", (unsigned)vma
, sect
));
1515 if (PRIV (sections
) == NULL
)
1517 if (sect
< 0 || sect
>= (int) PRIV (section_count
))
1520 sec
= PRIV (sections
)[sect
];
1524 /* Reading contents to an output bfd. */
1526 if (sec
->output_section
== NULL
)
1528 /* Section discarded. */
1529 vms_debug2 ((5, " section %s discarded\n", sec
->name
));
1531 /* This is not used. */
1532 PRIV (image_section
) = NULL
;
1533 PRIV (image_offset
) = 0;
1536 PRIV (image_offset
) = sec
->output_offset
+ vma
;
1537 PRIV (image_section
) = sec
->output_section
;
1541 PRIV (image_offset
) = vma
;
1542 PRIV (image_section
) = sec
;
1546 /* Increment image buffer pointer by offset. */
1549 image_inc_ptr (bfd
*abfd
, bfd_vma offset
)
1551 vms_debug2 ((4, "image_inc_ptr (%u)\n", (unsigned)offset
));
1553 PRIV (image_offset
) += offset
;
1556 /* Save current DST location counter under specified index. */
1559 dst_define_location (bfd
*abfd
, unsigned int loc
)
1561 vms_debug2 ((4, "dst_define_location (%d)\n", (int)loc
));
1563 /* Grow the ptr offset table if necessary. */
1564 if (loc
+ 1 > PRIV (dst_ptr_offsets_count
))
1566 PRIV (dst_ptr_offsets
) = bfd_realloc (PRIV (dst_ptr_offsets
),
1567 (loc
+ 1) * sizeof (unsigned int));
1568 PRIV (dst_ptr_offsets_count
) = loc
+ 1;
1571 PRIV (dst_ptr_offsets
)[loc
] = PRIV (image_offset
);
1574 /* Restore saved DST location counter from specified index. */
1577 dst_restore_location (bfd
*abfd
, unsigned int loc
)
1579 vms_debug2 ((4, "dst_restore_location (%d)\n", (int)loc
));
1581 PRIV (image_offset
) = PRIV (dst_ptr_offsets
)[loc
];
1584 /* Retrieve saved DST location counter from specified index. */
1587 dst_retrieve_location (bfd
*abfd
, unsigned int loc
)
1589 vms_debug2 ((4, "dst_retrieve_location (%d)\n", (int)loc
));
1591 return PRIV (dst_ptr_offsets
)[loc
];
1594 /* Write multiple bytes to section image. */
1597 image_write (bfd
*abfd
, unsigned char *ptr
, unsigned int size
)
1600 _bfd_vms_debug (8, "image_write from (%p, %d) to (%ld)\n", ptr
, size
,
1601 (long)PRIV (image_offset
));
1602 _bfd_hexdump (9, ptr
, size
, 0);
1605 if (PRIV (image_section
)->contents
!= NULL
)
1607 asection
*sec
= PRIV (image_section
);
1608 file_ptr off
= PRIV (image_offset
);
1611 if (off
> (file_ptr
)sec
->size
1612 || size
> (file_ptr
)sec
->size
1613 || off
+ size
> (file_ptr
)sec
->size
)
1615 bfd_set_error (bfd_error_bad_value
);
1619 memcpy (sec
->contents
+ off
, ptr
, size
);
1622 PRIV (image_offset
) += size
;
1626 /* Write byte to section image. */
1629 image_write_b (bfd
* abfd
, unsigned int value
)
1631 unsigned char data
[1];
1633 vms_debug2 ((6, "image_write_b (%02x)\n", (int) value
));
1637 return image_write (abfd
, data
, sizeof (data
));
1640 /* Write 2-byte word to image. */
1643 image_write_w (bfd
* abfd
, unsigned int value
)
1645 unsigned char data
[2];
1647 vms_debug2 ((6, "image_write_w (%04x)\n", (int) value
));
1649 bfd_putl16 (value
, data
);
1650 return image_write (abfd
, data
, sizeof (data
));
1653 /* Write 4-byte long to image. */
1656 image_write_l (bfd
* abfd
, unsigned long value
)
1658 unsigned char data
[4];
1660 vms_debug2 ((6, "image_write_l (%08lx)\n", value
));
1662 bfd_putl32 (value
, data
);
1663 return image_write (abfd
, data
, sizeof (data
));
1666 /* Write 8-byte quad to image. */
1669 image_write_q (bfd
* abfd
, bfd_vma value
)
1671 unsigned char data
[8];
1673 vms_debug2 ((6, "image_write_q (%08lx)\n", (unsigned long)value
));
1675 bfd_putl64 (value
, data
);
1676 return image_write (abfd
, data
, sizeof (data
));
1680 _bfd_vms_etir_name (int cmd
)
1684 case ETIR__C_STA_GBL
: return "ETIR__C_STA_GBL";
1685 case ETIR__C_STA_LW
: return "ETIR__C_STA_LW";
1686 case ETIR__C_STA_QW
: return "ETIR__C_STA_QW";
1687 case ETIR__C_STA_PQ
: return "ETIR__C_STA_PQ";
1688 case ETIR__C_STA_LI
: return "ETIR__C_STA_LI";
1689 case ETIR__C_STA_MOD
: return "ETIR__C_STA_MOD";
1690 case ETIR__C_STA_CKARG
: return "ETIR__C_STA_CKARG";
1691 case ETIR__C_STO_B
: return "ETIR__C_STO_B";
1692 case ETIR__C_STO_W
: return "ETIR__C_STO_W";
1693 case ETIR__C_STO_GBL
: return "ETIR__C_STO_GBL";
1694 case ETIR__C_STO_CA
: return "ETIR__C_STO_CA";
1695 case ETIR__C_STO_RB
: return "ETIR__C_STO_RB";
1696 case ETIR__C_STO_AB
: return "ETIR__C_STO_AB";
1697 case ETIR__C_STO_OFF
: return "ETIR__C_STO_OFF";
1698 case ETIR__C_STO_IMM
: return "ETIR__C_STO_IMM";
1699 case ETIR__C_STO_IMMR
: return "ETIR__C_STO_IMMR";
1700 case ETIR__C_STO_LW
: return "ETIR__C_STO_LW";
1701 case ETIR__C_STO_QW
: return "ETIR__C_STO_QW";
1702 case ETIR__C_STO_GBL_LW
: return "ETIR__C_STO_GBL_LW";
1703 case ETIR__C_STO_LP_PSB
: return "ETIR__C_STO_LP_PSB";
1704 case ETIR__C_STO_HINT_GBL
: return "ETIR__C_STO_HINT_GBL";
1705 case ETIR__C_STO_HINT_PS
: return "ETIR__C_STO_HINT_PS";
1706 case ETIR__C_OPR_ADD
: return "ETIR__C_OPR_ADD";
1707 case ETIR__C_OPR_SUB
: return "ETIR__C_OPR_SUB";
1708 case ETIR__C_OPR_INSV
: return "ETIR__C_OPR_INSV";
1709 case ETIR__C_OPR_USH
: return "ETIR__C_OPR_USH";
1710 case ETIR__C_OPR_ROT
: return "ETIR__C_OPR_ROT";
1711 case ETIR__C_OPR_REDEF
: return "ETIR__C_OPR_REDEF";
1712 case ETIR__C_OPR_DFLIT
: return "ETIR__C_OPR_DFLIT";
1713 case ETIR__C_STC_LP
: return "ETIR__C_STC_LP";
1714 case ETIR__C_STC_GBL
: return "ETIR__C_STC_GBL";
1715 case ETIR__C_STC_GCA
: return "ETIR__C_STC_GCA";
1716 case ETIR__C_STC_PS
: return "ETIR__C_STC_PS";
1717 case ETIR__C_STC_NBH_PS
: return "ETIR__C_STC_NBH_PS";
1718 case ETIR__C_STC_NOP_GBL
: return "ETIR__C_STC_NOP_GBL";
1719 case ETIR__C_STC_NOP_PS
: return "ETIR__C_STC_NOP_PS";
1720 case ETIR__C_STC_BSR_GBL
: return "ETIR__C_STC_BSR_GBL";
1721 case ETIR__C_STC_BSR_PS
: return "ETIR__C_STC_BSR_PS";
1722 case ETIR__C_STC_LDA_GBL
: return "ETIR__C_STC_LDA_GBL";
1723 case ETIR__C_STC_LDA_PS
: return "ETIR__C_STC_LDA_PS";
1724 case ETIR__C_STC_BOH_GBL
: return "ETIR__C_STC_BOH_GBL";
1725 case ETIR__C_STC_BOH_PS
: return "ETIR__C_STC_BOH_PS";
1726 case ETIR__C_STC_NBH_GBL
: return "ETIR__C_STC_NBH_GBL";
1727 case ETIR__C_STC_LP_PSB
: return "ETIR__C_STC_LP_PSB";
1728 case ETIR__C_CTL_SETRB
: return "ETIR__C_CTL_SETRB";
1729 case ETIR__C_CTL_AUGRB
: return "ETIR__C_CTL_AUGRB";
1730 case ETIR__C_CTL_DFLOC
: return "ETIR__C_CTL_DFLOC";
1731 case ETIR__C_CTL_STLOC
: return "ETIR__C_CTL_STLOC";
1732 case ETIR__C_CTL_STKDL
: return "ETIR__C_CTL_STKDL";
1735 /* These names have not yet been added to this switch statement. */
1736 _bfd_error_handler (_("unknown ETIR command %d"), cmd
);
1741 #define HIGHBIT(op) ((op & 0x80000000L) == 0x80000000L)
1744 _bfd_vms_get_value (bfd
*abfd
,
1745 const unsigned char *ascic
,
1746 const unsigned char *max_ascic
,
1747 struct bfd_link_info
*info
,
1749 struct alpha_vms_link_hash_entry
**hp
)
1754 struct alpha_vms_link_hash_entry
*h
;
1756 /* Not linking. Do not try to resolve the symbol. */
1765 if (ascic
+ len
>= max_ascic
)
1767 _bfd_error_handler (_("corrupt vms value"));
1773 for (i
= 0; i
< len
; i
++)
1774 name
[i
] = ascic
[i
+ 1];
1777 h
= (struct alpha_vms_link_hash_entry
*)
1778 bfd_link_hash_lookup (info
->hash
, name
, FALSE
, FALSE
, TRUE
);
1783 && (h
->root
.type
== bfd_link_hash_defined
1784 || h
->root
.type
== bfd_link_hash_defweak
))
1785 *vma
= h
->root
.u
.def
.value
1786 + h
->root
.u
.def
.section
->output_offset
1787 + h
->root
.u
.def
.section
->output_section
->vma
;
1788 else if (h
&& h
->root
.type
== bfd_link_hash_undefweak
)
1792 (*info
->callbacks
->undefined_symbol
)
1793 (info
, name
, abfd
, PRIV (image_section
), PRIV (image_offset
), TRUE
);
1800 #define RELC_SHR_BASE 0x10000
1801 #define RELC_SEC_BASE 0x20000
1802 #define RELC_MASK 0x0ffff
1805 alpha_vms_sym_to_ctxt (struct alpha_vms_link_hash_entry
*h
)
1807 /* Handle undefined symbols. */
1808 if (h
== NULL
|| h
->sym
== NULL
)
1811 if (h
->sym
->typ
== EGSD__C_SYMG
)
1813 if (h
->sym
->flags
& EGSY__V_REL
)
1814 return RELC_SHR_BASE
+ PRIV2 (h
->sym
->owner
, shr_index
);
1817 /* Can this happen (non-relocatable symg) ? I'd like to see
1822 if (h
->sym
->typ
== EGSD__C_SYM
)
1824 if (h
->sym
->flags
& EGSY__V_REL
)
1833 alpha_vms_get_sym_value (asection
*sect
, bfd_vma addr
)
1835 return sect
->output_section
->vma
+ sect
->output_offset
+ addr
;
1839 alpha_vms_fix_sec_rel (bfd
*abfd
, struct bfd_link_info
*info
,
1840 unsigned int rel
, bfd_vma vma
)
1844 if (PRIV (sections
) == NULL
)
1847 sec
= PRIV (sections
)[rel
& RELC_MASK
];
1851 if (sec
->output_section
== NULL
)
1853 return vma
+ sec
->output_section
->vma
+ sec
->output_offset
;
1856 return vma
+ sec
->vma
;
1859 /* Read an ETIR record from ABFD. If INFO is not null, put the content into
1860 the output section (used during linking).
1861 Return FALSE in case of error. */
1864 _bfd_vms_slurp_etir (bfd
*abfd
, struct bfd_link_info
*info
)
1867 unsigned int length
;
1868 unsigned char *maxptr
;
1873 struct alpha_vms_link_hash_entry
*h
;
1875 PRIV (recrd
.rec
) += ETIR__C_HEADER_SIZE
;
1876 PRIV (recrd
.rec_size
) -= ETIR__C_HEADER_SIZE
;
1878 ptr
= PRIV (recrd
.rec
);
1879 length
= PRIV (recrd
.rec_size
);
1880 maxptr
= ptr
+ length
;
1882 vms_debug2 ((2, "ETIR: %d bytes\n", length
));
1884 while (ptr
< maxptr
)
1886 int cmd
, cmd_length
;
1888 if (ptr
+ 4 > maxptr
)
1891 cmd
= bfd_getl16 (ptr
);
1892 cmd_length
= bfd_getl16 (ptr
+ 2);
1894 /* PR 21589 and 21579: Check for a corrupt ETIR record. */
1895 if (cmd_length
< 4 || ptr
+ cmd_length
> maxptr
)
1898 _bfd_error_handler (_("corrupt ETIR record encountered"));
1899 bfd_set_error (bfd_error_bad_value
);
1905 _bfd_vms_debug (4, "etir: %s(%d)\n",
1906 _bfd_vms_etir_name (cmd
), cmd
);
1907 _bfd_hexdump (8, ptr
, cmd_length
- 4, 0);
1915 stack 32 bit value of symbol (high bits set to 0). */
1916 case ETIR__C_STA_GBL
:
1917 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
1918 _bfd_vms_push (abfd
, op1
, alpha_vms_sym_to_ctxt (h
));
1924 stack 32 bit value, sign extend to 64 bit. */
1925 case ETIR__C_STA_LW
:
1926 if (ptr
+ 4 > maxptr
)
1928 _bfd_vms_push (abfd
, bfd_getl32 (ptr
), RELC_NONE
);
1934 stack 64 bit value of symbol. */
1935 case ETIR__C_STA_QW
:
1936 if (ptr
+ 8 > maxptr
)
1938 _bfd_vms_push (abfd
, bfd_getl64 (ptr
), RELC_NONE
);
1941 /* Stack psect base plus quadword offset
1942 arg: lw section index
1943 qw signed quadword offset (low 32 bits)
1945 Stack qw argument and section index
1946 (see ETIR__C_STO_OFF, ETIR__C_CTL_SETRB). */
1947 case ETIR__C_STA_PQ
:
1951 if (ptr
+ 12 > maxptr
)
1953 psect
= bfd_getl32 (ptr
);
1954 if ((unsigned int) psect
>= PRIV (section_count
))
1956 _bfd_error_handler (_("bad section index in %s"),
1957 _bfd_vms_etir_name (cmd
));
1958 bfd_set_error (bfd_error_bad_value
);
1961 op1
= bfd_getl64 (ptr
+ 4);
1962 _bfd_vms_push (abfd
, op1
, psect
| RELC_SEC_BASE
);
1966 case ETIR__C_STA_LI
:
1967 case ETIR__C_STA_MOD
:
1968 case ETIR__C_STA_CKARG
:
1969 _bfd_error_handler (_("unsupported STA cmd %s"),
1970 _bfd_vms_etir_name (cmd
));
1974 /* Store byte: pop stack, write byte
1977 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1978 if (rel1
!= RELC_NONE
)
1980 image_write_b (abfd
, (unsigned int) op1
& 0xff);
1983 /* Store word: pop stack, write word
1986 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1987 if (rel1
!= RELC_NONE
)
1989 image_write_w (abfd
, (unsigned int) op1
& 0xffff);
1992 /* Store longword: pop stack, write longword
1994 case ETIR__C_STO_LW
:
1995 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1996 if (rel1
& RELC_SEC_BASE
)
1998 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2001 else if (rel1
& RELC_SHR_BASE
)
2003 alpha_vms_add_fixup_lr (info
, rel1
& RELC_MASK
, op1
);
2006 if (rel1
!= RELC_NONE
)
2008 if (rel1
!= RELC_REL
)
2010 alpha_vms_add_lw_reloc (info
);
2012 image_write_l (abfd
, op1
);
2015 /* Store quadword: pop stack, write quadword
2017 case ETIR__C_STO_QW
:
2018 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2019 if (rel1
& RELC_SEC_BASE
)
2021 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2024 else if (rel1
& RELC_SHR_BASE
)
2026 if (rel1
!= RELC_NONE
)
2028 if (rel1
!= RELC_REL
)
2030 alpha_vms_add_qw_reloc (info
);
2032 image_write_q (abfd
, op1
);
2035 /* Store immediate repeated: pop stack for repeat count
2038 case ETIR__C_STO_IMMR
:
2042 if (ptr
+ 4 > maxptr
)
2044 size
= bfd_getl32 (ptr
);
2045 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2046 if (rel1
!= RELC_NONE
)
2049 image_write (abfd
, ptr
+ 4, size
);
2053 /* Store global: write symbol value
2054 arg: cs global symbol name. */
2055 case ETIR__C_STO_GBL
:
2056 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
2059 if (h
->sym
->typ
== EGSD__C_SYMG
)
2061 alpha_vms_add_fixup_qr
2062 (info
, abfd
, h
->sym
->owner
, h
->sym
->symbol_vector
);
2067 op1
= alpha_vms_get_sym_value (h
->sym
->section
,
2069 alpha_vms_add_qw_reloc (info
);
2072 image_write_q (abfd
, op1
);
2075 /* Store code address: write address of entry point
2076 arg: cs global symbol name (procedure). */
2077 case ETIR__C_STO_CA
:
2078 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
2081 if (h
->sym
->flags
& EGSY__V_NORM
)
2083 /* That's really a procedure. */
2084 if (h
->sym
->typ
== EGSD__C_SYMG
)
2086 alpha_vms_add_fixup_ca (info
, abfd
, h
->sym
->owner
);
2087 op1
= h
->sym
->symbol_vector
;
2091 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
2092 h
->sym
->code_value
);
2093 alpha_vms_add_qw_reloc (info
);
2098 /* Symbol is not a procedure. */
2102 image_write_q (abfd
, op1
);
2105 /* Store offset to psect: pop stack, add low 32 bits to base of psect
2107 case ETIR__C_STO_OFF
:
2108 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2110 if (!(rel1
& RELC_SEC_BASE
))
2113 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2115 image_write_q (abfd
, op1
);
2119 arg: lw count of bytes
2121 case ETIR__C_STO_IMM
:
2125 if (ptr
+ 4 > maxptr
)
2127 size
= bfd_getl32 (ptr
);
2128 image_write (abfd
, ptr
+ 4, size
);
2132 /* This code is 'reserved to digital' according to the openVMS
2133 linker manual, however it is generated by the DEC C compiler
2134 and defined in the include file.
2135 FIXME, since the following is just a guess
2136 store global longword: store 32bit value of symbol
2137 arg: cs symbol name. */
2138 case ETIR__C_STO_GBL_LW
:
2139 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
2143 image_write_l (abfd
, op1
);
2146 case ETIR__C_STO_RB
:
2147 case ETIR__C_STO_AB
:
2148 case ETIR__C_STO_LP_PSB
:
2149 _bfd_error_handler (_("%s: not supported"),
2150 _bfd_vms_etir_name (cmd
));
2153 case ETIR__C_STO_HINT_GBL
:
2154 case ETIR__C_STO_HINT_PS
:
2155 _bfd_error_handler (_("%s: not implemented"),
2156 _bfd_vms_etir_name (cmd
));
2160 /* 200 Store-conditional Linkage Pair
2162 case ETIR__C_STC_LP
:
2164 /* 202 Store-conditional Address at global address
2168 case ETIR__C_STC_GBL
:
2170 /* 203 Store-conditional Code Address at global address
2172 cs procedure name. */
2173 case ETIR__C_STC_GCA
:
2175 /* 204 Store-conditional Address at psect + offset
2179 case ETIR__C_STC_PS
:
2180 _bfd_error_handler (_("%s: not supported"),
2181 _bfd_vms_etir_name (cmd
));
2185 /* 201 Store-conditional Linkage Pair with Procedure Signature
2191 case ETIR__C_STC_LP_PSB
:
2192 _bfd_vms_get_value (abfd
, ptr
+ 4, maxptr
, info
, &op1
, &h
);
2195 if (h
->sym
->typ
== EGSD__C_SYMG
)
2197 alpha_vms_add_fixup_lp (info
, abfd
, h
->sym
->owner
);
2198 op1
= h
->sym
->symbol_vector
;
2203 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
2204 h
->sym
->code_value
);
2205 op2
= alpha_vms_get_sym_value (h
->sym
->section
,
2211 /* Undefined symbol. */
2215 image_write_q (abfd
, op1
);
2216 image_write_q (abfd
, op2
);
2219 /* 205 Store-conditional NOP at address of global
2221 case ETIR__C_STC_NOP_GBL
:
2224 /* 207 Store-conditional BSR at global address
2227 case ETIR__C_STC_BSR_GBL
:
2230 /* 209 Store-conditional LDA at global address
2233 case ETIR__C_STC_LDA_GBL
:
2236 /* 211 Store-conditional BSR or Hint at global address
2239 case ETIR__C_STC_BOH_GBL
:
2240 /* Currentl ignored. */
2243 /* 213 Store-conditional NOP,BSR or HINT at global address
2246 case ETIR__C_STC_NBH_GBL
:
2248 /* 206 Store-conditional NOP at pect + offset
2251 case ETIR__C_STC_NOP_PS
:
2253 /* 208 Store-conditional BSR at pect + offset
2256 case ETIR__C_STC_BSR_PS
:
2258 /* 210 Store-conditional LDA at psect + offset
2261 case ETIR__C_STC_LDA_PS
:
2263 /* 212 Store-conditional BSR or Hint at pect + offset
2266 case ETIR__C_STC_BOH_PS
:
2268 /* 214 Store-conditional NOP, BSR or HINT at psect + offset
2270 case ETIR__C_STC_NBH_PS
:
2271 _bfd_error_handler (_("%s: not supported"),
2272 _bfd_vms_etir_name (cmd
));
2276 /* Det relocation base: pop stack, set image location counter
2278 case ETIR__C_CTL_SETRB
:
2279 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2280 if (!(rel1
& RELC_SEC_BASE
))
2282 image_set_ptr (abfd
, op1
, rel1
& RELC_MASK
, info
);
2285 /* Augment relocation base: increment image location counter by offset
2286 arg: lw offset value. */
2287 case ETIR__C_CTL_AUGRB
:
2288 if (ptr
+ 4 > maxptr
)
2290 op1
= bfd_getl32 (ptr
);
2291 image_inc_ptr (abfd
, op1
);
2294 /* Define location: pop index, save location counter under index
2296 case ETIR__C_CTL_DFLOC
:
2297 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2298 if (rel1
!= RELC_NONE
)
2300 dst_define_location (abfd
, op1
);
2303 /* Set location: pop index, restore location counter from index
2305 case ETIR__C_CTL_STLOC
:
2306 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2307 if (rel1
!= RELC_NONE
)
2309 dst_restore_location (abfd
, op1
);
2312 /* Stack defined location: pop index, push location counter from index
2314 case ETIR__C_CTL_STKDL
:
2315 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2316 if (rel1
!= RELC_NONE
)
2318 _bfd_vms_push (abfd
, dst_retrieve_location (abfd
, op1
), RELC_NONE
);
2321 case ETIR__C_OPR_NOP
: /* No-op. */
2324 case ETIR__C_OPR_ADD
: /* Add. */
2325 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2326 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2327 if (rel1
== RELC_NONE
&& rel2
!= RELC_NONE
)
2329 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2331 _bfd_vms_push (abfd
, op1
+ op2
, rel1
);
2334 case ETIR__C_OPR_SUB
: /* Subtract. */
2335 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2336 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2337 if (rel1
== RELC_NONE
&& rel2
!= RELC_NONE
)
2339 else if ((rel1
& RELC_SEC_BASE
) && (rel2
& RELC_SEC_BASE
))
2341 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2342 op2
= alpha_vms_fix_sec_rel (abfd
, info
, rel2
, op2
);
2345 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2347 _bfd_vms_push (abfd
, op2
- op1
, rel1
);
2350 case ETIR__C_OPR_MUL
: /* Multiply. */
2351 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2352 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2353 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2355 _bfd_vms_push (abfd
, op1
* op2
, RELC_NONE
);
2358 case ETIR__C_OPR_DIV
: /* Divide. */
2359 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2360 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2361 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2364 _bfd_vms_push (abfd
, 0, RELC_NONE
);
2366 _bfd_vms_push (abfd
, op2
/ op1
, RELC_NONE
);
2369 case ETIR__C_OPR_AND
: /* Logical AND. */
2370 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2371 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2372 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2374 _bfd_vms_push (abfd
, op1
& op2
, RELC_NONE
);
2377 case ETIR__C_OPR_IOR
: /* Logical inclusive OR. */
2378 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2379 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2380 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2382 _bfd_vms_push (abfd
, op1
| op2
, RELC_NONE
);
2385 case ETIR__C_OPR_EOR
: /* Logical exclusive OR. */
2386 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2387 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2388 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2390 _bfd_vms_push (abfd
, op1
^ op2
, RELC_NONE
);
2393 case ETIR__C_OPR_NEG
: /* Negate. */
2394 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2395 if (rel1
!= RELC_NONE
)
2397 _bfd_vms_push (abfd
, -op1
, RELC_NONE
);
2400 case ETIR__C_OPR_COM
: /* Complement. */
2401 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2402 if (rel1
!= RELC_NONE
)
2404 _bfd_vms_push (abfd
, ~op1
, RELC_NONE
);
2407 case ETIR__C_OPR_ASH
: /* Arithmetic shift. */
2408 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2409 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2410 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2413 _bfd_error_handler (_("invalid use of %s with contexts"),
2414 _bfd_vms_etir_name (cmd
));
2417 if ((int)op2
< 0) /* Shift right. */
2419 else /* Shift left. */
2421 _bfd_vms_push (abfd
, op1
, RELC_NONE
); /* FIXME: sym. */
2424 case ETIR__C_OPR_INSV
: /* Insert field. */
2425 case ETIR__C_OPR_USH
: /* Unsigned shift. */
2426 case ETIR__C_OPR_ROT
: /* Rotate. */
2427 case ETIR__C_OPR_REDEF
: /* Redefine symbol to current location. */
2428 case ETIR__C_OPR_DFLIT
: /* Define a literal. */
2429 _bfd_error_handler (_("%s: not supported"),
2430 _bfd_vms_etir_name (cmd
));
2434 case ETIR__C_OPR_SEL
: /* Select. */
2435 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2437 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2440 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2441 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2442 _bfd_vms_push (abfd
, op1
, rel1
);
2447 _bfd_error_handler (_("reserved cmd %d"), cmd
);
2452 ptr
+= cmd_length
- 4;
2458 /* Process EDBG/ETBT record.
2459 Return TRUE on success, FALSE on error */
2462 vms_slurp_debug (bfd
*abfd
)
2464 asection
*section
= PRIV (dst_section
);
2466 if (section
== NULL
)
2468 /* We have no way to find out beforehand how much debug info there
2469 is in an object file, so pick an initial amount and grow it as
2471 flagword flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
| SEC_RELOC
2474 section
= bfd_make_section (abfd
, "$DST$");
2477 if (!bfd_set_section_flags (section
, flags
))
2479 PRIV (dst_section
) = section
;
2482 PRIV (image_section
) = section
;
2483 PRIV (image_offset
) = section
->size
;
2485 if (!_bfd_vms_slurp_etir (abfd
, NULL
))
2488 section
->size
= PRIV (image_offset
);
2492 /* Process EDBG record.
2493 Return TRUE on success, FALSE on error. */
2496 _bfd_vms_slurp_edbg (bfd
*abfd
)
2498 vms_debug2 ((2, "EDBG\n"));
2500 abfd
->flags
|= HAS_DEBUG
| HAS_LINENO
;
2502 return vms_slurp_debug (abfd
);
2505 /* Process ETBT record.
2506 Return TRUE on success, FALSE on error. */
2509 _bfd_vms_slurp_etbt (bfd
*abfd
)
2511 vms_debug2 ((2, "ETBT\n"));
2513 abfd
->flags
|= HAS_LINENO
;
2515 return vms_slurp_debug (abfd
);
2518 /* Process EEOM record.
2519 Return TRUE on success, FALSE on error. */
2522 _bfd_vms_slurp_eeom (bfd
*abfd
)
2524 struct vms_eeom
*eeom
= (struct vms_eeom
*) PRIV (recrd
.rec
);
2526 vms_debug2 ((2, "EEOM\n"));
2528 /* PR 21813: Check for an undersized record. */
2529 if (PRIV (recrd
.buf_size
) < sizeof (* eeom
))
2531 _bfd_error_handler (_("corrupt EEOM record - size is too small"));
2532 bfd_set_error (bfd_error_bad_value
);
2536 PRIV (eom_data
).eom_l_total_lps
= bfd_getl32 (eeom
->total_lps
);
2537 PRIV (eom_data
).eom_w_comcod
= bfd_getl16 (eeom
->comcod
);
2538 if (PRIV (eom_data
).eom_w_comcod
> 1)
2540 _bfd_error_handler (_("object module not error-free !"));
2541 bfd_set_error (bfd_error_bad_value
);
2545 PRIV (eom_data
).eom_has_transfer
= FALSE
;
2546 if (PRIV (recrd
.rec_size
) > 10)
2548 PRIV (eom_data
).eom_has_transfer
= TRUE
;
2549 PRIV (eom_data
).eom_b_tfrflg
= eeom
->tfrflg
;
2550 PRIV (eom_data
).eom_l_psindx
= bfd_getl32 (eeom
->psindx
);
2551 PRIV (eom_data
).eom_l_tfradr
= bfd_getl32 (eeom
->tfradr
);
2553 abfd
->start_address
= PRIV (eom_data
).eom_l_tfradr
;
2558 /* Slurp an ordered set of VMS object records. Return FALSE on error. */
2561 _bfd_vms_slurp_object_records (bfd
* abfd
)
2568 vms_debug2 ((7, "reading at %08lx\n", (unsigned long)bfd_tell (abfd
)));
2570 type
= _bfd_vms_get_object_record (abfd
);
2573 vms_debug2 ((2, "next_record failed\n"));
2580 err
= _bfd_vms_slurp_ehdr (abfd
);
2583 err
= _bfd_vms_slurp_eeom (abfd
);
2586 err
= _bfd_vms_slurp_egsd (abfd
);
2589 err
= TRUE
; /* _bfd_vms_slurp_etir (abfd); */
2592 err
= _bfd_vms_slurp_edbg (abfd
);
2595 err
= _bfd_vms_slurp_etbt (abfd
);
2602 vms_debug2 ((2, "slurp type %d failed\n", type
));
2606 while (type
!= EOBJ__C_EEOM
);
2611 /* Initialize private data */
2613 vms_initialize (bfd
* abfd
)
2617 amt
= sizeof (struct vms_private_data_struct
);
2618 abfd
->tdata
.any
= bfd_zalloc (abfd
, amt
);
2619 if (abfd
->tdata
.any
== NULL
)
2622 PRIV (recrd
.file_format
) = FF_UNKNOWN
;
2624 amt
= sizeof (struct stack_struct
) * STACKSIZE
;
2625 PRIV (stack
) = bfd_alloc (abfd
, amt
);
2626 if (PRIV (stack
) == NULL
)
2632 bfd_release (abfd
, abfd
->tdata
.any
);
2633 abfd
->tdata
.any
= NULL
;
2637 /* Free malloc'd memory. */
2640 alpha_vms_free_private (bfd
*abfd
)
2642 struct module
*module
;
2644 free (PRIV (recrd
.buf
));
2645 free (PRIV (sections
));
2647 free (PRIV (dst_ptr_offsets
));
2649 for (module
= PRIV (modules
); module
; module
= module
->next
)
2650 free (module
->file_table
);
2653 /* Check the format for a file being read.
2654 Return a (bfd_target *) if it's an object file or zero if not. */
2656 static const struct bfd_target
*
2657 alpha_vms_object_p (bfd
*abfd
)
2659 void *tdata_save
= abfd
->tdata
.any
;
2660 unsigned int test_len
;
2663 vms_debug2 ((1, "vms_object_p(%p)\n", abfd
));
2665 /* Allocate alpha-vms specific data. */
2666 if (!vms_initialize (abfd
))
2668 abfd
->tdata
.any
= tdata_save
;
2672 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
))
2673 goto err_wrong_format
;
2675 /* The first challenge with VMS is to discover the kind of the file.
2677 Image files (executable or shared images) are stored as a raw
2678 stream of bytes (like on UNIX), but there is no magic number.
2680 Object files are written with RMS (record management service), ie
2681 each records are preceeded by its length (on a word - 2 bytes), and
2682 padded for word-alignment. That would be simple but when files
2683 are transfered to a UNIX filesystem (using ftp), records are lost.
2684 Only the raw content of the records are transfered. Fortunately,
2685 the Alpha Object file format also store the length of the record
2686 in the records. Is that clear ? */
2688 /* Minimum is 6 bytes for objects (2 bytes size, 2 bytes record id,
2689 2 bytes size repeated) and 12 bytes for images (4 bytes major id,
2690 4 bytes minor id, 4 bytes length). */
2693 /* Size the main buffer. */
2694 buf
= (unsigned char *) bfd_malloc (test_len
);
2697 PRIV (recrd
.buf
) = buf
;
2698 PRIV (recrd
.buf_size
) = test_len
;
2700 /* Initialize the record pointer. */
2701 PRIV (recrd
.rec
) = buf
;
2703 if (bfd_bread (buf
, test_len
, abfd
) != test_len
)
2704 goto err_wrong_format
;
2706 /* Is it an image? */
2707 if ((bfd_getl32 (buf
) == EIHD__K_MAJORID
)
2708 && (bfd_getl32 (buf
+ 4) == EIHD__K_MINORID
))
2710 unsigned int to_read
;
2711 unsigned int read_so_far
;
2712 unsigned int remaining
;
2713 unsigned int eisd_offset
, eihs_offset
;
2715 /* Extract the header size. */
2716 PRIV (recrd
.rec_size
) = bfd_getl32 (buf
+ EIHD__L_SIZE
);
2718 /* The header size is 0 for DSF files. */
2719 if (PRIV (recrd
.rec_size
) == 0)
2720 PRIV (recrd
.rec_size
) = sizeof (struct vms_eihd
);
2722 if (PRIV (recrd
.rec_size
) > PRIV (recrd
.buf_size
))
2724 buf
= bfd_realloc_or_free (buf
, PRIV (recrd
.rec_size
));
2728 PRIV (recrd
.buf
) = NULL
;
2731 PRIV (recrd
.buf
) = buf
;
2732 PRIV (recrd
.buf_size
) = PRIV (recrd
.rec_size
);
2735 /* PR 21813: Check for a truncated record. */
2736 if (PRIV (recrd
.rec_size
< test_len
))
2738 /* Read the remaining record. */
2739 remaining
= PRIV (recrd
.rec_size
) - test_len
;
2740 to_read
= MIN (VMS_BLOCK_SIZE
- test_len
, remaining
);
2741 read_so_far
= test_len
;
2743 while (remaining
> 0)
2745 if (bfd_bread (buf
+ read_so_far
, to_read
, abfd
) != to_read
)
2746 goto err_wrong_format
;
2748 read_so_far
+= to_read
;
2749 remaining
-= to_read
;
2751 to_read
= MIN (VMS_BLOCK_SIZE
, remaining
);
2754 /* Reset the record pointer. */
2755 PRIV (recrd
.rec
) = buf
;
2757 /* PR 17512: file: 7d7c57c2. */
2758 if (PRIV (recrd
.rec_size
) < sizeof (struct vms_eihd
))
2760 vms_debug2 ((2, "file type is image\n"));
2762 if (!_bfd_vms_slurp_eihd (abfd
, &eisd_offset
, &eihs_offset
))
2763 goto err_wrong_format
;
2765 if (!_bfd_vms_slurp_eisd (abfd
, eisd_offset
))
2766 goto err_wrong_format
;
2768 /* EIHS is optional. */
2769 if (eihs_offset
!= 0 && !_bfd_vms_slurp_eihs (abfd
, eihs_offset
))
2770 goto err_wrong_format
;
2776 /* Assume it's a module and adjust record pointer if necessary. */
2777 maybe_adjust_record_pointer_for_object (abfd
);
2779 /* But is it really a module? */
2780 if (bfd_getl16 (PRIV (recrd
.rec
)) <= EOBJ__C_MAXRECTYP
2781 && bfd_getl16 (PRIV (recrd
.rec
) + 2) <= EOBJ__C_MAXRECSIZ
)
2783 if (vms_get_remaining_object_record (abfd
, test_len
) <= 0)
2784 goto err_wrong_format
;
2786 vms_debug2 ((2, "file type is module\n"));
2788 type
= bfd_getl16 (PRIV (recrd
.rec
));
2789 if (type
!= EOBJ__C_EMH
|| !_bfd_vms_slurp_ehdr (abfd
))
2790 goto err_wrong_format
;
2792 if (!_bfd_vms_slurp_object_records (abfd
))
2793 goto err_wrong_format
;
2796 goto err_wrong_format
;
2799 /* Set arch_info to alpha. */
2801 if (! bfd_default_set_arch_mach (abfd
, bfd_arch_alpha
, 0))
2802 goto err_wrong_format
;
2807 bfd_set_error (bfd_error_wrong_format
);
2810 alpha_vms_free_private (abfd
);
2811 if (abfd
->tdata
.any
!= tdata_save
&& abfd
->tdata
.any
!= NULL
)
2812 bfd_release (abfd
, abfd
->tdata
.any
);
2813 abfd
->tdata
.any
= tdata_save
;
2819 /* Write an EMH/MHD record. */
2822 _bfd_vms_write_emh (bfd
*abfd
)
2824 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2826 _bfd_vms_output_alignment (recwr
, 2);
2829 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
2830 _bfd_vms_output_short (recwr
, EMH__C_MHD
);
2831 _bfd_vms_output_short (recwr
, EOBJ__C_STRLVL
);
2832 _bfd_vms_output_long (recwr
, 0);
2833 _bfd_vms_output_long (recwr
, 0);
2834 _bfd_vms_output_long (recwr
, MAX_OUTREC_SIZE
);
2836 /* Create module name from filename. */
2837 if (bfd_get_filename (abfd
) != 0)
2839 char *module
= vms_get_module_name (bfd_get_filename (abfd
), TRUE
);
2840 _bfd_vms_output_counted (recwr
, module
);
2844 _bfd_vms_output_counted (recwr
, "NONAME");
2846 _bfd_vms_output_counted (recwr
, BFD_VERSION_STRING
);
2847 _bfd_vms_output_dump (recwr
, get_vms_time_string (), EMH_DATE_LENGTH
);
2848 _bfd_vms_output_fill (recwr
, 0, EMH_DATE_LENGTH
);
2849 _bfd_vms_output_end (abfd
, recwr
);
2852 /* Write an EMH/LMN record. */
2855 _bfd_vms_write_lmn (bfd
*abfd
, const char *name
)
2858 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2859 unsigned int ver
= BFD_VERSION
/ 10000;
2862 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
2863 _bfd_vms_output_short (recwr
, EMH__C_LNM
);
2864 snprintf (version
, sizeof (version
), "%s %d.%d.%d", name
,
2865 ver
/ 10000, (ver
/ 100) % 100, ver
% 100);
2866 _bfd_vms_output_dump (recwr
, (unsigned char *)version
, strlen (version
));
2867 _bfd_vms_output_end (abfd
, recwr
);
2871 /* Write eom record for bfd abfd. Return FALSE on error. */
2874 _bfd_vms_write_eeom (bfd
*abfd
)
2876 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2878 vms_debug2 ((2, "vms_write_eeom\n"));
2880 _bfd_vms_output_alignment (recwr
, 2);
2882 _bfd_vms_output_begin (recwr
, EOBJ__C_EEOM
);
2883 _bfd_vms_output_long (recwr
, PRIV (vms_linkage_index
+ 1) >> 1);
2884 _bfd_vms_output_byte (recwr
, 0); /* Completion code. */
2885 _bfd_vms_output_byte (recwr
, 0); /* Fill byte. */
2887 if ((abfd
->flags
& EXEC_P
) == 0
2888 && bfd_get_start_address (abfd
) != (bfd_vma
)-1)
2892 section
= bfd_get_section_by_name (abfd
, ".link");
2895 bfd_set_error (bfd_error_nonrepresentable_section
);
2898 _bfd_vms_output_short (recwr
, 0);
2899 _bfd_vms_output_long (recwr
, (unsigned long) section
->target_index
);
2900 _bfd_vms_output_long (recwr
,
2901 (unsigned long) bfd_get_start_address (abfd
));
2902 _bfd_vms_output_long (recwr
, 0);
2905 _bfd_vms_output_end (abfd
, recwr
);
2910 vector_grow1 (struct vector_type
*vec
, size_t elsz
)
2912 if (vec
->nbr_el
+ 1 < vec
->max_el
)
2915 if (vec
->max_el
== 0)
2918 vec
->els
= bfd_malloc2 (vec
->max_el
, elsz
);
2923 vec
->els
= bfd_realloc2 (vec
->els
, vec
->max_el
, elsz
);
2927 /* Bump ABFD file position to next block. */
2930 alpha_vms_file_position_block (bfd
*abfd
)
2933 PRIV (file_pos
) += VMS_BLOCK_SIZE
- 1;
2934 PRIV (file_pos
) -= (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
2937 /* Convert from internal structure SRC to external structure DST. */
2940 alpha_vms_swap_eisd_out (struct vms_internal_eisd_map
*src
,
2941 struct vms_eisd
*dst
)
2943 bfd_putl32 (src
->u
.eisd
.majorid
, dst
->majorid
);
2944 bfd_putl32 (src
->u
.eisd
.minorid
, dst
->minorid
);
2945 bfd_putl32 (src
->u
.eisd
.eisdsize
, dst
->eisdsize
);
2946 if (src
->u
.eisd
.eisdsize
<= EISD__K_LENEND
)
2948 bfd_putl32 (src
->u
.eisd
.secsize
, dst
->secsize
);
2949 bfd_putl64 (src
->u
.eisd
.virt_addr
, dst
->virt_addr
);
2950 bfd_putl32 (src
->u
.eisd
.flags
, dst
->flags
);
2951 bfd_putl32 (src
->u
.eisd
.vbn
, dst
->vbn
);
2952 dst
->pfc
= src
->u
.eisd
.pfc
;
2953 dst
->matchctl
= src
->u
.eisd
.matchctl
;
2954 dst
->type
= src
->u
.eisd
.type
;
2956 if (src
->u
.eisd
.flags
& EISD__M_GBL
)
2958 bfd_putl32 (src
->u
.gbl_eisd
.ident
, dst
->ident
);
2959 memcpy (dst
->gblnam
, src
->u
.gbl_eisd
.gblnam
,
2960 src
->u
.gbl_eisd
.gblnam
[0] + 1);
2964 /* Append EISD to the list of extra eisd for ABFD. */
2967 alpha_vms_append_extra_eisd (bfd
*abfd
, struct vms_internal_eisd_map
*eisd
)
2970 if (PRIV (gbl_eisd_head
) == NULL
)
2971 PRIV (gbl_eisd_head
) = eisd
;
2973 PRIV (gbl_eisd_tail
)->next
= eisd
;
2974 PRIV (gbl_eisd_tail
) = eisd
;
2977 /* Create an EISD for shared image SHRIMG.
2978 Return FALSE in case of error. */
2981 alpha_vms_create_eisd_for_shared (bfd
*abfd
, bfd
*shrimg
)
2983 struct vms_internal_eisd_map
*eisd
;
2986 namlen
= strlen (PRIV2 (shrimg
, hdr_data
.hdr_t_name
));
2987 if (namlen
+ 5 > EISD__K_GBLNAMLEN
)
2993 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
2997 /* Fill the fields. */
2998 eisd
->u
.gbl_eisd
.common
.majorid
= EISD__K_MAJORID
;
2999 eisd
->u
.gbl_eisd
.common
.minorid
= EISD__K_MINORID
;
3000 eisd
->u
.gbl_eisd
.common
.eisdsize
= (EISD__K_LEN
+ 4 + namlen
+ 5 + 3) & ~3;
3001 eisd
->u
.gbl_eisd
.common
.secsize
= VMS_BLOCK_SIZE
; /* Must not be 0. */
3002 eisd
->u
.gbl_eisd
.common
.virt_addr
= 0;
3003 eisd
->u
.gbl_eisd
.common
.flags
= EISD__M_GBL
;
3004 eisd
->u
.gbl_eisd
.common
.vbn
= 0;
3005 eisd
->u
.gbl_eisd
.common
.pfc
= 0;
3006 eisd
->u
.gbl_eisd
.common
.matchctl
= PRIV2 (shrimg
, matchctl
);
3007 eisd
->u
.gbl_eisd
.common
.type
= EISD__K_SHRPIC
;
3009 eisd
->u
.gbl_eisd
.ident
= PRIV2 (shrimg
, ident
);
3010 eisd
->u
.gbl_eisd
.gblnam
[0] = namlen
+ 4;
3011 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1, PRIV2 (shrimg
, hdr_data
.hdr_t_name
),
3013 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1 + namlen
, "_001", 4);
3015 /* Append it to the list. */
3016 alpha_vms_append_extra_eisd (abfd
, eisd
);
3021 /* Create an EISD for section SEC.
3022 Return FALSE in case of failure. */
3025 alpha_vms_create_eisd_for_section (bfd
*abfd
, asection
*sec
)
3027 struct vms_internal_eisd_map
*eisd
;
3029 /* Only for allocating section. */
3030 if (!(sec
->flags
& SEC_ALLOC
))
3033 BFD_ASSERT (vms_section_data (sec
)->eisd
== NULL
);
3034 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
3037 vms_section_data (sec
)->eisd
= eisd
;
3039 /* Fill the fields. */
3040 eisd
->u
.eisd
.majorid
= EISD__K_MAJORID
;
3041 eisd
->u
.eisd
.minorid
= EISD__K_MINORID
;
3042 eisd
->u
.eisd
.eisdsize
= EISD__K_LEN
;
3043 eisd
->u
.eisd
.secsize
=
3044 (sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
3045 eisd
->u
.eisd
.virt_addr
= sec
->vma
;
3046 eisd
->u
.eisd
.flags
= 0;
3047 eisd
->u
.eisd
.vbn
= 0; /* To be later defined. */
3048 eisd
->u
.eisd
.pfc
= 0; /* Default. */
3049 eisd
->u
.eisd
.matchctl
= EISD__K_MATALL
;
3050 eisd
->u
.eisd
.type
= EISD__K_NORMAL
;
3052 if (sec
->flags
& SEC_CODE
)
3053 eisd
->u
.eisd
.flags
|= EISD__M_EXE
;
3054 if (!(sec
->flags
& SEC_READONLY
))
3055 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
3057 /* If relocations or fixup will be applied, make this isect writeable. */
3058 if (sec
->flags
& SEC_RELOC
)
3059 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
3061 if (!(sec
->flags
& SEC_HAS_CONTENTS
))
3063 eisd
->u
.eisd
.flags
|= EISD__M_DZRO
;
3064 eisd
->u
.eisd
.flags
&= ~EISD__M_CRF
;
3066 if (sec
->flags
& SEC_LINKER_CREATED
)
3068 if (strcmp (sec
->name
, "$FIXUP$") == 0)
3069 eisd
->u
.eisd
.flags
|= EISD__M_FIXUPVEC
;
3072 /* Append it to the list. */
3074 if (PRIV (eisd_head
) == NULL
)
3075 PRIV (eisd_head
) = eisd
;
3077 PRIV (eisd_tail
)->next
= eisd
;
3078 PRIV (eisd_tail
) = eisd
;
3083 /* Layout executable ABFD and write it to the disk.
3084 Return FALSE in case of failure. */
3087 alpha_vms_write_exec (bfd
*abfd
)
3089 struct vms_eihd eihd
;
3090 struct vms_eiha
*eiha
;
3091 struct vms_eihi
*eihi
;
3092 struct vms_eihs
*eihs
= NULL
;
3094 struct vms_internal_eisd_map
*first_eisd
;
3095 struct vms_internal_eisd_map
*eisd
;
3098 file_ptr gst_filepos
= 0;
3099 unsigned int lnkflags
= 0;
3101 /* Build the EIHD. */
3102 PRIV (file_pos
) = EIHD__C_LENGTH
;
3104 memset (&eihd
, 0, sizeof (eihd
));
3105 memset (eihd
.fill_2
, 0xff, sizeof (eihd
.fill_2
));
3107 bfd_putl32 (EIHD__K_MAJORID
, eihd
.majorid
);
3108 bfd_putl32 (EIHD__K_MINORID
, eihd
.minorid
);
3110 bfd_putl32 (sizeof (eihd
), eihd
.size
);
3111 bfd_putl32 (0, eihd
.isdoff
);
3112 bfd_putl32 (0, eihd
.activoff
);
3113 bfd_putl32 (0, eihd
.symdbgoff
);
3114 bfd_putl32 (0, eihd
.imgidoff
);
3115 bfd_putl32 (0, eihd
.patchoff
);
3116 bfd_putl64 (0, eihd
.iafva
);
3117 bfd_putl32 (0, eihd
.version_array_off
);
3119 bfd_putl32 (EIHD__K_EXE
, eihd
.imgtype
);
3120 bfd_putl32 (0, eihd
.subtype
);
3122 bfd_putl32 (0, eihd
.imgiocnt
);
3123 bfd_putl32 (-1, eihd
.privreqs
);
3124 bfd_putl32 (-1, eihd
.privreqs
+ 4);
3126 bfd_putl32 ((sizeof (eihd
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
3128 bfd_putl32 (0, eihd
.ident
);
3129 bfd_putl32 (0, eihd
.sysver
);
3132 bfd_putl32 (0, eihd
.symvect_size
);
3133 bfd_putl32 (16, eihd
.virt_mem_block_size
);
3134 bfd_putl32 (0, eihd
.ext_fixup_off
);
3135 bfd_putl32 (0, eihd
.noopt_psect_off
);
3136 bfd_putl32 (-1, eihd
.alias
);
3139 eiha
= (struct vms_eiha
*)((char *) &eihd
+ PRIV (file_pos
));
3140 bfd_putl32 (PRIV (file_pos
), eihd
.activoff
);
3141 PRIV (file_pos
) += sizeof (struct vms_eiha
);
3143 bfd_putl32 (sizeof (struct vms_eiha
), eiha
->size
);
3144 bfd_putl32 (0, eiha
->spare
);
3145 bfd_putl64 (PRIV (transfer_address
[0]), eiha
->tfradr1
);
3146 bfd_putl64 (PRIV (transfer_address
[1]), eiha
->tfradr2
);
3147 bfd_putl64 (PRIV (transfer_address
[2]), eiha
->tfradr3
);
3148 bfd_putl64 (PRIV (transfer_address
[3]), eiha
->tfradr4
);
3149 bfd_putl64 (0, eiha
->inishr
);
3152 eihi
= (struct vms_eihi
*)((char *) &eihd
+ PRIV (file_pos
));
3153 bfd_putl32 (PRIV (file_pos
), eihd
.imgidoff
);
3154 PRIV (file_pos
) += sizeof (struct vms_eihi
);
3156 bfd_putl32 (EIHI__K_MAJORID
, eihi
->majorid
);
3157 bfd_putl32 (EIHI__K_MINORID
, eihi
->minorid
);
3162 /* Set module name. */
3163 module
= vms_get_module_name (bfd_get_filename (abfd
), TRUE
);
3164 len
= strlen (module
);
3165 if (len
> sizeof (eihi
->imgnam
) - 1)
3166 len
= sizeof (eihi
->imgnam
) - 1;
3167 eihi
->imgnam
[0] = len
;
3168 memcpy (eihi
->imgnam
+ 1, module
, len
);
3176 vms_get_time (&hi
, &lo
);
3177 bfd_putl32 (lo
, eihi
->linktime
+ 0);
3178 bfd_putl32 (hi
, eihi
->linktime
+ 4);
3181 eihi
->linkid
[0] = 0;
3182 eihi
->imgbid
[0] = 0;
3185 dst
= PRIV (dst_section
);
3186 dmt
= bfd_get_section_by_name (abfd
, "$DMT$");
3187 if (dst
!= NULL
&& dst
->size
!= 0)
3189 eihs
= (struct vms_eihs
*)((char *) &eihd
+ PRIV (file_pos
));
3190 bfd_putl32 (PRIV (file_pos
), eihd
.symdbgoff
);
3191 PRIV (file_pos
) += sizeof (struct vms_eihs
);
3193 bfd_putl32 (EIHS__K_MAJORID
, eihs
->majorid
);
3194 bfd_putl32 (EIHS__K_MINORID
, eihs
->minorid
);
3195 bfd_putl32 (0, eihs
->dstvbn
);
3196 bfd_putl32 (0, eihs
->dstsize
);
3197 bfd_putl32 (0, eihs
->gstvbn
);
3198 bfd_putl32 (0, eihs
->gstsize
);
3199 bfd_putl32 (0, eihs
->dmtvbn
);
3200 bfd_putl32 (0, eihs
->dmtsize
);
3203 /* One EISD per section. */
3204 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3206 if (!alpha_vms_create_eisd_for_section (abfd
, sec
))
3210 /* Merge section EIDS which extra ones. */
3211 if (PRIV (eisd_tail
))
3212 PRIV (eisd_tail
)->next
= PRIV (gbl_eisd_head
);
3214 PRIV (eisd_head
) = PRIV (gbl_eisd_head
);
3215 if (PRIV (gbl_eisd_tail
))
3216 PRIV (eisd_tail
) = PRIV (gbl_eisd_tail
);
3218 first_eisd
= PRIV (eisd_head
);
3220 /* Add end of eisd. */
3223 eisd
= bfd_zalloc (abfd
, sizeof (*eisd
));
3226 eisd
->u
.eisd
.majorid
= 0;
3227 eisd
->u
.eisd
.minorid
= 0;
3228 eisd
->u
.eisd
.eisdsize
= 0;
3229 alpha_vms_append_extra_eisd (abfd
, eisd
);
3232 /* Place EISD in the file. */
3233 for (eisd
= first_eisd
; eisd
; eisd
= eisd
->next
)
3235 file_ptr room
= VMS_BLOCK_SIZE
- (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
3237 /* First block is a little bit special: there is a word at the end. */
3238 if (PRIV (file_pos
) < VMS_BLOCK_SIZE
&& room
> 2)
3240 if (room
< eisd
->u
.eisd
.eisdsize
+ EISD__K_LENEND
)
3241 alpha_vms_file_position_block (abfd
);
3243 eisd
->file_pos
= PRIV (file_pos
);
3244 PRIV (file_pos
) += eisd
->u
.eisd
.eisdsize
;
3246 if (eisd
->u
.eisd
.flags
& EISD__M_FIXUPVEC
)
3247 bfd_putl64 (eisd
->u
.eisd
.virt_addr
, eihd
.iafva
);
3250 if (first_eisd
!= NULL
)
3252 bfd_putl32 (first_eisd
->file_pos
, eihd
.isdoff
);
3253 /* Real size of end of eisd marker. */
3254 PRIV (file_pos
) += EISD__K_LENEND
;
3257 bfd_putl32 (PRIV (file_pos
), eihd
.size
);
3258 bfd_putl32 ((PRIV (file_pos
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
3261 /* Place sections. */
3262 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3264 if (!(sec
->flags
& SEC_HAS_CONTENTS
))
3267 eisd
= vms_section_data (sec
)->eisd
;
3269 /* Align on a block. */
3270 alpha_vms_file_position_block (abfd
);
3271 sec
->filepos
= PRIV (file_pos
);
3274 eisd
->u
.eisd
.vbn
= (sec
->filepos
/ VMS_BLOCK_SIZE
) + 1;
3276 PRIV (file_pos
) += sec
->size
;
3280 if (eihs
!= NULL
&& dst
!= NULL
)
3282 bfd_putl32 ((dst
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dstvbn
);
3283 bfd_putl32 (dst
->size
, eihs
->dstsize
);
3287 lnkflags
|= EIHD__M_DBGDMT
;
3288 bfd_putl32 ((dmt
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dmtvbn
);
3289 bfd_putl32 (dmt
->size
, eihs
->dmtsize
);
3291 if (PRIV (gsd_sym_count
) != 0)
3293 alpha_vms_file_position_block (abfd
);
3294 gst_filepos
= PRIV (file_pos
);
3295 bfd_putl32 ((gst_filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->gstvbn
);
3296 bfd_putl32 ((PRIV (gsd_sym_count
) + 4) / 5 + 4, eihs
->gstsize
);
3300 /* Write EISD in hdr. */
3301 for (eisd
= first_eisd
; eisd
&& eisd
->file_pos
< VMS_BLOCK_SIZE
;
3303 alpha_vms_swap_eisd_out
3304 (eisd
, (struct vms_eisd
*)((char *)&eihd
+ eisd
->file_pos
));
3306 /* Write first block. */
3307 bfd_putl32 (lnkflags
, eihd
.lnkflags
);
3308 if (bfd_bwrite (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
3311 /* Write remaining eisd. */
3314 unsigned char blk
[VMS_BLOCK_SIZE
];
3315 struct vms_internal_eisd_map
*next_eisd
;
3317 memset (blk
, 0xff, sizeof (blk
));
3318 while (eisd
!= NULL
)
3320 alpha_vms_swap_eisd_out
3322 (struct vms_eisd
*)(blk
+ (eisd
->file_pos
% VMS_BLOCK_SIZE
)));
3324 next_eisd
= eisd
->next
;
3325 if (next_eisd
== NULL
3326 || (next_eisd
->file_pos
/ VMS_BLOCK_SIZE
3327 != eisd
->file_pos
/ VMS_BLOCK_SIZE
))
3329 if (bfd_bwrite (blk
, sizeof (blk
), abfd
) != sizeof (blk
))
3332 memset (blk
, 0xff, sizeof (blk
));
3338 /* Write sections. */
3339 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3341 unsigned char blk
[VMS_BLOCK_SIZE
];
3344 if (sec
->size
== 0 || !(sec
->flags
& SEC_HAS_CONTENTS
))
3346 if (bfd_bwrite (sec
->contents
, sec
->size
, abfd
) != sec
->size
)
3350 len
= VMS_BLOCK_SIZE
- sec
->size
% VMS_BLOCK_SIZE
;
3351 if (len
!= VMS_BLOCK_SIZE
)
3353 memset (blk
, 0, len
);
3354 if (bfd_bwrite (blk
, len
, abfd
) != len
)
3360 if (gst_filepos
!= 0)
3362 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3365 _bfd_vms_write_emh (abfd
);
3366 _bfd_vms_write_lmn (abfd
, "GNU LD");
3368 /* PSC for the absolute section. */
3369 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3370 _bfd_vms_output_long (recwr
, 0);
3371 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3372 _bfd_vms_output_short (recwr
, 0);
3373 _bfd_vms_output_short (recwr
, EGPS__V_PIC
| EGPS__V_LIB
| EGPS__V_RD
);
3374 _bfd_vms_output_long (recwr
, 0);
3375 _bfd_vms_output_counted (recwr
, ".$$ABS$$.");
3376 _bfd_vms_output_end_subrec (recwr
);
3377 _bfd_vms_output_end (abfd
, recwr
);
3379 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
3381 struct vms_symbol_entry
*sym
= PRIV (syms
)[i
];
3387 _bfd_vms_output_alignment (recwr
, 8);
3388 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3389 _bfd_vms_output_long (recwr
, 0);
3391 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYMG
);
3392 _bfd_vms_output_short (recwr
, 0); /* Data type, alignment. */
3393 _bfd_vms_output_short (recwr
, sym
->flags
);
3395 if (sym
->code_section
)
3396 ep
= alpha_vms_get_sym_value (sym
->code_section
, sym
->code_value
);
3399 BFD_ASSERT (sym
->code_value
== 0);
3402 val
= alpha_vms_get_sym_value (sym
->section
, sym
->value
);
3403 _bfd_vms_output_quad
3404 (recwr
, sym
->typ
== EGSD__C_SYMG
? sym
->symbol_vector
: val
);
3405 _bfd_vms_output_quad (recwr
, ep
);
3406 _bfd_vms_output_quad (recwr
, val
);
3407 _bfd_vms_output_long (recwr
, 0);
3408 _bfd_vms_output_counted (recwr
, sym
->name
);
3409 _bfd_vms_output_end_subrec (recwr
);
3411 _bfd_vms_output_end (abfd
, recwr
);
3414 _bfd_vms_output_end (abfd
, recwr
);
3416 if (!_bfd_vms_write_eeom (abfd
))
3424 /* Write section and symbol directory of bfd abfd. Return FALSE on error. */
3427 _bfd_vms_write_egsd (bfd
*abfd
)
3431 unsigned int symnum
;
3433 flagword new_flags
, old_flags
;
3434 int abs_section_index
= -1;
3435 unsigned int target_index
= 0;
3436 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3438 vms_debug2 ((2, "vms_write_egsd\n"));
3440 /* Egsd is quadword aligned. */
3441 _bfd_vms_output_alignment (recwr
, 8);
3443 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3444 _bfd_vms_output_long (recwr
, 0);
3446 /* Number sections. */
3447 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3449 if (section
->flags
& SEC_DEBUGGING
)
3451 if (!strcmp (section
->name
, ".vmsdebug"))
3453 section
->flags
|= SEC_DEBUGGING
;
3456 section
->target_index
= target_index
++;
3459 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3461 vms_debug2 ((3, "Section #%d %s, %d bytes\n",
3462 section
->target_index
, section
->name
, (int)section
->size
));
3464 /* Don't write out the VMS debug info section since it is in the
3465 ETBT and EDBG sections in etir. */
3466 if (section
->flags
& SEC_DEBUGGING
)
3469 /* 13 bytes egsd, max 31 chars name -> should be 44 bytes. */
3470 if (_bfd_vms_output_check (recwr
, 64) < 0)
3472 _bfd_vms_output_end (abfd
, recwr
);
3473 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3474 _bfd_vms_output_long (recwr
, 0);
3477 /* Don't know if this is necessary for the linker but for now it keeps
3478 vms_slurp_gsd happy. */
3479 sname
= section
->name
;
3482 /* Remove leading dot. */
3484 if ((*sname
== 't') && (strcmp (sname
, "text") == 0))
3485 sname
= EVAX_CODE_NAME
;
3486 else if ((*sname
== 'd') && (strcmp (sname
, "data") == 0))
3487 sname
= EVAX_DATA_NAME
;
3488 else if ((*sname
== 'b') && (strcmp (sname
, "bss") == 0))
3489 sname
= EVAX_BSS_NAME
;
3490 else if ((*sname
== 'l') && (strcmp (sname
, "link") == 0))
3491 sname
= EVAX_LINK_NAME
;
3492 else if ((*sname
== 'r') && (strcmp (sname
, "rdata") == 0))
3493 sname
= EVAX_READONLY_NAME
;
3494 else if ((*sname
== 'l') && (strcmp (sname
, "literal") == 0))
3495 sname
= EVAX_LITERAL_NAME
;
3496 else if ((*sname
== 'l') && (strcmp (sname
, "literals") == 0))
3497 sname
= EVAX_LITERALS_NAME
;
3498 else if ((*sname
== 'c') && (strcmp (sname
, "comm") == 0))
3499 sname
= EVAX_COMMON_NAME
;
3500 else if ((*sname
== 'l') && (strcmp (sname
, "lcomm") == 0))
3501 sname
= EVAX_LOCAL_NAME
;
3504 if (bfd_is_com_section (section
))
3505 new_flags
= (EGPS__V_OVR
| EGPS__V_REL
| EGPS__V_GBL
| EGPS__V_RD
3506 | EGPS__V_WRT
| EGPS__V_NOMOD
| EGPS__V_COM
);
3508 new_flags
= vms_esecflag_by_name (evax_section_flags
, sname
,
3511 /* Modify them as directed. */
3512 if (section
->flags
& SEC_READONLY
)
3513 new_flags
&= ~EGPS__V_WRT
;
3515 new_flags
&= ~vms_section_data (section
)->no_flags
;
3516 new_flags
|= vms_section_data (section
)->flags
;
3518 vms_debug2 ((3, "sec flags %x\n", section
->flags
));
3519 vms_debug2 ((3, "new_flags %x, _raw_size %lu\n",
3520 new_flags
, (unsigned long)section
->size
));
3522 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3523 _bfd_vms_output_short (recwr
, section
->alignment_power
& 0xff);
3524 _bfd_vms_output_short (recwr
, new_flags
);
3525 _bfd_vms_output_long (recwr
, (unsigned long) section
->size
);
3526 _bfd_vms_output_counted (recwr
, sname
);
3527 _bfd_vms_output_end_subrec (recwr
);
3529 /* If the section is an obsolute one, remind its index as it will be
3530 used later for absolute symbols. */
3531 if ((new_flags
& EGPS__V_REL
) == 0 && abs_section_index
< 0)
3532 abs_section_index
= section
->target_index
;
3535 /* Output symbols. */
3536 vms_debug2 ((3, "%d symbols found\n", abfd
->symcount
));
3538 bfd_set_start_address (abfd
, (bfd_vma
) -1);
3540 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3542 symbol
= abfd
->outsymbols
[symnum
];
3543 old_flags
= symbol
->flags
;
3545 /* Work-around a missing feature: consider __main as the main entry
3547 if (symbol
->name
[0] == '_' && strcmp (symbol
->name
, "__main") == 0)
3548 bfd_set_start_address (abfd
, (bfd_vma
)symbol
->value
);
3550 /* Only put in the GSD the global and the undefined symbols. */
3551 if (old_flags
& BSF_FILE
)
3554 if ((old_flags
& BSF_GLOBAL
) == 0 && !bfd_is_und_section (symbol
->section
))
3556 /* If the LIB$INITIIALIZE section is present, add a reference to
3557 LIB$INITIALIZE symbol. FIXME: this should be done explicitely
3558 in the assembly file. */
3559 if (!((old_flags
& BSF_SECTION_SYM
) != 0
3560 && strcmp (symbol
->section
->name
, "LIB$INITIALIZE") == 0))
3564 /* 13 bytes egsd, max 64 chars name -> should be 77 bytes. Add 16 more
3565 bytes for a possible ABS section. */
3566 if (_bfd_vms_output_check (recwr
, 80 + 16) < 0)
3568 _bfd_vms_output_end (abfd
, recwr
);
3569 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3570 _bfd_vms_output_long (recwr
, 0);
3573 if ((old_flags
& BSF_GLOBAL
) != 0
3574 && bfd_is_abs_section (symbol
->section
)
3575 && abs_section_index
<= 0)
3577 /* Create an absolute section if none was defined. It is highly
3578 unlikely that the name $ABS$ clashes with a user defined
3579 non-absolute section name. */
3580 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3581 _bfd_vms_output_short (recwr
, 4);
3582 _bfd_vms_output_short (recwr
, EGPS__V_SHR
);
3583 _bfd_vms_output_long (recwr
, 0);
3584 _bfd_vms_output_counted (recwr
, "$ABS$");
3585 _bfd_vms_output_end_subrec (recwr
);
3587 abs_section_index
= target_index
++;
3590 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYM
);
3592 /* Data type, alignment. */
3593 _bfd_vms_output_short (recwr
, 0);
3597 if (old_flags
& BSF_WEAK
)
3598 new_flags
|= EGSY__V_WEAK
;
3599 if (bfd_is_com_section (symbol
->section
)) /* .comm */
3600 new_flags
|= (EGSY__V_WEAK
| EGSY__V_COMM
);
3602 if (old_flags
& BSF_FUNCTION
)
3604 new_flags
|= EGSY__V_NORM
;
3605 new_flags
|= EGSY__V_REL
;
3607 if (old_flags
& BSF_GLOBAL
)
3609 new_flags
|= EGSY__V_DEF
;
3610 if (!bfd_is_abs_section (symbol
->section
))
3611 new_flags
|= EGSY__V_REL
;
3613 _bfd_vms_output_short (recwr
, new_flags
);
3615 if (old_flags
& BSF_GLOBAL
)
3617 /* Symbol definition. */
3618 bfd_vma code_address
= 0;
3619 unsigned long ca_psindx
= 0;
3620 unsigned long psindx
;
3622 if ((old_flags
& BSF_FUNCTION
) && symbol
->udata
.p
!= NULL
)
3627 ((struct evax_private_udata_struct
*)symbol
->udata
.p
)->enbsym
;
3628 code_address
= sym
->value
;
3629 ca_psindx
= sym
->section
->target_index
;
3631 if (bfd_is_abs_section (symbol
->section
))
3632 psindx
= abs_section_index
;
3634 psindx
= symbol
->section
->target_index
;
3636 _bfd_vms_output_quad (recwr
, symbol
->value
);
3637 _bfd_vms_output_quad (recwr
, code_address
);
3638 _bfd_vms_output_long (recwr
, ca_psindx
);
3639 _bfd_vms_output_long (recwr
, psindx
);
3641 _bfd_vms_output_counted (recwr
, symbol
->name
);
3643 _bfd_vms_output_end_subrec (recwr
);
3646 _bfd_vms_output_alignment (recwr
, 8);
3647 _bfd_vms_output_end (abfd
, recwr
);
3652 /* Write object header for bfd abfd. Return FALSE on error. */
3655 _bfd_vms_write_ehdr (bfd
*abfd
)
3658 unsigned int symnum
;
3659 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3661 vms_debug2 ((2, "vms_write_ehdr (%p)\n", abfd
));
3663 _bfd_vms_output_alignment (recwr
, 2);
3665 _bfd_vms_write_emh (abfd
);
3666 _bfd_vms_write_lmn (abfd
, "GNU AS");
3669 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3670 _bfd_vms_output_short (recwr
, EMH__C_SRC
);
3672 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3674 symbol
= abfd
->outsymbols
[symnum
];
3676 if (symbol
->flags
& BSF_FILE
)
3678 _bfd_vms_output_dump (recwr
, (unsigned char *) symbol
->name
,
3679 (int) strlen (symbol
->name
));
3684 if (symnum
== abfd
->symcount
)
3685 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("noname"));
3687 _bfd_vms_output_end (abfd
, recwr
);
3690 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3691 _bfd_vms_output_short (recwr
, EMH__C_TTL
);
3692 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("TTL"));
3693 _bfd_vms_output_end (abfd
, recwr
);
3696 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3697 _bfd_vms_output_short (recwr
, EMH__C_CPR
);
3698 _bfd_vms_output_dump (recwr
,
3699 (unsigned char *)"GNU BFD ported by Klaus Kämpf 1994-1996",
3701 _bfd_vms_output_end (abfd
, recwr
);
3706 /* Part 4.6, relocations. */
3709 /* WRITE ETIR SECTION
3711 This is still under construction and therefore not documented. */
3713 /* Close the etir/etbt record. */
3716 end_etir_record (bfd
* abfd
)
3718 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3720 _bfd_vms_output_end (abfd
, recwr
);
3724 start_etir_or_etbt_record (bfd
*abfd
, asection
*section
, bfd_vma offset
)
3726 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3728 if (section
->flags
& SEC_DEBUGGING
)
3730 _bfd_vms_output_begin (recwr
, EOBJ__C_ETBT
);
3734 /* Push start offset. */
3735 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3736 _bfd_vms_output_long (recwr
, (unsigned long) 0);
3737 _bfd_vms_output_end_subrec (recwr
);
3740 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_DFLOC
);
3741 _bfd_vms_output_end_subrec (recwr
);
3746 _bfd_vms_output_begin (recwr
, EOBJ__C_ETIR
);
3750 /* Push start offset. */
3751 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3752 _bfd_vms_output_long (recwr
, (unsigned long) section
->target_index
);
3753 _bfd_vms_output_quad (recwr
, offset
);
3754 _bfd_vms_output_end_subrec (recwr
);
3756 /* Start = pop (). */
3757 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_SETRB
);
3758 _bfd_vms_output_end_subrec (recwr
);
3763 /* Output a STO_IMM command for SSIZE bytes of data from CPR at virtual
3764 address VADDR in section specified by SEC_INDEX and NAME. */
3767 sto_imm (bfd
*abfd
, asection
*section
,
3768 bfd_size_type ssize
, unsigned char *cptr
, bfd_vma vaddr
)
3771 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3774 _bfd_vms_debug (8, "sto_imm %d bytes\n", (int) ssize
);
3775 _bfd_hexdump (9, cptr
, (int) ssize
, (int) vaddr
);
3780 /* Try all the rest. */
3783 if (_bfd_vms_output_check (recwr
, size
) < 0)
3785 /* Doesn't fit, split ! */
3786 end_etir_record (abfd
);
3788 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3790 size
= _bfd_vms_output_check (recwr
, 0); /* get max size */
3791 if (size
> ssize
) /* more than what's left ? */
3795 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_IMM
);
3796 _bfd_vms_output_long (recwr
, (unsigned long) (size
));
3797 _bfd_vms_output_dump (recwr
, cptr
, size
);
3798 _bfd_vms_output_end_subrec (recwr
);
3801 _bfd_vms_debug (10, "dumped %d bytes\n", (int) size
);
3802 _bfd_hexdump (10, cptr
, (int) size
, (int) vaddr
);
3812 etir_output_check (bfd
*abfd
, asection
*section
, bfd_vma vaddr
, int checklen
)
3814 if (_bfd_vms_output_check (&PRIV (recwr
), checklen
) < 0)
3816 /* Not enough room in this record. Close it and open a new one. */
3817 end_etir_record (abfd
);
3818 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3822 /* Return whether RELOC must be deferred till the end. */
3825 defer_reloc_p (arelent
*reloc
)
3827 switch (reloc
->howto
->type
)
3840 /* Write section contents for bfd abfd. Return FALSE on error. */
3843 _bfd_vms_write_etir (bfd
* abfd
, int objtype ATTRIBUTE_UNUSED
)
3846 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3848 vms_debug2 ((2, "vms_write_tir (%p, %d)\n", abfd
, objtype
));
3850 _bfd_vms_output_alignment (recwr
, 4);
3852 PRIV (vms_linkage_index
) = 0;
3854 for (section
= abfd
->sections
; section
; section
= section
->next
)
3856 vms_debug2 ((4, "writing %d. section '%s' (%d bytes)\n",
3857 section
->target_index
, section
->name
, (int) (section
->size
)));
3859 if (!(section
->flags
& SEC_HAS_CONTENTS
)
3860 || bfd_is_com_section (section
))
3863 if (!section
->contents
)
3865 bfd_set_error (bfd_error_no_contents
);
3869 start_etir_or_etbt_record (abfd
, section
, 0);
3871 if (section
->flags
& SEC_RELOC
)
3873 bfd_vma curr_addr
= 0;
3874 unsigned char *curr_data
= section
->contents
;
3876 int pass2_needed
= 0;
3877 int pass2_in_progress
= 0;
3880 if (section
->reloc_count
== 0)
3882 (_("SEC_RELOC with no relocs in section %pA"), section
);
3887 int i
= section
->reloc_count
;
3888 arelent
**rptr
= section
->orelocation
;
3889 _bfd_vms_debug (4, "%d relocations:\n", i
);
3892 _bfd_vms_debug (4, "sym %s in sec %s, value %08lx, "
3893 "addr %08lx, off %08lx, len %d: %s\n",
3894 (*(*rptr
)->sym_ptr_ptr
)->name
,
3895 (*(*rptr
)->sym_ptr_ptr
)->section
->name
,
3896 (long) (*(*rptr
)->sym_ptr_ptr
)->value
,
3897 (unsigned long)(*rptr
)->address
,
3898 (unsigned long)(*rptr
)->addend
,
3899 bfd_get_reloc_size ((*rptr
)->howto
),
3900 ( *rptr
)->howto
->name
);
3907 for (irel
= 0; irel
< section
->reloc_count
; irel
++)
3909 struct evax_private_udata_struct
*udata
;
3910 arelent
*rptr
= section
->orelocation
[irel
];
3911 bfd_vma addr
= rptr
->address
;
3912 asymbol
*sym
= *rptr
->sym_ptr_ptr
;
3913 asection
*sec
= sym
->section
;
3914 bfd_boolean defer
= defer_reloc_p (rptr
);
3917 if (pass2_in_progress
)
3919 /* Non-deferred relocs have already been output. */
3925 /* Deferred relocs must be output at the very end. */
3932 /* Regular relocs are intertwined with binary data. */
3933 if (curr_addr
> addr
)
3934 _bfd_error_handler (_("size error in section %pA"),
3936 size
= addr
- curr_addr
;
3937 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
3942 size
= bfd_get_reloc_size (rptr
->howto
);
3944 switch (rptr
->howto
->type
)
3946 case ALPHA_R_IGNORE
:
3949 case ALPHA_R_REFLONG
:
3950 if (bfd_is_und_section (sym
->section
))
3952 bfd_vma addend
= rptr
->addend
;
3953 slen
= strlen ((char *) sym
->name
);
3954 etir_output_check (abfd
, section
, curr_addr
, slen
);
3957 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
3958 _bfd_vms_output_counted (recwr
, sym
->name
);
3959 _bfd_vms_output_end_subrec (recwr
);
3960 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3961 _bfd_vms_output_long (recwr
, (unsigned long) addend
);
3962 _bfd_vms_output_end_subrec (recwr
);
3963 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
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 _bfd_vms_output_begin_subrec
3971 (recwr
, ETIR__C_STO_GBL_LW
);
3972 _bfd_vms_output_counted (recwr
, sym
->name
);
3973 _bfd_vms_output_end_subrec (recwr
);
3976 else if (bfd_is_abs_section (sym
->section
))
3978 etir_output_check (abfd
, section
, curr_addr
, 16);
3979 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3980 _bfd_vms_output_long (recwr
, (unsigned long) sym
->value
);
3981 _bfd_vms_output_end_subrec (recwr
);
3982 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3983 _bfd_vms_output_end_subrec (recwr
);
3987 etir_output_check (abfd
, section
, curr_addr
, 32);
3988 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3989 _bfd_vms_output_long (recwr
,
3990 (unsigned long) sec
->target_index
);
3991 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
3992 _bfd_vms_output_end_subrec (recwr
);
3993 /* ??? Table B-8 of the OpenVMS Linker Utilily Manual
3994 says that we should have a ETIR__C_STO_OFF here.
3995 But the relocation would not be BFD_RELOC_32 then.
3996 This case is very likely unreachable. */
3997 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3998 _bfd_vms_output_end_subrec (recwr
);
4002 case ALPHA_R_REFQUAD
:
4003 if (bfd_is_und_section (sym
->section
))
4005 bfd_vma addend
= rptr
->addend
;
4006 slen
= strlen ((char *) sym
->name
);
4007 etir_output_check (abfd
, section
, curr_addr
, slen
);
4010 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
4011 _bfd_vms_output_counted (recwr
, sym
->name
);
4012 _bfd_vms_output_end_subrec (recwr
);
4013 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
4014 _bfd_vms_output_quad (recwr
, addend
);
4015 _bfd_vms_output_end_subrec (recwr
);
4016 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
4017 _bfd_vms_output_end_subrec (recwr
);
4018 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
4019 _bfd_vms_output_end_subrec (recwr
);
4023 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_GBL
);
4024 _bfd_vms_output_counted (recwr
, sym
->name
);
4025 _bfd_vms_output_end_subrec (recwr
);
4028 else if (bfd_is_abs_section (sym
->section
))
4030 etir_output_check (abfd
, section
, curr_addr
, 16);
4031 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
4032 _bfd_vms_output_quad (recwr
, sym
->value
);
4033 _bfd_vms_output_end_subrec (recwr
);
4034 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
4035 _bfd_vms_output_end_subrec (recwr
);
4039 etir_output_check (abfd
, section
, curr_addr
, 32);
4040 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
4041 _bfd_vms_output_long (recwr
,
4042 (unsigned long) sec
->target_index
);
4043 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
4044 _bfd_vms_output_end_subrec (recwr
);
4045 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_OFF
);
4046 _bfd_vms_output_end_subrec (recwr
);
4051 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
4054 case ALPHA_R_LINKAGE
:
4056 etir_output_check (abfd
, section
, curr_addr
, 64);
4057 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LP_PSB
);
4058 _bfd_vms_output_long
4059 (recwr
, (unsigned long) rptr
->addend
);
4060 if (rptr
->addend
> PRIV (vms_linkage_index
))
4061 PRIV (vms_linkage_index
) = rptr
->addend
;
4062 _bfd_vms_output_counted (recwr
, sym
->name
);
4063 _bfd_vms_output_byte (recwr
, 0);
4064 _bfd_vms_output_end_subrec (recwr
);
4067 case ALPHA_R_CODEADDR
:
4068 slen
= strlen ((char *) sym
->name
);
4069 etir_output_check (abfd
, section
, curr_addr
, slen
);
4070 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_CA
);
4071 _bfd_vms_output_counted (recwr
, sym
->name
);
4072 _bfd_vms_output_end_subrec (recwr
);
4077 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4078 etir_output_check (abfd
, section
, curr_addr
,
4079 32 + 1 + strlen (udata
->origname
));
4080 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_NOP_GBL
);
4081 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
4082 _bfd_vms_output_long
4083 (recwr
, (unsigned long) section
->target_index
);
4084 _bfd_vms_output_quad (recwr
, rptr
->address
);
4085 _bfd_vms_output_long (recwr
, (unsigned long) 0x47ff041f);
4086 _bfd_vms_output_long
4087 (recwr
, (unsigned long) section
->target_index
);
4088 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4089 _bfd_vms_output_counted (recwr
, udata
->origname
);
4090 _bfd_vms_output_end_subrec (recwr
);
4094 _bfd_error_handler (_("spurious ALPHA_R_BSR reloc"));
4099 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4100 etir_output_check (abfd
, section
, curr_addr
,
4101 32 + 1 + strlen (udata
->origname
));
4102 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LDA_GBL
);
4103 _bfd_vms_output_long
4104 (recwr
, (unsigned long) udata
->lkindex
+ 1);
4105 _bfd_vms_output_long
4106 (recwr
, (unsigned long) section
->target_index
);
4107 _bfd_vms_output_quad (recwr
, rptr
->address
);
4108 _bfd_vms_output_long (recwr
, (unsigned long) 0x237B0000);
4109 _bfd_vms_output_long
4110 (recwr
, (unsigned long) udata
->bsym
->section
->target_index
);
4111 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4112 _bfd_vms_output_counted (recwr
, udata
->origname
);
4113 _bfd_vms_output_end_subrec (recwr
);
4118 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4119 etir_output_check (abfd
, section
, curr_addr
,
4120 32 + 1 + strlen (udata
->origname
));
4121 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_BOH_GBL
);
4122 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
4123 _bfd_vms_output_long
4124 (recwr
, (unsigned long) section
->target_index
);
4125 _bfd_vms_output_quad (recwr
, rptr
->address
);
4126 _bfd_vms_output_long (recwr
, (unsigned long) 0xD3400000);
4127 _bfd_vms_output_long
4128 (recwr
, (unsigned long) section
->target_index
);
4129 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4130 _bfd_vms_output_counted (recwr
, udata
->origname
);
4131 _bfd_vms_output_end_subrec (recwr
);
4135 _bfd_error_handler (_("unhandled relocation %s"),
4142 } /* End of relocs loop. */
4144 if (!pass2_in_progress
)
4146 /* Output rest of section. */
4147 if (curr_addr
> section
->size
)
4149 _bfd_error_handler (_("size error in section %pA"), section
);
4152 size
= section
->size
- curr_addr
;
4153 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
4159 pass2_in_progress
= 1;
4165 else /* (section->flags & SEC_RELOC) */
4166 sto_imm (abfd
, section
, section
->size
, section
->contents
, 0);
4168 end_etir_record (abfd
);
4171 _bfd_vms_output_alignment (recwr
, 2);
4175 /* Write cached information into a file being written, at bfd_close. */
4178 alpha_vms_write_object_contents (bfd
*abfd
)
4180 vms_debug2 ((1, "vms_write_object_contents (%p)\n", abfd
));
4182 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
4184 return alpha_vms_write_exec (abfd
);
4188 if (abfd
->section_count
> 0) /* we have sections */
4190 if (!_bfd_vms_write_ehdr (abfd
))
4192 if (!_bfd_vms_write_egsd (abfd
))
4194 if (!_bfd_vms_write_etir (abfd
, EOBJ__C_ETIR
))
4196 if (!_bfd_vms_write_eeom (abfd
))
4203 /* Debug stuff: nearest line. */
4205 #define SET_MODULE_PARSED(m) \
4206 do { if ((m)->name == NULL) (m)->name = ""; } while (0)
4207 #define IS_MODULE_PARSED(m) ((m)->name != NULL)
4209 /* Build a new module for the specified BFD. */
4211 static struct module
*
4212 new_module (bfd
*abfd
)
4214 struct module
*module
4215 = (struct module
*) bfd_zalloc (abfd
, sizeof (struct module
));
4216 module
->file_table_count
= 16; /* Arbitrary. */
4218 = bfd_malloc (module
->file_table_count
* sizeof (struct fileinfo
));
4222 /* Parse debug info for a module and internalize it. */
4225 parse_module (bfd
*abfd
, struct module
*module
, unsigned char *ptr
,
4228 unsigned char *maxptr
= ptr
+ length
;
4229 unsigned char *src_ptr
, *pcl_ptr
;
4230 unsigned int prev_linum
= 0, curr_linenum
= 0;
4231 bfd_vma prev_pc
= 0, curr_pc
= 0;
4232 struct srecinfo
*curr_srec
, *srec
;
4233 struct lineinfo
*curr_line
, *line
;
4234 struct funcinfo
*funcinfo
;
4236 /* Initialize tables with zero element. */
4237 curr_srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4238 module
->srec_table
= curr_srec
;
4240 curr_line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4241 module
->line_table
= curr_line
;
4243 while (length
== -1 || ptr
< maxptr
)
4245 /* The first byte is not counted in the recorded length. */
4246 int rec_length
= bfd_getl16 (ptr
) + 1;
4247 int rec_type
= bfd_getl16 (ptr
+ 2);
4249 vms_debug2 ((2, "DST record: leng %d, type %d\n", rec_length
, rec_type
));
4251 if (length
== -1 && rec_type
== DST__K_MODEND
)
4258 = _bfd_vms_save_counted_string (abfd
, ptr
+ DST_S_B_MODBEG_NAME
,
4259 maxptr
- (ptr
+ DST_S_B_MODBEG_NAME
));
4266 vms_debug2 ((3, "module: %s\n", module
->name
));
4273 funcinfo
= (struct funcinfo
*)
4274 bfd_zalloc (abfd
, sizeof (struct funcinfo
));
4276 = _bfd_vms_save_counted_string (abfd
, ptr
+ DST_S_B_RTNBEG_NAME
,
4277 maxptr
- (ptr
+ DST_S_B_RTNBEG_NAME
));
4278 funcinfo
->low
= bfd_getl32 (ptr
+ DST_S_L_RTNBEG_ADDRESS
);
4279 funcinfo
->next
= module
->func_table
;
4280 module
->func_table
= funcinfo
;
4282 vms_debug2 ((3, "routine: %s at 0x%lx\n",
4283 funcinfo
->name
, (unsigned long) funcinfo
->low
));
4287 module
->func_table
->high
= module
->func_table
->low
4288 + bfd_getl32 (ptr
+ DST_S_L_RTNEND_SIZE
) - 1;
4290 if (module
->func_table
->high
> module
->high
)
4291 module
->high
= module
->func_table
->high
;
4293 vms_debug2 ((3, "end routine\n"));
4297 vms_debug2 ((3, "prologue\n"));
4301 vms_debug2 ((3, "epilog\n"));
4305 vms_debug2 ((3, "block\n"));
4309 vms_debug2 ((3, "end block\n"));
4313 src_ptr
= ptr
+ DST_S_C_SOURCE_HEADER_SIZE
;
4315 vms_debug2 ((3, "source info\n"));
4317 while (src_ptr
< ptr
+ rec_length
)
4319 int cmd
= src_ptr
[0], cmd_length
, data
;
4323 case DST__K_SRC_DECLFILE
:
4326 = bfd_getl16 (src_ptr
+ DST_S_W_SRC_DF_FILEID
);
4327 char *filename
= _bfd_vms_save_counted_string
4329 src_ptr
+ DST_S_B_SRC_DF_FILENAME
,
4330 ptr
+ rec_length
- (src_ptr
+ DST_S_B_SRC_DF_FILENAME
));
4332 while (fileid
>= module
->file_table_count
)
4334 module
->file_table_count
*= 2;
4336 = bfd_realloc (module
->file_table
,
4337 module
->file_table_count
4338 * sizeof (struct fileinfo
));
4341 module
->file_table
[fileid
].name
= filename
;
4342 module
->file_table
[fileid
].srec
= 1;
4343 cmd_length
= src_ptr
[DST_S_B_SRC_DF_LENGTH
] + 2;
4344 vms_debug2 ((4, "DST_S_C_SRC_DECLFILE: %d, %s\n",
4345 fileid
, module
->file_table
[fileid
].name
));
4349 case DST__K_SRC_DEFLINES_B
:
4350 /* Perform the association and set the next higher index
4352 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4353 srec
= (struct srecinfo
*)
4354 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4355 srec
->line
= curr_srec
->line
+ data
;
4356 srec
->srec
= curr_srec
->srec
+ data
;
4357 srec
->sfile
= curr_srec
->sfile
;
4358 curr_srec
->next
= srec
;
4361 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_B: %d\n", data
));
4364 case DST__K_SRC_DEFLINES_W
:
4365 /* Perform the association and set the next higher index
4367 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4368 srec
= (struct srecinfo
*)
4369 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4370 srec
->line
= curr_srec
->line
+ data
;
4371 srec
->srec
= curr_srec
->srec
+ data
,
4372 srec
->sfile
= curr_srec
->sfile
;
4373 curr_srec
->next
= srec
;
4376 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_W: %d\n", data
));
4379 case DST__K_SRC_INCRLNUM_B
:
4380 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4381 curr_srec
->line
+= data
;
4383 vms_debug2 ((4, "DST_S_C_SRC_INCRLNUM_B: %d\n", data
));
4386 case DST__K_SRC_SETFILE
:
4387 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4388 curr_srec
->sfile
= data
;
4389 curr_srec
->srec
= module
->file_table
[data
].srec
;
4391 vms_debug2 ((4, "DST_S_C_SRC_SETFILE: %d\n", data
));
4394 case DST__K_SRC_SETLNUM_L
:
4395 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4396 curr_srec
->line
= data
;
4398 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_L: %d\n", data
));
4401 case DST__K_SRC_SETLNUM_W
:
4402 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4403 curr_srec
->line
= data
;
4405 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_W: %d\n", data
));
4408 case DST__K_SRC_SETREC_L
:
4409 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4410 curr_srec
->srec
= data
;
4411 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4413 vms_debug2 ((4, "DST_S_C_SRC_SETREC_L: %d\n", data
));
4416 case DST__K_SRC_SETREC_W
:
4417 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4418 curr_srec
->srec
= data
;
4419 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4421 vms_debug2 ((4, "DST_S_C_SRC_SETREC_W: %d\n", data
));
4424 case DST__K_SRC_FORMFEED
:
4426 vms_debug2 ((4, "DST_S_C_SRC_FORMFEED\n"));
4430 _bfd_error_handler (_("unknown source command %d"),
4436 src_ptr
+= cmd_length
;
4440 case DST__K_LINE_NUM
:
4441 pcl_ptr
= ptr
+ DST_S_C_LINE_NUM_HEADER_SIZE
;
4443 vms_debug2 ((3, "line info\n"));
4445 while (pcl_ptr
< ptr
+ rec_length
)
4447 /* The command byte is signed so we must sign-extend it. */
4448 int cmd
= ((signed char *)pcl_ptr
)[0], cmd_length
, data
;
4452 case DST__K_DELTA_PC_W
:
4453 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4457 vms_debug2 ((4, "DST__K_DELTA_PC_W: %d\n", data
));
4460 case DST__K_DELTA_PC_L
:
4461 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4465 vms_debug2 ((4, "DST__K_DELTA_PC_L: %d\n", data
));
4468 case DST__K_INCR_LINUM
:
4469 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4470 curr_linenum
+= data
;
4472 vms_debug2 ((4, "DST__K_INCR_LINUM: %d\n", data
));
4475 case DST__K_INCR_LINUM_W
:
4476 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4477 curr_linenum
+= data
;
4479 vms_debug2 ((4, "DST__K_INCR_LINUM_W: %d\n", data
));
4482 case DST__K_INCR_LINUM_L
:
4483 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4484 curr_linenum
+= data
;
4486 vms_debug2 ((4, "DST__K_INCR_LINUM_L: %d\n", data
));
4489 case DST__K_SET_LINUM_INCR
:
4491 (_("%s not implemented"), "DST__K_SET_LINUM_INCR");
4495 case DST__K_SET_LINUM_INCR_W
:
4497 (_("%s not implemented"), "DST__K_SET_LINUM_INCR_W");
4501 case DST__K_RESET_LINUM_INCR
:
4503 (_("%s not implemented"), "DST__K_RESET_LINUM_INCR");
4507 case DST__K_BEG_STMT_MODE
:
4509 (_("%s not implemented"), "DST__K_BEG_STMT_MODE");
4513 case DST__K_END_STMT_MODE
:
4515 (_("%s not implemented"), "DST__K_END_STMT_MODE");
4519 case DST__K_SET_LINUM_B
:
4520 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4521 curr_linenum
= data
;
4523 vms_debug2 ((4, "DST__K_SET_LINUM_B: %d\n", data
));
4526 case DST__K_SET_LINUM
:
4527 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4528 curr_linenum
= data
;
4530 vms_debug2 ((4, "DST__K_SET_LINE_NUM: %d\n", data
));
4533 case DST__K_SET_LINUM_L
:
4534 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4535 curr_linenum
= data
;
4537 vms_debug2 ((4, "DST__K_SET_LINUM_L: %d\n", data
));
4542 (_("%s not implemented"), "DST__K_SET_PC");
4546 case DST__K_SET_PC_W
:
4548 (_("%s not implemented"), "DST__K_SET_PC_W");
4552 case DST__K_SET_PC_L
:
4554 (_("%s not implemented"), "DST__K_SET_PC_L");
4558 case DST__K_SET_STMTNUM
:
4560 (_("%s not implemented"), "DST__K_SET_STMTNUM");
4565 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4568 vms_debug2 ((4, "DST__K_TERM: %d\n", data
));
4572 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4575 vms_debug2 ((4, "DST__K_TERM_W: %d\n", data
));
4579 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4582 vms_debug2 ((4, "DST__K_TERM_L: %d\n", data
));
4585 case DST__K_SET_ABS_PC
:
4586 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4589 vms_debug2 ((4, "DST__K_SET_ABS_PC: 0x%x\n", data
));
4598 vms_debug2 ((4, "bump pc to 0x%lx and line to %d\n",
4599 (unsigned long)curr_pc
, curr_linenum
));
4603 _bfd_error_handler (_("unknown line command %d"), cmd
);
4609 if ((curr_linenum
!= prev_linum
&& curr_pc
!= prev_pc
)
4611 || cmd
== DST__K_DELTA_PC_L
4612 || cmd
== DST__K_DELTA_PC_W
)
4614 line
= (struct lineinfo
*)
4615 bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4616 line
->address
= curr_pc
;
4617 line
->line
= curr_linenum
;
4619 curr_line
->next
= line
;
4622 prev_linum
= curr_linenum
;
4624 vms_debug2 ((4, "-> correlate pc 0x%lx with line %d\n",
4625 (unsigned long)curr_pc
, curr_linenum
));
4628 pcl_ptr
+= cmd_length
;
4632 case 0x17: /* Undocumented type used by DEC C to declare equates. */
4633 vms_debug2 ((3, "undocumented type 0x17\n"));
4637 vms_debug2 ((3, "ignoring record\n"));
4645 /* Finalize tables with EOL marker. */
4646 srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4647 srec
->line
= (unsigned int) -1;
4648 srec
->srec
= (unsigned int) -1;
4649 curr_srec
->next
= srec
;
4651 line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4652 line
->line
= (unsigned int) -1;
4653 line
->address
= (bfd_vma
) -1;
4654 curr_line
->next
= line
;
4656 /* Advertise that this module has been parsed. This is needed
4657 because parsing can be either performed at module creation
4658 or deferred until debug info is consumed. */
4659 SET_MODULE_PARSED (module
);
4662 /* Build the list of modules for the specified BFD. */
4664 static struct module
*
4665 build_module_list (bfd
*abfd
)
4667 struct module
*module
, *list
= NULL
;
4670 if ((dmt
= bfd_get_section_by_name (abfd
, "$DMT$")))
4672 /* We have a DMT section so this must be an image. Parse the
4673 section and build the list of modules. This is sufficient
4674 since we can compute the start address and the end address
4675 of every module from the section contents. */
4676 bfd_size_type size
= bfd_section_size (dmt
);
4677 unsigned char *ptr
, *end
;
4679 ptr
= (unsigned char *) bfd_alloc (abfd
, size
);
4683 if (! bfd_get_section_contents (abfd
, dmt
, ptr
, 0, size
))
4686 vms_debug2 ((2, "DMT\n"));
4692 /* Each header declares a module with its start offset and size
4693 of debug info in the DST section, as well as the count of
4694 program sections (i.e. address spans) it contains. */
4695 int modbeg
= bfd_getl32 (ptr
+ DBG_S_L_DMT_MODBEG
);
4696 int msize
= bfd_getl32 (ptr
+ DBG_S_L_DST_SIZE
);
4697 int count
= bfd_getl16 (ptr
+ DBG_S_W_DMT_PSECT_COUNT
);
4698 ptr
+= DBG_S_C_DMT_HEADER_SIZE
;
4700 vms_debug2 ((3, "module: modbeg = %d, size = %d, count = %d\n",
4701 modbeg
, msize
, count
));
4703 /* We create a 'module' structure for each program section since
4704 we only support contiguous addresses in a 'module' structure.
4705 As a consequence, the actual debug info in the DST section is
4706 shared and can be parsed multiple times; that doesn't seem to
4707 cause problems in practice. */
4710 int start
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_START
);
4711 int length
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_LENGTH
);
4712 module
= new_module (abfd
);
4713 module
->modbeg
= modbeg
;
4714 module
->size
= msize
;
4715 module
->low
= start
;
4716 module
->high
= start
+ length
;
4717 module
->next
= list
;
4719 ptr
+= DBG_S_C_DMT_PSECT_SIZE
;
4721 vms_debug2 ((4, "section: start = 0x%x, length = %d\n",
4728 /* We don't have a DMT section so this must be an object. Parse
4729 the module right now in order to compute its start address and
4731 void *dst
= PRIV (dst_section
)->contents
;
4736 module
= new_module (abfd
);
4737 parse_module (abfd
, module
, PRIV (dst_section
)->contents
, -1);
4744 /* Calculate and return the name of the source file and the line nearest
4745 to the wanted location in the specified module. */
4748 module_find_nearest_line (bfd
*abfd
, struct module
*module
, bfd_vma addr
,
4749 const char **file
, const char **func
,
4752 struct funcinfo
*funcinfo
;
4753 struct lineinfo
*lineinfo
;
4754 struct srecinfo
*srecinfo
;
4755 bfd_boolean ret
= FALSE
;
4757 /* Parse this module if that was not done at module creation. */
4758 if (! IS_MODULE_PARSED (module
))
4760 unsigned int size
= module
->size
;
4761 unsigned int modbeg
= PRIV (dst_section
)->filepos
+ module
->modbeg
;
4762 unsigned char *buffer
= (unsigned char *) bfd_malloc (module
->size
);
4764 if (bfd_seek (abfd
, modbeg
, SEEK_SET
) != 0
4765 || bfd_bread (buffer
, size
, abfd
) != size
)
4767 bfd_set_error (bfd_error_no_debug_section
);
4771 parse_module (abfd
, module
, buffer
, size
);
4775 /* Find out the function (if any) that contains the address. */
4776 for (funcinfo
= module
->func_table
; funcinfo
; funcinfo
= funcinfo
->next
)
4777 if (addr
>= funcinfo
->low
&& addr
<= funcinfo
->high
)
4779 *func
= funcinfo
->name
;
4784 /* Find out the source file and the line nearest to the address. */
4785 for (lineinfo
= module
->line_table
; lineinfo
; lineinfo
= lineinfo
->next
)
4786 if (lineinfo
->next
&& addr
< lineinfo
->next
->address
)
4788 for (srecinfo
= module
->srec_table
; srecinfo
; srecinfo
= srecinfo
->next
)
4789 if (srecinfo
->next
&& lineinfo
->line
< srecinfo
->next
->line
)
4791 if (srecinfo
->sfile
> 0)
4793 *file
= module
->file_table
[srecinfo
->sfile
].name
;
4794 *line
= srecinfo
->srec
+ lineinfo
->line
- srecinfo
->line
;
4798 *file
= module
->name
;
4799 *line
= lineinfo
->line
;
4810 /* Provided a BFD, a section and an offset into the section, calculate and
4811 return the name of the source file and the line nearest to the wanted
4815 _bfd_vms_find_nearest_line (bfd
*abfd
,
4816 asymbol
**symbols ATTRIBUTE_UNUSED
,
4822 unsigned int *discriminator
)
4824 struct module
*module
;
4826 /* What address are we looking for? */
4827 bfd_vma addr
= section
->vma
+ offset
;
4835 /* We can't do anything if there is no DST (debug symbol table). */
4836 if (PRIV (dst_section
) == NULL
)
4839 /* Create the module list - if not already done. */
4840 if (PRIV (modules
) == NULL
)
4842 PRIV (modules
) = build_module_list (abfd
);
4843 if (PRIV (modules
) == NULL
)
4847 for (module
= PRIV (modules
); module
; module
= module
->next
)
4848 if (addr
>= module
->low
&& addr
<= module
->high
)
4849 return module_find_nearest_line (abfd
, module
, addr
, file
, func
, line
);
4854 /* Canonicalizations. */
4855 /* Set name, value, section and flags of SYM from E. */
4858 alpha_vms_convert_symbol (bfd
*abfd
, struct vms_symbol_entry
*e
, asymbol
*sym
)
4867 flags
= BSF_NO_FLAGS
;
4873 if (e
->flags
& EGSY__V_WEAK
)
4876 if (e
->flags
& EGSY__V_DEF
)
4878 /* Symbol definition. */
4879 flags
|= BSF_GLOBAL
;
4880 if (e
->flags
& EGSY__V_NORM
)
4881 flags
|= BSF_FUNCTION
;
4887 /* Symbol reference. */
4888 sec
= bfd_und_section_ptr
;
4893 /* A universal symbol is by definition global... */
4894 flags
|= BSF_GLOBAL
;
4896 /* ...and dynamic in shared libraries. */
4897 if (abfd
->flags
& DYNAMIC
)
4898 flags
|= BSF_DYNAMIC
;
4900 if (e
->flags
& EGSY__V_WEAK
)
4903 if (!(e
->flags
& EGSY__V_DEF
))
4906 if (e
->flags
& EGSY__V_NORM
)
4907 flags
|= BSF_FUNCTION
;
4910 /* sec = e->section; */
4911 sec
= bfd_abs_section_ptr
;
4926 /* Return the number of bytes required to store a vector of pointers
4927 to asymbols for all the symbols in the BFD abfd, including a
4928 terminal NULL pointer. If there are no symbols in the BFD,
4929 then return 0. If an error occurs, return -1. */
4932 alpha_vms_get_symtab_upper_bound (bfd
*abfd
)
4934 vms_debug2 ((1, "alpha_vms_get_symtab_upper_bound (%p), %d symbols\n",
4935 abfd
, PRIV (gsd_sym_count
)));
4937 return (PRIV (gsd_sym_count
) + 1) * sizeof (asymbol
*);
4940 /* Read the symbols from the BFD abfd, and fills in the vector
4941 location with pointers to the symbols and a trailing NULL.
4943 Return number of symbols read. */
4946 alpha_vms_canonicalize_symtab (bfd
*abfd
, asymbol
**symbols
)
4950 vms_debug2 ((1, "alpha_vms_canonicalize_symtab (%p, <ret>)\n", abfd
));
4952 if (PRIV (csymbols
) == NULL
)
4954 PRIV (csymbols
) = (asymbol
**) bfd_alloc
4955 (abfd
, PRIV (gsd_sym_count
) * sizeof (asymbol
*));
4957 /* Traverse table and fill symbols vector. */
4958 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
4960 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
4963 sym
= bfd_make_empty_symbol (abfd
);
4964 if (sym
== NULL
|| !alpha_vms_convert_symbol (abfd
, e
, sym
))
4966 bfd_release (abfd
, PRIV (csymbols
));
4967 PRIV (csymbols
) = NULL
;
4971 PRIV (csymbols
)[i
] = sym
;
4975 if (symbols
!= NULL
)
4977 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
4978 symbols
[i
] = PRIV (csymbols
)[i
];
4982 return PRIV (gsd_sym_count
);
4985 /* Read and convert relocations from ETIR. We do it once for all sections. */
4988 alpha_vms_slurp_relocs (bfd
*abfd
)
4992 vms_debug2 ((3, "alpha_vms_slurp_relocs\n"));
4994 /* We slurp relocs only once, for all sections. */
4995 if (PRIV (reloc_done
))
4997 PRIV (reloc_done
) = TRUE
;
4999 if (alpha_vms_canonicalize_symtab (abfd
, NULL
) < 0)
5002 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
5007 unsigned char *begin
;
5010 bfd_reloc_code_real_type reloc_code
;
5016 bfd_vma cur_address
;
5018 unsigned char *cur_sym
= NULL
;
5020 bfd_vma cur_addend
= 0;
5022 /* Skip non-ETIR records. */
5023 type
= _bfd_vms_get_object_record (abfd
);
5024 if (type
== EOBJ__C_EEOM
)
5026 if (type
!= EOBJ__C_ETIR
)
5029 begin
= PRIV (recrd
.rec
) + 4;
5030 end
= PRIV (recrd
.rec
) + PRIV (recrd
.rec_size
);
5032 for (ptr
= begin
; ptr
< end
; ptr
+= length
)
5036 cmd
= bfd_getl16 (ptr
);
5037 length
= bfd_getl16 (ptr
+ 2);
5039 cur_address
= vaddr
;
5041 vms_debug2 ((4, "alpha_vms_slurp_relocs: etir %s\n",
5042 _bfd_vms_etir_name (cmd
)));
5046 case ETIR__C_STA_GBL
: /* ALPHA_R_REFLONG und_section, step 1 */
5047 /* ALPHA_R_REFQUAD und_section, step 1 */
5052 case ETIR__C_STA_PQ
: /* ALPHA_R_REF{LONG|QUAD}, others part 1 */
5053 cur_psidx
= bfd_getl32 (ptr
+ 4);
5054 cur_addend
= bfd_getl64 (ptr
+ 8);
5058 case ETIR__C_CTL_SETRB
:
5059 if (prev_cmd
!= ETIR__C_STA_PQ
)
5062 /* xgettext:c-format */
5063 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (prev_cmd
),
5064 _bfd_vms_etir_name (cmd
));
5067 cur_psect
= cur_psidx
;
5073 case ETIR__C_STA_LW
: /* ALPHA_R_REFLONG abs_section, step 1 */
5074 /* ALPHA_R_REFLONG und_section, step 2 */
5077 if (prev_cmd
!= ETIR__C_STA_GBL
)
5080 /* xgettext:c-format */
5081 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
5082 _bfd_vms_etir_name (ETIR__C_STA_LW
));
5086 cur_addend
= bfd_getl32 (ptr
+ 4);
5090 case ETIR__C_STA_QW
: /* ALPHA_R_REFQUAD abs_section, step 1 */
5091 /* ALPHA_R_REFQUAD und_section, step 2 */
5092 if (prev_cmd
!= -1 && prev_cmd
!= ETIR__C_STA_GBL
)
5095 /* xgettext:c-format */
5096 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
5097 _bfd_vms_etir_name (ETIR__C_STA_QW
));
5100 cur_addend
= bfd_getl64 (ptr
+ 4);
5104 case ETIR__C_STO_LW
: /* ALPHA_R_REFLONG und_section, step 4 */
5105 /* ALPHA_R_REFLONG abs_section, step 2 */
5106 /* ALPHA_R_REFLONG others, step 2 */
5107 if (prev_cmd
!= ETIR__C_OPR_ADD
5108 && prev_cmd
!= ETIR__C_STA_LW
5109 && prev_cmd
!= ETIR__C_STA_PQ
)
5111 /* xgettext:c-format */
5112 _bfd_error_handler (_("unknown reloc %s + %s"),
5113 _bfd_vms_etir_name (prev_cmd
),
5114 _bfd_vms_etir_name (ETIR__C_STO_LW
));
5117 reloc_code
= BFD_RELOC_32
;
5120 case ETIR__C_STO_QW
: /* ALPHA_R_REFQUAD und_section, step 4 */
5121 /* ALPHA_R_REFQUAD abs_section, step 2 */
5122 if (prev_cmd
!= ETIR__C_OPR_ADD
&& prev_cmd
!= ETIR__C_STA_QW
)
5124 /* xgettext:c-format */
5125 _bfd_error_handler (_("unknown reloc %s + %s"),
5126 _bfd_vms_etir_name (prev_cmd
),
5127 _bfd_vms_etir_name (ETIR__C_STO_QW
));
5130 reloc_code
= BFD_RELOC_64
;
5133 case ETIR__C_STO_OFF
: /* ALPHA_R_REFQUAD others, step 2 */
5134 if (prev_cmd
!= ETIR__C_STA_PQ
)
5136 /* xgettext:c-format */
5137 _bfd_error_handler (_("unknown reloc %s + %s"),
5138 _bfd_vms_etir_name (prev_cmd
),
5139 _bfd_vms_etir_name (ETIR__C_STO_OFF
));
5142 reloc_code
= BFD_RELOC_64
;
5145 case ETIR__C_OPR_ADD
: /* ALPHA_R_REFLONG und_section, step 3 */
5146 /* ALPHA_R_REFQUAD und_section, step 3 */
5147 if (prev_cmd
!= ETIR__C_STA_LW
&& prev_cmd
!= ETIR__C_STA_QW
)
5149 /* xgettext:c-format */
5150 _bfd_error_handler (_("unknown reloc %s + %s"),
5151 _bfd_vms_etir_name (prev_cmd
),
5152 _bfd_vms_etir_name (ETIR__C_OPR_ADD
));
5155 prev_cmd
= ETIR__C_OPR_ADD
;
5158 case ETIR__C_STO_CA
: /* ALPHA_R_CODEADDR */
5159 reloc_code
= BFD_RELOC_ALPHA_CODEADDR
;
5163 case ETIR__C_STO_GBL
: /* ALPHA_R_REFQUAD und_section */
5164 reloc_code
= BFD_RELOC_64
;
5168 case ETIR__C_STO_GBL_LW
: /* ALPHA_R_REFLONG und_section */
5169 reloc_code
= BFD_RELOC_32
;
5173 case ETIR__C_STC_LP_PSB
: /* ALPHA_R_LINKAGE */
5174 reloc_code
= BFD_RELOC_ALPHA_LINKAGE
;
5178 case ETIR__C_STC_NOP_GBL
: /* ALPHA_R_NOP */
5179 reloc_code
= BFD_RELOC_ALPHA_NOP
;
5182 case ETIR__C_STC_BSR_GBL
: /* ALPHA_R_BSR */
5183 reloc_code
= BFD_RELOC_ALPHA_BSR
;
5186 case ETIR__C_STC_LDA_GBL
: /* ALPHA_R_LDA */
5187 reloc_code
= BFD_RELOC_ALPHA_LDA
;
5190 case ETIR__C_STC_BOH_GBL
: /* ALPHA_R_BOH */
5191 reloc_code
= BFD_RELOC_ALPHA_BOH
;
5195 cur_sym
= ptr
+ 4 + 32;
5196 cur_address
= bfd_getl64 (ptr
+ 4 + 8);
5197 cur_addend
= bfd_getl64 (ptr
+ 4 + 24);
5200 case ETIR__C_STO_IMM
:
5201 vaddr
+= bfd_getl32 (ptr
+ 4);
5205 _bfd_error_handler (_("unknown reloc %s"),
5206 _bfd_vms_etir_name (cmd
));
5212 struct vms_section_data_struct
*vms_sec
;
5216 /* Get section to which the relocation applies. */
5217 if (cur_psect
< 0 || cur_psect
> (int)PRIV (section_count
))
5219 _bfd_error_handler (_("invalid section index in ETIR"));
5223 if (PRIV (sections
) == NULL
)
5225 sec
= PRIV (sections
)[cur_psect
];
5226 if (sec
== bfd_abs_section_ptr
)
5228 _bfd_error_handler (_("relocation for non-REL psect"));
5232 vms_sec
= vms_section_data (sec
);
5234 /* Allocate a reloc entry. */
5235 if (sec
->reloc_count
>= vms_sec
->reloc_max
)
5237 if (vms_sec
->reloc_max
== 0)
5239 vms_sec
->reloc_max
= 64;
5240 sec
->relocation
= bfd_zmalloc
5241 (vms_sec
->reloc_max
* sizeof (arelent
));
5245 vms_sec
->reloc_max
*= 2;
5246 sec
->relocation
= bfd_realloc
5247 (sec
->relocation
, vms_sec
->reloc_max
* sizeof (arelent
));
5250 reloc
= &sec
->relocation
[sec
->reloc_count
];
5253 reloc
->howto
= bfd_reloc_type_lookup (abfd
, reloc_code
);
5255 if (cur_sym
!= NULL
)
5258 unsigned int symlen
= *cur_sym
;
5261 /* Linear search. */
5266 for (j
= 0; j
< PRIV (gsd_sym_count
); j
++)
5267 if (PRIV (syms
)[j
]->namelen
== symlen
5268 && memcmp (PRIV (syms
)[j
]->name
, cur_sym
, symlen
) == 0)
5270 sym
= &PRIV (csymbols
)[j
];
5275 _bfd_error_handler (_("unknown symbol in command %s"),
5276 _bfd_vms_etir_name (cmd
));
5277 reloc
->sym_ptr_ptr
= NULL
;
5280 reloc
->sym_ptr_ptr
= sym
;
5282 else if (cur_psidx
>= 0)
5284 if (PRIV (sections
) == NULL
|| cur_psidx
>= (int) PRIV (section_count
))
5286 reloc
->sym_ptr_ptr
=
5287 PRIV (sections
)[cur_psidx
]->symbol_ptr_ptr
;
5290 reloc
->sym_ptr_ptr
= NULL
;
5292 reloc
->address
= cur_address
;
5293 reloc
->addend
= cur_addend
;
5295 if (reloc_code
== ALPHA_R_LINKAGE
)
5298 size
= bfd_get_reloc_size (reloc
->howto
);
5308 vms_debug2 ((3, "alpha_vms_slurp_relocs: result = TRUE\n"));
5313 /* Return the number of bytes required to store the relocation
5314 information associated with the given section. */
5317 alpha_vms_get_reloc_upper_bound (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*section
)
5319 alpha_vms_slurp_relocs (abfd
);
5321 return (section
->reloc_count
+ 1) * sizeof (arelent
*);
5324 /* Convert relocations from VMS (external) form into BFD internal
5325 form. Return the number of relocations. */
5328 alpha_vms_canonicalize_reloc (bfd
*abfd
, asection
*section
, arelent
**relptr
,
5329 asymbol
**symbols ATTRIBUTE_UNUSED
)
5334 if (!alpha_vms_slurp_relocs (abfd
))
5337 count
= section
->reloc_count
;
5338 tblptr
= section
->relocation
;
5341 *relptr
++ = tblptr
++;
5343 *relptr
= (arelent
*) NULL
;
5344 return section
->reloc_count
;
5347 /* Install a new set of internal relocs. */
5349 #define alpha_vms_set_reloc _bfd_generic_set_reloc
5352 /* This is just copied from ecoff-alpha, needs to be fixed probably. */
5354 /* How to process the various reloc types. */
5356 static bfd_reloc_status_type
5357 reloc_nil (bfd
* abfd ATTRIBUTE_UNUSED
,
5358 arelent
*reloc ATTRIBUTE_UNUSED
,
5359 asymbol
*sym ATTRIBUTE_UNUSED
,
5360 void * data ATTRIBUTE_UNUSED
,
5361 asection
*sec ATTRIBUTE_UNUSED
,
5362 bfd
*output_bfd ATTRIBUTE_UNUSED
,
5363 char **error_message ATTRIBUTE_UNUSED
)
5366 vms_debug (1, "reloc_nil (abfd %p, output_bfd %p)\n", abfd
, output_bfd
);
5367 vms_debug (2, "In section %s, symbol %s\n",
5368 sec
->name
, sym
->name
);
5369 vms_debug (2, "reloc sym %s, addr %08lx, addend %08lx, reloc is a %s\n",
5370 reloc
->sym_ptr_ptr
[0]->name
,
5371 (unsigned long)reloc
->address
,
5372 (unsigned long)reloc
->addend
, reloc
->howto
->name
);
5373 vms_debug (2, "data at %p\n", data
);
5374 /* _bfd_hexdump (2, data, bfd_get_reloc_size (reloc->howto), 0); */
5377 return bfd_reloc_ok
;
5380 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
5381 from smaller values. Start with zero, widen, *then* decrement. */
5382 #define MINUS_ONE (((bfd_vma)0) - 1)
5384 static reloc_howto_type alpha_howto_table
[] =
5386 HOWTO (ALPHA_R_IGNORE
, /* Type. */
5387 0, /* Rightshift. */
5388 0, /* Size (0 = byte, 1 = short, 2 = long). */
5390 TRUE
, /* PC relative. */
5392 complain_overflow_dont
,/* Complain_on_overflow. */
5393 reloc_nil
, /* Special_function. */
5394 "IGNORE", /* Name. */
5395 TRUE
, /* Partial_inplace. */
5396 0, /* Source mask */
5398 TRUE
), /* PC rel offset. */
5400 /* A 64 bit reference to a symbol. */
5401 HOWTO (ALPHA_R_REFQUAD
, /* Type. */
5402 0, /* Rightshift. */
5403 4, /* Size (0 = byte, 1 = short, 2 = long). */
5405 FALSE
, /* PC relative. */
5407 complain_overflow_bitfield
, /* Complain_on_overflow. */
5408 reloc_nil
, /* Special_function. */
5409 "REFQUAD", /* Name. */
5410 TRUE
, /* Partial_inplace. */
5411 MINUS_ONE
, /* Source mask. */
5412 MINUS_ONE
, /* Dest mask. */
5413 FALSE
), /* PC rel offset. */
5415 /* A 21 bit branch. The native assembler generates these for
5416 branches within the text segment, and also fills in the PC
5417 relative offset in the instruction. */
5418 HOWTO (ALPHA_R_BRADDR
, /* Type. */
5419 2, /* Rightshift. */
5420 2, /* Size (0 = byte, 1 = short, 2 = long). */
5422 TRUE
, /* PC relative. */
5424 complain_overflow_signed
, /* Complain_on_overflow. */
5425 reloc_nil
, /* Special_function. */
5426 "BRADDR", /* Name. */
5427 TRUE
, /* Partial_inplace. */
5428 0x1fffff, /* Source mask. */
5429 0x1fffff, /* Dest mask. */
5430 FALSE
), /* PC rel offset. */
5432 /* A hint for a jump to a register. */
5433 HOWTO (ALPHA_R_HINT
, /* Type. */
5434 2, /* Rightshift. */
5435 1, /* Size (0 = byte, 1 = short, 2 = long). */
5437 TRUE
, /* PC relative. */
5439 complain_overflow_dont
,/* Complain_on_overflow. */
5440 reloc_nil
, /* Special_function. */
5442 TRUE
, /* Partial_inplace. */
5443 0x3fff, /* Source mask. */
5444 0x3fff, /* Dest mask. */
5445 FALSE
), /* PC rel offset. */
5447 /* 16 bit PC relative offset. */
5448 HOWTO (ALPHA_R_SREL16
, /* Type. */
5449 0, /* Rightshift. */
5450 1, /* Size (0 = byte, 1 = short, 2 = long). */
5452 TRUE
, /* PC relative. */
5454 complain_overflow_signed
, /* Complain_on_overflow. */
5455 reloc_nil
, /* Special_function. */
5456 "SREL16", /* Name. */
5457 TRUE
, /* Partial_inplace. */
5458 0xffff, /* Source mask. */
5459 0xffff, /* Dest mask. */
5460 FALSE
), /* PC rel offset. */
5462 /* 32 bit PC relative offset. */
5463 HOWTO (ALPHA_R_SREL32
, /* Type. */
5464 0, /* Rightshift. */
5465 2, /* Size (0 = byte, 1 = short, 2 = long). */
5467 TRUE
, /* PC relative. */
5469 complain_overflow_signed
, /* Complain_on_overflow. */
5470 reloc_nil
, /* Special_function. */
5471 "SREL32", /* Name. */
5472 TRUE
, /* Partial_inplace. */
5473 0xffffffff, /* Source mask. */
5474 0xffffffff, /* Dest mask. */
5475 FALSE
), /* PC rel offset. */
5477 /* A 64 bit PC relative offset. */
5478 HOWTO (ALPHA_R_SREL64
, /* Type. */
5479 0, /* Rightshift. */
5480 4, /* Size (0 = byte, 1 = short, 2 = long). */
5482 TRUE
, /* PC relative. */
5484 complain_overflow_signed
, /* Complain_on_overflow. */
5485 reloc_nil
, /* Special_function. */
5486 "SREL64", /* Name. */
5487 TRUE
, /* Partial_inplace. */
5488 MINUS_ONE
, /* Source mask. */
5489 MINUS_ONE
, /* Dest mask. */
5490 FALSE
), /* PC rel offset. */
5492 /* Push a value on the reloc evaluation stack. */
5493 HOWTO (ALPHA_R_OP_PUSH
, /* Type. */
5494 0, /* Rightshift. */
5495 0, /* Size (0 = byte, 1 = short, 2 = long). */
5497 FALSE
, /* PC relative. */
5499 complain_overflow_dont
,/* Complain_on_overflow. */
5500 reloc_nil
, /* Special_function. */
5501 "OP_PUSH", /* Name. */
5502 FALSE
, /* Partial_inplace. */
5503 0, /* Source mask. */
5505 FALSE
), /* PC rel offset. */
5507 /* Store the value from the stack at the given address. Store it in
5508 a bitfield of size r_size starting at bit position r_offset. */
5509 HOWTO (ALPHA_R_OP_STORE
, /* Type. */
5510 0, /* Rightshift. */
5511 4, /* Size (0 = byte, 1 = short, 2 = long). */
5513 FALSE
, /* PC relative. */
5515 complain_overflow_dont
,/* Complain_on_overflow. */
5516 reloc_nil
, /* Special_function. */
5517 "OP_STORE", /* Name. */
5518 FALSE
, /* Partial_inplace. */
5519 0, /* Source mask. */
5520 MINUS_ONE
, /* Dest mask. */
5521 FALSE
), /* PC rel offset. */
5523 /* Subtract the reloc address from the value on the top of the
5524 relocation stack. */
5525 HOWTO (ALPHA_R_OP_PSUB
, /* Type. */
5526 0, /* Rightshift. */
5527 0, /* Size (0 = byte, 1 = short, 2 = long). */
5529 FALSE
, /* PC relative. */
5531 complain_overflow_dont
,/* Complain_on_overflow. */
5532 reloc_nil
, /* Special_function. */
5533 "OP_PSUB", /* Name. */
5534 FALSE
, /* Partial_inplace. */
5535 0, /* Source mask. */
5537 FALSE
), /* PC rel offset. */
5539 /* Shift the value on the top of the relocation stack right by the
5541 HOWTO (ALPHA_R_OP_PRSHIFT
, /* Type. */
5542 0, /* Rightshift. */
5543 0, /* Size (0 = byte, 1 = short, 2 = long). */
5545 FALSE
, /* PC relative. */
5547 complain_overflow_dont
,/* Complain_on_overflow. */
5548 reloc_nil
, /* Special_function. */
5549 "OP_PRSHIFT", /* Name. */
5550 FALSE
, /* Partial_inplace. */
5551 0, /* Source mask. */
5553 FALSE
), /* PC rel offset. */
5555 /* Hack. Linkage is done by linker. */
5556 HOWTO (ALPHA_R_LINKAGE
, /* Type. */
5557 0, /* Rightshift. */
5558 0, /* Size (0 = byte, 1 = short, 2 = long). */
5560 FALSE
, /* PC relative. */
5562 complain_overflow_dont
,/* Complain_on_overflow. */
5563 reloc_nil
, /* Special_function. */
5564 "LINKAGE", /* Name. */
5565 FALSE
, /* Partial_inplace. */
5566 0, /* Source mask. */
5568 FALSE
), /* PC rel offset. */
5570 /* A 32 bit reference to a symbol. */
5571 HOWTO (ALPHA_R_REFLONG
, /* Type. */
5572 0, /* Rightshift. */
5573 2, /* Size (0 = byte, 1 = short, 2 = long). */
5575 FALSE
, /* PC relative. */
5577 complain_overflow_bitfield
, /* Complain_on_overflow. */
5578 reloc_nil
, /* Special_function. */
5579 "REFLONG", /* Name. */
5580 TRUE
, /* Partial_inplace. */
5581 0xffffffff, /* Source mask. */
5582 0xffffffff, /* Dest mask. */
5583 FALSE
), /* PC rel offset. */
5585 /* A 64 bit reference to a procedure, written as 32 bit value. */
5586 HOWTO (ALPHA_R_CODEADDR
, /* Type. */
5587 0, /* Rightshift. */
5588 4, /* Size (0 = byte, 1 = short, 2 = long). */
5590 FALSE
, /* PC relative. */
5592 complain_overflow_signed
,/* Complain_on_overflow. */
5593 reloc_nil
, /* Special_function. */
5594 "CODEADDR", /* Name. */
5595 FALSE
, /* Partial_inplace. */
5596 0xffffffff, /* Source mask. */
5597 0xffffffff, /* Dest mask. */
5598 FALSE
), /* PC rel offset. */
5600 HOWTO (ALPHA_R_NOP
, /* Type. */
5601 0, /* Rightshift. */
5602 3, /* Size (0 = byte, 1 = short, 2 = long). */
5604 /* The following value must match that of ALPHA_R_BSR/ALPHA_R_BOH
5605 because the calculations for the 3 relocations are the same.
5606 See B.4.5.2 of the OpenVMS Linker Utility Manual. */
5607 TRUE
, /* PC relative. */
5609 complain_overflow_dont
,/* Complain_on_overflow. */
5610 reloc_nil
, /* Special_function. */
5612 FALSE
, /* Partial_inplace. */
5613 0xffffffff, /* Source mask. */
5614 0xffffffff, /* Dest mask. */
5615 FALSE
), /* PC rel offset. */
5617 HOWTO (ALPHA_R_BSR
, /* Type. */
5618 0, /* Rightshift. */
5619 3, /* Size (0 = byte, 1 = short, 2 = long). */
5621 TRUE
, /* PC relative. */
5623 complain_overflow_dont
,/* Complain_on_overflow. */
5624 reloc_nil
, /* Special_function. */
5626 FALSE
, /* Partial_inplace. */
5627 0xffffffff, /* Source mask. */
5628 0xffffffff, /* Dest mask. */
5629 FALSE
), /* PC rel offset. */
5631 HOWTO (ALPHA_R_LDA
, /* Type. */
5632 0, /* Rightshift. */
5633 3, /* Size (0 = byte, 1 = short, 2 = long). */
5635 FALSE
, /* PC relative. */
5637 complain_overflow_dont
,/* Complain_on_overflow. */
5638 reloc_nil
, /* Special_function. */
5640 FALSE
, /* Partial_inplace. */
5641 0xffffffff, /* Source mask. */
5642 0xffffffff, /* Dest mask. */
5643 FALSE
), /* PC rel offset. */
5645 HOWTO (ALPHA_R_BOH
, /* Type. */
5646 0, /* Rightshift. */
5647 3, /* Size (0 = byte, 1 = short, 2 = long, 3 = nil). */
5649 TRUE
, /* PC relative. */
5651 complain_overflow_dont
,/* Complain_on_overflow. */
5652 reloc_nil
, /* Special_function. */
5654 FALSE
, /* Partial_inplace. */
5655 0xffffffff, /* Source mask. */
5656 0xffffffff, /* Dest mask. */
5657 FALSE
), /* PC rel offset. */
5660 /* Return a pointer to a howto structure which, when invoked, will perform
5661 the relocation code on data from the architecture noted. */
5663 static reloc_howto_type
*
5664 alpha_vms_bfd_reloc_type_lookup (bfd
* abfd ATTRIBUTE_UNUSED
,
5665 bfd_reloc_code_real_type code
)
5669 vms_debug2 ((1, "vms_bfd_reloc_type_lookup (%p, %d)\t", abfd
, code
));
5673 case BFD_RELOC_16
: alpha_type
= ALPHA_R_SREL16
; break;
5674 case BFD_RELOC_32
: alpha_type
= ALPHA_R_REFLONG
; break;
5675 case BFD_RELOC_64
: alpha_type
= ALPHA_R_REFQUAD
; break;
5676 case BFD_RELOC_CTOR
: alpha_type
= ALPHA_R_REFQUAD
; break;
5677 case BFD_RELOC_23_PCREL_S2
: alpha_type
= ALPHA_R_BRADDR
; break;
5678 case BFD_RELOC_ALPHA_HINT
: alpha_type
= ALPHA_R_HINT
; break;
5679 case BFD_RELOC_16_PCREL
: alpha_type
= ALPHA_R_SREL16
; break;
5680 case BFD_RELOC_32_PCREL
: alpha_type
= ALPHA_R_SREL32
; break;
5681 case BFD_RELOC_64_PCREL
: alpha_type
= ALPHA_R_SREL64
; break;
5682 case BFD_RELOC_ALPHA_LINKAGE
: alpha_type
= ALPHA_R_LINKAGE
; break;
5683 case BFD_RELOC_ALPHA_CODEADDR
: alpha_type
= ALPHA_R_CODEADDR
; break;
5684 case BFD_RELOC_ALPHA_NOP
: alpha_type
= ALPHA_R_NOP
; break;
5685 case BFD_RELOC_ALPHA_BSR
: alpha_type
= ALPHA_R_BSR
; break;
5686 case BFD_RELOC_ALPHA_LDA
: alpha_type
= ALPHA_R_LDA
; break;
5687 case BFD_RELOC_ALPHA_BOH
: alpha_type
= ALPHA_R_BOH
; break;
5689 _bfd_error_handler (_("reloc (%d) is *UNKNOWN*"), code
);
5692 vms_debug2 ((2, "reloc is %s\n", alpha_howto_table
[alpha_type
].name
));
5693 return & alpha_howto_table
[alpha_type
];
5696 static reloc_howto_type
*
5697 alpha_vms_bfd_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
5703 i
< sizeof (alpha_howto_table
) / sizeof (alpha_howto_table
[0]);
5705 if (alpha_howto_table
[i
].name
!= NULL
5706 && strcasecmp (alpha_howto_table
[i
].name
, r_name
) == 0)
5707 return &alpha_howto_table
[i
];
5713 alpha_vms_get_synthetic_symtab (bfd
*abfd
,
5714 long symcount ATTRIBUTE_UNUSED
,
5715 asymbol
**usyms ATTRIBUTE_UNUSED
,
5716 long dynsymcount ATTRIBUTE_UNUSED
,
5717 asymbol
**dynsyms ATTRIBUTE_UNUSED
,
5724 syms
= (asymbol
*) bfd_malloc (PRIV (norm_sym_count
) * sizeof (asymbol
));
5729 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
5731 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
5742 flags
= BSF_LOCAL
| BSF_SYNTHETIC
;
5749 if ((e
->flags
& EGSY__V_DEF
) && (e
->flags
& EGSY__V_NORM
))
5751 value
= e
->code_value
;
5752 sec
= e
->code_section
;
5763 sname
= bfd_alloc (abfd
, l
+ 5);
5766 memcpy (sname
, name
, l
);
5767 memcpy (sname
+ l
, "..en", 5);
5774 sym
->udata
.p
= NULL
;
5783 vms_time_to_str (unsigned char *buf
)
5785 time_t t
= vms_rawtime_to_time_t (buf
);
5786 char *res
= ctime (&t
);
5789 res
= "*invalid time*";
5796 evax_bfd_print_emh (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5798 struct vms_emh_common
*emh
= (struct vms_emh_common
*)rec
;
5799 unsigned int subtype
;
5802 subtype
= (unsigned) bfd_getl16 (emh
->subtyp
);
5804 /* xgettext:c-format */
5805 fprintf (file
, _(" EMH %u (len=%u): "), subtype
, rec_len
);
5807 /* PR 21618: Check for invalid lengths. */
5808 if (rec_len
< sizeof (* emh
))
5810 fprintf (file
, _(" Error: The length is less than the length of an EMH record\n"));
5813 extra
= rec_len
- sizeof (struct vms_emh_common
);
5819 struct vms_emh_mhd
*mhd
= (struct vms_emh_mhd
*) rec
;
5821 const char * nextname
;
5822 const char * maxname
;
5824 /* PR 21840: Check for invalid lengths. */
5825 if (rec_len
< sizeof (* mhd
))
5827 fprintf (file
, _(" Error: The record length is less than the size of an EMH_MHD record\n"));
5830 fprintf (file
, _("Module header\n"));
5831 fprintf (file
, _(" structure level: %u\n"), mhd
->strlvl
);
5832 fprintf (file
, _(" max record size: %u\n"),
5833 (unsigned) bfd_getl32 (mhd
->recsiz
));
5834 name
= (char *)(mhd
+ 1);
5835 maxname
= (char *) rec
+ rec_len
;
5836 if (name
> maxname
- 2)
5838 fprintf (file
, _(" Error: The module name is missing\n"));
5841 nextname
= name
+ name
[0] + 1;
5842 if (nextname
>= maxname
)
5844 fprintf (file
, _(" Error: The module name is too long\n"));
5847 fprintf (file
, _(" module name : %.*s\n"), name
[0], name
+ 1);
5849 if (name
> maxname
- 2)
5851 fprintf (file
, _(" Error: The module version is missing\n"));
5854 nextname
= name
+ name
[0] + 1;
5855 if (nextname
>= maxname
)
5857 fprintf (file
, _(" Error: The module version is too long\n"));
5860 fprintf (file
, _(" module version : %.*s\n"), name
[0], name
+ 1);
5862 if ((maxname
- name
) < 17 && maxname
[-1] != 0)
5863 fprintf (file
, _(" Error: The compile date is truncated\n"));
5865 fprintf (file
, _(" compile date : %.17s\n"), name
);
5870 fprintf (file
, _("Language Processor Name\n"));
5871 fprintf (file
, _(" language name: %.*s\n"), extra
, (char *)(emh
+ 1));
5875 fprintf (file
, _("Source Files Header\n"));
5876 fprintf (file
, _(" file: %.*s\n"), extra
, (char *)(emh
+ 1));
5880 fprintf (file
, _("Title Text Header\n"));
5881 fprintf (file
, _(" title: %.*s\n"), extra
, (char *)(emh
+ 1));
5885 fprintf (file
, _("Copyright Header\n"));
5886 fprintf (file
, _(" copyright: %.*s\n"), extra
, (char *)(emh
+ 1));
5890 fprintf (file
, _("unhandled emh subtype %u\n"), subtype
);
5896 evax_bfd_print_eeom (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5898 struct vms_eeom
*eeom
= (struct vms_eeom
*)rec
;
5900 fprintf (file
, _(" EEOM (len=%u):\n"), rec_len
);
5902 /* PR 21618: Check for invalid lengths. */
5903 if (rec_len
< sizeof (* eeom
))
5905 fprintf (file
, _(" Error: The length is less than the length of an EEOM record\n"));
5909 fprintf (file
, _(" number of cond linkage pairs: %u\n"),
5910 (unsigned)bfd_getl32 (eeom
->total_lps
));
5911 fprintf (file
, _(" completion code: %u\n"),
5912 (unsigned)bfd_getl16 (eeom
->comcod
));
5915 fprintf (file
, _(" transfer addr flags: 0x%02x\n"), eeom
->tfrflg
);
5916 fprintf (file
, _(" transfer addr psect: %u\n"),
5917 (unsigned)bfd_getl32 (eeom
->psindx
));
5918 fprintf (file
, _(" transfer address : 0x%08x\n"),
5919 (unsigned)bfd_getl32 (eeom
->tfradr
));
5924 exav_bfd_print_egsy_flags (unsigned int flags
, FILE *file
)
5926 if (flags
& EGSY__V_WEAK
)
5927 fputs (_(" WEAK"), file
);
5928 if (flags
& EGSY__V_DEF
)
5929 fputs (_(" DEF"), file
);
5930 if (flags
& EGSY__V_UNI
)
5931 fputs (_(" UNI"), file
);
5932 if (flags
& EGSY__V_REL
)
5933 fputs (_(" REL"), file
);
5934 if (flags
& EGSY__V_COMM
)
5935 fputs (_(" COMM"), file
);
5936 if (flags
& EGSY__V_VECEP
)
5937 fputs (_(" VECEP"), file
);
5938 if (flags
& EGSY__V_NORM
)
5939 fputs (_(" NORM"), file
);
5940 if (flags
& EGSY__V_QUAD_VAL
)
5941 fputs (_(" QVAL"), file
);
5945 evax_bfd_print_egsd_flags (FILE *file
, unsigned int flags
)
5947 if (flags
& EGPS__V_PIC
)
5948 fputs (_(" PIC"), file
);
5949 if (flags
& EGPS__V_LIB
)
5950 fputs (_(" LIB"), file
);
5951 if (flags
& EGPS__V_OVR
)
5952 fputs (_(" OVR"), file
);
5953 if (flags
& EGPS__V_REL
)
5954 fputs (_(" REL"), file
);
5955 if (flags
& EGPS__V_GBL
)
5956 fputs (_(" GBL"), file
);
5957 if (flags
& EGPS__V_SHR
)
5958 fputs (_(" SHR"), file
);
5959 if (flags
& EGPS__V_EXE
)
5960 fputs (_(" EXE"), file
);
5961 if (flags
& EGPS__V_RD
)
5962 fputs (_(" RD"), file
);
5963 if (flags
& EGPS__V_WRT
)
5964 fputs (_(" WRT"), file
);
5965 if (flags
& EGPS__V_VEC
)
5966 fputs (_(" VEC"), file
);
5967 if (flags
& EGPS__V_NOMOD
)
5968 fputs (_(" NOMOD"), file
);
5969 if (flags
& EGPS__V_COM
)
5970 fputs (_(" COM"), file
);
5971 if (flags
& EGPS__V_ALLOC_64BIT
)
5972 fputs (_(" 64B"), file
);
5976 evax_bfd_print_egsd (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5978 unsigned int off
= sizeof (struct vms_egsd
);
5981 fprintf (file
, _(" EGSD (len=%u):\n"), rec_len
);
5984 for (off
= sizeof (struct vms_egsd
); off
< rec_len
; )
5986 struct vms_egsd_entry
*e
= (struct vms_egsd_entry
*)(rec
+ off
);
5990 type
= (unsigned)bfd_getl16 (e
->gsdtyp
);
5991 len
= (unsigned)bfd_getl16 (e
->gsdsiz
);
5993 /* xgettext:c-format */
5994 fprintf (file
, _(" EGSD entry %2u (type: %u, len: %u): "),
5998 if (off
+ len
> rec_len
|| off
+ len
< off
)
6000 fprintf (file
, _(" Error: length larger than remaining space in record\n"));
6008 struct vms_egps
*egps
= (struct vms_egps
*)e
;
6009 unsigned int flags
= bfd_getl16 (egps
->flags
);
6012 fprintf (file
, _("PSC - Program section definition\n"));
6013 fprintf (file
, _(" alignment : 2**%u\n"), egps
->align
);
6014 fprintf (file
, _(" flags : 0x%04x"), flags
);
6015 evax_bfd_print_egsd_flags (file
, flags
);
6017 l
= bfd_getl32 (egps
->alloc
);
6018 fprintf (file
, _(" alloc (len): %u (0x%08x)\n"), l
, l
);
6019 fprintf (file
, _(" name : %.*s\n"),
6020 egps
->namlng
, egps
->name
);
6025 struct vms_esgps
*esgps
= (struct vms_esgps
*)e
;
6026 unsigned int flags
= bfd_getl16 (esgps
->flags
);
6029 fprintf (file
, _("SPSC - Shared Image Program section def\n"));
6030 fprintf (file
, _(" alignment : 2**%u\n"), esgps
->align
);
6031 fprintf (file
, _(" flags : 0x%04x"), flags
);
6032 evax_bfd_print_egsd_flags (file
, flags
);
6034 l
= bfd_getl32 (esgps
->alloc
);
6035 fprintf (file
, _(" alloc (len) : %u (0x%08x)\n"), l
, l
);
6036 fprintf (file
, _(" image offset : 0x%08x\n"),
6037 (unsigned int)bfd_getl32 (esgps
->base
));
6038 fprintf (file
, _(" symvec offset : 0x%08x\n"),
6039 (unsigned int)bfd_getl32 (esgps
->value
));
6040 fprintf (file
, _(" name : %.*s\n"),
6041 esgps
->namlng
, esgps
->name
);
6046 struct vms_egsy
*egsy
= (struct vms_egsy
*)e
;
6047 unsigned int flags
= bfd_getl16 (egsy
->flags
);
6049 if (flags
& EGSY__V_DEF
)
6051 struct vms_esdf
*esdf
= (struct vms_esdf
*)e
;
6053 fprintf (file
, _("SYM - Global symbol definition\n"));
6054 fprintf (file
, _(" flags: 0x%04x"), flags
);
6055 exav_bfd_print_egsy_flags (flags
, file
);
6057 fprintf (file
, _(" psect offset: 0x%08x\n"),
6058 (unsigned)bfd_getl32 (esdf
->value
));
6059 if (flags
& EGSY__V_NORM
)
6061 fprintf (file
, _(" code address: 0x%08x\n"),
6062 (unsigned)bfd_getl32 (esdf
->code_address
));
6063 fprintf (file
, _(" psect index for entry point : %u\n"),
6064 (unsigned)bfd_getl32 (esdf
->ca_psindx
));
6066 fprintf (file
, _(" psect index : %u\n"),
6067 (unsigned)bfd_getl32 (esdf
->psindx
));
6068 fprintf (file
, _(" name : %.*s\n"),
6069 esdf
->namlng
, esdf
->name
);
6073 struct vms_esrf
*esrf
= (struct vms_esrf
*)e
;
6075 fprintf (file
, _("SYM - Global symbol reference\n"));
6076 fprintf (file
, _(" name : %.*s\n"),
6077 esrf
->namlng
, esrf
->name
);
6083 struct vms_eidc
*eidc
= (struct vms_eidc
*)e
;
6084 unsigned int flags
= bfd_getl32 (eidc
->flags
);
6087 fprintf (file
, _("IDC - Ident Consistency check\n"));
6088 fprintf (file
, _(" flags : 0x%08x"), flags
);
6089 if (flags
& EIDC__V_BINIDENT
)
6090 fputs (" BINDENT", file
);
6092 fprintf (file
, _(" id match : %x\n"),
6093 (flags
>> EIDC__V_IDMATCH_SH
) & EIDC__V_IDMATCH_MASK
);
6094 fprintf (file
, _(" error severity: %x\n"),
6095 (flags
>> EIDC__V_ERRSEV_SH
) & EIDC__V_ERRSEV_MASK
);
6097 fprintf (file
, _(" entity name : %.*s\n"), p
[0], p
+ 1);
6099 fprintf (file
, _(" object name : %.*s\n"), p
[0], p
+ 1);
6101 if (flags
& EIDC__V_BINIDENT
)
6102 fprintf (file
, _(" binary ident : 0x%08x\n"),
6103 (unsigned)bfd_getl32 (p
+ 1));
6105 fprintf (file
, _(" ascii ident : %.*s\n"), p
[0], p
+ 1);
6110 struct vms_egst
*egst
= (struct vms_egst
*)e
;
6111 unsigned int flags
= bfd_getl16 (egst
->header
.flags
);
6113 fprintf (file
, _("SYMG - Universal symbol definition\n"));
6114 fprintf (file
, _(" flags: 0x%04x"), flags
);
6115 exav_bfd_print_egsy_flags (flags
, file
);
6117 fprintf (file
, _(" symbol vector offset: 0x%08x\n"),
6118 (unsigned)bfd_getl32 (egst
->value
));
6119 fprintf (file
, _(" entry point: 0x%08x\n"),
6120 (unsigned)bfd_getl32 (egst
->lp_1
));
6121 fprintf (file
, _(" proc descr : 0x%08x\n"),
6122 (unsigned)bfd_getl32 (egst
->lp_2
));
6123 fprintf (file
, _(" psect index: %u\n"),
6124 (unsigned)bfd_getl32 (egst
->psindx
));
6125 fprintf (file
, _(" name : %.*s\n"),
6126 egst
->namlng
, egst
->name
);
6131 struct vms_esdfv
*esdfv
= (struct vms_esdfv
*)e
;
6132 unsigned int flags
= bfd_getl16 (esdfv
->flags
);
6134 fprintf (file
, _("SYMV - Vectored symbol definition\n"));
6135 fprintf (file
, _(" flags: 0x%04x"), flags
);
6136 exav_bfd_print_egsy_flags (flags
, file
);
6138 fprintf (file
, _(" vector : 0x%08x\n"),
6139 (unsigned)bfd_getl32 (esdfv
->vector
));
6140 fprintf (file
, _(" psect offset: %u\n"),
6141 (unsigned)bfd_getl32 (esdfv
->value
));
6142 fprintf (file
, _(" psect index : %u\n"),
6143 (unsigned)bfd_getl32 (esdfv
->psindx
));
6144 fprintf (file
, _(" name : %.*s\n"),
6145 esdfv
->namlng
, esdfv
->name
);
6150 struct vms_esdfm
*esdfm
= (struct vms_esdfm
*)e
;
6151 unsigned int flags
= bfd_getl16 (esdfm
->flags
);
6153 fprintf (file
, _("SYMM - Global symbol definition with version\n"));
6154 fprintf (file
, _(" flags: 0x%04x"), flags
);
6155 exav_bfd_print_egsy_flags (flags
, file
);
6157 fprintf (file
, _(" version mask: 0x%08x\n"),
6158 (unsigned)bfd_getl32 (esdfm
->version_mask
));
6159 fprintf (file
, _(" psect offset: %u\n"),
6160 (unsigned)bfd_getl32 (esdfm
->value
));
6161 fprintf (file
, _(" psect index : %u\n"),
6162 (unsigned)bfd_getl32 (esdfm
->psindx
));
6163 fprintf (file
, _(" name : %.*s\n"),
6164 esdfm
->namlng
, esdfm
->name
);
6168 fprintf (file
, _("unhandled egsd entry type %u\n"), type
);
6176 evax_bfd_print_hex (FILE *file
, const char *pfx
,
6177 const unsigned char *buf
, unsigned int len
)
6183 for (i
= 0; i
< len
; i
++)
6187 fprintf (file
, " %02x", buf
[i
]);
6200 evax_bfd_print_etir_stc_ir (FILE *file
, const unsigned char *buf
, int is_ps
)
6202 /* xgettext:c-format */
6203 fprintf (file
, _(" linkage index: %u, replacement insn: 0x%08x\n"),
6204 (unsigned)bfd_getl32 (buf
),
6205 (unsigned)bfd_getl32 (buf
+ 16));
6206 /* xgettext:c-format */
6207 fprintf (file
, _(" psect idx 1: %u, offset 1: 0x%08x %08x\n"),
6208 (unsigned)bfd_getl32 (buf
+ 4),
6209 (unsigned)bfd_getl32 (buf
+ 12),
6210 (unsigned)bfd_getl32 (buf
+ 8));
6211 /* xgettext:c-format */
6212 fprintf (file
, _(" psect idx 2: %u, offset 2: 0x%08x %08x\n"),
6213 (unsigned)bfd_getl32 (buf
+ 20),
6214 (unsigned)bfd_getl32 (buf
+ 28),
6215 (unsigned)bfd_getl32 (buf
+ 24));
6217 /* xgettext:c-format */
6218 fprintf (file
, _(" psect idx 3: %u, offset 3: 0x%08x %08x\n"),
6219 (unsigned)bfd_getl32 (buf
+ 32),
6220 (unsigned)bfd_getl32 (buf
+ 40),
6221 (unsigned)bfd_getl32 (buf
+ 36));
6223 fprintf (file
, _(" global name: %.*s\n"), buf
[32], buf
+ 33);
6227 evax_bfd_print_etir (FILE *file
, const char *name
,
6228 unsigned char *rec
, unsigned int rec_len
)
6230 unsigned int off
= sizeof (struct vms_egsd
);
6231 unsigned int sec_len
= 0;
6233 /* xgettext:c-format */
6234 fprintf (file
, _(" %s (len=%u+%u):\n"), name
,
6235 (unsigned)(rec_len
- sizeof (struct vms_eobjrec
)),
6236 (unsigned)sizeof (struct vms_eobjrec
));
6238 for (off
= sizeof (struct vms_eobjrec
); off
< rec_len
; )
6240 struct vms_etir
*etir
= (struct vms_etir
*)(rec
+ off
);
6245 type
= bfd_getl16 (etir
->rectyp
);
6246 size
= bfd_getl16 (etir
->size
);
6247 buf
= rec
+ off
+ sizeof (struct vms_etir
);
6249 if (off
+ size
> rec_len
|| off
+ size
< off
)
6251 fprintf (file
, _(" Error: length larger than remaining space in record\n"));
6255 /* xgettext:c-format */
6256 fprintf (file
, _(" (type: %3u, size: 4+%3u): "), type
, size
- 4);
6259 case ETIR__C_STA_GBL
:
6260 fprintf (file
, _("STA_GBL (stack global) %.*s\n"),
6263 case ETIR__C_STA_LW
:
6264 fprintf (file
, _("STA_LW (stack longword) 0x%08x\n"),
6265 (unsigned)bfd_getl32 (buf
));
6267 case ETIR__C_STA_QW
:
6268 fprintf (file
, _("STA_QW (stack quadword) 0x%08x %08x\n"),
6269 (unsigned)bfd_getl32 (buf
+ 4),
6270 (unsigned)bfd_getl32 (buf
+ 0));
6272 case ETIR__C_STA_PQ
:
6273 fprintf (file
, _("STA_PQ (stack psect base + offset)\n"));
6274 /* xgettext:c-format */
6275 fprintf (file
, _(" psect: %u, offset: 0x%08x %08x\n"),
6276 (unsigned)bfd_getl32 (buf
+ 0),
6277 (unsigned)bfd_getl32 (buf
+ 8),
6278 (unsigned)bfd_getl32 (buf
+ 4));
6280 case ETIR__C_STA_LI
:
6281 fprintf (file
, _("STA_LI (stack literal)\n"));
6283 case ETIR__C_STA_MOD
:
6284 fprintf (file
, _("STA_MOD (stack module)\n"));
6286 case ETIR__C_STA_CKARG
:
6287 fprintf (file
, _("STA_CKARG (compare procedure argument)\n"));
6291 fprintf (file
, _("STO_B (store byte)\n"));
6294 fprintf (file
, _("STO_W (store word)\n"));
6296 case ETIR__C_STO_LW
:
6297 fprintf (file
, _("STO_LW (store longword)\n"));
6299 case ETIR__C_STO_QW
:
6300 fprintf (file
, _("STO_QW (store quadword)\n"));
6302 case ETIR__C_STO_IMMR
:
6304 unsigned int len
= bfd_getl32 (buf
);
6306 _("STO_IMMR (store immediate repeat) %u bytes\n"),
6308 evax_bfd_print_hex (file
, " ", buf
+ 4, len
);
6312 case ETIR__C_STO_GBL
:
6313 fprintf (file
, _("STO_GBL (store global) %.*s\n"),
6316 case ETIR__C_STO_CA
:
6317 fprintf (file
, _("STO_CA (store code address) %.*s\n"),
6320 case ETIR__C_STO_RB
:
6321 fprintf (file
, _("STO_RB (store relative branch)\n"));
6323 case ETIR__C_STO_AB
:
6324 fprintf (file
, _("STO_AB (store absolute branch)\n"));
6326 case ETIR__C_STO_OFF
:
6327 fprintf (file
, _("STO_OFF (store offset to psect)\n"));
6329 case ETIR__C_STO_IMM
:
6331 unsigned int len
= bfd_getl32 (buf
);
6333 _("STO_IMM (store immediate) %u bytes\n"),
6335 evax_bfd_print_hex (file
, " ", buf
+ 4, len
);
6339 case ETIR__C_STO_GBL_LW
:
6340 fprintf (file
, _("STO_GBL_LW (store global longword) %.*s\n"),
6343 case ETIR__C_STO_LP_PSB
:
6344 fprintf (file
, _("STO_OFF (store LP with procedure signature)\n"));
6346 case ETIR__C_STO_HINT_GBL
:
6347 fprintf (file
, _("STO_BR_GBL (store branch global) *todo*\n"));
6349 case ETIR__C_STO_HINT_PS
:
6350 fprintf (file
, _("STO_BR_PS (store branch psect + offset) *todo*\n"));
6353 case ETIR__C_OPR_NOP
:
6354 fprintf (file
, _("OPR_NOP (no-operation)\n"));
6356 case ETIR__C_OPR_ADD
:
6357 fprintf (file
, _("OPR_ADD (add)\n"));
6359 case ETIR__C_OPR_SUB
:
6360 fprintf (file
, _("OPR_SUB (subtract)\n"));
6362 case ETIR__C_OPR_MUL
:
6363 fprintf (file
, _("OPR_MUL (multiply)\n"));
6365 case ETIR__C_OPR_DIV
:
6366 fprintf (file
, _("OPR_DIV (divide)\n"));
6368 case ETIR__C_OPR_AND
:
6369 fprintf (file
, _("OPR_AND (logical and)\n"));
6371 case ETIR__C_OPR_IOR
:
6372 fprintf (file
, _("OPR_IOR (logical inclusive or)\n"));
6374 case ETIR__C_OPR_EOR
:
6375 fprintf (file
, _("OPR_EOR (logical exclusive or)\n"));
6377 case ETIR__C_OPR_NEG
:
6378 fprintf (file
, _("OPR_NEG (negate)\n"));
6380 case ETIR__C_OPR_COM
:
6381 fprintf (file
, _("OPR_COM (complement)\n"));
6383 case ETIR__C_OPR_INSV
:
6384 fprintf (file
, _("OPR_INSV (insert field)\n"));
6386 case ETIR__C_OPR_ASH
:
6387 fprintf (file
, _("OPR_ASH (arithmetic shift)\n"));
6389 case ETIR__C_OPR_USH
:
6390 fprintf (file
, _("OPR_USH (unsigned shift)\n"));
6392 case ETIR__C_OPR_ROT
:
6393 fprintf (file
, _("OPR_ROT (rotate)\n"));
6395 case ETIR__C_OPR_SEL
:
6396 fprintf (file
, _("OPR_SEL (select)\n"));
6398 case ETIR__C_OPR_REDEF
:
6399 fprintf (file
, _("OPR_REDEF (redefine symbol to curr location)\n"));
6401 case ETIR__C_OPR_DFLIT
:
6402 fprintf (file
, _("OPR_REDEF (define a literal)\n"));
6405 case ETIR__C_STC_LP
:
6406 fprintf (file
, _("STC_LP (store cond linkage pair)\n"));
6408 case ETIR__C_STC_LP_PSB
:
6410 _("STC_LP_PSB (store cond linkage pair + signature)\n"));
6411 /* xgettext:c-format */
6412 fprintf (file
, _(" linkage index: %u, procedure: %.*s\n"),
6413 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6414 buf
+= 4 + 1 + buf
[4];
6415 fprintf (file
, _(" signature: %.*s\n"), buf
[0], buf
+ 1);
6417 case ETIR__C_STC_GBL
:
6418 fprintf (file
, _("STC_GBL (store cond global)\n"));
6419 /* xgettext:c-format */
6420 fprintf (file
, _(" linkage index: %u, global: %.*s\n"),
6421 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6423 case ETIR__C_STC_GCA
:
6424 fprintf (file
, _("STC_GCA (store cond code address)\n"));
6425 /* xgettext:c-format */
6426 fprintf (file
, _(" linkage index: %u, procedure name: %.*s\n"),
6427 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6429 case ETIR__C_STC_PS
:
6430 fprintf (file
, _("STC_PS (store cond psect + offset)\n"));
6432 /* xgettext:c-format */
6433 _(" linkage index: %u, psect: %u, offset: 0x%08x %08x\n"),
6434 (unsigned)bfd_getl32 (buf
),
6435 (unsigned)bfd_getl32 (buf
+ 4),
6436 (unsigned)bfd_getl32 (buf
+ 12),
6437 (unsigned)bfd_getl32 (buf
+ 8));
6439 case ETIR__C_STC_NOP_GBL
:
6440 fprintf (file
, _("STC_NOP_GBL (store cond NOP at global addr)\n"));
6441 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6443 case ETIR__C_STC_NOP_PS
:
6444 fprintf (file
, _("STC_NOP_PS (store cond NOP at psect + offset)\n"));
6445 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6447 case ETIR__C_STC_BSR_GBL
:
6448 fprintf (file
, _("STC_BSR_GBL (store cond BSR at global addr)\n"));
6449 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6451 case ETIR__C_STC_BSR_PS
:
6452 fprintf (file
, _("STC_BSR_PS (store cond BSR at psect + offset)\n"));
6453 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6455 case ETIR__C_STC_LDA_GBL
:
6456 fprintf (file
, _("STC_LDA_GBL (store cond LDA at global addr)\n"));
6457 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6459 case ETIR__C_STC_LDA_PS
:
6460 fprintf (file
, _("STC_LDA_PS (store cond LDA at psect + offset)\n"));
6461 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6463 case ETIR__C_STC_BOH_GBL
:
6464 fprintf (file
, _("STC_BOH_GBL (store cond BOH at global addr)\n"));
6465 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6467 case ETIR__C_STC_BOH_PS
:
6468 fprintf (file
, _("STC_BOH_PS (store cond BOH at psect + offset)\n"));
6469 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6471 case ETIR__C_STC_NBH_GBL
:
6473 _("STC_NBH_GBL (store cond or hint at global addr)\n"));
6475 case ETIR__C_STC_NBH_PS
:
6477 _("STC_NBH_PS (store cond or hint at psect + offset)\n"));
6480 case ETIR__C_CTL_SETRB
:
6481 fprintf (file
, _("CTL_SETRB (set relocation base)\n"));
6484 case ETIR__C_CTL_AUGRB
:
6486 unsigned int val
= bfd_getl32 (buf
);
6487 fprintf (file
, _("CTL_AUGRB (augment relocation base) %u\n"), val
);
6490 case ETIR__C_CTL_DFLOC
:
6491 fprintf (file
, _("CTL_DFLOC (define location)\n"));
6493 case ETIR__C_CTL_STLOC
:
6494 fprintf (file
, _("CTL_STLOC (set location)\n"));
6496 case ETIR__C_CTL_STKDL
:
6497 fprintf (file
, _("CTL_STKDL (stack defined location)\n"));
6500 fprintf (file
, _("*unhandled*\n"));
6508 evax_bfd_print_eobj (struct bfd
*abfd
, FILE *file
)
6510 bfd_boolean is_first
= TRUE
;
6511 bfd_boolean has_records
= FALSE
;
6515 unsigned int rec_len
;
6516 unsigned int pad_len
;
6518 unsigned int hdr_size
;
6523 unsigned char buf
[6];
6528 if (bfd_bread (buf
, sizeof (buf
), abfd
) != sizeof (buf
))
6530 fprintf (file
, _("cannot read GST record length\n"));
6533 rec_len
= bfd_getl16 (buf
+ 0);
6534 if (rec_len
== bfd_getl16 (buf
+ 4)
6535 && bfd_getl16 (buf
+ 2) == EOBJ__C_EMH
)
6537 /* The format is raw: record-size, type, record-size. */
6539 pad_len
= (rec_len
+ 1) & ~1U;
6542 else if (rec_len
== EOBJ__C_EMH
)
6544 has_records
= FALSE
;
6545 pad_len
= bfd_getl16 (buf
+ 2);
6551 fprintf (file
, _("cannot find EMH in first GST record\n"));
6554 rec
= bfd_malloc (pad_len
);
6555 memcpy (rec
, buf
+ sizeof (buf
) - hdr_size
, hdr_size
);
6559 unsigned int rec_len2
= 0;
6560 unsigned char hdr
[4];
6564 unsigned char buf_len
[2];
6566 if (bfd_bread (buf_len
, sizeof (buf_len
), abfd
)
6567 != sizeof (buf_len
))
6569 fprintf (file
, _("cannot read GST record length\n"));
6572 rec_len2
= (unsigned)bfd_getl16 (buf_len
);
6575 if (bfd_bread (hdr
, sizeof (hdr
), abfd
) != sizeof (hdr
))
6577 fprintf (file
, _("cannot read GST record header\n"));
6580 rec_len
= (unsigned)bfd_getl16 (hdr
+ 2);
6582 pad_len
= (rec_len
+ 1) & ~1U;
6585 rec
= bfd_malloc (pad_len
);
6586 memcpy (rec
, hdr
, sizeof (hdr
));
6587 hdr_size
= sizeof (hdr
);
6588 if (has_records
&& rec_len2
!= rec_len
)
6590 fprintf (file
, _(" corrupted GST\n"));
6595 if (bfd_bread (rec
+ hdr_size
, pad_len
- hdr_size
, abfd
)
6596 != pad_len
- hdr_size
)
6598 fprintf (file
, _("cannot read GST record\n"));
6602 type
= (unsigned)bfd_getl16 (rec
);
6607 evax_bfd_print_emh (file
, rec
, rec_len
);
6610 evax_bfd_print_egsd (file
, rec
, rec_len
);
6613 evax_bfd_print_eeom (file
, rec
, rec_len
);
6618 evax_bfd_print_etir (file
, "ETIR", rec
, rec_len
);
6621 evax_bfd_print_etir (file
, "EDBG", rec
, rec_len
);
6624 evax_bfd_print_etir (file
, "ETBT", rec
, rec_len
);
6627 fprintf (file
, _(" unhandled EOBJ record type %u\n"), type
);
6635 evax_bfd_print_relocation_records (FILE *file
, const unsigned char *rel
,
6636 unsigned int stride
)
6644 count
= bfd_getl32 (rel
+ 0);
6648 base
= bfd_getl32 (rel
+ 4);
6650 /* xgettext:c-format */
6651 fprintf (file
, _(" bitcount: %u, base addr: 0x%08x\n"),
6655 for (j
= 0; count
> 0; j
+= 4, count
-= 32)
6661 val
= bfd_getl32 (rel
);
6664 /* xgettext:c-format */
6665 fprintf (file
, _(" bitmap: 0x%08x (count: %u):\n"), val
, count
);
6667 for (k
= 0; k
< 32; k
++)
6668 if (val
& (1u << k
))
6672 fprintf (file
, _(" %08x"), base
+ (j
* 8 + k
) * stride
);
6687 evax_bfd_print_address_fixups (FILE *file
, const unsigned char *rel
)
6694 count
= bfd_getl32 (rel
+ 0);
6697 /* xgettext:c-format */
6698 fprintf (file
, _(" image %u (%u entries)\n"),
6699 (unsigned)bfd_getl32 (rel
+ 4), count
);
6701 for (j
= 0; j
< count
; j
++)
6703 /* xgettext:c-format */
6704 fprintf (file
, _(" offset: 0x%08x, val: 0x%08x\n"),
6705 (unsigned)bfd_getl32 (rel
+ 0),
6706 (unsigned)bfd_getl32 (rel
+ 4));
6713 evax_bfd_print_reference_fixups (FILE *file
, const unsigned char *rel
)
6722 count
= bfd_getl32 (rel
+ 0);
6725 /* xgettext:c-format */
6726 fprintf (file
, _(" image %u (%u entries), offsets:\n"),
6727 (unsigned)bfd_getl32 (rel
+ 4), count
);
6729 for (j
= 0; j
< count
; j
++)
6733 fprintf (file
, _(" 0x%08x"), (unsigned)bfd_getl32 (rel
));
6748 evax_bfd_print_indent (int indent
, FILE *file
)
6750 for (; indent
; indent
--)
6755 evax_bfd_get_dsc_name (unsigned int v
)
6759 case DSC__K_DTYPE_Z
:
6760 return "Z (Unspecified)";
6761 case DSC__K_DTYPE_V
:
6763 case DSC__K_DTYPE_BU
:
6764 return "BU (Byte logical)";
6765 case DSC__K_DTYPE_WU
:
6766 return "WU (Word logical)";
6767 case DSC__K_DTYPE_LU
:
6768 return "LU (Longword logical)";
6769 case DSC__K_DTYPE_QU
:
6770 return "QU (Quadword logical)";
6771 case DSC__K_DTYPE_B
:
6772 return "B (Byte integer)";
6773 case DSC__K_DTYPE_W
:
6774 return "W (Word integer)";
6775 case DSC__K_DTYPE_L
:
6776 return "L (Longword integer)";
6777 case DSC__K_DTYPE_Q
:
6778 return "Q (Quadword integer)";
6779 case DSC__K_DTYPE_F
:
6780 return "F (Single-precision floating)";
6781 case DSC__K_DTYPE_D
:
6782 return "D (Double-precision floating)";
6783 case DSC__K_DTYPE_FC
:
6784 return "FC (Complex)";
6785 case DSC__K_DTYPE_DC
:
6786 return "DC (Double-precision Complex)";
6787 case DSC__K_DTYPE_T
:
6788 return "T (ASCII text string)";
6789 case DSC__K_DTYPE_NU
:
6790 return "NU (Numeric string, unsigned)";
6791 case DSC__K_DTYPE_NL
:
6792 return "NL (Numeric string, left separate sign)";
6793 case DSC__K_DTYPE_NLO
:
6794 return "NLO (Numeric string, left overpunched sign)";
6795 case DSC__K_DTYPE_NR
:
6796 return "NR (Numeric string, right separate sign)";
6797 case DSC__K_DTYPE_NRO
:
6798 return "NRO (Numeric string, right overpunched sig)";
6799 case DSC__K_DTYPE_NZ
:
6800 return "NZ (Numeric string, zoned sign)";
6801 case DSC__K_DTYPE_P
:
6802 return "P (Packed decimal string)";
6803 case DSC__K_DTYPE_ZI
:
6804 return "ZI (Sequence of instructions)";
6805 case DSC__K_DTYPE_ZEM
:
6806 return "ZEM (Procedure entry mask)";
6807 case DSC__K_DTYPE_DSC
:
6808 return "DSC (Descriptor, used for arrays of dyn strings)";
6809 case DSC__K_DTYPE_OU
:
6810 return "OU (Octaword logical)";
6811 case DSC__K_DTYPE_O
:
6812 return "O (Octaword integer)";
6813 case DSC__K_DTYPE_G
:
6814 return "G (Double precision G floating, 64 bit)";
6815 case DSC__K_DTYPE_H
:
6816 return "H (Quadruple precision floating, 128 bit)";
6817 case DSC__K_DTYPE_GC
:
6818 return "GC (Double precision complex, G floating)";
6819 case DSC__K_DTYPE_HC
:
6820 return "HC (Quadruple precision complex, H floating)";
6821 case DSC__K_DTYPE_CIT
:
6822 return "CIT (COBOL intermediate temporary)";
6823 case DSC__K_DTYPE_BPV
:
6824 return "BPV (Bound Procedure Value)";
6825 case DSC__K_DTYPE_BLV
:
6826 return "BLV (Bound Label Value)";
6827 case DSC__K_DTYPE_VU
:
6828 return "VU (Bit Unaligned)";
6829 case DSC__K_DTYPE_ADT
:
6830 return "ADT (Absolute Date-Time)";
6831 case DSC__K_DTYPE_VT
:
6832 return "VT (Varying Text)";
6833 case DSC__K_DTYPE_T2
:
6834 return "T2 (16-bit char)";
6835 case DSC__K_DTYPE_VT2
:
6836 return "VT2 (16-bit varying char)";
6838 return "?? (unknown)";
6843 evax_bfd_print_desc (const unsigned char *buf
, int indent
, FILE *file
)
6845 unsigned char bclass
= buf
[3];
6846 unsigned char dtype
= buf
[2];
6847 unsigned int len
= (unsigned)bfd_getl16 (buf
);
6848 unsigned int pointer
= (unsigned)bfd_getl32 (buf
+ 4);
6850 evax_bfd_print_indent (indent
, file
);
6852 if (len
== 1 && pointer
== 0xffffffffUL
)
6855 fprintf (file
, _("64 bits *unhandled*\n"));
6859 /* xgettext:c-format */
6860 fprintf (file
, _("class: %u, dtype: %u, length: %u, pointer: 0x%08x\n"),
6861 bclass
, dtype
, len
, pointer
);
6864 case DSC__K_CLASS_NCA
:
6866 const struct vms_dsc_nca
*dsc
= (const void *)buf
;
6868 const unsigned char *b
;
6870 evax_bfd_print_indent (indent
, file
);
6871 fprintf (file
, _("non-contiguous array of %s\n"),
6872 evax_bfd_get_dsc_name (dsc
->dtype
));
6873 evax_bfd_print_indent (indent
+ 1, file
);
6875 /* xgettext:c-format */
6876 _("dimct: %u, aflags: 0x%02x, digits: %u, scale: %u\n"),
6877 dsc
->dimct
, dsc
->aflags
, dsc
->digits
, dsc
->scale
);
6878 evax_bfd_print_indent (indent
+ 1, file
);
6880 /* xgettext:c-format */
6881 _("arsize: %u, a0: 0x%08x\n"),
6882 (unsigned)bfd_getl32 (dsc
->arsize
),
6883 (unsigned)bfd_getl32 (dsc
->a0
));
6884 evax_bfd_print_indent (indent
+ 1, file
);
6885 fprintf (file
, _("Strides:\n"));
6886 b
= buf
+ sizeof (*dsc
);
6887 for (i
= 0; i
< dsc
->dimct
; i
++)
6889 evax_bfd_print_indent (indent
+ 2, file
);
6890 fprintf (file
, "[%u]: %u\n", i
+ 1,
6891 (unsigned)bfd_getl32 (b
));
6894 evax_bfd_print_indent (indent
+ 1, file
);
6895 fprintf (file
, _("Bounds:\n"));
6896 b
= buf
+ sizeof (*dsc
);
6897 for (i
= 0; i
< dsc
->dimct
; i
++)
6899 evax_bfd_print_indent (indent
+ 2, file
);
6900 /* xgettext:c-format */
6901 fprintf (file
, _("[%u]: Lower: %u, upper: %u\n"), i
+ 1,
6902 (unsigned)bfd_getl32 (b
+ 0),
6903 (unsigned)bfd_getl32 (b
+ 4));
6908 case DSC__K_CLASS_UBS
:
6910 const struct vms_dsc_ubs
*ubs
= (const void *)buf
;
6912 evax_bfd_print_indent (indent
, file
);
6913 fprintf (file
, _("unaligned bit-string of %s\n"),
6914 evax_bfd_get_dsc_name (ubs
->dtype
));
6915 evax_bfd_print_indent (indent
+ 1, file
);
6917 /* xgettext:c-format */
6918 _("base: %u, pos: %u\n"),
6919 (unsigned)bfd_getl32 (ubs
->base
),
6920 (unsigned)bfd_getl32 (ubs
->pos
));
6924 fprintf (file
, _("*unhandled*\n"));
6931 evax_bfd_print_valspec (const unsigned char *buf
, int indent
, FILE *file
)
6933 unsigned int vflags
= buf
[0];
6934 unsigned int value
= (unsigned)bfd_getl32 (buf
+ 1);
6935 unsigned int len
= 5;
6937 evax_bfd_print_indent (indent
, file
);
6938 /* xgettext:c-format */
6939 fprintf (file
, _("vflags: 0x%02x, value: 0x%08x "), vflags
, value
);
6944 case DST__K_VFLAGS_NOVAL
:
6945 fprintf (file
, _("(no value)\n"));
6947 case DST__K_VFLAGS_NOTACTIVE
:
6948 fprintf (file
, _("(not active)\n"));
6950 case DST__K_VFLAGS_UNALLOC
:
6951 fprintf (file
, _("(not allocated)\n"));
6953 case DST__K_VFLAGS_DSC
:
6954 fprintf (file
, _("(descriptor)\n"));
6955 evax_bfd_print_desc (buf
+ value
, indent
+ 1, file
);
6957 case DST__K_VFLAGS_TVS
:
6958 fprintf (file
, _("(trailing value)\n"));
6960 case DST__K_VS_FOLLOWS
:
6961 fprintf (file
, _("(value spec follows)\n"));
6963 case DST__K_VFLAGS_BITOFFS
:
6964 fprintf (file
, _("(at bit offset %u)\n"), value
);
6967 /* xgettext:c-format */
6968 fprintf (file
, _("(reg: %u, disp: %u, indir: %u, kind: "),
6969 (vflags
& DST__K_REGNUM_MASK
) >> DST__K_REGNUM_SHIFT
,
6970 vflags
& DST__K_DISP
? 1 : 0,
6971 vflags
& DST__K_INDIR
? 1 : 0);
6972 switch (vflags
& DST__K_VALKIND_MASK
)
6974 case DST__K_VALKIND_LITERAL
:
6975 fputs (_("literal"), file
);
6977 case DST__K_VALKIND_ADDR
:
6978 fputs (_("address"), file
);
6980 case DST__K_VALKIND_DESC
:
6981 fputs (_("desc"), file
);
6983 case DST__K_VALKIND_REG
:
6984 fputs (_("reg"), file
);
6987 fputs (")\n", file
);
6994 evax_bfd_print_typspec (const unsigned char *buf
, int indent
, FILE *file
)
6996 unsigned char kind
= buf
[2];
6997 unsigned int len
= (unsigned)bfd_getl16 (buf
);
6999 evax_bfd_print_indent (indent
, file
);
7000 /* xgettext:c-format */
7001 fprintf (file
, _("len: %2u, kind: %2u "), len
, kind
);
7005 case DST__K_TS_ATOM
:
7006 /* xgettext:c-format */
7007 fprintf (file
, _("atomic, type=0x%02x %s\n"),
7008 buf
[0], evax_bfd_get_dsc_name (buf
[0]));
7011 fprintf (file
, _("indirect, defined at 0x%08x\n"),
7012 (unsigned)bfd_getl32 (buf
));
7014 case DST__K_TS_TPTR
:
7015 fprintf (file
, _("typed pointer\n"));
7016 evax_bfd_print_typspec (buf
, indent
+ 1, file
);
7019 fprintf (file
, _("pointer\n"));
7021 case DST__K_TS_ARRAY
:
7023 const unsigned char *vs
;
7024 unsigned int vec_len
;
7027 fprintf (file
, _("array, dim: %u, bitmap: "), buf
[0]);
7028 vec_len
= (buf
[0] + 1 + 7) / 8;
7029 for (i
= 0; i
< vec_len
; i
++)
7030 fprintf (file
, " %02x", buf
[i
+ 1]);
7032 vs
= buf
+ 1 + vec_len
;
7033 evax_bfd_print_indent (indent
, file
);
7034 fprintf (file
, _("array descriptor:\n"));
7035 vs
+= evax_bfd_print_valspec (vs
, indent
+ 1, file
);
7036 for (i
= 0; i
< buf
[0] + 1U; i
++)
7037 if (buf
[1 + i
/ 8] & (1 << (i
% 8)))
7039 evax_bfd_print_indent (indent
, file
);
7041 fprintf (file
, _("type spec for element:\n"));
7043 fprintf (file
, _("type spec for subscript %u:\n"), i
);
7044 evax_bfd_print_typspec (vs
, indent
+ 1, file
);
7045 vs
+= bfd_getl16 (vs
);
7050 fprintf (file
, _("*unhandled*\n"));
7055 evax_bfd_print_dst (struct bfd
*abfd
, unsigned int dst_size
, FILE *file
)
7057 unsigned int off
= 0;
7058 unsigned int pc
= 0;
7059 unsigned int line
= 0;
7061 fprintf (file
, _("Debug symbol table:\n"));
7063 while (dst_size
> 0)
7065 struct vms_dst_header dsth
;
7070 if (bfd_bread (&dsth
, sizeof (dsth
), abfd
) != sizeof (dsth
))
7072 fprintf (file
, _("cannot read DST header\n"));
7075 len
= bfd_getl16 (dsth
.length
);
7076 type
= bfd_getl16 (dsth
.type
);
7077 /* xgettext:c-format */
7078 fprintf (file
, _(" type: %3u, len: %3u (at 0x%08x): "),
7088 len
-= sizeof (dsth
);
7089 buf
= bfd_malloc (len
);
7090 if (bfd_bread (buf
, len
, abfd
) != len
)
7092 fprintf (file
, _("cannot read DST symbol\n"));
7097 case DSC__K_DTYPE_V
:
7098 case DSC__K_DTYPE_BU
:
7099 case DSC__K_DTYPE_WU
:
7100 case DSC__K_DTYPE_LU
:
7101 case DSC__K_DTYPE_QU
:
7102 case DSC__K_DTYPE_B
:
7103 case DSC__K_DTYPE_W
:
7104 case DSC__K_DTYPE_L
:
7105 case DSC__K_DTYPE_Q
:
7106 case DSC__K_DTYPE_F
:
7107 case DSC__K_DTYPE_D
:
7108 case DSC__K_DTYPE_FC
:
7109 case DSC__K_DTYPE_DC
:
7110 case DSC__K_DTYPE_T
:
7111 case DSC__K_DTYPE_NU
:
7112 case DSC__K_DTYPE_NL
:
7113 case DSC__K_DTYPE_NLO
:
7114 case DSC__K_DTYPE_NR
:
7115 case DSC__K_DTYPE_NRO
:
7116 case DSC__K_DTYPE_NZ
:
7117 case DSC__K_DTYPE_P
:
7118 case DSC__K_DTYPE_ZI
:
7119 case DSC__K_DTYPE_ZEM
:
7120 case DSC__K_DTYPE_DSC
:
7121 case DSC__K_DTYPE_OU
:
7122 case DSC__K_DTYPE_O
:
7123 case DSC__K_DTYPE_G
:
7124 case DSC__K_DTYPE_H
:
7125 case DSC__K_DTYPE_GC
:
7126 case DSC__K_DTYPE_HC
:
7127 case DSC__K_DTYPE_CIT
:
7128 case DSC__K_DTYPE_BPV
:
7129 case DSC__K_DTYPE_BLV
:
7130 case DSC__K_DTYPE_VU
:
7131 case DSC__K_DTYPE_ADT
:
7132 case DSC__K_DTYPE_VT
:
7133 case DSC__K_DTYPE_T2
:
7134 case DSC__K_DTYPE_VT2
:
7135 fprintf (file
, _("standard data: %s\n"),
7136 evax_bfd_get_dsc_name (type
));
7137 evax_bfd_print_valspec (buf
, 4, file
);
7138 fprintf (file
, _(" name: %.*s\n"), buf
[5], buf
+ 6);
7142 struct vms_dst_modbeg
*dst
= (void *)buf
;
7143 const char *name
= (const char *)buf
+ sizeof (*dst
);
7145 fprintf (file
, _("modbeg\n"));
7146 /* xgettext:c-format */
7147 fprintf (file
, _(" flags: %d, language: %u, "
7148 "major: %u, minor: %u\n"),
7150 (unsigned)bfd_getl32 (dst
->language
),
7151 (unsigned)bfd_getl16 (dst
->major
),
7152 (unsigned)bfd_getl16 (dst
->minor
));
7153 fprintf (file
, _(" module name: %.*s\n"),
7155 name
+= name
[0] + 1;
7156 fprintf (file
, _(" compiler : %.*s\n"),
7161 fprintf (file
, _("modend\n"));
7165 struct vms_dst_rtnbeg
*dst
= (void *)buf
;
7166 const char *name
= (const char *)buf
+ sizeof (*dst
);
7168 fputs (_("rtnbeg\n"), file
);
7169 /* xgettext:c-format */
7170 fprintf (file
, _(" flags: %u, address: 0x%08x, "
7171 "pd-address: 0x%08x\n"),
7173 (unsigned)bfd_getl32 (dst
->address
),
7174 (unsigned)bfd_getl32 (dst
->pd_address
));
7175 fprintf (file
, _(" routine name: %.*s\n"),
7181 struct vms_dst_rtnend
*dst
= (void *)buf
;
7183 fprintf (file
, _("rtnend: size 0x%08x\n"),
7184 (unsigned)bfd_getl32 (dst
->size
));
7189 struct vms_dst_prolog
*dst
= (void *)buf
;
7191 fprintf (file
, _("prolog: bkpt address 0x%08x\n"),
7192 (unsigned)bfd_getl32 (dst
->bkpt_addr
));
7197 struct vms_dst_epilog
*dst
= (void *)buf
;
7199 /* xgettext:c-format */
7200 fprintf (file
, _("epilog: flags: %u, count: %u\n"),
7201 dst
->flags
, (unsigned)bfd_getl32 (dst
->count
));
7206 struct vms_dst_blkbeg
*dst
= (void *)buf
;
7207 const char *name
= (const char *)buf
+ sizeof (*dst
);
7209 /* xgettext:c-format */
7210 fprintf (file
, _("blkbeg: address: 0x%08x, name: %.*s\n"),
7211 (unsigned)bfd_getl32 (dst
->address
),
7217 struct vms_dst_blkend
*dst
= (void *)buf
;
7219 fprintf (file
, _("blkend: size: 0x%08x\n"),
7220 (unsigned)bfd_getl32 (dst
->size
));
7223 case DST__K_TYPSPEC
:
7225 fprintf (file
, _("typspec (len: %u)\n"), len
);
7226 fprintf (file
, _(" name: %.*s\n"), buf
[0], buf
+ 1);
7227 evax_bfd_print_typspec (buf
+ 1 + buf
[0], 5, file
);
7232 fprintf (file
, _("septyp, name: %.*s\n"), buf
[5], buf
+ 6);
7233 evax_bfd_print_valspec (buf
, 4, file
);
7238 struct vms_dst_recbeg
*recbeg
= (void *)buf
;
7239 const char *name
= (const char *)buf
+ sizeof (*recbeg
);
7241 fprintf (file
, _("recbeg: name: %.*s\n"), name
[0], name
+ 1);
7242 evax_bfd_print_valspec (buf
, 4, file
);
7243 fprintf (file
, _(" len: %u bits\n"),
7244 (unsigned)bfd_getl32 (name
+ 1 + name
[0]));
7248 fprintf (file
, _("recend\n"));
7250 case DST__K_ENUMBEG
:
7251 /* xgettext:c-format */
7252 fprintf (file
, _("enumbeg, len: %u, name: %.*s\n"),
7253 buf
[0], buf
[1], buf
+ 2);
7255 case DST__K_ENUMELT
:
7256 fprintf (file
, _("enumelt, name: %.*s\n"), buf
[5], buf
+ 6);
7257 evax_bfd_print_valspec (buf
, 4, file
);
7259 case DST__K_ENUMEND
:
7260 fprintf (file
, _("enumend\n"));
7264 struct vms_dst_label
*lab
= (void *)buf
;
7265 fprintf (file
, _("label, name: %.*s\n"),
7266 lab
->name
[0], lab
->name
+ 1);
7267 fprintf (file
, _(" address: 0x%08x\n"),
7268 (unsigned)bfd_getl32 (lab
->value
));
7271 case DST__K_DIS_RANGE
:
7273 unsigned int cnt
= bfd_getl32 (buf
);
7274 unsigned char *rng
= buf
+ 4;
7277 fprintf (file
, _("discontiguous range (nbr: %u)\n"), cnt
);
7278 for (i
= 0; i
< cnt
; i
++, rng
+= 8)
7279 /* xgettext:c-format */
7280 fprintf (file
, _(" address: 0x%08x, size: %u\n"),
7281 (unsigned)bfd_getl32 (rng
),
7282 (unsigned)bfd_getl32 (rng
+ 4));
7286 case DST__K_LINE_NUM
:
7288 unsigned char *buf_orig
= buf
;
7290 fprintf (file
, _("line num (len: %u)\n"), len
);
7295 unsigned char cmdlen
;
7305 case DST__K_DELTA_PC_W
:
7306 val
= bfd_getl16 (buf
+ 1);
7307 fprintf (file
, _("delta_pc_w %u\n"), val
);
7312 case DST__K_INCR_LINUM
:
7314 fprintf (file
, _("incr_linum(b): +%u\n"), val
);
7318 case DST__K_INCR_LINUM_W
:
7319 val
= bfd_getl16 (buf
+ 1);
7320 fprintf (file
, _("incr_linum_w: +%u\n"), val
);
7324 case DST__K_INCR_LINUM_L
:
7325 val
= bfd_getl32 (buf
+ 1);
7326 fprintf (file
, _("incr_linum_l: +%u\n"), val
);
7330 case DST__K_SET_LINUM
:
7331 line
= bfd_getl16 (buf
+ 1);
7332 fprintf (file
, _("set_line_num(w) %u\n"), line
);
7335 case DST__K_SET_LINUM_B
:
7337 fprintf (file
, _("set_line_num_b %u\n"), line
);
7340 case DST__K_SET_LINUM_L
:
7341 line
= bfd_getl32 (buf
+ 1);
7342 fprintf (file
, _("set_line_num_l %u\n"), line
);
7345 case DST__K_SET_ABS_PC
:
7346 pc
= bfd_getl32 (buf
+ 1);
7347 fprintf (file
, _("set_abs_pc: 0x%08x\n"), pc
);
7350 case DST__K_DELTA_PC_L
:
7351 fprintf (file
, _("delta_pc_l: +0x%08x\n"),
7352 (unsigned)bfd_getl32 (buf
+ 1));
7356 fprintf (file
, _("term(b): 0x%02x"), buf
[1]);
7358 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7362 val
= bfd_getl16 (buf
+ 1);
7363 fprintf (file
, _("term_w: 0x%04x"), val
);
7365 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7371 fprintf (file
, _("delta pc +%-4d"), -cmd
);
7372 line
++; /* FIXME: curr increment. */
7374 /* xgettext:c-format */
7375 fprintf (file
, _(" pc: 0x%08x line: %5u\n"),
7380 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7393 unsigned char *buf_orig
= buf
;
7395 fprintf (file
, _("source (len: %u)\n"), len
);
7399 signed char cmd
= buf
[0];
7400 unsigned char cmdlen
= 0;
7404 case DST__K_SRC_DECLFILE
:
7406 struct vms_dst_src_decl_src
*src
= (void *)(buf
+ 1);
7409 /* xgettext:c-format */
7410 fprintf (file
, _(" declfile: len: %u, flags: %u, "
7412 src
->length
, src
->flags
,
7413 (unsigned)bfd_getl16 (src
->fileid
));
7414 /* xgettext:c-format */
7415 fprintf (file
, _(" rms: cdt: 0x%08x %08x, "
7416 "ebk: 0x%08x, ffb: 0x%04x, "
7418 (unsigned)bfd_getl32 (src
->rms_cdt
+ 4),
7419 (unsigned)bfd_getl32 (src
->rms_cdt
+ 0),
7420 (unsigned)bfd_getl32 (src
->rms_ebk
),
7421 (unsigned)bfd_getl16 (src
->rms_ffb
),
7423 name
= (const char *)buf
+ 1 + sizeof (*src
);
7424 fprintf (file
, _(" filename : %.*s\n"),
7426 name
+= name
[0] + 1;
7427 fprintf (file
, _(" module name: %.*s\n"),
7429 cmdlen
= 2 + src
->length
;
7432 case DST__K_SRC_SETFILE
:
7433 fprintf (file
, _(" setfile %u\n"),
7434 (unsigned)bfd_getl16 (buf
+ 1));
7437 case DST__K_SRC_SETREC_W
:
7438 fprintf (file
, _(" setrec %u\n"),
7439 (unsigned)bfd_getl16 (buf
+ 1));
7442 case DST__K_SRC_SETREC_L
:
7443 fprintf (file
, _(" setrec %u\n"),
7444 (unsigned)bfd_getl32 (buf
+ 1));
7447 case DST__K_SRC_SETLNUM_W
:
7448 fprintf (file
, _(" setlnum %u\n"),
7449 (unsigned)bfd_getl16 (buf
+ 1));
7452 case DST__K_SRC_SETLNUM_L
:
7453 fprintf (file
, _(" setlnum %u\n"),
7454 (unsigned)bfd_getl32 (buf
+ 1));
7457 case DST__K_SRC_DEFLINES_W
:
7458 fprintf (file
, _(" deflines %u\n"),
7459 (unsigned)bfd_getl16 (buf
+ 1));
7462 case DST__K_SRC_DEFLINES_B
:
7463 fprintf (file
, _(" deflines %u\n"), buf
[1]);
7466 case DST__K_SRC_FORMFEED
:
7467 fprintf (file
, _(" formfeed\n"));
7471 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7483 fprintf (file
, _("*unhandled* dst type %u\n"), type
);
7491 evax_bfd_print_image (bfd
*abfd
, FILE *file
)
7493 struct vms_eihd eihd
;
7496 unsigned int eiha_off
;
7497 unsigned int eihi_off
;
7498 unsigned int eihs_off
;
7499 unsigned int eisd_off
;
7500 unsigned int eihef_off
= 0;
7501 unsigned int eihnp_off
= 0;
7502 unsigned int dmt_vbn
= 0;
7503 unsigned int dmt_size
= 0;
7504 unsigned int dst_vbn
= 0;
7505 unsigned int dst_size
= 0;
7506 unsigned int gst_vbn
= 0;
7507 unsigned int gst_size
= 0;
7508 unsigned int eiaf_vbn
= 0;
7509 unsigned int eiaf_size
= 0;
7510 unsigned int eihvn_off
;
7512 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
)
7513 || bfd_bread (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
7515 fprintf (file
, _("cannot read EIHD\n"));
7518 /* xgettext:c-format */
7519 fprintf (file
, _("EIHD: (size: %u, nbr blocks: %u)\n"),
7520 (unsigned)bfd_getl32 (eihd
.size
),
7521 (unsigned)bfd_getl32 (eihd
.hdrblkcnt
));
7522 /* xgettext:c-format */
7523 fprintf (file
, _(" majorid: %u, minorid: %u\n"),
7524 (unsigned)bfd_getl32 (eihd
.majorid
),
7525 (unsigned)bfd_getl32 (eihd
.minorid
));
7527 val
= (unsigned)bfd_getl32 (eihd
.imgtype
);
7531 name
= _("executable");
7534 name
= _("linkable image");
7537 name
= _("unknown");
7540 /* xgettext:c-format */
7541 fprintf (file
, _(" image type: %u (%s)"), val
, name
);
7543 val
= (unsigned)bfd_getl32 (eihd
.subtype
);
7546 case EIHD__C_NATIVE
:
7553 name
= _("unknown");
7556 /* xgettext:c-format */
7557 fprintf (file
, _(", subtype: %u (%s)\n"), val
, name
);
7559 eisd_off
= bfd_getl32 (eihd
.isdoff
);
7560 eiha_off
= bfd_getl32 (eihd
.activoff
);
7561 eihi_off
= bfd_getl32 (eihd
.imgidoff
);
7562 eihs_off
= bfd_getl32 (eihd
.symdbgoff
);
7563 /* xgettext:c-format */
7564 fprintf (file
, _(" offsets: isd: %u, activ: %u, symdbg: %u, "
7565 "imgid: %u, patch: %u\n"),
7566 eisd_off
, eiha_off
, eihs_off
, eihi_off
,
7567 (unsigned)bfd_getl32 (eihd
.patchoff
));
7568 fprintf (file
, _(" fixup info rva: "));
7569 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.iafva
));
7570 fprintf (file
, _(", symbol vector rva: "));
7571 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.symvva
));
7572 eihvn_off
= bfd_getl32 (eihd
.version_array_off
);
7573 fprintf (file
, _("\n"
7574 " version array off: %u\n"),
7577 /* xgettext:c-format */
7578 _(" img I/O count: %u, nbr channels: %u, req pri: %08x%08x\n"),
7579 (unsigned)bfd_getl32 (eihd
.imgiocnt
),
7580 (unsigned)bfd_getl32 (eihd
.iochancnt
),
7581 (unsigned)bfd_getl32 (eihd
.privreqs
+ 4),
7582 (unsigned)bfd_getl32 (eihd
.privreqs
+ 0));
7583 val
= (unsigned)bfd_getl32 (eihd
.lnkflags
);
7584 fprintf (file
, _(" linker flags: %08x:"), val
);
7585 if (val
& EIHD__M_LNKDEBUG
)
7586 fprintf (file
, " LNKDEBUG");
7587 if (val
& EIHD__M_LNKNOTFR
)
7588 fprintf (file
, " LNKNOTFR");
7589 if (val
& EIHD__M_NOP0BUFS
)
7590 fprintf (file
, " NOP0BUFS");
7591 if (val
& EIHD__M_PICIMG
)
7592 fprintf (file
, " PICIMG");
7593 if (val
& EIHD__M_P0IMAGE
)
7594 fprintf (file
, " P0IMAGE");
7595 if (val
& EIHD__M_DBGDMT
)
7596 fprintf (file
, " DBGDMT");
7597 if (val
& EIHD__M_INISHR
)
7598 fprintf (file
, " INISHR");
7599 if (val
& EIHD__M_XLATED
)
7600 fprintf (file
, " XLATED");
7601 if (val
& EIHD__M_BIND_CODE_SEC
)
7602 fprintf (file
, " BIND_CODE_SEC");
7603 if (val
& EIHD__M_BIND_DATA_SEC
)
7604 fprintf (file
, " BIND_DATA_SEC");
7605 if (val
& EIHD__M_MKTHREADS
)
7606 fprintf (file
, " MKTHREADS");
7607 if (val
& EIHD__M_UPCALLS
)
7608 fprintf (file
, " UPCALLS");
7609 if (val
& EIHD__M_OMV_READY
)
7610 fprintf (file
, " OMV_READY");
7611 if (val
& EIHD__M_EXT_BIND_SECT
)
7612 fprintf (file
, " EXT_BIND_SECT");
7613 fprintf (file
, "\n");
7614 /* xgettext:c-format */
7615 fprintf (file
, _(" ident: 0x%08x, sysver: 0x%08x, "
7616 "match ctrl: %u, symvect_size: %u\n"),
7617 (unsigned)bfd_getl32 (eihd
.ident
),
7618 (unsigned)bfd_getl32 (eihd
.sysver
),
7620 (unsigned)bfd_getl32 (eihd
.symvect_size
));
7621 fprintf (file
, _(" BPAGE: %u"),
7622 (unsigned)bfd_getl32 (eihd
.virt_mem_block_size
));
7623 if (val
& (EIHD__M_OMV_READY
| EIHD__M_EXT_BIND_SECT
))
7625 eihef_off
= bfd_getl32 (eihd
.ext_fixup_off
);
7626 eihnp_off
= bfd_getl32 (eihd
.noopt_psect_off
);
7627 /* xgettext:c-format */
7628 fprintf (file
, _(", ext fixup offset: %u, no_opt psect off: %u"),
7629 eihef_off
, eihnp_off
);
7631 fprintf (file
, _(", alias: %u\n"), (unsigned)bfd_getl16 (eihd
.alias
));
7635 struct vms_eihvn eihvn
;
7639 fprintf (file
, _("system version array information:\n"));
7640 if (bfd_seek (abfd
, (file_ptr
) eihvn_off
, SEEK_SET
)
7641 || bfd_bread (&eihvn
, sizeof (eihvn
), abfd
) != sizeof (eihvn
))
7643 fprintf (file
, _("cannot read EIHVN header\n"));
7646 mask
= bfd_getl32 (eihvn
.subsystem_mask
);
7647 for (j
= 0; j
< 32; j
++)
7648 if (mask
& (1 << j
))
7650 struct vms_eihvn_subversion ver
;
7651 if (bfd_bread (&ver
, sizeof (ver
), abfd
) != sizeof (ver
))
7653 fprintf (file
, _("cannot read EIHVN version\n"));
7656 fprintf (file
, _(" %02u "), j
);
7659 case EIHVN__BASE_IMAGE_BIT
:
7660 fputs (_("BASE_IMAGE "), file
);
7662 case EIHVN__MEMORY_MANAGEMENT_BIT
:
7663 fputs (_("MEMORY_MANAGEMENT"), file
);
7666 fputs (_("IO "), file
);
7668 case EIHVN__FILES_VOLUMES_BIT
:
7669 fputs (_("FILES_VOLUMES "), file
);
7671 case EIHVN__PROCESS_SCHED_BIT
:
7672 fputs (_("PROCESS_SCHED "), file
);
7674 case EIHVN__SYSGEN_BIT
:
7675 fputs (_("SYSGEN "), file
);
7677 case EIHVN__CLUSTERS_LOCKMGR_BIT
:
7678 fputs (_("CLUSTERS_LOCKMGR "), file
);
7680 case EIHVN__LOGICAL_NAMES_BIT
:
7681 fputs (_("LOGICAL_NAMES "), file
);
7683 case EIHVN__SECURITY_BIT
:
7684 fputs (_("SECURITY "), file
);
7686 case EIHVN__IMAGE_ACTIVATOR_BIT
:
7687 fputs (_("IMAGE_ACTIVATOR "), file
);
7689 case EIHVN__NETWORKS_BIT
:
7690 fputs (_("NETWORKS "), file
);
7692 case EIHVN__COUNTERS_BIT
:
7693 fputs (_("COUNTERS "), file
);
7695 case EIHVN__STABLE_BIT
:
7696 fputs (_("STABLE "), file
);
7698 case EIHVN__MISC_BIT
:
7699 fputs (_("MISC "), file
);
7701 case EIHVN__CPU_BIT
:
7702 fputs (_("CPU "), file
);
7704 case EIHVN__VOLATILE_BIT
:
7705 fputs (_("VOLATILE "), file
);
7707 case EIHVN__SHELL_BIT
:
7708 fputs (_("SHELL "), file
);
7710 case EIHVN__POSIX_BIT
:
7711 fputs (_("POSIX "), file
);
7713 case EIHVN__MULTI_PROCESSING_BIT
:
7714 fputs (_("MULTI_PROCESSING "), file
);
7716 case EIHVN__GALAXY_BIT
:
7717 fputs (_("GALAXY "), file
);
7720 fputs (_("*unknown* "), file
);
7723 fprintf (file
, ": %u.%u\n",
7724 (unsigned)bfd_getl16 (ver
.major
),
7725 (unsigned)bfd_getl16 (ver
.minor
));
7731 struct vms_eiha eiha
;
7733 if (bfd_seek (abfd
, (file_ptr
) eiha_off
, SEEK_SET
)
7734 || bfd_bread (&eiha
, sizeof (eiha
), abfd
) != sizeof (eiha
))
7736 fprintf (file
, _("cannot read EIHA\n"));
7739 fprintf (file
, _("Image activation: (size=%u)\n"),
7740 (unsigned)bfd_getl32 (eiha
.size
));
7741 /* xgettext:c-format */
7742 fprintf (file
, _(" First address : 0x%08x 0x%08x\n"),
7743 (unsigned)bfd_getl32 (eiha
.tfradr1_h
),
7744 (unsigned)bfd_getl32 (eiha
.tfradr1
));
7745 /* xgettext:c-format */
7746 fprintf (file
, _(" Second address: 0x%08x 0x%08x\n"),
7747 (unsigned)bfd_getl32 (eiha
.tfradr2_h
),
7748 (unsigned)bfd_getl32 (eiha
.tfradr2
));
7749 /* xgettext:c-format */
7750 fprintf (file
, _(" Third address : 0x%08x 0x%08x\n"),
7751 (unsigned)bfd_getl32 (eiha
.tfradr3_h
),
7752 (unsigned)bfd_getl32 (eiha
.tfradr3
));
7753 /* xgettext:c-format */
7754 fprintf (file
, _(" Fourth address: 0x%08x 0x%08x\n"),
7755 (unsigned)bfd_getl32 (eiha
.tfradr4_h
),
7756 (unsigned)bfd_getl32 (eiha
.tfradr4
));
7757 /* xgettext:c-format */
7758 fprintf (file
, _(" Shared image : 0x%08x 0x%08x\n"),
7759 (unsigned)bfd_getl32 (eiha
.inishr_h
),
7760 (unsigned)bfd_getl32 (eiha
.inishr
));
7764 struct vms_eihi eihi
;
7766 if (bfd_seek (abfd
, (file_ptr
) eihi_off
, SEEK_SET
)
7767 || bfd_bread (&eihi
, sizeof (eihi
), abfd
) != sizeof (eihi
))
7769 fprintf (file
, _("cannot read EIHI\n"));
7772 /* xgettext:c-format */
7773 fprintf (file
, _("Image identification: (major: %u, minor: %u)\n"),
7774 (unsigned)bfd_getl32 (eihi
.majorid
),
7775 (unsigned)bfd_getl32 (eihi
.minorid
));
7776 fprintf (file
, _(" image name : %.*s\n"),
7777 eihi
.imgnam
[0], eihi
.imgnam
+ 1);
7778 fprintf (file
, _(" link time : %s\n"),
7779 vms_time_to_str (eihi
.linktime
));
7780 fprintf (file
, _(" image ident : %.*s\n"),
7781 eihi
.imgid
[0], eihi
.imgid
+ 1);
7782 fprintf (file
, _(" linker ident : %.*s\n"),
7783 eihi
.linkid
[0], eihi
.linkid
+ 1);
7784 fprintf (file
, _(" image build ident: %.*s\n"),
7785 eihi
.imgbid
[0], eihi
.imgbid
+ 1);
7789 struct vms_eihs eihs
;
7791 if (bfd_seek (abfd
, (file_ptr
) eihs_off
, SEEK_SET
)
7792 || bfd_bread (&eihs
, sizeof (eihs
), abfd
) != sizeof (eihs
))
7794 fprintf (file
, _("cannot read EIHS\n"));
7797 /* xgettext:c-format */
7798 fprintf (file
, _("Image symbol & debug table: (major: %u, minor: %u)\n"),
7799 (unsigned)bfd_getl32 (eihs
.majorid
),
7800 (unsigned)bfd_getl32 (eihs
.minorid
));
7801 dst_vbn
= bfd_getl32 (eihs
.dstvbn
);
7802 dst_size
= bfd_getl32 (eihs
.dstsize
);
7803 /* xgettext:c-format */
7804 fprintf (file
, _(" debug symbol table : vbn: %u, size: %u (0x%x)\n"),
7805 dst_vbn
, dst_size
, dst_size
);
7806 gst_vbn
= bfd_getl32 (eihs
.gstvbn
);
7807 gst_size
= bfd_getl32 (eihs
.gstsize
);
7808 /* xgettext:c-format */
7809 fprintf (file
, _(" global symbol table: vbn: %u, records: %u\n"),
7811 dmt_vbn
= bfd_getl32 (eihs
.dmtvbn
);
7812 dmt_size
= bfd_getl32 (eihs
.dmtsize
);
7813 /* xgettext:c-format */
7814 fprintf (file
, _(" debug module table : vbn: %u, size: %u\n"),
7817 while (eisd_off
!= 0)
7819 struct vms_eisd eisd
;
7824 if (bfd_seek (abfd
, (file_ptr
) eisd_off
, SEEK_SET
)
7825 || bfd_bread (&eisd
, sizeof (eisd
), abfd
) != sizeof (eisd
))
7827 fprintf (file
, _("cannot read EISD\n"));
7830 len
= (unsigned)bfd_getl32 (eisd
.eisdsize
);
7831 if (len
!= (unsigned)-1)
7835 eisd_off
= (eisd_off
+ VMS_BLOCK_SIZE
) & ~(VMS_BLOCK_SIZE
- 1);
7837 /* xgettext:c-format */
7838 fprintf (file
, _("Image section descriptor: (major: %u, minor: %u, "
7839 "size: %u, offset: %u)\n"),
7840 (unsigned)bfd_getl32 (eisd
.majorid
),
7841 (unsigned)bfd_getl32 (eisd
.minorid
),
7845 /* xgettext:c-format */
7846 fprintf (file
, _(" section: base: 0x%08x%08x size: 0x%08x\n"),
7847 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 4),
7848 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 0),
7849 (unsigned)bfd_getl32 (eisd
.secsize
));
7850 val
= (unsigned)bfd_getl32 (eisd
.flags
);
7851 fprintf (file
, _(" flags: 0x%04x"), val
);
7852 if (val
& EISD__M_GBL
)
7853 fprintf (file
, " GBL");
7854 if (val
& EISD__M_CRF
)
7855 fprintf (file
, " CRF");
7856 if (val
& EISD__M_DZRO
)
7857 fprintf (file
, " DZRO");
7858 if (val
& EISD__M_WRT
)
7859 fprintf (file
, " WRT");
7860 if (val
& EISD__M_INITALCODE
)
7861 fprintf (file
, " INITALCODE");
7862 if (val
& EISD__M_BASED
)
7863 fprintf (file
, " BASED");
7864 if (val
& EISD__M_FIXUPVEC
)
7865 fprintf (file
, " FIXUPVEC");
7866 if (val
& EISD__M_RESIDENT
)
7867 fprintf (file
, " RESIDENT");
7868 if (val
& EISD__M_VECTOR
)
7869 fprintf (file
, " VECTOR");
7870 if (val
& EISD__M_PROTECT
)
7871 fprintf (file
, " PROTECT");
7872 if (val
& EISD__M_LASTCLU
)
7873 fprintf (file
, " LASTCLU");
7874 if (val
& EISD__M_EXE
)
7875 fprintf (file
, " EXE");
7876 if (val
& EISD__M_NONSHRADR
)
7877 fprintf (file
, " NONSHRADR");
7878 if (val
& EISD__M_QUAD_LENGTH
)
7879 fprintf (file
, " QUAD_LENGTH");
7880 if (val
& EISD__M_ALLOC_64BIT
)
7881 fprintf (file
, " ALLOC_64BIT");
7882 fprintf (file
, "\n");
7883 if (val
& EISD__M_FIXUPVEC
)
7885 eiaf_vbn
= bfd_getl32 (eisd
.vbn
);
7886 eiaf_size
= bfd_getl32 (eisd
.secsize
);
7888 /* xgettext:c-format */
7889 fprintf (file
, _(" vbn: %u, pfc: %u, matchctl: %u type: %u ("),
7890 (unsigned)bfd_getl32 (eisd
.vbn
),
7891 eisd
.pfc
, eisd
.matchctl
, eisd
.type
);
7894 case EISD__K_NORMAL
:
7895 fputs (_("NORMAL"), file
);
7897 case EISD__K_SHRFXD
:
7898 fputs (_("SHRFXD"), file
);
7900 case EISD__K_PRVFXD
:
7901 fputs (_("PRVFXD"), file
);
7903 case EISD__K_SHRPIC
:
7904 fputs (_("SHRPIC"), file
);
7906 case EISD__K_PRVPIC
:
7907 fputs (_("PRVPIC"), file
);
7909 case EISD__K_USRSTACK
:
7910 fputs (_("USRSTACK"), file
);
7913 fputs (_("*unknown*"), file
);
7916 fputs (_(")\n"), file
);
7917 if (val
& EISD__M_GBL
)
7918 /* xgettext:c-format */
7919 fprintf (file
, _(" ident: 0x%08x, name: %.*s\n"),
7920 (unsigned)bfd_getl32 (eisd
.ident
),
7921 eisd
.gblnam
[0], eisd
.gblnam
+ 1);
7927 if (bfd_seek (abfd
, (file_ptr
) (dmt_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7929 fprintf (file
, _("cannot read DMT\n"));
7933 fprintf (file
, _("Debug module table:\n"));
7935 while (dmt_size
> 0)
7937 struct vms_dmt_header dmth
;
7940 if (bfd_bread (&dmth
, sizeof (dmth
), abfd
) != sizeof (dmth
))
7942 fprintf (file
, _("cannot read DMT header\n"));
7945 count
= bfd_getl16 (dmth
.psect_count
);
7947 /* xgettext:c-format */
7948 _(" module offset: 0x%08x, size: 0x%08x, (%u psects)\n"),
7949 (unsigned)bfd_getl32 (dmth
.modbeg
),
7950 (unsigned)bfd_getl32 (dmth
.size
), count
);
7951 dmt_size
-= sizeof (dmth
);
7954 struct vms_dmt_psect dmtp
;
7956 if (bfd_bread (&dmtp
, sizeof (dmtp
), abfd
) != sizeof (dmtp
))
7958 fprintf (file
, _("cannot read DMT psect\n"));
7961 /* xgettext:c-format */
7962 fprintf (file
, _(" psect start: 0x%08x, length: %u\n"),
7963 (unsigned)bfd_getl32 (dmtp
.start
),
7964 (unsigned)bfd_getl32 (dmtp
.length
));
7966 dmt_size
-= sizeof (dmtp
);
7973 if (bfd_seek (abfd
, (file_ptr
) (dst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7975 fprintf (file
, _("cannot read DST\n"));
7979 evax_bfd_print_dst (abfd
, dst_size
, file
);
7983 if (bfd_seek (abfd
, (file_ptr
) (gst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7985 fprintf (file
, _("cannot read GST\n"));
7989 fprintf (file
, _("Global symbol table:\n"));
7990 evax_bfd_print_eobj (abfd
, file
);
7995 struct vms_eiaf
*eiaf
;
7996 unsigned int qrelfixoff
;
7997 unsigned int lrelfixoff
;
7998 unsigned int qdotadroff
;
7999 unsigned int ldotadroff
;
8000 unsigned int shrimgcnt
;
8001 unsigned int shlstoff
;
8002 unsigned int codeadroff
;
8003 unsigned int lpfixoff
;
8004 unsigned int chgprtoff
;
8006 buf
= bfd_malloc (eiaf_size
);
8008 if (bfd_seek (abfd
, (file_ptr
) (eiaf_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
)
8009 || bfd_bread (buf
, eiaf_size
, abfd
) != eiaf_size
)
8011 fprintf (file
, _("cannot read EIHA\n"));
8015 eiaf
= (struct vms_eiaf
*)buf
;
8017 /* xgettext:c-format */
8018 _("Image activator fixup: (major: %u, minor: %u)\n"),
8019 (unsigned)bfd_getl32 (eiaf
->majorid
),
8020 (unsigned)bfd_getl32 (eiaf
->minorid
));
8021 /* xgettext:c-format */
8022 fprintf (file
, _(" iaflink : 0x%08x %08x\n"),
8023 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 0),
8024 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 4));
8025 /* xgettext:c-format */
8026 fprintf (file
, _(" fixuplnk: 0x%08x %08x\n"),
8027 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 0),
8028 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 4));
8029 fprintf (file
, _(" size : %u\n"),
8030 (unsigned)bfd_getl32 (eiaf
->size
));
8031 fprintf (file
, _(" flags: 0x%08x\n"),
8032 (unsigned)bfd_getl32 (eiaf
->flags
));
8033 qrelfixoff
= bfd_getl32 (eiaf
->qrelfixoff
);
8034 lrelfixoff
= bfd_getl32 (eiaf
->lrelfixoff
);
8035 /* xgettext:c-format */
8036 fprintf (file
, _(" qrelfixoff: %5u, lrelfixoff: %5u\n"),
8037 qrelfixoff
, lrelfixoff
);
8038 qdotadroff
= bfd_getl32 (eiaf
->qdotadroff
);
8039 ldotadroff
= bfd_getl32 (eiaf
->ldotadroff
);
8040 /* xgettext:c-format */
8041 fprintf (file
, _(" qdotadroff: %5u, ldotadroff: %5u\n"),
8042 qdotadroff
, ldotadroff
);
8043 codeadroff
= bfd_getl32 (eiaf
->codeadroff
);
8044 lpfixoff
= bfd_getl32 (eiaf
->lpfixoff
);
8045 /* xgettext:c-format */
8046 fprintf (file
, _(" codeadroff: %5u, lpfixoff : %5u\n"),
8047 codeadroff
, lpfixoff
);
8048 chgprtoff
= bfd_getl32 (eiaf
->chgprtoff
);
8049 fprintf (file
, _(" chgprtoff : %5u\n"), chgprtoff
);
8050 shrimgcnt
= bfd_getl32 (eiaf
->shrimgcnt
);
8051 shlstoff
= bfd_getl32 (eiaf
->shlstoff
);
8052 /* xgettext:c-format */
8053 fprintf (file
, _(" shlstoff : %5u, shrimgcnt : %5u\n"),
8054 shlstoff
, shrimgcnt
);
8055 /* xgettext:c-format */
8056 fprintf (file
, _(" shlextra : %5u, permctx : %5u\n"),
8057 (unsigned)bfd_getl32 (eiaf
->shlextra
),
8058 (unsigned)bfd_getl32 (eiaf
->permctx
));
8059 fprintf (file
, _(" base_va : 0x%08x\n"),
8060 (unsigned)bfd_getl32 (eiaf
->base_va
));
8061 fprintf (file
, _(" lppsbfixoff: %5u\n"),
8062 (unsigned)bfd_getl32 (eiaf
->lppsbfixoff
));
8066 struct vms_shl
*shl
= (struct vms_shl
*)(buf
+ shlstoff
);
8069 fprintf (file
, _(" Shareable images:\n"));
8070 for (j
= 0; j
< shrimgcnt
; j
++, shl
++)
8073 /* xgettext:c-format */
8074 _(" %u: size: %u, flags: 0x%02x, name: %.*s\n"),
8075 j
, shl
->size
, shl
->flags
,
8076 shl
->imgnam
[0], shl
->imgnam
+ 1);
8079 if (qrelfixoff
!= 0)
8081 fprintf (file
, _(" quad-word relocation fixups:\n"));
8082 evax_bfd_print_relocation_records (file
, buf
+ qrelfixoff
, 8);
8084 if (lrelfixoff
!= 0)
8086 fprintf (file
, _(" long-word relocation fixups:\n"));
8087 evax_bfd_print_relocation_records (file
, buf
+ lrelfixoff
, 4);
8089 if (qdotadroff
!= 0)
8091 fprintf (file
, _(" quad-word .address reference fixups:\n"));
8092 evax_bfd_print_address_fixups (file
, buf
+ qdotadroff
);
8094 if (ldotadroff
!= 0)
8096 fprintf (file
, _(" long-word .address reference fixups:\n"));
8097 evax_bfd_print_address_fixups (file
, buf
+ ldotadroff
);
8099 if (codeadroff
!= 0)
8101 fprintf (file
, _(" Code Address Reference Fixups:\n"));
8102 evax_bfd_print_reference_fixups (file
, buf
+ codeadroff
);
8106 fprintf (file
, _(" Linkage Pairs Reference Fixups:\n"));
8107 evax_bfd_print_reference_fixups (file
, buf
+ lpfixoff
);
8111 unsigned int count
= (unsigned)bfd_getl32 (buf
+ chgprtoff
);
8112 struct vms_eicp
*eicp
= (struct vms_eicp
*)(buf
+ chgprtoff
+ 4);
8115 fprintf (file
, _(" Change Protection (%u entries):\n"), count
);
8116 for (j
= 0; j
< count
; j
++, eicp
++)
8118 unsigned int prot
= bfd_getl32 (eicp
->newprt
);
8120 /* xgettext:c-format */
8121 _(" base: 0x%08x %08x, size: 0x%08x, prot: 0x%08x "),
8122 (unsigned)bfd_getl32 (eicp
->baseva
+ 4),
8123 (unsigned)bfd_getl32 (eicp
->baseva
+ 0),
8124 (unsigned)bfd_getl32 (eicp
->size
),
8125 (unsigned)bfd_getl32 (eicp
->newprt
));
8129 fprintf (file
, "NA");
8131 case PRT__C_RESERVED
:
8132 fprintf (file
, "RES");
8135 fprintf (file
, "KW");
8138 fprintf (file
, "KR");
8141 fprintf (file
, "UW");
8144 fprintf (file
, "EW");
8147 fprintf (file
, "ERKW");
8150 fprintf (file
, "ER");
8153 fprintf (file
, "SW");
8156 fprintf (file
, "SREW");
8159 fprintf (file
, "SRKW");
8162 fprintf (file
, "SR");
8165 fprintf (file
, "URSW");
8168 fprintf (file
, "UREW");
8171 fprintf (file
, "URKW");
8174 fprintf (file
, "UR");
8188 vms_bfd_print_private_bfd_data (bfd
*abfd
, void *ptr
)
8190 FILE *file
= (FILE *)ptr
;
8192 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
8193 evax_bfd_print_image (abfd
, file
);
8196 if (bfd_seek (abfd
, 0, SEEK_SET
))
8198 evax_bfd_print_eobj (abfd
, file
);
8205 /* Slurp ETIR/EDBG/ETBT VMS object records. */
8208 alpha_vms_read_sections_content (bfd
*abfd
, struct bfd_link_info
*info
)
8210 asection
*cur_section
;
8211 file_ptr cur_offset
;
8212 asection
*dst_section
;
8213 file_ptr dst_offset
;
8215 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
8221 dst_section
= PRIV (dst_section
);
8225 if (info
->strip
== strip_all
|| info
->strip
== strip_debugger
)
8227 /* Discard the DST section. */
8231 else if (dst_section
)
8233 dst_offset
= dst_section
->output_offset
;
8234 dst_section
= dst_section
->output_section
;
8243 type
= _bfd_vms_get_object_record (abfd
);
8246 vms_debug2 ((2, "next_record failed\n"));
8252 PRIV (image_section
) = cur_section
;
8253 PRIV (image_offset
) = cur_offset
;
8254 res
= _bfd_vms_slurp_etir (abfd
, info
);
8255 cur_section
= PRIV (image_section
);
8256 cur_offset
= PRIV (image_offset
);
8260 if (dst_section
== NULL
)
8262 PRIV (image_section
) = dst_section
;
8263 PRIV (image_offset
) = dst_offset
;
8264 res
= _bfd_vms_slurp_etir (abfd
, info
);
8265 dst_offset
= PRIV (image_offset
);
8274 vms_debug2 ((2, "slurp eobj type %d failed\n", type
));
8281 alpha_vms_sizeof_headers (bfd
*abfd ATTRIBUTE_UNUSED
,
8282 struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8287 /* Add a linkage pair fixup at address SECT + OFFSET to SHLIB. */
8290 alpha_vms_add_fixup_lp (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
->lp
, bfd_vma
,
8300 sect
->output_section
->vma
+ sect
->output_offset
+ offset
);
8301 sect
->output_section
->flags
|= SEC_RELOC
;
8304 /* Add a code address fixup at address SECT + OFFSET to SHLIB. */
8307 alpha_vms_add_fixup_ca (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
8309 struct alpha_vms_shlib_el
*sl
;
8310 asection
*sect
= PRIV2 (src
, image_section
);
8311 file_ptr offset
= PRIV2 (src
, image_offset
);
8313 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8314 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8315 sl
->has_fixups
= TRUE
;
8316 VEC_APPEND_EL (sl
->ca
, bfd_vma
,
8317 sect
->output_section
->vma
+ sect
->output_offset
+ offset
);
8318 sect
->output_section
->flags
|= SEC_RELOC
;
8321 /* Add a quad word relocation fixup at address SECT + OFFSET to SHLIB. */
8324 alpha_vms_add_fixup_qr (struct bfd_link_info
*info
, bfd
*src
,
8325 bfd
*shlib
, bfd_vma vec
)
8327 struct alpha_vms_shlib_el
*sl
;
8328 struct alpha_vms_vma_ref
*r
;
8329 asection
*sect
= PRIV2 (src
, image_section
);
8330 file_ptr offset
= PRIV2 (src
, image_offset
);
8332 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8333 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8334 sl
->has_fixups
= TRUE
;
8335 r
= VEC_APPEND (sl
->qr
, struct alpha_vms_vma_ref
);
8336 r
->vma
= sect
->output_section
->vma
+ sect
->output_offset
+ offset
;
8338 sect
->output_section
->flags
|= SEC_RELOC
;
8342 alpha_vms_add_fixup_lr (struct bfd_link_info
*info ATTRIBUTE_UNUSED
,
8343 unsigned int shr ATTRIBUTE_UNUSED
,
8344 bfd_vma vec ATTRIBUTE_UNUSED
)
8346 /* Not yet supported. */
8350 /* Add relocation. FIXME: Not yet emitted. */
8353 alpha_vms_add_lw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8358 alpha_vms_add_qw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8362 static struct bfd_hash_entry
*
8363 alpha_vms_link_hash_newfunc (struct bfd_hash_entry
*entry
,
8364 struct bfd_hash_table
*table
,
8367 struct alpha_vms_link_hash_entry
*ret
=
8368 (struct alpha_vms_link_hash_entry
*) entry
;
8370 /* Allocate the structure if it has not already been allocated by a
8373 ret
= ((struct alpha_vms_link_hash_entry
*)
8374 bfd_hash_allocate (table
,
8375 sizeof (struct alpha_vms_link_hash_entry
)));
8379 /* Call the allocation method of the superclass. */
8380 ret
= ((struct alpha_vms_link_hash_entry
*)
8381 _bfd_link_hash_newfunc ((struct bfd_hash_entry
*) ret
,
8386 return (struct bfd_hash_entry
*) ret
;
8390 alpha_vms_bfd_link_hash_table_free (bfd
*abfd
)
8392 struct alpha_vms_link_hash_table
*t
;
8395 t
= (struct alpha_vms_link_hash_table
*) abfd
->link
.hash
;
8396 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8398 struct alpha_vms_shlib_el
*shlib
;
8400 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8401 free (&VEC_EL (shlib
->ca
, bfd_vma
, 0));
8402 free (&VEC_EL (shlib
->lp
, bfd_vma
, 0));
8403 free (&VEC_EL (shlib
->qr
, struct alpha_vms_vma_ref
, 0));
8405 free (&VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, 0));
8407 _bfd_generic_link_hash_table_free (abfd
);
8410 /* Create an Alpha/VMS link hash table. */
8412 static struct bfd_link_hash_table
*
8413 alpha_vms_bfd_link_hash_table_create (bfd
*abfd
)
8415 struct alpha_vms_link_hash_table
*ret
;
8416 bfd_size_type amt
= sizeof (struct alpha_vms_link_hash_table
);
8418 ret
= (struct alpha_vms_link_hash_table
*) bfd_malloc (amt
);
8421 if (!_bfd_link_hash_table_init (&ret
->root
, abfd
,
8422 alpha_vms_link_hash_newfunc
,
8423 sizeof (struct alpha_vms_link_hash_entry
)))
8429 VEC_INIT (ret
->shrlibs
);
8431 ret
->root
.hash_table_free
= alpha_vms_bfd_link_hash_table_free
;
8437 alpha_vms_link_add_object_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8441 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
8443 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
8444 struct alpha_vms_link_hash_entry
*h
;
8445 struct bfd_link_hash_entry
*h_root
;
8448 if (!alpha_vms_convert_symbol (abfd
, e
, &sym
))
8451 if ((e
->flags
& EGSY__V_DEF
) && abfd
->selective_search
)
8453 /* In selective_search mode, only add definition that are
8455 h
= (struct alpha_vms_link_hash_entry
*)bfd_link_hash_lookup
8456 (info
->hash
, sym
.name
, FALSE
, FALSE
, FALSE
);
8457 if (h
== NULL
|| h
->root
.type
!= bfd_link_hash_undefined
)
8463 h_root
= (struct bfd_link_hash_entry
*) h
;
8464 if (!_bfd_generic_link_add_one_symbol (info
, abfd
, sym
.name
, sym
.flags
,
8465 sym
.section
, sym
.value
, NULL
,
8466 FALSE
, FALSE
, &h_root
))
8468 h
= (struct alpha_vms_link_hash_entry
*) h_root
;
8470 if ((e
->flags
& EGSY__V_DEF
)
8472 && abfd
->xvec
== info
->output_bfd
->xvec
)
8476 if (abfd
->flags
& DYNAMIC
)
8478 struct alpha_vms_shlib_el
*shlib
;
8480 /* We do not want to include any of the sections in a dynamic
8481 object in the output file. See comment in elflink.c. */
8482 bfd_section_list_clear (abfd
);
8484 shlib
= VEC_APPEND (alpha_vms_link_hash (info
)->shrlibs
,
8485 struct alpha_vms_shlib_el
);
8487 VEC_INIT (shlib
->ca
);
8488 VEC_INIT (shlib
->lp
);
8489 VEC_INIT (shlib
->qr
);
8490 PRIV (shr_index
) = VEC_COUNT (alpha_vms_link_hash (info
)->shrlibs
) - 1;
8497 alpha_vms_link_add_archive_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8500 struct bfd_link_hash_entry
**pundef
;
8501 struct bfd_link_hash_entry
**next_pundef
;
8503 /* We only accept VMS libraries. */
8504 if (info
->output_bfd
->xvec
!= abfd
->xvec
)
8506 bfd_set_error (bfd_error_wrong_format
);
8510 /* The archive_pass field in the archive itself is used to
8511 initialize PASS, since we may search the same archive multiple
8513 pass
= ++abfd
->archive_pass
;
8515 /* Look through the list of undefined symbols. */
8516 for (pundef
= &info
->hash
->undefs
; *pundef
!= NULL
; pundef
= next_pundef
)
8518 struct bfd_link_hash_entry
*h
;
8524 next_pundef
= &(*pundef
)->u
.undef
.next
;
8526 /* When a symbol is defined, it is not necessarily removed from
8528 if (h
->type
!= bfd_link_hash_undefined
8529 && h
->type
!= bfd_link_hash_common
)
8531 /* Remove this entry from the list, for general cleanliness
8532 and because we are going to look through the list again
8533 if we search any more libraries. We can't remove the
8534 entry if it is the tail, because that would lose any
8535 entries we add to the list later on. */
8536 if (*pundef
!= info
->hash
->undefs_tail
)
8538 *pundef
= *next_pundef
;
8539 next_pundef
= pundef
;
8544 /* Look for this symbol in the archive hash table. */
8545 symidx
= _bfd_vms_lib_find_symbol (abfd
, h
->root
.string
);
8546 if (symidx
== BFD_NO_MORE_SYMBOLS
)
8548 /* Nothing in this slot. */
8552 element
= bfd_get_elt_at_index (abfd
, symidx
);
8553 if (element
== NULL
)
8556 if (element
->archive_pass
== -1 || element
->archive_pass
== pass
)
8558 /* Next symbol if this archive is wrong or already handled. */
8562 if (! bfd_check_format (element
, bfd_object
))
8564 element
->archive_pass
= -1;
8568 orig_element
= element
;
8569 if (bfd_is_thin_archive (abfd
))
8571 element
= _bfd_vms_lib_get_imagelib_file (element
);
8572 if (element
== NULL
|| !bfd_check_format (element
, bfd_object
))
8574 orig_element
->archive_pass
= -1;
8579 /* Unlike the generic linker, we know that this element provides
8580 a definition for an undefined symbol and we know that we want
8581 to include it. We don't need to check anything. */
8582 if (!(*info
->callbacks
8583 ->add_archive_element
) (info
, element
, h
->root
.string
, &element
))
8585 if (!alpha_vms_link_add_object_symbols (element
, info
))
8588 orig_element
->archive_pass
= pass
;
8595 alpha_vms_bfd_link_add_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8597 switch (bfd_get_format (abfd
))
8600 vms_debug2 ((2, "vms_link_add_symbols for object %s\n",
8602 return alpha_vms_link_add_object_symbols (abfd
, info
);
8605 vms_debug2 ((2, "vms_link_add_symbols for archive %s\n",
8607 return alpha_vms_link_add_archive_symbols (abfd
, info
);
8610 bfd_set_error (bfd_error_wrong_format
);
8616 alpha_vms_build_fixups (struct bfd_link_info
*info
)
8618 struct alpha_vms_link_hash_table
*t
= alpha_vms_link_hash (info
);
8619 unsigned char *content
;
8621 unsigned int sz
= 0;
8622 unsigned int lp_sz
= 0;
8623 unsigned int ca_sz
= 0;
8624 unsigned int qr_sz
= 0;
8625 unsigned int shrimg_cnt
= 0;
8626 unsigned int chgprt_num
= 0;
8627 unsigned int chgprt_sz
= 0;
8628 struct vms_eiaf
*eiaf
;
8632 /* Shared libraries. */
8633 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8635 struct alpha_vms_shlib_el
*shlib
;
8637 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8639 if (!shlib
->has_fixups
)
8644 if (VEC_COUNT (shlib
->ca
) > 0)
8646 /* Header + entries. */
8648 ca_sz
+= VEC_COUNT (shlib
->ca
) * 4;
8650 if (VEC_COUNT (shlib
->lp
) > 0)
8652 /* Header + entries. */
8654 lp_sz
+= VEC_COUNT (shlib
->lp
) * 4;
8656 if (VEC_COUNT (shlib
->qr
) > 0)
8658 /* Header + entries. */
8660 qr_sz
+= VEC_COUNT (shlib
->qr
) * 8;
8671 /* Finish now if there is no content. */
8672 if (ca_sz
+ lp_sz
+ qr_sz
== 0)
8675 /* Add an eicp entry for the fixup itself. */
8677 for (sec
= info
->output_bfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
8679 /* This isect could be made RO or EXE after relocations are applied. */
8680 if ((sec
->flags
& SEC_RELOC
) != 0
8681 && (sec
->flags
& (SEC_CODE
| SEC_READONLY
)) != 0)
8684 chgprt_sz
= 4 + chgprt_num
* sizeof (struct vms_eicp
);
8686 /* Allocate section content (round-up size) */
8687 sz
= sizeof (struct vms_eiaf
) + shrimg_cnt
* sizeof (struct vms_shl
)
8688 + ca_sz
+ lp_sz
+ qr_sz
+ chgprt_sz
;
8689 sz
= (sz
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
8690 content
= bfd_zalloc (info
->output_bfd
, sz
);
8691 if (content
== NULL
)
8694 sec
= alpha_vms_link_hash (info
)->fixup
;
8695 sec
->contents
= content
;
8698 eiaf
= (struct vms_eiaf
*)content
;
8699 off
= sizeof (struct vms_eiaf
);
8700 bfd_putl32 (0, eiaf
->majorid
);
8701 bfd_putl32 (0, eiaf
->minorid
);
8702 bfd_putl32 (0, eiaf
->iaflink
);
8703 bfd_putl32 (0, eiaf
->fixuplnk
);
8704 bfd_putl32 (sizeof (struct vms_eiaf
), eiaf
->size
);
8705 bfd_putl32 (0, eiaf
->flags
);
8706 bfd_putl32 (0, eiaf
->qrelfixoff
);
8707 bfd_putl32 (0, eiaf
->lrelfixoff
);
8708 bfd_putl32 (0, eiaf
->qdotadroff
);
8709 bfd_putl32 (0, eiaf
->ldotadroff
);
8710 bfd_putl32 (0, eiaf
->codeadroff
);
8711 bfd_putl32 (0, eiaf
->lpfixoff
);
8712 bfd_putl32 (0, eiaf
->chgprtoff
);
8713 bfd_putl32 (shrimg_cnt
? off
: 0, eiaf
->shlstoff
);
8714 bfd_putl32 (shrimg_cnt
, eiaf
->shrimgcnt
);
8715 bfd_putl32 (0, eiaf
->shlextra
);
8716 bfd_putl32 (0, eiaf
->permctx
);
8717 bfd_putl32 (0, eiaf
->base_va
);
8718 bfd_putl32 (0, eiaf
->lppsbfixoff
);
8725 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8727 struct alpha_vms_shlib_el
*shlib
;
8728 struct vms_shl
*shl
;
8730 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8732 if (!shlib
->has_fixups
)
8735 /* Renumber shared images. */
8736 PRIV2 (shlib
->abfd
, shr_index
) = shrimg_cnt
++;
8738 shl
= (struct vms_shl
*)(content
+ off
);
8739 bfd_putl32 (0, shl
->baseva
);
8740 bfd_putl32 (0, shl
->shlptr
);
8741 bfd_putl32 (0, shl
->ident
);
8742 bfd_putl32 (0, shl
->permctx
);
8743 shl
->size
= sizeof (struct vms_shl
);
8744 bfd_putl16 (0, shl
->fill_1
);
8746 bfd_putl32 (0, shl
->icb
);
8747 shl
->imgnam
[0] = strlen (PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
));
8748 memcpy (shl
->imgnam
+ 1, PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
),
8751 off
+= sizeof (struct vms_shl
);
8757 bfd_putl32 (off
, eiaf
->codeadroff
);
8759 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8761 struct alpha_vms_shlib_el
*shlib
;
8764 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8766 if (VEC_COUNT (shlib
->ca
) == 0)
8769 bfd_putl32 (VEC_COUNT (shlib
->ca
), content
+ off
);
8770 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8773 for (j
= 0; j
< VEC_COUNT (shlib
->ca
); j
++)
8775 bfd_putl32 (VEC_EL (shlib
->ca
, bfd_vma
, j
) - t
->base_addr
,
8781 bfd_putl32 (0, content
+ off
);
8782 bfd_putl32 (0, content
+ off
+ 4);
8789 bfd_putl32 (off
, eiaf
->lpfixoff
);
8791 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8793 struct alpha_vms_shlib_el
*shlib
;
8796 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8798 if (VEC_COUNT (shlib
->lp
) == 0)
8801 bfd_putl32 (VEC_COUNT (shlib
->lp
), content
+ off
);
8802 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8805 for (j
= 0; j
< VEC_COUNT (shlib
->lp
); j
++)
8807 bfd_putl32 (VEC_EL (shlib
->lp
, bfd_vma
, j
) - t
->base_addr
,
8813 bfd_putl32 (0, content
+ off
);
8814 bfd_putl32 (0, content
+ off
+ 4);
8821 bfd_putl32 (off
, eiaf
->qdotadroff
);
8823 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8825 struct alpha_vms_shlib_el
*shlib
;
8828 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8830 if (VEC_COUNT (shlib
->qr
) == 0)
8833 bfd_putl32 (VEC_COUNT (shlib
->qr
), content
+ off
);
8834 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8837 for (j
= 0; j
< VEC_COUNT (shlib
->qr
); j
++)
8839 struct alpha_vms_vma_ref
*r
;
8840 r
= &VEC_EL (shlib
->qr
, struct alpha_vms_vma_ref
, j
);
8841 bfd_putl32 (r
->vma
- t
->base_addr
, content
+ off
);
8842 bfd_putl32 (r
->ref
, content
+ off
+ 4);
8847 bfd_putl32 (0, content
+ off
);
8848 bfd_putl32 (0, content
+ off
+ 4);
8853 /* Write the change protection table. */
8854 bfd_putl32 (off
, eiaf
->chgprtoff
);
8855 bfd_putl32 (chgprt_num
, content
+ off
);
8858 for (sec
= info
->output_bfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
8860 struct vms_eicp
*eicp
;
8863 if ((sec
->flags
& SEC_LINKER_CREATED
) != 0 &&
8864 strcmp (sec
->name
, "$FIXUP$") == 0)
8866 else if ((sec
->flags
& SEC_RELOC
) != 0
8867 && (sec
->flags
& (SEC_CODE
| SEC_READONLY
)) != 0)
8872 eicp
= (struct vms_eicp
*)(content
+ off
);
8873 bfd_putl64 (sec
->vma
- t
->base_addr
, eicp
->baseva
);
8874 bfd_putl32 ((sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1),
8876 bfd_putl32 (prot
, eicp
->newprt
);
8877 off
+= sizeof (struct vms_eicp
);
8883 /* Called by bfd_hash_traverse to fill the symbol table.
8884 Return FALSE in case of failure. */
8887 alpha_vms_link_output_symbol (struct bfd_hash_entry
*bh
, void *infov
)
8889 struct bfd_link_hash_entry
*hc
= (struct bfd_link_hash_entry
*) bh
;
8890 struct bfd_link_info
*info
= (struct bfd_link_info
*)infov
;
8891 struct alpha_vms_link_hash_entry
*h
;
8892 struct vms_symbol_entry
*sym
;
8894 if (hc
->type
== bfd_link_hash_warning
)
8897 if (hc
->type
== bfd_link_hash_new
)
8900 h
= (struct alpha_vms_link_hash_entry
*) hc
;
8902 switch (h
->root
.type
)
8904 case bfd_link_hash_undefined
:
8906 case bfd_link_hash_new
:
8907 case bfd_link_hash_warning
:
8909 case bfd_link_hash_undefweak
:
8911 case bfd_link_hash_defined
:
8912 case bfd_link_hash_defweak
:
8914 asection
*sec
= h
->root
.u
.def
.section
;
8916 /* FIXME: this is certainly a symbol from a dynamic library. */
8917 if (bfd_is_abs_section (sec
))
8920 if (sec
->owner
->flags
& DYNAMIC
)
8924 case bfd_link_hash_common
:
8926 case bfd_link_hash_indirect
:
8930 /* Do not write not kept symbols. */
8931 if (info
->strip
== strip_some
8932 && bfd_hash_lookup (info
->keep_hash
, h
->root
.root
.string
,
8933 FALSE
, FALSE
) != NULL
)
8938 /* This symbol doesn't come from a VMS object. So we suppose it is
8940 int len
= strlen (h
->root
.root
.string
);
8942 sym
= (struct vms_symbol_entry
*)bfd_zalloc (info
->output_bfd
,
8943 sizeof (*sym
) + len
);
8947 memcpy (sym
->name
, h
->root
.root
.string
, len
);
8949 sym
->owner
= info
->output_bfd
;
8951 sym
->typ
= EGSD__C_SYMG
;
8953 sym
->flags
= EGSY__V_DEF
| EGSY__V_REL
;
8954 sym
->symbol_vector
= h
->root
.u
.def
.value
;
8955 sym
->section
= h
->root
.u
.def
.section
;
8956 sym
->value
= h
->root
.u
.def
.value
;
8961 if (!add_symbol_entry (info
->output_bfd
, sym
))
8968 alpha_vms_bfd_final_link (bfd
*abfd
, struct bfd_link_info
*info
)
8971 struct bfd_link_order
*p
;
8979 if (bfd_link_relocatable (info
))
8981 /* FIXME: we do not yet support relocatable link. It is not obvious
8982 how to do it for debug infos. */
8983 (*info
->callbacks
->einfo
)(_("%P: relocatable link is not supported\n"));
8987 abfd
->outsymbols
= NULL
;
8990 /* Mark all sections which will be included in the output file. */
8991 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8992 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
8993 if (p
->type
== bfd_indirect_link_order
)
8994 p
->u
.indirect
.section
->linker_mark
= TRUE
;
8997 /* Handle all the link order information for the sections. */
8998 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9000 printf ("For section %s (at 0x%08x, flags=0x%08x):\n",
9001 o
->name
, (unsigned)o
->vma
, (unsigned)o
->flags
);
9003 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
9005 printf (" at 0x%08x - 0x%08x: ",
9006 (unsigned)p
->offset
, (unsigned)(p
->offset
+ p
->size
- 1));
9009 case bfd_section_reloc_link_order
:
9010 case bfd_symbol_reloc_link_order
:
9011 printf (" section/symbol reloc\n");
9013 case bfd_indirect_link_order
:
9014 printf (" section %s of %s\n",
9015 p
->u
.indirect
.section
->name
,
9016 p
->u
.indirect
.section
->owner
->filename
);
9018 case bfd_data_link_order
:
9019 printf (" explicit data\n");
9022 printf (" *unknown* type %u\n", p
->type
);
9029 /* Generate the symbol table. */
9030 BFD_ASSERT (PRIV (syms
) == NULL
);
9031 if (info
->strip
!= strip_all
)
9032 bfd_hash_traverse (&info
->hash
->table
, alpha_vms_link_output_symbol
, info
);
9034 /* Find the entry point. */
9035 if (bfd_get_start_address (abfd
) == 0)
9037 bfd
*startbfd
= NULL
;
9039 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9041 /* Consider only VMS object files. */
9042 if (sub
->xvec
!= abfd
->xvec
)
9045 if (!PRIV2 (sub
, eom_data
).eom_has_transfer
)
9047 if ((PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
) && startbfd
)
9049 if (startbfd
!= NULL
9050 && !(PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
))
9052 (*info
->callbacks
->einfo
)
9053 /* xgettext:c-format */
9054 (_("%P: multiple entry points: in modules %pB and %pB\n"),
9063 unsigned int ps_idx
= PRIV2 (startbfd
, eom_data
).eom_l_psindx
;
9064 bfd_vma tfradr
= PRIV2 (startbfd
, eom_data
).eom_l_tfradr
;
9067 sec
= PRIV2 (startbfd
, sections
)[ps_idx
];
9069 bfd_set_start_address
9070 (abfd
, sec
->output_section
->vma
+ sec
->output_offset
+ tfradr
);
9074 /* Set transfer addresses. */
9077 struct bfd_link_hash_entry
*h
;
9080 PRIV (transfer_address
[i
++]) = 0xffffffff00000340ULL
; /* SYS$IMGACT */
9081 h
= bfd_link_hash_lookup (info
->hash
, "LIB$INITIALIZE", FALSE
, FALSE
, TRUE
);
9082 if (h
!= NULL
&& h
->type
== bfd_link_hash_defined
)
9083 PRIV (transfer_address
[i
++]) =
9084 alpha_vms_get_sym_value (h
->u
.def
.section
, h
->u
.def
.value
);
9085 PRIV (transfer_address
[i
++]) = bfd_get_start_address (abfd
);
9087 PRIV (transfer_address
[i
++]) = 0;
9090 /* Allocate contents.
9091 Also compute the virtual base address. */
9092 base_addr
= (bfd_vma
)-1;
9094 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9096 if (o
->flags
& SEC_HAS_CONTENTS
)
9098 o
->contents
= bfd_alloc (abfd
, o
->size
);
9099 if (o
->contents
== NULL
)
9102 if (o
->flags
& SEC_LOAD
)
9104 if (o
->vma
< base_addr
)
9106 if (o
->vma
+ o
->size
> last_addr
)
9107 last_addr
= o
->vma
+ o
->size
;
9109 /* Clear the RELOC flags. Currently we don't support incremental
9110 linking. We use the RELOC flag for computing the eicp entries. */
9111 o
->flags
&= ~SEC_RELOC
;
9114 /* Create the fixup section. */
9115 fixupsec
= bfd_make_section_anyway_with_flags
9116 (info
->output_bfd
, "$FIXUP$",
9117 SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
9118 if (fixupsec
== NULL
)
9120 last_addr
= (last_addr
+ 0xffff) & ~0xffff;
9121 fixupsec
->vma
= last_addr
;
9123 alpha_vms_link_hash (info
)->fixup
= fixupsec
;
9124 alpha_vms_link_hash (info
)->base_addr
= base_addr
;
9126 /* Create the DMT section, if necessary. */
9127 BFD_ASSERT (PRIV (dst_section
) == NULL
);
9128 dst
= bfd_get_section_by_name (abfd
, "$DST$");
9129 if (dst
!= NULL
&& dst
->size
== 0)
9133 PRIV (dst_section
) = dst
;
9134 dmt
= bfd_make_section_anyway_with_flags
9135 (info
->output_bfd
, "$DMT$",
9136 SEC_DEBUGGING
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
9143 /* Read all sections from the inputs. */
9144 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9146 if (sub
->flags
& DYNAMIC
)
9148 alpha_vms_create_eisd_for_shared (abfd
, sub
);
9152 if (!alpha_vms_read_sections_content (sub
, info
))
9156 /* Handle all the link order information for the sections.
9157 Note: past this point, it is not possible to create new sections. */
9158 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9160 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
9164 case bfd_section_reloc_link_order
:
9165 case bfd_symbol_reloc_link_order
:
9168 case bfd_indirect_link_order
:
9172 if (! _bfd_default_link_order (abfd
, info
, o
, p
))
9179 /* Compute fixups. */
9180 if (!alpha_vms_build_fixups (info
))
9183 /* Compute the DMT. */
9187 unsigned char *contents
= NULL
;
9189 /* In pass 1, compute the size. In pass 2, write the DMT contents. */
9190 for (pass
= 0; pass
< 2; pass
++)
9192 unsigned int off
= 0;
9194 /* For each object file (ie for each module). */
9195 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9198 struct vms_dmt_header
*dmth
= NULL
;
9199 unsigned int psect_count
;
9201 /* Skip this module if it has no DST. */
9202 sub_dst
= PRIV2 (sub
, dst_section
);
9203 if (sub_dst
== NULL
|| sub_dst
->size
== 0)
9208 /* Write the header. */
9209 dmth
= (struct vms_dmt_header
*)(contents
+ off
);
9210 bfd_putl32 (sub_dst
->output_offset
, dmth
->modbeg
);
9211 bfd_putl32 (sub_dst
->size
, dmth
->size
);
9214 off
+= sizeof (struct vms_dmt_header
);
9217 /* For each section (ie for each psect). */
9218 for (o
= sub
->sections
; o
!= NULL
; o
= o
->next
)
9220 /* Only consider interesting sections. */
9221 if (!(o
->flags
& SEC_ALLOC
))
9223 if (o
->flags
& SEC_LINKER_CREATED
)
9228 /* Write an entry. */
9229 struct vms_dmt_psect
*dmtp
;
9231 dmtp
= (struct vms_dmt_psect
*)(contents
+ off
);
9232 bfd_putl32 (o
->output_offset
+ o
->output_section
->vma
,
9234 bfd_putl32 (o
->size
, dmtp
->length
);
9237 off
+= sizeof (struct vms_dmt_psect
);
9240 bfd_putl32 (psect_count
, dmth
->psect_count
);
9245 contents
= bfd_zalloc (info
->output_bfd
, off
);
9246 if (contents
== NULL
)
9248 dmt
->contents
= contents
;
9253 BFD_ASSERT (off
== dmt
->size
);
9261 /* Read the contents of a section.
9262 buf points to a buffer of buf_size bytes to be filled with
9263 section data (starting at offset into section) */
9266 alpha_vms_get_section_contents (bfd
*abfd
, asection
*section
,
9267 void *buf
, file_ptr offset
,
9268 bfd_size_type count
)
9272 /* Image are easy. */
9273 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
9274 return _bfd_generic_get_section_contents (abfd
, section
,
9275 buf
, offset
, count
);
9278 if (offset
+ count
< count
9279 || offset
+ count
> section
->size
)
9281 bfd_set_error (bfd_error_invalid_operation
);
9285 /* If the section is already in memory, just copy it. */
9286 if (section
->flags
& SEC_IN_MEMORY
)
9288 BFD_ASSERT (section
->contents
!= NULL
);
9289 memcpy (buf
, section
->contents
+ offset
, count
);
9292 if (section
->size
== 0)
9295 /* Alloc in memory and read ETIRs. */
9296 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
9298 BFD_ASSERT (sec
->contents
== NULL
);
9300 if (sec
->size
!= 0 && (sec
->flags
& SEC_HAS_CONTENTS
))
9302 sec
->contents
= bfd_alloc (abfd
, sec
->size
);
9303 if (sec
->contents
== NULL
)
9307 if (!alpha_vms_read_sections_content (abfd
, NULL
))
9309 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
9311 sec
->flags
|= SEC_IN_MEMORY
;
9312 memcpy (buf
, section
->contents
+ offset
, count
);
9317 /* Set the format of a file being written. */
9320 alpha_vms_mkobject (bfd
* abfd
)
9322 const bfd_arch_info_type
*arch
;
9324 vms_debug2 ((1, "alpha_vms_mkobject (%p)\n", abfd
));
9326 if (!vms_initialize (abfd
))
9329 PRIV (recwr
.buf
) = bfd_alloc (abfd
, MAX_OUTREC_SIZE
);
9330 if (PRIV (recwr
.buf
) == NULL
)
9333 arch
= bfd_scan_arch ("alpha");
9337 bfd_set_error (bfd_error_wrong_format
);
9341 abfd
->arch_info
= arch
;
9348 /* Called when the BFD is being closed to do any necessary cleanup. */
9351 vms_close_and_cleanup (bfd
* abfd
)
9353 vms_debug2 ((1, "vms_close_and_cleanup (%p)\n", abfd
));
9355 if (abfd
== NULL
|| abfd
->tdata
.any
== NULL
)
9358 if (abfd
->format
== bfd_object
)
9360 alpha_vms_free_private (abfd
);
9363 if (abfd
->direction
== write_direction
)
9365 /* Last step on VMS is to convert the file to variable record length
9367 if (!bfd_cache_close (abfd
))
9369 if (!_bfd_vms_convert_to_var_unix_filename (abfd
->filename
))
9375 return _bfd_generic_close_and_cleanup (abfd
);
9378 /* Called when a new section is created. */
9381 vms_new_section_hook (bfd
* abfd
, asection
*section
)
9385 vms_debug2 ((1, "vms_new_section_hook (%p, [%u]%s)\n",
9386 abfd
, section
->index
, section
->name
));
9388 if (!bfd_set_section_alignment (section
, 0))
9391 vms_debug2 ((7, "%u: %s\n", section
->index
, section
->name
));
9393 amt
= sizeof (struct vms_section_data_struct
);
9394 section
->used_by_bfd
= bfd_zalloc (abfd
, amt
);
9395 if (section
->used_by_bfd
== NULL
)
9398 /* Create the section symbol. */
9399 return _bfd_generic_new_section_hook (abfd
, section
);
9402 /* Part 4.5, symbols. */
9404 /* Print symbol to file according to how. how is one of
9405 bfd_print_symbol_name just print the name
9406 bfd_print_symbol_more print more (???)
9407 bfd_print_symbol_all print all we know, which is not much right now :-). */
9410 vms_print_symbol (bfd
* abfd
,
9413 bfd_print_symbol_type how
)
9415 vms_debug2 ((1, "vms_print_symbol (%p, %p, %p, %d)\n",
9416 abfd
, file
, symbol
, how
));
9420 case bfd_print_symbol_name
:
9421 case bfd_print_symbol_more
:
9422 fprintf ((FILE *)file
," %s", symbol
->name
);
9425 case bfd_print_symbol_all
:
9427 const char *section_name
= symbol
->section
->name
;
9429 bfd_print_symbol_vandf (abfd
, file
, symbol
);
9431 fprintf ((FILE *) file
," %-8s %s", section_name
, symbol
->name
);
9437 /* Return information about symbol in ret.
9439 fill type, value and name
9442 B bss segment symbol
9444 D data segment symbol
9446 t a static function symbol
9447 T text segment symbol
9452 vms_get_symbol_info (bfd
* abfd ATTRIBUTE_UNUSED
,
9458 vms_debug2 ((1, "vms_get_symbol_info (%p, %p, %p)\n", abfd
, symbol
, ret
));
9460 sec
= symbol
->section
;
9467 else if (bfd_is_com_section (sec
))
9469 else if (bfd_is_abs_section (sec
))
9471 else if (bfd_is_und_section (sec
))
9473 else if (bfd_is_ind_section (sec
))
9475 else if ((symbol
->flags
& BSF_FUNCTION
)
9476 || (bfd_section_flags (sec
) & SEC_CODE
))
9478 else if (bfd_section_flags (sec
) & SEC_DATA
)
9480 else if (bfd_section_flags (sec
) & SEC_ALLOC
)
9485 if (ret
->type
!= 'U')
9486 ret
->value
= symbol
->value
+ symbol
->section
->vma
;
9489 ret
->name
= symbol
->name
;
9492 /* Return TRUE if the given symbol sym in the BFD abfd is
9493 a compiler generated local label, else return FALSE. */
9496 vms_bfd_is_local_label_name (bfd
* abfd ATTRIBUTE_UNUSED
,
9499 return name
[0] == '$';
9502 /* Part 4.7, writing an object file. */
9504 /* Sets the contents of the section section in BFD abfd to the data starting
9505 in memory at LOCATION. The data is written to the output section starting
9506 at offset offset for count bytes.
9508 Normally TRUE is returned, else FALSE. Possible error returns are:
9509 o bfd_error_no_contents - The output section does not have the
9510 SEC_HAS_CONTENTS attribute, so nothing can be written to it.
9511 o and some more too */
9514 _bfd_vms_set_section_contents (bfd
* abfd
,
9516 const void * location
,
9518 bfd_size_type count
)
9520 if (section
->contents
== NULL
)
9522 section
->contents
= bfd_alloc (abfd
, section
->size
);
9523 if (section
->contents
== NULL
)
9526 memcpy (section
->contents
+ offset
, location
, (size_t) count
);
9532 /* Set the architecture and machine type in BFD abfd to arch and mach.
9533 Find the correct pointer to a structure and insert it into the arch_info
9537 alpha_vms_set_arch_mach (bfd
*abfd
,
9538 enum bfd_architecture arch
, unsigned long mach
)
9540 if (arch
!= bfd_arch_alpha
9541 && arch
!= bfd_arch_unknown
)
9544 return bfd_default_set_arch_mach (abfd
, arch
, mach
);
9547 /* Set section VMS flags. Clear NO_FLAGS and set FLAGS. */
9550 bfd_vms_set_section_flags (bfd
*abfd ATTRIBUTE_UNUSED
,
9551 asection
*sec
, flagword no_flags
, flagword flags
)
9553 vms_section_data (sec
)->no_flags
= no_flags
;
9554 vms_section_data (sec
)->flags
= flags
;
9557 struct vms_private_data_struct
*
9558 bfd_vms_get_data (bfd
*abfd
)
9560 return (struct vms_private_data_struct
*)abfd
->tdata
.any
;
9563 #define vms_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false
9564 #define vms_bfd_link_just_syms _bfd_generic_link_just_syms
9565 #define vms_bfd_copy_link_hash_symbol_type \
9566 _bfd_generic_copy_link_hash_symbol_type
9567 #define vms_bfd_is_group_section bfd_generic_is_group_section
9568 #define vms_bfd_group_name bfd_generic_group_name
9569 #define vms_bfd_discard_group bfd_generic_discard_group
9570 #define vms_section_already_linked _bfd_generic_section_already_linked
9571 #define vms_bfd_define_common_symbol bfd_generic_define_common_symbol
9572 #define vms_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
9573 #define vms_bfd_define_start_stop bfd_generic_define_start_stop
9574 #define vms_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
9576 #define vms_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
9577 #define vms_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
9578 #define vms_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data
9579 #define vms_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
9580 #define vms_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
9581 #define vms_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
9583 /* Symbols table. */
9584 #define alpha_vms_make_empty_symbol _bfd_generic_make_empty_symbol
9585 #define alpha_vms_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false
9586 #define alpha_vms_print_symbol vms_print_symbol
9587 #define alpha_vms_get_symbol_info vms_get_symbol_info
9588 #define alpha_vms_get_symbol_version_string \
9589 _bfd_nosymbols_get_symbol_version_string
9591 #define alpha_vms_read_minisymbols _bfd_generic_read_minisymbols
9592 #define alpha_vms_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
9593 #define alpha_vms_get_lineno _bfd_nosymbols_get_lineno
9594 #define alpha_vms_find_inliner_info _bfd_nosymbols_find_inliner_info
9595 #define alpha_vms_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
9596 #define alpha_vms_find_nearest_line _bfd_vms_find_nearest_line
9597 #define alpha_vms_find_line _bfd_nosymbols_find_line
9598 #define alpha_vms_bfd_is_local_label_name vms_bfd_is_local_label_name
9600 /* Generic table. */
9601 #define alpha_vms_close_and_cleanup vms_close_and_cleanup
9602 #define alpha_vms_bfd_free_cached_info vms_bfd_free_cached_info
9603 #define alpha_vms_new_section_hook vms_new_section_hook
9604 #define alpha_vms_set_section_contents _bfd_vms_set_section_contents
9605 #define alpha_vms_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
9607 #define alpha_vms_bfd_get_relocated_section_contents \
9608 bfd_generic_get_relocated_section_contents
9610 #define alpha_vms_bfd_relax_section bfd_generic_relax_section
9611 #define alpha_vms_bfd_gc_sections bfd_generic_gc_sections
9612 #define alpha_vms_bfd_lookup_section_flags bfd_generic_lookup_section_flags
9613 #define alpha_vms_bfd_merge_sections bfd_generic_merge_sections
9614 #define alpha_vms_bfd_is_group_section bfd_generic_is_group_section
9615 #define alpha_vms_bfd_group_name bfd_generic_group_name
9616 #define alpha_vms_bfd_discard_group bfd_generic_discard_group
9617 #define alpha_vms_section_already_linked \
9618 _bfd_generic_section_already_linked
9620 #define alpha_vms_bfd_define_common_symbol bfd_generic_define_common_symbol
9621 #define alpha_vms_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
9622 #define alpha_vms_bfd_define_start_stop bfd_generic_define_start_stop
9623 #define alpha_vms_bfd_link_just_syms _bfd_generic_link_just_syms
9624 #define alpha_vms_bfd_copy_link_hash_symbol_type \
9625 _bfd_generic_copy_link_hash_symbol_type
9627 #define alpha_vms_bfd_link_split_section _bfd_generic_link_split_section
9629 #define alpha_vms_get_dynamic_symtab_upper_bound \
9630 _bfd_nodynamic_get_dynamic_symtab_upper_bound
9631 #define alpha_vms_canonicalize_dynamic_symtab \
9632 _bfd_nodynamic_canonicalize_dynamic_symtab
9633 #define alpha_vms_get_dynamic_reloc_upper_bound \
9634 _bfd_nodynamic_get_dynamic_reloc_upper_bound
9635 #define alpha_vms_canonicalize_dynamic_reloc \
9636 _bfd_nodynamic_canonicalize_dynamic_reloc
9637 #define alpha_vms_bfd_link_check_relocs _bfd_generic_link_check_relocs
9639 const bfd_target alpha_vms_vec
=
9641 "vms-alpha", /* Name. */
9642 bfd_target_evax_flavour
,
9643 BFD_ENDIAN_LITTLE
, /* Data byte order is little. */
9644 BFD_ENDIAN_LITTLE
, /* Header byte order is little. */
9646 (HAS_RELOC
| EXEC_P
| HAS_LINENO
| HAS_DEBUG
| HAS_SYMS
| HAS_LOCALS
9647 | WP_TEXT
| D_PAGED
), /* Object flags. */
9648 (SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
9649 | SEC_READONLY
| SEC_CODE
| SEC_DATA
9650 | SEC_HAS_CONTENTS
| SEC_IN_MEMORY
), /* Sect flags. */
9651 0, /* symbol_leading_char. */
9652 ' ', /* ar_pad_char. */
9653 15, /* ar_max_namelen. */
9654 0, /* match priority. */
9655 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
9656 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
9657 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
9658 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
9659 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
9660 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
9662 { /* bfd_check_format. */
9665 _bfd_vms_lib_alpha_archive_p
,
9668 { /* bfd_set_format. */
9669 _bfd_bool_bfd_false_error
,
9671 _bfd_vms_lib_alpha_mkarchive
,
9672 _bfd_bool_bfd_false_error
9674 { /* bfd_write_contents. */
9675 _bfd_bool_bfd_false_error
,
9676 alpha_vms_write_object_contents
,
9677 _bfd_vms_lib_write_archive_contents
,
9678 _bfd_bool_bfd_false_error
9681 BFD_JUMP_TABLE_GENERIC (alpha_vms
),
9682 BFD_JUMP_TABLE_COPY (vms
),
9683 BFD_JUMP_TABLE_CORE (_bfd_nocore
),
9684 BFD_JUMP_TABLE_ARCHIVE (_bfd_vms_lib
),
9685 BFD_JUMP_TABLE_SYMBOLS (alpha_vms
),
9686 BFD_JUMP_TABLE_RELOCS (alpha_vms
),
9687 BFD_JUMP_TABLE_WRITE (alpha_vms
),
9688 BFD_JUMP_TABLE_LINK (alpha_vms
),
9689 BFD_JUMP_TABLE_DYNAMIC (alpha_vms
),