1 /* vms.c -- BFD back-end for EVAX (openVMS/Alpha) files.
2 Copyright (C) 1996-2017 Free Software Foundation, Inc.
4 Initial version written by Klaus Kaempf (kkaempf@rmi.de)
5 Major rewrite by Adacore.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20 MA 02110-1301, USA. */
25 o Generation of shared image
26 o Relocation optimizations
32 o protected sections (for messages)
50 #include "vms/eihvn.h"
51 #include "vms/eobjrec.h"
54 #include "vms/esgps.h"
63 #include "vms/esdfm.h"
64 #include "vms/esdfv.h"
70 #include "vms/internal.h"
73 #define MIN(a,b) ((a) < (b) ? (a) : (b))
75 /* The r_type field in a reloc is one of the following values. */
76 #define ALPHA_R_IGNORE 0
77 #define ALPHA_R_REFQUAD 1
78 #define ALPHA_R_BRADDR 2
79 #define ALPHA_R_HINT 3
80 #define ALPHA_R_SREL16 4
81 #define ALPHA_R_SREL32 5
82 #define ALPHA_R_SREL64 6
83 #define ALPHA_R_OP_PUSH 7
84 #define ALPHA_R_OP_STORE 8
85 #define ALPHA_R_OP_PSUB 9
86 #define ALPHA_R_OP_PRSHIFT 10
87 #define ALPHA_R_LINKAGE 11
88 #define ALPHA_R_REFLONG 12
89 #define ALPHA_R_CODEADDR 13
90 #define ALPHA_R_NOP 14
91 #define ALPHA_R_BSR 15
92 #define ALPHA_R_LDA 16
93 #define ALPHA_R_BOH 17
95 /* These are used with DST_S_C_LINE_NUM. */
96 #define DST_S_C_LINE_NUM_HEADER_SIZE 4
98 /* These are used with DST_S_C_SOURCE */
100 #define DST_S_B_PCLINE_UNSBYTE 1
101 #define DST_S_W_PCLINE_UNSWORD 1
102 #define DST_S_L_PCLINE_UNSLONG 1
104 #define DST_S_B_MODBEG_NAME 14
105 #define DST_S_L_RTNBEG_ADDRESS 5
106 #define DST_S_B_RTNBEG_NAME 13
107 #define DST_S_L_RTNEND_SIZE 5
109 /* These are used with DST_S_C_SOURCE. */
110 #define DST_S_C_SOURCE_HEADER_SIZE 4
112 #define DST_S_B_SRC_DF_LENGTH 1
113 #define DST_S_W_SRC_DF_FILEID 3
114 #define DST_S_B_SRC_DF_FILENAME 20
115 #define DST_S_B_SRC_UNSBYTE 1
116 #define DST_S_W_SRC_UNSWORD 1
117 #define DST_S_L_SRC_UNSLONG 1
119 /* Debugger symbol definitions. */
121 #define DBG_S_L_DMT_MODBEG 0
122 #define DBG_S_L_DST_SIZE 4
123 #define DBG_S_W_DMT_PSECT_COUNT 8
124 #define DBG_S_C_DMT_HEADER_SIZE 12
126 #define DBG_S_L_DMT_PSECT_START 0
127 #define DBG_S_L_DMT_PSECT_LENGTH 4
128 #define DBG_S_C_DMT_PSECT_SIZE 8
130 /* VMS module header. */
146 #define EMH_DATE_LENGTH 17
148 /* VMS End-Of-Module records (EOM/EEOM). */
152 unsigned int eom_l_total_lps
;
153 unsigned short eom_w_comcod
;
154 bfd_boolean eom_has_transfer
;
155 unsigned char eom_b_tfrflg
;
156 unsigned int eom_l_psindx
;
157 unsigned int eom_l_tfradr
;
160 struct vms_symbol_entry
166 unsigned char data_type
;
167 unsigned short flags
;
169 /* Section and offset/value of the symbol. */
173 /* Section and offset/value for the entry point (only for subprg). */
174 asection
*code_section
;
175 unsigned int code_value
;
177 /* Symbol vector offset. */
178 unsigned int symbol_vector
;
180 /* Length of the name. */
181 unsigned char namelen
;
186 /* Stack value for push/pop commands. */
194 #define STACKSIZE 128
196 /* A minimal decoding of DST compilation units. We only decode
197 what's needed to get to the line number information. */
207 struct srecinfo
*next
;
215 struct lineinfo
*next
;
222 struct funcinfo
*next
;
230 /* Chain the previously read compilation unit. */
233 /* The module name. */
236 /* The start offset and size of debug info in the DST section. */
240 /* The lowest and highest addresses contained in this compilation
241 unit as specified in the compilation unit header. */
245 /* The listing line table. */
246 struct lineinfo
*line_table
;
248 /* The source record table. */
249 struct srecinfo
*srec_table
;
251 /* A list of the functions found in this module. */
252 struct funcinfo
*func_table
;
254 /* Current allocation of file_table. */
255 unsigned int file_table_count
;
257 /* An array of the files making up this module. */
258 struct fileinfo
*file_table
;
261 /* BFD private data for alpha-vms. */
263 struct vms_private_data_struct
265 /* If true, relocs have been read. */
266 bfd_boolean reloc_done
;
268 /* Record input buffer. */
269 struct vms_rec_rd recrd
;
270 struct vms_rec_wr recwr
;
272 struct hdr_struct hdr_data
; /* data from HDR/EMH record */
273 struct eom_struct eom_data
; /* data from EOM/EEOM record */
275 /* Transfer addresses (entry points). */
276 bfd_vma transfer_address
[4];
278 /* Array of GSD sections to get the correspond BFD one. */
279 unsigned int section_max
; /* Size of the sections array. */
280 unsigned int section_count
; /* Number of GSD sections. */
283 /* Array of raw symbols. */
284 struct vms_symbol_entry
**syms
;
286 /* Canonicalized symbols. */
289 /* Number of symbols. */
290 unsigned int gsd_sym_count
;
291 /* Size of the syms array. */
292 unsigned int max_sym_count
;
293 /* Number of procedure symbols. */
294 unsigned int norm_sym_count
;
296 /* Stack used to evaluate TIR/ETIR commands. */
297 struct stack_struct
*stack
;
300 /* Content reading. */
301 asection
*image_section
; /* section for image_ptr */
302 file_ptr image_offset
; /* Offset for image_ptr. */
304 struct module
*modules
; /* list of all compilation units */
306 /* The DST section. */
307 asection
*dst_section
;
309 unsigned int dst_ptr_offsets_count
; /* # of offsets in following array */
310 unsigned int *dst_ptr_offsets
; /* array of saved image_ptr offsets */
312 /* Shared library support */
313 bfd_vma symvva
; /* relative virtual address of symbol vector */
315 unsigned char matchctl
;
317 /* Shared library index. This is used for input bfd while linking. */
318 unsigned int shr_index
;
320 /* Used to place structures in the file. */
323 /* Simply linked list of eisd. */
324 struct vms_internal_eisd_map
*eisd_head
;
325 struct vms_internal_eisd_map
*eisd_tail
;
327 /* Simply linked list of eisd for shared libraries. */
328 struct vms_internal_eisd_map
*gbl_eisd_head
;
329 struct vms_internal_eisd_map
*gbl_eisd_tail
;
331 /* linkage index counter used by conditional store commands */
332 unsigned int vms_linkage_index
;
335 #define PRIV2(abfd, name) \
336 (((struct vms_private_data_struct *)(abfd)->tdata.any)->name)
337 #define PRIV(name) PRIV2(abfd,name)
340 /* Used to keep extra VMS specific information for a given section.
342 reloc_size holds the size of the relocation stream, note this
343 is very different from the number of relocations as VMS relocations
346 reloc_stream is the actual stream of relocation entries. */
348 struct vms_section_data_struct
350 /* Maximnum number of entries in sec->relocation. */
353 /* Corresponding eisd. Used only while generating executables. */
354 struct vms_internal_eisd_map
*eisd
;
356 /* PSC flags to be clear. */
359 /* PSC flags to be set. */
363 #define vms_section_data(sec) \
364 ((struct vms_section_data_struct *)sec->used_by_bfd)
366 /* To be called from the debugger. */
367 struct vms_private_data_struct
*bfd_vms_get_data (bfd
*);
369 static int vms_get_remaining_object_record (bfd
*, unsigned int);
370 static bfd_boolean
_bfd_vms_slurp_object_records (bfd
* abfd
);
371 static void alpha_vms_add_fixup_lp (struct bfd_link_info
*, bfd
*, bfd
*);
372 static void alpha_vms_add_fixup_ca (struct bfd_link_info
*, bfd
*, bfd
*);
373 static void alpha_vms_add_fixup_qr (struct bfd_link_info
*, bfd
*, bfd
*,
375 static void alpha_vms_add_fixup_lr (struct bfd_link_info
*, unsigned int,
377 static void alpha_vms_add_lw_reloc (struct bfd_link_info
*);
378 static void alpha_vms_add_qw_reloc (struct bfd_link_info
*);
387 /* Number of elements in VEC. */
389 #define VEC_COUNT(VEC) ((VEC).nbr_el)
391 /* Get the address of the Nth element. */
393 #define VEC_EL(VEC, TYPE, N) (((TYPE *)((VEC).els))[N])
395 #define VEC_INIT(VEC) \
402 /* Be sure there is room for a new element. */
404 static void vector_grow1 (struct vector_type
*vec
, size_t elsz
);
406 /* Allocate room for a new element and return its address. */
408 #define VEC_APPEND(VEC, TYPE) \
409 (vector_grow1 (&VEC, sizeof (TYPE)), &VEC_EL(VEC, TYPE, (VEC).nbr_el++))
411 /* Append an element. */
413 #define VEC_APPEND_EL(VEC, TYPE, EL) \
414 (*(VEC_APPEND (VEC, TYPE)) = EL)
416 struct alpha_vms_vma_ref
418 bfd_vma vma
; /* Vma in the output. */
419 bfd_vma ref
; /* Reference in the input. */
422 struct alpha_vms_shlib_el
425 bfd_boolean has_fixups
;
427 struct vector_type lp
; /* Vector of bfd_vma. */
428 struct vector_type ca
; /* Vector of bfd_vma. */
429 struct vector_type qr
; /* Vector of struct alpha_vms_vma_ref. */
432 /* Alpha VMS linker hash table. */
434 struct alpha_vms_link_hash_table
436 struct bfd_link_hash_table root
;
438 /* Vector of shared libraries. */
439 struct vector_type shrlibs
;
444 /* Base address. Used by fixups. */
448 #define alpha_vms_link_hash(INFO) \
449 ((struct alpha_vms_link_hash_table *)(INFO->hash))
451 /* Alpha VMS linker hash table entry. */
453 struct alpha_vms_link_hash_entry
455 struct bfd_link_hash_entry root
;
457 /* Pointer to the original vms symbol. */
458 struct vms_symbol_entry
*sym
;
463 /* Read & process EIHD record.
464 Return TRUE on success, FALSE on error. */
467 _bfd_vms_slurp_eihd (bfd
*abfd
, unsigned int *eisd_offset
,
468 unsigned int *eihs_offset
)
470 unsigned int imgtype
, size
;
472 struct vms_eihd
*eihd
= (struct vms_eihd
*)PRIV (recrd
.rec
);
474 vms_debug2 ((8, "_bfd_vms_slurp_eihd\n"));
476 /* PR 21813: Check for an undersized record. */
477 if (PRIV (recrd
.buf_size
) < sizeof (* eihd
))
479 _bfd_error_handler (_("Corrupt EIHD record - size is too small"));
480 bfd_set_error (bfd_error_bad_value
);
484 size
= bfd_getl32 (eihd
->size
);
485 imgtype
= bfd_getl32 (eihd
->imgtype
);
487 if (imgtype
== EIHD__K_EXE
|| imgtype
== EIHD__K_LIM
)
488 abfd
->flags
|= EXEC_P
;
490 symvva
= bfd_getl64 (eihd
->symvva
);
493 PRIV (symvva
) = symvva
;
494 abfd
->flags
|= DYNAMIC
;
497 PRIV (ident
) = bfd_getl32 (eihd
->ident
);
498 PRIV (matchctl
) = eihd
->matchctl
;
500 *eisd_offset
= bfd_getl32 (eihd
->isdoff
);
501 *eihs_offset
= bfd_getl32 (eihd
->symdbgoff
);
503 vms_debug2 ((4, "EIHD size %d imgtype %d symvva 0x%lx eisd %d eihs %d\n",
504 size
, imgtype
, (unsigned long)symvva
,
505 *eisd_offset
, *eihs_offset
));
510 /* Read & process EISD record.
511 Return TRUE on success, FALSE on error. */
514 _bfd_vms_slurp_eisd (bfd
*abfd
, unsigned int offset
)
516 int section_count
= 0;
518 vms_debug2 ((8, "_bfd_vms_slurp_eisd\n"));
522 struct vms_eisd
*eisd
;
523 unsigned int rec_size
;
532 /* PR 17512: file: 3d9e9fe9.
533 12 is the offset of the eisdsize field from the start of the record (8)
534 plus the size of the eisdsize field (4). */
535 if (offset
>= PRIV (recrd
.rec_size
) - 12)
537 eisd
= (struct vms_eisd
*)(PRIV (recrd
.rec
) + offset
);
538 rec_size
= bfd_getl32 (eisd
->eisdsize
);
542 /* Skip to next block if pad. */
543 if (rec_size
== 0xffffffff)
545 offset
= (offset
+ VMS_BLOCK_SIZE
) & ~(VMS_BLOCK_SIZE
- 1);
549 /* Make sure that there is enough data present in the record. */
550 /* FIXME: Should we use sizeof (struct vms_eisd) rather than just 32 here ? */
553 /* Make sure that the record is not too big either. */
554 if (offset
+ rec_size
>= PRIV (recrd
.rec_size
))
559 size
= bfd_getl32 (eisd
->secsize
);
560 vaddr
= bfd_getl64 (eisd
->virt_addr
);
561 flags
= bfd_getl32 (eisd
->flags
);
562 vbn
= bfd_getl32 (eisd
->vbn
);
564 vms_debug2 ((4, "EISD at 0x%x size 0x%x addr 0x%lx flags 0x%x blk %d\n",
565 offset
, size
, (unsigned long)vaddr
, flags
, vbn
));
567 /* VMS combines psects from .obj files into isects in the .exe. This
568 process doesn't preserve enough information to reliably determine
569 what's in each section without examining the data. This is
570 especially true of DWARF debug sections. */
571 bfd_flags
= SEC_ALLOC
;
573 bfd_flags
|= SEC_HAS_CONTENTS
| SEC_LOAD
;
575 if (flags
& EISD__M_EXE
)
576 bfd_flags
|= SEC_CODE
;
578 if (flags
& EISD__M_NONSHRADR
)
579 bfd_flags
|= SEC_DATA
;
581 if (!(flags
& EISD__M_WRT
))
582 bfd_flags
|= SEC_READONLY
;
584 if (flags
& EISD__M_DZRO
)
585 bfd_flags
|= SEC_DATA
;
587 if (flags
& EISD__M_FIXUPVEC
)
588 bfd_flags
|= SEC_DATA
;
590 if (flags
& EISD__M_CRF
)
591 bfd_flags
|= SEC_DATA
;
593 if (flags
& EISD__M_GBL
)
595 if (rec_size
< offsetof (struct vms_eisd
, gblnam
))
597 else if (rec_size
< sizeof (struct vms_eisd
))
598 name
= _bfd_vms_save_counted_string (eisd
->gblnam
,
599 rec_size
- offsetof (struct vms_eisd
, gblnam
));
601 name
= _bfd_vms_save_counted_string (eisd
->gblnam
, EISD__K_GBLNAMLEN
);
602 bfd_flags
|= SEC_COFF_SHARED_LIBRARY
;
603 bfd_flags
&= ~(SEC_ALLOC
| SEC_LOAD
);
605 else if (flags
& EISD__M_FIXUPVEC
)
607 else if (eisd
->type
== EISD__K_USRSTACK
)
613 name
= (char*) bfd_alloc (abfd
, 32);
614 if (flags
& EISD__M_DZRO
)
616 else if (flags
& EISD__M_EXE
)
618 else if (!(flags
& EISD__M_WRT
))
622 BFD_ASSERT (section_count
< 999);
623 sprintf (name
, "$%s_%03d$", pfx
, section_count
++);
626 section
= bfd_make_section (abfd
, name
);
631 section
->filepos
= vbn
? VMS_BLOCK_SIZE
* (vbn
- 1) : 0;
632 section
->size
= size
;
633 section
->vma
= vaddr
;
635 if (!bfd_set_section_flags (abfd
, section
, bfd_flags
))
642 /* Read & process EIHS record.
643 Return TRUE on success, FALSE on error. */
646 _bfd_vms_slurp_eihs (bfd
*abfd
, unsigned int offset
)
648 unsigned char *p
= PRIV (recrd
.rec
) + offset
;
650 unsigned int gstsize ATTRIBUTE_UNUSED
;
652 unsigned int dstsize
;
654 unsigned int dmtbytes
;
657 /* PR 21611: Check that offset is valid. */
658 if (offset
> PRIV (recrd
.rec_size
) - (EIHS__L_DMTBYTES
+ 4))
660 _bfd_error_handler (_("Unable to read EIHS record at offset %#x"), offset
);
661 bfd_set_error (bfd_error_file_truncated
);
665 gstvbn
= bfd_getl32 (p
+ EIHS__L_GSTVBN
);
666 gstsize
= bfd_getl32 (p
+ EIHS__L_GSTSIZE
);
667 dstvbn
= bfd_getl32 (p
+ EIHS__L_DSTVBN
);
668 dstsize
= bfd_getl32 (p
+ EIHS__L_DSTSIZE
);
669 dmtvbn
= bfd_getl32 (p
+ EIHS__L_DMTVBN
);
670 dmtbytes
= bfd_getl32 (p
+ EIHS__L_DMTBYTES
);
673 vms_debug (8, "_bfd_vms_slurp_ihs\n");
674 vms_debug (4, "EIHS record gstvbn %d gstsize %d dstvbn %d dstsize %d dmtvbn %d dmtbytes %d\n",
675 gstvbn
, gstsize
, dstvbn
, dstsize
, dmtvbn
, dmtbytes
);
680 flagword bfd_flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
;
682 section
= bfd_make_section (abfd
, "$DST$");
686 section
->size
= dstsize
;
687 section
->filepos
= VMS_BLOCK_SIZE
* (dstvbn
- 1);
689 if (!bfd_set_section_flags (abfd
, section
, bfd_flags
))
692 PRIV (dst_section
) = section
;
693 abfd
->flags
|= (HAS_DEBUG
| HAS_LINENO
);
698 flagword bfd_flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
;
700 section
= bfd_make_section (abfd
, "$DMT$");
704 section
->size
= dmtbytes
;
705 section
->filepos
= VMS_BLOCK_SIZE
* (dmtvbn
- 1);
707 if (!bfd_set_section_flags (abfd
, section
, bfd_flags
))
713 if (bfd_seek (abfd
, VMS_BLOCK_SIZE
* (gstvbn
- 1), SEEK_SET
))
715 bfd_set_error (bfd_error_file_truncated
);
719 if (!_bfd_vms_slurp_object_records (abfd
))
722 abfd
->flags
|= HAS_SYMS
;
728 /* Object file reading. */
730 /* Object file input functions. */
732 /* Get next record from object file to vms_buf.
733 Set PRIV(buf_size) and return it
735 This is a little tricky since it should be portable.
737 The openVMS object file has 'variable length' which means that
738 read() returns data in chunks of (hopefully) correct and expected
739 size. The linker (and other tools on VMS) depend on that. Unix
740 doesn't know about 'formatted' files, so reading and writing such
741 an object file in a Unix environment is not trivial.
743 With the tool 'file' (available on all VMS FTP sites), one
744 can view and change the attributes of a file. Changing from
745 'variable length' to 'fixed length, 512 bytes' reveals the
746 record size at the first 2 bytes of every record. The same
747 may happen during the transfer of object files from VMS to Unix,
748 at least with UCX, the DEC implementation of TCP/IP.
750 The VMS format repeats the size at bytes 2 & 3 of every record.
752 On the first call (file_format == FF_UNKNOWN) we check if
753 the first and the third byte pair (!) of the record match.
754 If they do it's an object file in an Unix environment or with
755 wrong attributes (FF_FOREIGN), else we should be in a VMS
756 environment where read() returns the record size (FF_NATIVE).
758 Reading is always done in 2 steps:
759 1. first just the record header is read and the size extracted,
760 2. then the read buffer is adjusted and the remaining bytes are
763 All file I/O is done on even file positions. */
765 #define VMS_OBJECT_ADJUSTMENT 2
768 maybe_adjust_record_pointer_for_object (bfd
*abfd
)
770 /* Set the file format once for all on the first invocation. */
771 if (PRIV (recrd
.file_format
) == FF_UNKNOWN
)
773 if (PRIV (recrd
.rec
)[0] == PRIV (recrd
.rec
)[4]
774 && PRIV (recrd
.rec
)[1] == PRIV (recrd
.rec
)[5])
775 PRIV (recrd
.file_format
) = FF_FOREIGN
;
777 PRIV (recrd
.file_format
) = FF_NATIVE
;
780 /* The adjustment is needed only in an Unix environment. */
781 if (PRIV (recrd
.file_format
) == FF_FOREIGN
)
782 PRIV (recrd
.rec
) += VMS_OBJECT_ADJUSTMENT
;
785 /* Implement step #1 of the object record reading procedure.
786 Return the record type or -1 on failure. */
789 _bfd_vms_get_object_record (bfd
*abfd
)
791 unsigned int test_len
= 6;
794 vms_debug2 ((8, "_bfd_vms_get_obj_record\n"));
796 /* Skip alignment byte if the current position is odd. */
797 if (PRIV (recrd
.file_format
) == FF_FOREIGN
&& (bfd_tell (abfd
) & 1))
799 if (bfd_bread (PRIV (recrd
.buf
), 1, abfd
) != 1)
801 bfd_set_error (bfd_error_file_truncated
);
806 /* Read the record header */
807 if (bfd_bread (PRIV (recrd
.buf
), test_len
, abfd
) != test_len
)
809 bfd_set_error (bfd_error_file_truncated
);
813 /* Reset the record pointer. */
814 PRIV (recrd
.rec
) = PRIV (recrd
.buf
);
815 maybe_adjust_record_pointer_for_object (abfd
);
817 if (vms_get_remaining_object_record (abfd
, test_len
) <= 0)
820 type
= bfd_getl16 (PRIV (recrd
.rec
));
822 vms_debug2 ((8, "_bfd_vms_get_obj_record: rec %p, size %d, type %d\n",
823 PRIV (recrd
.rec
), PRIV (recrd
.rec_size
), type
));
828 /* Implement step #2 of the object record reading procedure.
829 Return the size of the record or 0 on failure. */
832 vms_get_remaining_object_record (bfd
*abfd
, unsigned int read_so_far
)
834 unsigned int to_read
;
836 vms_debug2 ((8, "vms_get_remaining_obj_record\n"));
838 /* Extract record size. */
839 PRIV (recrd
.rec_size
) = bfd_getl16 (PRIV (recrd
.rec
) + 2);
841 if (PRIV (recrd
.rec_size
) == 0)
843 bfd_set_error (bfd_error_file_truncated
);
847 /* That's what the linker manual says. */
848 if (PRIV (recrd
.rec_size
) > EOBJ__C_MAXRECSIZ
)
850 bfd_set_error (bfd_error_file_truncated
);
854 /* Take into account object adjustment. */
855 to_read
= PRIV (recrd
.rec_size
);
856 if (PRIV (recrd
.file_format
) == FF_FOREIGN
)
857 to_read
+= VMS_OBJECT_ADJUSTMENT
;
859 /* Adjust the buffer. */
860 if (to_read
> PRIV (recrd
.buf_size
))
863 = (unsigned char *) bfd_realloc (PRIV (recrd
.buf
), to_read
);
864 if (PRIV (recrd
.buf
) == NULL
)
866 PRIV (recrd
.buf_size
) = to_read
;
868 /* PR 17512: file: 025-1974-0.004. */
869 else if (to_read
<= read_so_far
)
872 /* Read the remaining record. */
873 to_read
-= read_so_far
;
875 vms_debug2 ((8, "vms_get_remaining_obj_record: to_read %d\n", to_read
));
877 if (bfd_bread (PRIV (recrd
.buf
) + read_so_far
, to_read
, abfd
) != to_read
)
879 bfd_set_error (bfd_error_file_truncated
);
883 /* Reset the record pointer. */
884 PRIV (recrd
.rec
) = PRIV (recrd
.buf
);
885 maybe_adjust_record_pointer_for_object (abfd
);
887 vms_debug2 ((8, "vms_get_remaining_obj_record: size %d\n",
888 PRIV (recrd
.rec_size
)));
890 return PRIV (recrd
.rec_size
);
893 /* Read and process emh record.
894 Return TRUE on success, FALSE on error. */
897 _bfd_vms_slurp_ehdr (bfd
*abfd
)
900 unsigned char *vms_rec
;
904 vms_rec
= PRIV (recrd
.rec
);
905 /* PR 17512: file: 62736583. */
906 end
= vms_rec
+ PRIV (recrd
.buf_size
);
908 vms_debug2 ((2, "HDR/EMH\n"));
910 subtype
= bfd_getl16 (vms_rec
+ 4);
912 vms_debug2 ((3, "subtype %d\n", subtype
));
918 if (vms_rec
+ 21 >= end
)
920 PRIV (hdr_data
).hdr_b_strlvl
= vms_rec
[6];
921 PRIV (hdr_data
).hdr_l_arch1
= bfd_getl32 (vms_rec
+ 8);
922 PRIV (hdr_data
).hdr_l_arch2
= bfd_getl32 (vms_rec
+ 12);
923 PRIV (hdr_data
).hdr_l_recsiz
= bfd_getl32 (vms_rec
+ 16);
924 if ((vms_rec
+ 20 + vms_rec
[20] + 1) >= end
)
926 PRIV (hdr_data
).hdr_t_name
= _bfd_vms_save_counted_string (vms_rec
+ 20, vms_rec
[20]);
927 ptr
= vms_rec
+ 20 + vms_rec
[20] + 1;
928 if ((ptr
+ *ptr
+ 1) >= end
)
930 PRIV (hdr_data
).hdr_t_version
=_bfd_vms_save_counted_string (ptr
, *ptr
);
934 PRIV (hdr_data
).hdr_t_date
= _bfd_vms_save_sized_string (ptr
, 17);
938 if (vms_rec
+ PRIV (recrd
.rec_size
- 6) > end
)
940 PRIV (hdr_data
).hdr_c_lnm
=
941 _bfd_vms_save_sized_string (vms_rec
, PRIV (recrd
.rec_size
- 6));
945 if (vms_rec
+ PRIV (recrd
.rec_size
- 6) > end
)
947 PRIV (hdr_data
).hdr_c_src
=
948 _bfd_vms_save_sized_string (vms_rec
, PRIV (recrd
.rec_size
- 6));
952 if (vms_rec
+ PRIV (recrd
.rec_size
- 6) > end
)
954 PRIV (hdr_data
).hdr_c_ttl
=
955 _bfd_vms_save_sized_string (vms_rec
, PRIV (recrd
.rec_size
- 6));
965 bfd_set_error (bfd_error_wrong_format
);
972 /* Typical sections for evax object files. */
974 #define EVAX_ABS_NAME "$ABS$"
975 #define EVAX_CODE_NAME "$CODE$"
976 #define EVAX_LINK_NAME "$LINK$"
977 #define EVAX_DATA_NAME "$DATA$"
978 #define EVAX_BSS_NAME "$BSS$"
979 #define EVAX_READONLYADDR_NAME "$READONLY_ADDR$"
980 #define EVAX_READONLY_NAME "$READONLY$"
981 #define EVAX_LITERAL_NAME "$LITERAL$"
982 #define EVAX_LITERALS_NAME "$LITERALS"
983 #define EVAX_COMMON_NAME "$COMMON$"
984 #define EVAX_LOCAL_NAME "$LOCAL$"
986 struct sec_flags_struct
988 const char *name
; /* Name of section. */
990 flagword flags_always
; /* Flags we set always. */
992 flagword flags_hassize
; /* Flags we set if the section has a size > 0. */
995 /* These flags are deccrtl/vaxcrtl (openVMS 6.2 Alpha) compatible. */
997 static const struct sec_flags_struct evax_section_flags
[] =
1005 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_EXE
,
1006 SEC_CODE
| SEC_READONLY
,
1007 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_EXE
,
1008 SEC_CODE
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1009 { EVAX_LITERAL_NAME
,
1010 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
| EGPS__V_NOMOD
,
1011 SEC_DATA
| SEC_READONLY
,
1012 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
,
1013 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1015 EGPS__V_REL
| EGPS__V_RD
,
1016 SEC_DATA
| SEC_READONLY
,
1017 EGPS__V_REL
| EGPS__V_RD
,
1018 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1020 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
,
1022 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1023 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1025 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
,
1027 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
,
1029 { EVAX_READONLYADDR_NAME
,
1030 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_RD
,
1031 SEC_DATA
| SEC_READONLY
,
1032 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_RD
,
1033 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1034 { EVAX_READONLY_NAME
,
1035 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
| EGPS__V_NOMOD
,
1036 SEC_DATA
| SEC_READONLY
,
1037 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
,
1038 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1040 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1042 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1043 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1044 { EVAX_LITERALS_NAME
,
1045 EGPS__V_PIC
| EGPS__V_OVR
,
1046 SEC_DATA
| SEC_READONLY
,
1047 EGPS__V_PIC
| EGPS__V_OVR
,
1048 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1050 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1052 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1053 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
}
1056 /* Retrieve BFD section flags by name and size. */
1059 vms_secflag_by_name (const struct sec_flags_struct
*section_flags
,
1065 while (section_flags
[i
].name
!= NULL
)
1067 if (strcmp (name
, section_flags
[i
].name
) == 0)
1070 return section_flags
[i
].flags_hassize
;
1072 return section_flags
[i
].flags_always
;
1077 return section_flags
[i
].flags_hassize
;
1078 return section_flags
[i
].flags_always
;
1081 /* Retrieve VMS section flags by name and size. */
1084 vms_esecflag_by_name (const struct sec_flags_struct
*section_flags
,
1090 while (section_flags
[i
].name
!= NULL
)
1092 if (strcmp (name
, section_flags
[i
].name
) == 0)
1095 return section_flags
[i
].vflags_hassize
;
1097 return section_flags
[i
].vflags_always
;
1102 return section_flags
[i
].vflags_hassize
;
1103 return section_flags
[i
].vflags_always
;
1106 /* Add SYM to the symbol table of ABFD.
1107 Return FALSE in case of error. */
1110 add_symbol_entry (bfd
*abfd
, struct vms_symbol_entry
*sym
)
1112 if (PRIV (gsd_sym_count
) >= PRIV (max_sym_count
))
1114 if (PRIV (max_sym_count
) == 0)
1116 PRIV (max_sym_count
) = 128;
1117 PRIV (syms
) = bfd_malloc
1118 (PRIV (max_sym_count
) * sizeof (struct vms_symbol_entry
*));
1122 PRIV (max_sym_count
) *= 2;
1123 PRIV (syms
) = bfd_realloc
1125 (PRIV (max_sym_count
) * sizeof (struct vms_symbol_entry
*)));
1127 if (PRIV (syms
) == NULL
)
1131 PRIV (syms
)[PRIV (gsd_sym_count
)++] = sym
;
1135 /* Create a symbol whose name is ASCIC and add it to ABFD.
1136 Return NULL in case of error. */
1138 static struct vms_symbol_entry
*
1139 add_symbol (bfd
*abfd
, const unsigned char *ascic
)
1141 struct vms_symbol_entry
*entry
;
1145 entry
= (struct vms_symbol_entry
*)bfd_zalloc (abfd
, sizeof (*entry
) + len
);
1148 entry
->namelen
= len
;
1149 memcpy (entry
->name
, ascic
, len
);
1150 entry
->name
[len
] = 0;
1151 entry
->owner
= abfd
;
1153 if (!add_symbol_entry (abfd
, entry
))
1158 /* Read and process EGSD. Return FALSE on failure. */
1161 _bfd_vms_slurp_egsd (bfd
*abfd
)
1164 unsigned int gsd_size
;
1165 unsigned char *vms_rec
;
1166 unsigned long base_addr
;
1168 vms_debug2 ((2, "EGSD\n"));
1170 if (PRIV (recrd
.rec_size
) < 8)
1172 _bfd_error_handler (_("Corrupt EGSD record: its size (%#x) is too small"),
1173 PRIV (recrd
.rec_size
));
1174 bfd_set_error (bfd_error_bad_value
);
1178 PRIV (recrd
.rec
) += 8; /* Skip type, size, align pad. */
1179 PRIV (recrd
.rec_size
) -= 8;
1181 /* Calculate base address for each section. */
1184 while (PRIV (recrd
.rec_size
) > 4)
1186 vms_rec
= PRIV (recrd
.rec
);
1188 gsd_type
= bfd_getl16 (vms_rec
);
1189 gsd_size
= bfd_getl16 (vms_rec
+ 2);
1191 vms_debug2 ((3, "egsd_type %d\n", gsd_type
));
1193 /* PR 21615: Check for size overflow. */
1194 if (PRIV (recrd
.rec_size
) < gsd_size
)
1196 _bfd_error_handler (_("Corrupt EGSD record: size (%#x) is larger than remaining space (%#x)"),
1197 gsd_size
, PRIV (recrd
.rec_size
));
1198 bfd_set_error (bfd_error_bad_value
);
1204 _bfd_error_handler (_("Corrupt EGSD record: size (%#x) is too small"),
1206 bfd_set_error (bfd_error_bad_value
);
1213 /* Program section definition. */
1215 struct vms_egps
*egps
= (struct vms_egps
*)vms_rec
;
1216 flagword new_flags
, vms_flags
;
1219 vms_flags
= bfd_getl16 (egps
->flags
);
1221 if ((vms_flags
& EGPS__V_REL
) == 0)
1223 /* Use the global absolute section for all
1224 absolute sections. */
1225 section
= bfd_abs_section_ptr
;
1230 unsigned long align_addr
;
1232 name
= _bfd_vms_save_counted_string (&egps
->namlng
, gsd_size
- 4);
1234 section
= bfd_make_section (abfd
, name
);
1238 section
->filepos
= 0;
1239 section
->size
= bfd_getl32 (egps
->alloc
);
1240 section
->alignment_power
= egps
->align
;
1242 vms_section_data (section
)->flags
= vms_flags
;
1243 vms_section_data (section
)->no_flags
= 0;
1245 new_flags
= vms_secflag_by_name (evax_section_flags
, name
,
1247 if (section
->size
> 0)
1248 new_flags
|= SEC_LOAD
;
1249 if (!(vms_flags
& EGPS__V_NOMOD
) && section
->size
> 0)
1251 /* Set RELOC and HAS_CONTENTS if the section is not
1252 demand-zero and not empty. */
1253 new_flags
|= SEC_HAS_CONTENTS
;
1254 if (vms_flags
& EGPS__V_REL
)
1255 new_flags
|= SEC_RELOC
;
1257 if (vms_flags
& EGPS__V_EXE
)
1259 /* Set CODE if section is executable. */
1260 new_flags
|= SEC_CODE
;
1261 new_flags
&= ~SEC_DATA
;
1263 if (!bfd_set_section_flags (abfd
, section
, new_flags
))
1266 /* Give a non-overlapping vma to non absolute sections. */
1267 align_addr
= (1 << section
->alignment_power
);
1268 if ((base_addr
% align_addr
) != 0)
1269 base_addr
+= (align_addr
- (base_addr
% align_addr
));
1270 section
->vma
= (bfd_vma
)base_addr
;
1271 base_addr
+= section
->size
;
1274 /* Append it to the section array. */
1275 if (PRIV (section_count
) >= PRIV (section_max
))
1277 if (PRIV (section_max
) == 0)
1278 PRIV (section_max
) = 16;
1280 PRIV (section_max
) *= 2;
1281 PRIV (sections
) = bfd_realloc_or_free
1282 (PRIV (sections
), PRIV (section_max
) * sizeof (asection
*));
1283 if (PRIV (sections
) == NULL
)
1287 PRIV (sections
)[PRIV (section_count
)] = section
;
1288 PRIV (section_count
)++;
1295 struct vms_symbol_entry
*entry
;
1296 struct vms_egsy
*egsy
= (struct vms_egsy
*) vms_rec
;
1299 old_flags
= bfd_getl16 (egsy
->flags
);
1300 if (old_flags
& EGSY__V_DEF
)
1301 nameoff
= ESDF__B_NAMLNG
;
1303 nameoff
= ESRF__B_NAMLNG
;
1305 entry
= add_symbol (abfd
, vms_rec
+ nameoff
);
1309 /* Allow only duplicate reference. */
1310 if ((entry
->flags
& EGSY__V_DEF
) && (old_flags
& EGSY__V_DEF
))
1313 if (entry
->typ
== 0)
1315 entry
->typ
= gsd_type
;
1316 entry
->data_type
= egsy
->datyp
;
1317 entry
->flags
= old_flags
;
1320 if (old_flags
& EGSY__V_DEF
)
1322 struct vms_esdf
*esdf
= (struct vms_esdf
*)vms_rec
;
1325 entry
->value
= bfd_getl64 (esdf
->value
);
1326 if (PRIV (sections
) == NULL
)
1329 psindx
= bfd_getl32 (esdf
->psindx
);
1330 /* PR 21813: Check for an out of range index. */
1331 if (psindx
< 0 || psindx
>= (int) PRIV (section_count
))
1333 _bfd_error_handler (_("Corrupt EGSD record: its psindx field is too big (%#lx)"),
1335 bfd_set_error (bfd_error_bad_value
);
1338 entry
->section
= PRIV (sections
)[psindx
];
1340 if (old_flags
& EGSY__V_NORM
)
1342 PRIV (norm_sym_count
)++;
1344 entry
->code_value
= bfd_getl64 (esdf
->code_address
);
1345 psindx
= bfd_getl32 (esdf
->ca_psindx
);
1346 /* PR 21813: Check for an out of range index. */
1347 if (psindx
< 0 || psindx
>= (int) PRIV (section_count
))
1349 _bfd_error_handler (_("Corrupt EGSD record: its psindx field is too big (%#lx)"),
1351 bfd_set_error (bfd_error_bad_value
);
1354 entry
->code_section
= PRIV (sections
)[psindx
];
1362 struct vms_symbol_entry
*entry
;
1363 struct vms_egst
*egst
= (struct vms_egst
*)vms_rec
;
1366 old_flags
= bfd_getl16 (egst
->header
.flags
);
1368 entry
= add_symbol (abfd
, &egst
->namlng
);
1373 entry
->typ
= gsd_type
;
1374 entry
->data_type
= egst
->header
.datyp
;
1375 entry
->flags
= old_flags
;
1377 entry
->symbol_vector
= bfd_getl32 (egst
->value
);
1379 if (old_flags
& EGSY__V_REL
)
1383 if (PRIV (sections
) == NULL
)
1385 psindx
= bfd_getl32 (egst
->psindx
);
1386 /* PR 21813: Check for an out of range index. */
1387 if (psindx
< 0 || psindx
>= (int) PRIV (section_count
))
1389 _bfd_error_handler (_("Corrupt EGSD record: its psindx field is too big (%#lx)"),
1391 bfd_set_error (bfd_error_bad_value
);
1394 entry
->section
= PRIV (sections
)[psindx
];
1397 entry
->section
= bfd_abs_section_ptr
;
1399 entry
->value
= bfd_getl64 (egst
->lp_2
);
1401 if (old_flags
& EGSY__V_NORM
)
1403 PRIV (norm_sym_count
)++;
1405 entry
->code_value
= bfd_getl64 (egst
->lp_1
);
1406 entry
->code_section
= bfd_abs_section_ptr
;
1413 /* Currently ignored. */
1418 _bfd_error_handler (_("Unknown EGSD subtype %d"), gsd_type
);
1419 bfd_set_error (bfd_error_bad_value
);
1423 PRIV (recrd
.rec_size
) -= gsd_size
;
1424 PRIV (recrd
.rec
) += gsd_size
;
1427 /* FIXME: Should we complain if PRIV (recrd.rec_size) is not zero ? */
1429 if (PRIV (gsd_sym_count
) > 0)
1430 abfd
->flags
|= HAS_SYMS
;
1435 /* Stack routines for vms ETIR commands. */
1437 /* Push value and section index. */
1440 _bfd_vms_push (bfd
*abfd
, bfd_vma val
, unsigned int reloc
)
1442 vms_debug2 ((4, "<push %08lx (0x%08x) at %d>\n",
1443 (unsigned long)val
, reloc
, PRIV (stackptr
)));
1445 PRIV (stack
[PRIV (stackptr
)]).value
= val
;
1446 PRIV (stack
[PRIV (stackptr
)]).reloc
= reloc
;
1448 if (PRIV (stackptr
) >= STACKSIZE
)
1450 bfd_set_error (bfd_error_bad_value
);
1451 _bfd_error_handler (_("Stack overflow (%d) in _bfd_vms_push"), PRIV (stackptr
));
1456 /* Pop value and section index. */
1459 _bfd_vms_pop (bfd
*abfd
, bfd_vma
*val
, unsigned int *rel
)
1461 if (PRIV (stackptr
) == 0)
1463 bfd_set_error (bfd_error_bad_value
);
1464 _bfd_error_handler (_("Stack underflow in _bfd_vms_pop"));
1468 *val
= PRIV (stack
[PRIV (stackptr
)]).value
;
1469 *rel
= PRIV (stack
[PRIV (stackptr
)]).reloc
;
1471 vms_debug2 ((4, "<pop %08lx (0x%08x)>\n", (unsigned long)*val
, *rel
));
1474 /* Routines to fill sections contents during tir/etir read. */
1476 /* Initialize image buffer pointer to be filled. */
1479 image_set_ptr (bfd
*abfd
, bfd_vma vma
, int sect
, struct bfd_link_info
*info
)
1483 vms_debug2 ((4, "image_set_ptr (0x%08x, sect=%d)\n", (unsigned)vma
, sect
));
1485 if (PRIV (sections
) == NULL
)
1487 if (sect
< 0 || sect
>= (int) PRIV (section_count
))
1490 sec
= PRIV (sections
)[sect
];
1494 /* Reading contents to an output bfd. */
1496 if (sec
->output_section
== NULL
)
1498 /* Section discarded. */
1499 vms_debug2 ((5, " section %s discarded\n", sec
->name
));
1501 /* This is not used. */
1502 PRIV (image_section
) = NULL
;
1503 PRIV (image_offset
) = 0;
1506 PRIV (image_offset
) = sec
->output_offset
+ vma
;
1507 PRIV (image_section
) = sec
->output_section
;
1511 PRIV (image_offset
) = vma
;
1512 PRIV (image_section
) = sec
;
1516 /* Increment image buffer pointer by offset. */
1519 image_inc_ptr (bfd
*abfd
, bfd_vma offset
)
1521 vms_debug2 ((4, "image_inc_ptr (%u)\n", (unsigned)offset
));
1523 PRIV (image_offset
) += offset
;
1526 /* Save current DST location counter under specified index. */
1529 dst_define_location (bfd
*abfd
, unsigned int loc
)
1531 vms_debug2 ((4, "dst_define_location (%d)\n", (int)loc
));
1533 /* Grow the ptr offset table if necessary. */
1534 if (loc
+ 1 > PRIV (dst_ptr_offsets_count
))
1536 PRIV (dst_ptr_offsets
) = bfd_realloc (PRIV (dst_ptr_offsets
),
1537 (loc
+ 1) * sizeof (unsigned int));
1538 PRIV (dst_ptr_offsets_count
) = loc
+ 1;
1541 PRIV (dst_ptr_offsets
)[loc
] = PRIV (image_offset
);
1544 /* Restore saved DST location counter from specified index. */
1547 dst_restore_location (bfd
*abfd
, unsigned int loc
)
1549 vms_debug2 ((4, "dst_restore_location (%d)\n", (int)loc
));
1551 PRIV (image_offset
) = PRIV (dst_ptr_offsets
)[loc
];
1554 /* Retrieve saved DST location counter from specified index. */
1557 dst_retrieve_location (bfd
*abfd
, unsigned int loc
)
1559 vms_debug2 ((4, "dst_retrieve_location (%d)\n", (int)loc
));
1561 return PRIV (dst_ptr_offsets
)[loc
];
1564 /* Write multiple bytes to section image. */
1567 image_write (bfd
*abfd
, unsigned char *ptr
, unsigned int size
)
1570 _bfd_vms_debug (8, "image_write from (%p, %d) to (%ld)\n", ptr
, size
,
1571 (long)PRIV (image_offset
));
1572 _bfd_hexdump (9, ptr
, size
, 0);
1575 if (PRIV (image_section
)->contents
!= NULL
)
1577 asection
*sec
= PRIV (image_section
);
1578 file_ptr off
= PRIV (image_offset
);
1581 if (off
> (file_ptr
)sec
->size
1582 || size
> (file_ptr
)sec
->size
1583 || off
+ size
> (file_ptr
)sec
->size
)
1585 bfd_set_error (bfd_error_bad_value
);
1589 memcpy (sec
->contents
+ off
, ptr
, size
);
1592 PRIV (image_offset
) += size
;
1596 /* Write byte to section image. */
1599 image_write_b (bfd
* abfd
, unsigned int value
)
1601 unsigned char data
[1];
1603 vms_debug2 ((6, "image_write_b (%02x)\n", (int) value
));
1607 return image_write (abfd
, data
, sizeof (data
));
1610 /* Write 2-byte word to image. */
1613 image_write_w (bfd
* abfd
, unsigned int value
)
1615 unsigned char data
[2];
1617 vms_debug2 ((6, "image_write_w (%04x)\n", (int) value
));
1619 bfd_putl16 (value
, data
);
1620 return image_write (abfd
, data
, sizeof (data
));
1623 /* Write 4-byte long to image. */
1626 image_write_l (bfd
* abfd
, unsigned long value
)
1628 unsigned char data
[4];
1630 vms_debug2 ((6, "image_write_l (%08lx)\n", value
));
1632 bfd_putl32 (value
, data
);
1633 return image_write (abfd
, data
, sizeof (data
));
1636 /* Write 8-byte quad to image. */
1639 image_write_q (bfd
* abfd
, bfd_vma value
)
1641 unsigned char data
[8];
1643 vms_debug2 ((6, "image_write_q (%08lx)\n", (unsigned long)value
));
1645 bfd_putl64 (value
, data
);
1646 return image_write (abfd
, data
, sizeof (data
));
1650 _bfd_vms_etir_name (int cmd
)
1654 case ETIR__C_STA_GBL
: return "ETIR__C_STA_GBL";
1655 case ETIR__C_STA_LW
: return "ETIR__C_STA_LW";
1656 case ETIR__C_STA_QW
: return "ETIR__C_STA_QW";
1657 case ETIR__C_STA_PQ
: return "ETIR__C_STA_PQ";
1658 case ETIR__C_STA_LI
: return "ETIR__C_STA_LI";
1659 case ETIR__C_STA_MOD
: return "ETIR__C_STA_MOD";
1660 case ETIR__C_STA_CKARG
: return "ETIR__C_STA_CKARG";
1661 case ETIR__C_STO_B
: return "ETIR__C_STO_B";
1662 case ETIR__C_STO_W
: return "ETIR__C_STO_W";
1663 case ETIR__C_STO_GBL
: return "ETIR__C_STO_GBL";
1664 case ETIR__C_STO_CA
: return "ETIR__C_STO_CA";
1665 case ETIR__C_STO_RB
: return "ETIR__C_STO_RB";
1666 case ETIR__C_STO_AB
: return "ETIR__C_STO_AB";
1667 case ETIR__C_STO_OFF
: return "ETIR__C_STO_OFF";
1668 case ETIR__C_STO_IMM
: return "ETIR__C_STO_IMM";
1669 case ETIR__C_STO_IMMR
: return "ETIR__C_STO_IMMR";
1670 case ETIR__C_STO_LW
: return "ETIR__C_STO_LW";
1671 case ETIR__C_STO_QW
: return "ETIR__C_STO_QW";
1672 case ETIR__C_STO_GBL_LW
: return "ETIR__C_STO_GBL_LW";
1673 case ETIR__C_STO_LP_PSB
: return "ETIR__C_STO_LP_PSB";
1674 case ETIR__C_STO_HINT_GBL
: return "ETIR__C_STO_HINT_GBL";
1675 case ETIR__C_STO_HINT_PS
: return "ETIR__C_STO_HINT_PS";
1676 case ETIR__C_OPR_ADD
: return "ETIR__C_OPR_ADD";
1677 case ETIR__C_OPR_SUB
: return "ETIR__C_OPR_SUB";
1678 case ETIR__C_OPR_INSV
: return "ETIR__C_OPR_INSV";
1679 case ETIR__C_OPR_USH
: return "ETIR__C_OPR_USH";
1680 case ETIR__C_OPR_ROT
: return "ETIR__C_OPR_ROT";
1681 case ETIR__C_OPR_REDEF
: return "ETIR__C_OPR_REDEF";
1682 case ETIR__C_OPR_DFLIT
: return "ETIR__C_OPR_DFLIT";
1683 case ETIR__C_STC_LP
: return "ETIR__C_STC_LP";
1684 case ETIR__C_STC_GBL
: return "ETIR__C_STC_GBL";
1685 case ETIR__C_STC_GCA
: return "ETIR__C_STC_GCA";
1686 case ETIR__C_STC_PS
: return "ETIR__C_STC_PS";
1687 case ETIR__C_STC_NBH_PS
: return "ETIR__C_STC_NBH_PS";
1688 case ETIR__C_STC_NOP_GBL
: return "ETIR__C_STC_NOP_GBL";
1689 case ETIR__C_STC_NOP_PS
: return "ETIR__C_STC_NOP_PS";
1690 case ETIR__C_STC_BSR_GBL
: return "ETIR__C_STC_BSR_GBL";
1691 case ETIR__C_STC_BSR_PS
: return "ETIR__C_STC_BSR_PS";
1692 case ETIR__C_STC_LDA_GBL
: return "ETIR__C_STC_LDA_GBL";
1693 case ETIR__C_STC_LDA_PS
: return "ETIR__C_STC_LDA_PS";
1694 case ETIR__C_STC_BOH_GBL
: return "ETIR__C_STC_BOH_GBL";
1695 case ETIR__C_STC_BOH_PS
: return "ETIR__C_STC_BOH_PS";
1696 case ETIR__C_STC_NBH_GBL
: return "ETIR__C_STC_NBH_GBL";
1697 case ETIR__C_STC_LP_PSB
: return "ETIR__C_STC_LP_PSB";
1698 case ETIR__C_CTL_SETRB
: return "ETIR__C_CTL_SETRB";
1699 case ETIR__C_CTL_AUGRB
: return "ETIR__C_CTL_AUGRB";
1700 case ETIR__C_CTL_DFLOC
: return "ETIR__C_CTL_DFLOC";
1701 case ETIR__C_CTL_STLOC
: return "ETIR__C_CTL_STLOC";
1702 case ETIR__C_CTL_STKDL
: return "ETIR__C_CTL_STKDL";
1705 /* These names have not yet been added to this switch statement. */
1706 _bfd_error_handler (_("unknown ETIR command %d"), cmd
);
1711 #define HIGHBIT(op) ((op & 0x80000000L) == 0x80000000L)
1714 _bfd_vms_get_value (bfd
*abfd
,
1715 const unsigned char *ascic
,
1716 const unsigned char *max_ascic
,
1717 struct bfd_link_info
*info
,
1719 struct alpha_vms_link_hash_entry
**hp
)
1724 struct alpha_vms_link_hash_entry
*h
;
1726 /* Not linking. Do not try to resolve the symbol. */
1735 if (ascic
+ len
>= max_ascic
)
1737 _bfd_error_handler (_("Corrupt vms value"));
1743 for (i
= 0; i
< len
; i
++)
1744 name
[i
] = ascic
[i
+ 1];
1747 h
= (struct alpha_vms_link_hash_entry
*)
1748 bfd_link_hash_lookup (info
->hash
, name
, FALSE
, FALSE
, TRUE
);
1753 && (h
->root
.type
== bfd_link_hash_defined
1754 || h
->root
.type
== bfd_link_hash_defweak
))
1755 *vma
= h
->root
.u
.def
.value
1756 + h
->root
.u
.def
.section
->output_offset
1757 + h
->root
.u
.def
.section
->output_section
->vma
;
1758 else if (h
&& h
->root
.type
== bfd_link_hash_undefweak
)
1762 (*info
->callbacks
->undefined_symbol
)
1763 (info
, name
, abfd
, PRIV (image_section
), PRIV (image_offset
), TRUE
);
1770 #define RELC_SHR_BASE 0x10000
1771 #define RELC_SEC_BASE 0x20000
1772 #define RELC_MASK 0x0ffff
1775 alpha_vms_sym_to_ctxt (struct alpha_vms_link_hash_entry
*h
)
1777 /* Handle undefined symbols. */
1778 if (h
== NULL
|| h
->sym
== NULL
)
1781 if (h
->sym
->typ
== EGSD__C_SYMG
)
1783 if (h
->sym
->flags
& EGSY__V_REL
)
1784 return RELC_SHR_BASE
+ PRIV2 (h
->sym
->owner
, shr_index
);
1787 /* Can this happen (non-relocatable symg) ? I'd like to see
1792 if (h
->sym
->typ
== EGSD__C_SYM
)
1794 if (h
->sym
->flags
& EGSY__V_REL
)
1803 alpha_vms_get_sym_value (asection
*sect
, bfd_vma addr
)
1805 return sect
->output_section
->vma
+ sect
->output_offset
+ addr
;
1809 alpha_vms_fix_sec_rel (bfd
*abfd
, struct bfd_link_info
*info
,
1810 unsigned int rel
, bfd_vma vma
)
1814 if (PRIV (sections
) == NULL
)
1817 sec
= PRIV (sections
)[rel
& RELC_MASK
];
1821 if (sec
->output_section
== NULL
)
1823 return vma
+ sec
->output_section
->vma
+ sec
->output_offset
;
1826 return vma
+ sec
->vma
;
1829 /* Read an ETIR record from ABFD. If INFO is not null, put the content into
1830 the output section (used during linking).
1831 Return FALSE in case of error. */
1834 _bfd_vms_slurp_etir (bfd
*abfd
, struct bfd_link_info
*info
)
1837 unsigned int length
;
1838 unsigned char *maxptr
;
1843 struct alpha_vms_link_hash_entry
*h
;
1845 PRIV (recrd
.rec
) += ETIR__C_HEADER_SIZE
;
1846 PRIV (recrd
.rec_size
) -= ETIR__C_HEADER_SIZE
;
1848 ptr
= PRIV (recrd
.rec
);
1849 length
= PRIV (recrd
.rec_size
);
1850 maxptr
= ptr
+ length
;
1852 vms_debug2 ((2, "ETIR: %d bytes\n", length
));
1854 while (ptr
< maxptr
)
1856 int cmd
= bfd_getl16 (ptr
);
1857 int cmd_length
= bfd_getl16 (ptr
+ 2);
1861 /* PR 21589 and 21579: Check for a corrupt ETIR record. */
1862 if (cmd_length
< 4 || (ptr
+ cmd_length
> maxptr
+ 4))
1865 _bfd_error_handler (_("Corrupt ETIR record encountered"));
1866 bfd_set_error (bfd_error_bad_value
);
1871 _bfd_vms_debug (4, "etir: %s(%d)\n",
1872 _bfd_vms_etir_name (cmd
), cmd
);
1873 _bfd_hexdump (8, ptr
, cmd_length
- 4, 0);
1881 stack 32 bit value of symbol (high bits set to 0). */
1882 case ETIR__C_STA_GBL
:
1883 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
1884 _bfd_vms_push (abfd
, op1
, alpha_vms_sym_to_ctxt (h
));
1890 stack 32 bit value, sign extend to 64 bit. */
1891 case ETIR__C_STA_LW
:
1892 if (ptr
+ 4 >= maxptr
)
1894 _bfd_vms_push (abfd
, bfd_getl32 (ptr
), RELC_NONE
);
1900 stack 64 bit value of symbol. */
1901 case ETIR__C_STA_QW
:
1902 if (ptr
+ 8 >= maxptr
)
1904 _bfd_vms_push (abfd
, bfd_getl64 (ptr
), RELC_NONE
);
1907 /* Stack psect base plus quadword offset
1908 arg: lw section index
1909 qw signed quadword offset (low 32 bits)
1911 Stack qw argument and section index
1912 (see ETIR__C_STO_OFF, ETIR__C_CTL_SETRB). */
1913 case ETIR__C_STA_PQ
:
1917 if (ptr
+ 12 >= maxptr
)
1919 psect
= bfd_getl32 (ptr
);
1920 if ((unsigned int) psect
>= PRIV (section_count
))
1922 _bfd_error_handler (_("bad section index in %s"),
1923 _bfd_vms_etir_name (cmd
));
1924 bfd_set_error (bfd_error_bad_value
);
1927 op1
= bfd_getl64 (ptr
+ 4);
1928 _bfd_vms_push (abfd
, op1
, psect
| RELC_SEC_BASE
);
1932 case ETIR__C_STA_LI
:
1933 case ETIR__C_STA_MOD
:
1934 case ETIR__C_STA_CKARG
:
1935 _bfd_error_handler (_("unsupported STA cmd %s"),
1936 _bfd_vms_etir_name (cmd
));
1940 /* Store byte: pop stack, write byte
1943 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1944 if (rel1
!= RELC_NONE
)
1946 image_write_b (abfd
, (unsigned int) op1
& 0xff);
1949 /* Store word: pop stack, write word
1952 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1953 if (rel1
!= RELC_NONE
)
1955 image_write_w (abfd
, (unsigned int) op1
& 0xffff);
1958 /* Store longword: pop stack, write longword
1960 case ETIR__C_STO_LW
:
1961 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1962 if (rel1
& RELC_SEC_BASE
)
1964 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
1967 else if (rel1
& RELC_SHR_BASE
)
1969 alpha_vms_add_fixup_lr (info
, rel1
& RELC_MASK
, op1
);
1972 if (rel1
!= RELC_NONE
)
1974 if (rel1
!= RELC_REL
)
1976 alpha_vms_add_lw_reloc (info
);
1978 image_write_l (abfd
, op1
);
1981 /* Store quadword: pop stack, write quadword
1983 case ETIR__C_STO_QW
:
1984 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1985 if (rel1
& RELC_SEC_BASE
)
1987 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
1990 else if (rel1
& RELC_SHR_BASE
)
1992 if (rel1
!= RELC_NONE
)
1994 if (rel1
!= RELC_REL
)
1996 alpha_vms_add_qw_reloc (info
);
1998 image_write_q (abfd
, op1
);
2001 /* Store immediate repeated: pop stack for repeat count
2004 case ETIR__C_STO_IMMR
:
2008 if (ptr
+ 4 >= maxptr
)
2010 size
= bfd_getl32 (ptr
);
2011 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2012 if (rel1
!= RELC_NONE
)
2015 image_write (abfd
, ptr
+ 4, size
);
2019 /* Store global: write symbol value
2020 arg: cs global symbol name. */
2021 case ETIR__C_STO_GBL
:
2022 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
2025 if (h
->sym
->typ
== EGSD__C_SYMG
)
2027 alpha_vms_add_fixup_qr
2028 (info
, abfd
, h
->sym
->owner
, h
->sym
->symbol_vector
);
2033 op1
= alpha_vms_get_sym_value (h
->sym
->section
,
2035 alpha_vms_add_qw_reloc (info
);
2038 image_write_q (abfd
, op1
);
2041 /* Store code address: write address of entry point
2042 arg: cs global symbol name (procedure). */
2043 case ETIR__C_STO_CA
:
2044 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
2047 if (h
->sym
->flags
& EGSY__V_NORM
)
2049 /* That's really a procedure. */
2050 if (h
->sym
->typ
== EGSD__C_SYMG
)
2052 alpha_vms_add_fixup_ca (info
, abfd
, h
->sym
->owner
);
2053 op1
= h
->sym
->symbol_vector
;
2057 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
2058 h
->sym
->code_value
);
2059 alpha_vms_add_qw_reloc (info
);
2064 /* Symbol is not a procedure. */
2068 image_write_q (abfd
, op1
);
2071 /* Store offset to psect: pop stack, add low 32 bits to base of psect
2073 case ETIR__C_STO_OFF
:
2074 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2076 if (!(rel1
& RELC_SEC_BASE
))
2079 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2081 image_write_q (abfd
, op1
);
2085 arg: lw count of bytes
2087 case ETIR__C_STO_IMM
:
2091 if (ptr
+ 4 >= maxptr
)
2093 size
= bfd_getl32 (ptr
);
2094 image_write (abfd
, ptr
+ 4, size
);
2098 /* This code is 'reserved to digital' according to the openVMS
2099 linker manual, however it is generated by the DEC C compiler
2100 and defined in the include file.
2101 FIXME, since the following is just a guess
2102 store global longword: store 32bit value of symbol
2103 arg: cs symbol name. */
2104 case ETIR__C_STO_GBL_LW
:
2105 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
2109 image_write_l (abfd
, op1
);
2112 case ETIR__C_STO_RB
:
2113 case ETIR__C_STO_AB
:
2114 case ETIR__C_STO_LP_PSB
:
2115 _bfd_error_handler (_("%s: not supported"),
2116 _bfd_vms_etir_name (cmd
));
2119 case ETIR__C_STO_HINT_GBL
:
2120 case ETIR__C_STO_HINT_PS
:
2121 _bfd_error_handler (_("%s: not implemented"),
2122 _bfd_vms_etir_name (cmd
));
2126 /* 200 Store-conditional Linkage Pair
2128 case ETIR__C_STC_LP
:
2130 /* 202 Store-conditional Address at global address
2134 case ETIR__C_STC_GBL
:
2136 /* 203 Store-conditional Code Address at global address
2138 cs procedure name. */
2139 case ETIR__C_STC_GCA
:
2141 /* 204 Store-conditional Address at psect + offset
2145 case ETIR__C_STC_PS
:
2146 _bfd_error_handler (_("%s: not supported"),
2147 _bfd_vms_etir_name (cmd
));
2151 /* 201 Store-conditional Linkage Pair with Procedure Signature
2157 case ETIR__C_STC_LP_PSB
:
2158 _bfd_vms_get_value (abfd
, ptr
+ 4, maxptr
, info
, &op1
, &h
);
2161 if (h
->sym
->typ
== EGSD__C_SYMG
)
2163 alpha_vms_add_fixup_lp (info
, abfd
, h
->sym
->owner
);
2164 op1
= h
->sym
->symbol_vector
;
2169 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
2170 h
->sym
->code_value
);
2171 op2
= alpha_vms_get_sym_value (h
->sym
->section
,
2177 /* Undefined symbol. */
2181 image_write_q (abfd
, op1
);
2182 image_write_q (abfd
, op2
);
2185 /* 205 Store-conditional NOP at address of global
2187 case ETIR__C_STC_NOP_GBL
:
2190 /* 207 Store-conditional BSR at global address
2193 case ETIR__C_STC_BSR_GBL
:
2196 /* 209 Store-conditional LDA at global address
2199 case ETIR__C_STC_LDA_GBL
:
2202 /* 211 Store-conditional BSR or Hint at global address
2205 case ETIR__C_STC_BOH_GBL
:
2206 /* Currentl ignored. */
2209 /* 213 Store-conditional NOP,BSR or HINT at global address
2212 case ETIR__C_STC_NBH_GBL
:
2214 /* 206 Store-conditional NOP at pect + offset
2217 case ETIR__C_STC_NOP_PS
:
2219 /* 208 Store-conditional BSR at pect + offset
2222 case ETIR__C_STC_BSR_PS
:
2224 /* 210 Store-conditional LDA at psect + offset
2227 case ETIR__C_STC_LDA_PS
:
2229 /* 212 Store-conditional BSR or Hint at pect + offset
2232 case ETIR__C_STC_BOH_PS
:
2234 /* 214 Store-conditional NOP, BSR or HINT at psect + offset
2236 case ETIR__C_STC_NBH_PS
:
2237 _bfd_error_handler (_("%s: not supported"),
2238 _bfd_vms_etir_name (cmd
));
2242 /* Det relocation base: pop stack, set image location counter
2244 case ETIR__C_CTL_SETRB
:
2245 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2246 if (!(rel1
& RELC_SEC_BASE
))
2248 image_set_ptr (abfd
, op1
, rel1
& RELC_MASK
, info
);
2251 /* Augment relocation base: increment image location counter by offset
2252 arg: lw offset value. */
2253 case ETIR__C_CTL_AUGRB
:
2254 if (ptr
+ 4 >= maxptr
)
2256 op1
= bfd_getl32 (ptr
);
2257 image_inc_ptr (abfd
, op1
);
2260 /* Define location: pop index, save location counter under index
2262 case ETIR__C_CTL_DFLOC
:
2263 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2264 if (rel1
!= RELC_NONE
)
2266 dst_define_location (abfd
, op1
);
2269 /* Set location: pop index, restore location counter from index
2271 case ETIR__C_CTL_STLOC
:
2272 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2273 if (rel1
!= RELC_NONE
)
2275 dst_restore_location (abfd
, op1
);
2278 /* Stack defined location: pop index, push location counter from index
2280 case ETIR__C_CTL_STKDL
:
2281 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2282 if (rel1
!= RELC_NONE
)
2284 _bfd_vms_push (abfd
, dst_retrieve_location (abfd
, op1
), RELC_NONE
);
2287 case ETIR__C_OPR_NOP
: /* No-op. */
2290 case ETIR__C_OPR_ADD
: /* Add. */
2291 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2292 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2293 if (rel1
== RELC_NONE
&& rel2
!= RELC_NONE
)
2295 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2297 _bfd_vms_push (abfd
, op1
+ op2
, rel1
);
2300 case ETIR__C_OPR_SUB
: /* Subtract. */
2301 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2302 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2303 if (rel1
== RELC_NONE
&& rel2
!= RELC_NONE
)
2305 else if ((rel1
& RELC_SEC_BASE
) && (rel2
& RELC_SEC_BASE
))
2307 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2308 op2
= alpha_vms_fix_sec_rel (abfd
, info
, rel2
, op2
);
2311 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2313 _bfd_vms_push (abfd
, op2
- op1
, rel1
);
2316 case ETIR__C_OPR_MUL
: /* Multiply. */
2317 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2318 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2319 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2321 _bfd_vms_push (abfd
, op1
* op2
, RELC_NONE
);
2324 case ETIR__C_OPR_DIV
: /* Divide. */
2325 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2326 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2327 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2330 _bfd_vms_push (abfd
, 0, RELC_NONE
);
2332 _bfd_vms_push (abfd
, op2
/ op1
, RELC_NONE
);
2335 case ETIR__C_OPR_AND
: /* Logical AND. */
2336 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2337 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2338 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2340 _bfd_vms_push (abfd
, op1
& op2
, RELC_NONE
);
2343 case ETIR__C_OPR_IOR
: /* Logical inclusive OR. */
2344 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2345 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2346 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2348 _bfd_vms_push (abfd
, op1
| op2
, RELC_NONE
);
2351 case ETIR__C_OPR_EOR
: /* Logical exclusive OR. */
2352 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2353 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2354 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2356 _bfd_vms_push (abfd
, op1
^ op2
, RELC_NONE
);
2359 case ETIR__C_OPR_NEG
: /* Negate. */
2360 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2361 if (rel1
!= RELC_NONE
)
2363 _bfd_vms_push (abfd
, -op1
, RELC_NONE
);
2366 case ETIR__C_OPR_COM
: /* Complement. */
2367 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2368 if (rel1
!= RELC_NONE
)
2370 _bfd_vms_push (abfd
, ~op1
, RELC_NONE
);
2373 case ETIR__C_OPR_ASH
: /* Arithmetic shift. */
2374 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2375 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2376 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2379 _bfd_error_handler (_("invalid use of %s with contexts"),
2380 _bfd_vms_etir_name (cmd
));
2383 if ((int)op2
< 0) /* Shift right. */
2385 else /* Shift left. */
2387 _bfd_vms_push (abfd
, op1
, RELC_NONE
); /* FIXME: sym. */
2390 case ETIR__C_OPR_INSV
: /* Insert field. */
2391 case ETIR__C_OPR_USH
: /* Unsigned shift. */
2392 case ETIR__C_OPR_ROT
: /* Rotate. */
2393 case ETIR__C_OPR_REDEF
: /* Redefine symbol to current location. */
2394 case ETIR__C_OPR_DFLIT
: /* Define a literal. */
2395 _bfd_error_handler (_("%s: not supported"),
2396 _bfd_vms_etir_name (cmd
));
2400 case ETIR__C_OPR_SEL
: /* Select. */
2401 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2403 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2406 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2407 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2408 _bfd_vms_push (abfd
, op1
, rel1
);
2413 _bfd_error_handler (_("reserved cmd %d"), cmd
);
2418 ptr
+= cmd_length
- 4;
2424 /* Process EDBG/ETBT record.
2425 Return TRUE on success, FALSE on error */
2428 vms_slurp_debug (bfd
*abfd
)
2430 asection
*section
= PRIV (dst_section
);
2432 if (section
== NULL
)
2434 /* We have no way to find out beforehand how much debug info there
2435 is in an object file, so pick an initial amount and grow it as
2437 flagword flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
| SEC_RELOC
2440 section
= bfd_make_section (abfd
, "$DST$");
2443 if (!bfd_set_section_flags (abfd
, section
, flags
))
2445 PRIV (dst_section
) = section
;
2448 PRIV (image_section
) = section
;
2449 PRIV (image_offset
) = section
->size
;
2451 if (!_bfd_vms_slurp_etir (abfd
, NULL
))
2454 section
->size
= PRIV (image_offset
);
2458 /* Process EDBG record.
2459 Return TRUE on success, FALSE on error. */
2462 _bfd_vms_slurp_edbg (bfd
*abfd
)
2464 vms_debug2 ((2, "EDBG\n"));
2466 abfd
->flags
|= HAS_DEBUG
| HAS_LINENO
;
2468 return vms_slurp_debug (abfd
);
2471 /* Process ETBT record.
2472 Return TRUE on success, FALSE on error. */
2475 _bfd_vms_slurp_etbt (bfd
*abfd
)
2477 vms_debug2 ((2, "ETBT\n"));
2479 abfd
->flags
|= HAS_LINENO
;
2481 return vms_slurp_debug (abfd
);
2484 /* Process EEOM record.
2485 Return TRUE on success, FALSE on error. */
2488 _bfd_vms_slurp_eeom (bfd
*abfd
)
2490 struct vms_eeom
*eeom
= (struct vms_eeom
*) PRIV (recrd
.rec
);
2492 vms_debug2 ((2, "EEOM\n"));
2494 /* PR 21813: Check for an undersized record. */
2495 if (PRIV (recrd
.buf_size
) < sizeof (* eeom
))
2497 _bfd_error_handler (_("Corrupt EEOM record - size is too small"));
2498 bfd_set_error (bfd_error_bad_value
);
2502 PRIV (eom_data
).eom_l_total_lps
= bfd_getl32 (eeom
->total_lps
);
2503 PRIV (eom_data
).eom_w_comcod
= bfd_getl16 (eeom
->comcod
);
2504 if (PRIV (eom_data
).eom_w_comcod
> 1)
2506 _bfd_error_handler (_("Object module NOT error-free !\n"));
2507 bfd_set_error (bfd_error_bad_value
);
2511 PRIV (eom_data
).eom_has_transfer
= FALSE
;
2512 if (PRIV (recrd
.rec_size
) > 10)
2514 PRIV (eom_data
).eom_has_transfer
= TRUE
;
2515 PRIV (eom_data
).eom_b_tfrflg
= eeom
->tfrflg
;
2516 PRIV (eom_data
).eom_l_psindx
= bfd_getl32 (eeom
->psindx
);
2517 PRIV (eom_data
).eom_l_tfradr
= bfd_getl32 (eeom
->tfradr
);
2519 abfd
->start_address
= PRIV (eom_data
).eom_l_tfradr
;
2524 /* Slurp an ordered set of VMS object records. Return FALSE on error. */
2527 _bfd_vms_slurp_object_records (bfd
* abfd
)
2534 vms_debug2 ((7, "reading at %08lx\n", (unsigned long)bfd_tell (abfd
)));
2536 type
= _bfd_vms_get_object_record (abfd
);
2539 vms_debug2 ((2, "next_record failed\n"));
2546 err
= _bfd_vms_slurp_ehdr (abfd
);
2549 err
= _bfd_vms_slurp_eeom (abfd
);
2552 err
= _bfd_vms_slurp_egsd (abfd
);
2555 err
= TRUE
; /* _bfd_vms_slurp_etir (abfd); */
2558 err
= _bfd_vms_slurp_edbg (abfd
);
2561 err
= _bfd_vms_slurp_etbt (abfd
);
2568 vms_debug2 ((2, "slurp type %d failed\n", type
));
2572 while (type
!= EOBJ__C_EEOM
);
2577 /* Initialize private data */
2579 vms_initialize (bfd
* abfd
)
2583 amt
= sizeof (struct vms_private_data_struct
);
2584 abfd
->tdata
.any
= bfd_zalloc (abfd
, amt
);
2585 if (abfd
->tdata
.any
== NULL
)
2588 PRIV (recrd
.file_format
) = FF_UNKNOWN
;
2590 amt
= sizeof (struct stack_struct
) * STACKSIZE
;
2591 PRIV (stack
) = bfd_alloc (abfd
, amt
);
2592 if (PRIV (stack
) == NULL
)
2598 bfd_release (abfd
, abfd
->tdata
.any
);
2599 abfd
->tdata
.any
= NULL
;
2603 /* Check the format for a file being read.
2604 Return a (bfd_target *) if it's an object file or zero if not. */
2606 static const struct bfd_target
*
2607 alpha_vms_object_p (bfd
*abfd
)
2609 void *tdata_save
= abfd
->tdata
.any
;
2610 unsigned int test_len
;
2613 vms_debug2 ((1, "vms_object_p(%p)\n", abfd
));
2615 /* Allocate alpha-vms specific data. */
2616 if (!vms_initialize (abfd
))
2619 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
))
2620 goto err_wrong_format
;
2622 /* The first challenge with VMS is to discover the kind of the file.
2624 Image files (executable or shared images) are stored as a raw
2625 stream of bytes (like on UNIX), but there is no magic number.
2627 Object files are written with RMS (record management service), ie
2628 each records are preceeded by its length (on a word - 2 bytes), and
2629 padded for word-alignment. That would be simple but when files
2630 are transfered to a UNIX filesystem (using ftp), records are lost.
2631 Only the raw content of the records are transfered. Fortunately,
2632 the Alpha Object file format also store the length of the record
2633 in the records. Is that clear ? */
2635 /* Minimum is 6 bytes for objects (2 bytes size, 2 bytes record id,
2636 2 bytes size repeated) and 12 bytes for images (4 bytes major id,
2637 4 bytes minor id, 4 bytes length). */
2640 /* Size the main buffer. */
2641 buf
= (unsigned char *) bfd_malloc (test_len
);
2644 PRIV (recrd
.buf
) = buf
;
2645 PRIV (recrd
.buf_size
) = test_len
;
2647 /* Initialize the record pointer. */
2648 PRIV (recrd
.rec
) = buf
;
2650 if (bfd_bread (buf
, test_len
, abfd
) != test_len
)
2651 goto err_wrong_format
;
2653 /* Is it an image? */
2654 if ((bfd_getl32 (buf
) == EIHD__K_MAJORID
)
2655 && (bfd_getl32 (buf
+ 4) == EIHD__K_MINORID
))
2657 unsigned int to_read
;
2658 unsigned int read_so_far
;
2659 unsigned int remaining
;
2660 unsigned int eisd_offset
, eihs_offset
;
2662 /* Extract the header size. */
2663 PRIV (recrd
.rec_size
) = bfd_getl32 (buf
+ EIHD__L_SIZE
);
2665 /* The header size is 0 for DSF files. */
2666 if (PRIV (recrd
.rec_size
) == 0)
2667 PRIV (recrd
.rec_size
) = sizeof (struct vms_eihd
);
2669 if (PRIV (recrd
.rec_size
) > PRIV (recrd
.buf_size
))
2671 buf
= bfd_realloc_or_free (buf
, PRIV (recrd
.rec_size
));
2675 PRIV (recrd
.buf
) = NULL
;
2678 PRIV (recrd
.buf
) = buf
;
2679 PRIV (recrd
.buf_size
) = PRIV (recrd
.rec_size
);
2682 /* Read the remaining record. */
2683 remaining
= PRIV (recrd
.rec_size
) - test_len
;
2684 to_read
= MIN (VMS_BLOCK_SIZE
- test_len
, remaining
);
2685 read_so_far
= test_len
;
2687 while (remaining
> 0)
2689 if (bfd_bread (buf
+ read_so_far
, to_read
, abfd
) != to_read
)
2690 goto err_wrong_format
;
2692 read_so_far
+= to_read
;
2693 remaining
-= to_read
;
2695 to_read
= MIN (VMS_BLOCK_SIZE
, remaining
);
2698 /* Reset the record pointer. */
2699 PRIV (recrd
.rec
) = buf
;
2701 /* PR 17512: file: 7d7c57c2. */
2702 if (PRIV (recrd
.rec_size
) < sizeof (struct vms_eihd
))
2704 vms_debug2 ((2, "file type is image\n"));
2706 if (!_bfd_vms_slurp_eihd (abfd
, &eisd_offset
, &eihs_offset
))
2707 goto err_wrong_format
;
2709 if (!_bfd_vms_slurp_eisd (abfd
, eisd_offset
))
2710 goto err_wrong_format
;
2712 /* EIHS is optional. */
2713 if (eihs_offset
!= 0 && !_bfd_vms_slurp_eihs (abfd
, eihs_offset
))
2714 goto err_wrong_format
;
2720 /* Assume it's a module and adjust record pointer if necessary. */
2721 maybe_adjust_record_pointer_for_object (abfd
);
2723 /* But is it really a module? */
2724 if (bfd_getl16 (PRIV (recrd
.rec
)) <= EOBJ__C_MAXRECTYP
2725 && bfd_getl16 (PRIV (recrd
.rec
) + 2) <= EOBJ__C_MAXRECSIZ
)
2727 if (vms_get_remaining_object_record (abfd
, test_len
) <= 0)
2728 goto err_wrong_format
;
2730 vms_debug2 ((2, "file type is module\n"));
2732 type
= bfd_getl16 (PRIV (recrd
.rec
));
2733 if (type
!= EOBJ__C_EMH
|| !_bfd_vms_slurp_ehdr (abfd
))
2734 goto err_wrong_format
;
2736 if (!_bfd_vms_slurp_object_records (abfd
))
2737 goto err_wrong_format
;
2740 goto err_wrong_format
;
2743 /* Set arch_info to alpha. */
2745 if (! bfd_default_set_arch_mach (abfd
, bfd_arch_alpha
, 0))
2746 goto err_wrong_format
;
2751 bfd_set_error (bfd_error_wrong_format
);
2754 if (PRIV (recrd
.buf
))
2755 free (PRIV (recrd
.buf
));
2756 if (abfd
->tdata
.any
!= tdata_save
&& abfd
->tdata
.any
!= NULL
)
2757 bfd_release (abfd
, abfd
->tdata
.any
);
2758 abfd
->tdata
.any
= tdata_save
;
2764 /* Write an EMH/MHD record. */
2767 _bfd_vms_write_emh (bfd
*abfd
)
2769 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2771 _bfd_vms_output_alignment (recwr
, 2);
2774 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
2775 _bfd_vms_output_short (recwr
, EMH__C_MHD
);
2776 _bfd_vms_output_short (recwr
, EOBJ__C_STRLVL
);
2777 _bfd_vms_output_long (recwr
, 0);
2778 _bfd_vms_output_long (recwr
, 0);
2779 _bfd_vms_output_long (recwr
, MAX_OUTREC_SIZE
);
2781 /* Create module name from filename. */
2782 if (bfd_get_filename (abfd
) != 0)
2784 char *module
= vms_get_module_name (bfd_get_filename (abfd
), TRUE
);
2785 _bfd_vms_output_counted (recwr
, module
);
2789 _bfd_vms_output_counted (recwr
, "NONAME");
2791 _bfd_vms_output_counted (recwr
, BFD_VERSION_STRING
);
2792 _bfd_vms_output_dump (recwr
, get_vms_time_string (), EMH_DATE_LENGTH
);
2793 _bfd_vms_output_fill (recwr
, 0, EMH_DATE_LENGTH
);
2794 _bfd_vms_output_end (abfd
, recwr
);
2797 /* Write an EMH/LMN record. */
2800 _bfd_vms_write_lmn (bfd
*abfd
, const char *name
)
2803 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2804 unsigned int ver
= BFD_VERSION
/ 10000;
2807 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
2808 _bfd_vms_output_short (recwr
, EMH__C_LNM
);
2809 snprintf (version
, sizeof (version
), "%s %d.%d.%d", name
,
2810 ver
/ 10000, (ver
/ 100) % 100, ver
% 100);
2811 _bfd_vms_output_dump (recwr
, (unsigned char *)version
, strlen (version
));
2812 _bfd_vms_output_end (abfd
, recwr
);
2816 /* Write eom record for bfd abfd. Return FALSE on error. */
2819 _bfd_vms_write_eeom (bfd
*abfd
)
2821 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2823 vms_debug2 ((2, "vms_write_eeom\n"));
2825 _bfd_vms_output_alignment (recwr
, 2);
2827 _bfd_vms_output_begin (recwr
, EOBJ__C_EEOM
);
2828 _bfd_vms_output_long (recwr
, PRIV (vms_linkage_index
+ 1) >> 1);
2829 _bfd_vms_output_byte (recwr
, 0); /* Completion code. */
2830 _bfd_vms_output_byte (recwr
, 0); /* Fill byte. */
2832 if ((abfd
->flags
& EXEC_P
) == 0
2833 && bfd_get_start_address (abfd
) != (bfd_vma
)-1)
2837 section
= bfd_get_section_by_name (abfd
, ".link");
2840 bfd_set_error (bfd_error_nonrepresentable_section
);
2843 _bfd_vms_output_short (recwr
, 0);
2844 _bfd_vms_output_long (recwr
, (unsigned long) section
->target_index
);
2845 _bfd_vms_output_long (recwr
,
2846 (unsigned long) bfd_get_start_address (abfd
));
2847 _bfd_vms_output_long (recwr
, 0);
2850 _bfd_vms_output_end (abfd
, recwr
);
2855 vector_grow1 (struct vector_type
*vec
, size_t elsz
)
2857 if (vec
->nbr_el
+ 1 < vec
->max_el
)
2860 if (vec
->max_el
== 0)
2863 vec
->els
= bfd_malloc2 (vec
->max_el
, elsz
);
2868 vec
->els
= bfd_realloc2 (vec
->els
, vec
->max_el
, elsz
);
2872 /* Bump ABFD file position to next block. */
2875 alpha_vms_file_position_block (bfd
*abfd
)
2878 PRIV (file_pos
) += VMS_BLOCK_SIZE
- 1;
2879 PRIV (file_pos
) -= (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
2882 /* Convert from internal structure SRC to external structure DST. */
2885 alpha_vms_swap_eisd_out (struct vms_internal_eisd_map
*src
,
2886 struct vms_eisd
*dst
)
2888 bfd_putl32 (src
->u
.eisd
.majorid
, dst
->majorid
);
2889 bfd_putl32 (src
->u
.eisd
.minorid
, dst
->minorid
);
2890 bfd_putl32 (src
->u
.eisd
.eisdsize
, dst
->eisdsize
);
2891 if (src
->u
.eisd
.eisdsize
<= EISD__K_LENEND
)
2893 bfd_putl32 (src
->u
.eisd
.secsize
, dst
->secsize
);
2894 bfd_putl64 (src
->u
.eisd
.virt_addr
, dst
->virt_addr
);
2895 bfd_putl32 (src
->u
.eisd
.flags
, dst
->flags
);
2896 bfd_putl32 (src
->u
.eisd
.vbn
, dst
->vbn
);
2897 dst
->pfc
= src
->u
.eisd
.pfc
;
2898 dst
->matchctl
= src
->u
.eisd
.matchctl
;
2899 dst
->type
= src
->u
.eisd
.type
;
2901 if (src
->u
.eisd
.flags
& EISD__M_GBL
)
2903 bfd_putl32 (src
->u
.gbl_eisd
.ident
, dst
->ident
);
2904 memcpy (dst
->gblnam
, src
->u
.gbl_eisd
.gblnam
,
2905 src
->u
.gbl_eisd
.gblnam
[0] + 1);
2909 /* Append EISD to the list of extra eisd for ABFD. */
2912 alpha_vms_append_extra_eisd (bfd
*abfd
, struct vms_internal_eisd_map
*eisd
)
2915 if (PRIV (gbl_eisd_head
) == NULL
)
2916 PRIV (gbl_eisd_head
) = eisd
;
2918 PRIV (gbl_eisd_tail
)->next
= eisd
;
2919 PRIV (gbl_eisd_tail
) = eisd
;
2922 /* Create an EISD for shared image SHRIMG.
2923 Return FALSE in case of error. */
2926 alpha_vms_create_eisd_for_shared (bfd
*abfd
, bfd
*shrimg
)
2928 struct vms_internal_eisd_map
*eisd
;
2931 namlen
= strlen (PRIV2 (shrimg
, hdr_data
.hdr_t_name
));
2932 if (namlen
+ 5 > EISD__K_GBLNAMLEN
)
2938 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
2942 /* Fill the fields. */
2943 eisd
->u
.gbl_eisd
.common
.majorid
= EISD__K_MAJORID
;
2944 eisd
->u
.gbl_eisd
.common
.minorid
= EISD__K_MINORID
;
2945 eisd
->u
.gbl_eisd
.common
.eisdsize
= (EISD__K_LEN
+ 4 + namlen
+ 5 + 3) & ~3;
2946 eisd
->u
.gbl_eisd
.common
.secsize
= VMS_BLOCK_SIZE
; /* Must not be 0. */
2947 eisd
->u
.gbl_eisd
.common
.virt_addr
= 0;
2948 eisd
->u
.gbl_eisd
.common
.flags
= EISD__M_GBL
;
2949 eisd
->u
.gbl_eisd
.common
.vbn
= 0;
2950 eisd
->u
.gbl_eisd
.common
.pfc
= 0;
2951 eisd
->u
.gbl_eisd
.common
.matchctl
= PRIV2 (shrimg
, matchctl
);
2952 eisd
->u
.gbl_eisd
.common
.type
= EISD__K_SHRPIC
;
2954 eisd
->u
.gbl_eisd
.ident
= PRIV2 (shrimg
, ident
);
2955 eisd
->u
.gbl_eisd
.gblnam
[0] = namlen
+ 4;
2956 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1, PRIV2 (shrimg
, hdr_data
.hdr_t_name
),
2958 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1 + namlen
, "_001", 4);
2960 /* Append it to the list. */
2961 alpha_vms_append_extra_eisd (abfd
, eisd
);
2966 /* Create an EISD for section SEC.
2967 Return FALSE in case of failure. */
2970 alpha_vms_create_eisd_for_section (bfd
*abfd
, asection
*sec
)
2972 struct vms_internal_eisd_map
*eisd
;
2974 /* Only for allocating section. */
2975 if (!(sec
->flags
& SEC_ALLOC
))
2978 BFD_ASSERT (vms_section_data (sec
)->eisd
== NULL
);
2979 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
2982 vms_section_data (sec
)->eisd
= eisd
;
2984 /* Fill the fields. */
2985 eisd
->u
.eisd
.majorid
= EISD__K_MAJORID
;
2986 eisd
->u
.eisd
.minorid
= EISD__K_MINORID
;
2987 eisd
->u
.eisd
.eisdsize
= EISD__K_LEN
;
2988 eisd
->u
.eisd
.secsize
=
2989 (sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
2990 eisd
->u
.eisd
.virt_addr
= sec
->vma
;
2991 eisd
->u
.eisd
.flags
= 0;
2992 eisd
->u
.eisd
.vbn
= 0; /* To be later defined. */
2993 eisd
->u
.eisd
.pfc
= 0; /* Default. */
2994 eisd
->u
.eisd
.matchctl
= EISD__K_MATALL
;
2995 eisd
->u
.eisd
.type
= EISD__K_NORMAL
;
2997 if (sec
->flags
& SEC_CODE
)
2998 eisd
->u
.eisd
.flags
|= EISD__M_EXE
;
2999 if (!(sec
->flags
& SEC_READONLY
))
3000 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
3002 /* If relocations or fixup will be applied, make this isect writeable. */
3003 if (sec
->flags
& SEC_RELOC
)
3004 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
3006 if (!(sec
->flags
& SEC_HAS_CONTENTS
))
3008 eisd
->u
.eisd
.flags
|= EISD__M_DZRO
;
3009 eisd
->u
.eisd
.flags
&= ~EISD__M_CRF
;
3011 if (sec
->flags
& SEC_LINKER_CREATED
)
3013 if (strcmp (sec
->name
, "$FIXUP$") == 0)
3014 eisd
->u
.eisd
.flags
|= EISD__M_FIXUPVEC
;
3017 /* Append it to the list. */
3019 if (PRIV (eisd_head
) == NULL
)
3020 PRIV (eisd_head
) = eisd
;
3022 PRIV (eisd_tail
)->next
= eisd
;
3023 PRIV (eisd_tail
) = eisd
;
3028 /* Layout executable ABFD and write it to the disk.
3029 Return FALSE in case of failure. */
3032 alpha_vms_write_exec (bfd
*abfd
)
3034 struct vms_eihd eihd
;
3035 struct vms_eiha
*eiha
;
3036 struct vms_eihi
*eihi
;
3037 struct vms_eihs
*eihs
= NULL
;
3039 struct vms_internal_eisd_map
*first_eisd
;
3040 struct vms_internal_eisd_map
*eisd
;
3043 file_ptr gst_filepos
= 0;
3044 unsigned int lnkflags
= 0;
3046 /* Build the EIHD. */
3047 PRIV (file_pos
) = EIHD__C_LENGTH
;
3049 memset (&eihd
, 0, sizeof (eihd
));
3050 memset (eihd
.fill_2
, 0xff, sizeof (eihd
.fill_2
));
3052 bfd_putl32 (EIHD__K_MAJORID
, eihd
.majorid
);
3053 bfd_putl32 (EIHD__K_MINORID
, eihd
.minorid
);
3055 bfd_putl32 (sizeof (eihd
), eihd
.size
);
3056 bfd_putl32 (0, eihd
.isdoff
);
3057 bfd_putl32 (0, eihd
.activoff
);
3058 bfd_putl32 (0, eihd
.symdbgoff
);
3059 bfd_putl32 (0, eihd
.imgidoff
);
3060 bfd_putl32 (0, eihd
.patchoff
);
3061 bfd_putl64 (0, eihd
.iafva
);
3062 bfd_putl32 (0, eihd
.version_array_off
);
3064 bfd_putl32 (EIHD__K_EXE
, eihd
.imgtype
);
3065 bfd_putl32 (0, eihd
.subtype
);
3067 bfd_putl32 (0, eihd
.imgiocnt
);
3068 bfd_putl32 (-1, eihd
.privreqs
);
3069 bfd_putl32 (-1, eihd
.privreqs
+ 4);
3071 bfd_putl32 ((sizeof (eihd
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
3073 bfd_putl32 (0, eihd
.ident
);
3074 bfd_putl32 (0, eihd
.sysver
);
3077 bfd_putl32 (0, eihd
.symvect_size
);
3078 bfd_putl32 (16, eihd
.virt_mem_block_size
);
3079 bfd_putl32 (0, eihd
.ext_fixup_off
);
3080 bfd_putl32 (0, eihd
.noopt_psect_off
);
3081 bfd_putl32 (-1, eihd
.alias
);
3084 eiha
= (struct vms_eiha
*)((char *) &eihd
+ PRIV (file_pos
));
3085 bfd_putl32 (PRIV (file_pos
), eihd
.activoff
);
3086 PRIV (file_pos
) += sizeof (struct vms_eiha
);
3088 bfd_putl32 (sizeof (struct vms_eiha
), eiha
->size
);
3089 bfd_putl32 (0, eiha
->spare
);
3090 bfd_putl64 (PRIV (transfer_address
[0]), eiha
->tfradr1
);
3091 bfd_putl64 (PRIV (transfer_address
[1]), eiha
->tfradr2
);
3092 bfd_putl64 (PRIV (transfer_address
[2]), eiha
->tfradr3
);
3093 bfd_putl64 (PRIV (transfer_address
[3]), eiha
->tfradr4
);
3094 bfd_putl64 (0, eiha
->inishr
);
3097 eihi
= (struct vms_eihi
*)((char *) &eihd
+ PRIV (file_pos
));
3098 bfd_putl32 (PRIV (file_pos
), eihd
.imgidoff
);
3099 PRIV (file_pos
) += sizeof (struct vms_eihi
);
3101 bfd_putl32 (EIHI__K_MAJORID
, eihi
->majorid
);
3102 bfd_putl32 (EIHI__K_MINORID
, eihi
->minorid
);
3107 /* Set module name. */
3108 module
= vms_get_module_name (bfd_get_filename (abfd
), TRUE
);
3109 len
= strlen (module
);
3110 if (len
> sizeof (eihi
->imgnam
) - 1)
3111 len
= sizeof (eihi
->imgnam
) - 1;
3112 eihi
->imgnam
[0] = len
;
3113 memcpy (eihi
->imgnam
+ 1, module
, len
);
3121 vms_get_time (&hi
, &lo
);
3122 bfd_putl32 (lo
, eihi
->linktime
+ 0);
3123 bfd_putl32 (hi
, eihi
->linktime
+ 4);
3126 eihi
->linkid
[0] = 0;
3127 eihi
->imgbid
[0] = 0;
3130 dst
= PRIV (dst_section
);
3131 dmt
= bfd_get_section_by_name (abfd
, "$DMT$");
3132 if (dst
!= NULL
&& dst
->size
!= 0)
3134 eihs
= (struct vms_eihs
*)((char *) &eihd
+ PRIV (file_pos
));
3135 bfd_putl32 (PRIV (file_pos
), eihd
.symdbgoff
);
3136 PRIV (file_pos
) += sizeof (struct vms_eihs
);
3138 bfd_putl32 (EIHS__K_MAJORID
, eihs
->majorid
);
3139 bfd_putl32 (EIHS__K_MINORID
, eihs
->minorid
);
3140 bfd_putl32 (0, eihs
->dstvbn
);
3141 bfd_putl32 (0, eihs
->dstsize
);
3142 bfd_putl32 (0, eihs
->gstvbn
);
3143 bfd_putl32 (0, eihs
->gstsize
);
3144 bfd_putl32 (0, eihs
->dmtvbn
);
3145 bfd_putl32 (0, eihs
->dmtsize
);
3148 /* One EISD per section. */
3149 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3151 if (!alpha_vms_create_eisd_for_section (abfd
, sec
))
3155 /* Merge section EIDS which extra ones. */
3156 if (PRIV (eisd_tail
))
3157 PRIV (eisd_tail
)->next
= PRIV (gbl_eisd_head
);
3159 PRIV (eisd_head
) = PRIV (gbl_eisd_head
);
3160 if (PRIV (gbl_eisd_tail
))
3161 PRIV (eisd_tail
) = PRIV (gbl_eisd_tail
);
3163 first_eisd
= PRIV (eisd_head
);
3165 /* Add end of eisd. */
3168 eisd
= bfd_zalloc (abfd
, sizeof (*eisd
));
3171 eisd
->u
.eisd
.majorid
= 0;
3172 eisd
->u
.eisd
.minorid
= 0;
3173 eisd
->u
.eisd
.eisdsize
= 0;
3174 alpha_vms_append_extra_eisd (abfd
, eisd
);
3177 /* Place EISD in the file. */
3178 for (eisd
= first_eisd
; eisd
; eisd
= eisd
->next
)
3180 file_ptr room
= VMS_BLOCK_SIZE
- (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
3182 /* First block is a little bit special: there is a word at the end. */
3183 if (PRIV (file_pos
) < VMS_BLOCK_SIZE
&& room
> 2)
3185 if (room
< eisd
->u
.eisd
.eisdsize
+ EISD__K_LENEND
)
3186 alpha_vms_file_position_block (abfd
);
3188 eisd
->file_pos
= PRIV (file_pos
);
3189 PRIV (file_pos
) += eisd
->u
.eisd
.eisdsize
;
3191 if (eisd
->u
.eisd
.flags
& EISD__M_FIXUPVEC
)
3192 bfd_putl64 (eisd
->u
.eisd
.virt_addr
, eihd
.iafva
);
3195 if (first_eisd
!= NULL
)
3197 bfd_putl32 (first_eisd
->file_pos
, eihd
.isdoff
);
3198 /* Real size of end of eisd marker. */
3199 PRIV (file_pos
) += EISD__K_LENEND
;
3202 bfd_putl32 (PRIV (file_pos
), eihd
.size
);
3203 bfd_putl32 ((PRIV (file_pos
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
3206 /* Place sections. */
3207 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3209 if (!(sec
->flags
& SEC_HAS_CONTENTS
))
3212 eisd
= vms_section_data (sec
)->eisd
;
3214 /* Align on a block. */
3215 alpha_vms_file_position_block (abfd
);
3216 sec
->filepos
= PRIV (file_pos
);
3219 eisd
->u
.eisd
.vbn
= (sec
->filepos
/ VMS_BLOCK_SIZE
) + 1;
3221 PRIV (file_pos
) += sec
->size
;
3225 if (eihs
!= NULL
&& dst
!= NULL
)
3227 bfd_putl32 ((dst
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dstvbn
);
3228 bfd_putl32 (dst
->size
, eihs
->dstsize
);
3232 lnkflags
|= EIHD__M_DBGDMT
;
3233 bfd_putl32 ((dmt
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dmtvbn
);
3234 bfd_putl32 (dmt
->size
, eihs
->dmtsize
);
3236 if (PRIV (gsd_sym_count
) != 0)
3238 alpha_vms_file_position_block (abfd
);
3239 gst_filepos
= PRIV (file_pos
);
3240 bfd_putl32 ((gst_filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->gstvbn
);
3241 bfd_putl32 ((PRIV (gsd_sym_count
) + 4) / 5 + 4, eihs
->gstsize
);
3245 /* Write EISD in hdr. */
3246 for (eisd
= first_eisd
; eisd
&& eisd
->file_pos
< VMS_BLOCK_SIZE
;
3248 alpha_vms_swap_eisd_out
3249 (eisd
, (struct vms_eisd
*)((char *)&eihd
+ eisd
->file_pos
));
3251 /* Write first block. */
3252 bfd_putl32 (lnkflags
, eihd
.lnkflags
);
3253 if (bfd_bwrite (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
3256 /* Write remaining eisd. */
3259 unsigned char blk
[VMS_BLOCK_SIZE
];
3260 struct vms_internal_eisd_map
*next_eisd
;
3262 memset (blk
, 0xff, sizeof (blk
));
3263 while (eisd
!= NULL
)
3265 alpha_vms_swap_eisd_out
3267 (struct vms_eisd
*)(blk
+ (eisd
->file_pos
% VMS_BLOCK_SIZE
)));
3269 next_eisd
= eisd
->next
;
3270 if (next_eisd
== NULL
3271 || (next_eisd
->file_pos
/ VMS_BLOCK_SIZE
3272 != eisd
->file_pos
/ VMS_BLOCK_SIZE
))
3274 if (bfd_bwrite (blk
, sizeof (blk
), abfd
) != sizeof (blk
))
3277 memset (blk
, 0xff, sizeof (blk
));
3283 /* Write sections. */
3284 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3286 unsigned char blk
[VMS_BLOCK_SIZE
];
3289 if (sec
->size
== 0 || !(sec
->flags
& SEC_HAS_CONTENTS
))
3291 if (bfd_bwrite (sec
->contents
, sec
->size
, abfd
) != sec
->size
)
3295 len
= VMS_BLOCK_SIZE
- sec
->size
% VMS_BLOCK_SIZE
;
3296 if (len
!= VMS_BLOCK_SIZE
)
3298 memset (blk
, 0, len
);
3299 if (bfd_bwrite (blk
, len
, abfd
) != len
)
3305 if (gst_filepos
!= 0)
3307 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3310 _bfd_vms_write_emh (abfd
);
3311 _bfd_vms_write_lmn (abfd
, "GNU LD");
3313 /* PSC for the absolute section. */
3314 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3315 _bfd_vms_output_long (recwr
, 0);
3316 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3317 _bfd_vms_output_short (recwr
, 0);
3318 _bfd_vms_output_short (recwr
, EGPS__V_PIC
| EGPS__V_LIB
| EGPS__V_RD
);
3319 _bfd_vms_output_long (recwr
, 0);
3320 _bfd_vms_output_counted (recwr
, ".$$ABS$$.");
3321 _bfd_vms_output_end_subrec (recwr
);
3322 _bfd_vms_output_end (abfd
, recwr
);
3324 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
3326 struct vms_symbol_entry
*sym
= PRIV (syms
)[i
];
3332 _bfd_vms_output_alignment (recwr
, 8);
3333 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3334 _bfd_vms_output_long (recwr
, 0);
3336 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYMG
);
3337 _bfd_vms_output_short (recwr
, 0); /* Data type, alignment. */
3338 _bfd_vms_output_short (recwr
, sym
->flags
);
3340 if (sym
->code_section
)
3341 ep
= alpha_vms_get_sym_value (sym
->code_section
, sym
->code_value
);
3344 BFD_ASSERT (sym
->code_value
== 0);
3347 val
= alpha_vms_get_sym_value (sym
->section
, sym
->value
);
3348 _bfd_vms_output_quad
3349 (recwr
, sym
->typ
== EGSD__C_SYMG
? sym
->symbol_vector
: val
);
3350 _bfd_vms_output_quad (recwr
, ep
);
3351 _bfd_vms_output_quad (recwr
, val
);
3352 _bfd_vms_output_long (recwr
, 0);
3353 _bfd_vms_output_counted (recwr
, sym
->name
);
3354 _bfd_vms_output_end_subrec (recwr
);
3356 _bfd_vms_output_end (abfd
, recwr
);
3359 _bfd_vms_output_end (abfd
, recwr
);
3361 if (!_bfd_vms_write_eeom (abfd
))
3369 /* Write section and symbol directory of bfd abfd. Return FALSE on error. */
3372 _bfd_vms_write_egsd (bfd
*abfd
)
3376 unsigned int symnum
;
3378 flagword new_flags
, old_flags
;
3379 int abs_section_index
= -1;
3380 unsigned int target_index
= 0;
3381 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3383 vms_debug2 ((2, "vms_write_egsd\n"));
3385 /* Egsd is quadword aligned. */
3386 _bfd_vms_output_alignment (recwr
, 8);
3388 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3389 _bfd_vms_output_long (recwr
, 0);
3391 /* Number sections. */
3392 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3394 if (section
->flags
& SEC_DEBUGGING
)
3396 if (!strcmp (section
->name
, ".vmsdebug"))
3398 section
->flags
|= SEC_DEBUGGING
;
3401 section
->target_index
= target_index
++;
3404 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3406 vms_debug2 ((3, "Section #%d %s, %d bytes\n",
3407 section
->target_index
, section
->name
, (int)section
->size
));
3409 /* Don't write out the VMS debug info section since it is in the
3410 ETBT and EDBG sections in etir. */
3411 if (section
->flags
& SEC_DEBUGGING
)
3414 /* 13 bytes egsd, max 31 chars name -> should be 44 bytes. */
3415 if (_bfd_vms_output_check (recwr
, 64) < 0)
3417 _bfd_vms_output_end (abfd
, recwr
);
3418 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3419 _bfd_vms_output_long (recwr
, 0);
3422 /* Don't know if this is necessary for the linker but for now it keeps
3423 vms_slurp_gsd happy. */
3424 sname
= section
->name
;
3427 /* Remove leading dot. */
3429 if ((*sname
== 't') && (strcmp (sname
, "text") == 0))
3430 sname
= EVAX_CODE_NAME
;
3431 else if ((*sname
== 'd') && (strcmp (sname
, "data") == 0))
3432 sname
= EVAX_DATA_NAME
;
3433 else if ((*sname
== 'b') && (strcmp (sname
, "bss") == 0))
3434 sname
= EVAX_BSS_NAME
;
3435 else if ((*sname
== 'l') && (strcmp (sname
, "link") == 0))
3436 sname
= EVAX_LINK_NAME
;
3437 else if ((*sname
== 'r') && (strcmp (sname
, "rdata") == 0))
3438 sname
= EVAX_READONLY_NAME
;
3439 else if ((*sname
== 'l') && (strcmp (sname
, "literal") == 0))
3440 sname
= EVAX_LITERAL_NAME
;
3441 else if ((*sname
== 'l') && (strcmp (sname
, "literals") == 0))
3442 sname
= EVAX_LITERALS_NAME
;
3443 else if ((*sname
== 'c') && (strcmp (sname
, "comm") == 0))
3444 sname
= EVAX_COMMON_NAME
;
3445 else if ((*sname
== 'l') && (strcmp (sname
, "lcomm") == 0))
3446 sname
= EVAX_LOCAL_NAME
;
3449 if (bfd_is_com_section (section
))
3450 new_flags
= (EGPS__V_OVR
| EGPS__V_REL
| EGPS__V_GBL
| EGPS__V_RD
3451 | EGPS__V_WRT
| EGPS__V_NOMOD
| EGPS__V_COM
);
3453 new_flags
= vms_esecflag_by_name (evax_section_flags
, sname
,
3456 /* Modify them as directed. */
3457 if (section
->flags
& SEC_READONLY
)
3458 new_flags
&= ~EGPS__V_WRT
;
3460 new_flags
&= ~vms_section_data (section
)->no_flags
;
3461 new_flags
|= vms_section_data (section
)->flags
;
3463 vms_debug2 ((3, "sec flags %x\n", section
->flags
));
3464 vms_debug2 ((3, "new_flags %x, _raw_size %lu\n",
3465 new_flags
, (unsigned long)section
->size
));
3467 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3468 _bfd_vms_output_short (recwr
, section
->alignment_power
& 0xff);
3469 _bfd_vms_output_short (recwr
, new_flags
);
3470 _bfd_vms_output_long (recwr
, (unsigned long) section
->size
);
3471 _bfd_vms_output_counted (recwr
, sname
);
3472 _bfd_vms_output_end_subrec (recwr
);
3474 /* If the section is an obsolute one, remind its index as it will be
3475 used later for absolute symbols. */
3476 if ((new_flags
& EGPS__V_REL
) == 0 && abs_section_index
< 0)
3477 abs_section_index
= section
->target_index
;
3480 /* Output symbols. */
3481 vms_debug2 ((3, "%d symbols found\n", abfd
->symcount
));
3483 bfd_set_start_address (abfd
, (bfd_vma
) -1);
3485 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3487 symbol
= abfd
->outsymbols
[symnum
];
3488 old_flags
= symbol
->flags
;
3490 /* Work-around a missing feature: consider __main as the main entry
3492 if (symbol
->name
[0] == '_' && strcmp (symbol
->name
, "__main") == 0)
3493 bfd_set_start_address (abfd
, (bfd_vma
)symbol
->value
);
3495 /* Only put in the GSD the global and the undefined symbols. */
3496 if (old_flags
& BSF_FILE
)
3499 if ((old_flags
& BSF_GLOBAL
) == 0 && !bfd_is_und_section (symbol
->section
))
3501 /* If the LIB$INITIIALIZE section is present, add a reference to
3502 LIB$INITIALIZE symbol. FIXME: this should be done explicitely
3503 in the assembly file. */
3504 if (!((old_flags
& BSF_SECTION_SYM
) != 0
3505 && strcmp (symbol
->section
->name
, "LIB$INITIALIZE") == 0))
3509 /* 13 bytes egsd, max 64 chars name -> should be 77 bytes. Add 16 more
3510 bytes for a possible ABS section. */
3511 if (_bfd_vms_output_check (recwr
, 80 + 16) < 0)
3513 _bfd_vms_output_end (abfd
, recwr
);
3514 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3515 _bfd_vms_output_long (recwr
, 0);
3518 if ((old_flags
& BSF_GLOBAL
) != 0
3519 && bfd_is_abs_section (symbol
->section
)
3520 && abs_section_index
<= 0)
3522 /* Create an absolute section if none was defined. It is highly
3523 unlikely that the name $ABS$ clashes with a user defined
3524 non-absolute section name. */
3525 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3526 _bfd_vms_output_short (recwr
, 4);
3527 _bfd_vms_output_short (recwr
, EGPS__V_SHR
);
3528 _bfd_vms_output_long (recwr
, 0);
3529 _bfd_vms_output_counted (recwr
, "$ABS$");
3530 _bfd_vms_output_end_subrec (recwr
);
3532 abs_section_index
= target_index
++;
3535 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYM
);
3537 /* Data type, alignment. */
3538 _bfd_vms_output_short (recwr
, 0);
3542 if (old_flags
& BSF_WEAK
)
3543 new_flags
|= EGSY__V_WEAK
;
3544 if (bfd_is_com_section (symbol
->section
)) /* .comm */
3545 new_flags
|= (EGSY__V_WEAK
| EGSY__V_COMM
);
3547 if (old_flags
& BSF_FUNCTION
)
3549 new_flags
|= EGSY__V_NORM
;
3550 new_flags
|= EGSY__V_REL
;
3552 if (old_flags
& BSF_GLOBAL
)
3554 new_flags
|= EGSY__V_DEF
;
3555 if (!bfd_is_abs_section (symbol
->section
))
3556 new_flags
|= EGSY__V_REL
;
3558 _bfd_vms_output_short (recwr
, new_flags
);
3560 if (old_flags
& BSF_GLOBAL
)
3562 /* Symbol definition. */
3563 bfd_vma code_address
= 0;
3564 unsigned long ca_psindx
= 0;
3565 unsigned long psindx
;
3567 if ((old_flags
& BSF_FUNCTION
) && symbol
->udata
.p
!= NULL
)
3572 ((struct evax_private_udata_struct
*)symbol
->udata
.p
)->enbsym
;
3573 code_address
= sym
->value
;
3574 ca_psindx
= sym
->section
->target_index
;
3576 if (bfd_is_abs_section (symbol
->section
))
3577 psindx
= abs_section_index
;
3579 psindx
= symbol
->section
->target_index
;
3581 _bfd_vms_output_quad (recwr
, symbol
->value
);
3582 _bfd_vms_output_quad (recwr
, code_address
);
3583 _bfd_vms_output_long (recwr
, ca_psindx
);
3584 _bfd_vms_output_long (recwr
, psindx
);
3586 _bfd_vms_output_counted (recwr
, symbol
->name
);
3588 _bfd_vms_output_end_subrec (recwr
);
3591 _bfd_vms_output_alignment (recwr
, 8);
3592 _bfd_vms_output_end (abfd
, recwr
);
3597 /* Write object header for bfd abfd. Return FALSE on error. */
3600 _bfd_vms_write_ehdr (bfd
*abfd
)
3603 unsigned int symnum
;
3604 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3606 vms_debug2 ((2, "vms_write_ehdr (%p)\n", abfd
));
3608 _bfd_vms_output_alignment (recwr
, 2);
3610 _bfd_vms_write_emh (abfd
);
3611 _bfd_vms_write_lmn (abfd
, "GNU AS");
3614 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3615 _bfd_vms_output_short (recwr
, EMH__C_SRC
);
3617 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3619 symbol
= abfd
->outsymbols
[symnum
];
3621 if (symbol
->flags
& BSF_FILE
)
3623 _bfd_vms_output_dump (recwr
, (unsigned char *) symbol
->name
,
3624 (int) strlen (symbol
->name
));
3629 if (symnum
== abfd
->symcount
)
3630 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("noname"));
3632 _bfd_vms_output_end (abfd
, recwr
);
3635 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3636 _bfd_vms_output_short (recwr
, EMH__C_TTL
);
3637 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("TTL"));
3638 _bfd_vms_output_end (abfd
, recwr
);
3641 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3642 _bfd_vms_output_short (recwr
, EMH__C_CPR
);
3643 _bfd_vms_output_dump (recwr
,
3644 (unsigned char *)"GNU BFD ported by Klaus Kämpf 1994-1996",
3646 _bfd_vms_output_end (abfd
, recwr
);
3651 /* Part 4.6, relocations. */
3654 /* WRITE ETIR SECTION
3656 This is still under construction and therefore not documented. */
3658 /* Close the etir/etbt record. */
3661 end_etir_record (bfd
* abfd
)
3663 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3665 _bfd_vms_output_end (abfd
, recwr
);
3669 start_etir_or_etbt_record (bfd
*abfd
, asection
*section
, bfd_vma offset
)
3671 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3673 if (section
->flags
& SEC_DEBUGGING
)
3675 _bfd_vms_output_begin (recwr
, EOBJ__C_ETBT
);
3679 /* Push start offset. */
3680 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3681 _bfd_vms_output_long (recwr
, (unsigned long) 0);
3682 _bfd_vms_output_end_subrec (recwr
);
3685 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_DFLOC
);
3686 _bfd_vms_output_end_subrec (recwr
);
3691 _bfd_vms_output_begin (recwr
, EOBJ__C_ETIR
);
3695 /* Push start offset. */
3696 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3697 _bfd_vms_output_long (recwr
, (unsigned long) section
->target_index
);
3698 _bfd_vms_output_quad (recwr
, offset
);
3699 _bfd_vms_output_end_subrec (recwr
);
3701 /* Start = pop (). */
3702 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_SETRB
);
3703 _bfd_vms_output_end_subrec (recwr
);
3708 /* Output a STO_IMM command for SSIZE bytes of data from CPR at virtual
3709 address VADDR in section specified by SEC_INDEX and NAME. */
3712 sto_imm (bfd
*abfd
, asection
*section
,
3713 bfd_size_type ssize
, unsigned char *cptr
, bfd_vma vaddr
)
3716 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3719 _bfd_vms_debug (8, "sto_imm %d bytes\n", (int) ssize
);
3720 _bfd_hexdump (9, cptr
, (int) ssize
, (int) vaddr
);
3725 /* Try all the rest. */
3728 if (_bfd_vms_output_check (recwr
, size
) < 0)
3730 /* Doesn't fit, split ! */
3731 end_etir_record (abfd
);
3733 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3735 size
= _bfd_vms_output_check (recwr
, 0); /* get max size */
3736 if (size
> ssize
) /* more than what's left ? */
3740 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_IMM
);
3741 _bfd_vms_output_long (recwr
, (unsigned long) (size
));
3742 _bfd_vms_output_dump (recwr
, cptr
, size
);
3743 _bfd_vms_output_end_subrec (recwr
);
3746 _bfd_vms_debug (10, "dumped %d bytes\n", (int) size
);
3747 _bfd_hexdump (10, cptr
, (int) size
, (int) vaddr
);
3757 etir_output_check (bfd
*abfd
, asection
*section
, bfd_vma vaddr
, int checklen
)
3759 if (_bfd_vms_output_check (&PRIV (recwr
), checklen
) < 0)
3761 /* Not enough room in this record. Close it and open a new one. */
3762 end_etir_record (abfd
);
3763 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3767 /* Return whether RELOC must be deferred till the end. */
3770 defer_reloc_p (arelent
*reloc
)
3772 switch (reloc
->howto
->type
)
3785 /* Write section contents for bfd abfd. Return FALSE on error. */
3788 _bfd_vms_write_etir (bfd
* abfd
, int objtype ATTRIBUTE_UNUSED
)
3791 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3793 vms_debug2 ((2, "vms_write_tir (%p, %d)\n", abfd
, objtype
));
3795 _bfd_vms_output_alignment (recwr
, 4);
3797 PRIV (vms_linkage_index
) = 0;
3799 for (section
= abfd
->sections
; section
; section
= section
->next
)
3801 vms_debug2 ((4, "writing %d. section '%s' (%d bytes)\n",
3802 section
->target_index
, section
->name
, (int) (section
->size
)));
3804 if (!(section
->flags
& SEC_HAS_CONTENTS
)
3805 || bfd_is_com_section (section
))
3808 if (!section
->contents
)
3810 bfd_set_error (bfd_error_no_contents
);
3814 start_etir_or_etbt_record (abfd
, section
, 0);
3816 if (section
->flags
& SEC_RELOC
)
3818 bfd_vma curr_addr
= 0;
3819 unsigned char *curr_data
= section
->contents
;
3821 int pass2_needed
= 0;
3822 int pass2_in_progress
= 0;
3825 if (section
->reloc_count
== 0)
3827 (_("SEC_RELOC with no relocs in section %A"), section
);
3832 int i
= section
->reloc_count
;
3833 arelent
**rptr
= section
->orelocation
;
3834 _bfd_vms_debug (4, "%d relocations:\n", i
);
3837 _bfd_vms_debug (4, "sym %s in sec %s, value %08lx, "
3838 "addr %08lx, off %08lx, len %d: %s\n",
3839 (*(*rptr
)->sym_ptr_ptr
)->name
,
3840 (*(*rptr
)->sym_ptr_ptr
)->section
->name
,
3841 (long) (*(*rptr
)->sym_ptr_ptr
)->value
,
3842 (unsigned long)(*rptr
)->address
,
3843 (unsigned long)(*rptr
)->addend
,
3844 bfd_get_reloc_size ((*rptr
)->howto
),
3845 ( *rptr
)->howto
->name
);
3852 for (irel
= 0; irel
< section
->reloc_count
; irel
++)
3854 struct evax_private_udata_struct
*udata
;
3855 arelent
*rptr
= section
->orelocation
[irel
];
3856 bfd_vma addr
= rptr
->address
;
3857 asymbol
*sym
= *rptr
->sym_ptr_ptr
;
3858 asection
*sec
= sym
->section
;
3859 bfd_boolean defer
= defer_reloc_p (rptr
);
3862 if (pass2_in_progress
)
3864 /* Non-deferred relocs have already been output. */
3870 /* Deferred relocs must be output at the very end. */
3877 /* Regular relocs are intertwined with binary data. */
3878 if (curr_addr
> addr
)
3879 _bfd_error_handler (_("Size error in section %A"),
3881 size
= addr
- curr_addr
;
3882 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
3887 size
= bfd_get_reloc_size (rptr
->howto
);
3889 switch (rptr
->howto
->type
)
3891 case ALPHA_R_IGNORE
:
3894 case ALPHA_R_REFLONG
:
3895 if (bfd_is_und_section (sym
->section
))
3897 bfd_vma addend
= rptr
->addend
;
3898 slen
= strlen ((char *) sym
->name
);
3899 etir_output_check (abfd
, section
, curr_addr
, slen
);
3902 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
3903 _bfd_vms_output_counted (recwr
, sym
->name
);
3904 _bfd_vms_output_end_subrec (recwr
);
3905 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3906 _bfd_vms_output_long (recwr
, (unsigned long) addend
);
3907 _bfd_vms_output_end_subrec (recwr
);
3908 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
3909 _bfd_vms_output_end_subrec (recwr
);
3910 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3911 _bfd_vms_output_end_subrec (recwr
);
3915 _bfd_vms_output_begin_subrec
3916 (recwr
, ETIR__C_STO_GBL_LW
);
3917 _bfd_vms_output_counted (recwr
, sym
->name
);
3918 _bfd_vms_output_end_subrec (recwr
);
3921 else if (bfd_is_abs_section (sym
->section
))
3923 etir_output_check (abfd
, section
, curr_addr
, 16);
3924 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3925 _bfd_vms_output_long (recwr
, (unsigned long) sym
->value
);
3926 _bfd_vms_output_end_subrec (recwr
);
3927 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3928 _bfd_vms_output_end_subrec (recwr
);
3932 etir_output_check (abfd
, section
, curr_addr
, 32);
3933 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3934 _bfd_vms_output_long (recwr
,
3935 (unsigned long) sec
->target_index
);
3936 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
3937 _bfd_vms_output_end_subrec (recwr
);
3938 /* ??? Table B-8 of the OpenVMS Linker Utilily Manual
3939 says that we should have a ETIR__C_STO_OFF here.
3940 But the relocation would not be BFD_RELOC_32 then.
3941 This case is very likely unreachable. */
3942 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3943 _bfd_vms_output_end_subrec (recwr
);
3947 case ALPHA_R_REFQUAD
:
3948 if (bfd_is_und_section (sym
->section
))
3950 bfd_vma addend
= rptr
->addend
;
3951 slen
= strlen ((char *) sym
->name
);
3952 etir_output_check (abfd
, section
, curr_addr
, slen
);
3955 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
3956 _bfd_vms_output_counted (recwr
, sym
->name
);
3957 _bfd_vms_output_end_subrec (recwr
);
3958 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
3959 _bfd_vms_output_quad (recwr
, addend
);
3960 _bfd_vms_output_end_subrec (recwr
);
3961 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
3962 _bfd_vms_output_end_subrec (recwr
);
3963 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
3964 _bfd_vms_output_end_subrec (recwr
);
3968 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_GBL
);
3969 _bfd_vms_output_counted (recwr
, sym
->name
);
3970 _bfd_vms_output_end_subrec (recwr
);
3973 else if (bfd_is_abs_section (sym
->section
))
3975 etir_output_check (abfd
, section
, curr_addr
, 16);
3976 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
3977 _bfd_vms_output_quad (recwr
, sym
->value
);
3978 _bfd_vms_output_end_subrec (recwr
);
3979 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
3980 _bfd_vms_output_end_subrec (recwr
);
3984 etir_output_check (abfd
, section
, curr_addr
, 32);
3985 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3986 _bfd_vms_output_long (recwr
,
3987 (unsigned long) sec
->target_index
);
3988 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
3989 _bfd_vms_output_end_subrec (recwr
);
3990 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_OFF
);
3991 _bfd_vms_output_end_subrec (recwr
);
3996 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
3999 case ALPHA_R_LINKAGE
:
4000 etir_output_check (abfd
, section
, curr_addr
, 64);
4001 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LP_PSB
);
4002 _bfd_vms_output_long
4003 (recwr
, (unsigned long) rptr
->addend
);
4004 if (rptr
->addend
> PRIV (vms_linkage_index
))
4005 PRIV (vms_linkage_index
) = rptr
->addend
;
4006 _bfd_vms_output_counted (recwr
, sym
->name
);
4007 _bfd_vms_output_byte (recwr
, 0);
4008 _bfd_vms_output_end_subrec (recwr
);
4011 case ALPHA_R_CODEADDR
:
4012 slen
= strlen ((char *) sym
->name
);
4013 etir_output_check (abfd
, section
, curr_addr
, slen
);
4014 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_CA
);
4015 _bfd_vms_output_counted (recwr
, sym
->name
);
4016 _bfd_vms_output_end_subrec (recwr
);
4021 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4022 etir_output_check (abfd
, section
, curr_addr
,
4023 32 + 1 + strlen (udata
->origname
));
4024 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_NOP_GBL
);
4025 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
4026 _bfd_vms_output_long
4027 (recwr
, (unsigned long) section
->target_index
);
4028 _bfd_vms_output_quad (recwr
, rptr
->address
);
4029 _bfd_vms_output_long (recwr
, (unsigned long) 0x47ff041f);
4030 _bfd_vms_output_long
4031 (recwr
, (unsigned long) section
->target_index
);
4032 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4033 _bfd_vms_output_counted (recwr
, udata
->origname
);
4034 _bfd_vms_output_end_subrec (recwr
);
4038 _bfd_error_handler (_("Spurious ALPHA_R_BSR reloc"));
4043 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4044 etir_output_check (abfd
, section
, curr_addr
,
4045 32 + 1 + strlen (udata
->origname
));
4046 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LDA_GBL
);
4047 _bfd_vms_output_long
4048 (recwr
, (unsigned long) udata
->lkindex
+ 1);
4049 _bfd_vms_output_long
4050 (recwr
, (unsigned long) section
->target_index
);
4051 _bfd_vms_output_quad (recwr
, rptr
->address
);
4052 _bfd_vms_output_long (recwr
, (unsigned long) 0x237B0000);
4053 _bfd_vms_output_long
4054 (recwr
, (unsigned long) udata
->bsym
->section
->target_index
);
4055 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4056 _bfd_vms_output_counted (recwr
, udata
->origname
);
4057 _bfd_vms_output_end_subrec (recwr
);
4062 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4063 etir_output_check (abfd
, section
, curr_addr
,
4064 32 + 1 + strlen (udata
->origname
));
4065 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_BOH_GBL
);
4066 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
4067 _bfd_vms_output_long
4068 (recwr
, (unsigned long) section
->target_index
);
4069 _bfd_vms_output_quad (recwr
, rptr
->address
);
4070 _bfd_vms_output_long (recwr
, (unsigned long) 0xD3400000);
4071 _bfd_vms_output_long
4072 (recwr
, (unsigned long) section
->target_index
);
4073 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4074 _bfd_vms_output_counted (recwr
, udata
->origname
);
4075 _bfd_vms_output_end_subrec (recwr
);
4079 _bfd_error_handler (_("Unhandled relocation %s"),
4086 } /* End of relocs loop. */
4088 if (!pass2_in_progress
)
4090 /* Output rest of section. */
4091 if (curr_addr
> section
->size
)
4092 _bfd_error_handler (_("Size error in section %A"), section
);
4093 size
= section
->size
- curr_addr
;
4094 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
4100 pass2_in_progress
= 1;
4106 else /* (section->flags & SEC_RELOC) */
4107 sto_imm (abfd
, section
, section
->size
, section
->contents
, 0);
4109 end_etir_record (abfd
);
4112 _bfd_vms_output_alignment (recwr
, 2);
4116 /* Write cached information into a file being written, at bfd_close. */
4119 alpha_vms_write_object_contents (bfd
*abfd
)
4121 vms_debug2 ((1, "vms_write_object_contents (%p)\n", abfd
));
4123 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
4125 return alpha_vms_write_exec (abfd
);
4129 if (abfd
->section_count
> 0) /* we have sections */
4131 if (!_bfd_vms_write_ehdr (abfd
))
4133 if (!_bfd_vms_write_egsd (abfd
))
4135 if (!_bfd_vms_write_etir (abfd
, EOBJ__C_ETIR
))
4137 if (!_bfd_vms_write_eeom (abfd
))
4144 /* Debug stuff: nearest line. */
4146 #define SET_MODULE_PARSED(m) \
4147 do { if ((m)->name == NULL) (m)->name = ""; } while (0)
4148 #define IS_MODULE_PARSED(m) ((m)->name != NULL)
4150 /* Build a new module for the specified BFD. */
4152 static struct module
*
4153 new_module (bfd
*abfd
)
4155 struct module
*module
4156 = (struct module
*) bfd_zalloc (abfd
, sizeof (struct module
));
4157 module
->file_table_count
= 16; /* Arbitrary. */
4159 = bfd_malloc (module
->file_table_count
* sizeof (struct fileinfo
));
4163 /* Parse debug info for a module and internalize it. */
4166 parse_module (bfd
*abfd
, struct module
*module
, unsigned char *ptr
,
4169 unsigned char *maxptr
= ptr
+ length
;
4170 unsigned char *src_ptr
, *pcl_ptr
;
4171 unsigned int prev_linum
= 0, curr_linenum
= 0;
4172 bfd_vma prev_pc
= 0, curr_pc
= 0;
4173 struct srecinfo
*curr_srec
, *srec
;
4174 struct lineinfo
*curr_line
, *line
;
4175 struct funcinfo
*funcinfo
;
4177 /* Initialize tables with zero element. */
4178 curr_srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4179 module
->srec_table
= curr_srec
;
4181 curr_line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4182 module
->line_table
= curr_line
;
4184 while (length
== -1 || ptr
< maxptr
)
4186 /* The first byte is not counted in the recorded length. */
4187 int rec_length
= bfd_getl16 (ptr
) + 1;
4188 int rec_type
= bfd_getl16 (ptr
+ 2);
4190 vms_debug2 ((2, "DST record: leng %d, type %d\n", rec_length
, rec_type
));
4192 if (length
== -1 && rec_type
== DST__K_MODEND
)
4199 = _bfd_vms_save_counted_string (ptr
+ DST_S_B_MODBEG_NAME
,
4200 maxptr
- (ptr
+ DST_S_B_MODBEG_NAME
));
4207 vms_debug2 ((3, "module: %s\n", module
->name
));
4214 funcinfo
= (struct funcinfo
*)
4215 bfd_zalloc (abfd
, sizeof (struct funcinfo
));
4217 = _bfd_vms_save_counted_string (ptr
+ DST_S_B_RTNBEG_NAME
,
4218 maxptr
- (ptr
+ DST_S_B_RTNBEG_NAME
));
4219 funcinfo
->low
= bfd_getl32 (ptr
+ DST_S_L_RTNBEG_ADDRESS
);
4220 funcinfo
->next
= module
->func_table
;
4221 module
->func_table
= funcinfo
;
4223 vms_debug2 ((3, "routine: %s at 0x%lx\n",
4224 funcinfo
->name
, (unsigned long) funcinfo
->low
));
4228 module
->func_table
->high
= module
->func_table
->low
4229 + bfd_getl32 (ptr
+ DST_S_L_RTNEND_SIZE
) - 1;
4231 if (module
->func_table
->high
> module
->high
)
4232 module
->high
= module
->func_table
->high
;
4234 vms_debug2 ((3, "end routine\n"));
4238 vms_debug2 ((3, "prologue\n"));
4242 vms_debug2 ((3, "epilog\n"));
4246 vms_debug2 ((3, "block\n"));
4250 vms_debug2 ((3, "end block\n"));
4254 src_ptr
= ptr
+ DST_S_C_SOURCE_HEADER_SIZE
;
4256 vms_debug2 ((3, "source info\n"));
4258 while (src_ptr
< ptr
+ rec_length
)
4260 int cmd
= src_ptr
[0], cmd_length
, data
;
4264 case DST__K_SRC_DECLFILE
:
4267 = bfd_getl16 (src_ptr
+ DST_S_W_SRC_DF_FILEID
);
4269 = _bfd_vms_save_counted_string (src_ptr
+ DST_S_B_SRC_DF_FILENAME
,
4270 (ptr
+ rec_length
) -
4271 (src_ptr
+ DST_S_B_SRC_DF_FILENAME
)
4274 while (fileid
>= module
->file_table_count
)
4276 module
->file_table_count
*= 2;
4278 = bfd_realloc (module
->file_table
,
4279 module
->file_table_count
4280 * sizeof (struct fileinfo
));
4283 module
->file_table
[fileid
].name
= filename
;
4284 module
->file_table
[fileid
].srec
= 1;
4285 cmd_length
= src_ptr
[DST_S_B_SRC_DF_LENGTH
] + 2;
4286 vms_debug2 ((4, "DST_S_C_SRC_DECLFILE: %d, %s\n",
4287 fileid
, module
->file_table
[fileid
].name
));
4291 case DST__K_SRC_DEFLINES_B
:
4292 /* Perform the association and set the next higher index
4294 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4295 srec
= (struct srecinfo
*)
4296 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4297 srec
->line
= curr_srec
->line
+ data
;
4298 srec
->srec
= curr_srec
->srec
+ data
;
4299 srec
->sfile
= curr_srec
->sfile
;
4300 curr_srec
->next
= srec
;
4303 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_B: %d\n", data
));
4306 case DST__K_SRC_DEFLINES_W
:
4307 /* Perform the association and set the next higher index
4309 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4310 srec
= (struct srecinfo
*)
4311 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4312 srec
->line
= curr_srec
->line
+ data
;
4313 srec
->srec
= curr_srec
->srec
+ data
,
4314 srec
->sfile
= curr_srec
->sfile
;
4315 curr_srec
->next
= srec
;
4318 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_W: %d\n", data
));
4321 case DST__K_SRC_INCRLNUM_B
:
4322 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4323 curr_srec
->line
+= data
;
4325 vms_debug2 ((4, "DST_S_C_SRC_INCRLNUM_B: %d\n", data
));
4328 case DST__K_SRC_SETFILE
:
4329 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4330 curr_srec
->sfile
= data
;
4331 curr_srec
->srec
= module
->file_table
[data
].srec
;
4333 vms_debug2 ((4, "DST_S_C_SRC_SETFILE: %d\n", data
));
4336 case DST__K_SRC_SETLNUM_L
:
4337 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4338 curr_srec
->line
= data
;
4340 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_L: %d\n", data
));
4343 case DST__K_SRC_SETLNUM_W
:
4344 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4345 curr_srec
->line
= data
;
4347 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_W: %d\n", data
));
4350 case DST__K_SRC_SETREC_L
:
4351 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4352 curr_srec
->srec
= data
;
4353 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4355 vms_debug2 ((4, "DST_S_C_SRC_SETREC_L: %d\n", data
));
4358 case DST__K_SRC_SETREC_W
:
4359 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4360 curr_srec
->srec
= data
;
4361 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4363 vms_debug2 ((4, "DST_S_C_SRC_SETREC_W: %d\n", data
));
4366 case DST__K_SRC_FORMFEED
:
4368 vms_debug2 ((4, "DST_S_C_SRC_FORMFEED\n"));
4372 _bfd_error_handler (_("unknown source command %d"),
4378 src_ptr
+= cmd_length
;
4382 case DST__K_LINE_NUM
:
4383 pcl_ptr
= ptr
+ DST_S_C_LINE_NUM_HEADER_SIZE
;
4385 vms_debug2 ((3, "line info\n"));
4387 while (pcl_ptr
< ptr
+ rec_length
)
4389 /* The command byte is signed so we must sign-extend it. */
4390 int cmd
= ((signed char *)pcl_ptr
)[0], cmd_length
, data
;
4394 case DST__K_DELTA_PC_W
:
4395 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4399 vms_debug2 ((4, "DST__K_DELTA_PC_W: %d\n", data
));
4402 case DST__K_DELTA_PC_L
:
4403 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4407 vms_debug2 ((4, "DST__K_DELTA_PC_L: %d\n", data
));
4410 case DST__K_INCR_LINUM
:
4411 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4412 curr_linenum
+= data
;
4414 vms_debug2 ((4, "DST__K_INCR_LINUM: %d\n", data
));
4417 case DST__K_INCR_LINUM_W
:
4418 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4419 curr_linenum
+= data
;
4421 vms_debug2 ((4, "DST__K_INCR_LINUM_W: %d\n", data
));
4424 case DST__K_INCR_LINUM_L
:
4425 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4426 curr_linenum
+= data
;
4428 vms_debug2 ((4, "DST__K_INCR_LINUM_L: %d\n", data
));
4431 case DST__K_SET_LINUM_INCR
:
4433 (_("DST__K_SET_LINUM_INCR not implemented"));
4437 case DST__K_SET_LINUM_INCR_W
:
4439 (_("DST__K_SET_LINUM_INCR_W not implemented"));
4443 case DST__K_RESET_LINUM_INCR
:
4445 (_("DST__K_RESET_LINUM_INCR not implemented"));
4449 case DST__K_BEG_STMT_MODE
:
4451 (_("DST__K_BEG_STMT_MODE not implemented"));
4455 case DST__K_END_STMT_MODE
:
4457 (_("DST__K_END_STMT_MODE not implemented"));
4461 case DST__K_SET_LINUM_B
:
4462 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4463 curr_linenum
= data
;
4465 vms_debug2 ((4, "DST__K_SET_LINUM_B: %d\n", data
));
4468 case DST__K_SET_LINUM
:
4469 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4470 curr_linenum
= data
;
4472 vms_debug2 ((4, "DST__K_SET_LINE_NUM: %d\n", data
));
4475 case DST__K_SET_LINUM_L
:
4476 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4477 curr_linenum
= data
;
4479 vms_debug2 ((4, "DST__K_SET_LINUM_L: %d\n", data
));
4484 (_("DST__K_SET_PC not implemented"));
4488 case DST__K_SET_PC_W
:
4490 (_("DST__K_SET_PC_W not implemented"));
4494 case DST__K_SET_PC_L
:
4496 (_("DST__K_SET_PC_L not implemented"));
4500 case DST__K_SET_STMTNUM
:
4502 (_("DST__K_SET_STMTNUM not implemented"));
4507 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4510 vms_debug2 ((4, "DST__K_TERM: %d\n", data
));
4514 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4517 vms_debug2 ((4, "DST__K_TERM_W: %d\n", data
));
4521 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4524 vms_debug2 ((4, "DST__K_TERM_L: %d\n", data
));
4527 case DST__K_SET_ABS_PC
:
4528 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4531 vms_debug2 ((4, "DST__K_SET_ABS_PC: 0x%x\n", data
));
4540 vms_debug2 ((4, "bump pc to 0x%lx and line to %d\n",
4541 (unsigned long)curr_pc
, curr_linenum
));
4545 _bfd_error_handler (_("unknown line command %d"), cmd
);
4551 if ((curr_linenum
!= prev_linum
&& curr_pc
!= prev_pc
)
4553 || cmd
== DST__K_DELTA_PC_L
4554 || cmd
== DST__K_DELTA_PC_W
)
4556 line
= (struct lineinfo
*)
4557 bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4558 line
->address
= curr_pc
;
4559 line
->line
= curr_linenum
;
4561 curr_line
->next
= line
;
4564 prev_linum
= curr_linenum
;
4566 vms_debug2 ((4, "-> correlate pc 0x%lx with line %d\n",
4567 (unsigned long)curr_pc
, curr_linenum
));
4570 pcl_ptr
+= cmd_length
;
4574 case 0x17: /* Undocumented type used by DEC C to declare equates. */
4575 vms_debug2 ((3, "undocumented type 0x17\n"));
4579 vms_debug2 ((3, "ignoring record\n"));
4587 /* Finalize tables with EOL marker. */
4588 srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4589 srec
->line
= (unsigned int) -1;
4590 srec
->srec
= (unsigned int) -1;
4591 curr_srec
->next
= srec
;
4593 line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4594 line
->line
= (unsigned int) -1;
4595 line
->address
= (bfd_vma
) -1;
4596 curr_line
->next
= line
;
4598 /* Advertise that this module has been parsed. This is needed
4599 because parsing can be either performed at module creation
4600 or deferred until debug info is consumed. */
4601 SET_MODULE_PARSED (module
);
4604 /* Build the list of modules for the specified BFD. */
4606 static struct module
*
4607 build_module_list (bfd
*abfd
)
4609 struct module
*module
, *list
= NULL
;
4612 if ((dmt
= bfd_get_section_by_name (abfd
, "$DMT$")))
4614 /* We have a DMT section so this must be an image. Parse the
4615 section and build the list of modules. This is sufficient
4616 since we can compute the start address and the end address
4617 of every module from the section contents. */
4618 bfd_size_type size
= bfd_get_section_size (dmt
);
4619 unsigned char *ptr
, *end
;
4621 ptr
= (unsigned char *) bfd_alloc (abfd
, size
);
4625 if (! bfd_get_section_contents (abfd
, dmt
, ptr
, 0, size
))
4628 vms_debug2 ((2, "DMT\n"));
4634 /* Each header declares a module with its start offset and size
4635 of debug info in the DST section, as well as the count of
4636 program sections (i.e. address spans) it contains. */
4637 int modbeg
= bfd_getl32 (ptr
+ DBG_S_L_DMT_MODBEG
);
4638 int msize
= bfd_getl32 (ptr
+ DBG_S_L_DST_SIZE
);
4639 int count
= bfd_getl16 (ptr
+ DBG_S_W_DMT_PSECT_COUNT
);
4640 ptr
+= DBG_S_C_DMT_HEADER_SIZE
;
4642 vms_debug2 ((3, "module: modbeg = %d, size = %d, count = %d\n",
4643 modbeg
, msize
, count
));
4645 /* We create a 'module' structure for each program section since
4646 we only support contiguous addresses in a 'module' structure.
4647 As a consequence, the actual debug info in the DST section is
4648 shared and can be parsed multiple times; that doesn't seem to
4649 cause problems in practice. */
4652 int start
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_START
);
4653 int length
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_LENGTH
);
4654 module
= new_module (abfd
);
4655 module
->modbeg
= modbeg
;
4656 module
->size
= msize
;
4657 module
->low
= start
;
4658 module
->high
= start
+ length
;
4659 module
->next
= list
;
4661 ptr
+= DBG_S_C_DMT_PSECT_SIZE
;
4663 vms_debug2 ((4, "section: start = 0x%x, length = %d\n",
4670 /* We don't have a DMT section so this must be an object. Parse
4671 the module right now in order to compute its start address and
4673 void *dst
= PRIV (dst_section
)->contents
;
4678 module
= new_module (abfd
);
4679 parse_module (abfd
, module
, PRIV (dst_section
)->contents
, -1);
4686 /* Calculate and return the name of the source file and the line nearest
4687 to the wanted location in the specified module. */
4690 module_find_nearest_line (bfd
*abfd
, struct module
*module
, bfd_vma addr
,
4691 const char **file
, const char **func
,
4694 struct funcinfo
*funcinfo
;
4695 struct lineinfo
*lineinfo
;
4696 struct srecinfo
*srecinfo
;
4697 bfd_boolean ret
= FALSE
;
4699 /* Parse this module if that was not done at module creation. */
4700 if (! IS_MODULE_PARSED (module
))
4702 unsigned int size
= module
->size
;
4703 unsigned int modbeg
= PRIV (dst_section
)->filepos
+ module
->modbeg
;
4704 unsigned char *buffer
= (unsigned char *) bfd_malloc (module
->size
);
4706 if (bfd_seek (abfd
, modbeg
, SEEK_SET
) != 0
4707 || bfd_bread (buffer
, size
, abfd
) != size
)
4709 bfd_set_error (bfd_error_no_debug_section
);
4713 parse_module (abfd
, module
, buffer
, size
);
4717 /* Find out the function (if any) that contains the address. */
4718 for (funcinfo
= module
->func_table
; funcinfo
; funcinfo
= funcinfo
->next
)
4719 if (addr
>= funcinfo
->low
&& addr
<= funcinfo
->high
)
4721 *func
= funcinfo
->name
;
4726 /* Find out the source file and the line nearest to the address. */
4727 for (lineinfo
= module
->line_table
; lineinfo
; lineinfo
= lineinfo
->next
)
4728 if (lineinfo
->next
&& addr
< lineinfo
->next
->address
)
4730 for (srecinfo
= module
->srec_table
; srecinfo
; srecinfo
= srecinfo
->next
)
4731 if (srecinfo
->next
&& lineinfo
->line
< srecinfo
->next
->line
)
4733 if (srecinfo
->sfile
> 0)
4735 *file
= module
->file_table
[srecinfo
->sfile
].name
;
4736 *line
= srecinfo
->srec
+ lineinfo
->line
- srecinfo
->line
;
4740 *file
= module
->name
;
4741 *line
= lineinfo
->line
;
4752 /* Provided a BFD, a section and an offset into the section, calculate and
4753 return the name of the source file and the line nearest to the wanted
4757 _bfd_vms_find_nearest_line (bfd
*abfd
,
4758 asymbol
**symbols ATTRIBUTE_UNUSED
,
4764 unsigned int *discriminator
)
4766 struct module
*module
;
4768 /* What address are we looking for? */
4769 bfd_vma addr
= section
->vma
+ offset
;
4777 /* We can't do anything if there is no DST (debug symbol table). */
4778 if (PRIV (dst_section
) == NULL
)
4781 /* Create the module list - if not already done. */
4782 if (PRIV (modules
) == NULL
)
4784 PRIV (modules
) = build_module_list (abfd
);
4785 if (PRIV (modules
) == NULL
)
4789 for (module
= PRIV (modules
); module
; module
= module
->next
)
4790 if (addr
>= module
->low
&& addr
<= module
->high
)
4791 return module_find_nearest_line (abfd
, module
, addr
, file
, func
, line
);
4796 /* Canonicalizations. */
4797 /* Set name, value, section and flags of SYM from E. */
4800 alpha_vms_convert_symbol (bfd
*abfd
, struct vms_symbol_entry
*e
, asymbol
*sym
)
4809 flags
= BSF_NO_FLAGS
;
4815 if (e
->flags
& EGSY__V_WEAK
)
4818 if (e
->flags
& EGSY__V_DEF
)
4820 /* Symbol definition. */
4821 flags
|= BSF_GLOBAL
;
4822 if (e
->flags
& EGSY__V_NORM
)
4823 flags
|= BSF_FUNCTION
;
4829 /* Symbol reference. */
4830 sec
= bfd_und_section_ptr
;
4835 /* A universal symbol is by definition global... */
4836 flags
|= BSF_GLOBAL
;
4838 /* ...and dynamic in shared libraries. */
4839 if (abfd
->flags
& DYNAMIC
)
4840 flags
|= BSF_DYNAMIC
;
4842 if (e
->flags
& EGSY__V_WEAK
)
4845 if (!(e
->flags
& EGSY__V_DEF
))
4848 if (e
->flags
& EGSY__V_NORM
)
4849 flags
|= BSF_FUNCTION
;
4852 /* sec = e->section; */
4853 sec
= bfd_abs_section_ptr
;
4868 /* Return the number of bytes required to store a vector of pointers
4869 to asymbols for all the symbols in the BFD abfd, including a
4870 terminal NULL pointer. If there are no symbols in the BFD,
4871 then return 0. If an error occurs, return -1. */
4874 alpha_vms_get_symtab_upper_bound (bfd
*abfd
)
4876 vms_debug2 ((1, "alpha_vms_get_symtab_upper_bound (%p), %d symbols\n",
4877 abfd
, PRIV (gsd_sym_count
)));
4879 return (PRIV (gsd_sym_count
) + 1) * sizeof (asymbol
*);
4882 /* Read the symbols from the BFD abfd, and fills in the vector
4883 location with pointers to the symbols and a trailing NULL.
4885 Return number of symbols read. */
4888 alpha_vms_canonicalize_symtab (bfd
*abfd
, asymbol
**symbols
)
4892 vms_debug2 ((1, "alpha_vms_canonicalize_symtab (%p, <ret>)\n", abfd
));
4894 if (PRIV (csymbols
) == NULL
)
4896 PRIV (csymbols
) = (asymbol
**) bfd_alloc
4897 (abfd
, PRIV (gsd_sym_count
) * sizeof (asymbol
*));
4899 /* Traverse table and fill symbols vector. */
4900 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
4902 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
4905 sym
= bfd_make_empty_symbol (abfd
);
4906 if (sym
== NULL
|| !alpha_vms_convert_symbol (abfd
, e
, sym
))
4908 bfd_release (abfd
, PRIV (csymbols
));
4909 PRIV (csymbols
) = NULL
;
4913 PRIV (csymbols
)[i
] = sym
;
4917 if (symbols
!= NULL
)
4919 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
4920 symbols
[i
] = PRIV (csymbols
)[i
];
4924 return PRIV (gsd_sym_count
);
4927 /* Read and convert relocations from ETIR. We do it once for all sections. */
4930 alpha_vms_slurp_relocs (bfd
*abfd
)
4934 vms_debug2 ((3, "alpha_vms_slurp_relocs\n"));
4936 /* We slurp relocs only once, for all sections. */
4937 if (PRIV (reloc_done
))
4939 PRIV (reloc_done
) = TRUE
;
4941 if (alpha_vms_canonicalize_symtab (abfd
, NULL
) < 0)
4944 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
4949 unsigned char *begin
;
4952 bfd_reloc_code_real_type reloc_code
;
4958 bfd_vma cur_address
;
4960 unsigned char *cur_sym
= NULL
;
4962 bfd_vma cur_addend
= 0;
4964 /* Skip non-ETIR records. */
4965 type
= _bfd_vms_get_object_record (abfd
);
4966 if (type
== EOBJ__C_EEOM
)
4968 if (type
!= EOBJ__C_ETIR
)
4971 begin
= PRIV (recrd
.rec
) + 4;
4972 end
= PRIV (recrd
.rec
) + PRIV (recrd
.rec_size
);
4974 for (ptr
= begin
; ptr
< end
; ptr
+= length
)
4978 cmd
= bfd_getl16 (ptr
);
4979 length
= bfd_getl16 (ptr
+ 2);
4981 cur_address
= vaddr
;
4983 vms_debug2 ((4, "alpha_vms_slurp_relocs: etir %s\n",
4984 _bfd_vms_etir_name (cmd
)));
4988 case ETIR__C_STA_GBL
: /* ALPHA_R_REFLONG und_section, step 1 */
4989 /* ALPHA_R_REFQUAD und_section, step 1 */
4994 case ETIR__C_STA_PQ
: /* ALPHA_R_REF{LONG|QUAD}, others part 1 */
4995 cur_psidx
= bfd_getl32 (ptr
+ 4);
4996 cur_addend
= bfd_getl64 (ptr
+ 8);
5000 case ETIR__C_CTL_SETRB
:
5001 if (prev_cmd
!= ETIR__C_STA_PQ
)
5004 /* xgettext:c-format */
5005 (_("Unknown reloc %s + %s"), _bfd_vms_etir_name (prev_cmd
),
5006 _bfd_vms_etir_name (cmd
));
5009 cur_psect
= cur_psidx
;
5015 case ETIR__C_STA_LW
: /* ALPHA_R_REFLONG abs_section, step 1 */
5016 /* ALPHA_R_REFLONG und_section, step 2 */
5019 if (prev_cmd
!= ETIR__C_STA_GBL
)
5022 /* xgettext:c-format */
5023 (_("Unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
5024 _bfd_vms_etir_name (ETIR__C_STA_LW
));
5028 cur_addend
= bfd_getl32 (ptr
+ 4);
5032 case ETIR__C_STA_QW
: /* ALPHA_R_REFQUAD abs_section, step 1 */
5033 /* ALPHA_R_REFQUAD und_section, step 2 */
5034 if (prev_cmd
!= -1 && prev_cmd
!= ETIR__C_STA_GBL
)
5037 /* xgettext:c-format */
5038 (_("Unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
5039 _bfd_vms_etir_name (ETIR__C_STA_QW
));
5042 cur_addend
= bfd_getl64 (ptr
+ 4);
5046 case ETIR__C_STO_LW
: /* ALPHA_R_REFLONG und_section, step 4 */
5047 /* ALPHA_R_REFLONG abs_section, step 2 */
5048 /* ALPHA_R_REFLONG others, step 2 */
5049 if (prev_cmd
!= ETIR__C_OPR_ADD
5050 && prev_cmd
!= ETIR__C_STA_LW
5051 && prev_cmd
!= ETIR__C_STA_PQ
)
5053 /* xgettext:c-format */
5054 _bfd_error_handler (_("Unknown reloc %s + %s"),
5055 _bfd_vms_etir_name (prev_cmd
),
5056 _bfd_vms_etir_name (ETIR__C_STO_LW
));
5059 reloc_code
= BFD_RELOC_32
;
5062 case ETIR__C_STO_QW
: /* ALPHA_R_REFQUAD und_section, step 4 */
5063 /* ALPHA_R_REFQUAD abs_section, step 2 */
5064 if (prev_cmd
!= ETIR__C_OPR_ADD
&& prev_cmd
!= ETIR__C_STA_QW
)
5066 /* xgettext:c-format */
5067 _bfd_error_handler (_("Unknown reloc %s + %s"),
5068 _bfd_vms_etir_name (prev_cmd
),
5069 _bfd_vms_etir_name (ETIR__C_STO_QW
));
5072 reloc_code
= BFD_RELOC_64
;
5075 case ETIR__C_STO_OFF
: /* ALPHA_R_REFQUAD others, step 2 */
5076 if (prev_cmd
!= ETIR__C_STA_PQ
)
5078 /* xgettext:c-format */
5079 _bfd_error_handler (_("Unknown reloc %s + %s"),
5080 _bfd_vms_etir_name (prev_cmd
),
5081 _bfd_vms_etir_name (ETIR__C_STO_OFF
));
5084 reloc_code
= BFD_RELOC_64
;
5087 case ETIR__C_OPR_ADD
: /* ALPHA_R_REFLONG und_section, step 3 */
5088 /* ALPHA_R_REFQUAD und_section, step 3 */
5089 if (prev_cmd
!= ETIR__C_STA_LW
&& prev_cmd
!= ETIR__C_STA_QW
)
5091 /* xgettext:c-format */
5092 _bfd_error_handler (_("Unknown reloc %s + %s"),
5093 _bfd_vms_etir_name (prev_cmd
),
5094 _bfd_vms_etir_name (ETIR__C_OPR_ADD
));
5097 prev_cmd
= ETIR__C_OPR_ADD
;
5100 case ETIR__C_STO_CA
: /* ALPHA_R_CODEADDR */
5101 reloc_code
= BFD_RELOC_ALPHA_CODEADDR
;
5105 case ETIR__C_STO_GBL
: /* ALPHA_R_REFQUAD und_section */
5106 reloc_code
= BFD_RELOC_64
;
5110 case ETIR__C_STO_GBL_LW
: /* ALPHA_R_REFLONG und_section */
5111 reloc_code
= BFD_RELOC_32
;
5115 case ETIR__C_STC_LP_PSB
: /* ALPHA_R_LINKAGE */
5116 reloc_code
= BFD_RELOC_ALPHA_LINKAGE
;
5120 case ETIR__C_STC_NOP_GBL
: /* ALPHA_R_NOP */
5121 reloc_code
= BFD_RELOC_ALPHA_NOP
;
5124 case ETIR__C_STC_BSR_GBL
: /* ALPHA_R_BSR */
5125 reloc_code
= BFD_RELOC_ALPHA_BSR
;
5128 case ETIR__C_STC_LDA_GBL
: /* ALPHA_R_LDA */
5129 reloc_code
= BFD_RELOC_ALPHA_LDA
;
5132 case ETIR__C_STC_BOH_GBL
: /* ALPHA_R_BOH */
5133 reloc_code
= BFD_RELOC_ALPHA_BOH
;
5137 cur_sym
= ptr
+ 4 + 32;
5138 cur_address
= bfd_getl64 (ptr
+ 4 + 8);
5139 cur_addend
= bfd_getl64 (ptr
+ 4 + 24);
5142 case ETIR__C_STO_IMM
:
5143 vaddr
+= bfd_getl32 (ptr
+ 4);
5147 _bfd_error_handler (_("Unknown reloc %s"),
5148 _bfd_vms_etir_name (cmd
));
5154 struct vms_section_data_struct
*vms_sec
;
5157 /* Get section to which the relocation applies. */
5158 if (cur_psect
< 0 || cur_psect
> (int)PRIV (section_count
))
5160 _bfd_error_handler (_("Invalid section index in ETIR"));
5164 if (PRIV (sections
) == NULL
)
5166 sec
= PRIV (sections
)[cur_psect
];
5167 if (sec
== bfd_abs_section_ptr
)
5169 _bfd_error_handler (_("Relocation for non-REL psect"));
5173 vms_sec
= vms_section_data (sec
);
5175 /* Allocate a reloc entry. */
5176 if (sec
->reloc_count
>= vms_sec
->reloc_max
)
5178 if (vms_sec
->reloc_max
== 0)
5180 vms_sec
->reloc_max
= 64;
5181 sec
->relocation
= bfd_zmalloc
5182 (vms_sec
->reloc_max
* sizeof (arelent
));
5186 vms_sec
->reloc_max
*= 2;
5187 sec
->relocation
= bfd_realloc
5188 (sec
->relocation
, vms_sec
->reloc_max
* sizeof (arelent
));
5191 reloc
= &sec
->relocation
[sec
->reloc_count
];
5194 reloc
->howto
= bfd_reloc_type_lookup (abfd
, reloc_code
);
5196 if (cur_sym
!= NULL
)
5199 unsigned int symlen
= *cur_sym
;
5202 /* Linear search. */
5207 for (j
= 0; j
< PRIV (gsd_sym_count
); j
++)
5208 if (PRIV (syms
)[j
]->namelen
== symlen
5209 && memcmp (PRIV (syms
)[j
]->name
, cur_sym
, symlen
) == 0)
5211 sym
= &PRIV (csymbols
)[j
];
5216 _bfd_error_handler (_("Unknown symbol in command %s"),
5217 _bfd_vms_etir_name (cmd
));
5218 reloc
->sym_ptr_ptr
= NULL
;
5221 reloc
->sym_ptr_ptr
= sym
;
5223 else if (cur_psidx
>= 0)
5225 if (PRIV (sections
) == NULL
|| cur_psidx
>= (int) PRIV (section_count
))
5227 reloc
->sym_ptr_ptr
=
5228 PRIV (sections
)[cur_psidx
]->symbol_ptr_ptr
;
5231 reloc
->sym_ptr_ptr
= NULL
;
5233 reloc
->address
= cur_address
;
5234 reloc
->addend
= cur_addend
;
5236 vaddr
+= bfd_get_reloc_size (reloc
->howto
);
5245 vms_debug2 ((3, "alpha_vms_slurp_relocs: result = TRUE\n"));
5250 /* Return the number of bytes required to store the relocation
5251 information associated with the given section. */
5254 alpha_vms_get_reloc_upper_bound (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*section
)
5256 alpha_vms_slurp_relocs (abfd
);
5258 return (section
->reloc_count
+ 1) * sizeof (arelent
*);
5261 /* Convert relocations from VMS (external) form into BFD internal
5262 form. Return the number of relocations. */
5265 alpha_vms_canonicalize_reloc (bfd
*abfd
, asection
*section
, arelent
**relptr
,
5266 asymbol
**symbols ATTRIBUTE_UNUSED
)
5271 if (!alpha_vms_slurp_relocs (abfd
))
5274 count
= section
->reloc_count
;
5275 tblptr
= section
->relocation
;
5278 *relptr
++ = tblptr
++;
5280 *relptr
= (arelent
*) NULL
;
5281 return section
->reloc_count
;
5284 /* Install a new set of internal relocs. */
5286 #define alpha_vms_set_reloc _bfd_generic_set_reloc
5289 /* This is just copied from ecoff-alpha, needs to be fixed probably. */
5291 /* How to process the various reloc types. */
5293 static bfd_reloc_status_type
5294 reloc_nil (bfd
* abfd ATTRIBUTE_UNUSED
,
5295 arelent
*reloc ATTRIBUTE_UNUSED
,
5296 asymbol
*sym ATTRIBUTE_UNUSED
,
5297 void * data ATTRIBUTE_UNUSED
,
5298 asection
*sec ATTRIBUTE_UNUSED
,
5299 bfd
*output_bfd ATTRIBUTE_UNUSED
,
5300 char **error_message ATTRIBUTE_UNUSED
)
5303 vms_debug (1, "reloc_nil (abfd %p, output_bfd %p)\n", abfd
, output_bfd
);
5304 vms_debug (2, "In section %s, symbol %s\n",
5305 sec
->name
, sym
->name
);
5306 vms_debug (2, "reloc sym %s, addr %08lx, addend %08lx, reloc is a %s\n",
5307 reloc
->sym_ptr_ptr
[0]->name
,
5308 (unsigned long)reloc
->address
,
5309 (unsigned long)reloc
->addend
, reloc
->howto
->name
);
5310 vms_debug (2, "data at %p\n", data
);
5311 /* _bfd_hexdump (2, data, bfd_get_reloc_size (reloc->howto), 0); */
5314 return bfd_reloc_ok
;
5317 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
5318 from smaller values. Start with zero, widen, *then* decrement. */
5319 #define MINUS_ONE (((bfd_vma)0) - 1)
5321 static reloc_howto_type alpha_howto_table
[] =
5323 HOWTO (ALPHA_R_IGNORE
, /* Type. */
5324 0, /* Rightshift. */
5325 0, /* Size (0 = byte, 1 = short, 2 = long). */
5327 TRUE
, /* PC relative. */
5329 complain_overflow_dont
,/* Complain_on_overflow. */
5330 reloc_nil
, /* Special_function. */
5331 "IGNORE", /* Name. */
5332 TRUE
, /* Partial_inplace. */
5333 0, /* Source mask */
5335 TRUE
), /* PC rel offset. */
5337 /* A 64 bit reference to a symbol. */
5338 HOWTO (ALPHA_R_REFQUAD
, /* Type. */
5339 0, /* Rightshift. */
5340 4, /* Size (0 = byte, 1 = short, 2 = long). */
5342 FALSE
, /* PC relative. */
5344 complain_overflow_bitfield
, /* Complain_on_overflow. */
5345 reloc_nil
, /* Special_function. */
5346 "REFQUAD", /* Name. */
5347 TRUE
, /* Partial_inplace. */
5348 MINUS_ONE
, /* Source mask. */
5349 MINUS_ONE
, /* Dest mask. */
5350 FALSE
), /* PC rel offset. */
5352 /* A 21 bit branch. The native assembler generates these for
5353 branches within the text segment, and also fills in the PC
5354 relative offset in the instruction. */
5355 HOWTO (ALPHA_R_BRADDR
, /* Type. */
5356 2, /* Rightshift. */
5357 2, /* Size (0 = byte, 1 = short, 2 = long). */
5359 TRUE
, /* PC relative. */
5361 complain_overflow_signed
, /* Complain_on_overflow. */
5362 reloc_nil
, /* Special_function. */
5363 "BRADDR", /* Name. */
5364 TRUE
, /* Partial_inplace. */
5365 0x1fffff, /* Source mask. */
5366 0x1fffff, /* Dest mask. */
5367 FALSE
), /* PC rel offset. */
5369 /* A hint for a jump to a register. */
5370 HOWTO (ALPHA_R_HINT
, /* Type. */
5371 2, /* Rightshift. */
5372 1, /* Size (0 = byte, 1 = short, 2 = long). */
5374 TRUE
, /* PC relative. */
5376 complain_overflow_dont
,/* Complain_on_overflow. */
5377 reloc_nil
, /* Special_function. */
5379 TRUE
, /* Partial_inplace. */
5380 0x3fff, /* Source mask. */
5381 0x3fff, /* Dest mask. */
5382 FALSE
), /* PC rel offset. */
5384 /* 16 bit PC relative offset. */
5385 HOWTO (ALPHA_R_SREL16
, /* Type. */
5386 0, /* Rightshift. */
5387 1, /* Size (0 = byte, 1 = short, 2 = long). */
5389 TRUE
, /* PC relative. */
5391 complain_overflow_signed
, /* Complain_on_overflow. */
5392 reloc_nil
, /* Special_function. */
5393 "SREL16", /* Name. */
5394 TRUE
, /* Partial_inplace. */
5395 0xffff, /* Source mask. */
5396 0xffff, /* Dest mask. */
5397 FALSE
), /* PC rel offset. */
5399 /* 32 bit PC relative offset. */
5400 HOWTO (ALPHA_R_SREL32
, /* Type. */
5401 0, /* 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 "SREL32", /* Name. */
5409 TRUE
, /* Partial_inplace. */
5410 0xffffffff, /* Source mask. */
5411 0xffffffff, /* Dest mask. */
5412 FALSE
), /* PC rel offset. */
5414 /* A 64 bit PC relative offset. */
5415 HOWTO (ALPHA_R_SREL64
, /* Type. */
5416 0, /* Rightshift. */
5417 4, /* Size (0 = byte, 1 = short, 2 = long). */
5419 TRUE
, /* PC relative. */
5421 complain_overflow_signed
, /* Complain_on_overflow. */
5422 reloc_nil
, /* Special_function. */
5423 "SREL64", /* Name. */
5424 TRUE
, /* Partial_inplace. */
5425 MINUS_ONE
, /* Source mask. */
5426 MINUS_ONE
, /* Dest mask. */
5427 FALSE
), /* PC rel offset. */
5429 /* Push a value on the reloc evaluation stack. */
5430 HOWTO (ALPHA_R_OP_PUSH
, /* Type. */
5431 0, /* Rightshift. */
5432 0, /* Size (0 = byte, 1 = short, 2 = long). */
5434 FALSE
, /* PC relative. */
5436 complain_overflow_dont
,/* Complain_on_overflow. */
5437 reloc_nil
, /* Special_function. */
5438 "OP_PUSH", /* Name. */
5439 FALSE
, /* Partial_inplace. */
5440 0, /* Source mask. */
5442 FALSE
), /* PC rel offset. */
5444 /* Store the value from the stack at the given address. Store it in
5445 a bitfield of size r_size starting at bit position r_offset. */
5446 HOWTO (ALPHA_R_OP_STORE
, /* Type. */
5447 0, /* Rightshift. */
5448 4, /* Size (0 = byte, 1 = short, 2 = long). */
5450 FALSE
, /* PC relative. */
5452 complain_overflow_dont
,/* Complain_on_overflow. */
5453 reloc_nil
, /* Special_function. */
5454 "OP_STORE", /* Name. */
5455 FALSE
, /* Partial_inplace. */
5456 0, /* Source mask. */
5457 MINUS_ONE
, /* Dest mask. */
5458 FALSE
), /* PC rel offset. */
5460 /* Subtract the reloc address from the value on the top of the
5461 relocation stack. */
5462 HOWTO (ALPHA_R_OP_PSUB
, /* Type. */
5463 0, /* Rightshift. */
5464 0, /* Size (0 = byte, 1 = short, 2 = long). */
5466 FALSE
, /* PC relative. */
5468 complain_overflow_dont
,/* Complain_on_overflow. */
5469 reloc_nil
, /* Special_function. */
5470 "OP_PSUB", /* Name. */
5471 FALSE
, /* Partial_inplace. */
5472 0, /* Source mask. */
5474 FALSE
), /* PC rel offset. */
5476 /* Shift the value on the top of the relocation stack right by the
5478 HOWTO (ALPHA_R_OP_PRSHIFT
, /* Type. */
5479 0, /* Rightshift. */
5480 0, /* Size (0 = byte, 1 = short, 2 = long). */
5482 FALSE
, /* PC relative. */
5484 complain_overflow_dont
,/* Complain_on_overflow. */
5485 reloc_nil
, /* Special_function. */
5486 "OP_PRSHIFT", /* Name. */
5487 FALSE
, /* Partial_inplace. */
5488 0, /* Source mask. */
5490 FALSE
), /* PC rel offset. */
5492 /* Hack. Linkage is done by linker. */
5493 HOWTO (ALPHA_R_LINKAGE
, /* Type. */
5494 0, /* Rightshift. */
5495 8, /* Size (0 = byte, 1 = short, 2 = long). */
5497 FALSE
, /* PC relative. */
5499 complain_overflow_dont
,/* Complain_on_overflow. */
5500 reloc_nil
, /* Special_function. */
5501 "LINKAGE", /* Name. */
5502 FALSE
, /* Partial_inplace. */
5503 0, /* Source mask. */
5505 FALSE
), /* PC rel offset. */
5507 /* A 32 bit reference to a symbol. */
5508 HOWTO (ALPHA_R_REFLONG
, /* Type. */
5509 0, /* Rightshift. */
5510 2, /* Size (0 = byte, 1 = short, 2 = long). */
5512 FALSE
, /* PC relative. */
5514 complain_overflow_bitfield
, /* Complain_on_overflow. */
5515 reloc_nil
, /* Special_function. */
5516 "REFLONG", /* Name. */
5517 TRUE
, /* Partial_inplace. */
5518 0xffffffff, /* Source mask. */
5519 0xffffffff, /* Dest mask. */
5520 FALSE
), /* PC rel offset. */
5522 /* A 64 bit reference to a procedure, written as 32 bit value. */
5523 HOWTO (ALPHA_R_CODEADDR
, /* Type. */
5524 0, /* Rightshift. */
5525 4, /* Size (0 = byte, 1 = short, 2 = long). */
5527 FALSE
, /* PC relative. */
5529 complain_overflow_signed
,/* Complain_on_overflow. */
5530 reloc_nil
, /* Special_function. */
5531 "CODEADDR", /* Name. */
5532 FALSE
, /* Partial_inplace. */
5533 0xffffffff, /* Source mask. */
5534 0xffffffff, /* Dest mask. */
5535 FALSE
), /* PC rel offset. */
5537 HOWTO (ALPHA_R_NOP
, /* Type. */
5538 0, /* Rightshift. */
5539 3, /* Size (0 = byte, 1 = short, 2 = long). */
5541 /* The following value must match that of ALPHA_R_BSR/ALPHA_R_BOH
5542 because the calculations for the 3 relocations are the same.
5543 See B.4.5.2 of the OpenVMS Linker Utility Manual. */
5544 TRUE
, /* PC relative. */
5546 complain_overflow_dont
,/* Complain_on_overflow. */
5547 reloc_nil
, /* Special_function. */
5549 FALSE
, /* Partial_inplace. */
5550 0xffffffff, /* Source mask. */
5551 0xffffffff, /* Dest mask. */
5552 FALSE
), /* PC rel offset. */
5554 HOWTO (ALPHA_R_BSR
, /* Type. */
5555 0, /* Rightshift. */
5556 3, /* Size (0 = byte, 1 = short, 2 = long). */
5558 TRUE
, /* PC relative. */
5560 complain_overflow_dont
,/* Complain_on_overflow. */
5561 reloc_nil
, /* Special_function. */
5563 FALSE
, /* Partial_inplace. */
5564 0xffffffff, /* Source mask. */
5565 0xffffffff, /* Dest mask. */
5566 FALSE
), /* PC rel offset. */
5568 HOWTO (ALPHA_R_LDA
, /* Type. */
5569 0, /* Rightshift. */
5570 3, /* Size (0 = byte, 1 = short, 2 = long). */
5572 FALSE
, /* PC relative. */
5574 complain_overflow_dont
,/* Complain_on_overflow. */
5575 reloc_nil
, /* Special_function. */
5577 FALSE
, /* Partial_inplace. */
5578 0xffffffff, /* Source mask. */
5579 0xffffffff, /* Dest mask. */
5580 FALSE
), /* PC rel offset. */
5582 HOWTO (ALPHA_R_BOH
, /* Type. */
5583 0, /* Rightshift. */
5584 3, /* Size (0 = byte, 1 = short, 2 = long, 3 = nil). */
5586 TRUE
, /* PC relative. */
5588 complain_overflow_dont
,/* Complain_on_overflow. */
5589 reloc_nil
, /* Special_function. */
5591 FALSE
, /* Partial_inplace. */
5592 0xffffffff, /* Source mask. */
5593 0xffffffff, /* Dest mask. */
5594 FALSE
), /* PC rel offset. */
5597 /* Return a pointer to a howto structure which, when invoked, will perform
5598 the relocation code on data from the architecture noted. */
5600 static const struct reloc_howto_struct
*
5601 alpha_vms_bfd_reloc_type_lookup (bfd
* abfd ATTRIBUTE_UNUSED
,
5602 bfd_reloc_code_real_type code
)
5606 vms_debug2 ((1, "vms_bfd_reloc_type_lookup (%p, %d)\t", abfd
, code
));
5610 case BFD_RELOC_16
: alpha_type
= ALPHA_R_SREL16
; break;
5611 case BFD_RELOC_32
: alpha_type
= ALPHA_R_REFLONG
; break;
5612 case BFD_RELOC_64
: alpha_type
= ALPHA_R_REFQUAD
; break;
5613 case BFD_RELOC_CTOR
: alpha_type
= ALPHA_R_REFQUAD
; break;
5614 case BFD_RELOC_23_PCREL_S2
: alpha_type
= ALPHA_R_BRADDR
; break;
5615 case BFD_RELOC_ALPHA_HINT
: alpha_type
= ALPHA_R_HINT
; break;
5616 case BFD_RELOC_16_PCREL
: alpha_type
= ALPHA_R_SREL16
; break;
5617 case BFD_RELOC_32_PCREL
: alpha_type
= ALPHA_R_SREL32
; break;
5618 case BFD_RELOC_64_PCREL
: alpha_type
= ALPHA_R_SREL64
; break;
5619 case BFD_RELOC_ALPHA_LINKAGE
: alpha_type
= ALPHA_R_LINKAGE
; break;
5620 case BFD_RELOC_ALPHA_CODEADDR
: alpha_type
= ALPHA_R_CODEADDR
; break;
5621 case BFD_RELOC_ALPHA_NOP
: alpha_type
= ALPHA_R_NOP
; break;
5622 case BFD_RELOC_ALPHA_BSR
: alpha_type
= ALPHA_R_BSR
; break;
5623 case BFD_RELOC_ALPHA_LDA
: alpha_type
= ALPHA_R_LDA
; break;
5624 case BFD_RELOC_ALPHA_BOH
: alpha_type
= ALPHA_R_BOH
; break;
5626 _bfd_error_handler (_("reloc (%d) is *UNKNOWN*"), code
);
5629 vms_debug2 ((2, "reloc is %s\n", alpha_howto_table
[alpha_type
].name
));
5630 return & alpha_howto_table
[alpha_type
];
5633 static reloc_howto_type
*
5634 alpha_vms_bfd_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
5640 i
< sizeof (alpha_howto_table
) / sizeof (alpha_howto_table
[0]);
5642 if (alpha_howto_table
[i
].name
!= NULL
5643 && strcasecmp (alpha_howto_table
[i
].name
, r_name
) == 0)
5644 return &alpha_howto_table
[i
];
5650 alpha_vms_get_synthetic_symtab (bfd
*abfd
,
5651 long symcount ATTRIBUTE_UNUSED
,
5652 asymbol
**usyms ATTRIBUTE_UNUSED
,
5653 long dynsymcount ATTRIBUTE_UNUSED
,
5654 asymbol
**dynsyms ATTRIBUTE_UNUSED
,
5661 syms
= (asymbol
*) bfd_malloc (PRIV (norm_sym_count
) * sizeof (asymbol
));
5666 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
5668 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
5679 flags
= BSF_LOCAL
| BSF_SYNTHETIC
;
5686 if ((e
->flags
& EGSY__V_DEF
) && (e
->flags
& EGSY__V_NORM
))
5688 value
= e
->code_value
;
5689 sec
= e
->code_section
;
5700 sname
= bfd_alloc (abfd
, l
+ 5);
5703 memcpy (sname
, name
, l
);
5704 memcpy (sname
+ l
, "..en", 5);
5711 sym
->udata
.p
= NULL
;
5720 vms_time_to_str (unsigned char *buf
)
5722 time_t t
= vms_rawtime_to_time_t (buf
);
5723 char *res
= ctime (&t
);
5726 res
= "*invalid time*";
5733 evax_bfd_print_emh (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5735 struct vms_emh_common
*emh
= (struct vms_emh_common
*)rec
;
5736 unsigned int subtype
;
5738 subtype
= (unsigned)bfd_getl16 (emh
->subtyp
);
5740 /* xgettext:c-format */
5741 fprintf (file
, _(" EMH %u (len=%u): "), subtype
, rec_len
);
5743 /* PR 21618: Check for invalid lengths. */
5744 if (rec_len
< sizeof (* emh
))
5746 fprintf (file
, _(" Error: The length is less than the length of an EMH record\n"));
5754 struct vms_emh_mhd
*mhd
= (struct vms_emh_mhd
*)rec
;
5757 fprintf (file
, _("Module header\n"));
5758 fprintf (file
, _(" structure level: %u\n"), mhd
->strlvl
);
5759 fprintf (file
, _(" max record size: %u\n"),
5760 (unsigned)bfd_getl32 (mhd
->recsiz
));
5761 name
= (char *)(mhd
+ 1);
5762 fprintf (file
, _(" module name : %.*s\n"), name
[0], name
+ 1);
5763 name
+= name
[0] + 1;
5764 fprintf (file
, _(" module version : %.*s\n"), name
[0], name
+ 1);
5765 name
+= name
[0] + 1;
5766 fprintf (file
, _(" compile date : %.17s\n"), name
);
5771 fprintf (file
, _("Language Processor Name\n"));
5772 fprintf (file
, _(" language name: %.*s\n"),
5773 (int)(rec_len
- sizeof (struct vms_emh_common
)),
5774 (char *)rec
+ sizeof (struct vms_emh_common
));
5779 fprintf (file
, _("Source Files Header\n"));
5780 fprintf (file
, _(" file: %.*s\n"),
5781 (int)(rec_len
- sizeof (struct vms_emh_common
)),
5782 (char *)rec
+ sizeof (struct vms_emh_common
));
5787 fprintf (file
, _("Title Text Header\n"));
5788 fprintf (file
, _(" title: %.*s\n"),
5789 (int)(rec_len
- sizeof (struct vms_emh_common
)),
5790 (char *)rec
+ sizeof (struct vms_emh_common
));
5795 fprintf (file
, _("Copyright Header\n"));
5796 fprintf (file
, _(" copyright: %.*s\n"),
5797 (int)(rec_len
- sizeof (struct vms_emh_common
)),
5798 (char *)rec
+ sizeof (struct vms_emh_common
));
5802 fprintf (file
, _("unhandled emh subtype %u\n"), subtype
);
5808 evax_bfd_print_eeom (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5810 struct vms_eeom
*eeom
= (struct vms_eeom
*)rec
;
5812 fprintf (file
, _(" EEOM (len=%u):\n"), rec_len
);
5814 /* PR 21618: Check for invalid lengths. */
5815 if (rec_len
< sizeof (* eeom
))
5817 fprintf (file
, _(" Error: The length is less than the length of an EEOM record\n"));
5821 fprintf (file
, _(" number of cond linkage pairs: %u\n"),
5822 (unsigned)bfd_getl32 (eeom
->total_lps
));
5823 fprintf (file
, _(" completion code: %u\n"),
5824 (unsigned)bfd_getl16 (eeom
->comcod
));
5827 fprintf (file
, _(" transfer addr flags: 0x%02x\n"), eeom
->tfrflg
);
5828 fprintf (file
, _(" transfer addr psect: %u\n"),
5829 (unsigned)bfd_getl32 (eeom
->psindx
));
5830 fprintf (file
, _(" transfer address : 0x%08x\n"),
5831 (unsigned)bfd_getl32 (eeom
->tfradr
));
5836 exav_bfd_print_egsy_flags (unsigned int flags
, FILE *file
)
5838 if (flags
& EGSY__V_WEAK
)
5839 fputs (_(" WEAK"), file
);
5840 if (flags
& EGSY__V_DEF
)
5841 fputs (_(" DEF"), file
);
5842 if (flags
& EGSY__V_UNI
)
5843 fputs (_(" UNI"), file
);
5844 if (flags
& EGSY__V_REL
)
5845 fputs (_(" REL"), file
);
5846 if (flags
& EGSY__V_COMM
)
5847 fputs (_(" COMM"), file
);
5848 if (flags
& EGSY__V_VECEP
)
5849 fputs (_(" VECEP"), file
);
5850 if (flags
& EGSY__V_NORM
)
5851 fputs (_(" NORM"), file
);
5852 if (flags
& EGSY__V_QUAD_VAL
)
5853 fputs (_(" QVAL"), file
);
5857 evax_bfd_print_egsd_flags (FILE *file
, unsigned int flags
)
5859 if (flags
& EGPS__V_PIC
)
5860 fputs (_(" PIC"), file
);
5861 if (flags
& EGPS__V_LIB
)
5862 fputs (_(" LIB"), file
);
5863 if (flags
& EGPS__V_OVR
)
5864 fputs (_(" OVR"), file
);
5865 if (flags
& EGPS__V_REL
)
5866 fputs (_(" REL"), file
);
5867 if (flags
& EGPS__V_GBL
)
5868 fputs (_(" GBL"), file
);
5869 if (flags
& EGPS__V_SHR
)
5870 fputs (_(" SHR"), file
);
5871 if (flags
& EGPS__V_EXE
)
5872 fputs (_(" EXE"), file
);
5873 if (flags
& EGPS__V_RD
)
5874 fputs (_(" RD"), file
);
5875 if (flags
& EGPS__V_WRT
)
5876 fputs (_(" WRT"), file
);
5877 if (flags
& EGPS__V_VEC
)
5878 fputs (_(" VEC"), file
);
5879 if (flags
& EGPS__V_NOMOD
)
5880 fputs (_(" NOMOD"), file
);
5881 if (flags
& EGPS__V_COM
)
5882 fputs (_(" COM"), file
);
5883 if (flags
& EGPS__V_ALLOC_64BIT
)
5884 fputs (_(" 64B"), file
);
5888 evax_bfd_print_egsd (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5890 unsigned int off
= sizeof (struct vms_egsd
);
5893 fprintf (file
, _(" EGSD (len=%u):\n"), rec_len
);
5896 for (off
= sizeof (struct vms_egsd
); off
< rec_len
; )
5898 struct vms_egsd_entry
*e
= (struct vms_egsd_entry
*)(rec
+ off
);
5902 type
= (unsigned)bfd_getl16 (e
->gsdtyp
);
5903 len
= (unsigned)bfd_getl16 (e
->gsdsiz
);
5905 /* xgettext:c-format */
5906 fprintf (file
, _(" EGSD entry %2u (type: %u, len: %u): "),
5910 if (off
+ len
> rec_len
|| off
+ len
< off
)
5912 fprintf (file
, _(" Error: length larger than remaining space in record\n"));
5920 struct vms_egps
*egps
= (struct vms_egps
*)e
;
5921 unsigned int flags
= bfd_getl16 (egps
->flags
);
5924 fprintf (file
, _("PSC - Program section definition\n"));
5925 fprintf (file
, _(" alignment : 2**%u\n"), egps
->align
);
5926 fprintf (file
, _(" flags : 0x%04x"), flags
);
5927 evax_bfd_print_egsd_flags (file
, flags
);
5929 l
= bfd_getl32 (egps
->alloc
);
5930 fprintf (file
, _(" alloc (len): %u (0x%08x)\n"), l
, l
);
5931 fprintf (file
, _(" name : %.*s\n"),
5932 egps
->namlng
, egps
->name
);
5937 struct vms_esgps
*esgps
= (struct vms_esgps
*)e
;
5938 unsigned int flags
= bfd_getl16 (esgps
->flags
);
5941 fprintf (file
, _("SPSC - Shared Image Program section def\n"));
5942 fprintf (file
, _(" alignment : 2**%u\n"), esgps
->align
);
5943 fprintf (file
, _(" flags : 0x%04x"), flags
);
5944 evax_bfd_print_egsd_flags (file
, flags
);
5946 l
= bfd_getl32 (esgps
->alloc
);
5947 fprintf (file
, _(" alloc (len) : %u (0x%08x)\n"), l
, l
);
5948 fprintf (file
, _(" image offset : 0x%08x\n"),
5949 (unsigned int)bfd_getl32 (esgps
->base
));
5950 fprintf (file
, _(" symvec offset : 0x%08x\n"),
5951 (unsigned int)bfd_getl32 (esgps
->value
));
5952 fprintf (file
, _(" name : %.*s\n"),
5953 esgps
->namlng
, esgps
->name
);
5958 struct vms_egsy
*egsy
= (struct vms_egsy
*)e
;
5959 unsigned int flags
= bfd_getl16 (egsy
->flags
);
5961 if (flags
& EGSY__V_DEF
)
5963 struct vms_esdf
*esdf
= (struct vms_esdf
*)e
;
5965 fprintf (file
, _("SYM - Global symbol definition\n"));
5966 fprintf (file
, _(" flags: 0x%04x"), flags
);
5967 exav_bfd_print_egsy_flags (flags
, file
);
5969 fprintf (file
, _(" psect offset: 0x%08x\n"),
5970 (unsigned)bfd_getl32 (esdf
->value
));
5971 if (flags
& EGSY__V_NORM
)
5973 fprintf (file
, _(" code address: 0x%08x\n"),
5974 (unsigned)bfd_getl32 (esdf
->code_address
));
5975 fprintf (file
, _(" psect index for entry point : %u\n"),
5976 (unsigned)bfd_getl32 (esdf
->ca_psindx
));
5978 fprintf (file
, _(" psect index : %u\n"),
5979 (unsigned)bfd_getl32 (esdf
->psindx
));
5980 fprintf (file
, _(" name : %.*s\n"),
5981 esdf
->namlng
, esdf
->name
);
5985 struct vms_esrf
*esrf
= (struct vms_esrf
*)e
;
5987 fprintf (file
, _("SYM - Global symbol reference\n"));
5988 fprintf (file
, _(" name : %.*s\n"),
5989 esrf
->namlng
, esrf
->name
);
5995 struct vms_eidc
*eidc
= (struct vms_eidc
*)e
;
5996 unsigned int flags
= bfd_getl32 (eidc
->flags
);
5999 fprintf (file
, _("IDC - Ident Consistency check\n"));
6000 fprintf (file
, _(" flags : 0x%08x"), flags
);
6001 if (flags
& EIDC__V_BINIDENT
)
6002 fputs (" BINDENT", file
);
6004 fprintf (file
, _(" id match : %x\n"),
6005 (flags
>> EIDC__V_IDMATCH_SH
) & EIDC__V_IDMATCH_MASK
);
6006 fprintf (file
, _(" error severity: %x\n"),
6007 (flags
>> EIDC__V_ERRSEV_SH
) & EIDC__V_ERRSEV_MASK
);
6009 fprintf (file
, _(" entity name : %.*s\n"), p
[0], p
+ 1);
6011 fprintf (file
, _(" object name : %.*s\n"), p
[0], p
+ 1);
6013 if (flags
& EIDC__V_BINIDENT
)
6014 fprintf (file
, _(" binary ident : 0x%08x\n"),
6015 (unsigned)bfd_getl32 (p
+ 1));
6017 fprintf (file
, _(" ascii ident : %.*s\n"), p
[0], p
+ 1);
6022 struct vms_egst
*egst
= (struct vms_egst
*)e
;
6023 unsigned int flags
= bfd_getl16 (egst
->header
.flags
);
6025 fprintf (file
, _("SYMG - Universal symbol definition\n"));
6026 fprintf (file
, _(" flags: 0x%04x"), flags
);
6027 exav_bfd_print_egsy_flags (flags
, file
);
6029 fprintf (file
, _(" symbol vector offset: 0x%08x\n"),
6030 (unsigned)bfd_getl32 (egst
->value
));
6031 fprintf (file
, _(" entry point: 0x%08x\n"),
6032 (unsigned)bfd_getl32 (egst
->lp_1
));
6033 fprintf (file
, _(" proc descr : 0x%08x\n"),
6034 (unsigned)bfd_getl32 (egst
->lp_2
));
6035 fprintf (file
, _(" psect index: %u\n"),
6036 (unsigned)bfd_getl32 (egst
->psindx
));
6037 fprintf (file
, _(" name : %.*s\n"),
6038 egst
->namlng
, egst
->name
);
6043 struct vms_esdfv
*esdfv
= (struct vms_esdfv
*)e
;
6044 unsigned int flags
= bfd_getl16 (esdfv
->flags
);
6046 fprintf (file
, _("SYMV - Vectored symbol definition\n"));
6047 fprintf (file
, _(" flags: 0x%04x"), flags
);
6048 exav_bfd_print_egsy_flags (flags
, file
);
6050 fprintf (file
, _(" vector : 0x%08x\n"),
6051 (unsigned)bfd_getl32 (esdfv
->vector
));
6052 fprintf (file
, _(" psect offset: %u\n"),
6053 (unsigned)bfd_getl32 (esdfv
->value
));
6054 fprintf (file
, _(" psect index : %u\n"),
6055 (unsigned)bfd_getl32 (esdfv
->psindx
));
6056 fprintf (file
, _(" name : %.*s\n"),
6057 esdfv
->namlng
, esdfv
->name
);
6062 struct vms_esdfm
*esdfm
= (struct vms_esdfm
*)e
;
6063 unsigned int flags
= bfd_getl16 (esdfm
->flags
);
6065 fprintf (file
, _("SYMM - Global symbol definition with version\n"));
6066 fprintf (file
, _(" flags: 0x%04x"), flags
);
6067 exav_bfd_print_egsy_flags (flags
, file
);
6069 fprintf (file
, _(" version mask: 0x%08x\n"),
6070 (unsigned)bfd_getl32 (esdfm
->version_mask
));
6071 fprintf (file
, _(" psect offset: %u\n"),
6072 (unsigned)bfd_getl32 (esdfm
->value
));
6073 fprintf (file
, _(" psect index : %u\n"),
6074 (unsigned)bfd_getl32 (esdfm
->psindx
));
6075 fprintf (file
, _(" name : %.*s\n"),
6076 esdfm
->namlng
, esdfm
->name
);
6080 fprintf (file
, _("unhandled egsd entry type %u\n"), type
);
6088 evax_bfd_print_hex (FILE *file
, const char *pfx
,
6089 const unsigned char *buf
, unsigned int len
)
6095 for (i
= 0; i
< len
; i
++)
6099 fprintf (file
, " %02x", buf
[i
]);
6112 evax_bfd_print_etir_stc_ir (FILE *file
, const unsigned char *buf
, int is_ps
)
6114 /* xgettext:c-format */
6115 fprintf (file
, _(" linkage index: %u, replacement insn: 0x%08x\n"),
6116 (unsigned)bfd_getl32 (buf
),
6117 (unsigned)bfd_getl32 (buf
+ 16));
6118 /* xgettext:c-format */
6119 fprintf (file
, _(" psect idx 1: %u, offset 1: 0x%08x %08x\n"),
6120 (unsigned)bfd_getl32 (buf
+ 4),
6121 (unsigned)bfd_getl32 (buf
+ 12),
6122 (unsigned)bfd_getl32 (buf
+ 8));
6123 /* xgettext:c-format */
6124 fprintf (file
, _(" psect idx 2: %u, offset 2: 0x%08x %08x\n"),
6125 (unsigned)bfd_getl32 (buf
+ 20),
6126 (unsigned)bfd_getl32 (buf
+ 28),
6127 (unsigned)bfd_getl32 (buf
+ 24));
6129 /* xgettext:c-format */
6130 fprintf (file
, _(" psect idx 3: %u, offset 3: 0x%08x %08x\n"),
6131 (unsigned)bfd_getl32 (buf
+ 32),
6132 (unsigned)bfd_getl32 (buf
+ 40),
6133 (unsigned)bfd_getl32 (buf
+ 36));
6135 fprintf (file
, _(" global name: %.*s\n"), buf
[32], buf
+ 33);
6139 evax_bfd_print_etir (FILE *file
, const char *name
,
6140 unsigned char *rec
, unsigned int rec_len
)
6142 unsigned int off
= sizeof (struct vms_egsd
);
6143 unsigned int sec_len
= 0;
6145 /* xgettext:c-format */
6146 fprintf (file
, _(" %s (len=%u+%u):\n"), name
,
6147 (unsigned)(rec_len
- sizeof (struct vms_eobjrec
)),
6148 (unsigned)sizeof (struct vms_eobjrec
));
6150 for (off
= sizeof (struct vms_eobjrec
); off
< rec_len
; )
6152 struct vms_etir
*etir
= (struct vms_etir
*)(rec
+ off
);
6157 type
= bfd_getl16 (etir
->rectyp
);
6158 size
= bfd_getl16 (etir
->size
);
6159 buf
= rec
+ off
+ sizeof (struct vms_etir
);
6161 if (off
+ size
> rec_len
|| off
+ size
< off
)
6163 fprintf (file
, _(" Error: length larger than remaining space in record\n"));
6167 /* xgettext:c-format */
6168 fprintf (file
, _(" (type: %3u, size: 4+%3u): "), type
, size
- 4);
6171 case ETIR__C_STA_GBL
:
6172 fprintf (file
, _("STA_GBL (stack global) %.*s\n"),
6175 case ETIR__C_STA_LW
:
6176 fprintf (file
, _("STA_LW (stack longword) 0x%08x\n"),
6177 (unsigned)bfd_getl32 (buf
));
6179 case ETIR__C_STA_QW
:
6180 fprintf (file
, _("STA_QW (stack quadword) 0x%08x %08x\n"),
6181 (unsigned)bfd_getl32 (buf
+ 4),
6182 (unsigned)bfd_getl32 (buf
+ 0));
6184 case ETIR__C_STA_PQ
:
6185 fprintf (file
, _("STA_PQ (stack psect base + offset)\n"));
6186 /* xgettext:c-format */
6187 fprintf (file
, _(" psect: %u, offset: 0x%08x %08x\n"),
6188 (unsigned)bfd_getl32 (buf
+ 0),
6189 (unsigned)bfd_getl32 (buf
+ 8),
6190 (unsigned)bfd_getl32 (buf
+ 4));
6192 case ETIR__C_STA_LI
:
6193 fprintf (file
, _("STA_LI (stack literal)\n"));
6195 case ETIR__C_STA_MOD
:
6196 fprintf (file
, _("STA_MOD (stack module)\n"));
6198 case ETIR__C_STA_CKARG
:
6199 fprintf (file
, _("STA_CKARG (compare procedure argument)\n"));
6203 fprintf (file
, _("STO_B (store byte)\n"));
6206 fprintf (file
, _("STO_W (store word)\n"));
6208 case ETIR__C_STO_LW
:
6209 fprintf (file
, _("STO_LW (store longword)\n"));
6211 case ETIR__C_STO_QW
:
6212 fprintf (file
, _("STO_QW (store quadword)\n"));
6214 case ETIR__C_STO_IMMR
:
6216 unsigned int len
= bfd_getl32 (buf
);
6218 _("STO_IMMR (store immediate repeat) %u bytes\n"),
6220 evax_bfd_print_hex (file
, " ", buf
+ 4, len
);
6224 case ETIR__C_STO_GBL
:
6225 fprintf (file
, _("STO_GBL (store global) %.*s\n"),
6228 case ETIR__C_STO_CA
:
6229 fprintf (file
, _("STO_CA (store code address) %.*s\n"),
6232 case ETIR__C_STO_RB
:
6233 fprintf (file
, _("STO_RB (store relative branch)\n"));
6235 case ETIR__C_STO_AB
:
6236 fprintf (file
, _("STO_AB (store absolute branch)\n"));
6238 case ETIR__C_STO_OFF
:
6239 fprintf (file
, _("STO_OFF (store offset to psect)\n"));
6241 case ETIR__C_STO_IMM
:
6243 unsigned int len
= bfd_getl32 (buf
);
6245 _("STO_IMM (store immediate) %u bytes\n"),
6247 evax_bfd_print_hex (file
, " ", buf
+ 4, len
);
6251 case ETIR__C_STO_GBL_LW
:
6252 fprintf (file
, _("STO_GBL_LW (store global longword) %.*s\n"),
6255 case ETIR__C_STO_LP_PSB
:
6256 fprintf (file
, _("STO_OFF (store LP with procedure signature)\n"));
6258 case ETIR__C_STO_HINT_GBL
:
6259 fprintf (file
, _("STO_BR_GBL (store branch global) *todo*\n"));
6261 case ETIR__C_STO_HINT_PS
:
6262 fprintf (file
, _("STO_BR_PS (store branch psect + offset) *todo*\n"));
6265 case ETIR__C_OPR_NOP
:
6266 fprintf (file
, _("OPR_NOP (no-operation)\n"));
6268 case ETIR__C_OPR_ADD
:
6269 fprintf (file
, _("OPR_ADD (add)\n"));
6271 case ETIR__C_OPR_SUB
:
6272 fprintf (file
, _("OPR_SUB (subtract)\n"));
6274 case ETIR__C_OPR_MUL
:
6275 fprintf (file
, _("OPR_MUL (multiply)\n"));
6277 case ETIR__C_OPR_DIV
:
6278 fprintf (file
, _("OPR_DIV (divide)\n"));
6280 case ETIR__C_OPR_AND
:
6281 fprintf (file
, _("OPR_AND (logical and)\n"));
6283 case ETIR__C_OPR_IOR
:
6284 fprintf (file
, _("OPR_IOR (logical inclusive or)\n"));
6286 case ETIR__C_OPR_EOR
:
6287 fprintf (file
, _("OPR_EOR (logical exclusive or)\n"));
6289 case ETIR__C_OPR_NEG
:
6290 fprintf (file
, _("OPR_NEG (negate)\n"));
6292 case ETIR__C_OPR_COM
:
6293 fprintf (file
, _("OPR_COM (complement)\n"));
6295 case ETIR__C_OPR_INSV
:
6296 fprintf (file
, _("OPR_INSV (insert field)\n"));
6298 case ETIR__C_OPR_ASH
:
6299 fprintf (file
, _("OPR_ASH (arithmetic shift)\n"));
6301 case ETIR__C_OPR_USH
:
6302 fprintf (file
, _("OPR_USH (unsigned shift)\n"));
6304 case ETIR__C_OPR_ROT
:
6305 fprintf (file
, _("OPR_ROT (rotate)\n"));
6307 case ETIR__C_OPR_SEL
:
6308 fprintf (file
, _("OPR_SEL (select)\n"));
6310 case ETIR__C_OPR_REDEF
:
6311 fprintf (file
, _("OPR_REDEF (redefine symbol to curr location)\n"));
6313 case ETIR__C_OPR_DFLIT
:
6314 fprintf (file
, _("OPR_REDEF (define a literal)\n"));
6317 case ETIR__C_STC_LP
:
6318 fprintf (file
, _("STC_LP (store cond linkage pair)\n"));
6320 case ETIR__C_STC_LP_PSB
:
6322 _("STC_LP_PSB (store cond linkage pair + signature)\n"));
6323 /* xgettext:c-format */
6324 fprintf (file
, _(" linkage index: %u, procedure: %.*s\n"),
6325 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6326 buf
+= 4 + 1 + buf
[4];
6327 fprintf (file
, _(" signature: %.*s\n"), buf
[0], buf
+ 1);
6329 case ETIR__C_STC_GBL
:
6330 fprintf (file
, _("STC_GBL (store cond global)\n"));
6331 /* xgettext:c-format */
6332 fprintf (file
, _(" linkage index: %u, global: %.*s\n"),
6333 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6335 case ETIR__C_STC_GCA
:
6336 fprintf (file
, _("STC_GCA (store cond code address)\n"));
6337 /* xgettext:c-format */
6338 fprintf (file
, _(" linkage index: %u, procedure name: %.*s\n"),
6339 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6341 case ETIR__C_STC_PS
:
6342 fprintf (file
, _("STC_PS (store cond psect + offset)\n"));
6344 /* xgettext:c-format */
6345 _(" linkage index: %u, psect: %u, offset: 0x%08x %08x\n"),
6346 (unsigned)bfd_getl32 (buf
),
6347 (unsigned)bfd_getl32 (buf
+ 4),
6348 (unsigned)bfd_getl32 (buf
+ 12),
6349 (unsigned)bfd_getl32 (buf
+ 8));
6351 case ETIR__C_STC_NOP_GBL
:
6352 fprintf (file
, _("STC_NOP_GBL (store cond NOP at global addr)\n"));
6353 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6355 case ETIR__C_STC_NOP_PS
:
6356 fprintf (file
, _("STC_NOP_PS (store cond NOP at psect + offset)\n"));
6357 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6359 case ETIR__C_STC_BSR_GBL
:
6360 fprintf (file
, _("STC_BSR_GBL (store cond BSR at global addr)\n"));
6361 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6363 case ETIR__C_STC_BSR_PS
:
6364 fprintf (file
, _("STC_BSR_PS (store cond BSR at psect + offset)\n"));
6365 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6367 case ETIR__C_STC_LDA_GBL
:
6368 fprintf (file
, _("STC_LDA_GBL (store cond LDA at global addr)\n"));
6369 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6371 case ETIR__C_STC_LDA_PS
:
6372 fprintf (file
, _("STC_LDA_PS (store cond LDA at psect + offset)\n"));
6373 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6375 case ETIR__C_STC_BOH_GBL
:
6376 fprintf (file
, _("STC_BOH_GBL (store cond BOH at global addr)\n"));
6377 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6379 case ETIR__C_STC_BOH_PS
:
6380 fprintf (file
, _("STC_BOH_PS (store cond BOH at psect + offset)\n"));
6381 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6383 case ETIR__C_STC_NBH_GBL
:
6385 _("STC_NBH_GBL (store cond or hint at global addr)\n"));
6387 case ETIR__C_STC_NBH_PS
:
6389 _("STC_NBH_PS (store cond or hint at psect + offset)\n"));
6392 case ETIR__C_CTL_SETRB
:
6393 fprintf (file
, _("CTL_SETRB (set relocation base)\n"));
6396 case ETIR__C_CTL_AUGRB
:
6398 unsigned int val
= bfd_getl32 (buf
);
6399 fprintf (file
, _("CTL_AUGRB (augment relocation base) %u\n"), val
);
6402 case ETIR__C_CTL_DFLOC
:
6403 fprintf (file
, _("CTL_DFLOC (define location)\n"));
6405 case ETIR__C_CTL_STLOC
:
6406 fprintf (file
, _("CTL_STLOC (set location)\n"));
6408 case ETIR__C_CTL_STKDL
:
6409 fprintf (file
, _("CTL_STKDL (stack defined location)\n"));
6412 fprintf (file
, _("*unhandled*\n"));
6420 evax_bfd_print_eobj (struct bfd
*abfd
, FILE *file
)
6422 bfd_boolean is_first
= TRUE
;
6423 bfd_boolean has_records
= FALSE
;
6427 unsigned int rec_len
;
6428 unsigned int pad_len
;
6430 unsigned int hdr_size
;
6435 unsigned char buf
[6];
6440 if (bfd_bread (buf
, sizeof (buf
), abfd
) != sizeof (buf
))
6442 fprintf (file
, _("cannot read GST record length\n"));
6445 rec_len
= bfd_getl16 (buf
+ 0);
6446 if (rec_len
== bfd_getl16 (buf
+ 4)
6447 && bfd_getl16 (buf
+ 2) == EOBJ__C_EMH
)
6449 /* The format is raw: record-size, type, record-size. */
6451 pad_len
= (rec_len
+ 1) & ~1U;
6454 else if (rec_len
== EOBJ__C_EMH
)
6456 has_records
= FALSE
;
6457 pad_len
= bfd_getl16 (buf
+ 2);
6463 fprintf (file
, _("cannot find EMH in first GST record\n"));
6466 rec
= bfd_malloc (pad_len
);
6467 memcpy (rec
, buf
+ sizeof (buf
) - hdr_size
, hdr_size
);
6471 unsigned int rec_len2
= 0;
6472 unsigned char hdr
[4];
6476 unsigned char buf_len
[2];
6478 if (bfd_bread (buf_len
, sizeof (buf_len
), abfd
)
6479 != sizeof (buf_len
))
6481 fprintf (file
, _("cannot read GST record length\n"));
6484 rec_len2
= (unsigned)bfd_getl16 (buf_len
);
6487 if (bfd_bread (hdr
, sizeof (hdr
), abfd
) != sizeof (hdr
))
6489 fprintf (file
, _("cannot read GST record header\n"));
6492 rec_len
= (unsigned)bfd_getl16 (hdr
+ 2);
6494 pad_len
= (rec_len
+ 1) & ~1U;
6497 rec
= bfd_malloc (pad_len
);
6498 memcpy (rec
, hdr
, sizeof (hdr
));
6499 hdr_size
= sizeof (hdr
);
6500 if (has_records
&& rec_len2
!= rec_len
)
6502 fprintf (file
, _(" corrupted GST\n"));
6507 if (bfd_bread (rec
+ hdr_size
, pad_len
- hdr_size
, abfd
)
6508 != pad_len
- hdr_size
)
6510 fprintf (file
, _("cannot read GST record\n"));
6514 type
= (unsigned)bfd_getl16 (rec
);
6519 evax_bfd_print_emh (file
, rec
, rec_len
);
6522 evax_bfd_print_egsd (file
, rec
, rec_len
);
6525 evax_bfd_print_eeom (file
, rec
, rec_len
);
6530 evax_bfd_print_etir (file
, "ETIR", rec
, rec_len
);
6533 evax_bfd_print_etir (file
, "EDBG", rec
, rec_len
);
6536 evax_bfd_print_etir (file
, "ETBT", rec
, rec_len
);
6539 fprintf (file
, _(" unhandled EOBJ record type %u\n"), type
);
6547 evax_bfd_print_relocation_records (FILE *file
, const unsigned char *rel
,
6548 unsigned int stride
)
6556 count
= bfd_getl32 (rel
+ 0);
6560 base
= bfd_getl32 (rel
+ 4);
6562 /* xgettext:c-format */
6563 fprintf (file
, _(" bitcount: %u, base addr: 0x%08x\n"),
6567 for (j
= 0; count
> 0; j
+= 4, count
-= 32)
6573 val
= bfd_getl32 (rel
);
6576 /* xgettext:c-format */
6577 fprintf (file
, _(" bitmap: 0x%08x (count: %u):\n"), val
, count
);
6579 for (k
= 0; k
< 32; k
++)
6584 fprintf (file
, _(" %08x"), base
+ (j
* 8 + k
) * stride
);
6599 evax_bfd_print_address_fixups (FILE *file
, const unsigned char *rel
)
6606 count
= bfd_getl32 (rel
+ 0);
6609 /* xgettext:c-format */
6610 fprintf (file
, _(" image %u (%u entries)\n"),
6611 (unsigned)bfd_getl32 (rel
+ 4), count
);
6613 for (j
= 0; j
< count
; j
++)
6615 /* xgettext:c-format */
6616 fprintf (file
, _(" offset: 0x%08x, val: 0x%08x\n"),
6617 (unsigned)bfd_getl32 (rel
+ 0),
6618 (unsigned)bfd_getl32 (rel
+ 4));
6625 evax_bfd_print_reference_fixups (FILE *file
, const unsigned char *rel
)
6634 count
= bfd_getl32 (rel
+ 0);
6637 /* xgettext:c-format */
6638 fprintf (file
, _(" image %u (%u entries), offsets:\n"),
6639 (unsigned)bfd_getl32 (rel
+ 4), count
);
6641 for (j
= 0; j
< count
; j
++)
6645 fprintf (file
, _(" 0x%08x"), (unsigned)bfd_getl32 (rel
));
6660 evax_bfd_print_indent (int indent
, FILE *file
)
6662 for (; indent
; indent
--)
6667 evax_bfd_get_dsc_name (unsigned int v
)
6671 case DSC__K_DTYPE_Z
:
6672 return "Z (Unspecified)";
6673 case DSC__K_DTYPE_V
:
6675 case DSC__K_DTYPE_BU
:
6676 return "BU (Byte logical)";
6677 case DSC__K_DTYPE_WU
:
6678 return "WU (Word logical)";
6679 case DSC__K_DTYPE_LU
:
6680 return "LU (Longword logical)";
6681 case DSC__K_DTYPE_QU
:
6682 return "QU (Quadword logical)";
6683 case DSC__K_DTYPE_B
:
6684 return "B (Byte integer)";
6685 case DSC__K_DTYPE_W
:
6686 return "W (Word integer)";
6687 case DSC__K_DTYPE_L
:
6688 return "L (Longword integer)";
6689 case DSC__K_DTYPE_Q
:
6690 return "Q (Quadword integer)";
6691 case DSC__K_DTYPE_F
:
6692 return "F (Single-precision floating)";
6693 case DSC__K_DTYPE_D
:
6694 return "D (Double-precision floating)";
6695 case DSC__K_DTYPE_FC
:
6696 return "FC (Complex)";
6697 case DSC__K_DTYPE_DC
:
6698 return "DC (Double-precision Complex)";
6699 case DSC__K_DTYPE_T
:
6700 return "T (ASCII text string)";
6701 case DSC__K_DTYPE_NU
:
6702 return "NU (Numeric string, unsigned)";
6703 case DSC__K_DTYPE_NL
:
6704 return "NL (Numeric string, left separate sign)";
6705 case DSC__K_DTYPE_NLO
:
6706 return "NLO (Numeric string, left overpunched sign)";
6707 case DSC__K_DTYPE_NR
:
6708 return "NR (Numeric string, right separate sign)";
6709 case DSC__K_DTYPE_NRO
:
6710 return "NRO (Numeric string, right overpunched sig)";
6711 case DSC__K_DTYPE_NZ
:
6712 return "NZ (Numeric string, zoned sign)";
6713 case DSC__K_DTYPE_P
:
6714 return "P (Packed decimal string)";
6715 case DSC__K_DTYPE_ZI
:
6716 return "ZI (Sequence of instructions)";
6717 case DSC__K_DTYPE_ZEM
:
6718 return "ZEM (Procedure entry mask)";
6719 case DSC__K_DTYPE_DSC
:
6720 return "DSC (Descriptor, used for arrays of dyn strings)";
6721 case DSC__K_DTYPE_OU
:
6722 return "OU (Octaword logical)";
6723 case DSC__K_DTYPE_O
:
6724 return "O (Octaword integer)";
6725 case DSC__K_DTYPE_G
:
6726 return "G (Double precision G floating, 64 bit)";
6727 case DSC__K_DTYPE_H
:
6728 return "H (Quadruple precision floating, 128 bit)";
6729 case DSC__K_DTYPE_GC
:
6730 return "GC (Double precision complex, G floating)";
6731 case DSC__K_DTYPE_HC
:
6732 return "HC (Quadruple precision complex, H floating)";
6733 case DSC__K_DTYPE_CIT
:
6734 return "CIT (COBOL intermediate temporary)";
6735 case DSC__K_DTYPE_BPV
:
6736 return "BPV (Bound Procedure Value)";
6737 case DSC__K_DTYPE_BLV
:
6738 return "BLV (Bound Label Value)";
6739 case DSC__K_DTYPE_VU
:
6740 return "VU (Bit Unaligned)";
6741 case DSC__K_DTYPE_ADT
:
6742 return "ADT (Absolute Date-Time)";
6743 case DSC__K_DTYPE_VT
:
6744 return "VT (Varying Text)";
6745 case DSC__K_DTYPE_T2
:
6746 return "T2 (16-bit char)";
6747 case DSC__K_DTYPE_VT2
:
6748 return "VT2 (16-bit varying char)";
6750 return "?? (unknown)";
6755 evax_bfd_print_desc (const unsigned char *buf
, int indent
, FILE *file
)
6757 unsigned char bclass
= buf
[3];
6758 unsigned char dtype
= buf
[2];
6759 unsigned int len
= (unsigned)bfd_getl16 (buf
);
6760 unsigned int pointer
= (unsigned)bfd_getl32 (buf
+ 4);
6762 evax_bfd_print_indent (indent
, file
);
6764 if (len
== 1 && pointer
== 0xffffffffUL
)
6767 fprintf (file
, _("64 bits *unhandled*\n"));
6771 /* xgettext:c-format */
6772 fprintf (file
, _("class: %u, dtype: %u, length: %u, pointer: 0x%08x\n"),
6773 bclass
, dtype
, len
, pointer
);
6776 case DSC__K_CLASS_NCA
:
6778 const struct vms_dsc_nca
*dsc
= (const void *)buf
;
6780 const unsigned char *b
;
6782 evax_bfd_print_indent (indent
, file
);
6783 fprintf (file
, _("non-contiguous array of %s\n"),
6784 evax_bfd_get_dsc_name (dsc
->dtype
));
6785 evax_bfd_print_indent (indent
+ 1, file
);
6787 /* xgettext:c-format */
6788 _("dimct: %u, aflags: 0x%02x, digits: %u, scale: %u\n"),
6789 dsc
->dimct
, dsc
->aflags
, dsc
->digits
, dsc
->scale
);
6790 evax_bfd_print_indent (indent
+ 1, file
);
6792 /* xgettext:c-format */
6793 _("arsize: %u, a0: 0x%08x\n"),
6794 (unsigned)bfd_getl32 (dsc
->arsize
),
6795 (unsigned)bfd_getl32 (dsc
->a0
));
6796 evax_bfd_print_indent (indent
+ 1, file
);
6797 fprintf (file
, _("Strides:\n"));
6798 b
= buf
+ sizeof (*dsc
);
6799 for (i
= 0; i
< dsc
->dimct
; i
++)
6801 evax_bfd_print_indent (indent
+ 2, file
);
6802 fprintf (file
, "[%u]: %u\n", i
+ 1,
6803 (unsigned)bfd_getl32 (b
));
6806 evax_bfd_print_indent (indent
+ 1, file
);
6807 fprintf (file
, _("Bounds:\n"));
6808 b
= buf
+ sizeof (*dsc
);
6809 for (i
= 0; i
< dsc
->dimct
; i
++)
6811 evax_bfd_print_indent (indent
+ 2, file
);
6812 /* xgettext:c-format */
6813 fprintf (file
, _("[%u]: Lower: %u, upper: %u\n"), i
+ 1,
6814 (unsigned)bfd_getl32 (b
+ 0),
6815 (unsigned)bfd_getl32 (b
+ 4));
6820 case DSC__K_CLASS_UBS
:
6822 const struct vms_dsc_ubs
*ubs
= (const void *)buf
;
6824 evax_bfd_print_indent (indent
, file
);
6825 fprintf (file
, _("unaligned bit-string of %s\n"),
6826 evax_bfd_get_dsc_name (ubs
->dtype
));
6827 evax_bfd_print_indent (indent
+ 1, file
);
6829 /* xgettext:c-format */
6830 _("base: %u, pos: %u\n"),
6831 (unsigned)bfd_getl32 (ubs
->base
),
6832 (unsigned)bfd_getl32 (ubs
->pos
));
6836 fprintf (file
, _("*unhandled*\n"));
6843 evax_bfd_print_valspec (const unsigned char *buf
, int indent
, FILE *file
)
6845 unsigned int vflags
= buf
[0];
6846 unsigned int value
= (unsigned)bfd_getl32 (buf
+ 1);
6847 unsigned int len
= 5;
6849 evax_bfd_print_indent (indent
, file
);
6850 /* xgettext:c-format */
6851 fprintf (file
, _("vflags: 0x%02x, value: 0x%08x "), vflags
, value
);
6856 case DST__K_VFLAGS_NOVAL
:
6857 fprintf (file
, _("(no value)\n"));
6859 case DST__K_VFLAGS_NOTACTIVE
:
6860 fprintf (file
, _("(not active)\n"));
6862 case DST__K_VFLAGS_UNALLOC
:
6863 fprintf (file
, _("(not allocated)\n"));
6865 case DST__K_VFLAGS_DSC
:
6866 fprintf (file
, _("(descriptor)\n"));
6867 evax_bfd_print_desc (buf
+ value
, indent
+ 1, file
);
6869 case DST__K_VFLAGS_TVS
:
6870 fprintf (file
, _("(trailing value)\n"));
6872 case DST__K_VS_FOLLOWS
:
6873 fprintf (file
, _("(value spec follows)\n"));
6875 case DST__K_VFLAGS_BITOFFS
:
6876 fprintf (file
, _("(at bit offset %u)\n"), value
);
6879 /* xgettext:c-format */
6880 fprintf (file
, _("(reg: %u, disp: %u, indir: %u, kind: "),
6881 (vflags
& DST__K_REGNUM_MASK
) >> DST__K_REGNUM_SHIFT
,
6882 vflags
& DST__K_DISP
? 1 : 0,
6883 vflags
& DST__K_INDIR
? 1 : 0);
6884 switch (vflags
& DST__K_VALKIND_MASK
)
6886 case DST__K_VALKIND_LITERAL
:
6887 fputs (_("literal"), file
);
6889 case DST__K_VALKIND_ADDR
:
6890 fputs (_("address"), file
);
6892 case DST__K_VALKIND_DESC
:
6893 fputs (_("desc"), file
);
6895 case DST__K_VALKIND_REG
:
6896 fputs (_("reg"), file
);
6899 fputs (")\n", file
);
6906 evax_bfd_print_typspec (const unsigned char *buf
, int indent
, FILE *file
)
6908 unsigned char kind
= buf
[2];
6909 unsigned int len
= (unsigned)bfd_getl16 (buf
);
6911 evax_bfd_print_indent (indent
, file
);
6912 /* xgettext:c-format */
6913 fprintf (file
, _("len: %2u, kind: %2u "), len
, kind
);
6917 case DST__K_TS_ATOM
:
6918 /* xgettext:c-format */
6919 fprintf (file
, _("atomic, type=0x%02x %s\n"),
6920 buf
[0], evax_bfd_get_dsc_name (buf
[0]));
6923 fprintf (file
, _("indirect, defined at 0x%08x\n"),
6924 (unsigned)bfd_getl32 (buf
));
6926 case DST__K_TS_TPTR
:
6927 fprintf (file
, _("typed pointer\n"));
6928 evax_bfd_print_typspec (buf
, indent
+ 1, file
);
6931 fprintf (file
, _("pointer\n"));
6933 case DST__K_TS_ARRAY
:
6935 const unsigned char *vs
;
6936 unsigned int vec_len
;
6939 fprintf (file
, _("array, dim: %u, bitmap: "), buf
[0]);
6940 vec_len
= (buf
[0] + 1 + 7) / 8;
6941 for (i
= 0; i
< vec_len
; i
++)
6942 fprintf (file
, " %02x", buf
[i
+ 1]);
6944 vs
= buf
+ 1 + vec_len
;
6945 evax_bfd_print_indent (indent
, file
);
6946 fprintf (file
, _("array descriptor:\n"));
6947 vs
+= evax_bfd_print_valspec (vs
, indent
+ 1, file
);
6948 for (i
= 0; i
< buf
[0] + 1U; i
++)
6949 if (buf
[1 + i
/ 8] & (1 << (i
% 8)))
6951 evax_bfd_print_indent (indent
, file
);
6953 fprintf (file
, _("type spec for element:\n"));
6955 fprintf (file
, _("type spec for subscript %u:\n"), i
);
6956 evax_bfd_print_typspec (vs
, indent
+ 1, file
);
6957 vs
+= bfd_getl16 (vs
);
6962 fprintf (file
, _("*unhandled*\n"));
6967 evax_bfd_print_dst (struct bfd
*abfd
, unsigned int dst_size
, FILE *file
)
6969 unsigned int off
= 0;
6970 unsigned int pc
= 0;
6971 unsigned int line
= 0;
6973 fprintf (file
, _("Debug symbol table:\n"));
6975 while (dst_size
> 0)
6977 struct vms_dst_header dsth
;
6982 if (bfd_bread (&dsth
, sizeof (dsth
), abfd
) != sizeof (dsth
))
6984 fprintf (file
, _("cannot read DST header\n"));
6987 len
= bfd_getl16 (dsth
.length
);
6988 type
= bfd_getl16 (dsth
.type
);
6989 /* xgettext:c-format */
6990 fprintf (file
, _(" type: %3u, len: %3u (at 0x%08x): "),
7000 len
-= sizeof (dsth
);
7001 buf
= bfd_malloc (len
);
7002 if (bfd_bread (buf
, len
, abfd
) != len
)
7004 fprintf (file
, _("cannot read DST symbol\n"));
7009 case DSC__K_DTYPE_V
:
7010 case DSC__K_DTYPE_BU
:
7011 case DSC__K_DTYPE_WU
:
7012 case DSC__K_DTYPE_LU
:
7013 case DSC__K_DTYPE_QU
:
7014 case DSC__K_DTYPE_B
:
7015 case DSC__K_DTYPE_W
:
7016 case DSC__K_DTYPE_L
:
7017 case DSC__K_DTYPE_Q
:
7018 case DSC__K_DTYPE_F
:
7019 case DSC__K_DTYPE_D
:
7020 case DSC__K_DTYPE_FC
:
7021 case DSC__K_DTYPE_DC
:
7022 case DSC__K_DTYPE_T
:
7023 case DSC__K_DTYPE_NU
:
7024 case DSC__K_DTYPE_NL
:
7025 case DSC__K_DTYPE_NLO
:
7026 case DSC__K_DTYPE_NR
:
7027 case DSC__K_DTYPE_NRO
:
7028 case DSC__K_DTYPE_NZ
:
7029 case DSC__K_DTYPE_P
:
7030 case DSC__K_DTYPE_ZI
:
7031 case DSC__K_DTYPE_ZEM
:
7032 case DSC__K_DTYPE_DSC
:
7033 case DSC__K_DTYPE_OU
:
7034 case DSC__K_DTYPE_O
:
7035 case DSC__K_DTYPE_G
:
7036 case DSC__K_DTYPE_H
:
7037 case DSC__K_DTYPE_GC
:
7038 case DSC__K_DTYPE_HC
:
7039 case DSC__K_DTYPE_CIT
:
7040 case DSC__K_DTYPE_BPV
:
7041 case DSC__K_DTYPE_BLV
:
7042 case DSC__K_DTYPE_VU
:
7043 case DSC__K_DTYPE_ADT
:
7044 case DSC__K_DTYPE_VT
:
7045 case DSC__K_DTYPE_T2
:
7046 case DSC__K_DTYPE_VT2
:
7047 fprintf (file
, _("standard data: %s\n"),
7048 evax_bfd_get_dsc_name (type
));
7049 evax_bfd_print_valspec (buf
, 4, file
);
7050 fprintf (file
, _(" name: %.*s\n"), buf
[5], buf
+ 6);
7054 struct vms_dst_modbeg
*dst
= (void *)buf
;
7055 const char *name
= (const char *)buf
+ sizeof (*dst
);
7057 fprintf (file
, _("modbeg\n"));
7058 /* xgettext:c-format */
7059 fprintf (file
, _(" flags: %d, language: %u, "
7060 "major: %u, minor: %u\n"),
7062 (unsigned)bfd_getl32 (dst
->language
),
7063 (unsigned)bfd_getl16 (dst
->major
),
7064 (unsigned)bfd_getl16 (dst
->minor
));
7065 fprintf (file
, _(" module name: %.*s\n"),
7067 name
+= name
[0] + 1;
7068 fprintf (file
, _(" compiler : %.*s\n"),
7073 fprintf (file
, _("modend\n"));
7077 struct vms_dst_rtnbeg
*dst
= (void *)buf
;
7078 const char *name
= (const char *)buf
+ sizeof (*dst
);
7080 fputs (_("rtnbeg\n"), file
);
7081 /* xgettext:c-format */
7082 fprintf (file
, _(" flags: %u, address: 0x%08x, "
7083 "pd-address: 0x%08x\n"),
7085 (unsigned)bfd_getl32 (dst
->address
),
7086 (unsigned)bfd_getl32 (dst
->pd_address
));
7087 fprintf (file
, _(" routine name: %.*s\n"),
7093 struct vms_dst_rtnend
*dst
= (void *)buf
;
7095 fprintf (file
, _("rtnend: size 0x%08x\n"),
7096 (unsigned)bfd_getl32 (dst
->size
));
7101 struct vms_dst_prolog
*dst
= (void *)buf
;
7103 fprintf (file
, _("prolog: bkpt address 0x%08x\n"),
7104 (unsigned)bfd_getl32 (dst
->bkpt_addr
));
7109 struct vms_dst_epilog
*dst
= (void *)buf
;
7111 /* xgettext:c-format */
7112 fprintf (file
, _("epilog: flags: %u, count: %u\n"),
7113 dst
->flags
, (unsigned)bfd_getl32 (dst
->count
));
7118 struct vms_dst_blkbeg
*dst
= (void *)buf
;
7119 const char *name
= (const char *)buf
+ sizeof (*dst
);
7121 /* xgettext:c-format */
7122 fprintf (file
, _("blkbeg: address: 0x%08x, name: %.*s\n"),
7123 (unsigned)bfd_getl32 (dst
->address
),
7129 struct vms_dst_blkend
*dst
= (void *)buf
;
7131 fprintf (file
, _("blkend: size: 0x%08x\n"),
7132 (unsigned)bfd_getl32 (dst
->size
));
7135 case DST__K_TYPSPEC
:
7137 fprintf (file
, _("typspec (len: %u)\n"), len
);
7138 fprintf (file
, _(" name: %.*s\n"), buf
[0], buf
+ 1);
7139 evax_bfd_print_typspec (buf
+ 1 + buf
[0], 5, file
);
7144 fprintf (file
, _("septyp, name: %.*s\n"), buf
[5], buf
+ 6);
7145 evax_bfd_print_valspec (buf
, 4, file
);
7150 struct vms_dst_recbeg
*recbeg
= (void *)buf
;
7151 const char *name
= (const char *)buf
+ sizeof (*recbeg
);
7153 fprintf (file
, _("recbeg: name: %.*s\n"), name
[0], name
+ 1);
7154 evax_bfd_print_valspec (buf
, 4, file
);
7155 fprintf (file
, _(" len: %u bits\n"),
7156 (unsigned)bfd_getl32 (name
+ 1 + name
[0]));
7160 fprintf (file
, _("recend\n"));
7162 case DST__K_ENUMBEG
:
7163 /* xgettext:c-format */
7164 fprintf (file
, _("enumbeg, len: %u, name: %.*s\n"),
7165 buf
[0], buf
[1], buf
+ 2);
7167 case DST__K_ENUMELT
:
7168 fprintf (file
, _("enumelt, name: %.*s\n"), buf
[5], buf
+ 6);
7169 evax_bfd_print_valspec (buf
, 4, file
);
7171 case DST__K_ENUMEND
:
7172 fprintf (file
, _("enumend\n"));
7176 struct vms_dst_label
*lab
= (void *)buf
;
7177 fprintf (file
, _("label, name: %.*s\n"),
7178 lab
->name
[0], lab
->name
+ 1);
7179 fprintf (file
, _(" address: 0x%08x\n"),
7180 (unsigned)bfd_getl32 (lab
->value
));
7183 case DST__K_DIS_RANGE
:
7185 unsigned int cnt
= bfd_getl32 (buf
);
7186 unsigned char *rng
= buf
+ 4;
7189 fprintf (file
, _("discontiguous range (nbr: %u)\n"), cnt
);
7190 for (i
= 0; i
< cnt
; i
++, rng
+= 8)
7191 /* xgettext:c-format */
7192 fprintf (file
, _(" address: 0x%08x, size: %u\n"),
7193 (unsigned)bfd_getl32 (rng
),
7194 (unsigned)bfd_getl32 (rng
+ 4));
7198 case DST__K_LINE_NUM
:
7200 unsigned char *buf_orig
= buf
;
7202 fprintf (file
, _("line num (len: %u)\n"), len
);
7207 unsigned char cmdlen
;
7217 case DST__K_DELTA_PC_W
:
7218 val
= bfd_getl16 (buf
+ 1);
7219 fprintf (file
, _("delta_pc_w %u\n"), val
);
7224 case DST__K_INCR_LINUM
:
7226 fprintf (file
, _("incr_linum(b): +%u\n"), val
);
7230 case DST__K_INCR_LINUM_W
:
7231 val
= bfd_getl16 (buf
+ 1);
7232 fprintf (file
, _("incr_linum_w: +%u\n"), val
);
7236 case DST__K_INCR_LINUM_L
:
7237 val
= bfd_getl32 (buf
+ 1);
7238 fprintf (file
, _("incr_linum_l: +%u\n"), val
);
7242 case DST__K_SET_LINUM
:
7243 line
= bfd_getl16 (buf
+ 1);
7244 fprintf (file
, _("set_line_num(w) %u\n"), line
);
7247 case DST__K_SET_LINUM_B
:
7249 fprintf (file
, _("set_line_num_b %u\n"), line
);
7252 case DST__K_SET_LINUM_L
:
7253 line
= bfd_getl32 (buf
+ 1);
7254 fprintf (file
, _("set_line_num_l %u\n"), line
);
7257 case DST__K_SET_ABS_PC
:
7258 pc
= bfd_getl32 (buf
+ 1);
7259 fprintf (file
, _("set_abs_pc: 0x%08x\n"), pc
);
7262 case DST__K_DELTA_PC_L
:
7263 fprintf (file
, _("delta_pc_l: +0x%08x\n"),
7264 (unsigned)bfd_getl32 (buf
+ 1));
7268 fprintf (file
, _("term(b): 0x%02x"), buf
[1]);
7270 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7274 val
= bfd_getl16 (buf
+ 1);
7275 fprintf (file
, _("term_w: 0x%04x"), val
);
7277 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7283 fprintf (file
, _("delta pc +%-4d"), -cmd
);
7284 line
++; /* FIXME: curr increment. */
7286 /* xgettext:c-format */
7287 fprintf (file
, _(" pc: 0x%08x line: %5u\n"),
7292 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7305 unsigned char *buf_orig
= buf
;
7307 fprintf (file
, _("source (len: %u)\n"), len
);
7311 signed char cmd
= buf
[0];
7312 unsigned char cmdlen
= 0;
7316 case DST__K_SRC_DECLFILE
:
7318 struct vms_dst_src_decl_src
*src
= (void *)(buf
+ 1);
7321 /* xgettext:c-format */
7322 fprintf (file
, _(" declfile: len: %u, flags: %u, "
7324 src
->length
, src
->flags
,
7325 (unsigned)bfd_getl16 (src
->fileid
));
7326 /* xgettext:c-format */
7327 fprintf (file
, _(" rms: cdt: 0x%08x %08x, "
7328 "ebk: 0x%08x, ffb: 0x%04x, "
7330 (unsigned)bfd_getl32 (src
->rms_cdt
+ 4),
7331 (unsigned)bfd_getl32 (src
->rms_cdt
+ 0),
7332 (unsigned)bfd_getl32 (src
->rms_ebk
),
7333 (unsigned)bfd_getl16 (src
->rms_ffb
),
7335 name
= (const char *)buf
+ 1 + sizeof (*src
);
7336 fprintf (file
, _(" filename : %.*s\n"),
7338 name
+= name
[0] + 1;
7339 fprintf (file
, _(" module name: %.*s\n"),
7341 cmdlen
= 2 + src
->length
;
7344 case DST__K_SRC_SETFILE
:
7345 fprintf (file
, _(" setfile %u\n"),
7346 (unsigned)bfd_getl16 (buf
+ 1));
7349 case DST__K_SRC_SETREC_W
:
7350 fprintf (file
, _(" setrec %u\n"),
7351 (unsigned)bfd_getl16 (buf
+ 1));
7354 case DST__K_SRC_SETREC_L
:
7355 fprintf (file
, _(" setrec %u\n"),
7356 (unsigned)bfd_getl32 (buf
+ 1));
7359 case DST__K_SRC_SETLNUM_W
:
7360 fprintf (file
, _(" setlnum %u\n"),
7361 (unsigned)bfd_getl16 (buf
+ 1));
7364 case DST__K_SRC_SETLNUM_L
:
7365 fprintf (file
, _(" setlnum %u\n"),
7366 (unsigned)bfd_getl32 (buf
+ 1));
7369 case DST__K_SRC_DEFLINES_W
:
7370 fprintf (file
, _(" deflines %u\n"),
7371 (unsigned)bfd_getl16 (buf
+ 1));
7374 case DST__K_SRC_DEFLINES_B
:
7375 fprintf (file
, _(" deflines %u\n"), buf
[1]);
7378 case DST__K_SRC_FORMFEED
:
7379 fprintf (file
, _(" formfeed\n"));
7383 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7395 fprintf (file
, _("*unhandled* dst type %u\n"), type
);
7403 evax_bfd_print_image (bfd
*abfd
, FILE *file
)
7405 struct vms_eihd eihd
;
7408 unsigned int eiha_off
;
7409 unsigned int eihi_off
;
7410 unsigned int eihs_off
;
7411 unsigned int eisd_off
;
7412 unsigned int eihef_off
= 0;
7413 unsigned int eihnp_off
= 0;
7414 unsigned int dmt_vbn
= 0;
7415 unsigned int dmt_size
= 0;
7416 unsigned int dst_vbn
= 0;
7417 unsigned int dst_size
= 0;
7418 unsigned int gst_vbn
= 0;
7419 unsigned int gst_size
= 0;
7420 unsigned int eiaf_vbn
= 0;
7421 unsigned int eiaf_size
= 0;
7422 unsigned int eihvn_off
;
7424 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
)
7425 || bfd_bread (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
7427 fprintf (file
, _("cannot read EIHD\n"));
7430 /* xgettext:c-format */
7431 fprintf (file
, _("EIHD: (size: %u, nbr blocks: %u)\n"),
7432 (unsigned)bfd_getl32 (eihd
.size
),
7433 (unsigned)bfd_getl32 (eihd
.hdrblkcnt
));
7434 /* xgettext:c-format */
7435 fprintf (file
, _(" majorid: %u, minorid: %u\n"),
7436 (unsigned)bfd_getl32 (eihd
.majorid
),
7437 (unsigned)bfd_getl32 (eihd
.minorid
));
7439 val
= (unsigned)bfd_getl32 (eihd
.imgtype
);
7443 name
= _("executable");
7446 name
= _("linkable image");
7449 name
= _("unknown");
7452 /* xgettext:c-format */
7453 fprintf (file
, _(" image type: %u (%s)"), val
, name
);
7455 val
= (unsigned)bfd_getl32 (eihd
.subtype
);
7458 case EIHD__C_NATIVE
:
7465 name
= _("unknown");
7468 /* xgettext:c-format */
7469 fprintf (file
, _(", subtype: %u (%s)\n"), val
, name
);
7471 eisd_off
= bfd_getl32 (eihd
.isdoff
);
7472 eiha_off
= bfd_getl32 (eihd
.activoff
);
7473 eihi_off
= bfd_getl32 (eihd
.imgidoff
);
7474 eihs_off
= bfd_getl32 (eihd
.symdbgoff
);
7475 /* xgettext:c-format */
7476 fprintf (file
, _(" offsets: isd: %u, activ: %u, symdbg: %u, "
7477 "imgid: %u, patch: %u\n"),
7478 eisd_off
, eiha_off
, eihs_off
, eihi_off
,
7479 (unsigned)bfd_getl32 (eihd
.patchoff
));
7480 fprintf (file
, _(" fixup info rva: "));
7481 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.iafva
));
7482 fprintf (file
, _(", symbol vector rva: "));
7483 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.symvva
));
7484 eihvn_off
= bfd_getl32 (eihd
.version_array_off
);
7485 fprintf (file
, _("\n"
7486 " version array off: %u\n"),
7489 /* xgettext:c-format */
7490 _(" img I/O count: %u, nbr channels: %u, req pri: %08x%08x\n"),
7491 (unsigned)bfd_getl32 (eihd
.imgiocnt
),
7492 (unsigned)bfd_getl32 (eihd
.iochancnt
),
7493 (unsigned)bfd_getl32 (eihd
.privreqs
+ 4),
7494 (unsigned)bfd_getl32 (eihd
.privreqs
+ 0));
7495 val
= (unsigned)bfd_getl32 (eihd
.lnkflags
);
7496 fprintf (file
, _(" linker flags: %08x:"), val
);
7497 if (val
& EIHD__M_LNKDEBUG
)
7498 fprintf (file
, " LNKDEBUG");
7499 if (val
& EIHD__M_LNKNOTFR
)
7500 fprintf (file
, " LNKNOTFR");
7501 if (val
& EIHD__M_NOP0BUFS
)
7502 fprintf (file
, " NOP0BUFS");
7503 if (val
& EIHD__M_PICIMG
)
7504 fprintf (file
, " PICIMG");
7505 if (val
& EIHD__M_P0IMAGE
)
7506 fprintf (file
, " P0IMAGE");
7507 if (val
& EIHD__M_DBGDMT
)
7508 fprintf (file
, " DBGDMT");
7509 if (val
& EIHD__M_INISHR
)
7510 fprintf (file
, " INISHR");
7511 if (val
& EIHD__M_XLATED
)
7512 fprintf (file
, " XLATED");
7513 if (val
& EIHD__M_BIND_CODE_SEC
)
7514 fprintf (file
, " BIND_CODE_SEC");
7515 if (val
& EIHD__M_BIND_DATA_SEC
)
7516 fprintf (file
, " BIND_DATA_SEC");
7517 if (val
& EIHD__M_MKTHREADS
)
7518 fprintf (file
, " MKTHREADS");
7519 if (val
& EIHD__M_UPCALLS
)
7520 fprintf (file
, " UPCALLS");
7521 if (val
& EIHD__M_OMV_READY
)
7522 fprintf (file
, " OMV_READY");
7523 if (val
& EIHD__M_EXT_BIND_SECT
)
7524 fprintf (file
, " EXT_BIND_SECT");
7525 fprintf (file
, "\n");
7526 /* xgettext:c-format */
7527 fprintf (file
, _(" ident: 0x%08x, sysver: 0x%08x, "
7528 "match ctrl: %u, symvect_size: %u\n"),
7529 (unsigned)bfd_getl32 (eihd
.ident
),
7530 (unsigned)bfd_getl32 (eihd
.sysver
),
7532 (unsigned)bfd_getl32 (eihd
.symvect_size
));
7533 fprintf (file
, _(" BPAGE: %u"),
7534 (unsigned)bfd_getl32 (eihd
.virt_mem_block_size
));
7535 if (val
& (EIHD__M_OMV_READY
| EIHD__M_EXT_BIND_SECT
))
7537 eihef_off
= bfd_getl32 (eihd
.ext_fixup_off
);
7538 eihnp_off
= bfd_getl32 (eihd
.noopt_psect_off
);
7539 /* xgettext:c-format */
7540 fprintf (file
, _(", ext fixup offset: %u, no_opt psect off: %u"),
7541 eihef_off
, eihnp_off
);
7543 fprintf (file
, _(", alias: %u\n"), (unsigned)bfd_getl16 (eihd
.alias
));
7547 struct vms_eihvn eihvn
;
7551 fprintf (file
, _("system version array information:\n"));
7552 if (bfd_seek (abfd
, (file_ptr
) eihvn_off
, SEEK_SET
)
7553 || bfd_bread (&eihvn
, sizeof (eihvn
), abfd
) != sizeof (eihvn
))
7555 fprintf (file
, _("cannot read EIHVN header\n"));
7558 mask
= bfd_getl32 (eihvn
.subsystem_mask
);
7559 for (j
= 0; j
< 32; j
++)
7560 if (mask
& (1 << j
))
7562 struct vms_eihvn_subversion ver
;
7563 if (bfd_bread (&ver
, sizeof (ver
), abfd
) != sizeof (ver
))
7565 fprintf (file
, _("cannot read EIHVN version\n"));
7568 fprintf (file
, _(" %02u "), j
);
7571 case EIHVN__BASE_IMAGE_BIT
:
7572 fputs (_("BASE_IMAGE "), file
);
7574 case EIHVN__MEMORY_MANAGEMENT_BIT
:
7575 fputs (_("MEMORY_MANAGEMENT"), file
);
7578 fputs (_("IO "), file
);
7580 case EIHVN__FILES_VOLUMES_BIT
:
7581 fputs (_("FILES_VOLUMES "), file
);
7583 case EIHVN__PROCESS_SCHED_BIT
:
7584 fputs (_("PROCESS_SCHED "), file
);
7586 case EIHVN__SYSGEN_BIT
:
7587 fputs (_("SYSGEN "), file
);
7589 case EIHVN__CLUSTERS_LOCKMGR_BIT
:
7590 fputs (_("CLUSTERS_LOCKMGR "), file
);
7592 case EIHVN__LOGICAL_NAMES_BIT
:
7593 fputs (_("LOGICAL_NAMES "), file
);
7595 case EIHVN__SECURITY_BIT
:
7596 fputs (_("SECURITY "), file
);
7598 case EIHVN__IMAGE_ACTIVATOR_BIT
:
7599 fputs (_("IMAGE_ACTIVATOR "), file
);
7601 case EIHVN__NETWORKS_BIT
:
7602 fputs (_("NETWORKS "), file
);
7604 case EIHVN__COUNTERS_BIT
:
7605 fputs (_("COUNTERS "), file
);
7607 case EIHVN__STABLE_BIT
:
7608 fputs (_("STABLE "), file
);
7610 case EIHVN__MISC_BIT
:
7611 fputs (_("MISC "), file
);
7613 case EIHVN__CPU_BIT
:
7614 fputs (_("CPU "), file
);
7616 case EIHVN__VOLATILE_BIT
:
7617 fputs (_("VOLATILE "), file
);
7619 case EIHVN__SHELL_BIT
:
7620 fputs (_("SHELL "), file
);
7622 case EIHVN__POSIX_BIT
:
7623 fputs (_("POSIX "), file
);
7625 case EIHVN__MULTI_PROCESSING_BIT
:
7626 fputs (_("MULTI_PROCESSING "), file
);
7628 case EIHVN__GALAXY_BIT
:
7629 fputs (_("GALAXY "), file
);
7632 fputs (_("*unknown* "), file
);
7635 fprintf (file
, ": %u.%u\n",
7636 (unsigned)bfd_getl16 (ver
.major
),
7637 (unsigned)bfd_getl16 (ver
.minor
));
7643 struct vms_eiha eiha
;
7645 if (bfd_seek (abfd
, (file_ptr
) eiha_off
, SEEK_SET
)
7646 || bfd_bread (&eiha
, sizeof (eiha
), abfd
) != sizeof (eiha
))
7648 fprintf (file
, _("cannot read EIHA\n"));
7651 fprintf (file
, _("Image activation: (size=%u)\n"),
7652 (unsigned)bfd_getl32 (eiha
.size
));
7653 /* xgettext:c-format */
7654 fprintf (file
, _(" First address : 0x%08x 0x%08x\n"),
7655 (unsigned)bfd_getl32 (eiha
.tfradr1_h
),
7656 (unsigned)bfd_getl32 (eiha
.tfradr1
));
7657 /* xgettext:c-format */
7658 fprintf (file
, _(" Second address: 0x%08x 0x%08x\n"),
7659 (unsigned)bfd_getl32 (eiha
.tfradr2_h
),
7660 (unsigned)bfd_getl32 (eiha
.tfradr2
));
7661 /* xgettext:c-format */
7662 fprintf (file
, _(" Third address : 0x%08x 0x%08x\n"),
7663 (unsigned)bfd_getl32 (eiha
.tfradr3_h
),
7664 (unsigned)bfd_getl32 (eiha
.tfradr3
));
7665 /* xgettext:c-format */
7666 fprintf (file
, _(" Fourth address: 0x%08x 0x%08x\n"),
7667 (unsigned)bfd_getl32 (eiha
.tfradr4_h
),
7668 (unsigned)bfd_getl32 (eiha
.tfradr4
));
7669 /* xgettext:c-format */
7670 fprintf (file
, _(" Shared image : 0x%08x 0x%08x\n"),
7671 (unsigned)bfd_getl32 (eiha
.inishr_h
),
7672 (unsigned)bfd_getl32 (eiha
.inishr
));
7676 struct vms_eihi eihi
;
7678 if (bfd_seek (abfd
, (file_ptr
) eihi_off
, SEEK_SET
)
7679 || bfd_bread (&eihi
, sizeof (eihi
), abfd
) != sizeof (eihi
))
7681 fprintf (file
, _("cannot read EIHI\n"));
7684 /* xgettext:c-format */
7685 fprintf (file
, _("Image identification: (major: %u, minor: %u)\n"),
7686 (unsigned)bfd_getl32 (eihi
.majorid
),
7687 (unsigned)bfd_getl32 (eihi
.minorid
));
7688 fprintf (file
, _(" image name : %.*s\n"),
7689 eihi
.imgnam
[0], eihi
.imgnam
+ 1);
7690 fprintf (file
, _(" link time : %s\n"),
7691 vms_time_to_str (eihi
.linktime
));
7692 fprintf (file
, _(" image ident : %.*s\n"),
7693 eihi
.imgid
[0], eihi
.imgid
+ 1);
7694 fprintf (file
, _(" linker ident : %.*s\n"),
7695 eihi
.linkid
[0], eihi
.linkid
+ 1);
7696 fprintf (file
, _(" image build ident: %.*s\n"),
7697 eihi
.imgbid
[0], eihi
.imgbid
+ 1);
7701 struct vms_eihs eihs
;
7703 if (bfd_seek (abfd
, (file_ptr
) eihs_off
, SEEK_SET
)
7704 || bfd_bread (&eihs
, sizeof (eihs
), abfd
) != sizeof (eihs
))
7706 fprintf (file
, _("cannot read EIHS\n"));
7709 /* xgettext:c-format */
7710 fprintf (file
, _("Image symbol & debug table: (major: %u, minor: %u)\n"),
7711 (unsigned)bfd_getl32 (eihs
.majorid
),
7712 (unsigned)bfd_getl32 (eihs
.minorid
));
7713 dst_vbn
= bfd_getl32 (eihs
.dstvbn
);
7714 dst_size
= bfd_getl32 (eihs
.dstsize
);
7715 /* xgettext:c-format */
7716 fprintf (file
, _(" debug symbol table : vbn: %u, size: %u (0x%x)\n"),
7717 dst_vbn
, dst_size
, dst_size
);
7718 gst_vbn
= bfd_getl32 (eihs
.gstvbn
);
7719 gst_size
= bfd_getl32 (eihs
.gstsize
);
7720 /* xgettext:c-format */
7721 fprintf (file
, _(" global symbol table: vbn: %u, records: %u\n"),
7723 dmt_vbn
= bfd_getl32 (eihs
.dmtvbn
);
7724 dmt_size
= bfd_getl32 (eihs
.dmtsize
);
7725 /* xgettext:c-format */
7726 fprintf (file
, _(" debug module table : vbn: %u, size: %u\n"),
7729 while (eisd_off
!= 0)
7731 struct vms_eisd eisd
;
7736 if (bfd_seek (abfd
, (file_ptr
) eisd_off
, SEEK_SET
)
7737 || bfd_bread (&eisd
, sizeof (eisd
), abfd
) != sizeof (eisd
))
7739 fprintf (file
, _("cannot read EISD\n"));
7742 len
= (unsigned)bfd_getl32 (eisd
.eisdsize
);
7743 if (len
!= (unsigned)-1)
7747 eisd_off
= (eisd_off
+ VMS_BLOCK_SIZE
) & ~(VMS_BLOCK_SIZE
- 1);
7749 /* xgettext:c-format */
7750 fprintf (file
, _("Image section descriptor: (major: %u, minor: %u, "
7751 "size: %u, offset: %u)\n"),
7752 (unsigned)bfd_getl32 (eisd
.majorid
),
7753 (unsigned)bfd_getl32 (eisd
.minorid
),
7757 /* xgettext:c-format */
7758 fprintf (file
, _(" section: base: 0x%08x%08x size: 0x%08x\n"),
7759 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 4),
7760 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 0),
7761 (unsigned)bfd_getl32 (eisd
.secsize
));
7762 val
= (unsigned)bfd_getl32 (eisd
.flags
);
7763 fprintf (file
, _(" flags: 0x%04x"), val
);
7764 if (val
& EISD__M_GBL
)
7765 fprintf (file
, " GBL");
7766 if (val
& EISD__M_CRF
)
7767 fprintf (file
, " CRF");
7768 if (val
& EISD__M_DZRO
)
7769 fprintf (file
, " DZRO");
7770 if (val
& EISD__M_WRT
)
7771 fprintf (file
, " WRT");
7772 if (val
& EISD__M_INITALCODE
)
7773 fprintf (file
, " INITALCODE");
7774 if (val
& EISD__M_BASED
)
7775 fprintf (file
, " BASED");
7776 if (val
& EISD__M_FIXUPVEC
)
7777 fprintf (file
, " FIXUPVEC");
7778 if (val
& EISD__M_RESIDENT
)
7779 fprintf (file
, " RESIDENT");
7780 if (val
& EISD__M_VECTOR
)
7781 fprintf (file
, " VECTOR");
7782 if (val
& EISD__M_PROTECT
)
7783 fprintf (file
, " PROTECT");
7784 if (val
& EISD__M_LASTCLU
)
7785 fprintf (file
, " LASTCLU");
7786 if (val
& EISD__M_EXE
)
7787 fprintf (file
, " EXE");
7788 if (val
& EISD__M_NONSHRADR
)
7789 fprintf (file
, " NONSHRADR");
7790 if (val
& EISD__M_QUAD_LENGTH
)
7791 fprintf (file
, " QUAD_LENGTH");
7792 if (val
& EISD__M_ALLOC_64BIT
)
7793 fprintf (file
, " ALLOC_64BIT");
7794 fprintf (file
, "\n");
7795 if (val
& EISD__M_FIXUPVEC
)
7797 eiaf_vbn
= bfd_getl32 (eisd
.vbn
);
7798 eiaf_size
= bfd_getl32 (eisd
.secsize
);
7800 /* xgettext:c-format */
7801 fprintf (file
, _(" vbn: %u, pfc: %u, matchctl: %u type: %u ("),
7802 (unsigned)bfd_getl32 (eisd
.vbn
),
7803 eisd
.pfc
, eisd
.matchctl
, eisd
.type
);
7806 case EISD__K_NORMAL
:
7807 fputs (_("NORMAL"), file
);
7809 case EISD__K_SHRFXD
:
7810 fputs (_("SHRFXD"), file
);
7812 case EISD__K_PRVFXD
:
7813 fputs (_("PRVFXD"), file
);
7815 case EISD__K_SHRPIC
:
7816 fputs (_("SHRPIC"), file
);
7818 case EISD__K_PRVPIC
:
7819 fputs (_("PRVPIC"), file
);
7821 case EISD__K_USRSTACK
:
7822 fputs (_("USRSTACK"), file
);
7825 fputs (_("*unknown*"), file
);
7828 fputs (_(")\n"), file
);
7829 if (val
& EISD__M_GBL
)
7830 /* xgettext:c-format */
7831 fprintf (file
, _(" ident: 0x%08x, name: %.*s\n"),
7832 (unsigned)bfd_getl32 (eisd
.ident
),
7833 eisd
.gblnam
[0], eisd
.gblnam
+ 1);
7839 if (bfd_seek (abfd
, (file_ptr
) (dmt_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7841 fprintf (file
, _("cannot read DMT\n"));
7845 fprintf (file
, _("Debug module table:\n"));
7847 while (dmt_size
> 0)
7849 struct vms_dmt_header dmth
;
7852 if (bfd_bread (&dmth
, sizeof (dmth
), abfd
) != sizeof (dmth
))
7854 fprintf (file
, _("cannot read DMT header\n"));
7857 count
= bfd_getl16 (dmth
.psect_count
);
7859 /* xgettext:c-format */
7860 _(" module offset: 0x%08x, size: 0x%08x, (%u psects)\n"),
7861 (unsigned)bfd_getl32 (dmth
.modbeg
),
7862 (unsigned)bfd_getl32 (dmth
.size
), count
);
7863 dmt_size
-= sizeof (dmth
);
7866 struct vms_dmt_psect dmtp
;
7868 if (bfd_bread (&dmtp
, sizeof (dmtp
), abfd
) != sizeof (dmtp
))
7870 fprintf (file
, _("cannot read DMT psect\n"));
7873 /* xgettext:c-format */
7874 fprintf (file
, _(" psect start: 0x%08x, length: %u\n"),
7875 (unsigned)bfd_getl32 (dmtp
.start
),
7876 (unsigned)bfd_getl32 (dmtp
.length
));
7878 dmt_size
-= sizeof (dmtp
);
7885 if (bfd_seek (abfd
, (file_ptr
) (dst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7887 fprintf (file
, _("cannot read DST\n"));
7891 evax_bfd_print_dst (abfd
, dst_size
, file
);
7895 if (bfd_seek (abfd
, (file_ptr
) (gst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7897 fprintf (file
, _("cannot read GST\n"));
7901 fprintf (file
, _("Global symbol table:\n"));
7902 evax_bfd_print_eobj (abfd
, file
);
7907 struct vms_eiaf
*eiaf
;
7908 unsigned int qrelfixoff
;
7909 unsigned int lrelfixoff
;
7910 unsigned int qdotadroff
;
7911 unsigned int ldotadroff
;
7912 unsigned int shrimgcnt
;
7913 unsigned int shlstoff
;
7914 unsigned int codeadroff
;
7915 unsigned int lpfixoff
;
7916 unsigned int chgprtoff
;
7918 buf
= bfd_malloc (eiaf_size
);
7920 if (bfd_seek (abfd
, (file_ptr
) (eiaf_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
)
7921 || bfd_bread (buf
, eiaf_size
, abfd
) != eiaf_size
)
7923 fprintf (file
, _("cannot read EIHA\n"));
7927 eiaf
= (struct vms_eiaf
*)buf
;
7929 /* xgettext:c-format */
7930 _("Image activator fixup: (major: %u, minor: %u)\n"),
7931 (unsigned)bfd_getl32 (eiaf
->majorid
),
7932 (unsigned)bfd_getl32 (eiaf
->minorid
));
7933 /* xgettext:c-format */
7934 fprintf (file
, _(" iaflink : 0x%08x %08x\n"),
7935 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 0),
7936 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 4));
7937 /* xgettext:c-format */
7938 fprintf (file
, _(" fixuplnk: 0x%08x %08x\n"),
7939 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 0),
7940 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 4));
7941 fprintf (file
, _(" size : %u\n"),
7942 (unsigned)bfd_getl32 (eiaf
->size
));
7943 fprintf (file
, _(" flags: 0x%08x\n"),
7944 (unsigned)bfd_getl32 (eiaf
->flags
));
7945 qrelfixoff
= bfd_getl32 (eiaf
->qrelfixoff
);
7946 lrelfixoff
= bfd_getl32 (eiaf
->lrelfixoff
);
7947 /* xgettext:c-format */
7948 fprintf (file
, _(" qrelfixoff: %5u, lrelfixoff: %5u\n"),
7949 qrelfixoff
, lrelfixoff
);
7950 qdotadroff
= bfd_getl32 (eiaf
->qdotadroff
);
7951 ldotadroff
= bfd_getl32 (eiaf
->ldotadroff
);
7952 /* xgettext:c-format */
7953 fprintf (file
, _(" qdotadroff: %5u, ldotadroff: %5u\n"),
7954 qdotadroff
, ldotadroff
);
7955 codeadroff
= bfd_getl32 (eiaf
->codeadroff
);
7956 lpfixoff
= bfd_getl32 (eiaf
->lpfixoff
);
7957 /* xgettext:c-format */
7958 fprintf (file
, _(" codeadroff: %5u, lpfixoff : %5u\n"),
7959 codeadroff
, lpfixoff
);
7960 chgprtoff
= bfd_getl32 (eiaf
->chgprtoff
);
7961 fprintf (file
, _(" chgprtoff : %5u\n"), chgprtoff
);
7962 shrimgcnt
= bfd_getl32 (eiaf
->shrimgcnt
);
7963 shlstoff
= bfd_getl32 (eiaf
->shlstoff
);
7964 /* xgettext:c-format */
7965 fprintf (file
, _(" shlstoff : %5u, shrimgcnt : %5u\n"),
7966 shlstoff
, shrimgcnt
);
7967 /* xgettext:c-format */
7968 fprintf (file
, _(" shlextra : %5u, permctx : %5u\n"),
7969 (unsigned)bfd_getl32 (eiaf
->shlextra
),
7970 (unsigned)bfd_getl32 (eiaf
->permctx
));
7971 fprintf (file
, _(" base_va : 0x%08x\n"),
7972 (unsigned)bfd_getl32 (eiaf
->base_va
));
7973 fprintf (file
, _(" lppsbfixoff: %5u\n"),
7974 (unsigned)bfd_getl32 (eiaf
->lppsbfixoff
));
7978 struct vms_shl
*shl
= (struct vms_shl
*)(buf
+ shlstoff
);
7981 fprintf (file
, _(" Shareable images:\n"));
7982 for (j
= 0; j
< shrimgcnt
; j
++, shl
++)
7985 /* xgettext:c-format */
7986 _(" %u: size: %u, flags: 0x%02x, name: %.*s\n"),
7987 j
, shl
->size
, shl
->flags
,
7988 shl
->imgnam
[0], shl
->imgnam
+ 1);
7991 if (qrelfixoff
!= 0)
7993 fprintf (file
, _(" quad-word relocation fixups:\n"));
7994 evax_bfd_print_relocation_records (file
, buf
+ qrelfixoff
, 8);
7996 if (lrelfixoff
!= 0)
7998 fprintf (file
, _(" long-word relocation fixups:\n"));
7999 evax_bfd_print_relocation_records (file
, buf
+ lrelfixoff
, 4);
8001 if (qdotadroff
!= 0)
8003 fprintf (file
, _(" quad-word .address reference fixups:\n"));
8004 evax_bfd_print_address_fixups (file
, buf
+ qdotadroff
);
8006 if (ldotadroff
!= 0)
8008 fprintf (file
, _(" long-word .address reference fixups:\n"));
8009 evax_bfd_print_address_fixups (file
, buf
+ ldotadroff
);
8011 if (codeadroff
!= 0)
8013 fprintf (file
, _(" Code Address Reference Fixups:\n"));
8014 evax_bfd_print_reference_fixups (file
, buf
+ codeadroff
);
8018 fprintf (file
, _(" Linkage Pairs Reference Fixups:\n"));
8019 evax_bfd_print_reference_fixups (file
, buf
+ lpfixoff
);
8023 unsigned int count
= (unsigned)bfd_getl32 (buf
+ chgprtoff
);
8024 struct vms_eicp
*eicp
= (struct vms_eicp
*)(buf
+ chgprtoff
+ 4);
8027 fprintf (file
, _(" Change Protection (%u entries):\n"), count
);
8028 for (j
= 0; j
< count
; j
++, eicp
++)
8030 unsigned int prot
= bfd_getl32 (eicp
->newprt
);
8032 /* xgettext:c-format */
8033 _(" base: 0x%08x %08x, size: 0x%08x, prot: 0x%08x "),
8034 (unsigned)bfd_getl32 (eicp
->baseva
+ 4),
8035 (unsigned)bfd_getl32 (eicp
->baseva
+ 0),
8036 (unsigned)bfd_getl32 (eicp
->size
),
8037 (unsigned)bfd_getl32 (eicp
->newprt
));
8041 fprintf (file
, "NA");
8043 case PRT__C_RESERVED
:
8044 fprintf (file
, "RES");
8047 fprintf (file
, "KW");
8050 fprintf (file
, "KR");
8053 fprintf (file
, "UW");
8056 fprintf (file
, "EW");
8059 fprintf (file
, "ERKW");
8062 fprintf (file
, "ER");
8065 fprintf (file
, "SW");
8068 fprintf (file
, "SREW");
8071 fprintf (file
, "SRKW");
8074 fprintf (file
, "SR");
8077 fprintf (file
, "URSW");
8080 fprintf (file
, "UREW");
8083 fprintf (file
, "URKW");
8086 fprintf (file
, "UR");
8100 vms_bfd_print_private_bfd_data (bfd
*abfd
, void *ptr
)
8102 FILE *file
= (FILE *)ptr
;
8104 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
8105 evax_bfd_print_image (abfd
, file
);
8108 if (bfd_seek (abfd
, 0, SEEK_SET
))
8110 evax_bfd_print_eobj (abfd
, file
);
8117 /* Slurp ETIR/EDBG/ETBT VMS object records. */
8120 alpha_vms_read_sections_content (bfd
*abfd
, struct bfd_link_info
*info
)
8122 asection
*cur_section
;
8123 file_ptr cur_offset
;
8124 asection
*dst_section
;
8125 file_ptr dst_offset
;
8127 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
8133 dst_section
= PRIV (dst_section
);
8137 if (info
->strip
== strip_all
|| info
->strip
== strip_debugger
)
8139 /* Discard the DST section. */
8143 else if (dst_section
)
8145 dst_offset
= dst_section
->output_offset
;
8146 dst_section
= dst_section
->output_section
;
8155 type
= _bfd_vms_get_object_record (abfd
);
8158 vms_debug2 ((2, "next_record failed\n"));
8164 PRIV (image_section
) = cur_section
;
8165 PRIV (image_offset
) = cur_offset
;
8166 res
= _bfd_vms_slurp_etir (abfd
, info
);
8167 cur_section
= PRIV (image_section
);
8168 cur_offset
= PRIV (image_offset
);
8172 if (dst_section
== NULL
)
8174 PRIV (image_section
) = dst_section
;
8175 PRIV (image_offset
) = dst_offset
;
8176 res
= _bfd_vms_slurp_etir (abfd
, info
);
8177 dst_offset
= PRIV (image_offset
);
8186 vms_debug2 ((2, "slurp eobj type %d failed\n", type
));
8193 alpha_vms_sizeof_headers (bfd
*abfd ATTRIBUTE_UNUSED
,
8194 struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8199 /* Add a linkage pair fixup at address SECT + OFFSET to SHLIB. */
8202 alpha_vms_add_fixup_lp (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
8204 struct alpha_vms_shlib_el
*sl
;
8205 asection
*sect
= PRIV2 (src
, image_section
);
8206 file_ptr offset
= PRIV2 (src
, image_offset
);
8208 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8209 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8210 sl
->has_fixups
= TRUE
;
8211 VEC_APPEND_EL (sl
->lp
, bfd_vma
,
8212 sect
->output_section
->vma
+ sect
->output_offset
+ offset
);
8213 sect
->output_section
->flags
|= SEC_RELOC
;
8216 /* Add a code address fixup at address SECT + OFFSET to SHLIB. */
8219 alpha_vms_add_fixup_ca (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
8221 struct alpha_vms_shlib_el
*sl
;
8222 asection
*sect
= PRIV2 (src
, image_section
);
8223 file_ptr offset
= PRIV2 (src
, image_offset
);
8225 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8226 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8227 sl
->has_fixups
= TRUE
;
8228 VEC_APPEND_EL (sl
->ca
, bfd_vma
,
8229 sect
->output_section
->vma
+ sect
->output_offset
+ offset
);
8230 sect
->output_section
->flags
|= SEC_RELOC
;
8233 /* Add a quad word relocation fixup at address SECT + OFFSET to SHLIB. */
8236 alpha_vms_add_fixup_qr (struct bfd_link_info
*info
, bfd
*src
,
8237 bfd
*shlib
, bfd_vma vec
)
8239 struct alpha_vms_shlib_el
*sl
;
8240 struct alpha_vms_vma_ref
*r
;
8241 asection
*sect
= PRIV2 (src
, image_section
);
8242 file_ptr offset
= PRIV2 (src
, image_offset
);
8244 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8245 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8246 sl
->has_fixups
= TRUE
;
8247 r
= VEC_APPEND (sl
->qr
, struct alpha_vms_vma_ref
);
8248 r
->vma
= sect
->output_section
->vma
+ sect
->output_offset
+ offset
;
8250 sect
->output_section
->flags
|= SEC_RELOC
;
8254 alpha_vms_add_fixup_lr (struct bfd_link_info
*info ATTRIBUTE_UNUSED
,
8255 unsigned int shr ATTRIBUTE_UNUSED
,
8256 bfd_vma vec ATTRIBUTE_UNUSED
)
8258 /* Not yet supported. */
8262 /* Add relocation. FIXME: Not yet emitted. */
8265 alpha_vms_add_lw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8270 alpha_vms_add_qw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8274 static struct bfd_hash_entry
*
8275 alpha_vms_link_hash_newfunc (struct bfd_hash_entry
*entry
,
8276 struct bfd_hash_table
*table
,
8279 struct alpha_vms_link_hash_entry
*ret
=
8280 (struct alpha_vms_link_hash_entry
*) entry
;
8282 /* Allocate the structure if it has not already been allocated by a
8285 ret
= ((struct alpha_vms_link_hash_entry
*)
8286 bfd_hash_allocate (table
,
8287 sizeof (struct alpha_vms_link_hash_entry
)));
8291 /* Call the allocation method of the superclass. */
8292 ret
= ((struct alpha_vms_link_hash_entry
*)
8293 _bfd_link_hash_newfunc ((struct bfd_hash_entry
*) ret
,
8298 return (struct bfd_hash_entry
*) ret
;
8301 /* Create an Alpha/VMS link hash table. */
8303 static struct bfd_link_hash_table
*
8304 alpha_vms_bfd_link_hash_table_create (bfd
*abfd
)
8306 struct alpha_vms_link_hash_table
*ret
;
8307 bfd_size_type amt
= sizeof (struct alpha_vms_link_hash_table
);
8309 ret
= (struct alpha_vms_link_hash_table
*) bfd_malloc (amt
);
8312 if (!_bfd_link_hash_table_init (&ret
->root
, abfd
,
8313 alpha_vms_link_hash_newfunc
,
8314 sizeof (struct alpha_vms_link_hash_entry
)))
8320 VEC_INIT (ret
->shrlibs
);
8327 alpha_vms_link_add_object_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8331 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
8333 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
8334 struct alpha_vms_link_hash_entry
*h
;
8335 struct bfd_link_hash_entry
*h_root
;
8338 if (!alpha_vms_convert_symbol (abfd
, e
, &sym
))
8341 if ((e
->flags
& EGSY__V_DEF
) && abfd
->selective_search
)
8343 /* In selective_search mode, only add definition that are
8345 h
= (struct alpha_vms_link_hash_entry
*)bfd_link_hash_lookup
8346 (info
->hash
, sym
.name
, FALSE
, FALSE
, FALSE
);
8347 if (h
== NULL
|| h
->root
.type
!= bfd_link_hash_undefined
)
8353 h_root
= (struct bfd_link_hash_entry
*) h
;
8354 if (!_bfd_generic_link_add_one_symbol (info
, abfd
, sym
.name
, sym
.flags
,
8355 sym
.section
, sym
.value
, NULL
,
8356 FALSE
, FALSE
, &h_root
))
8358 h
= (struct alpha_vms_link_hash_entry
*) h_root
;
8360 if ((e
->flags
& EGSY__V_DEF
)
8362 && abfd
->xvec
== info
->output_bfd
->xvec
)
8366 if (abfd
->flags
& DYNAMIC
)
8368 struct alpha_vms_shlib_el
*shlib
;
8370 /* We do not want to include any of the sections in a dynamic
8371 object in the output file. See comment in elflink.c. */
8372 bfd_section_list_clear (abfd
);
8374 shlib
= VEC_APPEND (alpha_vms_link_hash (info
)->shrlibs
,
8375 struct alpha_vms_shlib_el
);
8377 VEC_INIT (shlib
->ca
);
8378 VEC_INIT (shlib
->lp
);
8379 VEC_INIT (shlib
->qr
);
8380 PRIV (shr_index
) = VEC_COUNT (alpha_vms_link_hash (info
)->shrlibs
) - 1;
8387 alpha_vms_link_add_archive_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8390 struct bfd_link_hash_entry
**pundef
;
8391 struct bfd_link_hash_entry
**next_pundef
;
8393 /* We only accept VMS libraries. */
8394 if (info
->output_bfd
->xvec
!= abfd
->xvec
)
8396 bfd_set_error (bfd_error_wrong_format
);
8400 /* The archive_pass field in the archive itself is used to
8401 initialize PASS, since we may search the same archive multiple
8403 pass
= ++abfd
->archive_pass
;
8405 /* Look through the list of undefined symbols. */
8406 for (pundef
= &info
->hash
->undefs
; *pundef
!= NULL
; pundef
= next_pundef
)
8408 struct bfd_link_hash_entry
*h
;
8414 next_pundef
= &(*pundef
)->u
.undef
.next
;
8416 /* When a symbol is defined, it is not necessarily removed from
8418 if (h
->type
!= bfd_link_hash_undefined
8419 && h
->type
!= bfd_link_hash_common
)
8421 /* Remove this entry from the list, for general cleanliness
8422 and because we are going to look through the list again
8423 if we search any more libraries. We can't remove the
8424 entry if it is the tail, because that would lose any
8425 entries we add to the list later on. */
8426 if (*pundef
!= info
->hash
->undefs_tail
)
8428 *pundef
= *next_pundef
;
8429 next_pundef
= pundef
;
8434 /* Look for this symbol in the archive hash table. */
8435 symidx
= _bfd_vms_lib_find_symbol (abfd
, h
->root
.string
);
8436 if (symidx
== BFD_NO_MORE_SYMBOLS
)
8438 /* Nothing in this slot. */
8442 element
= bfd_get_elt_at_index (abfd
, symidx
);
8443 if (element
== NULL
)
8446 if (element
->archive_pass
== -1 || element
->archive_pass
== pass
)
8448 /* Next symbol if this archive is wrong or already handled. */
8452 if (! bfd_check_format (element
, bfd_object
))
8454 element
->archive_pass
= -1;
8458 orig_element
= element
;
8459 if (bfd_is_thin_archive (abfd
))
8461 element
= _bfd_vms_lib_get_imagelib_file (element
);
8462 if (element
== NULL
|| !bfd_check_format (element
, bfd_object
))
8464 orig_element
->archive_pass
= -1;
8469 /* Unlike the generic linker, we know that this element provides
8470 a definition for an undefined symbol and we know that we want
8471 to include it. We don't need to check anything. */
8472 if (!(*info
->callbacks
8473 ->add_archive_element
) (info
, element
, h
->root
.string
, &element
))
8475 if (!alpha_vms_link_add_object_symbols (element
, info
))
8478 orig_element
->archive_pass
= pass
;
8485 alpha_vms_bfd_link_add_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8487 switch (bfd_get_format (abfd
))
8490 vms_debug2 ((2, "vms_link_add_symbols for object %s\n",
8492 return alpha_vms_link_add_object_symbols (abfd
, info
);
8495 vms_debug2 ((2, "vms_link_add_symbols for archive %s\n",
8497 return alpha_vms_link_add_archive_symbols (abfd
, info
);
8500 bfd_set_error (bfd_error_wrong_format
);
8506 alpha_vms_build_fixups (struct bfd_link_info
*info
)
8508 struct alpha_vms_link_hash_table
*t
= alpha_vms_link_hash (info
);
8509 unsigned char *content
;
8511 unsigned int sz
= 0;
8512 unsigned int lp_sz
= 0;
8513 unsigned int ca_sz
= 0;
8514 unsigned int qr_sz
= 0;
8515 unsigned int shrimg_cnt
= 0;
8516 unsigned int chgprt_num
= 0;
8517 unsigned int chgprt_sz
= 0;
8518 struct vms_eiaf
*eiaf
;
8522 /* Shared libraries. */
8523 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8525 struct alpha_vms_shlib_el
*shlib
;
8527 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8529 if (!shlib
->has_fixups
)
8534 if (VEC_COUNT (shlib
->ca
) > 0)
8536 /* Header + entries. */
8538 ca_sz
+= VEC_COUNT (shlib
->ca
) * 4;
8540 if (VEC_COUNT (shlib
->lp
) > 0)
8542 /* Header + entries. */
8544 lp_sz
+= VEC_COUNT (shlib
->lp
) * 4;
8546 if (VEC_COUNT (shlib
->qr
) > 0)
8548 /* Header + entries. */
8550 qr_sz
+= VEC_COUNT (shlib
->qr
) * 8;
8561 /* Finish now if there is no content. */
8562 if (ca_sz
+ lp_sz
+ qr_sz
== 0)
8565 /* Add an eicp entry for the fixup itself. */
8567 for (sec
= info
->output_bfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
8569 /* This isect could be made RO or EXE after relocations are applied. */
8570 if ((sec
->flags
& SEC_RELOC
) != 0
8571 && (sec
->flags
& (SEC_CODE
| SEC_READONLY
)) != 0)
8574 chgprt_sz
= 4 + chgprt_num
* sizeof (struct vms_eicp
);
8576 /* Allocate section content (round-up size) */
8577 sz
= sizeof (struct vms_eiaf
) + shrimg_cnt
* sizeof (struct vms_shl
)
8578 + ca_sz
+ lp_sz
+ qr_sz
+ chgprt_sz
;
8579 sz
= (sz
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
8580 content
= bfd_zalloc (info
->output_bfd
, sz
);
8581 if (content
== NULL
)
8584 sec
= alpha_vms_link_hash (info
)->fixup
;
8585 sec
->contents
= content
;
8588 eiaf
= (struct vms_eiaf
*)content
;
8589 off
= sizeof (struct vms_eiaf
);
8590 bfd_putl32 (0, eiaf
->majorid
);
8591 bfd_putl32 (0, eiaf
->minorid
);
8592 bfd_putl32 (0, eiaf
->iaflink
);
8593 bfd_putl32 (0, eiaf
->fixuplnk
);
8594 bfd_putl32 (sizeof (struct vms_eiaf
), eiaf
->size
);
8595 bfd_putl32 (0, eiaf
->flags
);
8596 bfd_putl32 (0, eiaf
->qrelfixoff
);
8597 bfd_putl32 (0, eiaf
->lrelfixoff
);
8598 bfd_putl32 (0, eiaf
->qdotadroff
);
8599 bfd_putl32 (0, eiaf
->ldotadroff
);
8600 bfd_putl32 (0, eiaf
->codeadroff
);
8601 bfd_putl32 (0, eiaf
->lpfixoff
);
8602 bfd_putl32 (0, eiaf
->chgprtoff
);
8603 bfd_putl32 (shrimg_cnt
? off
: 0, eiaf
->shlstoff
);
8604 bfd_putl32 (shrimg_cnt
, eiaf
->shrimgcnt
);
8605 bfd_putl32 (0, eiaf
->shlextra
);
8606 bfd_putl32 (0, eiaf
->permctx
);
8607 bfd_putl32 (0, eiaf
->base_va
);
8608 bfd_putl32 (0, eiaf
->lppsbfixoff
);
8615 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8617 struct alpha_vms_shlib_el
*shlib
;
8618 struct vms_shl
*shl
;
8620 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8622 if (!shlib
->has_fixups
)
8625 /* Renumber shared images. */
8626 PRIV2 (shlib
->abfd
, shr_index
) = shrimg_cnt
++;
8628 shl
= (struct vms_shl
*)(content
+ off
);
8629 bfd_putl32 (0, shl
->baseva
);
8630 bfd_putl32 (0, shl
->shlptr
);
8631 bfd_putl32 (0, shl
->ident
);
8632 bfd_putl32 (0, shl
->permctx
);
8633 shl
->size
= sizeof (struct vms_shl
);
8634 bfd_putl16 (0, shl
->fill_1
);
8636 bfd_putl32 (0, shl
->icb
);
8637 shl
->imgnam
[0] = strlen (PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
));
8638 memcpy (shl
->imgnam
+ 1, PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
),
8641 off
+= sizeof (struct vms_shl
);
8647 bfd_putl32 (off
, eiaf
->codeadroff
);
8649 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8651 struct alpha_vms_shlib_el
*shlib
;
8654 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8656 if (VEC_COUNT (shlib
->ca
) == 0)
8659 bfd_putl32 (VEC_COUNT (shlib
->ca
), content
+ off
);
8660 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8663 for (j
= 0; j
< VEC_COUNT (shlib
->ca
); j
++)
8665 bfd_putl32 (VEC_EL (shlib
->ca
, bfd_vma
, j
) - t
->base_addr
,
8671 bfd_putl32 (0, content
+ off
);
8672 bfd_putl32 (0, content
+ off
+ 4);
8679 bfd_putl32 (off
, eiaf
->lpfixoff
);
8681 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8683 struct alpha_vms_shlib_el
*shlib
;
8686 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8688 if (VEC_COUNT (shlib
->lp
) == 0)
8691 bfd_putl32 (VEC_COUNT (shlib
->lp
), content
+ off
);
8692 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8695 for (j
= 0; j
< VEC_COUNT (shlib
->lp
); j
++)
8697 bfd_putl32 (VEC_EL (shlib
->lp
, bfd_vma
, j
) - t
->base_addr
,
8703 bfd_putl32 (0, content
+ off
);
8704 bfd_putl32 (0, content
+ off
+ 4);
8711 bfd_putl32 (off
, eiaf
->qdotadroff
);
8713 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8715 struct alpha_vms_shlib_el
*shlib
;
8718 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8720 if (VEC_COUNT (shlib
->qr
) == 0)
8723 bfd_putl32 (VEC_COUNT (shlib
->qr
), content
+ off
);
8724 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8727 for (j
= 0; j
< VEC_COUNT (shlib
->qr
); j
++)
8729 struct alpha_vms_vma_ref
*r
;
8730 r
= &VEC_EL (shlib
->qr
, struct alpha_vms_vma_ref
, j
);
8731 bfd_putl32 (r
->vma
- t
->base_addr
, content
+ off
);
8732 bfd_putl32 (r
->ref
, content
+ off
+ 4);
8737 bfd_putl32 (0, content
+ off
);
8738 bfd_putl32 (0, content
+ off
+ 4);
8743 /* Write the change protection table. */
8744 bfd_putl32 (off
, eiaf
->chgprtoff
);
8745 bfd_putl32 (chgprt_num
, content
+ off
);
8748 for (sec
= info
->output_bfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
8750 struct vms_eicp
*eicp
;
8753 if ((sec
->flags
& SEC_LINKER_CREATED
) != 0 &&
8754 strcmp (sec
->name
, "$FIXUP$") == 0)
8756 else if ((sec
->flags
& SEC_RELOC
) != 0
8757 && (sec
->flags
& (SEC_CODE
| SEC_READONLY
)) != 0)
8762 eicp
= (struct vms_eicp
*)(content
+ off
);
8763 bfd_putl64 (sec
->vma
- t
->base_addr
, eicp
->baseva
);
8764 bfd_putl32 ((sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1),
8766 bfd_putl32 (prot
, eicp
->newprt
);
8767 off
+= sizeof (struct vms_eicp
);
8773 /* Called by bfd_hash_traverse to fill the symbol table.
8774 Return FALSE in case of failure. */
8777 alpha_vms_link_output_symbol (struct bfd_hash_entry
*bh
, void *infov
)
8779 struct bfd_link_hash_entry
*hc
= (struct bfd_link_hash_entry
*) bh
;
8780 struct bfd_link_info
*info
= (struct bfd_link_info
*)infov
;
8781 struct alpha_vms_link_hash_entry
*h
;
8782 struct vms_symbol_entry
*sym
;
8784 if (hc
->type
== bfd_link_hash_warning
)
8787 if (hc
->type
== bfd_link_hash_new
)
8790 h
= (struct alpha_vms_link_hash_entry
*) hc
;
8792 switch (h
->root
.type
)
8794 case bfd_link_hash_undefined
:
8796 case bfd_link_hash_new
:
8797 case bfd_link_hash_warning
:
8799 case bfd_link_hash_undefweak
:
8801 case bfd_link_hash_defined
:
8802 case bfd_link_hash_defweak
:
8804 asection
*sec
= h
->root
.u
.def
.section
;
8806 /* FIXME: this is certainly a symbol from a dynamic library. */
8807 if (bfd_is_abs_section (sec
))
8810 if (sec
->owner
->flags
& DYNAMIC
)
8814 case bfd_link_hash_common
:
8816 case bfd_link_hash_indirect
:
8820 /* Do not write not kept symbols. */
8821 if (info
->strip
== strip_some
8822 && bfd_hash_lookup (info
->keep_hash
, h
->root
.root
.string
,
8823 FALSE
, FALSE
) != NULL
)
8828 /* This symbol doesn't come from a VMS object. So we suppose it is
8830 int len
= strlen (h
->root
.root
.string
);
8832 sym
= (struct vms_symbol_entry
*)bfd_zalloc (info
->output_bfd
,
8833 sizeof (*sym
) + len
);
8837 memcpy (sym
->name
, h
->root
.root
.string
, len
);
8839 sym
->owner
= info
->output_bfd
;
8841 sym
->typ
= EGSD__C_SYMG
;
8843 sym
->flags
= EGSY__V_DEF
| EGSY__V_REL
;
8844 sym
->symbol_vector
= h
->root
.u
.def
.value
;
8845 sym
->section
= h
->root
.u
.def
.section
;
8846 sym
->value
= h
->root
.u
.def
.value
;
8851 if (!add_symbol_entry (info
->output_bfd
, sym
))
8858 alpha_vms_bfd_final_link (bfd
*abfd
, struct bfd_link_info
*info
)
8861 struct bfd_link_order
*p
;
8869 if (bfd_link_relocatable (info
))
8871 /* FIXME: we do not yet support relocatable link. It is not obvious
8872 how to do it for debug infos. */
8873 (*info
->callbacks
->einfo
)(_("%P: relocatable link is not supported\n"));
8877 bfd_get_outsymbols (abfd
) = NULL
;
8878 bfd_get_symcount (abfd
) = 0;
8880 /* Mark all sections which will be included in the output file. */
8881 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8882 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
8883 if (p
->type
== bfd_indirect_link_order
)
8884 p
->u
.indirect
.section
->linker_mark
= TRUE
;
8887 /* Handle all the link order information for the sections. */
8888 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8890 printf ("For section %s (at 0x%08x, flags=0x%08x):\n",
8891 o
->name
, (unsigned)o
->vma
, (unsigned)o
->flags
);
8893 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
8895 printf (" at 0x%08x - 0x%08x: ",
8896 (unsigned)p
->offset
, (unsigned)(p
->offset
+ p
->size
- 1));
8899 case bfd_section_reloc_link_order
:
8900 case bfd_symbol_reloc_link_order
:
8901 printf (" section/symbol reloc\n");
8903 case bfd_indirect_link_order
:
8904 printf (" section %s of %s\n",
8905 p
->u
.indirect
.section
->name
,
8906 p
->u
.indirect
.section
->owner
->filename
);
8908 case bfd_data_link_order
:
8909 printf (" explicit data\n");
8912 printf (" *unknown* type %u\n", p
->type
);
8919 /* Generate the symbol table. */
8920 BFD_ASSERT (PRIV (syms
) == NULL
);
8921 if (info
->strip
!= strip_all
)
8922 bfd_hash_traverse (&info
->hash
->table
, alpha_vms_link_output_symbol
, info
);
8924 /* Find the entry point. */
8925 if (bfd_get_start_address (abfd
) == 0)
8927 bfd
*startbfd
= NULL
;
8929 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
8931 /* Consider only VMS object files. */
8932 if (sub
->xvec
!= abfd
->xvec
)
8935 if (!PRIV2 (sub
, eom_data
).eom_has_transfer
)
8937 if ((PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
) && startbfd
)
8939 if (startbfd
!= NULL
8940 && !(PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
))
8942 (*info
->callbacks
->einfo
)
8943 /* xgettext:c-format */
8944 (_("%P: multiple entry points: in modules %B and %B\n"),
8953 unsigned int ps_idx
= PRIV2 (startbfd
, eom_data
).eom_l_psindx
;
8954 bfd_vma tfradr
= PRIV2 (startbfd
, eom_data
).eom_l_tfradr
;
8957 sec
= PRIV2 (startbfd
, sections
)[ps_idx
];
8959 bfd_set_start_address
8960 (abfd
, sec
->output_section
->vma
+ sec
->output_offset
+ tfradr
);
8964 /* Set transfer addresses. */
8967 struct bfd_link_hash_entry
*h
;
8970 PRIV (transfer_address
[i
++]) = 0xffffffff00000340ULL
; /* SYS$IMGACT */
8971 h
= bfd_link_hash_lookup (info
->hash
, "LIB$INITIALIZE", FALSE
, FALSE
, TRUE
);
8972 if (h
!= NULL
&& h
->type
== bfd_link_hash_defined
)
8973 PRIV (transfer_address
[i
++]) =
8974 alpha_vms_get_sym_value (h
->u
.def
.section
, h
->u
.def
.value
);
8975 PRIV (transfer_address
[i
++]) = bfd_get_start_address (abfd
);
8977 PRIV (transfer_address
[i
++]) = 0;
8980 /* Allocate contents.
8981 Also compute the virtual base address. */
8982 base_addr
= (bfd_vma
)-1;
8984 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8986 if (o
->flags
& SEC_HAS_CONTENTS
)
8988 o
->contents
= bfd_alloc (abfd
, o
->size
);
8989 if (o
->contents
== NULL
)
8992 if (o
->flags
& SEC_LOAD
)
8994 if (o
->vma
< base_addr
)
8996 if (o
->vma
+ o
->size
> last_addr
)
8997 last_addr
= o
->vma
+ o
->size
;
8999 /* Clear the RELOC flags. Currently we don't support incremental
9000 linking. We use the RELOC flag for computing the eicp entries. */
9001 o
->flags
&= ~SEC_RELOC
;
9004 /* Create the fixup section. */
9005 fixupsec
= bfd_make_section_anyway_with_flags
9006 (info
->output_bfd
, "$FIXUP$",
9007 SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
9008 if (fixupsec
== NULL
)
9010 last_addr
= (last_addr
+ 0xffff) & ~0xffff;
9011 fixupsec
->vma
= last_addr
;
9013 alpha_vms_link_hash (info
)->fixup
= fixupsec
;
9014 alpha_vms_link_hash (info
)->base_addr
= base_addr
;
9016 /* Create the DMT section, if necessary. */
9017 BFD_ASSERT (PRIV (dst_section
) == NULL
);
9018 dst
= bfd_get_section_by_name (abfd
, "$DST$");
9019 if (dst
!= NULL
&& dst
->size
== 0)
9023 PRIV (dst_section
) = dst
;
9024 dmt
= bfd_make_section_anyway_with_flags
9025 (info
->output_bfd
, "$DMT$",
9026 SEC_DEBUGGING
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
9033 /* Read all sections from the inputs. */
9034 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9036 if (sub
->flags
& DYNAMIC
)
9038 alpha_vms_create_eisd_for_shared (abfd
, sub
);
9042 if (!alpha_vms_read_sections_content (sub
, info
))
9046 /* Handle all the link order information for the sections.
9047 Note: past this point, it is not possible to create new sections. */
9048 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9050 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
9054 case bfd_section_reloc_link_order
:
9055 case bfd_symbol_reloc_link_order
:
9058 case bfd_indirect_link_order
:
9062 if (! _bfd_default_link_order (abfd
, info
, o
, p
))
9069 /* Compute fixups. */
9070 if (!alpha_vms_build_fixups (info
))
9073 /* Compute the DMT. */
9077 unsigned char *contents
= NULL
;
9079 /* In pass 1, compute the size. In pass 2, write the DMT contents. */
9080 for (pass
= 0; pass
< 2; pass
++)
9082 unsigned int off
= 0;
9084 /* For each object file (ie for each module). */
9085 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9088 struct vms_dmt_header
*dmth
= NULL
;
9089 unsigned int psect_count
;
9091 /* Skip this module if it has no DST. */
9092 sub_dst
= PRIV2 (sub
, dst_section
);
9093 if (sub_dst
== NULL
|| sub_dst
->size
== 0)
9098 /* Write the header. */
9099 dmth
= (struct vms_dmt_header
*)(contents
+ off
);
9100 bfd_putl32 (sub_dst
->output_offset
, dmth
->modbeg
);
9101 bfd_putl32 (sub_dst
->size
, dmth
->size
);
9104 off
+= sizeof (struct vms_dmt_header
);
9107 /* For each section (ie for each psect). */
9108 for (o
= sub
->sections
; o
!= NULL
; o
= o
->next
)
9110 /* Only consider interesting sections. */
9111 if (!(o
->flags
& SEC_ALLOC
))
9113 if (o
->flags
& SEC_LINKER_CREATED
)
9118 /* Write an entry. */
9119 struct vms_dmt_psect
*dmtp
;
9121 dmtp
= (struct vms_dmt_psect
*)(contents
+ off
);
9122 bfd_putl32 (o
->output_offset
+ o
->output_section
->vma
,
9124 bfd_putl32 (o
->size
, dmtp
->length
);
9127 off
+= sizeof (struct vms_dmt_psect
);
9130 bfd_putl32 (psect_count
, dmth
->psect_count
);
9135 contents
= bfd_zalloc (info
->output_bfd
, off
);
9136 if (contents
== NULL
)
9138 dmt
->contents
= contents
;
9143 BFD_ASSERT (off
== dmt
->size
);
9151 /* Read the contents of a section.
9152 buf points to a buffer of buf_size bytes to be filled with
9153 section data (starting at offset into section) */
9156 alpha_vms_get_section_contents (bfd
*abfd
, asection
*section
,
9157 void *buf
, file_ptr offset
,
9158 bfd_size_type count
)
9162 /* Image are easy. */
9163 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
9164 return _bfd_generic_get_section_contents (abfd
, section
,
9165 buf
, offset
, count
);
9168 if (offset
+ count
< count
9169 || offset
+ count
> section
->size
)
9171 bfd_set_error (bfd_error_invalid_operation
);
9175 /* If the section is already in memory, just copy it. */
9176 if (section
->flags
& SEC_IN_MEMORY
)
9178 BFD_ASSERT (section
->contents
!= NULL
);
9179 memcpy (buf
, section
->contents
+ offset
, count
);
9182 if (section
->size
== 0)
9185 /* Alloc in memory and read ETIRs. */
9186 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
9188 BFD_ASSERT (sec
->contents
== NULL
);
9190 if (sec
->size
!= 0 && (sec
->flags
& SEC_HAS_CONTENTS
))
9192 sec
->contents
= bfd_alloc (abfd
, sec
->size
);
9193 if (sec
->contents
== NULL
)
9197 if (!alpha_vms_read_sections_content (abfd
, NULL
))
9199 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
9201 sec
->flags
|= SEC_IN_MEMORY
;
9202 memcpy (buf
, section
->contents
+ offset
, count
);
9207 /* Set the format of a file being written. */
9210 alpha_vms_mkobject (bfd
* abfd
)
9212 const bfd_arch_info_type
*arch
;
9214 vms_debug2 ((1, "alpha_vms_mkobject (%p)\n", abfd
));
9216 if (!vms_initialize (abfd
))
9219 PRIV (recwr
.buf
) = bfd_alloc (abfd
, MAX_OUTREC_SIZE
);
9220 if (PRIV (recwr
.buf
) == NULL
)
9223 arch
= bfd_scan_arch ("alpha");
9227 bfd_set_error (bfd_error_wrong_format
);
9231 abfd
->arch_info
= arch
;
9238 /* Called when the BFD is being closed to do any necessary cleanup. */
9241 vms_close_and_cleanup (bfd
* abfd
)
9243 vms_debug2 ((1, "vms_close_and_cleanup (%p)\n", abfd
));
9245 if (abfd
== NULL
|| abfd
->tdata
.any
== NULL
)
9248 if (abfd
->format
== bfd_archive
)
9250 bfd_release (abfd
, abfd
->tdata
.any
);
9251 abfd
->tdata
.any
= NULL
;
9255 if (PRIV (recrd
.buf
) != NULL
)
9256 free (PRIV (recrd
.buf
));
9258 if (PRIV (sections
) != NULL
)
9259 free (PRIV (sections
));
9261 bfd_release (abfd
, abfd
->tdata
.any
);
9262 abfd
->tdata
.any
= NULL
;
9265 if (abfd
->direction
== write_direction
)
9267 /* Last step on VMS is to convert the file to variable record length
9269 if (!bfd_cache_close (abfd
))
9271 if (!_bfd_vms_convert_to_var_unix_filename (abfd
->filename
))
9279 /* Called when a new section is created. */
9282 vms_new_section_hook (bfd
* abfd
, asection
*section
)
9286 vms_debug2 ((1, "vms_new_section_hook (%p, [%u]%s)\n",
9287 abfd
, section
->index
, section
->name
));
9289 if (! bfd_set_section_alignment (abfd
, section
, 0))
9292 vms_debug2 ((7, "%u: %s\n", section
->index
, section
->name
));
9294 amt
= sizeof (struct vms_section_data_struct
);
9295 section
->used_by_bfd
= bfd_zalloc (abfd
, amt
);
9296 if (section
->used_by_bfd
== NULL
)
9299 /* Create the section symbol. */
9300 return _bfd_generic_new_section_hook (abfd
, section
);
9303 /* Part 4.5, symbols. */
9305 /* Print symbol to file according to how. how is one of
9306 bfd_print_symbol_name just print the name
9307 bfd_print_symbol_more print more (???)
9308 bfd_print_symbol_all print all we know, which is not much right now :-). */
9311 vms_print_symbol (bfd
* abfd
,
9314 bfd_print_symbol_type how
)
9316 vms_debug2 ((1, "vms_print_symbol (%p, %p, %p, %d)\n",
9317 abfd
, file
, symbol
, how
));
9321 case bfd_print_symbol_name
:
9322 case bfd_print_symbol_more
:
9323 fprintf ((FILE *)file
," %s", symbol
->name
);
9326 case bfd_print_symbol_all
:
9328 const char *section_name
= symbol
->section
->name
;
9330 bfd_print_symbol_vandf (abfd
, file
, symbol
);
9332 fprintf ((FILE *) file
," %-8s %s", section_name
, symbol
->name
);
9338 /* Return information about symbol in ret.
9340 fill type, value and name
9343 B bss segment symbol
9345 D data segment symbol
9347 t a static function symbol
9348 T text segment symbol
9353 vms_get_symbol_info (bfd
* abfd ATTRIBUTE_UNUSED
,
9359 vms_debug2 ((1, "vms_get_symbol_info (%p, %p, %p)\n", abfd
, symbol
, ret
));
9361 sec
= symbol
->section
;
9368 else if (bfd_is_com_section (sec
))
9370 else if (bfd_is_abs_section (sec
))
9372 else if (bfd_is_und_section (sec
))
9374 else if (bfd_is_ind_section (sec
))
9376 else if ((symbol
->flags
& BSF_FUNCTION
)
9377 || (bfd_get_section_flags (abfd
, sec
) & SEC_CODE
))
9379 else if (bfd_get_section_flags (abfd
, sec
) & SEC_DATA
)
9381 else if (bfd_get_section_flags (abfd
, sec
) & SEC_ALLOC
)
9386 if (ret
->type
!= 'U')
9387 ret
->value
= symbol
->value
+ symbol
->section
->vma
;
9390 ret
->name
= symbol
->name
;
9393 /* Return TRUE if the given symbol sym in the BFD abfd is
9394 a compiler generated local label, else return FALSE. */
9397 vms_bfd_is_local_label_name (bfd
* abfd ATTRIBUTE_UNUSED
,
9400 return name
[0] == '$';
9403 /* Part 4.7, writing an object file. */
9405 /* Sets the contents of the section section in BFD abfd to the data starting
9406 in memory at LOCATION. The data is written to the output section starting
9407 at offset offset for count bytes.
9409 Normally TRUE is returned, else FALSE. Possible error returns are:
9410 o bfd_error_no_contents - The output section does not have the
9411 SEC_HAS_CONTENTS attribute, so nothing can be written to it.
9412 o and some more too */
9415 _bfd_vms_set_section_contents (bfd
* abfd
,
9417 const void * location
,
9419 bfd_size_type count
)
9421 if (section
->contents
== NULL
)
9423 section
->contents
= bfd_alloc (abfd
, section
->size
);
9424 if (section
->contents
== NULL
)
9427 memcpy (section
->contents
+ offset
, location
, (size_t) count
);
9433 /* Set the architecture and machine type in BFD abfd to arch and mach.
9434 Find the correct pointer to a structure and insert it into the arch_info
9438 alpha_vms_set_arch_mach (bfd
*abfd
,
9439 enum bfd_architecture arch
, unsigned long mach
)
9441 if (arch
!= bfd_arch_alpha
9442 && arch
!= bfd_arch_unknown
)
9445 return bfd_default_set_arch_mach (abfd
, arch
, mach
);
9448 /* Set section VMS flags. Clear NO_FLAGS and set FLAGS. */
9451 bfd_vms_set_section_flags (bfd
*abfd ATTRIBUTE_UNUSED
,
9452 asection
*sec
, flagword no_flags
, flagword flags
)
9454 vms_section_data (sec
)->no_flags
= no_flags
;
9455 vms_section_data (sec
)->flags
= flags
;
9458 struct vms_private_data_struct
*
9459 bfd_vms_get_data (bfd
*abfd
)
9461 return (struct vms_private_data_struct
*)abfd
->tdata
.any
;
9464 #define vms_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
9465 #define vms_bfd_link_just_syms _bfd_generic_link_just_syms
9466 #define vms_bfd_copy_link_hash_symbol_type \
9467 _bfd_generic_copy_link_hash_symbol_type
9468 #define vms_bfd_is_group_section bfd_generic_is_group_section
9469 #define vms_bfd_discard_group bfd_generic_discard_group
9470 #define vms_section_already_linked _bfd_generic_section_already_linked
9471 #define vms_bfd_define_common_symbol bfd_generic_define_common_symbol
9472 #define vms_bfd_define_start_stop bfd_generic_define_start_stop
9473 #define vms_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
9475 #define vms_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
9476 #define vms_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
9477 #define vms_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data
9478 #define vms_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
9479 #define vms_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
9480 #define vms_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
9482 /* Symbols table. */
9483 #define alpha_vms_make_empty_symbol _bfd_generic_make_empty_symbol
9484 #define alpha_vms_bfd_is_target_special_symbol \
9485 ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
9486 #define alpha_vms_print_symbol vms_print_symbol
9487 #define alpha_vms_get_symbol_info vms_get_symbol_info
9488 #define alpha_vms_get_symbol_version_string \
9489 _bfd_nosymbols_get_symbol_version_string
9491 #define alpha_vms_read_minisymbols _bfd_generic_read_minisymbols
9492 #define alpha_vms_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
9493 #define alpha_vms_get_lineno _bfd_nosymbols_get_lineno
9494 #define alpha_vms_find_inliner_info _bfd_nosymbols_find_inliner_info
9495 #define alpha_vms_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
9496 #define alpha_vms_find_nearest_line _bfd_vms_find_nearest_line
9497 #define alpha_vms_find_line _bfd_nosymbols_find_line
9498 #define alpha_vms_bfd_is_local_label_name vms_bfd_is_local_label_name
9500 /* Generic table. */
9501 #define alpha_vms_close_and_cleanup vms_close_and_cleanup
9502 #define alpha_vms_bfd_free_cached_info vms_bfd_free_cached_info
9503 #define alpha_vms_new_section_hook vms_new_section_hook
9504 #define alpha_vms_set_section_contents _bfd_vms_set_section_contents
9505 #define alpha_vms_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
9507 #define alpha_vms_bfd_get_relocated_section_contents \
9508 bfd_generic_get_relocated_section_contents
9510 #define alpha_vms_bfd_relax_section bfd_generic_relax_section
9511 #define alpha_vms_bfd_gc_sections bfd_generic_gc_sections
9512 #define alpha_vms_bfd_lookup_section_flags bfd_generic_lookup_section_flags
9513 #define alpha_vms_bfd_merge_sections bfd_generic_merge_sections
9514 #define alpha_vms_bfd_is_group_section bfd_generic_is_group_section
9515 #define alpha_vms_bfd_discard_group bfd_generic_discard_group
9516 #define alpha_vms_section_already_linked \
9517 _bfd_generic_section_already_linked
9519 #define alpha_vms_bfd_define_common_symbol bfd_generic_define_common_symbol
9520 #define alpha_vms_bfd_define_start_stop bfd_generic_define_start_stop
9521 #define alpha_vms_bfd_link_just_syms _bfd_generic_link_just_syms
9522 #define alpha_vms_bfd_copy_link_hash_symbol_type \
9523 _bfd_generic_copy_link_hash_symbol_type
9525 #define alpha_vms_bfd_link_split_section _bfd_generic_link_split_section
9527 #define alpha_vms_get_dynamic_symtab_upper_bound \
9528 _bfd_nodynamic_get_dynamic_symtab_upper_bound
9529 #define alpha_vms_canonicalize_dynamic_symtab \
9530 _bfd_nodynamic_canonicalize_dynamic_symtab
9531 #define alpha_vms_get_dynamic_reloc_upper_bound \
9532 _bfd_nodynamic_get_dynamic_reloc_upper_bound
9533 #define alpha_vms_canonicalize_dynamic_reloc \
9534 _bfd_nodynamic_canonicalize_dynamic_reloc
9535 #define alpha_vms_bfd_link_check_relocs _bfd_generic_link_check_relocs
9537 const bfd_target alpha_vms_vec
=
9539 "vms-alpha", /* Name. */
9540 bfd_target_evax_flavour
,
9541 BFD_ENDIAN_LITTLE
, /* Data byte order is little. */
9542 BFD_ENDIAN_LITTLE
, /* Header byte order is little. */
9544 (HAS_RELOC
| EXEC_P
| HAS_LINENO
| HAS_DEBUG
| HAS_SYMS
| HAS_LOCALS
9545 | WP_TEXT
| D_PAGED
), /* Object flags. */
9546 (SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
9547 | SEC_READONLY
| SEC_CODE
| SEC_DATA
9548 | SEC_HAS_CONTENTS
| SEC_IN_MEMORY
), /* Sect flags. */
9549 0, /* symbol_leading_char. */
9550 ' ', /* ar_pad_char. */
9551 15, /* ar_max_namelen. */
9552 0, /* match priority. */
9553 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
9554 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
9555 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
9556 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
9557 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
9558 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
9560 {_bfd_dummy_target
, alpha_vms_object_p
, /* bfd_check_format. */
9561 _bfd_vms_lib_alpha_archive_p
, _bfd_dummy_target
},
9562 {bfd_false
, alpha_vms_mkobject
, /* bfd_set_format. */
9563 _bfd_vms_lib_alpha_mkarchive
, bfd_false
},
9564 {bfd_false
, alpha_vms_write_object_contents
, /* bfd_write_contents. */
9565 _bfd_vms_lib_write_archive_contents
, bfd_false
},
9567 BFD_JUMP_TABLE_GENERIC (alpha_vms
),
9568 BFD_JUMP_TABLE_COPY (vms
),
9569 BFD_JUMP_TABLE_CORE (_bfd_nocore
),
9570 BFD_JUMP_TABLE_ARCHIVE (_bfd_vms_lib
),
9571 BFD_JUMP_TABLE_SYMBOLS (alpha_vms
),
9572 BFD_JUMP_TABLE_RELOCS (alpha_vms
),
9573 BFD_JUMP_TABLE_WRITE (alpha_vms
),
9574 BFD_JUMP_TABLE_LINK (alpha_vms
),
9575 BFD_JUMP_TABLE_DYNAMIC (alpha_vms
),