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 /* Check the format for a file being read.
2638 Return a (bfd_target *) if it's an object file or zero if not. */
2640 static const struct bfd_target
*
2641 alpha_vms_object_p (bfd
*abfd
)
2643 void *tdata_save
= abfd
->tdata
.any
;
2644 unsigned int test_len
;
2647 vms_debug2 ((1, "vms_object_p(%p)\n", abfd
));
2649 /* Allocate alpha-vms specific data. */
2650 if (!vms_initialize (abfd
))
2653 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
))
2654 goto err_wrong_format
;
2656 /* The first challenge with VMS is to discover the kind of the file.
2658 Image files (executable or shared images) are stored as a raw
2659 stream of bytes (like on UNIX), but there is no magic number.
2661 Object files are written with RMS (record management service), ie
2662 each records are preceeded by its length (on a word - 2 bytes), and
2663 padded for word-alignment. That would be simple but when files
2664 are transfered to a UNIX filesystem (using ftp), records are lost.
2665 Only the raw content of the records are transfered. Fortunately,
2666 the Alpha Object file format also store the length of the record
2667 in the records. Is that clear ? */
2669 /* Minimum is 6 bytes for objects (2 bytes size, 2 bytes record id,
2670 2 bytes size repeated) and 12 bytes for images (4 bytes major id,
2671 4 bytes minor id, 4 bytes length). */
2674 /* Size the main buffer. */
2675 buf
= (unsigned char *) bfd_malloc (test_len
);
2678 PRIV (recrd
.buf
) = buf
;
2679 PRIV (recrd
.buf_size
) = test_len
;
2681 /* Initialize the record pointer. */
2682 PRIV (recrd
.rec
) = buf
;
2684 if (bfd_bread (buf
, test_len
, abfd
) != test_len
)
2685 goto err_wrong_format
;
2687 /* Is it an image? */
2688 if ((bfd_getl32 (buf
) == EIHD__K_MAJORID
)
2689 && (bfd_getl32 (buf
+ 4) == EIHD__K_MINORID
))
2691 unsigned int to_read
;
2692 unsigned int read_so_far
;
2693 unsigned int remaining
;
2694 unsigned int eisd_offset
, eihs_offset
;
2696 /* Extract the header size. */
2697 PRIV (recrd
.rec_size
) = bfd_getl32 (buf
+ EIHD__L_SIZE
);
2699 /* The header size is 0 for DSF files. */
2700 if (PRIV (recrd
.rec_size
) == 0)
2701 PRIV (recrd
.rec_size
) = sizeof (struct vms_eihd
);
2703 if (PRIV (recrd
.rec_size
) > PRIV (recrd
.buf_size
))
2705 buf
= bfd_realloc_or_free (buf
, PRIV (recrd
.rec_size
));
2709 PRIV (recrd
.buf
) = NULL
;
2712 PRIV (recrd
.buf
) = buf
;
2713 PRIV (recrd
.buf_size
) = PRIV (recrd
.rec_size
);
2716 /* PR 21813: Check for a truncated record. */
2717 if (PRIV (recrd
.rec_size
< test_len
))
2719 /* Read the remaining record. */
2720 remaining
= PRIV (recrd
.rec_size
) - test_len
;
2721 to_read
= MIN (VMS_BLOCK_SIZE
- test_len
, remaining
);
2722 read_so_far
= test_len
;
2724 while (remaining
> 0)
2726 if (bfd_bread (buf
+ read_so_far
, to_read
, abfd
) != to_read
)
2727 goto err_wrong_format
;
2729 read_so_far
+= to_read
;
2730 remaining
-= to_read
;
2732 to_read
= MIN (VMS_BLOCK_SIZE
, remaining
);
2735 /* Reset the record pointer. */
2736 PRIV (recrd
.rec
) = buf
;
2738 /* PR 17512: file: 7d7c57c2. */
2739 if (PRIV (recrd
.rec_size
) < sizeof (struct vms_eihd
))
2741 vms_debug2 ((2, "file type is image\n"));
2743 if (!_bfd_vms_slurp_eihd (abfd
, &eisd_offset
, &eihs_offset
))
2744 goto err_wrong_format
;
2746 if (!_bfd_vms_slurp_eisd (abfd
, eisd_offset
))
2747 goto err_wrong_format
;
2749 /* EIHS is optional. */
2750 if (eihs_offset
!= 0 && !_bfd_vms_slurp_eihs (abfd
, eihs_offset
))
2751 goto err_wrong_format
;
2757 /* Assume it's a module and adjust record pointer if necessary. */
2758 maybe_adjust_record_pointer_for_object (abfd
);
2760 /* But is it really a module? */
2761 if (bfd_getl16 (PRIV (recrd
.rec
)) <= EOBJ__C_MAXRECTYP
2762 && bfd_getl16 (PRIV (recrd
.rec
) + 2) <= EOBJ__C_MAXRECSIZ
)
2764 if (vms_get_remaining_object_record (abfd
, test_len
) <= 0)
2765 goto err_wrong_format
;
2767 vms_debug2 ((2, "file type is module\n"));
2769 type
= bfd_getl16 (PRIV (recrd
.rec
));
2770 if (type
!= EOBJ__C_EMH
|| !_bfd_vms_slurp_ehdr (abfd
))
2771 goto err_wrong_format
;
2773 if (!_bfd_vms_slurp_object_records (abfd
))
2774 goto err_wrong_format
;
2777 goto err_wrong_format
;
2780 /* Set arch_info to alpha. */
2782 if (! bfd_default_set_arch_mach (abfd
, bfd_arch_alpha
, 0))
2783 goto err_wrong_format
;
2788 bfd_set_error (bfd_error_wrong_format
);
2791 if (PRIV (recrd
.buf
))
2792 free (PRIV (recrd
.buf
));
2793 if (abfd
->tdata
.any
!= tdata_save
&& abfd
->tdata
.any
!= NULL
)
2794 bfd_release (abfd
, abfd
->tdata
.any
);
2795 abfd
->tdata
.any
= tdata_save
;
2801 /* Write an EMH/MHD record. */
2804 _bfd_vms_write_emh (bfd
*abfd
)
2806 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2808 _bfd_vms_output_alignment (recwr
, 2);
2811 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
2812 _bfd_vms_output_short (recwr
, EMH__C_MHD
);
2813 _bfd_vms_output_short (recwr
, EOBJ__C_STRLVL
);
2814 _bfd_vms_output_long (recwr
, 0);
2815 _bfd_vms_output_long (recwr
, 0);
2816 _bfd_vms_output_long (recwr
, MAX_OUTREC_SIZE
);
2818 /* Create module name from filename. */
2819 if (bfd_get_filename (abfd
) != 0)
2821 char *module
= vms_get_module_name (bfd_get_filename (abfd
), TRUE
);
2822 _bfd_vms_output_counted (recwr
, module
);
2826 _bfd_vms_output_counted (recwr
, "NONAME");
2828 _bfd_vms_output_counted (recwr
, BFD_VERSION_STRING
);
2829 _bfd_vms_output_dump (recwr
, get_vms_time_string (), EMH_DATE_LENGTH
);
2830 _bfd_vms_output_fill (recwr
, 0, EMH_DATE_LENGTH
);
2831 _bfd_vms_output_end (abfd
, recwr
);
2834 /* Write an EMH/LMN record. */
2837 _bfd_vms_write_lmn (bfd
*abfd
, const char *name
)
2840 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2841 unsigned int ver
= BFD_VERSION
/ 10000;
2844 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
2845 _bfd_vms_output_short (recwr
, EMH__C_LNM
);
2846 snprintf (version
, sizeof (version
), "%s %d.%d.%d", name
,
2847 ver
/ 10000, (ver
/ 100) % 100, ver
% 100);
2848 _bfd_vms_output_dump (recwr
, (unsigned char *)version
, strlen (version
));
2849 _bfd_vms_output_end (abfd
, recwr
);
2853 /* Write eom record for bfd abfd. Return FALSE on error. */
2856 _bfd_vms_write_eeom (bfd
*abfd
)
2858 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2860 vms_debug2 ((2, "vms_write_eeom\n"));
2862 _bfd_vms_output_alignment (recwr
, 2);
2864 _bfd_vms_output_begin (recwr
, EOBJ__C_EEOM
);
2865 _bfd_vms_output_long (recwr
, PRIV (vms_linkage_index
+ 1) >> 1);
2866 _bfd_vms_output_byte (recwr
, 0); /* Completion code. */
2867 _bfd_vms_output_byte (recwr
, 0); /* Fill byte. */
2869 if ((abfd
->flags
& EXEC_P
) == 0
2870 && bfd_get_start_address (abfd
) != (bfd_vma
)-1)
2874 section
= bfd_get_section_by_name (abfd
, ".link");
2877 bfd_set_error (bfd_error_nonrepresentable_section
);
2880 _bfd_vms_output_short (recwr
, 0);
2881 _bfd_vms_output_long (recwr
, (unsigned long) section
->target_index
);
2882 _bfd_vms_output_long (recwr
,
2883 (unsigned long) bfd_get_start_address (abfd
));
2884 _bfd_vms_output_long (recwr
, 0);
2887 _bfd_vms_output_end (abfd
, recwr
);
2892 vector_grow1 (struct vector_type
*vec
, size_t elsz
)
2894 if (vec
->nbr_el
+ 1 < vec
->max_el
)
2897 if (vec
->max_el
== 0)
2900 vec
->els
= bfd_malloc2 (vec
->max_el
, elsz
);
2905 vec
->els
= bfd_realloc2 (vec
->els
, vec
->max_el
, elsz
);
2909 /* Bump ABFD file position to next block. */
2912 alpha_vms_file_position_block (bfd
*abfd
)
2915 PRIV (file_pos
) += VMS_BLOCK_SIZE
- 1;
2916 PRIV (file_pos
) -= (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
2919 /* Convert from internal structure SRC to external structure DST. */
2922 alpha_vms_swap_eisd_out (struct vms_internal_eisd_map
*src
,
2923 struct vms_eisd
*dst
)
2925 bfd_putl32 (src
->u
.eisd
.majorid
, dst
->majorid
);
2926 bfd_putl32 (src
->u
.eisd
.minorid
, dst
->minorid
);
2927 bfd_putl32 (src
->u
.eisd
.eisdsize
, dst
->eisdsize
);
2928 if (src
->u
.eisd
.eisdsize
<= EISD__K_LENEND
)
2930 bfd_putl32 (src
->u
.eisd
.secsize
, dst
->secsize
);
2931 bfd_putl64 (src
->u
.eisd
.virt_addr
, dst
->virt_addr
);
2932 bfd_putl32 (src
->u
.eisd
.flags
, dst
->flags
);
2933 bfd_putl32 (src
->u
.eisd
.vbn
, dst
->vbn
);
2934 dst
->pfc
= src
->u
.eisd
.pfc
;
2935 dst
->matchctl
= src
->u
.eisd
.matchctl
;
2936 dst
->type
= src
->u
.eisd
.type
;
2938 if (src
->u
.eisd
.flags
& EISD__M_GBL
)
2940 bfd_putl32 (src
->u
.gbl_eisd
.ident
, dst
->ident
);
2941 memcpy (dst
->gblnam
, src
->u
.gbl_eisd
.gblnam
,
2942 src
->u
.gbl_eisd
.gblnam
[0] + 1);
2946 /* Append EISD to the list of extra eisd for ABFD. */
2949 alpha_vms_append_extra_eisd (bfd
*abfd
, struct vms_internal_eisd_map
*eisd
)
2952 if (PRIV (gbl_eisd_head
) == NULL
)
2953 PRIV (gbl_eisd_head
) = eisd
;
2955 PRIV (gbl_eisd_tail
)->next
= eisd
;
2956 PRIV (gbl_eisd_tail
) = eisd
;
2959 /* Create an EISD for shared image SHRIMG.
2960 Return FALSE in case of error. */
2963 alpha_vms_create_eisd_for_shared (bfd
*abfd
, bfd
*shrimg
)
2965 struct vms_internal_eisd_map
*eisd
;
2968 namlen
= strlen (PRIV2 (shrimg
, hdr_data
.hdr_t_name
));
2969 if (namlen
+ 5 > EISD__K_GBLNAMLEN
)
2975 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
2979 /* Fill the fields. */
2980 eisd
->u
.gbl_eisd
.common
.majorid
= EISD__K_MAJORID
;
2981 eisd
->u
.gbl_eisd
.common
.minorid
= EISD__K_MINORID
;
2982 eisd
->u
.gbl_eisd
.common
.eisdsize
= (EISD__K_LEN
+ 4 + namlen
+ 5 + 3) & ~3;
2983 eisd
->u
.gbl_eisd
.common
.secsize
= VMS_BLOCK_SIZE
; /* Must not be 0. */
2984 eisd
->u
.gbl_eisd
.common
.virt_addr
= 0;
2985 eisd
->u
.gbl_eisd
.common
.flags
= EISD__M_GBL
;
2986 eisd
->u
.gbl_eisd
.common
.vbn
= 0;
2987 eisd
->u
.gbl_eisd
.common
.pfc
= 0;
2988 eisd
->u
.gbl_eisd
.common
.matchctl
= PRIV2 (shrimg
, matchctl
);
2989 eisd
->u
.gbl_eisd
.common
.type
= EISD__K_SHRPIC
;
2991 eisd
->u
.gbl_eisd
.ident
= PRIV2 (shrimg
, ident
);
2992 eisd
->u
.gbl_eisd
.gblnam
[0] = namlen
+ 4;
2993 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1, PRIV2 (shrimg
, hdr_data
.hdr_t_name
),
2995 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1 + namlen
, "_001", 4);
2997 /* Append it to the list. */
2998 alpha_vms_append_extra_eisd (abfd
, eisd
);
3003 /* Create an EISD for section SEC.
3004 Return FALSE in case of failure. */
3007 alpha_vms_create_eisd_for_section (bfd
*abfd
, asection
*sec
)
3009 struct vms_internal_eisd_map
*eisd
;
3011 /* Only for allocating section. */
3012 if (!(sec
->flags
& SEC_ALLOC
))
3015 BFD_ASSERT (vms_section_data (sec
)->eisd
== NULL
);
3016 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
3019 vms_section_data (sec
)->eisd
= eisd
;
3021 /* Fill the fields. */
3022 eisd
->u
.eisd
.majorid
= EISD__K_MAJORID
;
3023 eisd
->u
.eisd
.minorid
= EISD__K_MINORID
;
3024 eisd
->u
.eisd
.eisdsize
= EISD__K_LEN
;
3025 eisd
->u
.eisd
.secsize
=
3026 (sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
3027 eisd
->u
.eisd
.virt_addr
= sec
->vma
;
3028 eisd
->u
.eisd
.flags
= 0;
3029 eisd
->u
.eisd
.vbn
= 0; /* To be later defined. */
3030 eisd
->u
.eisd
.pfc
= 0; /* Default. */
3031 eisd
->u
.eisd
.matchctl
= EISD__K_MATALL
;
3032 eisd
->u
.eisd
.type
= EISD__K_NORMAL
;
3034 if (sec
->flags
& SEC_CODE
)
3035 eisd
->u
.eisd
.flags
|= EISD__M_EXE
;
3036 if (!(sec
->flags
& SEC_READONLY
))
3037 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
3039 /* If relocations or fixup will be applied, make this isect writeable. */
3040 if (sec
->flags
& SEC_RELOC
)
3041 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
3043 if (!(sec
->flags
& SEC_HAS_CONTENTS
))
3045 eisd
->u
.eisd
.flags
|= EISD__M_DZRO
;
3046 eisd
->u
.eisd
.flags
&= ~EISD__M_CRF
;
3048 if (sec
->flags
& SEC_LINKER_CREATED
)
3050 if (strcmp (sec
->name
, "$FIXUP$") == 0)
3051 eisd
->u
.eisd
.flags
|= EISD__M_FIXUPVEC
;
3054 /* Append it to the list. */
3056 if (PRIV (eisd_head
) == NULL
)
3057 PRIV (eisd_head
) = eisd
;
3059 PRIV (eisd_tail
)->next
= eisd
;
3060 PRIV (eisd_tail
) = eisd
;
3065 /* Layout executable ABFD and write it to the disk.
3066 Return FALSE in case of failure. */
3069 alpha_vms_write_exec (bfd
*abfd
)
3071 struct vms_eihd eihd
;
3072 struct vms_eiha
*eiha
;
3073 struct vms_eihi
*eihi
;
3074 struct vms_eihs
*eihs
= NULL
;
3076 struct vms_internal_eisd_map
*first_eisd
;
3077 struct vms_internal_eisd_map
*eisd
;
3080 file_ptr gst_filepos
= 0;
3081 unsigned int lnkflags
= 0;
3083 /* Build the EIHD. */
3084 PRIV (file_pos
) = EIHD__C_LENGTH
;
3086 memset (&eihd
, 0, sizeof (eihd
));
3087 memset (eihd
.fill_2
, 0xff, sizeof (eihd
.fill_2
));
3089 bfd_putl32 (EIHD__K_MAJORID
, eihd
.majorid
);
3090 bfd_putl32 (EIHD__K_MINORID
, eihd
.minorid
);
3092 bfd_putl32 (sizeof (eihd
), eihd
.size
);
3093 bfd_putl32 (0, eihd
.isdoff
);
3094 bfd_putl32 (0, eihd
.activoff
);
3095 bfd_putl32 (0, eihd
.symdbgoff
);
3096 bfd_putl32 (0, eihd
.imgidoff
);
3097 bfd_putl32 (0, eihd
.patchoff
);
3098 bfd_putl64 (0, eihd
.iafva
);
3099 bfd_putl32 (0, eihd
.version_array_off
);
3101 bfd_putl32 (EIHD__K_EXE
, eihd
.imgtype
);
3102 bfd_putl32 (0, eihd
.subtype
);
3104 bfd_putl32 (0, eihd
.imgiocnt
);
3105 bfd_putl32 (-1, eihd
.privreqs
);
3106 bfd_putl32 (-1, eihd
.privreqs
+ 4);
3108 bfd_putl32 ((sizeof (eihd
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
3110 bfd_putl32 (0, eihd
.ident
);
3111 bfd_putl32 (0, eihd
.sysver
);
3114 bfd_putl32 (0, eihd
.symvect_size
);
3115 bfd_putl32 (16, eihd
.virt_mem_block_size
);
3116 bfd_putl32 (0, eihd
.ext_fixup_off
);
3117 bfd_putl32 (0, eihd
.noopt_psect_off
);
3118 bfd_putl32 (-1, eihd
.alias
);
3121 eiha
= (struct vms_eiha
*)((char *) &eihd
+ PRIV (file_pos
));
3122 bfd_putl32 (PRIV (file_pos
), eihd
.activoff
);
3123 PRIV (file_pos
) += sizeof (struct vms_eiha
);
3125 bfd_putl32 (sizeof (struct vms_eiha
), eiha
->size
);
3126 bfd_putl32 (0, eiha
->spare
);
3127 bfd_putl64 (PRIV (transfer_address
[0]), eiha
->tfradr1
);
3128 bfd_putl64 (PRIV (transfer_address
[1]), eiha
->tfradr2
);
3129 bfd_putl64 (PRIV (transfer_address
[2]), eiha
->tfradr3
);
3130 bfd_putl64 (PRIV (transfer_address
[3]), eiha
->tfradr4
);
3131 bfd_putl64 (0, eiha
->inishr
);
3134 eihi
= (struct vms_eihi
*)((char *) &eihd
+ PRIV (file_pos
));
3135 bfd_putl32 (PRIV (file_pos
), eihd
.imgidoff
);
3136 PRIV (file_pos
) += sizeof (struct vms_eihi
);
3138 bfd_putl32 (EIHI__K_MAJORID
, eihi
->majorid
);
3139 bfd_putl32 (EIHI__K_MINORID
, eihi
->minorid
);
3144 /* Set module name. */
3145 module
= vms_get_module_name (bfd_get_filename (abfd
), TRUE
);
3146 len
= strlen (module
);
3147 if (len
> sizeof (eihi
->imgnam
) - 1)
3148 len
= sizeof (eihi
->imgnam
) - 1;
3149 eihi
->imgnam
[0] = len
;
3150 memcpy (eihi
->imgnam
+ 1, module
, len
);
3158 vms_get_time (&hi
, &lo
);
3159 bfd_putl32 (lo
, eihi
->linktime
+ 0);
3160 bfd_putl32 (hi
, eihi
->linktime
+ 4);
3163 eihi
->linkid
[0] = 0;
3164 eihi
->imgbid
[0] = 0;
3167 dst
= PRIV (dst_section
);
3168 dmt
= bfd_get_section_by_name (abfd
, "$DMT$");
3169 if (dst
!= NULL
&& dst
->size
!= 0)
3171 eihs
= (struct vms_eihs
*)((char *) &eihd
+ PRIV (file_pos
));
3172 bfd_putl32 (PRIV (file_pos
), eihd
.symdbgoff
);
3173 PRIV (file_pos
) += sizeof (struct vms_eihs
);
3175 bfd_putl32 (EIHS__K_MAJORID
, eihs
->majorid
);
3176 bfd_putl32 (EIHS__K_MINORID
, eihs
->minorid
);
3177 bfd_putl32 (0, eihs
->dstvbn
);
3178 bfd_putl32 (0, eihs
->dstsize
);
3179 bfd_putl32 (0, eihs
->gstvbn
);
3180 bfd_putl32 (0, eihs
->gstsize
);
3181 bfd_putl32 (0, eihs
->dmtvbn
);
3182 bfd_putl32 (0, eihs
->dmtsize
);
3185 /* One EISD per section. */
3186 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3188 if (!alpha_vms_create_eisd_for_section (abfd
, sec
))
3192 /* Merge section EIDS which extra ones. */
3193 if (PRIV (eisd_tail
))
3194 PRIV (eisd_tail
)->next
= PRIV (gbl_eisd_head
);
3196 PRIV (eisd_head
) = PRIV (gbl_eisd_head
);
3197 if (PRIV (gbl_eisd_tail
))
3198 PRIV (eisd_tail
) = PRIV (gbl_eisd_tail
);
3200 first_eisd
= PRIV (eisd_head
);
3202 /* Add end of eisd. */
3205 eisd
= bfd_zalloc (abfd
, sizeof (*eisd
));
3208 eisd
->u
.eisd
.majorid
= 0;
3209 eisd
->u
.eisd
.minorid
= 0;
3210 eisd
->u
.eisd
.eisdsize
= 0;
3211 alpha_vms_append_extra_eisd (abfd
, eisd
);
3214 /* Place EISD in the file. */
3215 for (eisd
= first_eisd
; eisd
; eisd
= eisd
->next
)
3217 file_ptr room
= VMS_BLOCK_SIZE
- (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
3219 /* First block is a little bit special: there is a word at the end. */
3220 if (PRIV (file_pos
) < VMS_BLOCK_SIZE
&& room
> 2)
3222 if (room
< eisd
->u
.eisd
.eisdsize
+ EISD__K_LENEND
)
3223 alpha_vms_file_position_block (abfd
);
3225 eisd
->file_pos
= PRIV (file_pos
);
3226 PRIV (file_pos
) += eisd
->u
.eisd
.eisdsize
;
3228 if (eisd
->u
.eisd
.flags
& EISD__M_FIXUPVEC
)
3229 bfd_putl64 (eisd
->u
.eisd
.virt_addr
, eihd
.iafva
);
3232 if (first_eisd
!= NULL
)
3234 bfd_putl32 (first_eisd
->file_pos
, eihd
.isdoff
);
3235 /* Real size of end of eisd marker. */
3236 PRIV (file_pos
) += EISD__K_LENEND
;
3239 bfd_putl32 (PRIV (file_pos
), eihd
.size
);
3240 bfd_putl32 ((PRIV (file_pos
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
3243 /* Place sections. */
3244 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3246 if (!(sec
->flags
& SEC_HAS_CONTENTS
))
3249 eisd
= vms_section_data (sec
)->eisd
;
3251 /* Align on a block. */
3252 alpha_vms_file_position_block (abfd
);
3253 sec
->filepos
= PRIV (file_pos
);
3256 eisd
->u
.eisd
.vbn
= (sec
->filepos
/ VMS_BLOCK_SIZE
) + 1;
3258 PRIV (file_pos
) += sec
->size
;
3262 if (eihs
!= NULL
&& dst
!= NULL
)
3264 bfd_putl32 ((dst
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dstvbn
);
3265 bfd_putl32 (dst
->size
, eihs
->dstsize
);
3269 lnkflags
|= EIHD__M_DBGDMT
;
3270 bfd_putl32 ((dmt
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dmtvbn
);
3271 bfd_putl32 (dmt
->size
, eihs
->dmtsize
);
3273 if (PRIV (gsd_sym_count
) != 0)
3275 alpha_vms_file_position_block (abfd
);
3276 gst_filepos
= PRIV (file_pos
);
3277 bfd_putl32 ((gst_filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->gstvbn
);
3278 bfd_putl32 ((PRIV (gsd_sym_count
) + 4) / 5 + 4, eihs
->gstsize
);
3282 /* Write EISD in hdr. */
3283 for (eisd
= first_eisd
; eisd
&& eisd
->file_pos
< VMS_BLOCK_SIZE
;
3285 alpha_vms_swap_eisd_out
3286 (eisd
, (struct vms_eisd
*)((char *)&eihd
+ eisd
->file_pos
));
3288 /* Write first block. */
3289 bfd_putl32 (lnkflags
, eihd
.lnkflags
);
3290 if (bfd_bwrite (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
3293 /* Write remaining eisd. */
3296 unsigned char blk
[VMS_BLOCK_SIZE
];
3297 struct vms_internal_eisd_map
*next_eisd
;
3299 memset (blk
, 0xff, sizeof (blk
));
3300 while (eisd
!= NULL
)
3302 alpha_vms_swap_eisd_out
3304 (struct vms_eisd
*)(blk
+ (eisd
->file_pos
% VMS_BLOCK_SIZE
)));
3306 next_eisd
= eisd
->next
;
3307 if (next_eisd
== NULL
3308 || (next_eisd
->file_pos
/ VMS_BLOCK_SIZE
3309 != eisd
->file_pos
/ VMS_BLOCK_SIZE
))
3311 if (bfd_bwrite (blk
, sizeof (blk
), abfd
) != sizeof (blk
))
3314 memset (blk
, 0xff, sizeof (blk
));
3320 /* Write sections. */
3321 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3323 unsigned char blk
[VMS_BLOCK_SIZE
];
3326 if (sec
->size
== 0 || !(sec
->flags
& SEC_HAS_CONTENTS
))
3328 if (bfd_bwrite (sec
->contents
, sec
->size
, abfd
) != sec
->size
)
3332 len
= VMS_BLOCK_SIZE
- sec
->size
% VMS_BLOCK_SIZE
;
3333 if (len
!= VMS_BLOCK_SIZE
)
3335 memset (blk
, 0, len
);
3336 if (bfd_bwrite (blk
, len
, abfd
) != len
)
3342 if (gst_filepos
!= 0)
3344 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3347 _bfd_vms_write_emh (abfd
);
3348 _bfd_vms_write_lmn (abfd
, "GNU LD");
3350 /* PSC for the absolute section. */
3351 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3352 _bfd_vms_output_long (recwr
, 0);
3353 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3354 _bfd_vms_output_short (recwr
, 0);
3355 _bfd_vms_output_short (recwr
, EGPS__V_PIC
| EGPS__V_LIB
| EGPS__V_RD
);
3356 _bfd_vms_output_long (recwr
, 0);
3357 _bfd_vms_output_counted (recwr
, ".$$ABS$$.");
3358 _bfd_vms_output_end_subrec (recwr
);
3359 _bfd_vms_output_end (abfd
, recwr
);
3361 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
3363 struct vms_symbol_entry
*sym
= PRIV (syms
)[i
];
3369 _bfd_vms_output_alignment (recwr
, 8);
3370 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3371 _bfd_vms_output_long (recwr
, 0);
3373 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYMG
);
3374 _bfd_vms_output_short (recwr
, 0); /* Data type, alignment. */
3375 _bfd_vms_output_short (recwr
, sym
->flags
);
3377 if (sym
->code_section
)
3378 ep
= alpha_vms_get_sym_value (sym
->code_section
, sym
->code_value
);
3381 BFD_ASSERT (sym
->code_value
== 0);
3384 val
= alpha_vms_get_sym_value (sym
->section
, sym
->value
);
3385 _bfd_vms_output_quad
3386 (recwr
, sym
->typ
== EGSD__C_SYMG
? sym
->symbol_vector
: val
);
3387 _bfd_vms_output_quad (recwr
, ep
);
3388 _bfd_vms_output_quad (recwr
, val
);
3389 _bfd_vms_output_long (recwr
, 0);
3390 _bfd_vms_output_counted (recwr
, sym
->name
);
3391 _bfd_vms_output_end_subrec (recwr
);
3393 _bfd_vms_output_end (abfd
, recwr
);
3396 _bfd_vms_output_end (abfd
, recwr
);
3398 if (!_bfd_vms_write_eeom (abfd
))
3406 /* Write section and symbol directory of bfd abfd. Return FALSE on error. */
3409 _bfd_vms_write_egsd (bfd
*abfd
)
3413 unsigned int symnum
;
3415 flagword new_flags
, old_flags
;
3416 int abs_section_index
= -1;
3417 unsigned int target_index
= 0;
3418 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3420 vms_debug2 ((2, "vms_write_egsd\n"));
3422 /* Egsd is quadword aligned. */
3423 _bfd_vms_output_alignment (recwr
, 8);
3425 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3426 _bfd_vms_output_long (recwr
, 0);
3428 /* Number sections. */
3429 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3431 if (section
->flags
& SEC_DEBUGGING
)
3433 if (!strcmp (section
->name
, ".vmsdebug"))
3435 section
->flags
|= SEC_DEBUGGING
;
3438 section
->target_index
= target_index
++;
3441 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3443 vms_debug2 ((3, "Section #%d %s, %d bytes\n",
3444 section
->target_index
, section
->name
, (int)section
->size
));
3446 /* Don't write out the VMS debug info section since it is in the
3447 ETBT and EDBG sections in etir. */
3448 if (section
->flags
& SEC_DEBUGGING
)
3451 /* 13 bytes egsd, max 31 chars name -> should be 44 bytes. */
3452 if (_bfd_vms_output_check (recwr
, 64) < 0)
3454 _bfd_vms_output_end (abfd
, recwr
);
3455 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3456 _bfd_vms_output_long (recwr
, 0);
3459 /* Don't know if this is necessary for the linker but for now it keeps
3460 vms_slurp_gsd happy. */
3461 sname
= section
->name
;
3464 /* Remove leading dot. */
3466 if ((*sname
== 't') && (strcmp (sname
, "text") == 0))
3467 sname
= EVAX_CODE_NAME
;
3468 else if ((*sname
== 'd') && (strcmp (sname
, "data") == 0))
3469 sname
= EVAX_DATA_NAME
;
3470 else if ((*sname
== 'b') && (strcmp (sname
, "bss") == 0))
3471 sname
= EVAX_BSS_NAME
;
3472 else if ((*sname
== 'l') && (strcmp (sname
, "link") == 0))
3473 sname
= EVAX_LINK_NAME
;
3474 else if ((*sname
== 'r') && (strcmp (sname
, "rdata") == 0))
3475 sname
= EVAX_READONLY_NAME
;
3476 else if ((*sname
== 'l') && (strcmp (sname
, "literal") == 0))
3477 sname
= EVAX_LITERAL_NAME
;
3478 else if ((*sname
== 'l') && (strcmp (sname
, "literals") == 0))
3479 sname
= EVAX_LITERALS_NAME
;
3480 else if ((*sname
== 'c') && (strcmp (sname
, "comm") == 0))
3481 sname
= EVAX_COMMON_NAME
;
3482 else if ((*sname
== 'l') && (strcmp (sname
, "lcomm") == 0))
3483 sname
= EVAX_LOCAL_NAME
;
3486 if (bfd_is_com_section (section
))
3487 new_flags
= (EGPS__V_OVR
| EGPS__V_REL
| EGPS__V_GBL
| EGPS__V_RD
3488 | EGPS__V_WRT
| EGPS__V_NOMOD
| EGPS__V_COM
);
3490 new_flags
= vms_esecflag_by_name (evax_section_flags
, sname
,
3493 /* Modify them as directed. */
3494 if (section
->flags
& SEC_READONLY
)
3495 new_flags
&= ~EGPS__V_WRT
;
3497 new_flags
&= ~vms_section_data (section
)->no_flags
;
3498 new_flags
|= vms_section_data (section
)->flags
;
3500 vms_debug2 ((3, "sec flags %x\n", section
->flags
));
3501 vms_debug2 ((3, "new_flags %x, _raw_size %lu\n",
3502 new_flags
, (unsigned long)section
->size
));
3504 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3505 _bfd_vms_output_short (recwr
, section
->alignment_power
& 0xff);
3506 _bfd_vms_output_short (recwr
, new_flags
);
3507 _bfd_vms_output_long (recwr
, (unsigned long) section
->size
);
3508 _bfd_vms_output_counted (recwr
, sname
);
3509 _bfd_vms_output_end_subrec (recwr
);
3511 /* If the section is an obsolute one, remind its index as it will be
3512 used later for absolute symbols. */
3513 if ((new_flags
& EGPS__V_REL
) == 0 && abs_section_index
< 0)
3514 abs_section_index
= section
->target_index
;
3517 /* Output symbols. */
3518 vms_debug2 ((3, "%d symbols found\n", abfd
->symcount
));
3520 bfd_set_start_address (abfd
, (bfd_vma
) -1);
3522 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3524 symbol
= abfd
->outsymbols
[symnum
];
3525 old_flags
= symbol
->flags
;
3527 /* Work-around a missing feature: consider __main as the main entry
3529 if (symbol
->name
[0] == '_' && strcmp (symbol
->name
, "__main") == 0)
3530 bfd_set_start_address (abfd
, (bfd_vma
)symbol
->value
);
3532 /* Only put in the GSD the global and the undefined symbols. */
3533 if (old_flags
& BSF_FILE
)
3536 if ((old_flags
& BSF_GLOBAL
) == 0 && !bfd_is_und_section (symbol
->section
))
3538 /* If the LIB$INITIIALIZE section is present, add a reference to
3539 LIB$INITIALIZE symbol. FIXME: this should be done explicitely
3540 in the assembly file. */
3541 if (!((old_flags
& BSF_SECTION_SYM
) != 0
3542 && strcmp (symbol
->section
->name
, "LIB$INITIALIZE") == 0))
3546 /* 13 bytes egsd, max 64 chars name -> should be 77 bytes. Add 16 more
3547 bytes for a possible ABS section. */
3548 if (_bfd_vms_output_check (recwr
, 80 + 16) < 0)
3550 _bfd_vms_output_end (abfd
, recwr
);
3551 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3552 _bfd_vms_output_long (recwr
, 0);
3555 if ((old_flags
& BSF_GLOBAL
) != 0
3556 && bfd_is_abs_section (symbol
->section
)
3557 && abs_section_index
<= 0)
3559 /* Create an absolute section if none was defined. It is highly
3560 unlikely that the name $ABS$ clashes with a user defined
3561 non-absolute section name. */
3562 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3563 _bfd_vms_output_short (recwr
, 4);
3564 _bfd_vms_output_short (recwr
, EGPS__V_SHR
);
3565 _bfd_vms_output_long (recwr
, 0);
3566 _bfd_vms_output_counted (recwr
, "$ABS$");
3567 _bfd_vms_output_end_subrec (recwr
);
3569 abs_section_index
= target_index
++;
3572 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYM
);
3574 /* Data type, alignment. */
3575 _bfd_vms_output_short (recwr
, 0);
3579 if (old_flags
& BSF_WEAK
)
3580 new_flags
|= EGSY__V_WEAK
;
3581 if (bfd_is_com_section (symbol
->section
)) /* .comm */
3582 new_flags
|= (EGSY__V_WEAK
| EGSY__V_COMM
);
3584 if (old_flags
& BSF_FUNCTION
)
3586 new_flags
|= EGSY__V_NORM
;
3587 new_flags
|= EGSY__V_REL
;
3589 if (old_flags
& BSF_GLOBAL
)
3591 new_flags
|= EGSY__V_DEF
;
3592 if (!bfd_is_abs_section (symbol
->section
))
3593 new_flags
|= EGSY__V_REL
;
3595 _bfd_vms_output_short (recwr
, new_flags
);
3597 if (old_flags
& BSF_GLOBAL
)
3599 /* Symbol definition. */
3600 bfd_vma code_address
= 0;
3601 unsigned long ca_psindx
= 0;
3602 unsigned long psindx
;
3604 if ((old_flags
& BSF_FUNCTION
) && symbol
->udata
.p
!= NULL
)
3609 ((struct evax_private_udata_struct
*)symbol
->udata
.p
)->enbsym
;
3610 code_address
= sym
->value
;
3611 ca_psindx
= sym
->section
->target_index
;
3613 if (bfd_is_abs_section (symbol
->section
))
3614 psindx
= abs_section_index
;
3616 psindx
= symbol
->section
->target_index
;
3618 _bfd_vms_output_quad (recwr
, symbol
->value
);
3619 _bfd_vms_output_quad (recwr
, code_address
);
3620 _bfd_vms_output_long (recwr
, ca_psindx
);
3621 _bfd_vms_output_long (recwr
, psindx
);
3623 _bfd_vms_output_counted (recwr
, symbol
->name
);
3625 _bfd_vms_output_end_subrec (recwr
);
3628 _bfd_vms_output_alignment (recwr
, 8);
3629 _bfd_vms_output_end (abfd
, recwr
);
3634 /* Write object header for bfd abfd. Return FALSE on error. */
3637 _bfd_vms_write_ehdr (bfd
*abfd
)
3640 unsigned int symnum
;
3641 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3643 vms_debug2 ((2, "vms_write_ehdr (%p)\n", abfd
));
3645 _bfd_vms_output_alignment (recwr
, 2);
3647 _bfd_vms_write_emh (abfd
);
3648 _bfd_vms_write_lmn (abfd
, "GNU AS");
3651 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3652 _bfd_vms_output_short (recwr
, EMH__C_SRC
);
3654 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3656 symbol
= abfd
->outsymbols
[symnum
];
3658 if (symbol
->flags
& BSF_FILE
)
3660 _bfd_vms_output_dump (recwr
, (unsigned char *) symbol
->name
,
3661 (int) strlen (symbol
->name
));
3666 if (symnum
== abfd
->symcount
)
3667 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("noname"));
3669 _bfd_vms_output_end (abfd
, recwr
);
3672 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3673 _bfd_vms_output_short (recwr
, EMH__C_TTL
);
3674 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("TTL"));
3675 _bfd_vms_output_end (abfd
, recwr
);
3678 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3679 _bfd_vms_output_short (recwr
, EMH__C_CPR
);
3680 _bfd_vms_output_dump (recwr
,
3681 (unsigned char *)"GNU BFD ported by Klaus Kämpf 1994-1996",
3683 _bfd_vms_output_end (abfd
, recwr
);
3688 /* Part 4.6, relocations. */
3691 /* WRITE ETIR SECTION
3693 This is still under construction and therefore not documented. */
3695 /* Close the etir/etbt record. */
3698 end_etir_record (bfd
* abfd
)
3700 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3702 _bfd_vms_output_end (abfd
, recwr
);
3706 start_etir_or_etbt_record (bfd
*abfd
, asection
*section
, bfd_vma offset
)
3708 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3710 if (section
->flags
& SEC_DEBUGGING
)
3712 _bfd_vms_output_begin (recwr
, EOBJ__C_ETBT
);
3716 /* Push start offset. */
3717 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3718 _bfd_vms_output_long (recwr
, (unsigned long) 0);
3719 _bfd_vms_output_end_subrec (recwr
);
3722 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_DFLOC
);
3723 _bfd_vms_output_end_subrec (recwr
);
3728 _bfd_vms_output_begin (recwr
, EOBJ__C_ETIR
);
3732 /* Push start offset. */
3733 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3734 _bfd_vms_output_long (recwr
, (unsigned long) section
->target_index
);
3735 _bfd_vms_output_quad (recwr
, offset
);
3736 _bfd_vms_output_end_subrec (recwr
);
3738 /* Start = pop (). */
3739 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_SETRB
);
3740 _bfd_vms_output_end_subrec (recwr
);
3745 /* Output a STO_IMM command for SSIZE bytes of data from CPR at virtual
3746 address VADDR in section specified by SEC_INDEX and NAME. */
3749 sto_imm (bfd
*abfd
, asection
*section
,
3750 bfd_size_type ssize
, unsigned char *cptr
, bfd_vma vaddr
)
3753 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3756 _bfd_vms_debug (8, "sto_imm %d bytes\n", (int) ssize
);
3757 _bfd_hexdump (9, cptr
, (int) ssize
, (int) vaddr
);
3762 /* Try all the rest. */
3765 if (_bfd_vms_output_check (recwr
, size
) < 0)
3767 /* Doesn't fit, split ! */
3768 end_etir_record (abfd
);
3770 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3772 size
= _bfd_vms_output_check (recwr
, 0); /* get max size */
3773 if (size
> ssize
) /* more than what's left ? */
3777 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_IMM
);
3778 _bfd_vms_output_long (recwr
, (unsigned long) (size
));
3779 _bfd_vms_output_dump (recwr
, cptr
, size
);
3780 _bfd_vms_output_end_subrec (recwr
);
3783 _bfd_vms_debug (10, "dumped %d bytes\n", (int) size
);
3784 _bfd_hexdump (10, cptr
, (int) size
, (int) vaddr
);
3794 etir_output_check (bfd
*abfd
, asection
*section
, bfd_vma vaddr
, int checklen
)
3796 if (_bfd_vms_output_check (&PRIV (recwr
), checklen
) < 0)
3798 /* Not enough room in this record. Close it and open a new one. */
3799 end_etir_record (abfd
);
3800 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3804 /* Return whether RELOC must be deferred till the end. */
3807 defer_reloc_p (arelent
*reloc
)
3809 switch (reloc
->howto
->type
)
3822 /* Write section contents for bfd abfd. Return FALSE on error. */
3825 _bfd_vms_write_etir (bfd
* abfd
, int objtype ATTRIBUTE_UNUSED
)
3828 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3830 vms_debug2 ((2, "vms_write_tir (%p, %d)\n", abfd
, objtype
));
3832 _bfd_vms_output_alignment (recwr
, 4);
3834 PRIV (vms_linkage_index
) = 0;
3836 for (section
= abfd
->sections
; section
; section
= section
->next
)
3838 vms_debug2 ((4, "writing %d. section '%s' (%d bytes)\n",
3839 section
->target_index
, section
->name
, (int) (section
->size
)));
3841 if (!(section
->flags
& SEC_HAS_CONTENTS
)
3842 || bfd_is_com_section (section
))
3845 if (!section
->contents
)
3847 bfd_set_error (bfd_error_no_contents
);
3851 start_etir_or_etbt_record (abfd
, section
, 0);
3853 if (section
->flags
& SEC_RELOC
)
3855 bfd_vma curr_addr
= 0;
3856 unsigned char *curr_data
= section
->contents
;
3858 int pass2_needed
= 0;
3859 int pass2_in_progress
= 0;
3862 if (section
->reloc_count
== 0)
3864 (_("SEC_RELOC with no relocs in section %pA"), section
);
3869 int i
= section
->reloc_count
;
3870 arelent
**rptr
= section
->orelocation
;
3871 _bfd_vms_debug (4, "%d relocations:\n", i
);
3874 _bfd_vms_debug (4, "sym %s in sec %s, value %08lx, "
3875 "addr %08lx, off %08lx, len %d: %s\n",
3876 (*(*rptr
)->sym_ptr_ptr
)->name
,
3877 (*(*rptr
)->sym_ptr_ptr
)->section
->name
,
3878 (long) (*(*rptr
)->sym_ptr_ptr
)->value
,
3879 (unsigned long)(*rptr
)->address
,
3880 (unsigned long)(*rptr
)->addend
,
3881 bfd_get_reloc_size ((*rptr
)->howto
),
3882 ( *rptr
)->howto
->name
);
3889 for (irel
= 0; irel
< section
->reloc_count
; irel
++)
3891 struct evax_private_udata_struct
*udata
;
3892 arelent
*rptr
= section
->orelocation
[irel
];
3893 bfd_vma addr
= rptr
->address
;
3894 asymbol
*sym
= *rptr
->sym_ptr_ptr
;
3895 asection
*sec
= sym
->section
;
3896 bfd_boolean defer
= defer_reloc_p (rptr
);
3899 if (pass2_in_progress
)
3901 /* Non-deferred relocs have already been output. */
3907 /* Deferred relocs must be output at the very end. */
3914 /* Regular relocs are intertwined with binary data. */
3915 if (curr_addr
> addr
)
3916 _bfd_error_handler (_("size error in section %pA"),
3918 size
= addr
- curr_addr
;
3919 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
3924 size
= bfd_get_reloc_size (rptr
->howto
);
3926 switch (rptr
->howto
->type
)
3928 case ALPHA_R_IGNORE
:
3931 case ALPHA_R_REFLONG
:
3932 if (bfd_is_und_section (sym
->section
))
3934 bfd_vma addend
= rptr
->addend
;
3935 slen
= strlen ((char *) sym
->name
);
3936 etir_output_check (abfd
, section
, curr_addr
, slen
);
3939 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
3940 _bfd_vms_output_counted (recwr
, sym
->name
);
3941 _bfd_vms_output_end_subrec (recwr
);
3942 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3943 _bfd_vms_output_long (recwr
, (unsigned long) addend
);
3944 _bfd_vms_output_end_subrec (recwr
);
3945 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
3946 _bfd_vms_output_end_subrec (recwr
);
3947 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3948 _bfd_vms_output_end_subrec (recwr
);
3952 _bfd_vms_output_begin_subrec
3953 (recwr
, ETIR__C_STO_GBL_LW
);
3954 _bfd_vms_output_counted (recwr
, sym
->name
);
3955 _bfd_vms_output_end_subrec (recwr
);
3958 else if (bfd_is_abs_section (sym
->section
))
3960 etir_output_check (abfd
, section
, curr_addr
, 16);
3961 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3962 _bfd_vms_output_long (recwr
, (unsigned long) sym
->value
);
3963 _bfd_vms_output_end_subrec (recwr
);
3964 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3965 _bfd_vms_output_end_subrec (recwr
);
3969 etir_output_check (abfd
, section
, curr_addr
, 32);
3970 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3971 _bfd_vms_output_long (recwr
,
3972 (unsigned long) sec
->target_index
);
3973 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
3974 _bfd_vms_output_end_subrec (recwr
);
3975 /* ??? Table B-8 of the OpenVMS Linker Utilily Manual
3976 says that we should have a ETIR__C_STO_OFF here.
3977 But the relocation would not be BFD_RELOC_32 then.
3978 This case is very likely unreachable. */
3979 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3980 _bfd_vms_output_end_subrec (recwr
);
3984 case ALPHA_R_REFQUAD
:
3985 if (bfd_is_und_section (sym
->section
))
3987 bfd_vma addend
= rptr
->addend
;
3988 slen
= strlen ((char *) sym
->name
);
3989 etir_output_check (abfd
, section
, curr_addr
, slen
);
3992 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
3993 _bfd_vms_output_counted (recwr
, sym
->name
);
3994 _bfd_vms_output_end_subrec (recwr
);
3995 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
3996 _bfd_vms_output_quad (recwr
, addend
);
3997 _bfd_vms_output_end_subrec (recwr
);
3998 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
3999 _bfd_vms_output_end_subrec (recwr
);
4000 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
4001 _bfd_vms_output_end_subrec (recwr
);
4005 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_GBL
);
4006 _bfd_vms_output_counted (recwr
, sym
->name
);
4007 _bfd_vms_output_end_subrec (recwr
);
4010 else if (bfd_is_abs_section (sym
->section
))
4012 etir_output_check (abfd
, section
, curr_addr
, 16);
4013 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
4014 _bfd_vms_output_quad (recwr
, sym
->value
);
4015 _bfd_vms_output_end_subrec (recwr
);
4016 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
4017 _bfd_vms_output_end_subrec (recwr
);
4021 etir_output_check (abfd
, section
, curr_addr
, 32);
4022 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
4023 _bfd_vms_output_long (recwr
,
4024 (unsigned long) sec
->target_index
);
4025 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
4026 _bfd_vms_output_end_subrec (recwr
);
4027 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_OFF
);
4028 _bfd_vms_output_end_subrec (recwr
);
4033 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
4036 case ALPHA_R_LINKAGE
:
4038 etir_output_check (abfd
, section
, curr_addr
, 64);
4039 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LP_PSB
);
4040 _bfd_vms_output_long
4041 (recwr
, (unsigned long) rptr
->addend
);
4042 if (rptr
->addend
> PRIV (vms_linkage_index
))
4043 PRIV (vms_linkage_index
) = rptr
->addend
;
4044 _bfd_vms_output_counted (recwr
, sym
->name
);
4045 _bfd_vms_output_byte (recwr
, 0);
4046 _bfd_vms_output_end_subrec (recwr
);
4049 case ALPHA_R_CODEADDR
:
4050 slen
= strlen ((char *) sym
->name
);
4051 etir_output_check (abfd
, section
, curr_addr
, slen
);
4052 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_CA
);
4053 _bfd_vms_output_counted (recwr
, sym
->name
);
4054 _bfd_vms_output_end_subrec (recwr
);
4059 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4060 etir_output_check (abfd
, section
, curr_addr
,
4061 32 + 1 + strlen (udata
->origname
));
4062 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_NOP_GBL
);
4063 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
4064 _bfd_vms_output_long
4065 (recwr
, (unsigned long) section
->target_index
);
4066 _bfd_vms_output_quad (recwr
, rptr
->address
);
4067 _bfd_vms_output_long (recwr
, (unsigned long) 0x47ff041f);
4068 _bfd_vms_output_long
4069 (recwr
, (unsigned long) section
->target_index
);
4070 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4071 _bfd_vms_output_counted (recwr
, udata
->origname
);
4072 _bfd_vms_output_end_subrec (recwr
);
4076 _bfd_error_handler (_("spurious ALPHA_R_BSR reloc"));
4081 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4082 etir_output_check (abfd
, section
, curr_addr
,
4083 32 + 1 + strlen (udata
->origname
));
4084 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LDA_GBL
);
4085 _bfd_vms_output_long
4086 (recwr
, (unsigned long) udata
->lkindex
+ 1);
4087 _bfd_vms_output_long
4088 (recwr
, (unsigned long) section
->target_index
);
4089 _bfd_vms_output_quad (recwr
, rptr
->address
);
4090 _bfd_vms_output_long (recwr
, (unsigned long) 0x237B0000);
4091 _bfd_vms_output_long
4092 (recwr
, (unsigned long) udata
->bsym
->section
->target_index
);
4093 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4094 _bfd_vms_output_counted (recwr
, udata
->origname
);
4095 _bfd_vms_output_end_subrec (recwr
);
4100 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4101 etir_output_check (abfd
, section
, curr_addr
,
4102 32 + 1 + strlen (udata
->origname
));
4103 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_BOH_GBL
);
4104 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
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) 0xD3400000);
4109 _bfd_vms_output_long
4110 (recwr
, (unsigned long) 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
);
4117 _bfd_error_handler (_("unhandled relocation %s"),
4124 } /* End of relocs loop. */
4126 if (!pass2_in_progress
)
4128 /* Output rest of section. */
4129 if (curr_addr
> section
->size
)
4131 _bfd_error_handler (_("size error in section %pA"), section
);
4134 size
= section
->size
- curr_addr
;
4135 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
4141 pass2_in_progress
= 1;
4147 else /* (section->flags & SEC_RELOC) */
4148 sto_imm (abfd
, section
, section
->size
, section
->contents
, 0);
4150 end_etir_record (abfd
);
4153 _bfd_vms_output_alignment (recwr
, 2);
4157 /* Write cached information into a file being written, at bfd_close. */
4160 alpha_vms_write_object_contents (bfd
*abfd
)
4162 vms_debug2 ((1, "vms_write_object_contents (%p)\n", abfd
));
4164 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
4166 return alpha_vms_write_exec (abfd
);
4170 if (abfd
->section_count
> 0) /* we have sections */
4172 if (!_bfd_vms_write_ehdr (abfd
))
4174 if (!_bfd_vms_write_egsd (abfd
))
4176 if (!_bfd_vms_write_etir (abfd
, EOBJ__C_ETIR
))
4178 if (!_bfd_vms_write_eeom (abfd
))
4185 /* Debug stuff: nearest line. */
4187 #define SET_MODULE_PARSED(m) \
4188 do { if ((m)->name == NULL) (m)->name = ""; } while (0)
4189 #define IS_MODULE_PARSED(m) ((m)->name != NULL)
4191 /* Build a new module for the specified BFD. */
4193 static struct module
*
4194 new_module (bfd
*abfd
)
4196 struct module
*module
4197 = (struct module
*) bfd_zalloc (abfd
, sizeof (struct module
));
4198 module
->file_table_count
= 16; /* Arbitrary. */
4200 = bfd_malloc (module
->file_table_count
* sizeof (struct fileinfo
));
4204 /* Parse debug info for a module and internalize it. */
4207 parse_module (bfd
*abfd
, struct module
*module
, unsigned char *ptr
,
4210 unsigned char *maxptr
= ptr
+ length
;
4211 unsigned char *src_ptr
, *pcl_ptr
;
4212 unsigned int prev_linum
= 0, curr_linenum
= 0;
4213 bfd_vma prev_pc
= 0, curr_pc
= 0;
4214 struct srecinfo
*curr_srec
, *srec
;
4215 struct lineinfo
*curr_line
, *line
;
4216 struct funcinfo
*funcinfo
;
4218 /* Initialize tables with zero element. */
4219 curr_srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4220 module
->srec_table
= curr_srec
;
4222 curr_line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4223 module
->line_table
= curr_line
;
4225 while (length
== -1 || ptr
< maxptr
)
4227 /* The first byte is not counted in the recorded length. */
4228 int rec_length
= bfd_getl16 (ptr
) + 1;
4229 int rec_type
= bfd_getl16 (ptr
+ 2);
4231 vms_debug2 ((2, "DST record: leng %d, type %d\n", rec_length
, rec_type
));
4233 if (length
== -1 && rec_type
== DST__K_MODEND
)
4240 = _bfd_vms_save_counted_string (abfd
, ptr
+ DST_S_B_MODBEG_NAME
,
4241 maxptr
- (ptr
+ DST_S_B_MODBEG_NAME
));
4248 vms_debug2 ((3, "module: %s\n", module
->name
));
4255 funcinfo
= (struct funcinfo
*)
4256 bfd_zalloc (abfd
, sizeof (struct funcinfo
));
4258 = _bfd_vms_save_counted_string (abfd
, ptr
+ DST_S_B_RTNBEG_NAME
,
4259 maxptr
- (ptr
+ DST_S_B_RTNBEG_NAME
));
4260 funcinfo
->low
= bfd_getl32 (ptr
+ DST_S_L_RTNBEG_ADDRESS
);
4261 funcinfo
->next
= module
->func_table
;
4262 module
->func_table
= funcinfo
;
4264 vms_debug2 ((3, "routine: %s at 0x%lx\n",
4265 funcinfo
->name
, (unsigned long) funcinfo
->low
));
4269 module
->func_table
->high
= module
->func_table
->low
4270 + bfd_getl32 (ptr
+ DST_S_L_RTNEND_SIZE
) - 1;
4272 if (module
->func_table
->high
> module
->high
)
4273 module
->high
= module
->func_table
->high
;
4275 vms_debug2 ((3, "end routine\n"));
4279 vms_debug2 ((3, "prologue\n"));
4283 vms_debug2 ((3, "epilog\n"));
4287 vms_debug2 ((3, "block\n"));
4291 vms_debug2 ((3, "end block\n"));
4295 src_ptr
= ptr
+ DST_S_C_SOURCE_HEADER_SIZE
;
4297 vms_debug2 ((3, "source info\n"));
4299 while (src_ptr
< ptr
+ rec_length
)
4301 int cmd
= src_ptr
[0], cmd_length
, data
;
4305 case DST__K_SRC_DECLFILE
:
4308 = bfd_getl16 (src_ptr
+ DST_S_W_SRC_DF_FILEID
);
4309 char *filename
= _bfd_vms_save_counted_string
4311 src_ptr
+ DST_S_B_SRC_DF_FILENAME
,
4312 ptr
+ rec_length
- (src_ptr
+ DST_S_B_SRC_DF_FILENAME
));
4314 while (fileid
>= module
->file_table_count
)
4316 module
->file_table_count
*= 2;
4318 = bfd_realloc (module
->file_table
,
4319 module
->file_table_count
4320 * sizeof (struct fileinfo
));
4323 module
->file_table
[fileid
].name
= filename
;
4324 module
->file_table
[fileid
].srec
= 1;
4325 cmd_length
= src_ptr
[DST_S_B_SRC_DF_LENGTH
] + 2;
4326 vms_debug2 ((4, "DST_S_C_SRC_DECLFILE: %d, %s\n",
4327 fileid
, module
->file_table
[fileid
].name
));
4331 case DST__K_SRC_DEFLINES_B
:
4332 /* Perform the association and set the next higher index
4334 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4335 srec
= (struct srecinfo
*)
4336 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4337 srec
->line
= curr_srec
->line
+ data
;
4338 srec
->srec
= curr_srec
->srec
+ data
;
4339 srec
->sfile
= curr_srec
->sfile
;
4340 curr_srec
->next
= srec
;
4343 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_B: %d\n", data
));
4346 case DST__K_SRC_DEFLINES_W
:
4347 /* Perform the association and set the next higher index
4349 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4350 srec
= (struct srecinfo
*)
4351 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4352 srec
->line
= curr_srec
->line
+ data
;
4353 srec
->srec
= curr_srec
->srec
+ data
,
4354 srec
->sfile
= curr_srec
->sfile
;
4355 curr_srec
->next
= srec
;
4358 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_W: %d\n", data
));
4361 case DST__K_SRC_INCRLNUM_B
:
4362 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4363 curr_srec
->line
+= data
;
4365 vms_debug2 ((4, "DST_S_C_SRC_INCRLNUM_B: %d\n", data
));
4368 case DST__K_SRC_SETFILE
:
4369 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4370 curr_srec
->sfile
= data
;
4371 curr_srec
->srec
= module
->file_table
[data
].srec
;
4373 vms_debug2 ((4, "DST_S_C_SRC_SETFILE: %d\n", data
));
4376 case DST__K_SRC_SETLNUM_L
:
4377 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4378 curr_srec
->line
= data
;
4380 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_L: %d\n", data
));
4383 case DST__K_SRC_SETLNUM_W
:
4384 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4385 curr_srec
->line
= data
;
4387 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_W: %d\n", data
));
4390 case DST__K_SRC_SETREC_L
:
4391 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4392 curr_srec
->srec
= data
;
4393 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4395 vms_debug2 ((4, "DST_S_C_SRC_SETREC_L: %d\n", data
));
4398 case DST__K_SRC_SETREC_W
:
4399 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4400 curr_srec
->srec
= data
;
4401 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4403 vms_debug2 ((4, "DST_S_C_SRC_SETREC_W: %d\n", data
));
4406 case DST__K_SRC_FORMFEED
:
4408 vms_debug2 ((4, "DST_S_C_SRC_FORMFEED\n"));
4412 _bfd_error_handler (_("unknown source command %d"),
4418 src_ptr
+= cmd_length
;
4422 case DST__K_LINE_NUM
:
4423 pcl_ptr
= ptr
+ DST_S_C_LINE_NUM_HEADER_SIZE
;
4425 vms_debug2 ((3, "line info\n"));
4427 while (pcl_ptr
< ptr
+ rec_length
)
4429 /* The command byte is signed so we must sign-extend it. */
4430 int cmd
= ((signed char *)pcl_ptr
)[0], cmd_length
, data
;
4434 case DST__K_DELTA_PC_W
:
4435 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4439 vms_debug2 ((4, "DST__K_DELTA_PC_W: %d\n", data
));
4442 case DST__K_DELTA_PC_L
:
4443 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4447 vms_debug2 ((4, "DST__K_DELTA_PC_L: %d\n", data
));
4450 case DST__K_INCR_LINUM
:
4451 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4452 curr_linenum
+= data
;
4454 vms_debug2 ((4, "DST__K_INCR_LINUM: %d\n", data
));
4457 case DST__K_INCR_LINUM_W
:
4458 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4459 curr_linenum
+= data
;
4461 vms_debug2 ((4, "DST__K_INCR_LINUM_W: %d\n", data
));
4464 case DST__K_INCR_LINUM_L
:
4465 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4466 curr_linenum
+= data
;
4468 vms_debug2 ((4, "DST__K_INCR_LINUM_L: %d\n", data
));
4471 case DST__K_SET_LINUM_INCR
:
4473 (_("%s not implemented"), "DST__K_SET_LINUM_INCR");
4477 case DST__K_SET_LINUM_INCR_W
:
4479 (_("%s not implemented"), "DST__K_SET_LINUM_INCR_W");
4483 case DST__K_RESET_LINUM_INCR
:
4485 (_("%s not implemented"), "DST__K_RESET_LINUM_INCR");
4489 case DST__K_BEG_STMT_MODE
:
4491 (_("%s not implemented"), "DST__K_BEG_STMT_MODE");
4495 case DST__K_END_STMT_MODE
:
4497 (_("%s not implemented"), "DST__K_END_STMT_MODE");
4501 case DST__K_SET_LINUM_B
:
4502 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4503 curr_linenum
= data
;
4505 vms_debug2 ((4, "DST__K_SET_LINUM_B: %d\n", data
));
4508 case DST__K_SET_LINUM
:
4509 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4510 curr_linenum
= data
;
4512 vms_debug2 ((4, "DST__K_SET_LINE_NUM: %d\n", data
));
4515 case DST__K_SET_LINUM_L
:
4516 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4517 curr_linenum
= data
;
4519 vms_debug2 ((4, "DST__K_SET_LINUM_L: %d\n", data
));
4524 (_("%s not implemented"), "DST__K_SET_PC");
4528 case DST__K_SET_PC_W
:
4530 (_("%s not implemented"), "DST__K_SET_PC_W");
4534 case DST__K_SET_PC_L
:
4536 (_("%s not implemented"), "DST__K_SET_PC_L");
4540 case DST__K_SET_STMTNUM
:
4542 (_("%s not implemented"), "DST__K_SET_STMTNUM");
4547 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4550 vms_debug2 ((4, "DST__K_TERM: %d\n", data
));
4554 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4557 vms_debug2 ((4, "DST__K_TERM_W: %d\n", data
));
4561 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4564 vms_debug2 ((4, "DST__K_TERM_L: %d\n", data
));
4567 case DST__K_SET_ABS_PC
:
4568 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4571 vms_debug2 ((4, "DST__K_SET_ABS_PC: 0x%x\n", data
));
4580 vms_debug2 ((4, "bump pc to 0x%lx and line to %d\n",
4581 (unsigned long)curr_pc
, curr_linenum
));
4585 _bfd_error_handler (_("unknown line command %d"), cmd
);
4591 if ((curr_linenum
!= prev_linum
&& curr_pc
!= prev_pc
)
4593 || cmd
== DST__K_DELTA_PC_L
4594 || cmd
== DST__K_DELTA_PC_W
)
4596 line
= (struct lineinfo
*)
4597 bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4598 line
->address
= curr_pc
;
4599 line
->line
= curr_linenum
;
4601 curr_line
->next
= line
;
4604 prev_linum
= curr_linenum
;
4606 vms_debug2 ((4, "-> correlate pc 0x%lx with line %d\n",
4607 (unsigned long)curr_pc
, curr_linenum
));
4610 pcl_ptr
+= cmd_length
;
4614 case 0x17: /* Undocumented type used by DEC C to declare equates. */
4615 vms_debug2 ((3, "undocumented type 0x17\n"));
4619 vms_debug2 ((3, "ignoring record\n"));
4627 /* Finalize tables with EOL marker. */
4628 srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4629 srec
->line
= (unsigned int) -1;
4630 srec
->srec
= (unsigned int) -1;
4631 curr_srec
->next
= srec
;
4633 line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4634 line
->line
= (unsigned int) -1;
4635 line
->address
= (bfd_vma
) -1;
4636 curr_line
->next
= line
;
4638 /* Advertise that this module has been parsed. This is needed
4639 because parsing can be either performed at module creation
4640 or deferred until debug info is consumed. */
4641 SET_MODULE_PARSED (module
);
4644 /* Build the list of modules for the specified BFD. */
4646 static struct module
*
4647 build_module_list (bfd
*abfd
)
4649 struct module
*module
, *list
= NULL
;
4652 if ((dmt
= bfd_get_section_by_name (abfd
, "$DMT$")))
4654 /* We have a DMT section so this must be an image. Parse the
4655 section and build the list of modules. This is sufficient
4656 since we can compute the start address and the end address
4657 of every module from the section contents. */
4658 bfd_size_type size
= bfd_section_size (dmt
);
4659 unsigned char *ptr
, *end
;
4661 ptr
= (unsigned char *) bfd_alloc (abfd
, size
);
4665 if (! bfd_get_section_contents (abfd
, dmt
, ptr
, 0, size
))
4668 vms_debug2 ((2, "DMT\n"));
4674 /* Each header declares a module with its start offset and size
4675 of debug info in the DST section, as well as the count of
4676 program sections (i.e. address spans) it contains. */
4677 int modbeg
= bfd_getl32 (ptr
+ DBG_S_L_DMT_MODBEG
);
4678 int msize
= bfd_getl32 (ptr
+ DBG_S_L_DST_SIZE
);
4679 int count
= bfd_getl16 (ptr
+ DBG_S_W_DMT_PSECT_COUNT
);
4680 ptr
+= DBG_S_C_DMT_HEADER_SIZE
;
4682 vms_debug2 ((3, "module: modbeg = %d, size = %d, count = %d\n",
4683 modbeg
, msize
, count
));
4685 /* We create a 'module' structure for each program section since
4686 we only support contiguous addresses in a 'module' structure.
4687 As a consequence, the actual debug info in the DST section is
4688 shared and can be parsed multiple times; that doesn't seem to
4689 cause problems in practice. */
4692 int start
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_START
);
4693 int length
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_LENGTH
);
4694 module
= new_module (abfd
);
4695 module
->modbeg
= modbeg
;
4696 module
->size
= msize
;
4697 module
->low
= start
;
4698 module
->high
= start
+ length
;
4699 module
->next
= list
;
4701 ptr
+= DBG_S_C_DMT_PSECT_SIZE
;
4703 vms_debug2 ((4, "section: start = 0x%x, length = %d\n",
4710 /* We don't have a DMT section so this must be an object. Parse
4711 the module right now in order to compute its start address and
4713 void *dst
= PRIV (dst_section
)->contents
;
4718 module
= new_module (abfd
);
4719 parse_module (abfd
, module
, PRIV (dst_section
)->contents
, -1);
4726 /* Calculate and return the name of the source file and the line nearest
4727 to the wanted location in the specified module. */
4730 module_find_nearest_line (bfd
*abfd
, struct module
*module
, bfd_vma addr
,
4731 const char **file
, const char **func
,
4734 struct funcinfo
*funcinfo
;
4735 struct lineinfo
*lineinfo
;
4736 struct srecinfo
*srecinfo
;
4737 bfd_boolean ret
= FALSE
;
4739 /* Parse this module if that was not done at module creation. */
4740 if (! IS_MODULE_PARSED (module
))
4742 unsigned int size
= module
->size
;
4743 unsigned int modbeg
= PRIV (dst_section
)->filepos
+ module
->modbeg
;
4744 unsigned char *buffer
= (unsigned char *) bfd_malloc (module
->size
);
4746 if (bfd_seek (abfd
, modbeg
, SEEK_SET
) != 0
4747 || bfd_bread (buffer
, size
, abfd
) != size
)
4749 bfd_set_error (bfd_error_no_debug_section
);
4753 parse_module (abfd
, module
, buffer
, size
);
4757 /* Find out the function (if any) that contains the address. */
4758 for (funcinfo
= module
->func_table
; funcinfo
; funcinfo
= funcinfo
->next
)
4759 if (addr
>= funcinfo
->low
&& addr
<= funcinfo
->high
)
4761 *func
= funcinfo
->name
;
4766 /* Find out the source file and the line nearest to the address. */
4767 for (lineinfo
= module
->line_table
; lineinfo
; lineinfo
= lineinfo
->next
)
4768 if (lineinfo
->next
&& addr
< lineinfo
->next
->address
)
4770 for (srecinfo
= module
->srec_table
; srecinfo
; srecinfo
= srecinfo
->next
)
4771 if (srecinfo
->next
&& lineinfo
->line
< srecinfo
->next
->line
)
4773 if (srecinfo
->sfile
> 0)
4775 *file
= module
->file_table
[srecinfo
->sfile
].name
;
4776 *line
= srecinfo
->srec
+ lineinfo
->line
- srecinfo
->line
;
4780 *file
= module
->name
;
4781 *line
= lineinfo
->line
;
4792 /* Provided a BFD, a section and an offset into the section, calculate and
4793 return the name of the source file and the line nearest to the wanted
4797 _bfd_vms_find_nearest_line (bfd
*abfd
,
4798 asymbol
**symbols ATTRIBUTE_UNUSED
,
4804 unsigned int *discriminator
)
4806 struct module
*module
;
4808 /* What address are we looking for? */
4809 bfd_vma addr
= section
->vma
+ offset
;
4817 /* We can't do anything if there is no DST (debug symbol table). */
4818 if (PRIV (dst_section
) == NULL
)
4821 /* Create the module list - if not already done. */
4822 if (PRIV (modules
) == NULL
)
4824 PRIV (modules
) = build_module_list (abfd
);
4825 if (PRIV (modules
) == NULL
)
4829 for (module
= PRIV (modules
); module
; module
= module
->next
)
4830 if (addr
>= module
->low
&& addr
<= module
->high
)
4831 return module_find_nearest_line (abfd
, module
, addr
, file
, func
, line
);
4836 /* Canonicalizations. */
4837 /* Set name, value, section and flags of SYM from E. */
4840 alpha_vms_convert_symbol (bfd
*abfd
, struct vms_symbol_entry
*e
, asymbol
*sym
)
4849 flags
= BSF_NO_FLAGS
;
4855 if (e
->flags
& EGSY__V_WEAK
)
4858 if (e
->flags
& EGSY__V_DEF
)
4860 /* Symbol definition. */
4861 flags
|= BSF_GLOBAL
;
4862 if (e
->flags
& EGSY__V_NORM
)
4863 flags
|= BSF_FUNCTION
;
4869 /* Symbol reference. */
4870 sec
= bfd_und_section_ptr
;
4875 /* A universal symbol is by definition global... */
4876 flags
|= BSF_GLOBAL
;
4878 /* ...and dynamic in shared libraries. */
4879 if (abfd
->flags
& DYNAMIC
)
4880 flags
|= BSF_DYNAMIC
;
4882 if (e
->flags
& EGSY__V_WEAK
)
4885 if (!(e
->flags
& EGSY__V_DEF
))
4888 if (e
->flags
& EGSY__V_NORM
)
4889 flags
|= BSF_FUNCTION
;
4892 /* sec = e->section; */
4893 sec
= bfd_abs_section_ptr
;
4908 /* Return the number of bytes required to store a vector of pointers
4909 to asymbols for all the symbols in the BFD abfd, including a
4910 terminal NULL pointer. If there are no symbols in the BFD,
4911 then return 0. If an error occurs, return -1. */
4914 alpha_vms_get_symtab_upper_bound (bfd
*abfd
)
4916 vms_debug2 ((1, "alpha_vms_get_symtab_upper_bound (%p), %d symbols\n",
4917 abfd
, PRIV (gsd_sym_count
)));
4919 return (PRIV (gsd_sym_count
) + 1) * sizeof (asymbol
*);
4922 /* Read the symbols from the BFD abfd, and fills in the vector
4923 location with pointers to the symbols and a trailing NULL.
4925 Return number of symbols read. */
4928 alpha_vms_canonicalize_symtab (bfd
*abfd
, asymbol
**symbols
)
4932 vms_debug2 ((1, "alpha_vms_canonicalize_symtab (%p, <ret>)\n", abfd
));
4934 if (PRIV (csymbols
) == NULL
)
4936 PRIV (csymbols
) = (asymbol
**) bfd_alloc
4937 (abfd
, PRIV (gsd_sym_count
) * sizeof (asymbol
*));
4939 /* Traverse table and fill symbols vector. */
4940 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
4942 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
4945 sym
= bfd_make_empty_symbol (abfd
);
4946 if (sym
== NULL
|| !alpha_vms_convert_symbol (abfd
, e
, sym
))
4948 bfd_release (abfd
, PRIV (csymbols
));
4949 PRIV (csymbols
) = NULL
;
4953 PRIV (csymbols
)[i
] = sym
;
4957 if (symbols
!= NULL
)
4959 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
4960 symbols
[i
] = PRIV (csymbols
)[i
];
4964 return PRIV (gsd_sym_count
);
4967 /* Read and convert relocations from ETIR. We do it once for all sections. */
4970 alpha_vms_slurp_relocs (bfd
*abfd
)
4974 vms_debug2 ((3, "alpha_vms_slurp_relocs\n"));
4976 /* We slurp relocs only once, for all sections. */
4977 if (PRIV (reloc_done
))
4979 PRIV (reloc_done
) = TRUE
;
4981 if (alpha_vms_canonicalize_symtab (abfd
, NULL
) < 0)
4984 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
4989 unsigned char *begin
;
4992 bfd_reloc_code_real_type reloc_code
;
4998 bfd_vma cur_address
;
5000 unsigned char *cur_sym
= NULL
;
5002 bfd_vma cur_addend
= 0;
5004 /* Skip non-ETIR records. */
5005 type
= _bfd_vms_get_object_record (abfd
);
5006 if (type
== EOBJ__C_EEOM
)
5008 if (type
!= EOBJ__C_ETIR
)
5011 begin
= PRIV (recrd
.rec
) + 4;
5012 end
= PRIV (recrd
.rec
) + PRIV (recrd
.rec_size
);
5014 for (ptr
= begin
; ptr
< end
; ptr
+= length
)
5018 cmd
= bfd_getl16 (ptr
);
5019 length
= bfd_getl16 (ptr
+ 2);
5021 cur_address
= vaddr
;
5023 vms_debug2 ((4, "alpha_vms_slurp_relocs: etir %s\n",
5024 _bfd_vms_etir_name (cmd
)));
5028 case ETIR__C_STA_GBL
: /* ALPHA_R_REFLONG und_section, step 1 */
5029 /* ALPHA_R_REFQUAD und_section, step 1 */
5034 case ETIR__C_STA_PQ
: /* ALPHA_R_REF{LONG|QUAD}, others part 1 */
5035 cur_psidx
= bfd_getl32 (ptr
+ 4);
5036 cur_addend
= bfd_getl64 (ptr
+ 8);
5040 case ETIR__C_CTL_SETRB
:
5041 if (prev_cmd
!= ETIR__C_STA_PQ
)
5044 /* xgettext:c-format */
5045 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (prev_cmd
),
5046 _bfd_vms_etir_name (cmd
));
5049 cur_psect
= cur_psidx
;
5055 case ETIR__C_STA_LW
: /* ALPHA_R_REFLONG abs_section, step 1 */
5056 /* ALPHA_R_REFLONG und_section, step 2 */
5059 if (prev_cmd
!= ETIR__C_STA_GBL
)
5062 /* xgettext:c-format */
5063 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
5064 _bfd_vms_etir_name (ETIR__C_STA_LW
));
5068 cur_addend
= bfd_getl32 (ptr
+ 4);
5072 case ETIR__C_STA_QW
: /* ALPHA_R_REFQUAD abs_section, step 1 */
5073 /* ALPHA_R_REFQUAD und_section, step 2 */
5074 if (prev_cmd
!= -1 && prev_cmd
!= ETIR__C_STA_GBL
)
5077 /* xgettext:c-format */
5078 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
5079 _bfd_vms_etir_name (ETIR__C_STA_QW
));
5082 cur_addend
= bfd_getl64 (ptr
+ 4);
5086 case ETIR__C_STO_LW
: /* ALPHA_R_REFLONG und_section, step 4 */
5087 /* ALPHA_R_REFLONG abs_section, step 2 */
5088 /* ALPHA_R_REFLONG others, step 2 */
5089 if (prev_cmd
!= ETIR__C_OPR_ADD
5090 && prev_cmd
!= ETIR__C_STA_LW
5091 && prev_cmd
!= ETIR__C_STA_PQ
)
5093 /* xgettext:c-format */
5094 _bfd_error_handler (_("unknown reloc %s + %s"),
5095 _bfd_vms_etir_name (prev_cmd
),
5096 _bfd_vms_etir_name (ETIR__C_STO_LW
));
5099 reloc_code
= BFD_RELOC_32
;
5102 case ETIR__C_STO_QW
: /* ALPHA_R_REFQUAD und_section, step 4 */
5103 /* ALPHA_R_REFQUAD abs_section, step 2 */
5104 if (prev_cmd
!= ETIR__C_OPR_ADD
&& prev_cmd
!= ETIR__C_STA_QW
)
5106 /* xgettext:c-format */
5107 _bfd_error_handler (_("unknown reloc %s + %s"),
5108 _bfd_vms_etir_name (prev_cmd
),
5109 _bfd_vms_etir_name (ETIR__C_STO_QW
));
5112 reloc_code
= BFD_RELOC_64
;
5115 case ETIR__C_STO_OFF
: /* ALPHA_R_REFQUAD others, step 2 */
5116 if (prev_cmd
!= ETIR__C_STA_PQ
)
5118 /* xgettext:c-format */
5119 _bfd_error_handler (_("unknown reloc %s + %s"),
5120 _bfd_vms_etir_name (prev_cmd
),
5121 _bfd_vms_etir_name (ETIR__C_STO_OFF
));
5124 reloc_code
= BFD_RELOC_64
;
5127 case ETIR__C_OPR_ADD
: /* ALPHA_R_REFLONG und_section, step 3 */
5128 /* ALPHA_R_REFQUAD und_section, step 3 */
5129 if (prev_cmd
!= ETIR__C_STA_LW
&& prev_cmd
!= ETIR__C_STA_QW
)
5131 /* xgettext:c-format */
5132 _bfd_error_handler (_("unknown reloc %s + %s"),
5133 _bfd_vms_etir_name (prev_cmd
),
5134 _bfd_vms_etir_name (ETIR__C_OPR_ADD
));
5137 prev_cmd
= ETIR__C_OPR_ADD
;
5140 case ETIR__C_STO_CA
: /* ALPHA_R_CODEADDR */
5141 reloc_code
= BFD_RELOC_ALPHA_CODEADDR
;
5145 case ETIR__C_STO_GBL
: /* ALPHA_R_REFQUAD und_section */
5146 reloc_code
= BFD_RELOC_64
;
5150 case ETIR__C_STO_GBL_LW
: /* ALPHA_R_REFLONG und_section */
5151 reloc_code
= BFD_RELOC_32
;
5155 case ETIR__C_STC_LP_PSB
: /* ALPHA_R_LINKAGE */
5156 reloc_code
= BFD_RELOC_ALPHA_LINKAGE
;
5160 case ETIR__C_STC_NOP_GBL
: /* ALPHA_R_NOP */
5161 reloc_code
= BFD_RELOC_ALPHA_NOP
;
5164 case ETIR__C_STC_BSR_GBL
: /* ALPHA_R_BSR */
5165 reloc_code
= BFD_RELOC_ALPHA_BSR
;
5168 case ETIR__C_STC_LDA_GBL
: /* ALPHA_R_LDA */
5169 reloc_code
= BFD_RELOC_ALPHA_LDA
;
5172 case ETIR__C_STC_BOH_GBL
: /* ALPHA_R_BOH */
5173 reloc_code
= BFD_RELOC_ALPHA_BOH
;
5177 cur_sym
= ptr
+ 4 + 32;
5178 cur_address
= bfd_getl64 (ptr
+ 4 + 8);
5179 cur_addend
= bfd_getl64 (ptr
+ 4 + 24);
5182 case ETIR__C_STO_IMM
:
5183 vaddr
+= bfd_getl32 (ptr
+ 4);
5187 _bfd_error_handler (_("unknown reloc %s"),
5188 _bfd_vms_etir_name (cmd
));
5194 struct vms_section_data_struct
*vms_sec
;
5198 /* Get section to which the relocation applies. */
5199 if (cur_psect
< 0 || cur_psect
> (int)PRIV (section_count
))
5201 _bfd_error_handler (_("invalid section index in ETIR"));
5205 if (PRIV (sections
) == NULL
)
5207 sec
= PRIV (sections
)[cur_psect
];
5208 if (sec
== bfd_abs_section_ptr
)
5210 _bfd_error_handler (_("relocation for non-REL psect"));
5214 vms_sec
= vms_section_data (sec
);
5216 /* Allocate a reloc entry. */
5217 if (sec
->reloc_count
>= vms_sec
->reloc_max
)
5219 if (vms_sec
->reloc_max
== 0)
5221 vms_sec
->reloc_max
= 64;
5222 sec
->relocation
= bfd_zmalloc
5223 (vms_sec
->reloc_max
* sizeof (arelent
));
5227 vms_sec
->reloc_max
*= 2;
5228 sec
->relocation
= bfd_realloc
5229 (sec
->relocation
, vms_sec
->reloc_max
* sizeof (arelent
));
5232 reloc
= &sec
->relocation
[sec
->reloc_count
];
5235 reloc
->howto
= bfd_reloc_type_lookup (abfd
, reloc_code
);
5237 if (cur_sym
!= NULL
)
5240 unsigned int symlen
= *cur_sym
;
5243 /* Linear search. */
5248 for (j
= 0; j
< PRIV (gsd_sym_count
); j
++)
5249 if (PRIV (syms
)[j
]->namelen
== symlen
5250 && memcmp (PRIV (syms
)[j
]->name
, cur_sym
, symlen
) == 0)
5252 sym
= &PRIV (csymbols
)[j
];
5257 _bfd_error_handler (_("unknown symbol in command %s"),
5258 _bfd_vms_etir_name (cmd
));
5259 reloc
->sym_ptr_ptr
= NULL
;
5262 reloc
->sym_ptr_ptr
= sym
;
5264 else if (cur_psidx
>= 0)
5266 if (PRIV (sections
) == NULL
|| cur_psidx
>= (int) PRIV (section_count
))
5268 reloc
->sym_ptr_ptr
=
5269 PRIV (sections
)[cur_psidx
]->symbol_ptr_ptr
;
5272 reloc
->sym_ptr_ptr
= NULL
;
5274 reloc
->address
= cur_address
;
5275 reloc
->addend
= cur_addend
;
5277 if (reloc_code
== ALPHA_R_LINKAGE
)
5280 size
= bfd_get_reloc_size (reloc
->howto
);
5290 vms_debug2 ((3, "alpha_vms_slurp_relocs: result = TRUE\n"));
5295 /* Return the number of bytes required to store the relocation
5296 information associated with the given section. */
5299 alpha_vms_get_reloc_upper_bound (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*section
)
5301 alpha_vms_slurp_relocs (abfd
);
5303 return (section
->reloc_count
+ 1) * sizeof (arelent
*);
5306 /* Convert relocations from VMS (external) form into BFD internal
5307 form. Return the number of relocations. */
5310 alpha_vms_canonicalize_reloc (bfd
*abfd
, asection
*section
, arelent
**relptr
,
5311 asymbol
**symbols ATTRIBUTE_UNUSED
)
5316 if (!alpha_vms_slurp_relocs (abfd
))
5319 count
= section
->reloc_count
;
5320 tblptr
= section
->relocation
;
5323 *relptr
++ = tblptr
++;
5325 *relptr
= (arelent
*) NULL
;
5326 return section
->reloc_count
;
5329 /* Install a new set of internal relocs. */
5331 #define alpha_vms_set_reloc _bfd_generic_set_reloc
5334 /* This is just copied from ecoff-alpha, needs to be fixed probably. */
5336 /* How to process the various reloc types. */
5338 static bfd_reloc_status_type
5339 reloc_nil (bfd
* abfd ATTRIBUTE_UNUSED
,
5340 arelent
*reloc ATTRIBUTE_UNUSED
,
5341 asymbol
*sym ATTRIBUTE_UNUSED
,
5342 void * data ATTRIBUTE_UNUSED
,
5343 asection
*sec ATTRIBUTE_UNUSED
,
5344 bfd
*output_bfd ATTRIBUTE_UNUSED
,
5345 char **error_message ATTRIBUTE_UNUSED
)
5348 vms_debug (1, "reloc_nil (abfd %p, output_bfd %p)\n", abfd
, output_bfd
);
5349 vms_debug (2, "In section %s, symbol %s\n",
5350 sec
->name
, sym
->name
);
5351 vms_debug (2, "reloc sym %s, addr %08lx, addend %08lx, reloc is a %s\n",
5352 reloc
->sym_ptr_ptr
[0]->name
,
5353 (unsigned long)reloc
->address
,
5354 (unsigned long)reloc
->addend
, reloc
->howto
->name
);
5355 vms_debug (2, "data at %p\n", data
);
5356 /* _bfd_hexdump (2, data, bfd_get_reloc_size (reloc->howto), 0); */
5359 return bfd_reloc_ok
;
5362 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
5363 from smaller values. Start with zero, widen, *then* decrement. */
5364 #define MINUS_ONE (((bfd_vma)0) - 1)
5366 static reloc_howto_type alpha_howto_table
[] =
5368 HOWTO (ALPHA_R_IGNORE
, /* Type. */
5369 0, /* Rightshift. */
5370 0, /* Size (0 = byte, 1 = short, 2 = long). */
5372 TRUE
, /* PC relative. */
5374 complain_overflow_dont
,/* Complain_on_overflow. */
5375 reloc_nil
, /* Special_function. */
5376 "IGNORE", /* Name. */
5377 TRUE
, /* Partial_inplace. */
5378 0, /* Source mask */
5380 TRUE
), /* PC rel offset. */
5382 /* A 64 bit reference to a symbol. */
5383 HOWTO (ALPHA_R_REFQUAD
, /* Type. */
5384 0, /* Rightshift. */
5385 4, /* Size (0 = byte, 1 = short, 2 = long). */
5387 FALSE
, /* PC relative. */
5389 complain_overflow_bitfield
, /* Complain_on_overflow. */
5390 reloc_nil
, /* Special_function. */
5391 "REFQUAD", /* Name. */
5392 TRUE
, /* Partial_inplace. */
5393 MINUS_ONE
, /* Source mask. */
5394 MINUS_ONE
, /* Dest mask. */
5395 FALSE
), /* PC rel offset. */
5397 /* A 21 bit branch. The native assembler generates these for
5398 branches within the text segment, and also fills in the PC
5399 relative offset in the instruction. */
5400 HOWTO (ALPHA_R_BRADDR
, /* Type. */
5401 2, /* Rightshift. */
5402 2, /* Size (0 = byte, 1 = short, 2 = long). */
5404 TRUE
, /* PC relative. */
5406 complain_overflow_signed
, /* Complain_on_overflow. */
5407 reloc_nil
, /* Special_function. */
5408 "BRADDR", /* Name. */
5409 TRUE
, /* Partial_inplace. */
5410 0x1fffff, /* Source mask. */
5411 0x1fffff, /* Dest mask. */
5412 FALSE
), /* PC rel offset. */
5414 /* A hint for a jump to a register. */
5415 HOWTO (ALPHA_R_HINT
, /* Type. */
5416 2, /* Rightshift. */
5417 1, /* Size (0 = byte, 1 = short, 2 = long). */
5419 TRUE
, /* PC relative. */
5421 complain_overflow_dont
,/* Complain_on_overflow. */
5422 reloc_nil
, /* Special_function. */
5424 TRUE
, /* Partial_inplace. */
5425 0x3fff, /* Source mask. */
5426 0x3fff, /* Dest mask. */
5427 FALSE
), /* PC rel offset. */
5429 /* 16 bit PC relative offset. */
5430 HOWTO (ALPHA_R_SREL16
, /* Type. */
5431 0, /* Rightshift. */
5432 1, /* Size (0 = byte, 1 = short, 2 = long). */
5434 TRUE
, /* PC relative. */
5436 complain_overflow_signed
, /* Complain_on_overflow. */
5437 reloc_nil
, /* Special_function. */
5438 "SREL16", /* Name. */
5439 TRUE
, /* Partial_inplace. */
5440 0xffff, /* Source mask. */
5441 0xffff, /* Dest mask. */
5442 FALSE
), /* PC rel offset. */
5444 /* 32 bit PC relative offset. */
5445 HOWTO (ALPHA_R_SREL32
, /* Type. */
5446 0, /* Rightshift. */
5447 2, /* Size (0 = byte, 1 = short, 2 = long). */
5449 TRUE
, /* PC relative. */
5451 complain_overflow_signed
, /* Complain_on_overflow. */
5452 reloc_nil
, /* Special_function. */
5453 "SREL32", /* Name. */
5454 TRUE
, /* Partial_inplace. */
5455 0xffffffff, /* Source mask. */
5456 0xffffffff, /* Dest mask. */
5457 FALSE
), /* PC rel offset. */
5459 /* A 64 bit PC relative offset. */
5460 HOWTO (ALPHA_R_SREL64
, /* Type. */
5461 0, /* Rightshift. */
5462 4, /* Size (0 = byte, 1 = short, 2 = long). */
5464 TRUE
, /* PC relative. */
5466 complain_overflow_signed
, /* Complain_on_overflow. */
5467 reloc_nil
, /* Special_function. */
5468 "SREL64", /* Name. */
5469 TRUE
, /* Partial_inplace. */
5470 MINUS_ONE
, /* Source mask. */
5471 MINUS_ONE
, /* Dest mask. */
5472 FALSE
), /* PC rel offset. */
5474 /* Push a value on the reloc evaluation stack. */
5475 HOWTO (ALPHA_R_OP_PUSH
, /* Type. */
5476 0, /* Rightshift. */
5477 0, /* Size (0 = byte, 1 = short, 2 = long). */
5479 FALSE
, /* PC relative. */
5481 complain_overflow_dont
,/* Complain_on_overflow. */
5482 reloc_nil
, /* Special_function. */
5483 "OP_PUSH", /* Name. */
5484 FALSE
, /* Partial_inplace. */
5485 0, /* Source mask. */
5487 FALSE
), /* PC rel offset. */
5489 /* Store the value from the stack at the given address. Store it in
5490 a bitfield of size r_size starting at bit position r_offset. */
5491 HOWTO (ALPHA_R_OP_STORE
, /* Type. */
5492 0, /* Rightshift. */
5493 4, /* Size (0 = byte, 1 = short, 2 = long). */
5495 FALSE
, /* PC relative. */
5497 complain_overflow_dont
,/* Complain_on_overflow. */
5498 reloc_nil
, /* Special_function. */
5499 "OP_STORE", /* Name. */
5500 FALSE
, /* Partial_inplace. */
5501 0, /* Source mask. */
5502 MINUS_ONE
, /* Dest mask. */
5503 FALSE
), /* PC rel offset. */
5505 /* Subtract the reloc address from the value on the top of the
5506 relocation stack. */
5507 HOWTO (ALPHA_R_OP_PSUB
, /* Type. */
5508 0, /* Rightshift. */
5509 0, /* Size (0 = byte, 1 = short, 2 = long). */
5511 FALSE
, /* PC relative. */
5513 complain_overflow_dont
,/* Complain_on_overflow. */
5514 reloc_nil
, /* Special_function. */
5515 "OP_PSUB", /* Name. */
5516 FALSE
, /* Partial_inplace. */
5517 0, /* Source mask. */
5519 FALSE
), /* PC rel offset. */
5521 /* Shift the value on the top of the relocation stack right by the
5523 HOWTO (ALPHA_R_OP_PRSHIFT
, /* Type. */
5524 0, /* Rightshift. */
5525 0, /* Size (0 = byte, 1 = short, 2 = long). */
5527 FALSE
, /* PC relative. */
5529 complain_overflow_dont
,/* Complain_on_overflow. */
5530 reloc_nil
, /* Special_function. */
5531 "OP_PRSHIFT", /* Name. */
5532 FALSE
, /* Partial_inplace. */
5533 0, /* Source mask. */
5535 FALSE
), /* PC rel offset. */
5537 /* Hack. Linkage is done by linker. */
5538 HOWTO (ALPHA_R_LINKAGE
, /* Type. */
5539 0, /* Rightshift. */
5540 0, /* Size (0 = byte, 1 = short, 2 = long). */
5542 FALSE
, /* PC relative. */
5544 complain_overflow_dont
,/* Complain_on_overflow. */
5545 reloc_nil
, /* Special_function. */
5546 "LINKAGE", /* Name. */
5547 FALSE
, /* Partial_inplace. */
5548 0, /* Source mask. */
5550 FALSE
), /* PC rel offset. */
5552 /* A 32 bit reference to a symbol. */
5553 HOWTO (ALPHA_R_REFLONG
, /* Type. */
5554 0, /* Rightshift. */
5555 2, /* Size (0 = byte, 1 = short, 2 = long). */
5557 FALSE
, /* PC relative. */
5559 complain_overflow_bitfield
, /* Complain_on_overflow. */
5560 reloc_nil
, /* Special_function. */
5561 "REFLONG", /* Name. */
5562 TRUE
, /* Partial_inplace. */
5563 0xffffffff, /* Source mask. */
5564 0xffffffff, /* Dest mask. */
5565 FALSE
), /* PC rel offset. */
5567 /* A 64 bit reference to a procedure, written as 32 bit value. */
5568 HOWTO (ALPHA_R_CODEADDR
, /* Type. */
5569 0, /* Rightshift. */
5570 4, /* Size (0 = byte, 1 = short, 2 = long). */
5572 FALSE
, /* PC relative. */
5574 complain_overflow_signed
,/* Complain_on_overflow. */
5575 reloc_nil
, /* Special_function. */
5576 "CODEADDR", /* Name. */
5577 FALSE
, /* Partial_inplace. */
5578 0xffffffff, /* Source mask. */
5579 0xffffffff, /* Dest mask. */
5580 FALSE
), /* PC rel offset. */
5582 HOWTO (ALPHA_R_NOP
, /* Type. */
5583 0, /* Rightshift. */
5584 3, /* Size (0 = byte, 1 = short, 2 = long). */
5586 /* The following value must match that of ALPHA_R_BSR/ALPHA_R_BOH
5587 because the calculations for the 3 relocations are the same.
5588 See B.4.5.2 of the OpenVMS Linker Utility Manual. */
5589 TRUE
, /* PC relative. */
5591 complain_overflow_dont
,/* Complain_on_overflow. */
5592 reloc_nil
, /* Special_function. */
5594 FALSE
, /* Partial_inplace. */
5595 0xffffffff, /* Source mask. */
5596 0xffffffff, /* Dest mask. */
5597 FALSE
), /* PC rel offset. */
5599 HOWTO (ALPHA_R_BSR
, /* Type. */
5600 0, /* Rightshift. */
5601 3, /* Size (0 = byte, 1 = short, 2 = long). */
5603 TRUE
, /* PC relative. */
5605 complain_overflow_dont
,/* Complain_on_overflow. */
5606 reloc_nil
, /* Special_function. */
5608 FALSE
, /* Partial_inplace. */
5609 0xffffffff, /* Source mask. */
5610 0xffffffff, /* Dest mask. */
5611 FALSE
), /* PC rel offset. */
5613 HOWTO (ALPHA_R_LDA
, /* Type. */
5614 0, /* Rightshift. */
5615 3, /* Size (0 = byte, 1 = short, 2 = long). */
5617 FALSE
, /* PC relative. */
5619 complain_overflow_dont
,/* Complain_on_overflow. */
5620 reloc_nil
, /* Special_function. */
5622 FALSE
, /* Partial_inplace. */
5623 0xffffffff, /* Source mask. */
5624 0xffffffff, /* Dest mask. */
5625 FALSE
), /* PC rel offset. */
5627 HOWTO (ALPHA_R_BOH
, /* Type. */
5628 0, /* Rightshift. */
5629 3, /* Size (0 = byte, 1 = short, 2 = long, 3 = nil). */
5631 TRUE
, /* PC relative. */
5633 complain_overflow_dont
,/* Complain_on_overflow. */
5634 reloc_nil
, /* Special_function. */
5636 FALSE
, /* Partial_inplace. */
5637 0xffffffff, /* Source mask. */
5638 0xffffffff, /* Dest mask. */
5639 FALSE
), /* PC rel offset. */
5642 /* Return a pointer to a howto structure which, when invoked, will perform
5643 the relocation code on data from the architecture noted. */
5645 static reloc_howto_type
*
5646 alpha_vms_bfd_reloc_type_lookup (bfd
* abfd ATTRIBUTE_UNUSED
,
5647 bfd_reloc_code_real_type code
)
5651 vms_debug2 ((1, "vms_bfd_reloc_type_lookup (%p, %d)\t", abfd
, code
));
5655 case BFD_RELOC_16
: alpha_type
= ALPHA_R_SREL16
; break;
5656 case BFD_RELOC_32
: alpha_type
= ALPHA_R_REFLONG
; break;
5657 case BFD_RELOC_64
: alpha_type
= ALPHA_R_REFQUAD
; break;
5658 case BFD_RELOC_CTOR
: alpha_type
= ALPHA_R_REFQUAD
; break;
5659 case BFD_RELOC_23_PCREL_S2
: alpha_type
= ALPHA_R_BRADDR
; break;
5660 case BFD_RELOC_ALPHA_HINT
: alpha_type
= ALPHA_R_HINT
; break;
5661 case BFD_RELOC_16_PCREL
: alpha_type
= ALPHA_R_SREL16
; break;
5662 case BFD_RELOC_32_PCREL
: alpha_type
= ALPHA_R_SREL32
; break;
5663 case BFD_RELOC_64_PCREL
: alpha_type
= ALPHA_R_SREL64
; break;
5664 case BFD_RELOC_ALPHA_LINKAGE
: alpha_type
= ALPHA_R_LINKAGE
; break;
5665 case BFD_RELOC_ALPHA_CODEADDR
: alpha_type
= ALPHA_R_CODEADDR
; break;
5666 case BFD_RELOC_ALPHA_NOP
: alpha_type
= ALPHA_R_NOP
; break;
5667 case BFD_RELOC_ALPHA_BSR
: alpha_type
= ALPHA_R_BSR
; break;
5668 case BFD_RELOC_ALPHA_LDA
: alpha_type
= ALPHA_R_LDA
; break;
5669 case BFD_RELOC_ALPHA_BOH
: alpha_type
= ALPHA_R_BOH
; break;
5671 _bfd_error_handler (_("reloc (%d) is *UNKNOWN*"), code
);
5674 vms_debug2 ((2, "reloc is %s\n", alpha_howto_table
[alpha_type
].name
));
5675 return & alpha_howto_table
[alpha_type
];
5678 static reloc_howto_type
*
5679 alpha_vms_bfd_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
5685 i
< sizeof (alpha_howto_table
) / sizeof (alpha_howto_table
[0]);
5687 if (alpha_howto_table
[i
].name
!= NULL
5688 && strcasecmp (alpha_howto_table
[i
].name
, r_name
) == 0)
5689 return &alpha_howto_table
[i
];
5695 alpha_vms_get_synthetic_symtab (bfd
*abfd
,
5696 long symcount ATTRIBUTE_UNUSED
,
5697 asymbol
**usyms ATTRIBUTE_UNUSED
,
5698 long dynsymcount ATTRIBUTE_UNUSED
,
5699 asymbol
**dynsyms ATTRIBUTE_UNUSED
,
5706 syms
= (asymbol
*) bfd_malloc (PRIV (norm_sym_count
) * sizeof (asymbol
));
5711 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
5713 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
5724 flags
= BSF_LOCAL
| BSF_SYNTHETIC
;
5731 if ((e
->flags
& EGSY__V_DEF
) && (e
->flags
& EGSY__V_NORM
))
5733 value
= e
->code_value
;
5734 sec
= e
->code_section
;
5745 sname
= bfd_alloc (abfd
, l
+ 5);
5748 memcpy (sname
, name
, l
);
5749 memcpy (sname
+ l
, "..en", 5);
5756 sym
->udata
.p
= NULL
;
5765 vms_time_to_str (unsigned char *buf
)
5767 time_t t
= vms_rawtime_to_time_t (buf
);
5768 char *res
= ctime (&t
);
5771 res
= "*invalid time*";
5778 evax_bfd_print_emh (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5780 struct vms_emh_common
*emh
= (struct vms_emh_common
*)rec
;
5781 unsigned int subtype
;
5784 subtype
= (unsigned) bfd_getl16 (emh
->subtyp
);
5786 /* xgettext:c-format */
5787 fprintf (file
, _(" EMH %u (len=%u): "), subtype
, rec_len
);
5789 /* PR 21618: Check for invalid lengths. */
5790 if (rec_len
< sizeof (* emh
))
5792 fprintf (file
, _(" Error: The length is less than the length of an EMH record\n"));
5795 extra
= rec_len
- sizeof (struct vms_emh_common
);
5801 struct vms_emh_mhd
*mhd
= (struct vms_emh_mhd
*) rec
;
5803 const char * nextname
;
5804 const char * maxname
;
5806 /* PR 21840: Check for invalid lengths. */
5807 if (rec_len
< sizeof (* mhd
))
5809 fprintf (file
, _(" Error: The record length is less than the size of an EMH_MHD record\n"));
5812 fprintf (file
, _("Module header\n"));
5813 fprintf (file
, _(" structure level: %u\n"), mhd
->strlvl
);
5814 fprintf (file
, _(" max record size: %u\n"),
5815 (unsigned) bfd_getl32 (mhd
->recsiz
));
5816 name
= (char *)(mhd
+ 1);
5817 maxname
= (char *) rec
+ rec_len
;
5818 if (name
> maxname
- 2)
5820 fprintf (file
, _(" Error: The module name is missing\n"));
5823 nextname
= name
+ name
[0] + 1;
5824 if (nextname
>= maxname
)
5826 fprintf (file
, _(" Error: The module name is too long\n"));
5829 fprintf (file
, _(" module name : %.*s\n"), name
[0], name
+ 1);
5831 if (name
> maxname
- 2)
5833 fprintf (file
, _(" Error: The module version is missing\n"));
5836 nextname
= name
+ name
[0] + 1;
5837 if (nextname
>= maxname
)
5839 fprintf (file
, _(" Error: The module version is too long\n"));
5842 fprintf (file
, _(" module version : %.*s\n"), name
[0], name
+ 1);
5844 if ((maxname
- name
) < 17 && maxname
[-1] != 0)
5845 fprintf (file
, _(" Error: The compile date is truncated\n"));
5847 fprintf (file
, _(" compile date : %.17s\n"), name
);
5852 fprintf (file
, _("Language Processor Name\n"));
5853 fprintf (file
, _(" language name: %.*s\n"), extra
, (char *)(emh
+ 1));
5857 fprintf (file
, _("Source Files Header\n"));
5858 fprintf (file
, _(" file: %.*s\n"), extra
, (char *)(emh
+ 1));
5862 fprintf (file
, _("Title Text Header\n"));
5863 fprintf (file
, _(" title: %.*s\n"), extra
, (char *)(emh
+ 1));
5867 fprintf (file
, _("Copyright Header\n"));
5868 fprintf (file
, _(" copyright: %.*s\n"), extra
, (char *)(emh
+ 1));
5872 fprintf (file
, _("unhandled emh subtype %u\n"), subtype
);
5878 evax_bfd_print_eeom (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5880 struct vms_eeom
*eeom
= (struct vms_eeom
*)rec
;
5882 fprintf (file
, _(" EEOM (len=%u):\n"), rec_len
);
5884 /* PR 21618: Check for invalid lengths. */
5885 if (rec_len
< sizeof (* eeom
))
5887 fprintf (file
, _(" Error: The length is less than the length of an EEOM record\n"));
5891 fprintf (file
, _(" number of cond linkage pairs: %u\n"),
5892 (unsigned)bfd_getl32 (eeom
->total_lps
));
5893 fprintf (file
, _(" completion code: %u\n"),
5894 (unsigned)bfd_getl16 (eeom
->comcod
));
5897 fprintf (file
, _(" transfer addr flags: 0x%02x\n"), eeom
->tfrflg
);
5898 fprintf (file
, _(" transfer addr psect: %u\n"),
5899 (unsigned)bfd_getl32 (eeom
->psindx
));
5900 fprintf (file
, _(" transfer address : 0x%08x\n"),
5901 (unsigned)bfd_getl32 (eeom
->tfradr
));
5906 exav_bfd_print_egsy_flags (unsigned int flags
, FILE *file
)
5908 if (flags
& EGSY__V_WEAK
)
5909 fputs (_(" WEAK"), file
);
5910 if (flags
& EGSY__V_DEF
)
5911 fputs (_(" DEF"), file
);
5912 if (flags
& EGSY__V_UNI
)
5913 fputs (_(" UNI"), file
);
5914 if (flags
& EGSY__V_REL
)
5915 fputs (_(" REL"), file
);
5916 if (flags
& EGSY__V_COMM
)
5917 fputs (_(" COMM"), file
);
5918 if (flags
& EGSY__V_VECEP
)
5919 fputs (_(" VECEP"), file
);
5920 if (flags
& EGSY__V_NORM
)
5921 fputs (_(" NORM"), file
);
5922 if (flags
& EGSY__V_QUAD_VAL
)
5923 fputs (_(" QVAL"), file
);
5927 evax_bfd_print_egsd_flags (FILE *file
, unsigned int flags
)
5929 if (flags
& EGPS__V_PIC
)
5930 fputs (_(" PIC"), file
);
5931 if (flags
& EGPS__V_LIB
)
5932 fputs (_(" LIB"), file
);
5933 if (flags
& EGPS__V_OVR
)
5934 fputs (_(" OVR"), file
);
5935 if (flags
& EGPS__V_REL
)
5936 fputs (_(" REL"), file
);
5937 if (flags
& EGPS__V_GBL
)
5938 fputs (_(" GBL"), file
);
5939 if (flags
& EGPS__V_SHR
)
5940 fputs (_(" SHR"), file
);
5941 if (flags
& EGPS__V_EXE
)
5942 fputs (_(" EXE"), file
);
5943 if (flags
& EGPS__V_RD
)
5944 fputs (_(" RD"), file
);
5945 if (flags
& EGPS__V_WRT
)
5946 fputs (_(" WRT"), file
);
5947 if (flags
& EGPS__V_VEC
)
5948 fputs (_(" VEC"), file
);
5949 if (flags
& EGPS__V_NOMOD
)
5950 fputs (_(" NOMOD"), file
);
5951 if (flags
& EGPS__V_COM
)
5952 fputs (_(" COM"), file
);
5953 if (flags
& EGPS__V_ALLOC_64BIT
)
5954 fputs (_(" 64B"), file
);
5958 evax_bfd_print_egsd (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5960 unsigned int off
= sizeof (struct vms_egsd
);
5963 fprintf (file
, _(" EGSD (len=%u):\n"), rec_len
);
5966 for (off
= sizeof (struct vms_egsd
); off
< rec_len
; )
5968 struct vms_egsd_entry
*e
= (struct vms_egsd_entry
*)(rec
+ off
);
5972 type
= (unsigned)bfd_getl16 (e
->gsdtyp
);
5973 len
= (unsigned)bfd_getl16 (e
->gsdsiz
);
5975 /* xgettext:c-format */
5976 fprintf (file
, _(" EGSD entry %2u (type: %u, len: %u): "),
5980 if (off
+ len
> rec_len
|| off
+ len
< off
)
5982 fprintf (file
, _(" Error: length larger than remaining space in record\n"));
5990 struct vms_egps
*egps
= (struct vms_egps
*)e
;
5991 unsigned int flags
= bfd_getl16 (egps
->flags
);
5994 fprintf (file
, _("PSC - Program section definition\n"));
5995 fprintf (file
, _(" alignment : 2**%u\n"), egps
->align
);
5996 fprintf (file
, _(" flags : 0x%04x"), flags
);
5997 evax_bfd_print_egsd_flags (file
, flags
);
5999 l
= bfd_getl32 (egps
->alloc
);
6000 fprintf (file
, _(" alloc (len): %u (0x%08x)\n"), l
, l
);
6001 fprintf (file
, _(" name : %.*s\n"),
6002 egps
->namlng
, egps
->name
);
6007 struct vms_esgps
*esgps
= (struct vms_esgps
*)e
;
6008 unsigned int flags
= bfd_getl16 (esgps
->flags
);
6011 fprintf (file
, _("SPSC - Shared Image Program section def\n"));
6012 fprintf (file
, _(" alignment : 2**%u\n"), esgps
->align
);
6013 fprintf (file
, _(" flags : 0x%04x"), flags
);
6014 evax_bfd_print_egsd_flags (file
, flags
);
6016 l
= bfd_getl32 (esgps
->alloc
);
6017 fprintf (file
, _(" alloc (len) : %u (0x%08x)\n"), l
, l
);
6018 fprintf (file
, _(" image offset : 0x%08x\n"),
6019 (unsigned int)bfd_getl32 (esgps
->base
));
6020 fprintf (file
, _(" symvec offset : 0x%08x\n"),
6021 (unsigned int)bfd_getl32 (esgps
->value
));
6022 fprintf (file
, _(" name : %.*s\n"),
6023 esgps
->namlng
, esgps
->name
);
6028 struct vms_egsy
*egsy
= (struct vms_egsy
*)e
;
6029 unsigned int flags
= bfd_getl16 (egsy
->flags
);
6031 if (flags
& EGSY__V_DEF
)
6033 struct vms_esdf
*esdf
= (struct vms_esdf
*)e
;
6035 fprintf (file
, _("SYM - Global symbol definition\n"));
6036 fprintf (file
, _(" flags: 0x%04x"), flags
);
6037 exav_bfd_print_egsy_flags (flags
, file
);
6039 fprintf (file
, _(" psect offset: 0x%08x\n"),
6040 (unsigned)bfd_getl32 (esdf
->value
));
6041 if (flags
& EGSY__V_NORM
)
6043 fprintf (file
, _(" code address: 0x%08x\n"),
6044 (unsigned)bfd_getl32 (esdf
->code_address
));
6045 fprintf (file
, _(" psect index for entry point : %u\n"),
6046 (unsigned)bfd_getl32 (esdf
->ca_psindx
));
6048 fprintf (file
, _(" psect index : %u\n"),
6049 (unsigned)bfd_getl32 (esdf
->psindx
));
6050 fprintf (file
, _(" name : %.*s\n"),
6051 esdf
->namlng
, esdf
->name
);
6055 struct vms_esrf
*esrf
= (struct vms_esrf
*)e
;
6057 fprintf (file
, _("SYM - Global symbol reference\n"));
6058 fprintf (file
, _(" name : %.*s\n"),
6059 esrf
->namlng
, esrf
->name
);
6065 struct vms_eidc
*eidc
= (struct vms_eidc
*)e
;
6066 unsigned int flags
= bfd_getl32 (eidc
->flags
);
6069 fprintf (file
, _("IDC - Ident Consistency check\n"));
6070 fprintf (file
, _(" flags : 0x%08x"), flags
);
6071 if (flags
& EIDC__V_BINIDENT
)
6072 fputs (" BINDENT", file
);
6074 fprintf (file
, _(" id match : %x\n"),
6075 (flags
>> EIDC__V_IDMATCH_SH
) & EIDC__V_IDMATCH_MASK
);
6076 fprintf (file
, _(" error severity: %x\n"),
6077 (flags
>> EIDC__V_ERRSEV_SH
) & EIDC__V_ERRSEV_MASK
);
6079 fprintf (file
, _(" entity name : %.*s\n"), p
[0], p
+ 1);
6081 fprintf (file
, _(" object name : %.*s\n"), p
[0], p
+ 1);
6083 if (flags
& EIDC__V_BINIDENT
)
6084 fprintf (file
, _(" binary ident : 0x%08x\n"),
6085 (unsigned)bfd_getl32 (p
+ 1));
6087 fprintf (file
, _(" ascii ident : %.*s\n"), p
[0], p
+ 1);
6092 struct vms_egst
*egst
= (struct vms_egst
*)e
;
6093 unsigned int flags
= bfd_getl16 (egst
->header
.flags
);
6095 fprintf (file
, _("SYMG - Universal symbol definition\n"));
6096 fprintf (file
, _(" flags: 0x%04x"), flags
);
6097 exav_bfd_print_egsy_flags (flags
, file
);
6099 fprintf (file
, _(" symbol vector offset: 0x%08x\n"),
6100 (unsigned)bfd_getl32 (egst
->value
));
6101 fprintf (file
, _(" entry point: 0x%08x\n"),
6102 (unsigned)bfd_getl32 (egst
->lp_1
));
6103 fprintf (file
, _(" proc descr : 0x%08x\n"),
6104 (unsigned)bfd_getl32 (egst
->lp_2
));
6105 fprintf (file
, _(" psect index: %u\n"),
6106 (unsigned)bfd_getl32 (egst
->psindx
));
6107 fprintf (file
, _(" name : %.*s\n"),
6108 egst
->namlng
, egst
->name
);
6113 struct vms_esdfv
*esdfv
= (struct vms_esdfv
*)e
;
6114 unsigned int flags
= bfd_getl16 (esdfv
->flags
);
6116 fprintf (file
, _("SYMV - Vectored symbol definition\n"));
6117 fprintf (file
, _(" flags: 0x%04x"), flags
);
6118 exav_bfd_print_egsy_flags (flags
, file
);
6120 fprintf (file
, _(" vector : 0x%08x\n"),
6121 (unsigned)bfd_getl32 (esdfv
->vector
));
6122 fprintf (file
, _(" psect offset: %u\n"),
6123 (unsigned)bfd_getl32 (esdfv
->value
));
6124 fprintf (file
, _(" psect index : %u\n"),
6125 (unsigned)bfd_getl32 (esdfv
->psindx
));
6126 fprintf (file
, _(" name : %.*s\n"),
6127 esdfv
->namlng
, esdfv
->name
);
6132 struct vms_esdfm
*esdfm
= (struct vms_esdfm
*)e
;
6133 unsigned int flags
= bfd_getl16 (esdfm
->flags
);
6135 fprintf (file
, _("SYMM - Global symbol definition with version\n"));
6136 fprintf (file
, _(" flags: 0x%04x"), flags
);
6137 exav_bfd_print_egsy_flags (flags
, file
);
6139 fprintf (file
, _(" version mask: 0x%08x\n"),
6140 (unsigned)bfd_getl32 (esdfm
->version_mask
));
6141 fprintf (file
, _(" psect offset: %u\n"),
6142 (unsigned)bfd_getl32 (esdfm
->value
));
6143 fprintf (file
, _(" psect index : %u\n"),
6144 (unsigned)bfd_getl32 (esdfm
->psindx
));
6145 fprintf (file
, _(" name : %.*s\n"),
6146 esdfm
->namlng
, esdfm
->name
);
6150 fprintf (file
, _("unhandled egsd entry type %u\n"), type
);
6158 evax_bfd_print_hex (FILE *file
, const char *pfx
,
6159 const unsigned char *buf
, unsigned int len
)
6165 for (i
= 0; i
< len
; i
++)
6169 fprintf (file
, " %02x", buf
[i
]);
6182 evax_bfd_print_etir_stc_ir (FILE *file
, const unsigned char *buf
, int is_ps
)
6184 /* xgettext:c-format */
6185 fprintf (file
, _(" linkage index: %u, replacement insn: 0x%08x\n"),
6186 (unsigned)bfd_getl32 (buf
),
6187 (unsigned)bfd_getl32 (buf
+ 16));
6188 /* xgettext:c-format */
6189 fprintf (file
, _(" psect idx 1: %u, offset 1: 0x%08x %08x\n"),
6190 (unsigned)bfd_getl32 (buf
+ 4),
6191 (unsigned)bfd_getl32 (buf
+ 12),
6192 (unsigned)bfd_getl32 (buf
+ 8));
6193 /* xgettext:c-format */
6194 fprintf (file
, _(" psect idx 2: %u, offset 2: 0x%08x %08x\n"),
6195 (unsigned)bfd_getl32 (buf
+ 20),
6196 (unsigned)bfd_getl32 (buf
+ 28),
6197 (unsigned)bfd_getl32 (buf
+ 24));
6199 /* xgettext:c-format */
6200 fprintf (file
, _(" psect idx 3: %u, offset 3: 0x%08x %08x\n"),
6201 (unsigned)bfd_getl32 (buf
+ 32),
6202 (unsigned)bfd_getl32 (buf
+ 40),
6203 (unsigned)bfd_getl32 (buf
+ 36));
6205 fprintf (file
, _(" global name: %.*s\n"), buf
[32], buf
+ 33);
6209 evax_bfd_print_etir (FILE *file
, const char *name
,
6210 unsigned char *rec
, unsigned int rec_len
)
6212 unsigned int off
= sizeof (struct vms_egsd
);
6213 unsigned int sec_len
= 0;
6215 /* xgettext:c-format */
6216 fprintf (file
, _(" %s (len=%u+%u):\n"), name
,
6217 (unsigned)(rec_len
- sizeof (struct vms_eobjrec
)),
6218 (unsigned)sizeof (struct vms_eobjrec
));
6220 for (off
= sizeof (struct vms_eobjrec
); off
< rec_len
; )
6222 struct vms_etir
*etir
= (struct vms_etir
*)(rec
+ off
);
6227 type
= bfd_getl16 (etir
->rectyp
);
6228 size
= bfd_getl16 (etir
->size
);
6229 buf
= rec
+ off
+ sizeof (struct vms_etir
);
6231 if (off
+ size
> rec_len
|| off
+ size
< off
)
6233 fprintf (file
, _(" Error: length larger than remaining space in record\n"));
6237 /* xgettext:c-format */
6238 fprintf (file
, _(" (type: %3u, size: 4+%3u): "), type
, size
- 4);
6241 case ETIR__C_STA_GBL
:
6242 fprintf (file
, _("STA_GBL (stack global) %.*s\n"),
6245 case ETIR__C_STA_LW
:
6246 fprintf (file
, _("STA_LW (stack longword) 0x%08x\n"),
6247 (unsigned)bfd_getl32 (buf
));
6249 case ETIR__C_STA_QW
:
6250 fprintf (file
, _("STA_QW (stack quadword) 0x%08x %08x\n"),
6251 (unsigned)bfd_getl32 (buf
+ 4),
6252 (unsigned)bfd_getl32 (buf
+ 0));
6254 case ETIR__C_STA_PQ
:
6255 fprintf (file
, _("STA_PQ (stack psect base + offset)\n"));
6256 /* xgettext:c-format */
6257 fprintf (file
, _(" psect: %u, offset: 0x%08x %08x\n"),
6258 (unsigned)bfd_getl32 (buf
+ 0),
6259 (unsigned)bfd_getl32 (buf
+ 8),
6260 (unsigned)bfd_getl32 (buf
+ 4));
6262 case ETIR__C_STA_LI
:
6263 fprintf (file
, _("STA_LI (stack literal)\n"));
6265 case ETIR__C_STA_MOD
:
6266 fprintf (file
, _("STA_MOD (stack module)\n"));
6268 case ETIR__C_STA_CKARG
:
6269 fprintf (file
, _("STA_CKARG (compare procedure argument)\n"));
6273 fprintf (file
, _("STO_B (store byte)\n"));
6276 fprintf (file
, _("STO_W (store word)\n"));
6278 case ETIR__C_STO_LW
:
6279 fprintf (file
, _("STO_LW (store longword)\n"));
6281 case ETIR__C_STO_QW
:
6282 fprintf (file
, _("STO_QW (store quadword)\n"));
6284 case ETIR__C_STO_IMMR
:
6286 unsigned int len
= bfd_getl32 (buf
);
6288 _("STO_IMMR (store immediate repeat) %u bytes\n"),
6290 evax_bfd_print_hex (file
, " ", buf
+ 4, len
);
6294 case ETIR__C_STO_GBL
:
6295 fprintf (file
, _("STO_GBL (store global) %.*s\n"),
6298 case ETIR__C_STO_CA
:
6299 fprintf (file
, _("STO_CA (store code address) %.*s\n"),
6302 case ETIR__C_STO_RB
:
6303 fprintf (file
, _("STO_RB (store relative branch)\n"));
6305 case ETIR__C_STO_AB
:
6306 fprintf (file
, _("STO_AB (store absolute branch)\n"));
6308 case ETIR__C_STO_OFF
:
6309 fprintf (file
, _("STO_OFF (store offset to psect)\n"));
6311 case ETIR__C_STO_IMM
:
6313 unsigned int len
= bfd_getl32 (buf
);
6315 _("STO_IMM (store immediate) %u bytes\n"),
6317 evax_bfd_print_hex (file
, " ", buf
+ 4, len
);
6321 case ETIR__C_STO_GBL_LW
:
6322 fprintf (file
, _("STO_GBL_LW (store global longword) %.*s\n"),
6325 case ETIR__C_STO_LP_PSB
:
6326 fprintf (file
, _("STO_OFF (store LP with procedure signature)\n"));
6328 case ETIR__C_STO_HINT_GBL
:
6329 fprintf (file
, _("STO_BR_GBL (store branch global) *todo*\n"));
6331 case ETIR__C_STO_HINT_PS
:
6332 fprintf (file
, _("STO_BR_PS (store branch psect + offset) *todo*\n"));
6335 case ETIR__C_OPR_NOP
:
6336 fprintf (file
, _("OPR_NOP (no-operation)\n"));
6338 case ETIR__C_OPR_ADD
:
6339 fprintf (file
, _("OPR_ADD (add)\n"));
6341 case ETIR__C_OPR_SUB
:
6342 fprintf (file
, _("OPR_SUB (subtract)\n"));
6344 case ETIR__C_OPR_MUL
:
6345 fprintf (file
, _("OPR_MUL (multiply)\n"));
6347 case ETIR__C_OPR_DIV
:
6348 fprintf (file
, _("OPR_DIV (divide)\n"));
6350 case ETIR__C_OPR_AND
:
6351 fprintf (file
, _("OPR_AND (logical and)\n"));
6353 case ETIR__C_OPR_IOR
:
6354 fprintf (file
, _("OPR_IOR (logical inclusive or)\n"));
6356 case ETIR__C_OPR_EOR
:
6357 fprintf (file
, _("OPR_EOR (logical exclusive or)\n"));
6359 case ETIR__C_OPR_NEG
:
6360 fprintf (file
, _("OPR_NEG (negate)\n"));
6362 case ETIR__C_OPR_COM
:
6363 fprintf (file
, _("OPR_COM (complement)\n"));
6365 case ETIR__C_OPR_INSV
:
6366 fprintf (file
, _("OPR_INSV (insert field)\n"));
6368 case ETIR__C_OPR_ASH
:
6369 fprintf (file
, _("OPR_ASH (arithmetic shift)\n"));
6371 case ETIR__C_OPR_USH
:
6372 fprintf (file
, _("OPR_USH (unsigned shift)\n"));
6374 case ETIR__C_OPR_ROT
:
6375 fprintf (file
, _("OPR_ROT (rotate)\n"));
6377 case ETIR__C_OPR_SEL
:
6378 fprintf (file
, _("OPR_SEL (select)\n"));
6380 case ETIR__C_OPR_REDEF
:
6381 fprintf (file
, _("OPR_REDEF (redefine symbol to curr location)\n"));
6383 case ETIR__C_OPR_DFLIT
:
6384 fprintf (file
, _("OPR_REDEF (define a literal)\n"));
6387 case ETIR__C_STC_LP
:
6388 fprintf (file
, _("STC_LP (store cond linkage pair)\n"));
6390 case ETIR__C_STC_LP_PSB
:
6392 _("STC_LP_PSB (store cond linkage pair + signature)\n"));
6393 /* xgettext:c-format */
6394 fprintf (file
, _(" linkage index: %u, procedure: %.*s\n"),
6395 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6396 buf
+= 4 + 1 + buf
[4];
6397 fprintf (file
, _(" signature: %.*s\n"), buf
[0], buf
+ 1);
6399 case ETIR__C_STC_GBL
:
6400 fprintf (file
, _("STC_GBL (store cond global)\n"));
6401 /* xgettext:c-format */
6402 fprintf (file
, _(" linkage index: %u, global: %.*s\n"),
6403 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6405 case ETIR__C_STC_GCA
:
6406 fprintf (file
, _("STC_GCA (store cond code address)\n"));
6407 /* xgettext:c-format */
6408 fprintf (file
, _(" linkage index: %u, procedure name: %.*s\n"),
6409 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6411 case ETIR__C_STC_PS
:
6412 fprintf (file
, _("STC_PS (store cond psect + offset)\n"));
6414 /* xgettext:c-format */
6415 _(" linkage index: %u, psect: %u, offset: 0x%08x %08x\n"),
6416 (unsigned)bfd_getl32 (buf
),
6417 (unsigned)bfd_getl32 (buf
+ 4),
6418 (unsigned)bfd_getl32 (buf
+ 12),
6419 (unsigned)bfd_getl32 (buf
+ 8));
6421 case ETIR__C_STC_NOP_GBL
:
6422 fprintf (file
, _("STC_NOP_GBL (store cond NOP at global addr)\n"));
6423 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6425 case ETIR__C_STC_NOP_PS
:
6426 fprintf (file
, _("STC_NOP_PS (store cond NOP at psect + offset)\n"));
6427 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6429 case ETIR__C_STC_BSR_GBL
:
6430 fprintf (file
, _("STC_BSR_GBL (store cond BSR at global addr)\n"));
6431 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6433 case ETIR__C_STC_BSR_PS
:
6434 fprintf (file
, _("STC_BSR_PS (store cond BSR at psect + offset)\n"));
6435 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6437 case ETIR__C_STC_LDA_GBL
:
6438 fprintf (file
, _("STC_LDA_GBL (store cond LDA at global addr)\n"));
6439 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6441 case ETIR__C_STC_LDA_PS
:
6442 fprintf (file
, _("STC_LDA_PS (store cond LDA at psect + offset)\n"));
6443 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6445 case ETIR__C_STC_BOH_GBL
:
6446 fprintf (file
, _("STC_BOH_GBL (store cond BOH at global addr)\n"));
6447 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6449 case ETIR__C_STC_BOH_PS
:
6450 fprintf (file
, _("STC_BOH_PS (store cond BOH at psect + offset)\n"));
6451 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6453 case ETIR__C_STC_NBH_GBL
:
6455 _("STC_NBH_GBL (store cond or hint at global addr)\n"));
6457 case ETIR__C_STC_NBH_PS
:
6459 _("STC_NBH_PS (store cond or hint at psect + offset)\n"));
6462 case ETIR__C_CTL_SETRB
:
6463 fprintf (file
, _("CTL_SETRB (set relocation base)\n"));
6466 case ETIR__C_CTL_AUGRB
:
6468 unsigned int val
= bfd_getl32 (buf
);
6469 fprintf (file
, _("CTL_AUGRB (augment relocation base) %u\n"), val
);
6472 case ETIR__C_CTL_DFLOC
:
6473 fprintf (file
, _("CTL_DFLOC (define location)\n"));
6475 case ETIR__C_CTL_STLOC
:
6476 fprintf (file
, _("CTL_STLOC (set location)\n"));
6478 case ETIR__C_CTL_STKDL
:
6479 fprintf (file
, _("CTL_STKDL (stack defined location)\n"));
6482 fprintf (file
, _("*unhandled*\n"));
6490 evax_bfd_print_eobj (struct bfd
*abfd
, FILE *file
)
6492 bfd_boolean is_first
= TRUE
;
6493 bfd_boolean has_records
= FALSE
;
6497 unsigned int rec_len
;
6498 unsigned int pad_len
;
6500 unsigned int hdr_size
;
6505 unsigned char buf
[6];
6510 if (bfd_bread (buf
, sizeof (buf
), abfd
) != sizeof (buf
))
6512 fprintf (file
, _("cannot read GST record length\n"));
6515 rec_len
= bfd_getl16 (buf
+ 0);
6516 if (rec_len
== bfd_getl16 (buf
+ 4)
6517 && bfd_getl16 (buf
+ 2) == EOBJ__C_EMH
)
6519 /* The format is raw: record-size, type, record-size. */
6521 pad_len
= (rec_len
+ 1) & ~1U;
6524 else if (rec_len
== EOBJ__C_EMH
)
6526 has_records
= FALSE
;
6527 pad_len
= bfd_getl16 (buf
+ 2);
6533 fprintf (file
, _("cannot find EMH in first GST record\n"));
6536 rec
= bfd_malloc (pad_len
);
6537 memcpy (rec
, buf
+ sizeof (buf
) - hdr_size
, hdr_size
);
6541 unsigned int rec_len2
= 0;
6542 unsigned char hdr
[4];
6546 unsigned char buf_len
[2];
6548 if (bfd_bread (buf_len
, sizeof (buf_len
), abfd
)
6549 != sizeof (buf_len
))
6551 fprintf (file
, _("cannot read GST record length\n"));
6554 rec_len2
= (unsigned)bfd_getl16 (buf_len
);
6557 if (bfd_bread (hdr
, sizeof (hdr
), abfd
) != sizeof (hdr
))
6559 fprintf (file
, _("cannot read GST record header\n"));
6562 rec_len
= (unsigned)bfd_getl16 (hdr
+ 2);
6564 pad_len
= (rec_len
+ 1) & ~1U;
6567 rec
= bfd_malloc (pad_len
);
6568 memcpy (rec
, hdr
, sizeof (hdr
));
6569 hdr_size
= sizeof (hdr
);
6570 if (has_records
&& rec_len2
!= rec_len
)
6572 fprintf (file
, _(" corrupted GST\n"));
6577 if (bfd_bread (rec
+ hdr_size
, pad_len
- hdr_size
, abfd
)
6578 != pad_len
- hdr_size
)
6580 fprintf (file
, _("cannot read GST record\n"));
6584 type
= (unsigned)bfd_getl16 (rec
);
6589 evax_bfd_print_emh (file
, rec
, rec_len
);
6592 evax_bfd_print_egsd (file
, rec
, rec_len
);
6595 evax_bfd_print_eeom (file
, rec
, rec_len
);
6600 evax_bfd_print_etir (file
, "ETIR", rec
, rec_len
);
6603 evax_bfd_print_etir (file
, "EDBG", rec
, rec_len
);
6606 evax_bfd_print_etir (file
, "ETBT", rec
, rec_len
);
6609 fprintf (file
, _(" unhandled EOBJ record type %u\n"), type
);
6617 evax_bfd_print_relocation_records (FILE *file
, const unsigned char *rel
,
6618 unsigned int stride
)
6626 count
= bfd_getl32 (rel
+ 0);
6630 base
= bfd_getl32 (rel
+ 4);
6632 /* xgettext:c-format */
6633 fprintf (file
, _(" bitcount: %u, base addr: 0x%08x\n"),
6637 for (j
= 0; count
> 0; j
+= 4, count
-= 32)
6643 val
= bfd_getl32 (rel
);
6646 /* xgettext:c-format */
6647 fprintf (file
, _(" bitmap: 0x%08x (count: %u):\n"), val
, count
);
6649 for (k
= 0; k
< 32; k
++)
6650 if (val
& (1u << k
))
6654 fprintf (file
, _(" %08x"), base
+ (j
* 8 + k
) * stride
);
6669 evax_bfd_print_address_fixups (FILE *file
, const unsigned char *rel
)
6676 count
= bfd_getl32 (rel
+ 0);
6679 /* xgettext:c-format */
6680 fprintf (file
, _(" image %u (%u entries)\n"),
6681 (unsigned)bfd_getl32 (rel
+ 4), count
);
6683 for (j
= 0; j
< count
; j
++)
6685 /* xgettext:c-format */
6686 fprintf (file
, _(" offset: 0x%08x, val: 0x%08x\n"),
6687 (unsigned)bfd_getl32 (rel
+ 0),
6688 (unsigned)bfd_getl32 (rel
+ 4));
6695 evax_bfd_print_reference_fixups (FILE *file
, const unsigned char *rel
)
6704 count
= bfd_getl32 (rel
+ 0);
6707 /* xgettext:c-format */
6708 fprintf (file
, _(" image %u (%u entries), offsets:\n"),
6709 (unsigned)bfd_getl32 (rel
+ 4), count
);
6711 for (j
= 0; j
< count
; j
++)
6715 fprintf (file
, _(" 0x%08x"), (unsigned)bfd_getl32 (rel
));
6730 evax_bfd_print_indent (int indent
, FILE *file
)
6732 for (; indent
; indent
--)
6737 evax_bfd_get_dsc_name (unsigned int v
)
6741 case DSC__K_DTYPE_Z
:
6742 return "Z (Unspecified)";
6743 case DSC__K_DTYPE_V
:
6745 case DSC__K_DTYPE_BU
:
6746 return "BU (Byte logical)";
6747 case DSC__K_DTYPE_WU
:
6748 return "WU (Word logical)";
6749 case DSC__K_DTYPE_LU
:
6750 return "LU (Longword logical)";
6751 case DSC__K_DTYPE_QU
:
6752 return "QU (Quadword logical)";
6753 case DSC__K_DTYPE_B
:
6754 return "B (Byte integer)";
6755 case DSC__K_DTYPE_W
:
6756 return "W (Word integer)";
6757 case DSC__K_DTYPE_L
:
6758 return "L (Longword integer)";
6759 case DSC__K_DTYPE_Q
:
6760 return "Q (Quadword integer)";
6761 case DSC__K_DTYPE_F
:
6762 return "F (Single-precision floating)";
6763 case DSC__K_DTYPE_D
:
6764 return "D (Double-precision floating)";
6765 case DSC__K_DTYPE_FC
:
6766 return "FC (Complex)";
6767 case DSC__K_DTYPE_DC
:
6768 return "DC (Double-precision Complex)";
6769 case DSC__K_DTYPE_T
:
6770 return "T (ASCII text string)";
6771 case DSC__K_DTYPE_NU
:
6772 return "NU (Numeric string, unsigned)";
6773 case DSC__K_DTYPE_NL
:
6774 return "NL (Numeric string, left separate sign)";
6775 case DSC__K_DTYPE_NLO
:
6776 return "NLO (Numeric string, left overpunched sign)";
6777 case DSC__K_DTYPE_NR
:
6778 return "NR (Numeric string, right separate sign)";
6779 case DSC__K_DTYPE_NRO
:
6780 return "NRO (Numeric string, right overpunched sig)";
6781 case DSC__K_DTYPE_NZ
:
6782 return "NZ (Numeric string, zoned sign)";
6783 case DSC__K_DTYPE_P
:
6784 return "P (Packed decimal string)";
6785 case DSC__K_DTYPE_ZI
:
6786 return "ZI (Sequence of instructions)";
6787 case DSC__K_DTYPE_ZEM
:
6788 return "ZEM (Procedure entry mask)";
6789 case DSC__K_DTYPE_DSC
:
6790 return "DSC (Descriptor, used for arrays of dyn strings)";
6791 case DSC__K_DTYPE_OU
:
6792 return "OU (Octaword logical)";
6793 case DSC__K_DTYPE_O
:
6794 return "O (Octaword integer)";
6795 case DSC__K_DTYPE_G
:
6796 return "G (Double precision G floating, 64 bit)";
6797 case DSC__K_DTYPE_H
:
6798 return "H (Quadruple precision floating, 128 bit)";
6799 case DSC__K_DTYPE_GC
:
6800 return "GC (Double precision complex, G floating)";
6801 case DSC__K_DTYPE_HC
:
6802 return "HC (Quadruple precision complex, H floating)";
6803 case DSC__K_DTYPE_CIT
:
6804 return "CIT (COBOL intermediate temporary)";
6805 case DSC__K_DTYPE_BPV
:
6806 return "BPV (Bound Procedure Value)";
6807 case DSC__K_DTYPE_BLV
:
6808 return "BLV (Bound Label Value)";
6809 case DSC__K_DTYPE_VU
:
6810 return "VU (Bit Unaligned)";
6811 case DSC__K_DTYPE_ADT
:
6812 return "ADT (Absolute Date-Time)";
6813 case DSC__K_DTYPE_VT
:
6814 return "VT (Varying Text)";
6815 case DSC__K_DTYPE_T2
:
6816 return "T2 (16-bit char)";
6817 case DSC__K_DTYPE_VT2
:
6818 return "VT2 (16-bit varying char)";
6820 return "?? (unknown)";
6825 evax_bfd_print_desc (const unsigned char *buf
, int indent
, FILE *file
)
6827 unsigned char bclass
= buf
[3];
6828 unsigned char dtype
= buf
[2];
6829 unsigned int len
= (unsigned)bfd_getl16 (buf
);
6830 unsigned int pointer
= (unsigned)bfd_getl32 (buf
+ 4);
6832 evax_bfd_print_indent (indent
, file
);
6834 if (len
== 1 && pointer
== 0xffffffffUL
)
6837 fprintf (file
, _("64 bits *unhandled*\n"));
6841 /* xgettext:c-format */
6842 fprintf (file
, _("class: %u, dtype: %u, length: %u, pointer: 0x%08x\n"),
6843 bclass
, dtype
, len
, pointer
);
6846 case DSC__K_CLASS_NCA
:
6848 const struct vms_dsc_nca
*dsc
= (const void *)buf
;
6850 const unsigned char *b
;
6852 evax_bfd_print_indent (indent
, file
);
6853 fprintf (file
, _("non-contiguous array of %s\n"),
6854 evax_bfd_get_dsc_name (dsc
->dtype
));
6855 evax_bfd_print_indent (indent
+ 1, file
);
6857 /* xgettext:c-format */
6858 _("dimct: %u, aflags: 0x%02x, digits: %u, scale: %u\n"),
6859 dsc
->dimct
, dsc
->aflags
, dsc
->digits
, dsc
->scale
);
6860 evax_bfd_print_indent (indent
+ 1, file
);
6862 /* xgettext:c-format */
6863 _("arsize: %u, a0: 0x%08x\n"),
6864 (unsigned)bfd_getl32 (dsc
->arsize
),
6865 (unsigned)bfd_getl32 (dsc
->a0
));
6866 evax_bfd_print_indent (indent
+ 1, file
);
6867 fprintf (file
, _("Strides:\n"));
6868 b
= buf
+ sizeof (*dsc
);
6869 for (i
= 0; i
< dsc
->dimct
; i
++)
6871 evax_bfd_print_indent (indent
+ 2, file
);
6872 fprintf (file
, "[%u]: %u\n", i
+ 1,
6873 (unsigned)bfd_getl32 (b
));
6876 evax_bfd_print_indent (indent
+ 1, file
);
6877 fprintf (file
, _("Bounds:\n"));
6878 b
= buf
+ sizeof (*dsc
);
6879 for (i
= 0; i
< dsc
->dimct
; i
++)
6881 evax_bfd_print_indent (indent
+ 2, file
);
6882 /* xgettext:c-format */
6883 fprintf (file
, _("[%u]: Lower: %u, upper: %u\n"), i
+ 1,
6884 (unsigned)bfd_getl32 (b
+ 0),
6885 (unsigned)bfd_getl32 (b
+ 4));
6890 case DSC__K_CLASS_UBS
:
6892 const struct vms_dsc_ubs
*ubs
= (const void *)buf
;
6894 evax_bfd_print_indent (indent
, file
);
6895 fprintf (file
, _("unaligned bit-string of %s\n"),
6896 evax_bfd_get_dsc_name (ubs
->dtype
));
6897 evax_bfd_print_indent (indent
+ 1, file
);
6899 /* xgettext:c-format */
6900 _("base: %u, pos: %u\n"),
6901 (unsigned)bfd_getl32 (ubs
->base
),
6902 (unsigned)bfd_getl32 (ubs
->pos
));
6906 fprintf (file
, _("*unhandled*\n"));
6913 evax_bfd_print_valspec (const unsigned char *buf
, int indent
, FILE *file
)
6915 unsigned int vflags
= buf
[0];
6916 unsigned int value
= (unsigned)bfd_getl32 (buf
+ 1);
6917 unsigned int len
= 5;
6919 evax_bfd_print_indent (indent
, file
);
6920 /* xgettext:c-format */
6921 fprintf (file
, _("vflags: 0x%02x, value: 0x%08x "), vflags
, value
);
6926 case DST__K_VFLAGS_NOVAL
:
6927 fprintf (file
, _("(no value)\n"));
6929 case DST__K_VFLAGS_NOTACTIVE
:
6930 fprintf (file
, _("(not active)\n"));
6932 case DST__K_VFLAGS_UNALLOC
:
6933 fprintf (file
, _("(not allocated)\n"));
6935 case DST__K_VFLAGS_DSC
:
6936 fprintf (file
, _("(descriptor)\n"));
6937 evax_bfd_print_desc (buf
+ value
, indent
+ 1, file
);
6939 case DST__K_VFLAGS_TVS
:
6940 fprintf (file
, _("(trailing value)\n"));
6942 case DST__K_VS_FOLLOWS
:
6943 fprintf (file
, _("(value spec follows)\n"));
6945 case DST__K_VFLAGS_BITOFFS
:
6946 fprintf (file
, _("(at bit offset %u)\n"), value
);
6949 /* xgettext:c-format */
6950 fprintf (file
, _("(reg: %u, disp: %u, indir: %u, kind: "),
6951 (vflags
& DST__K_REGNUM_MASK
) >> DST__K_REGNUM_SHIFT
,
6952 vflags
& DST__K_DISP
? 1 : 0,
6953 vflags
& DST__K_INDIR
? 1 : 0);
6954 switch (vflags
& DST__K_VALKIND_MASK
)
6956 case DST__K_VALKIND_LITERAL
:
6957 fputs (_("literal"), file
);
6959 case DST__K_VALKIND_ADDR
:
6960 fputs (_("address"), file
);
6962 case DST__K_VALKIND_DESC
:
6963 fputs (_("desc"), file
);
6965 case DST__K_VALKIND_REG
:
6966 fputs (_("reg"), file
);
6969 fputs (")\n", file
);
6976 evax_bfd_print_typspec (const unsigned char *buf
, int indent
, FILE *file
)
6978 unsigned char kind
= buf
[2];
6979 unsigned int len
= (unsigned)bfd_getl16 (buf
);
6981 evax_bfd_print_indent (indent
, file
);
6982 /* xgettext:c-format */
6983 fprintf (file
, _("len: %2u, kind: %2u "), len
, kind
);
6987 case DST__K_TS_ATOM
:
6988 /* xgettext:c-format */
6989 fprintf (file
, _("atomic, type=0x%02x %s\n"),
6990 buf
[0], evax_bfd_get_dsc_name (buf
[0]));
6993 fprintf (file
, _("indirect, defined at 0x%08x\n"),
6994 (unsigned)bfd_getl32 (buf
));
6996 case DST__K_TS_TPTR
:
6997 fprintf (file
, _("typed pointer\n"));
6998 evax_bfd_print_typspec (buf
, indent
+ 1, file
);
7001 fprintf (file
, _("pointer\n"));
7003 case DST__K_TS_ARRAY
:
7005 const unsigned char *vs
;
7006 unsigned int vec_len
;
7009 fprintf (file
, _("array, dim: %u, bitmap: "), buf
[0]);
7010 vec_len
= (buf
[0] + 1 + 7) / 8;
7011 for (i
= 0; i
< vec_len
; i
++)
7012 fprintf (file
, " %02x", buf
[i
+ 1]);
7014 vs
= buf
+ 1 + vec_len
;
7015 evax_bfd_print_indent (indent
, file
);
7016 fprintf (file
, _("array descriptor:\n"));
7017 vs
+= evax_bfd_print_valspec (vs
, indent
+ 1, file
);
7018 for (i
= 0; i
< buf
[0] + 1U; i
++)
7019 if (buf
[1 + i
/ 8] & (1 << (i
% 8)))
7021 evax_bfd_print_indent (indent
, file
);
7023 fprintf (file
, _("type spec for element:\n"));
7025 fprintf (file
, _("type spec for subscript %u:\n"), i
);
7026 evax_bfd_print_typspec (vs
, indent
+ 1, file
);
7027 vs
+= bfd_getl16 (vs
);
7032 fprintf (file
, _("*unhandled*\n"));
7037 evax_bfd_print_dst (struct bfd
*abfd
, unsigned int dst_size
, FILE *file
)
7039 unsigned int off
= 0;
7040 unsigned int pc
= 0;
7041 unsigned int line
= 0;
7043 fprintf (file
, _("Debug symbol table:\n"));
7045 while (dst_size
> 0)
7047 struct vms_dst_header dsth
;
7052 if (bfd_bread (&dsth
, sizeof (dsth
), abfd
) != sizeof (dsth
))
7054 fprintf (file
, _("cannot read DST header\n"));
7057 len
= bfd_getl16 (dsth
.length
);
7058 type
= bfd_getl16 (dsth
.type
);
7059 /* xgettext:c-format */
7060 fprintf (file
, _(" type: %3u, len: %3u (at 0x%08x): "),
7070 len
-= sizeof (dsth
);
7071 buf
= bfd_malloc (len
);
7072 if (bfd_bread (buf
, len
, abfd
) != len
)
7074 fprintf (file
, _("cannot read DST symbol\n"));
7079 case DSC__K_DTYPE_V
:
7080 case DSC__K_DTYPE_BU
:
7081 case DSC__K_DTYPE_WU
:
7082 case DSC__K_DTYPE_LU
:
7083 case DSC__K_DTYPE_QU
:
7084 case DSC__K_DTYPE_B
:
7085 case DSC__K_DTYPE_W
:
7086 case DSC__K_DTYPE_L
:
7087 case DSC__K_DTYPE_Q
:
7088 case DSC__K_DTYPE_F
:
7089 case DSC__K_DTYPE_D
:
7090 case DSC__K_DTYPE_FC
:
7091 case DSC__K_DTYPE_DC
:
7092 case DSC__K_DTYPE_T
:
7093 case DSC__K_DTYPE_NU
:
7094 case DSC__K_DTYPE_NL
:
7095 case DSC__K_DTYPE_NLO
:
7096 case DSC__K_DTYPE_NR
:
7097 case DSC__K_DTYPE_NRO
:
7098 case DSC__K_DTYPE_NZ
:
7099 case DSC__K_DTYPE_P
:
7100 case DSC__K_DTYPE_ZI
:
7101 case DSC__K_DTYPE_ZEM
:
7102 case DSC__K_DTYPE_DSC
:
7103 case DSC__K_DTYPE_OU
:
7104 case DSC__K_DTYPE_O
:
7105 case DSC__K_DTYPE_G
:
7106 case DSC__K_DTYPE_H
:
7107 case DSC__K_DTYPE_GC
:
7108 case DSC__K_DTYPE_HC
:
7109 case DSC__K_DTYPE_CIT
:
7110 case DSC__K_DTYPE_BPV
:
7111 case DSC__K_DTYPE_BLV
:
7112 case DSC__K_DTYPE_VU
:
7113 case DSC__K_DTYPE_ADT
:
7114 case DSC__K_DTYPE_VT
:
7115 case DSC__K_DTYPE_T2
:
7116 case DSC__K_DTYPE_VT2
:
7117 fprintf (file
, _("standard data: %s\n"),
7118 evax_bfd_get_dsc_name (type
));
7119 evax_bfd_print_valspec (buf
, 4, file
);
7120 fprintf (file
, _(" name: %.*s\n"), buf
[5], buf
+ 6);
7124 struct vms_dst_modbeg
*dst
= (void *)buf
;
7125 const char *name
= (const char *)buf
+ sizeof (*dst
);
7127 fprintf (file
, _("modbeg\n"));
7128 /* xgettext:c-format */
7129 fprintf (file
, _(" flags: %d, language: %u, "
7130 "major: %u, minor: %u\n"),
7132 (unsigned)bfd_getl32 (dst
->language
),
7133 (unsigned)bfd_getl16 (dst
->major
),
7134 (unsigned)bfd_getl16 (dst
->minor
));
7135 fprintf (file
, _(" module name: %.*s\n"),
7137 name
+= name
[0] + 1;
7138 fprintf (file
, _(" compiler : %.*s\n"),
7143 fprintf (file
, _("modend\n"));
7147 struct vms_dst_rtnbeg
*dst
= (void *)buf
;
7148 const char *name
= (const char *)buf
+ sizeof (*dst
);
7150 fputs (_("rtnbeg\n"), file
);
7151 /* xgettext:c-format */
7152 fprintf (file
, _(" flags: %u, address: 0x%08x, "
7153 "pd-address: 0x%08x\n"),
7155 (unsigned)bfd_getl32 (dst
->address
),
7156 (unsigned)bfd_getl32 (dst
->pd_address
));
7157 fprintf (file
, _(" routine name: %.*s\n"),
7163 struct vms_dst_rtnend
*dst
= (void *)buf
;
7165 fprintf (file
, _("rtnend: size 0x%08x\n"),
7166 (unsigned)bfd_getl32 (dst
->size
));
7171 struct vms_dst_prolog
*dst
= (void *)buf
;
7173 fprintf (file
, _("prolog: bkpt address 0x%08x\n"),
7174 (unsigned)bfd_getl32 (dst
->bkpt_addr
));
7179 struct vms_dst_epilog
*dst
= (void *)buf
;
7181 /* xgettext:c-format */
7182 fprintf (file
, _("epilog: flags: %u, count: %u\n"),
7183 dst
->flags
, (unsigned)bfd_getl32 (dst
->count
));
7188 struct vms_dst_blkbeg
*dst
= (void *)buf
;
7189 const char *name
= (const char *)buf
+ sizeof (*dst
);
7191 /* xgettext:c-format */
7192 fprintf (file
, _("blkbeg: address: 0x%08x, name: %.*s\n"),
7193 (unsigned)bfd_getl32 (dst
->address
),
7199 struct vms_dst_blkend
*dst
= (void *)buf
;
7201 fprintf (file
, _("blkend: size: 0x%08x\n"),
7202 (unsigned)bfd_getl32 (dst
->size
));
7205 case DST__K_TYPSPEC
:
7207 fprintf (file
, _("typspec (len: %u)\n"), len
);
7208 fprintf (file
, _(" name: %.*s\n"), buf
[0], buf
+ 1);
7209 evax_bfd_print_typspec (buf
+ 1 + buf
[0], 5, file
);
7214 fprintf (file
, _("septyp, name: %.*s\n"), buf
[5], buf
+ 6);
7215 evax_bfd_print_valspec (buf
, 4, file
);
7220 struct vms_dst_recbeg
*recbeg
= (void *)buf
;
7221 const char *name
= (const char *)buf
+ sizeof (*recbeg
);
7223 fprintf (file
, _("recbeg: name: %.*s\n"), name
[0], name
+ 1);
7224 evax_bfd_print_valspec (buf
, 4, file
);
7225 fprintf (file
, _(" len: %u bits\n"),
7226 (unsigned)bfd_getl32 (name
+ 1 + name
[0]));
7230 fprintf (file
, _("recend\n"));
7232 case DST__K_ENUMBEG
:
7233 /* xgettext:c-format */
7234 fprintf (file
, _("enumbeg, len: %u, name: %.*s\n"),
7235 buf
[0], buf
[1], buf
+ 2);
7237 case DST__K_ENUMELT
:
7238 fprintf (file
, _("enumelt, name: %.*s\n"), buf
[5], buf
+ 6);
7239 evax_bfd_print_valspec (buf
, 4, file
);
7241 case DST__K_ENUMEND
:
7242 fprintf (file
, _("enumend\n"));
7246 struct vms_dst_label
*lab
= (void *)buf
;
7247 fprintf (file
, _("label, name: %.*s\n"),
7248 lab
->name
[0], lab
->name
+ 1);
7249 fprintf (file
, _(" address: 0x%08x\n"),
7250 (unsigned)bfd_getl32 (lab
->value
));
7253 case DST__K_DIS_RANGE
:
7255 unsigned int cnt
= bfd_getl32 (buf
);
7256 unsigned char *rng
= buf
+ 4;
7259 fprintf (file
, _("discontiguous range (nbr: %u)\n"), cnt
);
7260 for (i
= 0; i
< cnt
; i
++, rng
+= 8)
7261 /* xgettext:c-format */
7262 fprintf (file
, _(" address: 0x%08x, size: %u\n"),
7263 (unsigned)bfd_getl32 (rng
),
7264 (unsigned)bfd_getl32 (rng
+ 4));
7268 case DST__K_LINE_NUM
:
7270 unsigned char *buf_orig
= buf
;
7272 fprintf (file
, _("line num (len: %u)\n"), len
);
7277 unsigned char cmdlen
;
7287 case DST__K_DELTA_PC_W
:
7288 val
= bfd_getl16 (buf
+ 1);
7289 fprintf (file
, _("delta_pc_w %u\n"), val
);
7294 case DST__K_INCR_LINUM
:
7296 fprintf (file
, _("incr_linum(b): +%u\n"), val
);
7300 case DST__K_INCR_LINUM_W
:
7301 val
= bfd_getl16 (buf
+ 1);
7302 fprintf (file
, _("incr_linum_w: +%u\n"), val
);
7306 case DST__K_INCR_LINUM_L
:
7307 val
= bfd_getl32 (buf
+ 1);
7308 fprintf (file
, _("incr_linum_l: +%u\n"), val
);
7312 case DST__K_SET_LINUM
:
7313 line
= bfd_getl16 (buf
+ 1);
7314 fprintf (file
, _("set_line_num(w) %u\n"), line
);
7317 case DST__K_SET_LINUM_B
:
7319 fprintf (file
, _("set_line_num_b %u\n"), line
);
7322 case DST__K_SET_LINUM_L
:
7323 line
= bfd_getl32 (buf
+ 1);
7324 fprintf (file
, _("set_line_num_l %u\n"), line
);
7327 case DST__K_SET_ABS_PC
:
7328 pc
= bfd_getl32 (buf
+ 1);
7329 fprintf (file
, _("set_abs_pc: 0x%08x\n"), pc
);
7332 case DST__K_DELTA_PC_L
:
7333 fprintf (file
, _("delta_pc_l: +0x%08x\n"),
7334 (unsigned)bfd_getl32 (buf
+ 1));
7338 fprintf (file
, _("term(b): 0x%02x"), buf
[1]);
7340 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7344 val
= bfd_getl16 (buf
+ 1);
7345 fprintf (file
, _("term_w: 0x%04x"), val
);
7347 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7353 fprintf (file
, _("delta pc +%-4d"), -cmd
);
7354 line
++; /* FIXME: curr increment. */
7356 /* xgettext:c-format */
7357 fprintf (file
, _(" pc: 0x%08x line: %5u\n"),
7362 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7375 unsigned char *buf_orig
= buf
;
7377 fprintf (file
, _("source (len: %u)\n"), len
);
7381 signed char cmd
= buf
[0];
7382 unsigned char cmdlen
= 0;
7386 case DST__K_SRC_DECLFILE
:
7388 struct vms_dst_src_decl_src
*src
= (void *)(buf
+ 1);
7391 /* xgettext:c-format */
7392 fprintf (file
, _(" declfile: len: %u, flags: %u, "
7394 src
->length
, src
->flags
,
7395 (unsigned)bfd_getl16 (src
->fileid
));
7396 /* xgettext:c-format */
7397 fprintf (file
, _(" rms: cdt: 0x%08x %08x, "
7398 "ebk: 0x%08x, ffb: 0x%04x, "
7400 (unsigned)bfd_getl32 (src
->rms_cdt
+ 4),
7401 (unsigned)bfd_getl32 (src
->rms_cdt
+ 0),
7402 (unsigned)bfd_getl32 (src
->rms_ebk
),
7403 (unsigned)bfd_getl16 (src
->rms_ffb
),
7405 name
= (const char *)buf
+ 1 + sizeof (*src
);
7406 fprintf (file
, _(" filename : %.*s\n"),
7408 name
+= name
[0] + 1;
7409 fprintf (file
, _(" module name: %.*s\n"),
7411 cmdlen
= 2 + src
->length
;
7414 case DST__K_SRC_SETFILE
:
7415 fprintf (file
, _(" setfile %u\n"),
7416 (unsigned)bfd_getl16 (buf
+ 1));
7419 case DST__K_SRC_SETREC_W
:
7420 fprintf (file
, _(" setrec %u\n"),
7421 (unsigned)bfd_getl16 (buf
+ 1));
7424 case DST__K_SRC_SETREC_L
:
7425 fprintf (file
, _(" setrec %u\n"),
7426 (unsigned)bfd_getl32 (buf
+ 1));
7429 case DST__K_SRC_SETLNUM_W
:
7430 fprintf (file
, _(" setlnum %u\n"),
7431 (unsigned)bfd_getl16 (buf
+ 1));
7434 case DST__K_SRC_SETLNUM_L
:
7435 fprintf (file
, _(" setlnum %u\n"),
7436 (unsigned)bfd_getl32 (buf
+ 1));
7439 case DST__K_SRC_DEFLINES_W
:
7440 fprintf (file
, _(" deflines %u\n"),
7441 (unsigned)bfd_getl16 (buf
+ 1));
7444 case DST__K_SRC_DEFLINES_B
:
7445 fprintf (file
, _(" deflines %u\n"), buf
[1]);
7448 case DST__K_SRC_FORMFEED
:
7449 fprintf (file
, _(" formfeed\n"));
7453 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7465 fprintf (file
, _("*unhandled* dst type %u\n"), type
);
7473 evax_bfd_print_image (bfd
*abfd
, FILE *file
)
7475 struct vms_eihd eihd
;
7478 unsigned int eiha_off
;
7479 unsigned int eihi_off
;
7480 unsigned int eihs_off
;
7481 unsigned int eisd_off
;
7482 unsigned int eihef_off
= 0;
7483 unsigned int eihnp_off
= 0;
7484 unsigned int dmt_vbn
= 0;
7485 unsigned int dmt_size
= 0;
7486 unsigned int dst_vbn
= 0;
7487 unsigned int dst_size
= 0;
7488 unsigned int gst_vbn
= 0;
7489 unsigned int gst_size
= 0;
7490 unsigned int eiaf_vbn
= 0;
7491 unsigned int eiaf_size
= 0;
7492 unsigned int eihvn_off
;
7494 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
)
7495 || bfd_bread (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
7497 fprintf (file
, _("cannot read EIHD\n"));
7500 /* xgettext:c-format */
7501 fprintf (file
, _("EIHD: (size: %u, nbr blocks: %u)\n"),
7502 (unsigned)bfd_getl32 (eihd
.size
),
7503 (unsigned)bfd_getl32 (eihd
.hdrblkcnt
));
7504 /* xgettext:c-format */
7505 fprintf (file
, _(" majorid: %u, minorid: %u\n"),
7506 (unsigned)bfd_getl32 (eihd
.majorid
),
7507 (unsigned)bfd_getl32 (eihd
.minorid
));
7509 val
= (unsigned)bfd_getl32 (eihd
.imgtype
);
7513 name
= _("executable");
7516 name
= _("linkable image");
7519 name
= _("unknown");
7522 /* xgettext:c-format */
7523 fprintf (file
, _(" image type: %u (%s)"), val
, name
);
7525 val
= (unsigned)bfd_getl32 (eihd
.subtype
);
7528 case EIHD__C_NATIVE
:
7535 name
= _("unknown");
7538 /* xgettext:c-format */
7539 fprintf (file
, _(", subtype: %u (%s)\n"), val
, name
);
7541 eisd_off
= bfd_getl32 (eihd
.isdoff
);
7542 eiha_off
= bfd_getl32 (eihd
.activoff
);
7543 eihi_off
= bfd_getl32 (eihd
.imgidoff
);
7544 eihs_off
= bfd_getl32 (eihd
.symdbgoff
);
7545 /* xgettext:c-format */
7546 fprintf (file
, _(" offsets: isd: %u, activ: %u, symdbg: %u, "
7547 "imgid: %u, patch: %u\n"),
7548 eisd_off
, eiha_off
, eihs_off
, eihi_off
,
7549 (unsigned)bfd_getl32 (eihd
.patchoff
));
7550 fprintf (file
, _(" fixup info rva: "));
7551 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.iafva
));
7552 fprintf (file
, _(", symbol vector rva: "));
7553 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.symvva
));
7554 eihvn_off
= bfd_getl32 (eihd
.version_array_off
);
7555 fprintf (file
, _("\n"
7556 " version array off: %u\n"),
7559 /* xgettext:c-format */
7560 _(" img I/O count: %u, nbr channels: %u, req pri: %08x%08x\n"),
7561 (unsigned)bfd_getl32 (eihd
.imgiocnt
),
7562 (unsigned)bfd_getl32 (eihd
.iochancnt
),
7563 (unsigned)bfd_getl32 (eihd
.privreqs
+ 4),
7564 (unsigned)bfd_getl32 (eihd
.privreqs
+ 0));
7565 val
= (unsigned)bfd_getl32 (eihd
.lnkflags
);
7566 fprintf (file
, _(" linker flags: %08x:"), val
);
7567 if (val
& EIHD__M_LNKDEBUG
)
7568 fprintf (file
, " LNKDEBUG");
7569 if (val
& EIHD__M_LNKNOTFR
)
7570 fprintf (file
, " LNKNOTFR");
7571 if (val
& EIHD__M_NOP0BUFS
)
7572 fprintf (file
, " NOP0BUFS");
7573 if (val
& EIHD__M_PICIMG
)
7574 fprintf (file
, " PICIMG");
7575 if (val
& EIHD__M_P0IMAGE
)
7576 fprintf (file
, " P0IMAGE");
7577 if (val
& EIHD__M_DBGDMT
)
7578 fprintf (file
, " DBGDMT");
7579 if (val
& EIHD__M_INISHR
)
7580 fprintf (file
, " INISHR");
7581 if (val
& EIHD__M_XLATED
)
7582 fprintf (file
, " XLATED");
7583 if (val
& EIHD__M_BIND_CODE_SEC
)
7584 fprintf (file
, " BIND_CODE_SEC");
7585 if (val
& EIHD__M_BIND_DATA_SEC
)
7586 fprintf (file
, " BIND_DATA_SEC");
7587 if (val
& EIHD__M_MKTHREADS
)
7588 fprintf (file
, " MKTHREADS");
7589 if (val
& EIHD__M_UPCALLS
)
7590 fprintf (file
, " UPCALLS");
7591 if (val
& EIHD__M_OMV_READY
)
7592 fprintf (file
, " OMV_READY");
7593 if (val
& EIHD__M_EXT_BIND_SECT
)
7594 fprintf (file
, " EXT_BIND_SECT");
7595 fprintf (file
, "\n");
7596 /* xgettext:c-format */
7597 fprintf (file
, _(" ident: 0x%08x, sysver: 0x%08x, "
7598 "match ctrl: %u, symvect_size: %u\n"),
7599 (unsigned)bfd_getl32 (eihd
.ident
),
7600 (unsigned)bfd_getl32 (eihd
.sysver
),
7602 (unsigned)bfd_getl32 (eihd
.symvect_size
));
7603 fprintf (file
, _(" BPAGE: %u"),
7604 (unsigned)bfd_getl32 (eihd
.virt_mem_block_size
));
7605 if (val
& (EIHD__M_OMV_READY
| EIHD__M_EXT_BIND_SECT
))
7607 eihef_off
= bfd_getl32 (eihd
.ext_fixup_off
);
7608 eihnp_off
= bfd_getl32 (eihd
.noopt_psect_off
);
7609 /* xgettext:c-format */
7610 fprintf (file
, _(", ext fixup offset: %u, no_opt psect off: %u"),
7611 eihef_off
, eihnp_off
);
7613 fprintf (file
, _(", alias: %u\n"), (unsigned)bfd_getl16 (eihd
.alias
));
7617 struct vms_eihvn eihvn
;
7621 fprintf (file
, _("system version array information:\n"));
7622 if (bfd_seek (abfd
, (file_ptr
) eihvn_off
, SEEK_SET
)
7623 || bfd_bread (&eihvn
, sizeof (eihvn
), abfd
) != sizeof (eihvn
))
7625 fprintf (file
, _("cannot read EIHVN header\n"));
7628 mask
= bfd_getl32 (eihvn
.subsystem_mask
);
7629 for (j
= 0; j
< 32; j
++)
7630 if (mask
& (1 << j
))
7632 struct vms_eihvn_subversion ver
;
7633 if (bfd_bread (&ver
, sizeof (ver
), abfd
) != sizeof (ver
))
7635 fprintf (file
, _("cannot read EIHVN version\n"));
7638 fprintf (file
, _(" %02u "), j
);
7641 case EIHVN__BASE_IMAGE_BIT
:
7642 fputs (_("BASE_IMAGE "), file
);
7644 case EIHVN__MEMORY_MANAGEMENT_BIT
:
7645 fputs (_("MEMORY_MANAGEMENT"), file
);
7648 fputs (_("IO "), file
);
7650 case EIHVN__FILES_VOLUMES_BIT
:
7651 fputs (_("FILES_VOLUMES "), file
);
7653 case EIHVN__PROCESS_SCHED_BIT
:
7654 fputs (_("PROCESS_SCHED "), file
);
7656 case EIHVN__SYSGEN_BIT
:
7657 fputs (_("SYSGEN "), file
);
7659 case EIHVN__CLUSTERS_LOCKMGR_BIT
:
7660 fputs (_("CLUSTERS_LOCKMGR "), file
);
7662 case EIHVN__LOGICAL_NAMES_BIT
:
7663 fputs (_("LOGICAL_NAMES "), file
);
7665 case EIHVN__SECURITY_BIT
:
7666 fputs (_("SECURITY "), file
);
7668 case EIHVN__IMAGE_ACTIVATOR_BIT
:
7669 fputs (_("IMAGE_ACTIVATOR "), file
);
7671 case EIHVN__NETWORKS_BIT
:
7672 fputs (_("NETWORKS "), file
);
7674 case EIHVN__COUNTERS_BIT
:
7675 fputs (_("COUNTERS "), file
);
7677 case EIHVN__STABLE_BIT
:
7678 fputs (_("STABLE "), file
);
7680 case EIHVN__MISC_BIT
:
7681 fputs (_("MISC "), file
);
7683 case EIHVN__CPU_BIT
:
7684 fputs (_("CPU "), file
);
7686 case EIHVN__VOLATILE_BIT
:
7687 fputs (_("VOLATILE "), file
);
7689 case EIHVN__SHELL_BIT
:
7690 fputs (_("SHELL "), file
);
7692 case EIHVN__POSIX_BIT
:
7693 fputs (_("POSIX "), file
);
7695 case EIHVN__MULTI_PROCESSING_BIT
:
7696 fputs (_("MULTI_PROCESSING "), file
);
7698 case EIHVN__GALAXY_BIT
:
7699 fputs (_("GALAXY "), file
);
7702 fputs (_("*unknown* "), file
);
7705 fprintf (file
, ": %u.%u\n",
7706 (unsigned)bfd_getl16 (ver
.major
),
7707 (unsigned)bfd_getl16 (ver
.minor
));
7713 struct vms_eiha eiha
;
7715 if (bfd_seek (abfd
, (file_ptr
) eiha_off
, SEEK_SET
)
7716 || bfd_bread (&eiha
, sizeof (eiha
), abfd
) != sizeof (eiha
))
7718 fprintf (file
, _("cannot read EIHA\n"));
7721 fprintf (file
, _("Image activation: (size=%u)\n"),
7722 (unsigned)bfd_getl32 (eiha
.size
));
7723 /* xgettext:c-format */
7724 fprintf (file
, _(" First address : 0x%08x 0x%08x\n"),
7725 (unsigned)bfd_getl32 (eiha
.tfradr1_h
),
7726 (unsigned)bfd_getl32 (eiha
.tfradr1
));
7727 /* xgettext:c-format */
7728 fprintf (file
, _(" Second address: 0x%08x 0x%08x\n"),
7729 (unsigned)bfd_getl32 (eiha
.tfradr2_h
),
7730 (unsigned)bfd_getl32 (eiha
.tfradr2
));
7731 /* xgettext:c-format */
7732 fprintf (file
, _(" Third address : 0x%08x 0x%08x\n"),
7733 (unsigned)bfd_getl32 (eiha
.tfradr3_h
),
7734 (unsigned)bfd_getl32 (eiha
.tfradr3
));
7735 /* xgettext:c-format */
7736 fprintf (file
, _(" Fourth address: 0x%08x 0x%08x\n"),
7737 (unsigned)bfd_getl32 (eiha
.tfradr4_h
),
7738 (unsigned)bfd_getl32 (eiha
.tfradr4
));
7739 /* xgettext:c-format */
7740 fprintf (file
, _(" Shared image : 0x%08x 0x%08x\n"),
7741 (unsigned)bfd_getl32 (eiha
.inishr_h
),
7742 (unsigned)bfd_getl32 (eiha
.inishr
));
7746 struct vms_eihi eihi
;
7748 if (bfd_seek (abfd
, (file_ptr
) eihi_off
, SEEK_SET
)
7749 || bfd_bread (&eihi
, sizeof (eihi
), abfd
) != sizeof (eihi
))
7751 fprintf (file
, _("cannot read EIHI\n"));
7754 /* xgettext:c-format */
7755 fprintf (file
, _("Image identification: (major: %u, minor: %u)\n"),
7756 (unsigned)bfd_getl32 (eihi
.majorid
),
7757 (unsigned)bfd_getl32 (eihi
.minorid
));
7758 fprintf (file
, _(" image name : %.*s\n"),
7759 eihi
.imgnam
[0], eihi
.imgnam
+ 1);
7760 fprintf (file
, _(" link time : %s\n"),
7761 vms_time_to_str (eihi
.linktime
));
7762 fprintf (file
, _(" image ident : %.*s\n"),
7763 eihi
.imgid
[0], eihi
.imgid
+ 1);
7764 fprintf (file
, _(" linker ident : %.*s\n"),
7765 eihi
.linkid
[0], eihi
.linkid
+ 1);
7766 fprintf (file
, _(" image build ident: %.*s\n"),
7767 eihi
.imgbid
[0], eihi
.imgbid
+ 1);
7771 struct vms_eihs eihs
;
7773 if (bfd_seek (abfd
, (file_ptr
) eihs_off
, SEEK_SET
)
7774 || bfd_bread (&eihs
, sizeof (eihs
), abfd
) != sizeof (eihs
))
7776 fprintf (file
, _("cannot read EIHS\n"));
7779 /* xgettext:c-format */
7780 fprintf (file
, _("Image symbol & debug table: (major: %u, minor: %u)\n"),
7781 (unsigned)bfd_getl32 (eihs
.majorid
),
7782 (unsigned)bfd_getl32 (eihs
.minorid
));
7783 dst_vbn
= bfd_getl32 (eihs
.dstvbn
);
7784 dst_size
= bfd_getl32 (eihs
.dstsize
);
7785 /* xgettext:c-format */
7786 fprintf (file
, _(" debug symbol table : vbn: %u, size: %u (0x%x)\n"),
7787 dst_vbn
, dst_size
, dst_size
);
7788 gst_vbn
= bfd_getl32 (eihs
.gstvbn
);
7789 gst_size
= bfd_getl32 (eihs
.gstsize
);
7790 /* xgettext:c-format */
7791 fprintf (file
, _(" global symbol table: vbn: %u, records: %u\n"),
7793 dmt_vbn
= bfd_getl32 (eihs
.dmtvbn
);
7794 dmt_size
= bfd_getl32 (eihs
.dmtsize
);
7795 /* xgettext:c-format */
7796 fprintf (file
, _(" debug module table : vbn: %u, size: %u\n"),
7799 while (eisd_off
!= 0)
7801 struct vms_eisd eisd
;
7806 if (bfd_seek (abfd
, (file_ptr
) eisd_off
, SEEK_SET
)
7807 || bfd_bread (&eisd
, sizeof (eisd
), abfd
) != sizeof (eisd
))
7809 fprintf (file
, _("cannot read EISD\n"));
7812 len
= (unsigned)bfd_getl32 (eisd
.eisdsize
);
7813 if (len
!= (unsigned)-1)
7817 eisd_off
= (eisd_off
+ VMS_BLOCK_SIZE
) & ~(VMS_BLOCK_SIZE
- 1);
7819 /* xgettext:c-format */
7820 fprintf (file
, _("Image section descriptor: (major: %u, minor: %u, "
7821 "size: %u, offset: %u)\n"),
7822 (unsigned)bfd_getl32 (eisd
.majorid
),
7823 (unsigned)bfd_getl32 (eisd
.minorid
),
7827 /* xgettext:c-format */
7828 fprintf (file
, _(" section: base: 0x%08x%08x size: 0x%08x\n"),
7829 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 4),
7830 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 0),
7831 (unsigned)bfd_getl32 (eisd
.secsize
));
7832 val
= (unsigned)bfd_getl32 (eisd
.flags
);
7833 fprintf (file
, _(" flags: 0x%04x"), val
);
7834 if (val
& EISD__M_GBL
)
7835 fprintf (file
, " GBL");
7836 if (val
& EISD__M_CRF
)
7837 fprintf (file
, " CRF");
7838 if (val
& EISD__M_DZRO
)
7839 fprintf (file
, " DZRO");
7840 if (val
& EISD__M_WRT
)
7841 fprintf (file
, " WRT");
7842 if (val
& EISD__M_INITALCODE
)
7843 fprintf (file
, " INITALCODE");
7844 if (val
& EISD__M_BASED
)
7845 fprintf (file
, " BASED");
7846 if (val
& EISD__M_FIXUPVEC
)
7847 fprintf (file
, " FIXUPVEC");
7848 if (val
& EISD__M_RESIDENT
)
7849 fprintf (file
, " RESIDENT");
7850 if (val
& EISD__M_VECTOR
)
7851 fprintf (file
, " VECTOR");
7852 if (val
& EISD__M_PROTECT
)
7853 fprintf (file
, " PROTECT");
7854 if (val
& EISD__M_LASTCLU
)
7855 fprintf (file
, " LASTCLU");
7856 if (val
& EISD__M_EXE
)
7857 fprintf (file
, " EXE");
7858 if (val
& EISD__M_NONSHRADR
)
7859 fprintf (file
, " NONSHRADR");
7860 if (val
& EISD__M_QUAD_LENGTH
)
7861 fprintf (file
, " QUAD_LENGTH");
7862 if (val
& EISD__M_ALLOC_64BIT
)
7863 fprintf (file
, " ALLOC_64BIT");
7864 fprintf (file
, "\n");
7865 if (val
& EISD__M_FIXUPVEC
)
7867 eiaf_vbn
= bfd_getl32 (eisd
.vbn
);
7868 eiaf_size
= bfd_getl32 (eisd
.secsize
);
7870 /* xgettext:c-format */
7871 fprintf (file
, _(" vbn: %u, pfc: %u, matchctl: %u type: %u ("),
7872 (unsigned)bfd_getl32 (eisd
.vbn
),
7873 eisd
.pfc
, eisd
.matchctl
, eisd
.type
);
7876 case EISD__K_NORMAL
:
7877 fputs (_("NORMAL"), file
);
7879 case EISD__K_SHRFXD
:
7880 fputs (_("SHRFXD"), file
);
7882 case EISD__K_PRVFXD
:
7883 fputs (_("PRVFXD"), file
);
7885 case EISD__K_SHRPIC
:
7886 fputs (_("SHRPIC"), file
);
7888 case EISD__K_PRVPIC
:
7889 fputs (_("PRVPIC"), file
);
7891 case EISD__K_USRSTACK
:
7892 fputs (_("USRSTACK"), file
);
7895 fputs (_("*unknown*"), file
);
7898 fputs (_(")\n"), file
);
7899 if (val
& EISD__M_GBL
)
7900 /* xgettext:c-format */
7901 fprintf (file
, _(" ident: 0x%08x, name: %.*s\n"),
7902 (unsigned)bfd_getl32 (eisd
.ident
),
7903 eisd
.gblnam
[0], eisd
.gblnam
+ 1);
7909 if (bfd_seek (abfd
, (file_ptr
) (dmt_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7911 fprintf (file
, _("cannot read DMT\n"));
7915 fprintf (file
, _("Debug module table:\n"));
7917 while (dmt_size
> 0)
7919 struct vms_dmt_header dmth
;
7922 if (bfd_bread (&dmth
, sizeof (dmth
), abfd
) != sizeof (dmth
))
7924 fprintf (file
, _("cannot read DMT header\n"));
7927 count
= bfd_getl16 (dmth
.psect_count
);
7929 /* xgettext:c-format */
7930 _(" module offset: 0x%08x, size: 0x%08x, (%u psects)\n"),
7931 (unsigned)bfd_getl32 (dmth
.modbeg
),
7932 (unsigned)bfd_getl32 (dmth
.size
), count
);
7933 dmt_size
-= sizeof (dmth
);
7936 struct vms_dmt_psect dmtp
;
7938 if (bfd_bread (&dmtp
, sizeof (dmtp
), abfd
) != sizeof (dmtp
))
7940 fprintf (file
, _("cannot read DMT psect\n"));
7943 /* xgettext:c-format */
7944 fprintf (file
, _(" psect start: 0x%08x, length: %u\n"),
7945 (unsigned)bfd_getl32 (dmtp
.start
),
7946 (unsigned)bfd_getl32 (dmtp
.length
));
7948 dmt_size
-= sizeof (dmtp
);
7955 if (bfd_seek (abfd
, (file_ptr
) (dst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7957 fprintf (file
, _("cannot read DST\n"));
7961 evax_bfd_print_dst (abfd
, dst_size
, file
);
7965 if (bfd_seek (abfd
, (file_ptr
) (gst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7967 fprintf (file
, _("cannot read GST\n"));
7971 fprintf (file
, _("Global symbol table:\n"));
7972 evax_bfd_print_eobj (abfd
, file
);
7977 struct vms_eiaf
*eiaf
;
7978 unsigned int qrelfixoff
;
7979 unsigned int lrelfixoff
;
7980 unsigned int qdotadroff
;
7981 unsigned int ldotadroff
;
7982 unsigned int shrimgcnt
;
7983 unsigned int shlstoff
;
7984 unsigned int codeadroff
;
7985 unsigned int lpfixoff
;
7986 unsigned int chgprtoff
;
7988 buf
= bfd_malloc (eiaf_size
);
7990 if (bfd_seek (abfd
, (file_ptr
) (eiaf_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
)
7991 || bfd_bread (buf
, eiaf_size
, abfd
) != eiaf_size
)
7993 fprintf (file
, _("cannot read EIHA\n"));
7997 eiaf
= (struct vms_eiaf
*)buf
;
7999 /* xgettext:c-format */
8000 _("Image activator fixup: (major: %u, minor: %u)\n"),
8001 (unsigned)bfd_getl32 (eiaf
->majorid
),
8002 (unsigned)bfd_getl32 (eiaf
->minorid
));
8003 /* xgettext:c-format */
8004 fprintf (file
, _(" iaflink : 0x%08x %08x\n"),
8005 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 0),
8006 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 4));
8007 /* xgettext:c-format */
8008 fprintf (file
, _(" fixuplnk: 0x%08x %08x\n"),
8009 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 0),
8010 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 4));
8011 fprintf (file
, _(" size : %u\n"),
8012 (unsigned)bfd_getl32 (eiaf
->size
));
8013 fprintf (file
, _(" flags: 0x%08x\n"),
8014 (unsigned)bfd_getl32 (eiaf
->flags
));
8015 qrelfixoff
= bfd_getl32 (eiaf
->qrelfixoff
);
8016 lrelfixoff
= bfd_getl32 (eiaf
->lrelfixoff
);
8017 /* xgettext:c-format */
8018 fprintf (file
, _(" qrelfixoff: %5u, lrelfixoff: %5u\n"),
8019 qrelfixoff
, lrelfixoff
);
8020 qdotadroff
= bfd_getl32 (eiaf
->qdotadroff
);
8021 ldotadroff
= bfd_getl32 (eiaf
->ldotadroff
);
8022 /* xgettext:c-format */
8023 fprintf (file
, _(" qdotadroff: %5u, ldotadroff: %5u\n"),
8024 qdotadroff
, ldotadroff
);
8025 codeadroff
= bfd_getl32 (eiaf
->codeadroff
);
8026 lpfixoff
= bfd_getl32 (eiaf
->lpfixoff
);
8027 /* xgettext:c-format */
8028 fprintf (file
, _(" codeadroff: %5u, lpfixoff : %5u\n"),
8029 codeadroff
, lpfixoff
);
8030 chgprtoff
= bfd_getl32 (eiaf
->chgprtoff
);
8031 fprintf (file
, _(" chgprtoff : %5u\n"), chgprtoff
);
8032 shrimgcnt
= bfd_getl32 (eiaf
->shrimgcnt
);
8033 shlstoff
= bfd_getl32 (eiaf
->shlstoff
);
8034 /* xgettext:c-format */
8035 fprintf (file
, _(" shlstoff : %5u, shrimgcnt : %5u\n"),
8036 shlstoff
, shrimgcnt
);
8037 /* xgettext:c-format */
8038 fprintf (file
, _(" shlextra : %5u, permctx : %5u\n"),
8039 (unsigned)bfd_getl32 (eiaf
->shlextra
),
8040 (unsigned)bfd_getl32 (eiaf
->permctx
));
8041 fprintf (file
, _(" base_va : 0x%08x\n"),
8042 (unsigned)bfd_getl32 (eiaf
->base_va
));
8043 fprintf (file
, _(" lppsbfixoff: %5u\n"),
8044 (unsigned)bfd_getl32 (eiaf
->lppsbfixoff
));
8048 struct vms_shl
*shl
= (struct vms_shl
*)(buf
+ shlstoff
);
8051 fprintf (file
, _(" Shareable images:\n"));
8052 for (j
= 0; j
< shrimgcnt
; j
++, shl
++)
8055 /* xgettext:c-format */
8056 _(" %u: size: %u, flags: 0x%02x, name: %.*s\n"),
8057 j
, shl
->size
, shl
->flags
,
8058 shl
->imgnam
[0], shl
->imgnam
+ 1);
8061 if (qrelfixoff
!= 0)
8063 fprintf (file
, _(" quad-word relocation fixups:\n"));
8064 evax_bfd_print_relocation_records (file
, buf
+ qrelfixoff
, 8);
8066 if (lrelfixoff
!= 0)
8068 fprintf (file
, _(" long-word relocation fixups:\n"));
8069 evax_bfd_print_relocation_records (file
, buf
+ lrelfixoff
, 4);
8071 if (qdotadroff
!= 0)
8073 fprintf (file
, _(" quad-word .address reference fixups:\n"));
8074 evax_bfd_print_address_fixups (file
, buf
+ qdotadroff
);
8076 if (ldotadroff
!= 0)
8078 fprintf (file
, _(" long-word .address reference fixups:\n"));
8079 evax_bfd_print_address_fixups (file
, buf
+ ldotadroff
);
8081 if (codeadroff
!= 0)
8083 fprintf (file
, _(" Code Address Reference Fixups:\n"));
8084 evax_bfd_print_reference_fixups (file
, buf
+ codeadroff
);
8088 fprintf (file
, _(" Linkage Pairs Reference Fixups:\n"));
8089 evax_bfd_print_reference_fixups (file
, buf
+ lpfixoff
);
8093 unsigned int count
= (unsigned)bfd_getl32 (buf
+ chgprtoff
);
8094 struct vms_eicp
*eicp
= (struct vms_eicp
*)(buf
+ chgprtoff
+ 4);
8097 fprintf (file
, _(" Change Protection (%u entries):\n"), count
);
8098 for (j
= 0; j
< count
; j
++, eicp
++)
8100 unsigned int prot
= bfd_getl32 (eicp
->newprt
);
8102 /* xgettext:c-format */
8103 _(" base: 0x%08x %08x, size: 0x%08x, prot: 0x%08x "),
8104 (unsigned)bfd_getl32 (eicp
->baseva
+ 4),
8105 (unsigned)bfd_getl32 (eicp
->baseva
+ 0),
8106 (unsigned)bfd_getl32 (eicp
->size
),
8107 (unsigned)bfd_getl32 (eicp
->newprt
));
8111 fprintf (file
, "NA");
8113 case PRT__C_RESERVED
:
8114 fprintf (file
, "RES");
8117 fprintf (file
, "KW");
8120 fprintf (file
, "KR");
8123 fprintf (file
, "UW");
8126 fprintf (file
, "EW");
8129 fprintf (file
, "ERKW");
8132 fprintf (file
, "ER");
8135 fprintf (file
, "SW");
8138 fprintf (file
, "SREW");
8141 fprintf (file
, "SRKW");
8144 fprintf (file
, "SR");
8147 fprintf (file
, "URSW");
8150 fprintf (file
, "UREW");
8153 fprintf (file
, "URKW");
8156 fprintf (file
, "UR");
8170 vms_bfd_print_private_bfd_data (bfd
*abfd
, void *ptr
)
8172 FILE *file
= (FILE *)ptr
;
8174 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
8175 evax_bfd_print_image (abfd
, file
);
8178 if (bfd_seek (abfd
, 0, SEEK_SET
))
8180 evax_bfd_print_eobj (abfd
, file
);
8187 /* Slurp ETIR/EDBG/ETBT VMS object records. */
8190 alpha_vms_read_sections_content (bfd
*abfd
, struct bfd_link_info
*info
)
8192 asection
*cur_section
;
8193 file_ptr cur_offset
;
8194 asection
*dst_section
;
8195 file_ptr dst_offset
;
8197 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
8203 dst_section
= PRIV (dst_section
);
8207 if (info
->strip
== strip_all
|| info
->strip
== strip_debugger
)
8209 /* Discard the DST section. */
8213 else if (dst_section
)
8215 dst_offset
= dst_section
->output_offset
;
8216 dst_section
= dst_section
->output_section
;
8225 type
= _bfd_vms_get_object_record (abfd
);
8228 vms_debug2 ((2, "next_record failed\n"));
8234 PRIV (image_section
) = cur_section
;
8235 PRIV (image_offset
) = cur_offset
;
8236 res
= _bfd_vms_slurp_etir (abfd
, info
);
8237 cur_section
= PRIV (image_section
);
8238 cur_offset
= PRIV (image_offset
);
8242 if (dst_section
== NULL
)
8244 PRIV (image_section
) = dst_section
;
8245 PRIV (image_offset
) = dst_offset
;
8246 res
= _bfd_vms_slurp_etir (abfd
, info
);
8247 dst_offset
= PRIV (image_offset
);
8256 vms_debug2 ((2, "slurp eobj type %d failed\n", type
));
8263 alpha_vms_sizeof_headers (bfd
*abfd ATTRIBUTE_UNUSED
,
8264 struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8269 /* Add a linkage pair fixup at address SECT + OFFSET to SHLIB. */
8272 alpha_vms_add_fixup_lp (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
8274 struct alpha_vms_shlib_el
*sl
;
8275 asection
*sect
= PRIV2 (src
, image_section
);
8276 file_ptr offset
= PRIV2 (src
, image_offset
);
8278 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8279 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8280 sl
->has_fixups
= TRUE
;
8281 VEC_APPEND_EL (sl
->lp
, bfd_vma
,
8282 sect
->output_section
->vma
+ sect
->output_offset
+ offset
);
8283 sect
->output_section
->flags
|= SEC_RELOC
;
8286 /* Add a code address fixup at address SECT + OFFSET to SHLIB. */
8289 alpha_vms_add_fixup_ca (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
8291 struct alpha_vms_shlib_el
*sl
;
8292 asection
*sect
= PRIV2 (src
, image_section
);
8293 file_ptr offset
= PRIV2 (src
, image_offset
);
8295 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8296 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8297 sl
->has_fixups
= TRUE
;
8298 VEC_APPEND_EL (sl
->ca
, bfd_vma
,
8299 sect
->output_section
->vma
+ sect
->output_offset
+ offset
);
8300 sect
->output_section
->flags
|= SEC_RELOC
;
8303 /* Add a quad word relocation fixup at address SECT + OFFSET to SHLIB. */
8306 alpha_vms_add_fixup_qr (struct bfd_link_info
*info
, bfd
*src
,
8307 bfd
*shlib
, bfd_vma vec
)
8309 struct alpha_vms_shlib_el
*sl
;
8310 struct alpha_vms_vma_ref
*r
;
8311 asection
*sect
= PRIV2 (src
, image_section
);
8312 file_ptr offset
= PRIV2 (src
, image_offset
);
8314 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8315 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8316 sl
->has_fixups
= TRUE
;
8317 r
= VEC_APPEND (sl
->qr
, struct alpha_vms_vma_ref
);
8318 r
->vma
= sect
->output_section
->vma
+ sect
->output_offset
+ offset
;
8320 sect
->output_section
->flags
|= SEC_RELOC
;
8324 alpha_vms_add_fixup_lr (struct bfd_link_info
*info ATTRIBUTE_UNUSED
,
8325 unsigned int shr ATTRIBUTE_UNUSED
,
8326 bfd_vma vec ATTRIBUTE_UNUSED
)
8328 /* Not yet supported. */
8332 /* Add relocation. FIXME: Not yet emitted. */
8335 alpha_vms_add_lw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8340 alpha_vms_add_qw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8344 static struct bfd_hash_entry
*
8345 alpha_vms_link_hash_newfunc (struct bfd_hash_entry
*entry
,
8346 struct bfd_hash_table
*table
,
8349 struct alpha_vms_link_hash_entry
*ret
=
8350 (struct alpha_vms_link_hash_entry
*) entry
;
8352 /* Allocate the structure if it has not already been allocated by a
8355 ret
= ((struct alpha_vms_link_hash_entry
*)
8356 bfd_hash_allocate (table
,
8357 sizeof (struct alpha_vms_link_hash_entry
)));
8361 /* Call the allocation method of the superclass. */
8362 ret
= ((struct alpha_vms_link_hash_entry
*)
8363 _bfd_link_hash_newfunc ((struct bfd_hash_entry
*) ret
,
8368 return (struct bfd_hash_entry
*) ret
;
8372 alpha_vms_bfd_link_hash_table_free (bfd
*abfd
)
8374 struct alpha_vms_link_hash_table
*t
;
8377 t
= (struct alpha_vms_link_hash_table
*) abfd
->link
.hash
;
8378 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8380 struct alpha_vms_shlib_el
*shlib
;
8382 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8383 free (&VEC_EL (shlib
->ca
, bfd_vma
, 0));
8384 free (&VEC_EL (shlib
->lp
, bfd_vma
, 0));
8385 free (&VEC_EL (shlib
->qr
, struct alpha_vms_vma_ref
, 0));
8387 free (&VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, 0));
8389 _bfd_generic_link_hash_table_free (abfd
);
8392 /* Create an Alpha/VMS link hash table. */
8394 static struct bfd_link_hash_table
*
8395 alpha_vms_bfd_link_hash_table_create (bfd
*abfd
)
8397 struct alpha_vms_link_hash_table
*ret
;
8398 bfd_size_type amt
= sizeof (struct alpha_vms_link_hash_table
);
8400 ret
= (struct alpha_vms_link_hash_table
*) bfd_malloc (amt
);
8403 if (!_bfd_link_hash_table_init (&ret
->root
, abfd
,
8404 alpha_vms_link_hash_newfunc
,
8405 sizeof (struct alpha_vms_link_hash_entry
)))
8411 VEC_INIT (ret
->shrlibs
);
8413 ret
->root
.hash_table_free
= alpha_vms_bfd_link_hash_table_free
;
8419 alpha_vms_link_add_object_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8423 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
8425 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
8426 struct alpha_vms_link_hash_entry
*h
;
8427 struct bfd_link_hash_entry
*h_root
;
8430 if (!alpha_vms_convert_symbol (abfd
, e
, &sym
))
8433 if ((e
->flags
& EGSY__V_DEF
) && abfd
->selective_search
)
8435 /* In selective_search mode, only add definition that are
8437 h
= (struct alpha_vms_link_hash_entry
*)bfd_link_hash_lookup
8438 (info
->hash
, sym
.name
, FALSE
, FALSE
, FALSE
);
8439 if (h
== NULL
|| h
->root
.type
!= bfd_link_hash_undefined
)
8445 h_root
= (struct bfd_link_hash_entry
*) h
;
8446 if (!_bfd_generic_link_add_one_symbol (info
, abfd
, sym
.name
, sym
.flags
,
8447 sym
.section
, sym
.value
, NULL
,
8448 FALSE
, FALSE
, &h_root
))
8450 h
= (struct alpha_vms_link_hash_entry
*) h_root
;
8452 if ((e
->flags
& EGSY__V_DEF
)
8454 && abfd
->xvec
== info
->output_bfd
->xvec
)
8458 if (abfd
->flags
& DYNAMIC
)
8460 struct alpha_vms_shlib_el
*shlib
;
8462 /* We do not want to include any of the sections in a dynamic
8463 object in the output file. See comment in elflink.c. */
8464 bfd_section_list_clear (abfd
);
8466 shlib
= VEC_APPEND (alpha_vms_link_hash (info
)->shrlibs
,
8467 struct alpha_vms_shlib_el
);
8469 VEC_INIT (shlib
->ca
);
8470 VEC_INIT (shlib
->lp
);
8471 VEC_INIT (shlib
->qr
);
8472 PRIV (shr_index
) = VEC_COUNT (alpha_vms_link_hash (info
)->shrlibs
) - 1;
8479 alpha_vms_link_add_archive_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8482 struct bfd_link_hash_entry
**pundef
;
8483 struct bfd_link_hash_entry
**next_pundef
;
8485 /* We only accept VMS libraries. */
8486 if (info
->output_bfd
->xvec
!= abfd
->xvec
)
8488 bfd_set_error (bfd_error_wrong_format
);
8492 /* The archive_pass field in the archive itself is used to
8493 initialize PASS, since we may search the same archive multiple
8495 pass
= ++abfd
->archive_pass
;
8497 /* Look through the list of undefined symbols. */
8498 for (pundef
= &info
->hash
->undefs
; *pundef
!= NULL
; pundef
= next_pundef
)
8500 struct bfd_link_hash_entry
*h
;
8506 next_pundef
= &(*pundef
)->u
.undef
.next
;
8508 /* When a symbol is defined, it is not necessarily removed from
8510 if (h
->type
!= bfd_link_hash_undefined
8511 && h
->type
!= bfd_link_hash_common
)
8513 /* Remove this entry from the list, for general cleanliness
8514 and because we are going to look through the list again
8515 if we search any more libraries. We can't remove the
8516 entry if it is the tail, because that would lose any
8517 entries we add to the list later on. */
8518 if (*pundef
!= info
->hash
->undefs_tail
)
8520 *pundef
= *next_pundef
;
8521 next_pundef
= pundef
;
8526 /* Look for this symbol in the archive hash table. */
8527 symidx
= _bfd_vms_lib_find_symbol (abfd
, h
->root
.string
);
8528 if (symidx
== BFD_NO_MORE_SYMBOLS
)
8530 /* Nothing in this slot. */
8534 element
= bfd_get_elt_at_index (abfd
, symidx
);
8535 if (element
== NULL
)
8538 if (element
->archive_pass
== -1 || element
->archive_pass
== pass
)
8540 /* Next symbol if this archive is wrong or already handled. */
8544 if (! bfd_check_format (element
, bfd_object
))
8546 element
->archive_pass
= -1;
8550 orig_element
= element
;
8551 if (bfd_is_thin_archive (abfd
))
8553 element
= _bfd_vms_lib_get_imagelib_file (element
);
8554 if (element
== NULL
|| !bfd_check_format (element
, bfd_object
))
8556 orig_element
->archive_pass
= -1;
8561 /* Unlike the generic linker, we know that this element provides
8562 a definition for an undefined symbol and we know that we want
8563 to include it. We don't need to check anything. */
8564 if (!(*info
->callbacks
8565 ->add_archive_element
) (info
, element
, h
->root
.string
, &element
))
8567 if (!alpha_vms_link_add_object_symbols (element
, info
))
8570 orig_element
->archive_pass
= pass
;
8577 alpha_vms_bfd_link_add_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8579 switch (bfd_get_format (abfd
))
8582 vms_debug2 ((2, "vms_link_add_symbols for object %s\n",
8584 return alpha_vms_link_add_object_symbols (abfd
, info
);
8587 vms_debug2 ((2, "vms_link_add_symbols for archive %s\n",
8589 return alpha_vms_link_add_archive_symbols (abfd
, info
);
8592 bfd_set_error (bfd_error_wrong_format
);
8598 alpha_vms_build_fixups (struct bfd_link_info
*info
)
8600 struct alpha_vms_link_hash_table
*t
= alpha_vms_link_hash (info
);
8601 unsigned char *content
;
8603 unsigned int sz
= 0;
8604 unsigned int lp_sz
= 0;
8605 unsigned int ca_sz
= 0;
8606 unsigned int qr_sz
= 0;
8607 unsigned int shrimg_cnt
= 0;
8608 unsigned int chgprt_num
= 0;
8609 unsigned int chgprt_sz
= 0;
8610 struct vms_eiaf
*eiaf
;
8614 /* Shared libraries. */
8615 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8617 struct alpha_vms_shlib_el
*shlib
;
8619 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8621 if (!shlib
->has_fixups
)
8626 if (VEC_COUNT (shlib
->ca
) > 0)
8628 /* Header + entries. */
8630 ca_sz
+= VEC_COUNT (shlib
->ca
) * 4;
8632 if (VEC_COUNT (shlib
->lp
) > 0)
8634 /* Header + entries. */
8636 lp_sz
+= VEC_COUNT (shlib
->lp
) * 4;
8638 if (VEC_COUNT (shlib
->qr
) > 0)
8640 /* Header + entries. */
8642 qr_sz
+= VEC_COUNT (shlib
->qr
) * 8;
8653 /* Finish now if there is no content. */
8654 if (ca_sz
+ lp_sz
+ qr_sz
== 0)
8657 /* Add an eicp entry for the fixup itself. */
8659 for (sec
= info
->output_bfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
8661 /* This isect could be made RO or EXE after relocations are applied. */
8662 if ((sec
->flags
& SEC_RELOC
) != 0
8663 && (sec
->flags
& (SEC_CODE
| SEC_READONLY
)) != 0)
8666 chgprt_sz
= 4 + chgprt_num
* sizeof (struct vms_eicp
);
8668 /* Allocate section content (round-up size) */
8669 sz
= sizeof (struct vms_eiaf
) + shrimg_cnt
* sizeof (struct vms_shl
)
8670 + ca_sz
+ lp_sz
+ qr_sz
+ chgprt_sz
;
8671 sz
= (sz
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
8672 content
= bfd_zalloc (info
->output_bfd
, sz
);
8673 if (content
== NULL
)
8676 sec
= alpha_vms_link_hash (info
)->fixup
;
8677 sec
->contents
= content
;
8680 eiaf
= (struct vms_eiaf
*)content
;
8681 off
= sizeof (struct vms_eiaf
);
8682 bfd_putl32 (0, eiaf
->majorid
);
8683 bfd_putl32 (0, eiaf
->minorid
);
8684 bfd_putl32 (0, eiaf
->iaflink
);
8685 bfd_putl32 (0, eiaf
->fixuplnk
);
8686 bfd_putl32 (sizeof (struct vms_eiaf
), eiaf
->size
);
8687 bfd_putl32 (0, eiaf
->flags
);
8688 bfd_putl32 (0, eiaf
->qrelfixoff
);
8689 bfd_putl32 (0, eiaf
->lrelfixoff
);
8690 bfd_putl32 (0, eiaf
->qdotadroff
);
8691 bfd_putl32 (0, eiaf
->ldotadroff
);
8692 bfd_putl32 (0, eiaf
->codeadroff
);
8693 bfd_putl32 (0, eiaf
->lpfixoff
);
8694 bfd_putl32 (0, eiaf
->chgprtoff
);
8695 bfd_putl32 (shrimg_cnt
? off
: 0, eiaf
->shlstoff
);
8696 bfd_putl32 (shrimg_cnt
, eiaf
->shrimgcnt
);
8697 bfd_putl32 (0, eiaf
->shlextra
);
8698 bfd_putl32 (0, eiaf
->permctx
);
8699 bfd_putl32 (0, eiaf
->base_va
);
8700 bfd_putl32 (0, eiaf
->lppsbfixoff
);
8707 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8709 struct alpha_vms_shlib_el
*shlib
;
8710 struct vms_shl
*shl
;
8712 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8714 if (!shlib
->has_fixups
)
8717 /* Renumber shared images. */
8718 PRIV2 (shlib
->abfd
, shr_index
) = shrimg_cnt
++;
8720 shl
= (struct vms_shl
*)(content
+ off
);
8721 bfd_putl32 (0, shl
->baseva
);
8722 bfd_putl32 (0, shl
->shlptr
);
8723 bfd_putl32 (0, shl
->ident
);
8724 bfd_putl32 (0, shl
->permctx
);
8725 shl
->size
= sizeof (struct vms_shl
);
8726 bfd_putl16 (0, shl
->fill_1
);
8728 bfd_putl32 (0, shl
->icb
);
8729 shl
->imgnam
[0] = strlen (PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
));
8730 memcpy (shl
->imgnam
+ 1, PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
),
8733 off
+= sizeof (struct vms_shl
);
8739 bfd_putl32 (off
, eiaf
->codeadroff
);
8741 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8743 struct alpha_vms_shlib_el
*shlib
;
8746 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8748 if (VEC_COUNT (shlib
->ca
) == 0)
8751 bfd_putl32 (VEC_COUNT (shlib
->ca
), content
+ off
);
8752 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8755 for (j
= 0; j
< VEC_COUNT (shlib
->ca
); j
++)
8757 bfd_putl32 (VEC_EL (shlib
->ca
, bfd_vma
, j
) - t
->base_addr
,
8763 bfd_putl32 (0, content
+ off
);
8764 bfd_putl32 (0, content
+ off
+ 4);
8771 bfd_putl32 (off
, eiaf
->lpfixoff
);
8773 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8775 struct alpha_vms_shlib_el
*shlib
;
8778 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8780 if (VEC_COUNT (shlib
->lp
) == 0)
8783 bfd_putl32 (VEC_COUNT (shlib
->lp
), content
+ off
);
8784 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8787 for (j
= 0; j
< VEC_COUNT (shlib
->lp
); j
++)
8789 bfd_putl32 (VEC_EL (shlib
->lp
, bfd_vma
, j
) - t
->base_addr
,
8795 bfd_putl32 (0, content
+ off
);
8796 bfd_putl32 (0, content
+ off
+ 4);
8803 bfd_putl32 (off
, eiaf
->qdotadroff
);
8805 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8807 struct alpha_vms_shlib_el
*shlib
;
8810 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8812 if (VEC_COUNT (shlib
->qr
) == 0)
8815 bfd_putl32 (VEC_COUNT (shlib
->qr
), content
+ off
);
8816 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8819 for (j
= 0; j
< VEC_COUNT (shlib
->qr
); j
++)
8821 struct alpha_vms_vma_ref
*r
;
8822 r
= &VEC_EL (shlib
->qr
, struct alpha_vms_vma_ref
, j
);
8823 bfd_putl32 (r
->vma
- t
->base_addr
, content
+ off
);
8824 bfd_putl32 (r
->ref
, content
+ off
+ 4);
8829 bfd_putl32 (0, content
+ off
);
8830 bfd_putl32 (0, content
+ off
+ 4);
8835 /* Write the change protection table. */
8836 bfd_putl32 (off
, eiaf
->chgprtoff
);
8837 bfd_putl32 (chgprt_num
, content
+ off
);
8840 for (sec
= info
->output_bfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
8842 struct vms_eicp
*eicp
;
8845 if ((sec
->flags
& SEC_LINKER_CREATED
) != 0 &&
8846 strcmp (sec
->name
, "$FIXUP$") == 0)
8848 else if ((sec
->flags
& SEC_RELOC
) != 0
8849 && (sec
->flags
& (SEC_CODE
| SEC_READONLY
)) != 0)
8854 eicp
= (struct vms_eicp
*)(content
+ off
);
8855 bfd_putl64 (sec
->vma
- t
->base_addr
, eicp
->baseva
);
8856 bfd_putl32 ((sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1),
8858 bfd_putl32 (prot
, eicp
->newprt
);
8859 off
+= sizeof (struct vms_eicp
);
8865 /* Called by bfd_hash_traverse to fill the symbol table.
8866 Return FALSE in case of failure. */
8869 alpha_vms_link_output_symbol (struct bfd_hash_entry
*bh
, void *infov
)
8871 struct bfd_link_hash_entry
*hc
= (struct bfd_link_hash_entry
*) bh
;
8872 struct bfd_link_info
*info
= (struct bfd_link_info
*)infov
;
8873 struct alpha_vms_link_hash_entry
*h
;
8874 struct vms_symbol_entry
*sym
;
8876 if (hc
->type
== bfd_link_hash_warning
)
8879 if (hc
->type
== bfd_link_hash_new
)
8882 h
= (struct alpha_vms_link_hash_entry
*) hc
;
8884 switch (h
->root
.type
)
8886 case bfd_link_hash_undefined
:
8888 case bfd_link_hash_new
:
8889 case bfd_link_hash_warning
:
8891 case bfd_link_hash_undefweak
:
8893 case bfd_link_hash_defined
:
8894 case bfd_link_hash_defweak
:
8896 asection
*sec
= h
->root
.u
.def
.section
;
8898 /* FIXME: this is certainly a symbol from a dynamic library. */
8899 if (bfd_is_abs_section (sec
))
8902 if (sec
->owner
->flags
& DYNAMIC
)
8906 case bfd_link_hash_common
:
8908 case bfd_link_hash_indirect
:
8912 /* Do not write not kept symbols. */
8913 if (info
->strip
== strip_some
8914 && bfd_hash_lookup (info
->keep_hash
, h
->root
.root
.string
,
8915 FALSE
, FALSE
) != NULL
)
8920 /* This symbol doesn't come from a VMS object. So we suppose it is
8922 int len
= strlen (h
->root
.root
.string
);
8924 sym
= (struct vms_symbol_entry
*)bfd_zalloc (info
->output_bfd
,
8925 sizeof (*sym
) + len
);
8929 memcpy (sym
->name
, h
->root
.root
.string
, len
);
8931 sym
->owner
= info
->output_bfd
;
8933 sym
->typ
= EGSD__C_SYMG
;
8935 sym
->flags
= EGSY__V_DEF
| EGSY__V_REL
;
8936 sym
->symbol_vector
= h
->root
.u
.def
.value
;
8937 sym
->section
= h
->root
.u
.def
.section
;
8938 sym
->value
= h
->root
.u
.def
.value
;
8943 if (!add_symbol_entry (info
->output_bfd
, sym
))
8950 alpha_vms_bfd_final_link (bfd
*abfd
, struct bfd_link_info
*info
)
8953 struct bfd_link_order
*p
;
8961 if (bfd_link_relocatable (info
))
8963 /* FIXME: we do not yet support relocatable link. It is not obvious
8964 how to do it for debug infos. */
8965 (*info
->callbacks
->einfo
)(_("%P: relocatable link is not supported\n"));
8969 abfd
->outsymbols
= NULL
;
8972 /* Mark all sections which will be included in the output file. */
8973 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8974 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
8975 if (p
->type
== bfd_indirect_link_order
)
8976 p
->u
.indirect
.section
->linker_mark
= TRUE
;
8979 /* Handle all the link order information for the sections. */
8980 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8982 printf ("For section %s (at 0x%08x, flags=0x%08x):\n",
8983 o
->name
, (unsigned)o
->vma
, (unsigned)o
->flags
);
8985 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
8987 printf (" at 0x%08x - 0x%08x: ",
8988 (unsigned)p
->offset
, (unsigned)(p
->offset
+ p
->size
- 1));
8991 case bfd_section_reloc_link_order
:
8992 case bfd_symbol_reloc_link_order
:
8993 printf (" section/symbol reloc\n");
8995 case bfd_indirect_link_order
:
8996 printf (" section %s of %s\n",
8997 p
->u
.indirect
.section
->name
,
8998 p
->u
.indirect
.section
->owner
->filename
);
9000 case bfd_data_link_order
:
9001 printf (" explicit data\n");
9004 printf (" *unknown* type %u\n", p
->type
);
9011 /* Generate the symbol table. */
9012 BFD_ASSERT (PRIV (syms
) == NULL
);
9013 if (info
->strip
!= strip_all
)
9014 bfd_hash_traverse (&info
->hash
->table
, alpha_vms_link_output_symbol
, info
);
9016 /* Find the entry point. */
9017 if (bfd_get_start_address (abfd
) == 0)
9019 bfd
*startbfd
= NULL
;
9021 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9023 /* Consider only VMS object files. */
9024 if (sub
->xvec
!= abfd
->xvec
)
9027 if (!PRIV2 (sub
, eom_data
).eom_has_transfer
)
9029 if ((PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
) && startbfd
)
9031 if (startbfd
!= NULL
9032 && !(PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
))
9034 (*info
->callbacks
->einfo
)
9035 /* xgettext:c-format */
9036 (_("%P: multiple entry points: in modules %pB and %pB\n"),
9045 unsigned int ps_idx
= PRIV2 (startbfd
, eom_data
).eom_l_psindx
;
9046 bfd_vma tfradr
= PRIV2 (startbfd
, eom_data
).eom_l_tfradr
;
9049 sec
= PRIV2 (startbfd
, sections
)[ps_idx
];
9051 bfd_set_start_address
9052 (abfd
, sec
->output_section
->vma
+ sec
->output_offset
+ tfradr
);
9056 /* Set transfer addresses. */
9059 struct bfd_link_hash_entry
*h
;
9062 PRIV (transfer_address
[i
++]) = 0xffffffff00000340ULL
; /* SYS$IMGACT */
9063 h
= bfd_link_hash_lookup (info
->hash
, "LIB$INITIALIZE", FALSE
, FALSE
, TRUE
);
9064 if (h
!= NULL
&& h
->type
== bfd_link_hash_defined
)
9065 PRIV (transfer_address
[i
++]) =
9066 alpha_vms_get_sym_value (h
->u
.def
.section
, h
->u
.def
.value
);
9067 PRIV (transfer_address
[i
++]) = bfd_get_start_address (abfd
);
9069 PRIV (transfer_address
[i
++]) = 0;
9072 /* Allocate contents.
9073 Also compute the virtual base address. */
9074 base_addr
= (bfd_vma
)-1;
9076 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9078 if (o
->flags
& SEC_HAS_CONTENTS
)
9080 o
->contents
= bfd_alloc (abfd
, o
->size
);
9081 if (o
->contents
== NULL
)
9084 if (o
->flags
& SEC_LOAD
)
9086 if (o
->vma
< base_addr
)
9088 if (o
->vma
+ o
->size
> last_addr
)
9089 last_addr
= o
->vma
+ o
->size
;
9091 /* Clear the RELOC flags. Currently we don't support incremental
9092 linking. We use the RELOC flag for computing the eicp entries. */
9093 o
->flags
&= ~SEC_RELOC
;
9096 /* Create the fixup section. */
9097 fixupsec
= bfd_make_section_anyway_with_flags
9098 (info
->output_bfd
, "$FIXUP$",
9099 SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
9100 if (fixupsec
== NULL
)
9102 last_addr
= (last_addr
+ 0xffff) & ~0xffff;
9103 fixupsec
->vma
= last_addr
;
9105 alpha_vms_link_hash (info
)->fixup
= fixupsec
;
9106 alpha_vms_link_hash (info
)->base_addr
= base_addr
;
9108 /* Create the DMT section, if necessary. */
9109 BFD_ASSERT (PRIV (dst_section
) == NULL
);
9110 dst
= bfd_get_section_by_name (abfd
, "$DST$");
9111 if (dst
!= NULL
&& dst
->size
== 0)
9115 PRIV (dst_section
) = dst
;
9116 dmt
= bfd_make_section_anyway_with_flags
9117 (info
->output_bfd
, "$DMT$",
9118 SEC_DEBUGGING
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
9125 /* Read all sections from the inputs. */
9126 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9128 if (sub
->flags
& DYNAMIC
)
9130 alpha_vms_create_eisd_for_shared (abfd
, sub
);
9134 if (!alpha_vms_read_sections_content (sub
, info
))
9138 /* Handle all the link order information for the sections.
9139 Note: past this point, it is not possible to create new sections. */
9140 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9142 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
9146 case bfd_section_reloc_link_order
:
9147 case bfd_symbol_reloc_link_order
:
9150 case bfd_indirect_link_order
:
9154 if (! _bfd_default_link_order (abfd
, info
, o
, p
))
9161 /* Compute fixups. */
9162 if (!alpha_vms_build_fixups (info
))
9165 /* Compute the DMT. */
9169 unsigned char *contents
= NULL
;
9171 /* In pass 1, compute the size. In pass 2, write the DMT contents. */
9172 for (pass
= 0; pass
< 2; pass
++)
9174 unsigned int off
= 0;
9176 /* For each object file (ie for each module). */
9177 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9180 struct vms_dmt_header
*dmth
= NULL
;
9181 unsigned int psect_count
;
9183 /* Skip this module if it has no DST. */
9184 sub_dst
= PRIV2 (sub
, dst_section
);
9185 if (sub_dst
== NULL
|| sub_dst
->size
== 0)
9190 /* Write the header. */
9191 dmth
= (struct vms_dmt_header
*)(contents
+ off
);
9192 bfd_putl32 (sub_dst
->output_offset
, dmth
->modbeg
);
9193 bfd_putl32 (sub_dst
->size
, dmth
->size
);
9196 off
+= sizeof (struct vms_dmt_header
);
9199 /* For each section (ie for each psect). */
9200 for (o
= sub
->sections
; o
!= NULL
; o
= o
->next
)
9202 /* Only consider interesting sections. */
9203 if (!(o
->flags
& SEC_ALLOC
))
9205 if (o
->flags
& SEC_LINKER_CREATED
)
9210 /* Write an entry. */
9211 struct vms_dmt_psect
*dmtp
;
9213 dmtp
= (struct vms_dmt_psect
*)(contents
+ off
);
9214 bfd_putl32 (o
->output_offset
+ o
->output_section
->vma
,
9216 bfd_putl32 (o
->size
, dmtp
->length
);
9219 off
+= sizeof (struct vms_dmt_psect
);
9222 bfd_putl32 (psect_count
, dmth
->psect_count
);
9227 contents
= bfd_zalloc (info
->output_bfd
, off
);
9228 if (contents
== NULL
)
9230 dmt
->contents
= contents
;
9235 BFD_ASSERT (off
== dmt
->size
);
9243 /* Read the contents of a section.
9244 buf points to a buffer of buf_size bytes to be filled with
9245 section data (starting at offset into section) */
9248 alpha_vms_get_section_contents (bfd
*abfd
, asection
*section
,
9249 void *buf
, file_ptr offset
,
9250 bfd_size_type count
)
9254 /* Image are easy. */
9255 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
9256 return _bfd_generic_get_section_contents (abfd
, section
,
9257 buf
, offset
, count
);
9260 if (offset
+ count
< count
9261 || offset
+ count
> section
->size
)
9263 bfd_set_error (bfd_error_invalid_operation
);
9267 /* If the section is already in memory, just copy it. */
9268 if (section
->flags
& SEC_IN_MEMORY
)
9270 BFD_ASSERT (section
->contents
!= NULL
);
9271 memcpy (buf
, section
->contents
+ offset
, count
);
9274 if (section
->size
== 0)
9277 /* Alloc in memory and read ETIRs. */
9278 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
9280 BFD_ASSERT (sec
->contents
== NULL
);
9282 if (sec
->size
!= 0 && (sec
->flags
& SEC_HAS_CONTENTS
))
9284 sec
->contents
= bfd_alloc (abfd
, sec
->size
);
9285 if (sec
->contents
== NULL
)
9289 if (!alpha_vms_read_sections_content (abfd
, NULL
))
9291 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
9293 sec
->flags
|= SEC_IN_MEMORY
;
9294 memcpy (buf
, section
->contents
+ offset
, count
);
9299 /* Set the format of a file being written. */
9302 alpha_vms_mkobject (bfd
* abfd
)
9304 const bfd_arch_info_type
*arch
;
9306 vms_debug2 ((1, "alpha_vms_mkobject (%p)\n", abfd
));
9308 if (!vms_initialize (abfd
))
9311 PRIV (recwr
.buf
) = bfd_alloc (abfd
, MAX_OUTREC_SIZE
);
9312 if (PRIV (recwr
.buf
) == NULL
)
9315 arch
= bfd_scan_arch ("alpha");
9319 bfd_set_error (bfd_error_wrong_format
);
9323 abfd
->arch_info
= arch
;
9330 /* Called when the BFD is being closed to do any necessary cleanup. */
9333 vms_close_and_cleanup (bfd
* abfd
)
9335 vms_debug2 ((1, "vms_close_and_cleanup (%p)\n", abfd
));
9337 if (abfd
== NULL
|| abfd
->tdata
.any
== NULL
)
9340 if (abfd
->format
== bfd_object
)
9342 struct module
*module
;
9344 free (PRIV (recrd
.buf
));
9345 free (PRIV (sections
));
9347 free (PRIV (dst_ptr_offsets
));
9349 for (module
= PRIV (modules
); module
; module
= module
->next
)
9350 free (module
->file_table
);
9353 if (abfd
->direction
== write_direction
)
9355 /* Last step on VMS is to convert the file to variable record length
9357 if (!bfd_cache_close (abfd
))
9359 if (!_bfd_vms_convert_to_var_unix_filename (abfd
->filename
))
9365 return _bfd_generic_close_and_cleanup (abfd
);
9368 /* Called when a new section is created. */
9371 vms_new_section_hook (bfd
* abfd
, asection
*section
)
9375 vms_debug2 ((1, "vms_new_section_hook (%p, [%u]%s)\n",
9376 abfd
, section
->index
, section
->name
));
9378 if (!bfd_set_section_alignment (section
, 0))
9381 vms_debug2 ((7, "%u: %s\n", section
->index
, section
->name
));
9383 amt
= sizeof (struct vms_section_data_struct
);
9384 section
->used_by_bfd
= bfd_zalloc (abfd
, amt
);
9385 if (section
->used_by_bfd
== NULL
)
9388 /* Create the section symbol. */
9389 return _bfd_generic_new_section_hook (abfd
, section
);
9392 /* Part 4.5, symbols. */
9394 /* Print symbol to file according to how. how is one of
9395 bfd_print_symbol_name just print the name
9396 bfd_print_symbol_more print more (???)
9397 bfd_print_symbol_all print all we know, which is not much right now :-). */
9400 vms_print_symbol (bfd
* abfd
,
9403 bfd_print_symbol_type how
)
9405 vms_debug2 ((1, "vms_print_symbol (%p, %p, %p, %d)\n",
9406 abfd
, file
, symbol
, how
));
9410 case bfd_print_symbol_name
:
9411 case bfd_print_symbol_more
:
9412 fprintf ((FILE *)file
," %s", symbol
->name
);
9415 case bfd_print_symbol_all
:
9417 const char *section_name
= symbol
->section
->name
;
9419 bfd_print_symbol_vandf (abfd
, file
, symbol
);
9421 fprintf ((FILE *) file
," %-8s %s", section_name
, symbol
->name
);
9427 /* Return information about symbol in ret.
9429 fill type, value and name
9432 B bss segment symbol
9434 D data segment symbol
9436 t a static function symbol
9437 T text segment symbol
9442 vms_get_symbol_info (bfd
* abfd ATTRIBUTE_UNUSED
,
9448 vms_debug2 ((1, "vms_get_symbol_info (%p, %p, %p)\n", abfd
, symbol
, ret
));
9450 sec
= symbol
->section
;
9457 else if (bfd_is_com_section (sec
))
9459 else if (bfd_is_abs_section (sec
))
9461 else if (bfd_is_und_section (sec
))
9463 else if (bfd_is_ind_section (sec
))
9465 else if ((symbol
->flags
& BSF_FUNCTION
)
9466 || (bfd_section_flags (sec
) & SEC_CODE
))
9468 else if (bfd_section_flags (sec
) & SEC_DATA
)
9470 else if (bfd_section_flags (sec
) & SEC_ALLOC
)
9475 if (ret
->type
!= 'U')
9476 ret
->value
= symbol
->value
+ symbol
->section
->vma
;
9479 ret
->name
= symbol
->name
;
9482 /* Return TRUE if the given symbol sym in the BFD abfd is
9483 a compiler generated local label, else return FALSE. */
9486 vms_bfd_is_local_label_name (bfd
* abfd ATTRIBUTE_UNUSED
,
9489 return name
[0] == '$';
9492 /* Part 4.7, writing an object file. */
9494 /* Sets the contents of the section section in BFD abfd to the data starting
9495 in memory at LOCATION. The data is written to the output section starting
9496 at offset offset for count bytes.
9498 Normally TRUE is returned, else FALSE. Possible error returns are:
9499 o bfd_error_no_contents - The output section does not have the
9500 SEC_HAS_CONTENTS attribute, so nothing can be written to it.
9501 o and some more too */
9504 _bfd_vms_set_section_contents (bfd
* abfd
,
9506 const void * location
,
9508 bfd_size_type count
)
9510 if (section
->contents
== NULL
)
9512 section
->contents
= bfd_alloc (abfd
, section
->size
);
9513 if (section
->contents
== NULL
)
9516 memcpy (section
->contents
+ offset
, location
, (size_t) count
);
9522 /* Set the architecture and machine type in BFD abfd to arch and mach.
9523 Find the correct pointer to a structure and insert it into the arch_info
9527 alpha_vms_set_arch_mach (bfd
*abfd
,
9528 enum bfd_architecture arch
, unsigned long mach
)
9530 if (arch
!= bfd_arch_alpha
9531 && arch
!= bfd_arch_unknown
)
9534 return bfd_default_set_arch_mach (abfd
, arch
, mach
);
9537 /* Set section VMS flags. Clear NO_FLAGS and set FLAGS. */
9540 bfd_vms_set_section_flags (bfd
*abfd ATTRIBUTE_UNUSED
,
9541 asection
*sec
, flagword no_flags
, flagword flags
)
9543 vms_section_data (sec
)->no_flags
= no_flags
;
9544 vms_section_data (sec
)->flags
= flags
;
9547 struct vms_private_data_struct
*
9548 bfd_vms_get_data (bfd
*abfd
)
9550 return (struct vms_private_data_struct
*)abfd
->tdata
.any
;
9553 #define vms_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false
9554 #define vms_bfd_link_just_syms _bfd_generic_link_just_syms
9555 #define vms_bfd_copy_link_hash_symbol_type \
9556 _bfd_generic_copy_link_hash_symbol_type
9557 #define vms_bfd_is_group_section bfd_generic_is_group_section
9558 #define vms_bfd_group_name bfd_generic_group_name
9559 #define vms_bfd_discard_group bfd_generic_discard_group
9560 #define vms_section_already_linked _bfd_generic_section_already_linked
9561 #define vms_bfd_define_common_symbol bfd_generic_define_common_symbol
9562 #define vms_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
9563 #define vms_bfd_define_start_stop bfd_generic_define_start_stop
9564 #define vms_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
9566 #define vms_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
9567 #define vms_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
9568 #define vms_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data
9569 #define vms_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
9570 #define vms_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
9571 #define vms_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
9573 /* Symbols table. */
9574 #define alpha_vms_make_empty_symbol _bfd_generic_make_empty_symbol
9575 #define alpha_vms_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false
9576 #define alpha_vms_print_symbol vms_print_symbol
9577 #define alpha_vms_get_symbol_info vms_get_symbol_info
9578 #define alpha_vms_get_symbol_version_string \
9579 _bfd_nosymbols_get_symbol_version_string
9581 #define alpha_vms_read_minisymbols _bfd_generic_read_minisymbols
9582 #define alpha_vms_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
9583 #define alpha_vms_get_lineno _bfd_nosymbols_get_lineno
9584 #define alpha_vms_find_inliner_info _bfd_nosymbols_find_inliner_info
9585 #define alpha_vms_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
9586 #define alpha_vms_find_nearest_line _bfd_vms_find_nearest_line
9587 #define alpha_vms_find_line _bfd_nosymbols_find_line
9588 #define alpha_vms_bfd_is_local_label_name vms_bfd_is_local_label_name
9590 /* Generic table. */
9591 #define alpha_vms_close_and_cleanup vms_close_and_cleanup
9592 #define alpha_vms_bfd_free_cached_info vms_bfd_free_cached_info
9593 #define alpha_vms_new_section_hook vms_new_section_hook
9594 #define alpha_vms_set_section_contents _bfd_vms_set_section_contents
9595 #define alpha_vms_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
9597 #define alpha_vms_bfd_get_relocated_section_contents \
9598 bfd_generic_get_relocated_section_contents
9600 #define alpha_vms_bfd_relax_section bfd_generic_relax_section
9601 #define alpha_vms_bfd_gc_sections bfd_generic_gc_sections
9602 #define alpha_vms_bfd_lookup_section_flags bfd_generic_lookup_section_flags
9603 #define alpha_vms_bfd_merge_sections bfd_generic_merge_sections
9604 #define alpha_vms_bfd_is_group_section bfd_generic_is_group_section
9605 #define alpha_vms_bfd_group_name bfd_generic_group_name
9606 #define alpha_vms_bfd_discard_group bfd_generic_discard_group
9607 #define alpha_vms_section_already_linked \
9608 _bfd_generic_section_already_linked
9610 #define alpha_vms_bfd_define_common_symbol bfd_generic_define_common_symbol
9611 #define alpha_vms_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
9612 #define alpha_vms_bfd_define_start_stop bfd_generic_define_start_stop
9613 #define alpha_vms_bfd_link_just_syms _bfd_generic_link_just_syms
9614 #define alpha_vms_bfd_copy_link_hash_symbol_type \
9615 _bfd_generic_copy_link_hash_symbol_type
9617 #define alpha_vms_bfd_link_split_section _bfd_generic_link_split_section
9619 #define alpha_vms_get_dynamic_symtab_upper_bound \
9620 _bfd_nodynamic_get_dynamic_symtab_upper_bound
9621 #define alpha_vms_canonicalize_dynamic_symtab \
9622 _bfd_nodynamic_canonicalize_dynamic_symtab
9623 #define alpha_vms_get_dynamic_reloc_upper_bound \
9624 _bfd_nodynamic_get_dynamic_reloc_upper_bound
9625 #define alpha_vms_canonicalize_dynamic_reloc \
9626 _bfd_nodynamic_canonicalize_dynamic_reloc
9627 #define alpha_vms_bfd_link_check_relocs _bfd_generic_link_check_relocs
9629 const bfd_target alpha_vms_vec
=
9631 "vms-alpha", /* Name. */
9632 bfd_target_evax_flavour
,
9633 BFD_ENDIAN_LITTLE
, /* Data byte order is little. */
9634 BFD_ENDIAN_LITTLE
, /* Header byte order is little. */
9636 (HAS_RELOC
| EXEC_P
| HAS_LINENO
| HAS_DEBUG
| HAS_SYMS
| HAS_LOCALS
9637 | WP_TEXT
| D_PAGED
), /* Object flags. */
9638 (SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
9639 | SEC_READONLY
| SEC_CODE
| SEC_DATA
9640 | SEC_HAS_CONTENTS
| SEC_IN_MEMORY
), /* Sect flags. */
9641 0, /* symbol_leading_char. */
9642 ' ', /* ar_pad_char. */
9643 15, /* ar_max_namelen. */
9644 0, /* match priority. */
9645 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
9646 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
9647 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
9648 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
9649 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
9650 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
9652 { /* bfd_check_format. */
9655 _bfd_vms_lib_alpha_archive_p
,
9658 { /* bfd_set_format. */
9659 _bfd_bool_bfd_false_error
,
9661 _bfd_vms_lib_alpha_mkarchive
,
9662 _bfd_bool_bfd_false_error
9664 { /* bfd_write_contents. */
9665 _bfd_bool_bfd_false_error
,
9666 alpha_vms_write_object_contents
,
9667 _bfd_vms_lib_write_archive_contents
,
9668 _bfd_bool_bfd_false_error
9671 BFD_JUMP_TABLE_GENERIC (alpha_vms
),
9672 BFD_JUMP_TABLE_COPY (vms
),
9673 BFD_JUMP_TABLE_CORE (_bfd_nocore
),
9674 BFD_JUMP_TABLE_ARCHIVE (_bfd_vms_lib
),
9675 BFD_JUMP_TABLE_SYMBOLS (alpha_vms
),
9676 BFD_JUMP_TABLE_RELOCS (alpha_vms
),
9677 BFD_JUMP_TABLE_WRITE (alpha_vms
),
9678 BFD_JUMP_TABLE_LINK (alpha_vms
),
9679 BFD_JUMP_TABLE_DYNAMIC (alpha_vms
),