1 /* vms.c -- BFD back-end for EVAX (openVMS/Alpha) files.
2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
4 Initial version written by Klaus Kaempf (kkaempf@rmi.de)
5 Major rewrite by Adacore.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20 MA 02110-1301, USA. */
25 o Generation of shared image
26 o Relocation optimizations
32 o protected sections (for messages)
50 #include "vms/eihvn.h"
51 #include "vms/eobjrec.h"
54 #include "vms/esgps.h"
63 #include "vms/esdfm.h"
64 #include "vms/esdfv.h"
70 #include "vms/internal.h"
73 #define MIN(a,b) ((a) < (b) ? (a) : (b))
75 /* The r_type field in a reloc is one of the following values. */
76 #define ALPHA_R_IGNORE 0
77 #define ALPHA_R_REFQUAD 1
78 #define ALPHA_R_BRADDR 2
79 #define ALPHA_R_HINT 3
80 #define ALPHA_R_SREL16 4
81 #define ALPHA_R_SREL32 5
82 #define ALPHA_R_SREL64 6
83 #define ALPHA_R_OP_PUSH 7
84 #define ALPHA_R_OP_STORE 8
85 #define ALPHA_R_OP_PSUB 9
86 #define ALPHA_R_OP_PRSHIFT 10
87 #define ALPHA_R_LINKAGE 11
88 #define ALPHA_R_REFLONG 12
89 #define ALPHA_R_CODEADDR 13
90 #define ALPHA_R_NOP 14
91 #define ALPHA_R_BSR 15
92 #define ALPHA_R_LDA 16
93 #define ALPHA_R_BOH 17
95 /* These are used with DST_S_C_LINE_NUM. */
96 #define DST_S_C_LINE_NUM_HEADER_SIZE 4
98 /* These are used with DST_S_C_SOURCE */
100 #define DST_S_B_PCLINE_UNSBYTE 1
101 #define DST_S_W_PCLINE_UNSWORD 1
102 #define DST_S_L_PCLINE_UNSLONG 1
104 #define DST_S_B_MODBEG_NAME 14
105 #define DST_S_L_RTNBEG_ADDRESS 5
106 #define DST_S_B_RTNBEG_NAME 13
107 #define DST_S_L_RTNEND_SIZE 5
109 /* These are used with DST_S_C_SOURCE. */
110 #define DST_S_C_SOURCE_HEADER_SIZE 4
112 #define DST_S_B_SRC_DF_LENGTH 1
113 #define DST_S_W_SRC_DF_FILEID 3
114 #define DST_S_B_SRC_DF_FILENAME 20
115 #define DST_S_B_SRC_UNSBYTE 1
116 #define DST_S_W_SRC_UNSWORD 1
117 #define DST_S_L_SRC_UNSLONG 1
119 /* Debugger symbol definitions. */
121 #define DBG_S_L_DMT_MODBEG 0
122 #define DBG_S_L_DST_SIZE 4
123 #define DBG_S_W_DMT_PSECT_COUNT 8
124 #define DBG_S_C_DMT_HEADER_SIZE 12
126 #define DBG_S_L_DMT_PSECT_START 0
127 #define DBG_S_L_DMT_PSECT_LENGTH 4
128 #define DBG_S_C_DMT_PSECT_SIZE 8
130 /* VMS module header. */
146 #define EMH_DATE_LENGTH 17
148 /* VMS End-Of-Module records (EOM/EEOM). */
152 unsigned int eom_l_total_lps
;
153 unsigned short eom_w_comcod
;
154 bfd_boolean eom_has_transfer
;
155 unsigned char eom_b_tfrflg
;
156 unsigned int eom_l_psindx
;
157 unsigned int eom_l_tfradr
;
160 struct vms_symbol_entry
166 unsigned char data_type
;
167 unsigned short flags
;
169 /* Section and offset/value of the symbol. */
173 /* Section and offset/value for the entry point (only for subprg). */
174 asection
*code_section
;
175 unsigned int code_value
;
177 /* Symbol vector offset. */
178 unsigned int symbol_vector
;
180 /* Length of the name. */
181 unsigned char namelen
;
186 /* Stack value for push/pop commands. */
194 #define STACKSIZE 128
196 /* A minimal decoding of DST compilation units. We only decode
197 what's needed to get to the line number information. */
207 struct srecinfo
*next
;
215 struct lineinfo
*next
;
222 struct funcinfo
*next
;
230 /* Chain the previously read compilation unit. */
233 /* The module name. */
236 /* The start offset and size of debug info in the DST section. */
240 /* The lowest and highest addresses contained in this compilation
241 unit as specified in the compilation unit header. */
245 /* The listing line table. */
246 struct lineinfo
*line_table
;
248 /* The source record table. */
249 struct srecinfo
*srec_table
;
251 /* A list of the functions found in this module. */
252 struct funcinfo
*func_table
;
254 /* Current allocation of file_table. */
255 unsigned int file_table_count
;
257 /* An array of the files making up this module. */
258 struct fileinfo
*file_table
;
261 /* BFD private data for alpha-vms. */
263 struct vms_private_data_struct
265 /* If true, relocs have been read. */
266 bfd_boolean reloc_done
;
268 /* Record input buffer. */
269 struct vms_rec_rd recrd
;
270 struct vms_rec_wr recwr
;
272 struct hdr_struct hdr_data
; /* data from HDR/EMH record */
273 struct eom_struct eom_data
; /* data from EOM/EEOM record */
275 /* Transfer addresses (entry points). */
276 bfd_vma transfer_address
[4];
278 /* Array of GSD sections to get the correspond BFD one. */
279 unsigned int section_max
; /* Size of the sections array. */
280 unsigned int section_count
; /* Number of GSD sections. */
283 /* Array of raw symbols. */
284 struct vms_symbol_entry
**syms
;
286 /* Canonicalized symbols. */
289 /* Number of symbols. */
290 unsigned int gsd_sym_count
;
291 /* Size of the syms array. */
292 unsigned int max_sym_count
;
293 /* Number of procedure symbols. */
294 unsigned int norm_sym_count
;
296 /* Stack used to evaluate TIR/ETIR commands. */
297 struct stack_struct
*stack
;
300 /* Content reading. */
301 asection
*image_section
; /* section for image_ptr */
302 file_ptr image_offset
; /* Offset for image_ptr. */
304 struct module
*modules
; /* list of all compilation units */
306 /* The DST section. */
307 asection
*dst_section
;
309 unsigned int dst_ptr_offsets_count
; /* # of offsets in following array */
310 unsigned int *dst_ptr_offsets
; /* array of saved image_ptr offsets */
312 /* Shared library support */
313 bfd_vma symvva
; /* relative virtual address of symbol vector */
315 unsigned char matchctl
;
317 /* Shared library index. This is used for input bfd while linking. */
318 unsigned int shr_index
;
320 /* Used to place structures in the file. */
323 /* Simply linked list of eisd. */
324 struct vms_internal_eisd_map
*eisd_head
;
325 struct vms_internal_eisd_map
*eisd_tail
;
327 /* Simply linked list of eisd for shared libraries. */
328 struct vms_internal_eisd_map
*gbl_eisd_head
;
329 struct vms_internal_eisd_map
*gbl_eisd_tail
;
331 /* linkage index counter used by conditional store commands */
332 unsigned int vms_linkage_index
;
335 #define PRIV2(abfd, name) \
336 (((struct vms_private_data_struct *)(abfd)->tdata.any)->name)
337 #define PRIV(name) PRIV2(abfd,name)
340 /* Used to keep extra VMS specific information for a given section.
342 reloc_size holds the size of the relocation stream, note this
343 is very different from the number of relocations as VMS relocations
346 reloc_stream is the actual stream of relocation entries. */
348 struct vms_section_data_struct
350 /* Maximnum number of entries in sec->relocation. */
353 /* Corresponding eisd. Used only while generating executables. */
354 struct vms_internal_eisd_map
*eisd
;
356 /* PSC flags to be clear. */
359 /* PSC flags to be set. */
363 #define vms_section_data(sec) \
364 ((struct vms_section_data_struct *)sec->used_by_bfd)
366 /* To be called from the debugger. */
367 struct vms_private_data_struct
*bfd_vms_get_data (bfd
*);
369 static int vms_get_remaining_object_record (bfd
*, unsigned int);
370 static bfd_boolean
_bfd_vms_slurp_object_records (bfd
* abfd
);
371 static void alpha_vms_add_fixup_lp (struct bfd_link_info
*, bfd
*, bfd
*);
372 static void alpha_vms_add_fixup_ca (struct bfd_link_info
*, bfd
*, bfd
*);
373 static void alpha_vms_add_fixup_qr (struct bfd_link_info
*, bfd
*, bfd
*,
375 static void alpha_vms_add_fixup_lr (struct bfd_link_info
*, unsigned int,
377 static void alpha_vms_add_lw_reloc (struct bfd_link_info
*);
378 static void alpha_vms_add_qw_reloc (struct bfd_link_info
*);
387 /* Number of elements in VEC. */
389 #define VEC_COUNT(VEC) ((VEC).nbr_el)
391 /* Get the address of the Nth element. */
393 #define VEC_EL(VEC, TYPE, N) (((TYPE *)((VEC).els))[N])
395 #define VEC_INIT(VEC) \
402 /* Be sure there is room for a new element. */
404 static void vector_grow1 (struct vector_type
*vec
, size_t elsz
);
406 /* Allocate room for a new element and return its address. */
408 #define VEC_APPEND(VEC, TYPE) \
409 (vector_grow1 (&VEC, sizeof (TYPE)), &VEC_EL(VEC, TYPE, (VEC).nbr_el++))
411 /* Append an element. */
413 #define VEC_APPEND_EL(VEC, TYPE, EL) \
414 (*(VEC_APPEND (VEC, TYPE)) = EL)
416 struct alpha_vms_vma_ref
418 bfd_vma vma
; /* Vma in the output. */
419 bfd_vma ref
; /* Reference in the input. */
422 struct alpha_vms_shlib_el
425 bfd_boolean has_fixups
;
427 struct vector_type lp
; /* Vector of bfd_vma. */
428 struct vector_type ca
; /* Vector of bfd_vma. */
429 struct vector_type qr
; /* Vector of struct alpha_vms_vma_ref. */
432 /* Alpha VMS linker hash table. */
434 struct alpha_vms_link_hash_table
436 struct bfd_link_hash_table root
;
438 /* Vector of shared libraries. */
439 struct vector_type shrlibs
;
444 /* Base address. Used by fixups. */
448 #define alpha_vms_link_hash(INFO) \
449 ((struct alpha_vms_link_hash_table *)(INFO->hash))
451 /* Alpha VMS linker hash table entry. */
453 struct alpha_vms_link_hash_entry
455 struct bfd_link_hash_entry root
;
457 /* Pointer to the original vms symbol. */
458 struct vms_symbol_entry
*sym
;
463 /* Read & process EIHD record.
464 Return TRUE on success, FALSE on error. */
467 _bfd_vms_slurp_eihd (bfd
*abfd
, unsigned int *eisd_offset
,
468 unsigned int *eihs_offset
)
470 unsigned int imgtype
, size
;
472 struct vms_eihd
*eihd
= (struct vms_eihd
*)PRIV (recrd
.rec
);
474 vms_debug2 ((8, "_bfd_vms_slurp_eihd\n"));
476 /* PR 21813: Check for an undersized record. */
477 if (PRIV (recrd
.buf_size
) < sizeof (* eihd
))
479 _bfd_error_handler (_("corrupt EIHD record - size is too small"));
480 bfd_set_error (bfd_error_bad_value
);
484 size
= bfd_getl32 (eihd
->size
);
485 imgtype
= bfd_getl32 (eihd
->imgtype
);
487 if (imgtype
== EIHD__K_EXE
|| imgtype
== EIHD__K_LIM
)
488 abfd
->flags
|= EXEC_P
;
490 symvva
= bfd_getl64 (eihd
->symvva
);
493 PRIV (symvva
) = symvva
;
494 abfd
->flags
|= DYNAMIC
;
497 PRIV (ident
) = bfd_getl32 (eihd
->ident
);
498 PRIV (matchctl
) = eihd
->matchctl
;
500 *eisd_offset
= bfd_getl32 (eihd
->isdoff
);
501 *eihs_offset
= bfd_getl32 (eihd
->symdbgoff
);
503 vms_debug2 ((4, "EIHD size %d imgtype %d symvva 0x%lx eisd %d eihs %d\n",
504 size
, imgtype
, (unsigned long)symvva
,
505 *eisd_offset
, *eihs_offset
));
510 /* Read & process EISD record.
511 Return TRUE on success, FALSE on error. */
514 _bfd_vms_slurp_eisd (bfd
*abfd
, unsigned int offset
)
516 int section_count
= 0;
518 vms_debug2 ((8, "_bfd_vms_slurp_eisd\n"));
522 struct vms_eisd
*eisd
;
523 unsigned int rec_size
;
532 /* PR 17512: file: 3d9e9fe9.
533 12 is the offset of the eisdsize field from the start of the record (8)
534 plus the size of the eisdsize field (4). */
535 if (offset
>= PRIV (recrd
.rec_size
) - 12)
537 eisd
= (struct vms_eisd
*)(PRIV (recrd
.rec
) + offset
);
538 rec_size
= bfd_getl32 (eisd
->eisdsize
);
542 /* Skip to next block if pad. */
543 if (rec_size
== 0xffffffff)
545 offset
= (offset
+ VMS_BLOCK_SIZE
) & ~(VMS_BLOCK_SIZE
- 1);
549 /* Make sure that there is enough data present in the record. */
550 /* FIXME: Should we use sizeof (struct vms_eisd) rather than just 32 here ? */
553 /* Make sure that the record is not too big either. */
554 if (offset
+ rec_size
>= PRIV (recrd
.rec_size
))
559 size
= bfd_getl32 (eisd
->secsize
);
560 vaddr
= bfd_getl64 (eisd
->virt_addr
);
561 flags
= bfd_getl32 (eisd
->flags
);
562 vbn
= bfd_getl32 (eisd
->vbn
);
564 vms_debug2 ((4, "EISD at 0x%x size 0x%x addr 0x%lx flags 0x%x blk %d\n",
565 offset
, size
, (unsigned long)vaddr
, flags
, vbn
));
567 /* VMS combines psects from .obj files into isects in the .exe. This
568 process doesn't preserve enough information to reliably determine
569 what's in each section without examining the data. This is
570 especially true of DWARF debug sections. */
571 bfd_flags
= SEC_ALLOC
;
573 bfd_flags
|= SEC_HAS_CONTENTS
| SEC_LOAD
;
575 if (flags
& EISD__M_EXE
)
576 bfd_flags
|= SEC_CODE
;
578 if (flags
& EISD__M_NONSHRADR
)
579 bfd_flags
|= SEC_DATA
;
581 if (!(flags
& EISD__M_WRT
))
582 bfd_flags
|= SEC_READONLY
;
584 if (flags
& EISD__M_DZRO
)
585 bfd_flags
|= SEC_DATA
;
587 if (flags
& EISD__M_FIXUPVEC
)
588 bfd_flags
|= SEC_DATA
;
590 if (flags
& EISD__M_CRF
)
591 bfd_flags
|= SEC_DATA
;
593 if (flags
& EISD__M_GBL
)
595 if (rec_size
< offsetof (struct vms_eisd
, gblnam
))
597 else if (rec_size
< sizeof (struct vms_eisd
))
598 name
= _bfd_vms_save_counted_string (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"),
662 bfd_set_error (bfd_error_file_truncated
);
666 gstvbn
= bfd_getl32 (p
+ EIHS__L_GSTVBN
);
667 gstsize
= bfd_getl32 (p
+ EIHS__L_GSTSIZE
);
668 dstvbn
= bfd_getl32 (p
+ EIHS__L_DSTVBN
);
669 dstsize
= bfd_getl32 (p
+ EIHS__L_DSTSIZE
);
670 dmtvbn
= bfd_getl32 (p
+ EIHS__L_DMTVBN
);
671 dmtbytes
= bfd_getl32 (p
+ EIHS__L_DMTBYTES
);
674 vms_debug (8, "_bfd_vms_slurp_ihs\n");
675 vms_debug (4, "EIHS record gstvbn %d gstsize %d dstvbn %d dstsize %d dmtvbn %d dmtbytes %d\n",
676 gstvbn
, gstsize
, dstvbn
, dstsize
, dmtvbn
, dmtbytes
);
681 flagword bfd_flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
;
683 section
= bfd_make_section (abfd
, "$DST$");
687 section
->size
= dstsize
;
688 section
->filepos
= VMS_BLOCK_SIZE
* (dstvbn
- 1);
690 if (!bfd_set_section_flags (abfd
, section
, bfd_flags
))
693 PRIV (dst_section
) = section
;
694 abfd
->flags
|= (HAS_DEBUG
| HAS_LINENO
);
699 flagword bfd_flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
;
701 section
= bfd_make_section (abfd
, "$DMT$");
705 section
->size
= dmtbytes
;
706 section
->filepos
= VMS_BLOCK_SIZE
* (dmtvbn
- 1);
708 if (!bfd_set_section_flags (abfd
, section
, bfd_flags
))
714 if (bfd_seek (abfd
, VMS_BLOCK_SIZE
* (gstvbn
- 1), SEEK_SET
))
716 bfd_set_error (bfd_error_file_truncated
);
720 if (!_bfd_vms_slurp_object_records (abfd
))
723 abfd
->flags
|= HAS_SYMS
;
729 /* Object file reading. */
731 /* Object file input functions. */
733 /* Get next record from object file to vms_buf.
734 Set PRIV(buf_size) and return it
736 This is a little tricky since it should be portable.
738 The openVMS object file has 'variable length' which means that
739 read() returns data in chunks of (hopefully) correct and expected
740 size. The linker (and other tools on VMS) depend on that. Unix
741 doesn't know about 'formatted' files, so reading and writing such
742 an object file in a Unix environment is not trivial.
744 With the tool 'file' (available on all VMS FTP sites), one
745 can view and change the attributes of a file. Changing from
746 'variable length' to 'fixed length, 512 bytes' reveals the
747 record size at the first 2 bytes of every record. The same
748 may happen during the transfer of object files from VMS to Unix,
749 at least with UCX, the DEC implementation of TCP/IP.
751 The VMS format repeats the size at bytes 2 & 3 of every record.
753 On the first call (file_format == FF_UNKNOWN) we check if
754 the first and the third byte pair (!) of the record match.
755 If they do it's an object file in an Unix environment or with
756 wrong attributes (FF_FOREIGN), else we should be in a VMS
757 environment where read() returns the record size (FF_NATIVE).
759 Reading is always done in 2 steps:
760 1. first just the record header is read and the size extracted,
761 2. then the read buffer is adjusted and the remaining bytes are
764 All file I/O is done on even file positions. */
766 #define VMS_OBJECT_ADJUSTMENT 2
769 maybe_adjust_record_pointer_for_object (bfd
*abfd
)
771 /* Set the file format once for all on the first invocation. */
772 if (PRIV (recrd
.file_format
) == FF_UNKNOWN
)
774 if (PRIV (recrd
.rec
)[0] == PRIV (recrd
.rec
)[4]
775 && PRIV (recrd
.rec
)[1] == PRIV (recrd
.rec
)[5])
776 PRIV (recrd
.file_format
) = FF_FOREIGN
;
778 PRIV (recrd
.file_format
) = FF_NATIVE
;
781 /* The adjustment is needed only in an Unix environment. */
782 if (PRIV (recrd
.file_format
) == FF_FOREIGN
)
783 PRIV (recrd
.rec
) += VMS_OBJECT_ADJUSTMENT
;
786 /* Implement step #1 of the object record reading procedure.
787 Return the record type or -1 on failure. */
790 _bfd_vms_get_object_record (bfd
*abfd
)
792 unsigned int test_len
= 6;
795 vms_debug2 ((8, "_bfd_vms_get_obj_record\n"));
797 /* Skip alignment byte if the current position is odd. */
798 if (PRIV (recrd
.file_format
) == FF_FOREIGN
&& (bfd_tell (abfd
) & 1))
800 if (bfd_bread (PRIV (recrd
.buf
), 1, abfd
) != 1)
802 bfd_set_error (bfd_error_file_truncated
);
807 /* Read the record header */
808 if (bfd_bread (PRIV (recrd
.buf
), test_len
, abfd
) != test_len
)
810 bfd_set_error (bfd_error_file_truncated
);
814 /* Reset the record pointer. */
815 PRIV (recrd
.rec
) = PRIV (recrd
.buf
);
816 maybe_adjust_record_pointer_for_object (abfd
);
818 if (vms_get_remaining_object_record (abfd
, test_len
) <= 0)
821 type
= bfd_getl16 (PRIV (recrd
.rec
));
823 vms_debug2 ((8, "_bfd_vms_get_obj_record: rec %p, size %d, type %d\n",
824 PRIV (recrd
.rec
), PRIV (recrd
.rec_size
), type
));
829 /* Implement step #2 of the object record reading procedure.
830 Return the size of the record or 0 on failure. */
833 vms_get_remaining_object_record (bfd
*abfd
, unsigned int read_so_far
)
835 unsigned int to_read
;
837 vms_debug2 ((8, "vms_get_remaining_obj_record\n"));
839 /* Extract record size. */
840 PRIV (recrd
.rec_size
) = bfd_getl16 (PRIV (recrd
.rec
) + 2);
842 if (PRIV (recrd
.rec_size
) == 0)
844 bfd_set_error (bfd_error_file_truncated
);
848 /* That's what the linker manual says. */
849 if (PRIV (recrd
.rec_size
) > EOBJ__C_MAXRECSIZ
)
851 bfd_set_error (bfd_error_file_truncated
);
855 /* Take into account object adjustment. */
856 to_read
= PRIV (recrd
.rec_size
);
857 if (PRIV (recrd
.file_format
) == FF_FOREIGN
)
858 to_read
+= VMS_OBJECT_ADJUSTMENT
;
860 /* Adjust the buffer. */
861 if (to_read
> PRIV (recrd
.buf_size
))
864 = (unsigned char *) bfd_realloc (PRIV (recrd
.buf
), to_read
);
865 if (PRIV (recrd
.buf
) == NULL
)
867 PRIV (recrd
.buf_size
) = to_read
;
869 /* PR 17512: file: 025-1974-0.004. */
870 else if (to_read
<= read_so_far
)
873 /* Read the remaining record. */
874 to_read
-= read_so_far
;
876 vms_debug2 ((8, "vms_get_remaining_obj_record: to_read %d\n", to_read
));
878 if (bfd_bread (PRIV (recrd
.buf
) + read_so_far
, to_read
, abfd
) != to_read
)
880 bfd_set_error (bfd_error_file_truncated
);
884 /* Reset the record pointer. */
885 PRIV (recrd
.rec
) = PRIV (recrd
.buf
);
886 maybe_adjust_record_pointer_for_object (abfd
);
888 vms_debug2 ((8, "vms_get_remaining_obj_record: size %d\n",
889 PRIV (recrd
.rec_size
)));
891 return PRIV (recrd
.rec_size
);
894 /* Read and process emh record.
895 Return TRUE on success, FALSE on error. */
898 _bfd_vms_slurp_ehdr (bfd
*abfd
)
901 unsigned char *vms_rec
;
905 vms_rec
= PRIV (recrd
.rec
);
906 /* PR 17512: file: 62736583. */
907 end
= PRIV (recrd
.buf
) + PRIV (recrd
.buf_size
);
909 vms_debug2 ((2, "HDR/EMH\n"));
911 subtype
= bfd_getl16 (vms_rec
+ 4);
913 vms_debug2 ((3, "subtype %d\n", subtype
));
919 if (vms_rec
+ 21 >= end
)
921 PRIV (hdr_data
).hdr_b_strlvl
= vms_rec
[6];
922 PRIV (hdr_data
).hdr_l_arch1
= bfd_getl32 (vms_rec
+ 8);
923 PRIV (hdr_data
).hdr_l_arch2
= bfd_getl32 (vms_rec
+ 12);
924 PRIV (hdr_data
).hdr_l_recsiz
= bfd_getl32 (vms_rec
+ 16);
925 if ((vms_rec
+ 20 + vms_rec
[20] + 1) >= end
)
927 PRIV (hdr_data
).hdr_t_name
= _bfd_vms_save_counted_string (vms_rec
+ 20, vms_rec
[20]);
928 ptr
= vms_rec
+ 20 + vms_rec
[20] + 1;
929 if ((ptr
+ *ptr
+ 1) >= end
)
931 PRIV (hdr_data
).hdr_t_version
=_bfd_vms_save_counted_string (ptr
, *ptr
);
935 PRIV (hdr_data
).hdr_t_date
= _bfd_vms_save_sized_string (ptr
, 17);
939 if (vms_rec
+ PRIV (recrd
.rec_size
- 6) > end
)
941 PRIV (hdr_data
).hdr_c_lnm
=
942 _bfd_vms_save_sized_string (vms_rec
, PRIV (recrd
.rec_size
- 6));
946 if (vms_rec
+ PRIV (recrd
.rec_size
- 6) > end
)
948 PRIV (hdr_data
).hdr_c_src
=
949 _bfd_vms_save_sized_string (vms_rec
, PRIV (recrd
.rec_size
- 6));
953 if (vms_rec
+ PRIV (recrd
.rec_size
- 6) > end
)
955 PRIV (hdr_data
).hdr_c_ttl
=
956 _bfd_vms_save_sized_string (vms_rec
, PRIV (recrd
.rec_size
- 6));
966 bfd_set_error (bfd_error_wrong_format
);
973 /* Typical sections for evax object files. */
975 #define EVAX_ABS_NAME "$ABS$"
976 #define EVAX_CODE_NAME "$CODE$"
977 #define EVAX_LINK_NAME "$LINK$"
978 #define EVAX_DATA_NAME "$DATA$"
979 #define EVAX_BSS_NAME "$BSS$"
980 #define EVAX_READONLYADDR_NAME "$READONLY_ADDR$"
981 #define EVAX_READONLY_NAME "$READONLY$"
982 #define EVAX_LITERAL_NAME "$LITERAL$"
983 #define EVAX_LITERALS_NAME "$LITERALS"
984 #define EVAX_COMMON_NAME "$COMMON$"
985 #define EVAX_LOCAL_NAME "$LOCAL$"
987 struct sec_flags_struct
989 const char *name
; /* Name of section. */
991 flagword flags_always
; /* Flags we set always. */
993 flagword flags_hassize
; /* Flags we set if the section has a size > 0. */
996 /* These flags are deccrtl/vaxcrtl (openVMS 6.2 Alpha) compatible. */
998 static const struct sec_flags_struct evax_section_flags
[] =
1006 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_EXE
,
1007 SEC_CODE
| SEC_READONLY
,
1008 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_EXE
,
1009 SEC_CODE
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1010 { EVAX_LITERAL_NAME
,
1011 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
| EGPS__V_NOMOD
,
1012 SEC_DATA
| SEC_READONLY
,
1013 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
,
1014 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1016 EGPS__V_REL
| EGPS__V_RD
,
1017 SEC_DATA
| SEC_READONLY
,
1018 EGPS__V_REL
| EGPS__V_RD
,
1019 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1021 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
,
1023 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1024 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1026 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
,
1028 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
,
1030 { EVAX_READONLYADDR_NAME
,
1031 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_RD
,
1032 SEC_DATA
| SEC_READONLY
,
1033 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_RD
,
1034 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1035 { EVAX_READONLY_NAME
,
1036 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
| EGPS__V_NOMOD
,
1037 SEC_DATA
| SEC_READONLY
,
1038 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
,
1039 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1041 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1043 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1044 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1045 { EVAX_LITERALS_NAME
,
1046 EGPS__V_PIC
| EGPS__V_OVR
,
1047 SEC_DATA
| SEC_READONLY
,
1048 EGPS__V_PIC
| EGPS__V_OVR
,
1049 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1051 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1053 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1054 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
}
1057 /* Retrieve BFD section flags by name and size. */
1060 vms_secflag_by_name (const struct sec_flags_struct
*section_flags
,
1066 while (section_flags
[i
].name
!= NULL
)
1068 if (strcmp (name
, section_flags
[i
].name
) == 0)
1071 return section_flags
[i
].flags_hassize
;
1073 return section_flags
[i
].flags_always
;
1078 return section_flags
[i
].flags_hassize
;
1079 return section_flags
[i
].flags_always
;
1082 /* Retrieve VMS section flags by name and size. */
1085 vms_esecflag_by_name (const struct sec_flags_struct
*section_flags
,
1091 while (section_flags
[i
].name
!= NULL
)
1093 if (strcmp (name
, section_flags
[i
].name
) == 0)
1096 return section_flags
[i
].vflags_hassize
;
1098 return section_flags
[i
].vflags_always
;
1103 return section_flags
[i
].vflags_hassize
;
1104 return section_flags
[i
].vflags_always
;
1107 /* Add SYM to the symbol table of ABFD.
1108 Return FALSE in case of error. */
1111 add_symbol_entry (bfd
*abfd
, struct vms_symbol_entry
*sym
)
1113 if (PRIV (gsd_sym_count
) >= PRIV (max_sym_count
))
1115 if (PRIV (max_sym_count
) == 0)
1117 PRIV (max_sym_count
) = 128;
1118 PRIV (syms
) = bfd_malloc
1119 (PRIV (max_sym_count
) * sizeof (struct vms_symbol_entry
*));
1123 PRIV (max_sym_count
) *= 2;
1124 PRIV (syms
) = bfd_realloc
1126 (PRIV (max_sym_count
) * sizeof (struct vms_symbol_entry
*)));
1128 if (PRIV (syms
) == NULL
)
1132 PRIV (syms
)[PRIV (gsd_sym_count
)++] = sym
;
1136 /* Create a symbol whose name is ASCIC and add it to ABFD.
1137 Return NULL in case of error. */
1139 static struct vms_symbol_entry
*
1140 add_symbol (bfd
*abfd
, const unsigned char *ascic
)
1142 struct vms_symbol_entry
*entry
;
1146 entry
= (struct vms_symbol_entry
*)bfd_zalloc (abfd
, sizeof (*entry
) + len
);
1149 entry
->namelen
= len
;
1150 memcpy (entry
->name
, ascic
, len
);
1151 entry
->name
[len
] = 0;
1152 entry
->owner
= abfd
;
1154 if (!add_symbol_entry (abfd
, entry
))
1159 /* Read and process EGSD. Return FALSE on failure. */
1162 _bfd_vms_slurp_egsd (bfd
*abfd
)
1165 unsigned int gsd_size
;
1166 unsigned char *vms_rec
;
1167 unsigned long base_addr
;
1169 vms_debug2 ((2, "EGSD\n"));
1171 if (PRIV (recrd
.rec_size
) < 8)
1173 _bfd_error_handler (_("corrupt EGSD record: its size (%#x) is too small"),
1174 PRIV (recrd
.rec_size
));
1175 bfd_set_error (bfd_error_bad_value
);
1179 PRIV (recrd
.rec
) += 8; /* Skip type, size, align pad. */
1180 PRIV (recrd
.rec_size
) -= 8;
1182 /* Calculate base address for each section. */
1185 while (PRIV (recrd
.rec_size
) > 4)
1187 vms_rec
= PRIV (recrd
.rec
);
1189 gsd_type
= bfd_getl16 (vms_rec
);
1190 gsd_size
= bfd_getl16 (vms_rec
+ 2);
1192 vms_debug2 ((3, "egsd_type %d\n", gsd_type
));
1194 /* PR 21615: Check for size overflow. */
1195 if (PRIV (recrd
.rec_size
) < gsd_size
)
1197 _bfd_error_handler (_("corrupt EGSD record: size (%#x) is larger than remaining space (%#x)"),
1198 gsd_size
, PRIV (recrd
.rec_size
));
1199 bfd_set_error (bfd_error_bad_value
);
1205 _bfd_error_handler (_("corrupt EGSD record: size (%#x) is too small"),
1207 bfd_set_error (bfd_error_bad_value
);
1214 /* Program section definition. */
1216 struct vms_egps
*egps
= (struct vms_egps
*)vms_rec
;
1217 flagword new_flags
, vms_flags
;
1220 vms_flags
= bfd_getl16 (egps
->flags
);
1222 if ((vms_flags
& EGPS__V_REL
) == 0)
1224 /* Use the global absolute section for all
1225 absolute sections. */
1226 section
= bfd_abs_section_ptr
;
1231 unsigned long align_addr
;
1233 name
= _bfd_vms_save_counted_string (&egps
->namlng
, gsd_size
- 4);
1235 section
= bfd_make_section (abfd
, name
);
1239 section
->filepos
= 0;
1240 section
->size
= bfd_getl32 (egps
->alloc
);
1241 section
->alignment_power
= egps
->align
;
1243 vms_section_data (section
)->flags
= vms_flags
;
1244 vms_section_data (section
)->no_flags
= 0;
1246 new_flags
= vms_secflag_by_name (evax_section_flags
, name
,
1248 if (section
->size
> 0)
1249 new_flags
|= SEC_LOAD
;
1250 if (!(vms_flags
& EGPS__V_NOMOD
) && section
->size
> 0)
1252 /* Set RELOC and HAS_CONTENTS if the section is not
1253 demand-zero and not empty. */
1254 new_flags
|= SEC_HAS_CONTENTS
;
1255 if (vms_flags
& EGPS__V_REL
)
1256 new_flags
|= SEC_RELOC
;
1258 if (vms_flags
& EGPS__V_EXE
)
1260 /* Set CODE if section is executable. */
1261 new_flags
|= SEC_CODE
;
1262 new_flags
&= ~SEC_DATA
;
1264 if (!bfd_set_section_flags (abfd
, section
, new_flags
))
1267 /* Give a non-overlapping vma to non absolute sections. */
1268 align_addr
= (1 << section
->alignment_power
);
1269 if ((base_addr
% align_addr
) != 0)
1270 base_addr
+= (align_addr
- (base_addr
% align_addr
));
1271 section
->vma
= (bfd_vma
)base_addr
;
1272 base_addr
+= section
->size
;
1275 /* Append it to the section array. */
1276 if (PRIV (section_count
) >= PRIV (section_max
))
1278 if (PRIV (section_max
) == 0)
1279 PRIV (section_max
) = 16;
1281 PRIV (section_max
) *= 2;
1282 PRIV (sections
) = bfd_realloc_or_free
1283 (PRIV (sections
), PRIV (section_max
) * sizeof (asection
*));
1284 if (PRIV (sections
) == NULL
)
1288 PRIV (sections
)[PRIV (section_count
)] = section
;
1289 PRIV (section_count
)++;
1296 struct vms_symbol_entry
*entry
;
1297 struct vms_egsy
*egsy
= (struct vms_egsy
*) vms_rec
;
1300 old_flags
= bfd_getl16 (egsy
->flags
);
1301 if (old_flags
& EGSY__V_DEF
)
1302 nameoff
= ESDF__B_NAMLNG
;
1304 nameoff
= ESRF__B_NAMLNG
;
1306 entry
= add_symbol (abfd
, vms_rec
+ nameoff
);
1310 /* Allow only duplicate reference. */
1311 if ((entry
->flags
& EGSY__V_DEF
) && (old_flags
& EGSY__V_DEF
))
1314 if (entry
->typ
== 0)
1316 entry
->typ
= gsd_type
;
1317 entry
->data_type
= egsy
->datyp
;
1318 entry
->flags
= old_flags
;
1321 if (old_flags
& EGSY__V_DEF
)
1323 struct vms_esdf
*esdf
= (struct vms_esdf
*)vms_rec
;
1326 entry
->value
= bfd_getl64 (esdf
->value
);
1327 if (PRIV (sections
) == NULL
)
1330 psindx
= bfd_getl32 (esdf
->psindx
);
1331 /* PR 21813: Check for an out of range index. */
1332 if (psindx
< 0 || psindx
>= (int) PRIV (section_count
))
1334 _bfd_error_handler (_("corrupt EGSD record: its psindx field is too big (%#lx)"),
1336 bfd_set_error (bfd_error_bad_value
);
1339 entry
->section
= PRIV (sections
)[psindx
];
1341 if (old_flags
& EGSY__V_NORM
)
1343 PRIV (norm_sym_count
)++;
1345 entry
->code_value
= bfd_getl64 (esdf
->code_address
);
1346 psindx
= bfd_getl32 (esdf
->ca_psindx
);
1347 /* PR 21813: Check for an out of range index. */
1348 if (psindx
< 0 || psindx
>= (int) PRIV (section_count
))
1350 _bfd_error_handler (_("corrupt EGSD record: its psindx field is too big (%#lx)"),
1352 bfd_set_error (bfd_error_bad_value
);
1355 entry
->code_section
= PRIV (sections
)[psindx
];
1363 struct vms_symbol_entry
*entry
;
1364 struct vms_egst
*egst
= (struct vms_egst
*)vms_rec
;
1367 old_flags
= bfd_getl16 (egst
->header
.flags
);
1369 entry
= add_symbol (abfd
, &egst
->namlng
);
1374 entry
->typ
= gsd_type
;
1375 entry
->data_type
= egst
->header
.datyp
;
1376 entry
->flags
= old_flags
;
1378 entry
->symbol_vector
= bfd_getl32 (egst
->value
);
1380 if (old_flags
& EGSY__V_REL
)
1384 if (PRIV (sections
) == NULL
)
1386 psindx
= bfd_getl32 (egst
->psindx
);
1387 /* PR 21813: Check for an out of range index. */
1388 if (psindx
< 0 || psindx
>= (int) PRIV (section_count
))
1390 _bfd_error_handler (_("corrupt EGSD record: its psindx field is too big (%#lx)"),
1392 bfd_set_error (bfd_error_bad_value
);
1395 entry
->section
= PRIV (sections
)[psindx
];
1398 entry
->section
= bfd_abs_section_ptr
;
1400 entry
->value
= bfd_getl64 (egst
->lp_2
);
1402 if (old_flags
& EGSY__V_NORM
)
1404 PRIV (norm_sym_count
)++;
1406 entry
->code_value
= bfd_getl64 (egst
->lp_1
);
1407 entry
->code_section
= bfd_abs_section_ptr
;
1414 /* Currently ignored. */
1419 _bfd_error_handler (_("unknown EGSD subtype %d"), gsd_type
);
1420 bfd_set_error (bfd_error_bad_value
);
1424 PRIV (recrd
.rec_size
) -= gsd_size
;
1425 PRIV (recrd
.rec
) += gsd_size
;
1428 /* FIXME: Should we complain if PRIV (recrd.rec_size) is not zero ? */
1430 if (PRIV (gsd_sym_count
) > 0)
1431 abfd
->flags
|= HAS_SYMS
;
1436 /* Stack routines for vms ETIR commands. */
1438 /* Push value and section index. */
1441 _bfd_vms_push (bfd
*abfd
, bfd_vma val
, unsigned int reloc
)
1443 vms_debug2 ((4, "<push %08lx (0x%08x) at %d>\n",
1444 (unsigned long)val
, reloc
, PRIV (stackptr
)));
1446 PRIV (stack
[PRIV (stackptr
)]).value
= val
;
1447 PRIV (stack
[PRIV (stackptr
)]).reloc
= reloc
;
1449 if (PRIV (stackptr
) >= STACKSIZE
)
1451 bfd_set_error (bfd_error_bad_value
);
1452 _bfd_error_handler (_("stack overflow (%d) in _bfd_vms_push"), PRIV (stackptr
));
1457 /* Pop value and section index. */
1460 _bfd_vms_pop (bfd
*abfd
, bfd_vma
*val
, unsigned int *rel
)
1462 if (PRIV (stackptr
) == 0)
1464 bfd_set_error (bfd_error_bad_value
);
1465 _bfd_error_handler (_("stack underflow in _bfd_vms_pop"));
1469 *val
= PRIV (stack
[PRIV (stackptr
)]).value
;
1470 *rel
= PRIV (stack
[PRIV (stackptr
)]).reloc
;
1472 vms_debug2 ((4, "<pop %08lx (0x%08x)>\n", (unsigned long)*val
, *rel
));
1475 /* Routines to fill sections contents during tir/etir read. */
1477 /* Initialize image buffer pointer to be filled. */
1480 image_set_ptr (bfd
*abfd
, bfd_vma vma
, int sect
, struct bfd_link_info
*info
)
1484 vms_debug2 ((4, "image_set_ptr (0x%08x, sect=%d)\n", (unsigned)vma
, sect
));
1486 if (PRIV (sections
) == NULL
)
1488 if (sect
< 0 || sect
>= (int) PRIV (section_count
))
1491 sec
= PRIV (sections
)[sect
];
1495 /* Reading contents to an output bfd. */
1497 if (sec
->output_section
== NULL
)
1499 /* Section discarded. */
1500 vms_debug2 ((5, " section %s discarded\n", sec
->name
));
1502 /* This is not used. */
1503 PRIV (image_section
) = NULL
;
1504 PRIV (image_offset
) = 0;
1507 PRIV (image_offset
) = sec
->output_offset
+ vma
;
1508 PRIV (image_section
) = sec
->output_section
;
1512 PRIV (image_offset
) = vma
;
1513 PRIV (image_section
) = sec
;
1517 /* Increment image buffer pointer by offset. */
1520 image_inc_ptr (bfd
*abfd
, bfd_vma offset
)
1522 vms_debug2 ((4, "image_inc_ptr (%u)\n", (unsigned)offset
));
1524 PRIV (image_offset
) += offset
;
1527 /* Save current DST location counter under specified index. */
1530 dst_define_location (bfd
*abfd
, unsigned int loc
)
1532 vms_debug2 ((4, "dst_define_location (%d)\n", (int)loc
));
1534 /* Grow the ptr offset table if necessary. */
1535 if (loc
+ 1 > PRIV (dst_ptr_offsets_count
))
1537 PRIV (dst_ptr_offsets
) = bfd_realloc (PRIV (dst_ptr_offsets
),
1538 (loc
+ 1) * sizeof (unsigned int));
1539 PRIV (dst_ptr_offsets_count
) = loc
+ 1;
1542 PRIV (dst_ptr_offsets
)[loc
] = PRIV (image_offset
);
1545 /* Restore saved DST location counter from specified index. */
1548 dst_restore_location (bfd
*abfd
, unsigned int loc
)
1550 vms_debug2 ((4, "dst_restore_location (%d)\n", (int)loc
));
1552 PRIV (image_offset
) = PRIV (dst_ptr_offsets
)[loc
];
1555 /* Retrieve saved DST location counter from specified index. */
1558 dst_retrieve_location (bfd
*abfd
, unsigned int loc
)
1560 vms_debug2 ((4, "dst_retrieve_location (%d)\n", (int)loc
));
1562 return PRIV (dst_ptr_offsets
)[loc
];
1565 /* Write multiple bytes to section image. */
1568 image_write (bfd
*abfd
, unsigned char *ptr
, unsigned int size
)
1571 _bfd_vms_debug (8, "image_write from (%p, %d) to (%ld)\n", ptr
, size
,
1572 (long)PRIV (image_offset
));
1573 _bfd_hexdump (9, ptr
, size
, 0);
1576 if (PRIV (image_section
)->contents
!= NULL
)
1578 asection
*sec
= PRIV (image_section
);
1579 file_ptr off
= PRIV (image_offset
);
1582 if (off
> (file_ptr
)sec
->size
1583 || size
> (file_ptr
)sec
->size
1584 || off
+ size
> (file_ptr
)sec
->size
)
1586 bfd_set_error (bfd_error_bad_value
);
1590 memcpy (sec
->contents
+ off
, ptr
, size
);
1593 PRIV (image_offset
) += size
;
1597 /* Write byte to section image. */
1600 image_write_b (bfd
* abfd
, unsigned int value
)
1602 unsigned char data
[1];
1604 vms_debug2 ((6, "image_write_b (%02x)\n", (int) value
));
1608 return image_write (abfd
, data
, sizeof (data
));
1611 /* Write 2-byte word to image. */
1614 image_write_w (bfd
* abfd
, unsigned int value
)
1616 unsigned char data
[2];
1618 vms_debug2 ((6, "image_write_w (%04x)\n", (int) value
));
1620 bfd_putl16 (value
, data
);
1621 return image_write (abfd
, data
, sizeof (data
));
1624 /* Write 4-byte long to image. */
1627 image_write_l (bfd
* abfd
, unsigned long value
)
1629 unsigned char data
[4];
1631 vms_debug2 ((6, "image_write_l (%08lx)\n", value
));
1633 bfd_putl32 (value
, data
);
1634 return image_write (abfd
, data
, sizeof (data
));
1637 /* Write 8-byte quad to image. */
1640 image_write_q (bfd
* abfd
, bfd_vma value
)
1642 unsigned char data
[8];
1644 vms_debug2 ((6, "image_write_q (%08lx)\n", (unsigned long)value
));
1646 bfd_putl64 (value
, data
);
1647 return image_write (abfd
, data
, sizeof (data
));
1651 _bfd_vms_etir_name (int cmd
)
1655 case ETIR__C_STA_GBL
: return "ETIR__C_STA_GBL";
1656 case ETIR__C_STA_LW
: return "ETIR__C_STA_LW";
1657 case ETIR__C_STA_QW
: return "ETIR__C_STA_QW";
1658 case ETIR__C_STA_PQ
: return "ETIR__C_STA_PQ";
1659 case ETIR__C_STA_LI
: return "ETIR__C_STA_LI";
1660 case ETIR__C_STA_MOD
: return "ETIR__C_STA_MOD";
1661 case ETIR__C_STA_CKARG
: return "ETIR__C_STA_CKARG";
1662 case ETIR__C_STO_B
: return "ETIR__C_STO_B";
1663 case ETIR__C_STO_W
: return "ETIR__C_STO_W";
1664 case ETIR__C_STO_GBL
: return "ETIR__C_STO_GBL";
1665 case ETIR__C_STO_CA
: return "ETIR__C_STO_CA";
1666 case ETIR__C_STO_RB
: return "ETIR__C_STO_RB";
1667 case ETIR__C_STO_AB
: return "ETIR__C_STO_AB";
1668 case ETIR__C_STO_OFF
: return "ETIR__C_STO_OFF";
1669 case ETIR__C_STO_IMM
: return "ETIR__C_STO_IMM";
1670 case ETIR__C_STO_IMMR
: return "ETIR__C_STO_IMMR";
1671 case ETIR__C_STO_LW
: return "ETIR__C_STO_LW";
1672 case ETIR__C_STO_QW
: return "ETIR__C_STO_QW";
1673 case ETIR__C_STO_GBL_LW
: return "ETIR__C_STO_GBL_LW";
1674 case ETIR__C_STO_LP_PSB
: return "ETIR__C_STO_LP_PSB";
1675 case ETIR__C_STO_HINT_GBL
: return "ETIR__C_STO_HINT_GBL";
1676 case ETIR__C_STO_HINT_PS
: return "ETIR__C_STO_HINT_PS";
1677 case ETIR__C_OPR_ADD
: return "ETIR__C_OPR_ADD";
1678 case ETIR__C_OPR_SUB
: return "ETIR__C_OPR_SUB";
1679 case ETIR__C_OPR_INSV
: return "ETIR__C_OPR_INSV";
1680 case ETIR__C_OPR_USH
: return "ETIR__C_OPR_USH";
1681 case ETIR__C_OPR_ROT
: return "ETIR__C_OPR_ROT";
1682 case ETIR__C_OPR_REDEF
: return "ETIR__C_OPR_REDEF";
1683 case ETIR__C_OPR_DFLIT
: return "ETIR__C_OPR_DFLIT";
1684 case ETIR__C_STC_LP
: return "ETIR__C_STC_LP";
1685 case ETIR__C_STC_GBL
: return "ETIR__C_STC_GBL";
1686 case ETIR__C_STC_GCA
: return "ETIR__C_STC_GCA";
1687 case ETIR__C_STC_PS
: return "ETIR__C_STC_PS";
1688 case ETIR__C_STC_NBH_PS
: return "ETIR__C_STC_NBH_PS";
1689 case ETIR__C_STC_NOP_GBL
: return "ETIR__C_STC_NOP_GBL";
1690 case ETIR__C_STC_NOP_PS
: return "ETIR__C_STC_NOP_PS";
1691 case ETIR__C_STC_BSR_GBL
: return "ETIR__C_STC_BSR_GBL";
1692 case ETIR__C_STC_BSR_PS
: return "ETIR__C_STC_BSR_PS";
1693 case ETIR__C_STC_LDA_GBL
: return "ETIR__C_STC_LDA_GBL";
1694 case ETIR__C_STC_LDA_PS
: return "ETIR__C_STC_LDA_PS";
1695 case ETIR__C_STC_BOH_GBL
: return "ETIR__C_STC_BOH_GBL";
1696 case ETIR__C_STC_BOH_PS
: return "ETIR__C_STC_BOH_PS";
1697 case ETIR__C_STC_NBH_GBL
: return "ETIR__C_STC_NBH_GBL";
1698 case ETIR__C_STC_LP_PSB
: return "ETIR__C_STC_LP_PSB";
1699 case ETIR__C_CTL_SETRB
: return "ETIR__C_CTL_SETRB";
1700 case ETIR__C_CTL_AUGRB
: return "ETIR__C_CTL_AUGRB";
1701 case ETIR__C_CTL_DFLOC
: return "ETIR__C_CTL_DFLOC";
1702 case ETIR__C_CTL_STLOC
: return "ETIR__C_CTL_STLOC";
1703 case ETIR__C_CTL_STKDL
: return "ETIR__C_CTL_STKDL";
1706 /* These names have not yet been added to this switch statement. */
1707 _bfd_error_handler (_("unknown ETIR command %d"), cmd
);
1712 #define HIGHBIT(op) ((op & 0x80000000L) == 0x80000000L)
1715 _bfd_vms_get_value (bfd
*abfd
,
1716 const unsigned char *ascic
,
1717 const unsigned char *max_ascic
,
1718 struct bfd_link_info
*info
,
1720 struct alpha_vms_link_hash_entry
**hp
)
1725 struct alpha_vms_link_hash_entry
*h
;
1727 /* Not linking. Do not try to resolve the symbol. */
1736 if (ascic
+ len
>= max_ascic
)
1738 _bfd_error_handler (_("corrupt vms value"));
1744 for (i
= 0; i
< len
; i
++)
1745 name
[i
] = ascic
[i
+ 1];
1748 h
= (struct alpha_vms_link_hash_entry
*)
1749 bfd_link_hash_lookup (info
->hash
, name
, FALSE
, FALSE
, TRUE
);
1754 && (h
->root
.type
== bfd_link_hash_defined
1755 || h
->root
.type
== bfd_link_hash_defweak
))
1756 *vma
= h
->root
.u
.def
.value
1757 + h
->root
.u
.def
.section
->output_offset
1758 + h
->root
.u
.def
.section
->output_section
->vma
;
1759 else if (h
&& h
->root
.type
== bfd_link_hash_undefweak
)
1763 (*info
->callbacks
->undefined_symbol
)
1764 (info
, name
, abfd
, PRIV (image_section
), PRIV (image_offset
), TRUE
);
1771 #define RELC_SHR_BASE 0x10000
1772 #define RELC_SEC_BASE 0x20000
1773 #define RELC_MASK 0x0ffff
1776 alpha_vms_sym_to_ctxt (struct alpha_vms_link_hash_entry
*h
)
1778 /* Handle undefined symbols. */
1779 if (h
== NULL
|| h
->sym
== NULL
)
1782 if (h
->sym
->typ
== EGSD__C_SYMG
)
1784 if (h
->sym
->flags
& EGSY__V_REL
)
1785 return RELC_SHR_BASE
+ PRIV2 (h
->sym
->owner
, shr_index
);
1788 /* Can this happen (non-relocatable symg) ? I'd like to see
1793 if (h
->sym
->typ
== EGSD__C_SYM
)
1795 if (h
->sym
->flags
& EGSY__V_REL
)
1804 alpha_vms_get_sym_value (asection
*sect
, bfd_vma addr
)
1806 return sect
->output_section
->vma
+ sect
->output_offset
+ addr
;
1810 alpha_vms_fix_sec_rel (bfd
*abfd
, struct bfd_link_info
*info
,
1811 unsigned int rel
, bfd_vma vma
)
1815 if (PRIV (sections
) == NULL
)
1818 sec
= PRIV (sections
)[rel
& RELC_MASK
];
1822 if (sec
->output_section
== NULL
)
1824 return vma
+ sec
->output_section
->vma
+ sec
->output_offset
;
1827 return vma
+ sec
->vma
;
1830 /* Read an ETIR record from ABFD. If INFO is not null, put the content into
1831 the output section (used during linking).
1832 Return FALSE in case of error. */
1835 _bfd_vms_slurp_etir (bfd
*abfd
, struct bfd_link_info
*info
)
1838 unsigned int length
;
1839 unsigned char *maxptr
;
1844 struct alpha_vms_link_hash_entry
*h
;
1846 PRIV (recrd
.rec
) += ETIR__C_HEADER_SIZE
;
1847 PRIV (recrd
.rec_size
) -= ETIR__C_HEADER_SIZE
;
1849 ptr
= PRIV (recrd
.rec
);
1850 length
= PRIV (recrd
.rec_size
);
1851 maxptr
= ptr
+ length
;
1853 vms_debug2 ((2, "ETIR: %d bytes\n", length
));
1855 while (ptr
< maxptr
)
1857 int cmd
= bfd_getl16 (ptr
);
1858 int cmd_length
= bfd_getl16 (ptr
+ 2);
1862 /* PR 21589 and 21579: Check for a corrupt ETIR record. */
1863 if (cmd_length
< 4 || (ptr
+ cmd_length
> maxptr
+ 4))
1866 _bfd_error_handler (_("corrupt ETIR record encountered"));
1867 bfd_set_error (bfd_error_bad_value
);
1872 _bfd_vms_debug (4, "etir: %s(%d)\n",
1873 _bfd_vms_etir_name (cmd
), cmd
);
1874 _bfd_hexdump (8, ptr
, cmd_length
- 4, 0);
1882 stack 32 bit value of symbol (high bits set to 0). */
1883 case ETIR__C_STA_GBL
:
1884 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
1885 _bfd_vms_push (abfd
, op1
, alpha_vms_sym_to_ctxt (h
));
1891 stack 32 bit value, sign extend to 64 bit. */
1892 case ETIR__C_STA_LW
:
1893 if (ptr
+ 4 >= maxptr
)
1895 _bfd_vms_push (abfd
, bfd_getl32 (ptr
), RELC_NONE
);
1901 stack 64 bit value of symbol. */
1902 case ETIR__C_STA_QW
:
1903 if (ptr
+ 8 >= maxptr
)
1905 _bfd_vms_push (abfd
, bfd_getl64 (ptr
), RELC_NONE
);
1908 /* Stack psect base plus quadword offset
1909 arg: lw section index
1910 qw signed quadword offset (low 32 bits)
1912 Stack qw argument and section index
1913 (see ETIR__C_STO_OFF, ETIR__C_CTL_SETRB). */
1914 case ETIR__C_STA_PQ
:
1918 if (ptr
+ 12 >= maxptr
)
1920 psect
= bfd_getl32 (ptr
);
1921 if ((unsigned int) psect
>= PRIV (section_count
))
1923 _bfd_error_handler (_("bad section index in %s"),
1924 _bfd_vms_etir_name (cmd
));
1925 bfd_set_error (bfd_error_bad_value
);
1928 op1
= bfd_getl64 (ptr
+ 4);
1929 _bfd_vms_push (abfd
, op1
, psect
| RELC_SEC_BASE
);
1933 case ETIR__C_STA_LI
:
1934 case ETIR__C_STA_MOD
:
1935 case ETIR__C_STA_CKARG
:
1936 _bfd_error_handler (_("unsupported STA cmd %s"),
1937 _bfd_vms_etir_name (cmd
));
1941 /* Store byte: pop stack, write byte
1944 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1945 if (rel1
!= RELC_NONE
)
1947 image_write_b (abfd
, (unsigned int) op1
& 0xff);
1950 /* Store word: pop stack, write word
1953 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1954 if (rel1
!= RELC_NONE
)
1956 image_write_w (abfd
, (unsigned int) op1
& 0xffff);
1959 /* Store longword: pop stack, write longword
1961 case ETIR__C_STO_LW
:
1962 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1963 if (rel1
& RELC_SEC_BASE
)
1965 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
1968 else if (rel1
& RELC_SHR_BASE
)
1970 alpha_vms_add_fixup_lr (info
, rel1
& RELC_MASK
, op1
);
1973 if (rel1
!= RELC_NONE
)
1975 if (rel1
!= RELC_REL
)
1977 alpha_vms_add_lw_reloc (info
);
1979 image_write_l (abfd
, op1
);
1982 /* Store quadword: pop stack, write quadword
1984 case ETIR__C_STO_QW
:
1985 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1986 if (rel1
& RELC_SEC_BASE
)
1988 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
1991 else if (rel1
& RELC_SHR_BASE
)
1993 if (rel1
!= RELC_NONE
)
1995 if (rel1
!= RELC_REL
)
1997 alpha_vms_add_qw_reloc (info
);
1999 image_write_q (abfd
, op1
);
2002 /* Store immediate repeated: pop stack for repeat count
2005 case ETIR__C_STO_IMMR
:
2009 if (ptr
+ 4 >= maxptr
)
2011 size
= bfd_getl32 (ptr
);
2012 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2013 if (rel1
!= RELC_NONE
)
2016 image_write (abfd
, ptr
+ 4, size
);
2020 /* Store global: write symbol value
2021 arg: cs global symbol name. */
2022 case ETIR__C_STO_GBL
:
2023 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
2026 if (h
->sym
->typ
== EGSD__C_SYMG
)
2028 alpha_vms_add_fixup_qr
2029 (info
, abfd
, h
->sym
->owner
, h
->sym
->symbol_vector
);
2034 op1
= alpha_vms_get_sym_value (h
->sym
->section
,
2036 alpha_vms_add_qw_reloc (info
);
2039 image_write_q (abfd
, op1
);
2042 /* Store code address: write address of entry point
2043 arg: cs global symbol name (procedure). */
2044 case ETIR__C_STO_CA
:
2045 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
2048 if (h
->sym
->flags
& EGSY__V_NORM
)
2050 /* That's really a procedure. */
2051 if (h
->sym
->typ
== EGSD__C_SYMG
)
2053 alpha_vms_add_fixup_ca (info
, abfd
, h
->sym
->owner
);
2054 op1
= h
->sym
->symbol_vector
;
2058 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
2059 h
->sym
->code_value
);
2060 alpha_vms_add_qw_reloc (info
);
2065 /* Symbol is not a procedure. */
2069 image_write_q (abfd
, op1
);
2072 /* Store offset to psect: pop stack, add low 32 bits to base of psect
2074 case ETIR__C_STO_OFF
:
2075 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2077 if (!(rel1
& RELC_SEC_BASE
))
2080 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2082 image_write_q (abfd
, op1
);
2086 arg: lw count of bytes
2088 case ETIR__C_STO_IMM
:
2092 if (ptr
+ 4 >= maxptr
)
2094 size
= bfd_getl32 (ptr
);
2095 image_write (abfd
, ptr
+ 4, size
);
2099 /* This code is 'reserved to digital' according to the openVMS
2100 linker manual, however it is generated by the DEC C compiler
2101 and defined in the include file.
2102 FIXME, since the following is just a guess
2103 store global longword: store 32bit value of symbol
2104 arg: cs symbol name. */
2105 case ETIR__C_STO_GBL_LW
:
2106 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
2110 image_write_l (abfd
, op1
);
2113 case ETIR__C_STO_RB
:
2114 case ETIR__C_STO_AB
:
2115 case ETIR__C_STO_LP_PSB
:
2116 _bfd_error_handler (_("%s: not supported"),
2117 _bfd_vms_etir_name (cmd
));
2120 case ETIR__C_STO_HINT_GBL
:
2121 case ETIR__C_STO_HINT_PS
:
2122 _bfd_error_handler (_("%s: not implemented"),
2123 _bfd_vms_etir_name (cmd
));
2127 /* 200 Store-conditional Linkage Pair
2129 case ETIR__C_STC_LP
:
2131 /* 202 Store-conditional Address at global address
2135 case ETIR__C_STC_GBL
:
2137 /* 203 Store-conditional Code Address at global address
2139 cs procedure name. */
2140 case ETIR__C_STC_GCA
:
2142 /* 204 Store-conditional Address at psect + offset
2146 case ETIR__C_STC_PS
:
2147 _bfd_error_handler (_("%s: not supported"),
2148 _bfd_vms_etir_name (cmd
));
2152 /* 201 Store-conditional Linkage Pair with Procedure Signature
2158 case ETIR__C_STC_LP_PSB
:
2159 _bfd_vms_get_value (abfd
, ptr
+ 4, maxptr
, info
, &op1
, &h
);
2162 if (h
->sym
->typ
== EGSD__C_SYMG
)
2164 alpha_vms_add_fixup_lp (info
, abfd
, h
->sym
->owner
);
2165 op1
= h
->sym
->symbol_vector
;
2170 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
2171 h
->sym
->code_value
);
2172 op2
= alpha_vms_get_sym_value (h
->sym
->section
,
2178 /* Undefined symbol. */
2182 image_write_q (abfd
, op1
);
2183 image_write_q (abfd
, op2
);
2186 /* 205 Store-conditional NOP at address of global
2188 case ETIR__C_STC_NOP_GBL
:
2191 /* 207 Store-conditional BSR at global address
2194 case ETIR__C_STC_BSR_GBL
:
2197 /* 209 Store-conditional LDA at global address
2200 case ETIR__C_STC_LDA_GBL
:
2203 /* 211 Store-conditional BSR or Hint at global address
2206 case ETIR__C_STC_BOH_GBL
:
2207 /* Currentl ignored. */
2210 /* 213 Store-conditional NOP,BSR or HINT at global address
2213 case ETIR__C_STC_NBH_GBL
:
2215 /* 206 Store-conditional NOP at pect + offset
2218 case ETIR__C_STC_NOP_PS
:
2220 /* 208 Store-conditional BSR at pect + offset
2223 case ETIR__C_STC_BSR_PS
:
2225 /* 210 Store-conditional LDA at psect + offset
2228 case ETIR__C_STC_LDA_PS
:
2230 /* 212 Store-conditional BSR or Hint at pect + offset
2233 case ETIR__C_STC_BOH_PS
:
2235 /* 214 Store-conditional NOP, BSR or HINT at psect + offset
2237 case ETIR__C_STC_NBH_PS
:
2238 _bfd_error_handler (_("%s: not supported"),
2239 _bfd_vms_etir_name (cmd
));
2243 /* Det relocation base: pop stack, set image location counter
2245 case ETIR__C_CTL_SETRB
:
2246 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2247 if (!(rel1
& RELC_SEC_BASE
))
2249 image_set_ptr (abfd
, op1
, rel1
& RELC_MASK
, info
);
2252 /* Augment relocation base: increment image location counter by offset
2253 arg: lw offset value. */
2254 case ETIR__C_CTL_AUGRB
:
2255 if (ptr
+ 4 >= maxptr
)
2257 op1
= bfd_getl32 (ptr
);
2258 image_inc_ptr (abfd
, op1
);
2261 /* Define location: pop index, save location counter under index
2263 case ETIR__C_CTL_DFLOC
:
2264 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2265 if (rel1
!= RELC_NONE
)
2267 dst_define_location (abfd
, op1
);
2270 /* Set location: pop index, restore location counter from index
2272 case ETIR__C_CTL_STLOC
:
2273 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2274 if (rel1
!= RELC_NONE
)
2276 dst_restore_location (abfd
, op1
);
2279 /* Stack defined location: pop index, push location counter from index
2281 case ETIR__C_CTL_STKDL
:
2282 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2283 if (rel1
!= RELC_NONE
)
2285 _bfd_vms_push (abfd
, dst_retrieve_location (abfd
, op1
), RELC_NONE
);
2288 case ETIR__C_OPR_NOP
: /* No-op. */
2291 case ETIR__C_OPR_ADD
: /* Add. */
2292 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2293 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2294 if (rel1
== RELC_NONE
&& rel2
!= RELC_NONE
)
2296 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2298 _bfd_vms_push (abfd
, op1
+ op2
, rel1
);
2301 case ETIR__C_OPR_SUB
: /* Subtract. */
2302 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2303 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2304 if (rel1
== RELC_NONE
&& rel2
!= RELC_NONE
)
2306 else if ((rel1
& RELC_SEC_BASE
) && (rel2
& RELC_SEC_BASE
))
2308 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2309 op2
= alpha_vms_fix_sec_rel (abfd
, info
, rel2
, op2
);
2312 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2314 _bfd_vms_push (abfd
, op2
- op1
, rel1
);
2317 case ETIR__C_OPR_MUL
: /* Multiply. */
2318 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2319 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2320 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2322 _bfd_vms_push (abfd
, op1
* op2
, RELC_NONE
);
2325 case ETIR__C_OPR_DIV
: /* Divide. */
2326 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2327 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2328 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2331 _bfd_vms_push (abfd
, 0, RELC_NONE
);
2333 _bfd_vms_push (abfd
, op2
/ op1
, RELC_NONE
);
2336 case ETIR__C_OPR_AND
: /* Logical AND. */
2337 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2338 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2339 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2341 _bfd_vms_push (abfd
, op1
& op2
, RELC_NONE
);
2344 case ETIR__C_OPR_IOR
: /* Logical inclusive OR. */
2345 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2346 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2347 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2349 _bfd_vms_push (abfd
, op1
| op2
, RELC_NONE
);
2352 case ETIR__C_OPR_EOR
: /* Logical exclusive OR. */
2353 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2354 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2355 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2357 _bfd_vms_push (abfd
, op1
^ op2
, RELC_NONE
);
2360 case ETIR__C_OPR_NEG
: /* Negate. */
2361 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2362 if (rel1
!= RELC_NONE
)
2364 _bfd_vms_push (abfd
, -op1
, RELC_NONE
);
2367 case ETIR__C_OPR_COM
: /* Complement. */
2368 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2369 if (rel1
!= RELC_NONE
)
2371 _bfd_vms_push (abfd
, ~op1
, RELC_NONE
);
2374 case ETIR__C_OPR_ASH
: /* Arithmetic shift. */
2375 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2376 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2377 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2380 _bfd_error_handler (_("invalid use of %s with contexts"),
2381 _bfd_vms_etir_name (cmd
));
2384 if ((int)op2
< 0) /* Shift right. */
2386 else /* Shift left. */
2388 _bfd_vms_push (abfd
, op1
, RELC_NONE
); /* FIXME: sym. */
2391 case ETIR__C_OPR_INSV
: /* Insert field. */
2392 case ETIR__C_OPR_USH
: /* Unsigned shift. */
2393 case ETIR__C_OPR_ROT
: /* Rotate. */
2394 case ETIR__C_OPR_REDEF
: /* Redefine symbol to current location. */
2395 case ETIR__C_OPR_DFLIT
: /* Define a literal. */
2396 _bfd_error_handler (_("%s: not supported"),
2397 _bfd_vms_etir_name (cmd
));
2401 case ETIR__C_OPR_SEL
: /* Select. */
2402 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2404 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2407 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2408 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2409 _bfd_vms_push (abfd
, op1
, rel1
);
2414 _bfd_error_handler (_("reserved cmd %d"), cmd
);
2419 ptr
+= cmd_length
- 4;
2425 /* Process EDBG/ETBT record.
2426 Return TRUE on success, FALSE on error */
2429 vms_slurp_debug (bfd
*abfd
)
2431 asection
*section
= PRIV (dst_section
);
2433 if (section
== NULL
)
2435 /* We have no way to find out beforehand how much debug info there
2436 is in an object file, so pick an initial amount and grow it as
2438 flagword flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
| SEC_RELOC
2441 section
= bfd_make_section (abfd
, "$DST$");
2444 if (!bfd_set_section_flags (abfd
, section
, flags
))
2446 PRIV (dst_section
) = section
;
2449 PRIV (image_section
) = section
;
2450 PRIV (image_offset
) = section
->size
;
2452 if (!_bfd_vms_slurp_etir (abfd
, NULL
))
2455 section
->size
= PRIV (image_offset
);
2459 /* Process EDBG record.
2460 Return TRUE on success, FALSE on error. */
2463 _bfd_vms_slurp_edbg (bfd
*abfd
)
2465 vms_debug2 ((2, "EDBG\n"));
2467 abfd
->flags
|= HAS_DEBUG
| HAS_LINENO
;
2469 return vms_slurp_debug (abfd
);
2472 /* Process ETBT record.
2473 Return TRUE on success, FALSE on error. */
2476 _bfd_vms_slurp_etbt (bfd
*abfd
)
2478 vms_debug2 ((2, "ETBT\n"));
2480 abfd
->flags
|= HAS_LINENO
;
2482 return vms_slurp_debug (abfd
);
2485 /* Process EEOM record.
2486 Return TRUE on success, FALSE on error. */
2489 _bfd_vms_slurp_eeom (bfd
*abfd
)
2491 struct vms_eeom
*eeom
= (struct vms_eeom
*) PRIV (recrd
.rec
);
2493 vms_debug2 ((2, "EEOM\n"));
2495 /* PR 21813: Check for an undersized record. */
2496 if (PRIV (recrd
.buf_size
) < sizeof (* eeom
))
2498 _bfd_error_handler (_("corrupt EEOM record - size is too small"));
2499 bfd_set_error (bfd_error_bad_value
);
2503 PRIV (eom_data
).eom_l_total_lps
= bfd_getl32 (eeom
->total_lps
);
2504 PRIV (eom_data
).eom_w_comcod
= bfd_getl16 (eeom
->comcod
);
2505 if (PRIV (eom_data
).eom_w_comcod
> 1)
2507 _bfd_error_handler (_("object module not error-free !"));
2508 bfd_set_error (bfd_error_bad_value
);
2512 PRIV (eom_data
).eom_has_transfer
= FALSE
;
2513 if (PRIV (recrd
.rec_size
) > 10)
2515 PRIV (eom_data
).eom_has_transfer
= TRUE
;
2516 PRIV (eom_data
).eom_b_tfrflg
= eeom
->tfrflg
;
2517 PRIV (eom_data
).eom_l_psindx
= bfd_getl32 (eeom
->psindx
);
2518 PRIV (eom_data
).eom_l_tfradr
= bfd_getl32 (eeom
->tfradr
);
2520 abfd
->start_address
= PRIV (eom_data
).eom_l_tfradr
;
2525 /* Slurp an ordered set of VMS object records. Return FALSE on error. */
2528 _bfd_vms_slurp_object_records (bfd
* abfd
)
2535 vms_debug2 ((7, "reading at %08lx\n", (unsigned long)bfd_tell (abfd
)));
2537 type
= _bfd_vms_get_object_record (abfd
);
2540 vms_debug2 ((2, "next_record failed\n"));
2547 err
= _bfd_vms_slurp_ehdr (abfd
);
2550 err
= _bfd_vms_slurp_eeom (abfd
);
2553 err
= _bfd_vms_slurp_egsd (abfd
);
2556 err
= TRUE
; /* _bfd_vms_slurp_etir (abfd); */
2559 err
= _bfd_vms_slurp_edbg (abfd
);
2562 err
= _bfd_vms_slurp_etbt (abfd
);
2569 vms_debug2 ((2, "slurp type %d failed\n", type
));
2573 while (type
!= EOBJ__C_EEOM
);
2578 /* Initialize private data */
2580 vms_initialize (bfd
* abfd
)
2584 amt
= sizeof (struct vms_private_data_struct
);
2585 abfd
->tdata
.any
= bfd_zalloc (abfd
, amt
);
2586 if (abfd
->tdata
.any
== NULL
)
2589 PRIV (recrd
.file_format
) = FF_UNKNOWN
;
2591 amt
= sizeof (struct stack_struct
) * STACKSIZE
;
2592 PRIV (stack
) = bfd_alloc (abfd
, amt
);
2593 if (PRIV (stack
) == NULL
)
2599 bfd_release (abfd
, abfd
->tdata
.any
);
2600 abfd
->tdata
.any
= NULL
;
2604 /* Check the format for a file being read.
2605 Return a (bfd_target *) if it's an object file or zero if not. */
2607 static const struct bfd_target
*
2608 alpha_vms_object_p (bfd
*abfd
)
2610 void *tdata_save
= abfd
->tdata
.any
;
2611 unsigned int test_len
;
2614 vms_debug2 ((1, "vms_object_p(%p)\n", abfd
));
2616 /* Allocate alpha-vms specific data. */
2617 if (!vms_initialize (abfd
))
2620 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
))
2621 goto err_wrong_format
;
2623 /* The first challenge with VMS is to discover the kind of the file.
2625 Image files (executable or shared images) are stored as a raw
2626 stream of bytes (like on UNIX), but there is no magic number.
2628 Object files are written with RMS (record management service), ie
2629 each records are preceeded by its length (on a word - 2 bytes), and
2630 padded for word-alignment. That would be simple but when files
2631 are transfered to a UNIX filesystem (using ftp), records are lost.
2632 Only the raw content of the records are transfered. Fortunately,
2633 the Alpha Object file format also store the length of the record
2634 in the records. Is that clear ? */
2636 /* Minimum is 6 bytes for objects (2 bytes size, 2 bytes record id,
2637 2 bytes size repeated) and 12 bytes for images (4 bytes major id,
2638 4 bytes minor id, 4 bytes length). */
2641 /* Size the main buffer. */
2642 buf
= (unsigned char *) bfd_malloc (test_len
);
2645 PRIV (recrd
.buf
) = buf
;
2646 PRIV (recrd
.buf_size
) = test_len
;
2648 /* Initialize the record pointer. */
2649 PRIV (recrd
.rec
) = buf
;
2651 if (bfd_bread (buf
, test_len
, abfd
) != test_len
)
2652 goto err_wrong_format
;
2654 /* Is it an image? */
2655 if ((bfd_getl32 (buf
) == EIHD__K_MAJORID
)
2656 && (bfd_getl32 (buf
+ 4) == EIHD__K_MINORID
))
2658 unsigned int to_read
;
2659 unsigned int read_so_far
;
2660 unsigned int remaining
;
2661 unsigned int eisd_offset
, eihs_offset
;
2663 /* Extract the header size. */
2664 PRIV (recrd
.rec_size
) = bfd_getl32 (buf
+ EIHD__L_SIZE
);
2666 /* The header size is 0 for DSF files. */
2667 if (PRIV (recrd
.rec_size
) == 0)
2668 PRIV (recrd
.rec_size
) = sizeof (struct vms_eihd
);
2670 if (PRIV (recrd
.rec_size
) > PRIV (recrd
.buf_size
))
2672 buf
= bfd_realloc_or_free (buf
, PRIV (recrd
.rec_size
));
2676 PRIV (recrd
.buf
) = NULL
;
2679 PRIV (recrd
.buf
) = buf
;
2680 PRIV (recrd
.buf_size
) = PRIV (recrd
.rec_size
);
2683 /* PR 21813: Check for a truncated record. */
2684 if (PRIV (recrd
.rec_size
< test_len
))
2686 /* Read the remaining record. */
2687 remaining
= PRIV (recrd
.rec_size
) - test_len
;
2688 to_read
= MIN (VMS_BLOCK_SIZE
- test_len
, remaining
);
2689 read_so_far
= test_len
;
2691 while (remaining
> 0)
2693 if (bfd_bread (buf
+ read_so_far
, to_read
, abfd
) != to_read
)
2694 goto err_wrong_format
;
2696 read_so_far
+= to_read
;
2697 remaining
-= to_read
;
2699 to_read
= MIN (VMS_BLOCK_SIZE
, remaining
);
2702 /* Reset the record pointer. */
2703 PRIV (recrd
.rec
) = buf
;
2705 /* PR 17512: file: 7d7c57c2. */
2706 if (PRIV (recrd
.rec_size
) < sizeof (struct vms_eihd
))
2708 vms_debug2 ((2, "file type is image\n"));
2710 if (!_bfd_vms_slurp_eihd (abfd
, &eisd_offset
, &eihs_offset
))
2711 goto err_wrong_format
;
2713 if (!_bfd_vms_slurp_eisd (abfd
, eisd_offset
))
2714 goto err_wrong_format
;
2716 /* EIHS is optional. */
2717 if (eihs_offset
!= 0 && !_bfd_vms_slurp_eihs (abfd
, eihs_offset
))
2718 goto err_wrong_format
;
2724 /* Assume it's a module and adjust record pointer if necessary. */
2725 maybe_adjust_record_pointer_for_object (abfd
);
2727 /* But is it really a module? */
2728 if (bfd_getl16 (PRIV (recrd
.rec
)) <= EOBJ__C_MAXRECTYP
2729 && bfd_getl16 (PRIV (recrd
.rec
) + 2) <= EOBJ__C_MAXRECSIZ
)
2731 if (vms_get_remaining_object_record (abfd
, test_len
) <= 0)
2732 goto err_wrong_format
;
2734 vms_debug2 ((2, "file type is module\n"));
2736 type
= bfd_getl16 (PRIV (recrd
.rec
));
2737 if (type
!= EOBJ__C_EMH
|| !_bfd_vms_slurp_ehdr (abfd
))
2738 goto err_wrong_format
;
2740 if (!_bfd_vms_slurp_object_records (abfd
))
2741 goto err_wrong_format
;
2744 goto err_wrong_format
;
2747 /* Set arch_info to alpha. */
2749 if (! bfd_default_set_arch_mach (abfd
, bfd_arch_alpha
, 0))
2750 goto err_wrong_format
;
2755 bfd_set_error (bfd_error_wrong_format
);
2758 if (PRIV (recrd
.buf
))
2759 free (PRIV (recrd
.buf
));
2760 if (abfd
->tdata
.any
!= tdata_save
&& abfd
->tdata
.any
!= NULL
)
2761 bfd_release (abfd
, abfd
->tdata
.any
);
2762 abfd
->tdata
.any
= tdata_save
;
2768 /* Write an EMH/MHD record. */
2771 _bfd_vms_write_emh (bfd
*abfd
)
2773 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2775 _bfd_vms_output_alignment (recwr
, 2);
2778 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
2779 _bfd_vms_output_short (recwr
, EMH__C_MHD
);
2780 _bfd_vms_output_short (recwr
, EOBJ__C_STRLVL
);
2781 _bfd_vms_output_long (recwr
, 0);
2782 _bfd_vms_output_long (recwr
, 0);
2783 _bfd_vms_output_long (recwr
, MAX_OUTREC_SIZE
);
2785 /* Create module name from filename. */
2786 if (bfd_get_filename (abfd
) != 0)
2788 char *module
= vms_get_module_name (bfd_get_filename (abfd
), TRUE
);
2789 _bfd_vms_output_counted (recwr
, module
);
2793 _bfd_vms_output_counted (recwr
, "NONAME");
2795 _bfd_vms_output_counted (recwr
, BFD_VERSION_STRING
);
2796 _bfd_vms_output_dump (recwr
, get_vms_time_string (), EMH_DATE_LENGTH
);
2797 _bfd_vms_output_fill (recwr
, 0, EMH_DATE_LENGTH
);
2798 _bfd_vms_output_end (abfd
, recwr
);
2801 /* Write an EMH/LMN record. */
2804 _bfd_vms_write_lmn (bfd
*abfd
, const char *name
)
2807 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2808 unsigned int ver
= BFD_VERSION
/ 10000;
2811 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
2812 _bfd_vms_output_short (recwr
, EMH__C_LNM
);
2813 snprintf (version
, sizeof (version
), "%s %d.%d.%d", name
,
2814 ver
/ 10000, (ver
/ 100) % 100, ver
% 100);
2815 _bfd_vms_output_dump (recwr
, (unsigned char *)version
, strlen (version
));
2816 _bfd_vms_output_end (abfd
, recwr
);
2820 /* Write eom record for bfd abfd. Return FALSE on error. */
2823 _bfd_vms_write_eeom (bfd
*abfd
)
2825 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2827 vms_debug2 ((2, "vms_write_eeom\n"));
2829 _bfd_vms_output_alignment (recwr
, 2);
2831 _bfd_vms_output_begin (recwr
, EOBJ__C_EEOM
);
2832 _bfd_vms_output_long (recwr
, PRIV (vms_linkage_index
+ 1) >> 1);
2833 _bfd_vms_output_byte (recwr
, 0); /* Completion code. */
2834 _bfd_vms_output_byte (recwr
, 0); /* Fill byte. */
2836 if ((abfd
->flags
& EXEC_P
) == 0
2837 && bfd_get_start_address (abfd
) != (bfd_vma
)-1)
2841 section
= bfd_get_section_by_name (abfd
, ".link");
2844 bfd_set_error (bfd_error_nonrepresentable_section
);
2847 _bfd_vms_output_short (recwr
, 0);
2848 _bfd_vms_output_long (recwr
, (unsigned long) section
->target_index
);
2849 _bfd_vms_output_long (recwr
,
2850 (unsigned long) bfd_get_start_address (abfd
));
2851 _bfd_vms_output_long (recwr
, 0);
2854 _bfd_vms_output_end (abfd
, recwr
);
2859 vector_grow1 (struct vector_type
*vec
, size_t elsz
)
2861 if (vec
->nbr_el
+ 1 < vec
->max_el
)
2864 if (vec
->max_el
== 0)
2867 vec
->els
= bfd_malloc2 (vec
->max_el
, elsz
);
2872 vec
->els
= bfd_realloc2 (vec
->els
, vec
->max_el
, elsz
);
2876 /* Bump ABFD file position to next block. */
2879 alpha_vms_file_position_block (bfd
*abfd
)
2882 PRIV (file_pos
) += VMS_BLOCK_SIZE
- 1;
2883 PRIV (file_pos
) -= (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
2886 /* Convert from internal structure SRC to external structure DST. */
2889 alpha_vms_swap_eisd_out (struct vms_internal_eisd_map
*src
,
2890 struct vms_eisd
*dst
)
2892 bfd_putl32 (src
->u
.eisd
.majorid
, dst
->majorid
);
2893 bfd_putl32 (src
->u
.eisd
.minorid
, dst
->minorid
);
2894 bfd_putl32 (src
->u
.eisd
.eisdsize
, dst
->eisdsize
);
2895 if (src
->u
.eisd
.eisdsize
<= EISD__K_LENEND
)
2897 bfd_putl32 (src
->u
.eisd
.secsize
, dst
->secsize
);
2898 bfd_putl64 (src
->u
.eisd
.virt_addr
, dst
->virt_addr
);
2899 bfd_putl32 (src
->u
.eisd
.flags
, dst
->flags
);
2900 bfd_putl32 (src
->u
.eisd
.vbn
, dst
->vbn
);
2901 dst
->pfc
= src
->u
.eisd
.pfc
;
2902 dst
->matchctl
= src
->u
.eisd
.matchctl
;
2903 dst
->type
= src
->u
.eisd
.type
;
2905 if (src
->u
.eisd
.flags
& EISD__M_GBL
)
2907 bfd_putl32 (src
->u
.gbl_eisd
.ident
, dst
->ident
);
2908 memcpy (dst
->gblnam
, src
->u
.gbl_eisd
.gblnam
,
2909 src
->u
.gbl_eisd
.gblnam
[0] + 1);
2913 /* Append EISD to the list of extra eisd for ABFD. */
2916 alpha_vms_append_extra_eisd (bfd
*abfd
, struct vms_internal_eisd_map
*eisd
)
2919 if (PRIV (gbl_eisd_head
) == NULL
)
2920 PRIV (gbl_eisd_head
) = eisd
;
2922 PRIV (gbl_eisd_tail
)->next
= eisd
;
2923 PRIV (gbl_eisd_tail
) = eisd
;
2926 /* Create an EISD for shared image SHRIMG.
2927 Return FALSE in case of error. */
2930 alpha_vms_create_eisd_for_shared (bfd
*abfd
, bfd
*shrimg
)
2932 struct vms_internal_eisd_map
*eisd
;
2935 namlen
= strlen (PRIV2 (shrimg
, hdr_data
.hdr_t_name
));
2936 if (namlen
+ 5 > EISD__K_GBLNAMLEN
)
2942 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
2946 /* Fill the fields. */
2947 eisd
->u
.gbl_eisd
.common
.majorid
= EISD__K_MAJORID
;
2948 eisd
->u
.gbl_eisd
.common
.minorid
= EISD__K_MINORID
;
2949 eisd
->u
.gbl_eisd
.common
.eisdsize
= (EISD__K_LEN
+ 4 + namlen
+ 5 + 3) & ~3;
2950 eisd
->u
.gbl_eisd
.common
.secsize
= VMS_BLOCK_SIZE
; /* Must not be 0. */
2951 eisd
->u
.gbl_eisd
.common
.virt_addr
= 0;
2952 eisd
->u
.gbl_eisd
.common
.flags
= EISD__M_GBL
;
2953 eisd
->u
.gbl_eisd
.common
.vbn
= 0;
2954 eisd
->u
.gbl_eisd
.common
.pfc
= 0;
2955 eisd
->u
.gbl_eisd
.common
.matchctl
= PRIV2 (shrimg
, matchctl
);
2956 eisd
->u
.gbl_eisd
.common
.type
= EISD__K_SHRPIC
;
2958 eisd
->u
.gbl_eisd
.ident
= PRIV2 (shrimg
, ident
);
2959 eisd
->u
.gbl_eisd
.gblnam
[0] = namlen
+ 4;
2960 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1, PRIV2 (shrimg
, hdr_data
.hdr_t_name
),
2962 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1 + namlen
, "_001", 4);
2964 /* Append it to the list. */
2965 alpha_vms_append_extra_eisd (abfd
, eisd
);
2970 /* Create an EISD for section SEC.
2971 Return FALSE in case of failure. */
2974 alpha_vms_create_eisd_for_section (bfd
*abfd
, asection
*sec
)
2976 struct vms_internal_eisd_map
*eisd
;
2978 /* Only for allocating section. */
2979 if (!(sec
->flags
& SEC_ALLOC
))
2982 BFD_ASSERT (vms_section_data (sec
)->eisd
== NULL
);
2983 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
2986 vms_section_data (sec
)->eisd
= eisd
;
2988 /* Fill the fields. */
2989 eisd
->u
.eisd
.majorid
= EISD__K_MAJORID
;
2990 eisd
->u
.eisd
.minorid
= EISD__K_MINORID
;
2991 eisd
->u
.eisd
.eisdsize
= EISD__K_LEN
;
2992 eisd
->u
.eisd
.secsize
=
2993 (sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
2994 eisd
->u
.eisd
.virt_addr
= sec
->vma
;
2995 eisd
->u
.eisd
.flags
= 0;
2996 eisd
->u
.eisd
.vbn
= 0; /* To be later defined. */
2997 eisd
->u
.eisd
.pfc
= 0; /* Default. */
2998 eisd
->u
.eisd
.matchctl
= EISD__K_MATALL
;
2999 eisd
->u
.eisd
.type
= EISD__K_NORMAL
;
3001 if (sec
->flags
& SEC_CODE
)
3002 eisd
->u
.eisd
.flags
|= EISD__M_EXE
;
3003 if (!(sec
->flags
& SEC_READONLY
))
3004 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
3006 /* If relocations or fixup will be applied, make this isect writeable. */
3007 if (sec
->flags
& SEC_RELOC
)
3008 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
3010 if (!(sec
->flags
& SEC_HAS_CONTENTS
))
3012 eisd
->u
.eisd
.flags
|= EISD__M_DZRO
;
3013 eisd
->u
.eisd
.flags
&= ~EISD__M_CRF
;
3015 if (sec
->flags
& SEC_LINKER_CREATED
)
3017 if (strcmp (sec
->name
, "$FIXUP$") == 0)
3018 eisd
->u
.eisd
.flags
|= EISD__M_FIXUPVEC
;
3021 /* Append it to the list. */
3023 if (PRIV (eisd_head
) == NULL
)
3024 PRIV (eisd_head
) = eisd
;
3026 PRIV (eisd_tail
)->next
= eisd
;
3027 PRIV (eisd_tail
) = eisd
;
3032 /* Layout executable ABFD and write it to the disk.
3033 Return FALSE in case of failure. */
3036 alpha_vms_write_exec (bfd
*abfd
)
3038 struct vms_eihd eihd
;
3039 struct vms_eiha
*eiha
;
3040 struct vms_eihi
*eihi
;
3041 struct vms_eihs
*eihs
= NULL
;
3043 struct vms_internal_eisd_map
*first_eisd
;
3044 struct vms_internal_eisd_map
*eisd
;
3047 file_ptr gst_filepos
= 0;
3048 unsigned int lnkflags
= 0;
3050 /* Build the EIHD. */
3051 PRIV (file_pos
) = EIHD__C_LENGTH
;
3053 memset (&eihd
, 0, sizeof (eihd
));
3054 memset (eihd
.fill_2
, 0xff, sizeof (eihd
.fill_2
));
3056 bfd_putl32 (EIHD__K_MAJORID
, eihd
.majorid
);
3057 bfd_putl32 (EIHD__K_MINORID
, eihd
.minorid
);
3059 bfd_putl32 (sizeof (eihd
), eihd
.size
);
3060 bfd_putl32 (0, eihd
.isdoff
);
3061 bfd_putl32 (0, eihd
.activoff
);
3062 bfd_putl32 (0, eihd
.symdbgoff
);
3063 bfd_putl32 (0, eihd
.imgidoff
);
3064 bfd_putl32 (0, eihd
.patchoff
);
3065 bfd_putl64 (0, eihd
.iafva
);
3066 bfd_putl32 (0, eihd
.version_array_off
);
3068 bfd_putl32 (EIHD__K_EXE
, eihd
.imgtype
);
3069 bfd_putl32 (0, eihd
.subtype
);
3071 bfd_putl32 (0, eihd
.imgiocnt
);
3072 bfd_putl32 (-1, eihd
.privreqs
);
3073 bfd_putl32 (-1, eihd
.privreqs
+ 4);
3075 bfd_putl32 ((sizeof (eihd
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
3077 bfd_putl32 (0, eihd
.ident
);
3078 bfd_putl32 (0, eihd
.sysver
);
3081 bfd_putl32 (0, eihd
.symvect_size
);
3082 bfd_putl32 (16, eihd
.virt_mem_block_size
);
3083 bfd_putl32 (0, eihd
.ext_fixup_off
);
3084 bfd_putl32 (0, eihd
.noopt_psect_off
);
3085 bfd_putl32 (-1, eihd
.alias
);
3088 eiha
= (struct vms_eiha
*)((char *) &eihd
+ PRIV (file_pos
));
3089 bfd_putl32 (PRIV (file_pos
), eihd
.activoff
);
3090 PRIV (file_pos
) += sizeof (struct vms_eiha
);
3092 bfd_putl32 (sizeof (struct vms_eiha
), eiha
->size
);
3093 bfd_putl32 (0, eiha
->spare
);
3094 bfd_putl64 (PRIV (transfer_address
[0]), eiha
->tfradr1
);
3095 bfd_putl64 (PRIV (transfer_address
[1]), eiha
->tfradr2
);
3096 bfd_putl64 (PRIV (transfer_address
[2]), eiha
->tfradr3
);
3097 bfd_putl64 (PRIV (transfer_address
[3]), eiha
->tfradr4
);
3098 bfd_putl64 (0, eiha
->inishr
);
3101 eihi
= (struct vms_eihi
*)((char *) &eihd
+ PRIV (file_pos
));
3102 bfd_putl32 (PRIV (file_pos
), eihd
.imgidoff
);
3103 PRIV (file_pos
) += sizeof (struct vms_eihi
);
3105 bfd_putl32 (EIHI__K_MAJORID
, eihi
->majorid
);
3106 bfd_putl32 (EIHI__K_MINORID
, eihi
->minorid
);
3111 /* Set module name. */
3112 module
= vms_get_module_name (bfd_get_filename (abfd
), TRUE
);
3113 len
= strlen (module
);
3114 if (len
> sizeof (eihi
->imgnam
) - 1)
3115 len
= sizeof (eihi
->imgnam
) - 1;
3116 eihi
->imgnam
[0] = len
;
3117 memcpy (eihi
->imgnam
+ 1, module
, len
);
3125 vms_get_time (&hi
, &lo
);
3126 bfd_putl32 (lo
, eihi
->linktime
+ 0);
3127 bfd_putl32 (hi
, eihi
->linktime
+ 4);
3130 eihi
->linkid
[0] = 0;
3131 eihi
->imgbid
[0] = 0;
3134 dst
= PRIV (dst_section
);
3135 dmt
= bfd_get_section_by_name (abfd
, "$DMT$");
3136 if (dst
!= NULL
&& dst
->size
!= 0)
3138 eihs
= (struct vms_eihs
*)((char *) &eihd
+ PRIV (file_pos
));
3139 bfd_putl32 (PRIV (file_pos
), eihd
.symdbgoff
);
3140 PRIV (file_pos
) += sizeof (struct vms_eihs
);
3142 bfd_putl32 (EIHS__K_MAJORID
, eihs
->majorid
);
3143 bfd_putl32 (EIHS__K_MINORID
, eihs
->minorid
);
3144 bfd_putl32 (0, eihs
->dstvbn
);
3145 bfd_putl32 (0, eihs
->dstsize
);
3146 bfd_putl32 (0, eihs
->gstvbn
);
3147 bfd_putl32 (0, eihs
->gstsize
);
3148 bfd_putl32 (0, eihs
->dmtvbn
);
3149 bfd_putl32 (0, eihs
->dmtsize
);
3152 /* One EISD per section. */
3153 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3155 if (!alpha_vms_create_eisd_for_section (abfd
, sec
))
3159 /* Merge section EIDS which extra ones. */
3160 if (PRIV (eisd_tail
))
3161 PRIV (eisd_tail
)->next
= PRIV (gbl_eisd_head
);
3163 PRIV (eisd_head
) = PRIV (gbl_eisd_head
);
3164 if (PRIV (gbl_eisd_tail
))
3165 PRIV (eisd_tail
) = PRIV (gbl_eisd_tail
);
3167 first_eisd
= PRIV (eisd_head
);
3169 /* Add end of eisd. */
3172 eisd
= bfd_zalloc (abfd
, sizeof (*eisd
));
3175 eisd
->u
.eisd
.majorid
= 0;
3176 eisd
->u
.eisd
.minorid
= 0;
3177 eisd
->u
.eisd
.eisdsize
= 0;
3178 alpha_vms_append_extra_eisd (abfd
, eisd
);
3181 /* Place EISD in the file. */
3182 for (eisd
= first_eisd
; eisd
; eisd
= eisd
->next
)
3184 file_ptr room
= VMS_BLOCK_SIZE
- (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
3186 /* First block is a little bit special: there is a word at the end. */
3187 if (PRIV (file_pos
) < VMS_BLOCK_SIZE
&& room
> 2)
3189 if (room
< eisd
->u
.eisd
.eisdsize
+ EISD__K_LENEND
)
3190 alpha_vms_file_position_block (abfd
);
3192 eisd
->file_pos
= PRIV (file_pos
);
3193 PRIV (file_pos
) += eisd
->u
.eisd
.eisdsize
;
3195 if (eisd
->u
.eisd
.flags
& EISD__M_FIXUPVEC
)
3196 bfd_putl64 (eisd
->u
.eisd
.virt_addr
, eihd
.iafva
);
3199 if (first_eisd
!= NULL
)
3201 bfd_putl32 (first_eisd
->file_pos
, eihd
.isdoff
);
3202 /* Real size of end of eisd marker. */
3203 PRIV (file_pos
) += EISD__K_LENEND
;
3206 bfd_putl32 (PRIV (file_pos
), eihd
.size
);
3207 bfd_putl32 ((PRIV (file_pos
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
3210 /* Place sections. */
3211 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3213 if (!(sec
->flags
& SEC_HAS_CONTENTS
))
3216 eisd
= vms_section_data (sec
)->eisd
;
3218 /* Align on a block. */
3219 alpha_vms_file_position_block (abfd
);
3220 sec
->filepos
= PRIV (file_pos
);
3223 eisd
->u
.eisd
.vbn
= (sec
->filepos
/ VMS_BLOCK_SIZE
) + 1;
3225 PRIV (file_pos
) += sec
->size
;
3229 if (eihs
!= NULL
&& dst
!= NULL
)
3231 bfd_putl32 ((dst
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dstvbn
);
3232 bfd_putl32 (dst
->size
, eihs
->dstsize
);
3236 lnkflags
|= EIHD__M_DBGDMT
;
3237 bfd_putl32 ((dmt
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dmtvbn
);
3238 bfd_putl32 (dmt
->size
, eihs
->dmtsize
);
3240 if (PRIV (gsd_sym_count
) != 0)
3242 alpha_vms_file_position_block (abfd
);
3243 gst_filepos
= PRIV (file_pos
);
3244 bfd_putl32 ((gst_filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->gstvbn
);
3245 bfd_putl32 ((PRIV (gsd_sym_count
) + 4) / 5 + 4, eihs
->gstsize
);
3249 /* Write EISD in hdr. */
3250 for (eisd
= first_eisd
; eisd
&& eisd
->file_pos
< VMS_BLOCK_SIZE
;
3252 alpha_vms_swap_eisd_out
3253 (eisd
, (struct vms_eisd
*)((char *)&eihd
+ eisd
->file_pos
));
3255 /* Write first block. */
3256 bfd_putl32 (lnkflags
, eihd
.lnkflags
);
3257 if (bfd_bwrite (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
3260 /* Write remaining eisd. */
3263 unsigned char blk
[VMS_BLOCK_SIZE
];
3264 struct vms_internal_eisd_map
*next_eisd
;
3266 memset (blk
, 0xff, sizeof (blk
));
3267 while (eisd
!= NULL
)
3269 alpha_vms_swap_eisd_out
3271 (struct vms_eisd
*)(blk
+ (eisd
->file_pos
% VMS_BLOCK_SIZE
)));
3273 next_eisd
= eisd
->next
;
3274 if (next_eisd
== NULL
3275 || (next_eisd
->file_pos
/ VMS_BLOCK_SIZE
3276 != eisd
->file_pos
/ VMS_BLOCK_SIZE
))
3278 if (bfd_bwrite (blk
, sizeof (blk
), abfd
) != sizeof (blk
))
3281 memset (blk
, 0xff, sizeof (blk
));
3287 /* Write sections. */
3288 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3290 unsigned char blk
[VMS_BLOCK_SIZE
];
3293 if (sec
->size
== 0 || !(sec
->flags
& SEC_HAS_CONTENTS
))
3295 if (bfd_bwrite (sec
->contents
, sec
->size
, abfd
) != sec
->size
)
3299 len
= VMS_BLOCK_SIZE
- sec
->size
% VMS_BLOCK_SIZE
;
3300 if (len
!= VMS_BLOCK_SIZE
)
3302 memset (blk
, 0, len
);
3303 if (bfd_bwrite (blk
, len
, abfd
) != len
)
3309 if (gst_filepos
!= 0)
3311 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3314 _bfd_vms_write_emh (abfd
);
3315 _bfd_vms_write_lmn (abfd
, "GNU LD");
3317 /* PSC for the absolute section. */
3318 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3319 _bfd_vms_output_long (recwr
, 0);
3320 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3321 _bfd_vms_output_short (recwr
, 0);
3322 _bfd_vms_output_short (recwr
, EGPS__V_PIC
| EGPS__V_LIB
| EGPS__V_RD
);
3323 _bfd_vms_output_long (recwr
, 0);
3324 _bfd_vms_output_counted (recwr
, ".$$ABS$$.");
3325 _bfd_vms_output_end_subrec (recwr
);
3326 _bfd_vms_output_end (abfd
, recwr
);
3328 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
3330 struct vms_symbol_entry
*sym
= PRIV (syms
)[i
];
3336 _bfd_vms_output_alignment (recwr
, 8);
3337 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3338 _bfd_vms_output_long (recwr
, 0);
3340 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYMG
);
3341 _bfd_vms_output_short (recwr
, 0); /* Data type, alignment. */
3342 _bfd_vms_output_short (recwr
, sym
->flags
);
3344 if (sym
->code_section
)
3345 ep
= alpha_vms_get_sym_value (sym
->code_section
, sym
->code_value
);
3348 BFD_ASSERT (sym
->code_value
== 0);
3351 val
= alpha_vms_get_sym_value (sym
->section
, sym
->value
);
3352 _bfd_vms_output_quad
3353 (recwr
, sym
->typ
== EGSD__C_SYMG
? sym
->symbol_vector
: val
);
3354 _bfd_vms_output_quad (recwr
, ep
);
3355 _bfd_vms_output_quad (recwr
, val
);
3356 _bfd_vms_output_long (recwr
, 0);
3357 _bfd_vms_output_counted (recwr
, sym
->name
);
3358 _bfd_vms_output_end_subrec (recwr
);
3360 _bfd_vms_output_end (abfd
, recwr
);
3363 _bfd_vms_output_end (abfd
, recwr
);
3365 if (!_bfd_vms_write_eeom (abfd
))
3373 /* Write section and symbol directory of bfd abfd. Return FALSE on error. */
3376 _bfd_vms_write_egsd (bfd
*abfd
)
3380 unsigned int symnum
;
3382 flagword new_flags
, old_flags
;
3383 int abs_section_index
= -1;
3384 unsigned int target_index
= 0;
3385 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3387 vms_debug2 ((2, "vms_write_egsd\n"));
3389 /* Egsd is quadword aligned. */
3390 _bfd_vms_output_alignment (recwr
, 8);
3392 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3393 _bfd_vms_output_long (recwr
, 0);
3395 /* Number sections. */
3396 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3398 if (section
->flags
& SEC_DEBUGGING
)
3400 if (!strcmp (section
->name
, ".vmsdebug"))
3402 section
->flags
|= SEC_DEBUGGING
;
3405 section
->target_index
= target_index
++;
3408 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3410 vms_debug2 ((3, "Section #%d %s, %d bytes\n",
3411 section
->target_index
, section
->name
, (int)section
->size
));
3413 /* Don't write out the VMS debug info section since it is in the
3414 ETBT and EDBG sections in etir. */
3415 if (section
->flags
& SEC_DEBUGGING
)
3418 /* 13 bytes egsd, max 31 chars name -> should be 44 bytes. */
3419 if (_bfd_vms_output_check (recwr
, 64) < 0)
3421 _bfd_vms_output_end (abfd
, recwr
);
3422 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3423 _bfd_vms_output_long (recwr
, 0);
3426 /* Don't know if this is necessary for the linker but for now it keeps
3427 vms_slurp_gsd happy. */
3428 sname
= section
->name
;
3431 /* Remove leading dot. */
3433 if ((*sname
== 't') && (strcmp (sname
, "text") == 0))
3434 sname
= EVAX_CODE_NAME
;
3435 else if ((*sname
== 'd') && (strcmp (sname
, "data") == 0))
3436 sname
= EVAX_DATA_NAME
;
3437 else if ((*sname
== 'b') && (strcmp (sname
, "bss") == 0))
3438 sname
= EVAX_BSS_NAME
;
3439 else if ((*sname
== 'l') && (strcmp (sname
, "link") == 0))
3440 sname
= EVAX_LINK_NAME
;
3441 else if ((*sname
== 'r') && (strcmp (sname
, "rdata") == 0))
3442 sname
= EVAX_READONLY_NAME
;
3443 else if ((*sname
== 'l') && (strcmp (sname
, "literal") == 0))
3444 sname
= EVAX_LITERAL_NAME
;
3445 else if ((*sname
== 'l') && (strcmp (sname
, "literals") == 0))
3446 sname
= EVAX_LITERALS_NAME
;
3447 else if ((*sname
== 'c') && (strcmp (sname
, "comm") == 0))
3448 sname
= EVAX_COMMON_NAME
;
3449 else if ((*sname
== 'l') && (strcmp (sname
, "lcomm") == 0))
3450 sname
= EVAX_LOCAL_NAME
;
3453 if (bfd_is_com_section (section
))
3454 new_flags
= (EGPS__V_OVR
| EGPS__V_REL
| EGPS__V_GBL
| EGPS__V_RD
3455 | EGPS__V_WRT
| EGPS__V_NOMOD
| EGPS__V_COM
);
3457 new_flags
= vms_esecflag_by_name (evax_section_flags
, sname
,
3460 /* Modify them as directed. */
3461 if (section
->flags
& SEC_READONLY
)
3462 new_flags
&= ~EGPS__V_WRT
;
3464 new_flags
&= ~vms_section_data (section
)->no_flags
;
3465 new_flags
|= vms_section_data (section
)->flags
;
3467 vms_debug2 ((3, "sec flags %x\n", section
->flags
));
3468 vms_debug2 ((3, "new_flags %x, _raw_size %lu\n",
3469 new_flags
, (unsigned long)section
->size
));
3471 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3472 _bfd_vms_output_short (recwr
, section
->alignment_power
& 0xff);
3473 _bfd_vms_output_short (recwr
, new_flags
);
3474 _bfd_vms_output_long (recwr
, (unsigned long) section
->size
);
3475 _bfd_vms_output_counted (recwr
, sname
);
3476 _bfd_vms_output_end_subrec (recwr
);
3478 /* If the section is an obsolute one, remind its index as it will be
3479 used later for absolute symbols. */
3480 if ((new_flags
& EGPS__V_REL
) == 0 && abs_section_index
< 0)
3481 abs_section_index
= section
->target_index
;
3484 /* Output symbols. */
3485 vms_debug2 ((3, "%d symbols found\n", abfd
->symcount
));
3487 bfd_set_start_address (abfd
, (bfd_vma
) -1);
3489 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3491 symbol
= abfd
->outsymbols
[symnum
];
3492 old_flags
= symbol
->flags
;
3494 /* Work-around a missing feature: consider __main as the main entry
3496 if (symbol
->name
[0] == '_' && strcmp (symbol
->name
, "__main") == 0)
3497 bfd_set_start_address (abfd
, (bfd_vma
)symbol
->value
);
3499 /* Only put in the GSD the global and the undefined symbols. */
3500 if (old_flags
& BSF_FILE
)
3503 if ((old_flags
& BSF_GLOBAL
) == 0 && !bfd_is_und_section (symbol
->section
))
3505 /* If the LIB$INITIIALIZE section is present, add a reference to
3506 LIB$INITIALIZE symbol. FIXME: this should be done explicitely
3507 in the assembly file. */
3508 if (!((old_flags
& BSF_SECTION_SYM
) != 0
3509 && strcmp (symbol
->section
->name
, "LIB$INITIALIZE") == 0))
3513 /* 13 bytes egsd, max 64 chars name -> should be 77 bytes. Add 16 more
3514 bytes for a possible ABS section. */
3515 if (_bfd_vms_output_check (recwr
, 80 + 16) < 0)
3517 _bfd_vms_output_end (abfd
, recwr
);
3518 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3519 _bfd_vms_output_long (recwr
, 0);
3522 if ((old_flags
& BSF_GLOBAL
) != 0
3523 && bfd_is_abs_section (symbol
->section
)
3524 && abs_section_index
<= 0)
3526 /* Create an absolute section if none was defined. It is highly
3527 unlikely that the name $ABS$ clashes with a user defined
3528 non-absolute section name. */
3529 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3530 _bfd_vms_output_short (recwr
, 4);
3531 _bfd_vms_output_short (recwr
, EGPS__V_SHR
);
3532 _bfd_vms_output_long (recwr
, 0);
3533 _bfd_vms_output_counted (recwr
, "$ABS$");
3534 _bfd_vms_output_end_subrec (recwr
);
3536 abs_section_index
= target_index
++;
3539 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYM
);
3541 /* Data type, alignment. */
3542 _bfd_vms_output_short (recwr
, 0);
3546 if (old_flags
& BSF_WEAK
)
3547 new_flags
|= EGSY__V_WEAK
;
3548 if (bfd_is_com_section (symbol
->section
)) /* .comm */
3549 new_flags
|= (EGSY__V_WEAK
| EGSY__V_COMM
);
3551 if (old_flags
& BSF_FUNCTION
)
3553 new_flags
|= EGSY__V_NORM
;
3554 new_flags
|= EGSY__V_REL
;
3556 if (old_flags
& BSF_GLOBAL
)
3558 new_flags
|= EGSY__V_DEF
;
3559 if (!bfd_is_abs_section (symbol
->section
))
3560 new_flags
|= EGSY__V_REL
;
3562 _bfd_vms_output_short (recwr
, new_flags
);
3564 if (old_flags
& BSF_GLOBAL
)
3566 /* Symbol definition. */
3567 bfd_vma code_address
= 0;
3568 unsigned long ca_psindx
= 0;
3569 unsigned long psindx
;
3571 if ((old_flags
& BSF_FUNCTION
) && symbol
->udata
.p
!= NULL
)
3576 ((struct evax_private_udata_struct
*)symbol
->udata
.p
)->enbsym
;
3577 code_address
= sym
->value
;
3578 ca_psindx
= sym
->section
->target_index
;
3580 if (bfd_is_abs_section (symbol
->section
))
3581 psindx
= abs_section_index
;
3583 psindx
= symbol
->section
->target_index
;
3585 _bfd_vms_output_quad (recwr
, symbol
->value
);
3586 _bfd_vms_output_quad (recwr
, code_address
);
3587 _bfd_vms_output_long (recwr
, ca_psindx
);
3588 _bfd_vms_output_long (recwr
, psindx
);
3590 _bfd_vms_output_counted (recwr
, symbol
->name
);
3592 _bfd_vms_output_end_subrec (recwr
);
3595 _bfd_vms_output_alignment (recwr
, 8);
3596 _bfd_vms_output_end (abfd
, recwr
);
3601 /* Write object header for bfd abfd. Return FALSE on error. */
3604 _bfd_vms_write_ehdr (bfd
*abfd
)
3607 unsigned int symnum
;
3608 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3610 vms_debug2 ((2, "vms_write_ehdr (%p)\n", abfd
));
3612 _bfd_vms_output_alignment (recwr
, 2);
3614 _bfd_vms_write_emh (abfd
);
3615 _bfd_vms_write_lmn (abfd
, "GNU AS");
3618 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3619 _bfd_vms_output_short (recwr
, EMH__C_SRC
);
3621 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3623 symbol
= abfd
->outsymbols
[symnum
];
3625 if (symbol
->flags
& BSF_FILE
)
3627 _bfd_vms_output_dump (recwr
, (unsigned char *) symbol
->name
,
3628 (int) strlen (symbol
->name
));
3633 if (symnum
== abfd
->symcount
)
3634 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("noname"));
3636 _bfd_vms_output_end (abfd
, recwr
);
3639 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3640 _bfd_vms_output_short (recwr
, EMH__C_TTL
);
3641 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("TTL"));
3642 _bfd_vms_output_end (abfd
, recwr
);
3645 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3646 _bfd_vms_output_short (recwr
, EMH__C_CPR
);
3647 _bfd_vms_output_dump (recwr
,
3648 (unsigned char *)"GNU BFD ported by Klaus Kämpf 1994-1996",
3650 _bfd_vms_output_end (abfd
, recwr
);
3655 /* Part 4.6, relocations. */
3658 /* WRITE ETIR SECTION
3660 This is still under construction and therefore not documented. */
3662 /* Close the etir/etbt record. */
3665 end_etir_record (bfd
* abfd
)
3667 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3669 _bfd_vms_output_end (abfd
, recwr
);
3673 start_etir_or_etbt_record (bfd
*abfd
, asection
*section
, bfd_vma offset
)
3675 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3677 if (section
->flags
& SEC_DEBUGGING
)
3679 _bfd_vms_output_begin (recwr
, EOBJ__C_ETBT
);
3683 /* Push start offset. */
3684 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3685 _bfd_vms_output_long (recwr
, (unsigned long) 0);
3686 _bfd_vms_output_end_subrec (recwr
);
3689 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_DFLOC
);
3690 _bfd_vms_output_end_subrec (recwr
);
3695 _bfd_vms_output_begin (recwr
, EOBJ__C_ETIR
);
3699 /* Push start offset. */
3700 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3701 _bfd_vms_output_long (recwr
, (unsigned long) section
->target_index
);
3702 _bfd_vms_output_quad (recwr
, offset
);
3703 _bfd_vms_output_end_subrec (recwr
);
3705 /* Start = pop (). */
3706 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_SETRB
);
3707 _bfd_vms_output_end_subrec (recwr
);
3712 /* Output a STO_IMM command for SSIZE bytes of data from CPR at virtual
3713 address VADDR in section specified by SEC_INDEX and NAME. */
3716 sto_imm (bfd
*abfd
, asection
*section
,
3717 bfd_size_type ssize
, unsigned char *cptr
, bfd_vma vaddr
)
3720 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3723 _bfd_vms_debug (8, "sto_imm %d bytes\n", (int) ssize
);
3724 _bfd_hexdump (9, cptr
, (int) ssize
, (int) vaddr
);
3729 /* Try all the rest. */
3732 if (_bfd_vms_output_check (recwr
, size
) < 0)
3734 /* Doesn't fit, split ! */
3735 end_etir_record (abfd
);
3737 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3739 size
= _bfd_vms_output_check (recwr
, 0); /* get max size */
3740 if (size
> ssize
) /* more than what's left ? */
3744 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_IMM
);
3745 _bfd_vms_output_long (recwr
, (unsigned long) (size
));
3746 _bfd_vms_output_dump (recwr
, cptr
, size
);
3747 _bfd_vms_output_end_subrec (recwr
);
3750 _bfd_vms_debug (10, "dumped %d bytes\n", (int) size
);
3751 _bfd_hexdump (10, cptr
, (int) size
, (int) vaddr
);
3761 etir_output_check (bfd
*abfd
, asection
*section
, bfd_vma vaddr
, int checklen
)
3763 if (_bfd_vms_output_check (&PRIV (recwr
), checklen
) < 0)
3765 /* Not enough room in this record. Close it and open a new one. */
3766 end_etir_record (abfd
);
3767 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3771 /* Return whether RELOC must be deferred till the end. */
3774 defer_reloc_p (arelent
*reloc
)
3776 switch (reloc
->howto
->type
)
3789 /* Write section contents for bfd abfd. Return FALSE on error. */
3792 _bfd_vms_write_etir (bfd
* abfd
, int objtype ATTRIBUTE_UNUSED
)
3795 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3797 vms_debug2 ((2, "vms_write_tir (%p, %d)\n", abfd
, objtype
));
3799 _bfd_vms_output_alignment (recwr
, 4);
3801 PRIV (vms_linkage_index
) = 0;
3803 for (section
= abfd
->sections
; section
; section
= section
->next
)
3805 vms_debug2 ((4, "writing %d. section '%s' (%d bytes)\n",
3806 section
->target_index
, section
->name
, (int) (section
->size
)));
3808 if (!(section
->flags
& SEC_HAS_CONTENTS
)
3809 || bfd_is_com_section (section
))
3812 if (!section
->contents
)
3814 bfd_set_error (bfd_error_no_contents
);
3818 start_etir_or_etbt_record (abfd
, section
, 0);
3820 if (section
->flags
& SEC_RELOC
)
3822 bfd_vma curr_addr
= 0;
3823 unsigned char *curr_data
= section
->contents
;
3825 int pass2_needed
= 0;
3826 int pass2_in_progress
= 0;
3829 if (section
->reloc_count
== 0)
3831 (_("SEC_RELOC with no relocs in section %pA"), section
);
3836 int i
= section
->reloc_count
;
3837 arelent
**rptr
= section
->orelocation
;
3838 _bfd_vms_debug (4, "%d relocations:\n", i
);
3841 _bfd_vms_debug (4, "sym %s in sec %s, value %08lx, "
3842 "addr %08lx, off %08lx, len %d: %s\n",
3843 (*(*rptr
)->sym_ptr_ptr
)->name
,
3844 (*(*rptr
)->sym_ptr_ptr
)->section
->name
,
3845 (long) (*(*rptr
)->sym_ptr_ptr
)->value
,
3846 (unsigned long)(*rptr
)->address
,
3847 (unsigned long)(*rptr
)->addend
,
3848 bfd_get_reloc_size ((*rptr
)->howto
),
3849 ( *rptr
)->howto
->name
);
3856 for (irel
= 0; irel
< section
->reloc_count
; irel
++)
3858 struct evax_private_udata_struct
*udata
;
3859 arelent
*rptr
= section
->orelocation
[irel
];
3860 bfd_vma addr
= rptr
->address
;
3861 asymbol
*sym
= *rptr
->sym_ptr_ptr
;
3862 asection
*sec
= sym
->section
;
3863 bfd_boolean defer
= defer_reloc_p (rptr
);
3866 if (pass2_in_progress
)
3868 /* Non-deferred relocs have already been output. */
3874 /* Deferred relocs must be output at the very end. */
3881 /* Regular relocs are intertwined with binary data. */
3882 if (curr_addr
> addr
)
3883 _bfd_error_handler (_("size error in section %pA"),
3885 size
= addr
- curr_addr
;
3886 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
3891 size
= bfd_get_reloc_size (rptr
->howto
);
3893 switch (rptr
->howto
->type
)
3895 case ALPHA_R_IGNORE
:
3898 case ALPHA_R_REFLONG
:
3899 if (bfd_is_und_section (sym
->section
))
3901 bfd_vma addend
= rptr
->addend
;
3902 slen
= strlen ((char *) sym
->name
);
3903 etir_output_check (abfd
, section
, curr_addr
, slen
);
3906 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
3907 _bfd_vms_output_counted (recwr
, sym
->name
);
3908 _bfd_vms_output_end_subrec (recwr
);
3909 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3910 _bfd_vms_output_long (recwr
, (unsigned long) addend
);
3911 _bfd_vms_output_end_subrec (recwr
);
3912 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
3913 _bfd_vms_output_end_subrec (recwr
);
3914 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3915 _bfd_vms_output_end_subrec (recwr
);
3919 _bfd_vms_output_begin_subrec
3920 (recwr
, ETIR__C_STO_GBL_LW
);
3921 _bfd_vms_output_counted (recwr
, sym
->name
);
3922 _bfd_vms_output_end_subrec (recwr
);
3925 else if (bfd_is_abs_section (sym
->section
))
3927 etir_output_check (abfd
, section
, curr_addr
, 16);
3928 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3929 _bfd_vms_output_long (recwr
, (unsigned long) sym
->value
);
3930 _bfd_vms_output_end_subrec (recwr
);
3931 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3932 _bfd_vms_output_end_subrec (recwr
);
3936 etir_output_check (abfd
, section
, curr_addr
, 32);
3937 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3938 _bfd_vms_output_long (recwr
,
3939 (unsigned long) sec
->target_index
);
3940 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
3941 _bfd_vms_output_end_subrec (recwr
);
3942 /* ??? Table B-8 of the OpenVMS Linker Utilily Manual
3943 says that we should have a ETIR__C_STO_OFF here.
3944 But the relocation would not be BFD_RELOC_32 then.
3945 This case is very likely unreachable. */
3946 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3947 _bfd_vms_output_end_subrec (recwr
);
3951 case ALPHA_R_REFQUAD
:
3952 if (bfd_is_und_section (sym
->section
))
3954 bfd_vma addend
= rptr
->addend
;
3955 slen
= strlen ((char *) sym
->name
);
3956 etir_output_check (abfd
, section
, curr_addr
, slen
);
3959 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
3960 _bfd_vms_output_counted (recwr
, sym
->name
);
3961 _bfd_vms_output_end_subrec (recwr
);
3962 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
3963 _bfd_vms_output_quad (recwr
, addend
);
3964 _bfd_vms_output_end_subrec (recwr
);
3965 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
3966 _bfd_vms_output_end_subrec (recwr
);
3967 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
3968 _bfd_vms_output_end_subrec (recwr
);
3972 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_GBL
);
3973 _bfd_vms_output_counted (recwr
, sym
->name
);
3974 _bfd_vms_output_end_subrec (recwr
);
3977 else if (bfd_is_abs_section (sym
->section
))
3979 etir_output_check (abfd
, section
, curr_addr
, 16);
3980 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
3981 _bfd_vms_output_quad (recwr
, sym
->value
);
3982 _bfd_vms_output_end_subrec (recwr
);
3983 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
3984 _bfd_vms_output_end_subrec (recwr
);
3988 etir_output_check (abfd
, section
, curr_addr
, 32);
3989 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3990 _bfd_vms_output_long (recwr
,
3991 (unsigned long) sec
->target_index
);
3992 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
3993 _bfd_vms_output_end_subrec (recwr
);
3994 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_OFF
);
3995 _bfd_vms_output_end_subrec (recwr
);
4000 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
4003 case ALPHA_R_LINKAGE
:
4005 etir_output_check (abfd
, section
, curr_addr
, 64);
4006 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LP_PSB
);
4007 _bfd_vms_output_long
4008 (recwr
, (unsigned long) rptr
->addend
);
4009 if (rptr
->addend
> PRIV (vms_linkage_index
))
4010 PRIV (vms_linkage_index
) = rptr
->addend
;
4011 _bfd_vms_output_counted (recwr
, sym
->name
);
4012 _bfd_vms_output_byte (recwr
, 0);
4013 _bfd_vms_output_end_subrec (recwr
);
4016 case ALPHA_R_CODEADDR
:
4017 slen
= strlen ((char *) sym
->name
);
4018 etir_output_check (abfd
, section
, curr_addr
, slen
);
4019 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_CA
);
4020 _bfd_vms_output_counted (recwr
, sym
->name
);
4021 _bfd_vms_output_end_subrec (recwr
);
4026 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4027 etir_output_check (abfd
, section
, curr_addr
,
4028 32 + 1 + strlen (udata
->origname
));
4029 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_NOP_GBL
);
4030 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
4031 _bfd_vms_output_long
4032 (recwr
, (unsigned long) section
->target_index
);
4033 _bfd_vms_output_quad (recwr
, rptr
->address
);
4034 _bfd_vms_output_long (recwr
, (unsigned long) 0x47ff041f);
4035 _bfd_vms_output_long
4036 (recwr
, (unsigned long) section
->target_index
);
4037 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4038 _bfd_vms_output_counted (recwr
, udata
->origname
);
4039 _bfd_vms_output_end_subrec (recwr
);
4043 _bfd_error_handler (_("spurious ALPHA_R_BSR reloc"));
4048 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4049 etir_output_check (abfd
, section
, curr_addr
,
4050 32 + 1 + strlen (udata
->origname
));
4051 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LDA_GBL
);
4052 _bfd_vms_output_long
4053 (recwr
, (unsigned long) udata
->lkindex
+ 1);
4054 _bfd_vms_output_long
4055 (recwr
, (unsigned long) section
->target_index
);
4056 _bfd_vms_output_quad (recwr
, rptr
->address
);
4057 _bfd_vms_output_long (recwr
, (unsigned long) 0x237B0000);
4058 _bfd_vms_output_long
4059 (recwr
, (unsigned long) udata
->bsym
->section
->target_index
);
4060 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4061 _bfd_vms_output_counted (recwr
, udata
->origname
);
4062 _bfd_vms_output_end_subrec (recwr
);
4067 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4068 etir_output_check (abfd
, section
, curr_addr
,
4069 32 + 1 + strlen (udata
->origname
));
4070 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_BOH_GBL
);
4071 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
4072 _bfd_vms_output_long
4073 (recwr
, (unsigned long) section
->target_index
);
4074 _bfd_vms_output_quad (recwr
, rptr
->address
);
4075 _bfd_vms_output_long (recwr
, (unsigned long) 0xD3400000);
4076 _bfd_vms_output_long
4077 (recwr
, (unsigned long) section
->target_index
);
4078 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4079 _bfd_vms_output_counted (recwr
, udata
->origname
);
4080 _bfd_vms_output_end_subrec (recwr
);
4084 _bfd_error_handler (_("unhandled relocation %s"),
4091 } /* End of relocs loop. */
4093 if (!pass2_in_progress
)
4095 /* Output rest of section. */
4096 if (curr_addr
> section
->size
)
4097 _bfd_error_handler (_("size error in section %pA"), section
);
4098 size
= section
->size
- curr_addr
;
4099 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
4105 pass2_in_progress
= 1;
4111 else /* (section->flags & SEC_RELOC) */
4112 sto_imm (abfd
, section
, section
->size
, section
->contents
, 0);
4114 end_etir_record (abfd
);
4117 _bfd_vms_output_alignment (recwr
, 2);
4121 /* Write cached information into a file being written, at bfd_close. */
4124 alpha_vms_write_object_contents (bfd
*abfd
)
4126 vms_debug2 ((1, "vms_write_object_contents (%p)\n", abfd
));
4128 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
4130 return alpha_vms_write_exec (abfd
);
4134 if (abfd
->section_count
> 0) /* we have sections */
4136 if (!_bfd_vms_write_ehdr (abfd
))
4138 if (!_bfd_vms_write_egsd (abfd
))
4140 if (!_bfd_vms_write_etir (abfd
, EOBJ__C_ETIR
))
4142 if (!_bfd_vms_write_eeom (abfd
))
4149 /* Debug stuff: nearest line. */
4151 #define SET_MODULE_PARSED(m) \
4152 do { if ((m)->name == NULL) (m)->name = ""; } while (0)
4153 #define IS_MODULE_PARSED(m) ((m)->name != NULL)
4155 /* Build a new module for the specified BFD. */
4157 static struct module
*
4158 new_module (bfd
*abfd
)
4160 struct module
*module
4161 = (struct module
*) bfd_zalloc (abfd
, sizeof (struct module
));
4162 module
->file_table_count
= 16; /* Arbitrary. */
4164 = bfd_malloc (module
->file_table_count
* sizeof (struct fileinfo
));
4168 /* Parse debug info for a module and internalize it. */
4171 parse_module (bfd
*abfd
, struct module
*module
, unsigned char *ptr
,
4174 unsigned char *maxptr
= ptr
+ length
;
4175 unsigned char *src_ptr
, *pcl_ptr
;
4176 unsigned int prev_linum
= 0, curr_linenum
= 0;
4177 bfd_vma prev_pc
= 0, curr_pc
= 0;
4178 struct srecinfo
*curr_srec
, *srec
;
4179 struct lineinfo
*curr_line
, *line
;
4180 struct funcinfo
*funcinfo
;
4182 /* Initialize tables with zero element. */
4183 curr_srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4184 module
->srec_table
= curr_srec
;
4186 curr_line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4187 module
->line_table
= curr_line
;
4189 while (length
== -1 || ptr
< maxptr
)
4191 /* The first byte is not counted in the recorded length. */
4192 int rec_length
= bfd_getl16 (ptr
) + 1;
4193 int rec_type
= bfd_getl16 (ptr
+ 2);
4195 vms_debug2 ((2, "DST record: leng %d, type %d\n", rec_length
, rec_type
));
4197 if (length
== -1 && rec_type
== DST__K_MODEND
)
4204 = _bfd_vms_save_counted_string (ptr
+ DST_S_B_MODBEG_NAME
,
4205 maxptr
- (ptr
+ DST_S_B_MODBEG_NAME
));
4212 vms_debug2 ((3, "module: %s\n", module
->name
));
4219 funcinfo
= (struct funcinfo
*)
4220 bfd_zalloc (abfd
, sizeof (struct funcinfo
));
4222 = _bfd_vms_save_counted_string (ptr
+ DST_S_B_RTNBEG_NAME
,
4223 maxptr
- (ptr
+ DST_S_B_RTNBEG_NAME
));
4224 funcinfo
->low
= bfd_getl32 (ptr
+ DST_S_L_RTNBEG_ADDRESS
);
4225 funcinfo
->next
= module
->func_table
;
4226 module
->func_table
= funcinfo
;
4228 vms_debug2 ((3, "routine: %s at 0x%lx\n",
4229 funcinfo
->name
, (unsigned long) funcinfo
->low
));
4233 module
->func_table
->high
= module
->func_table
->low
4234 + bfd_getl32 (ptr
+ DST_S_L_RTNEND_SIZE
) - 1;
4236 if (module
->func_table
->high
> module
->high
)
4237 module
->high
= module
->func_table
->high
;
4239 vms_debug2 ((3, "end routine\n"));
4243 vms_debug2 ((3, "prologue\n"));
4247 vms_debug2 ((3, "epilog\n"));
4251 vms_debug2 ((3, "block\n"));
4255 vms_debug2 ((3, "end block\n"));
4259 src_ptr
= ptr
+ DST_S_C_SOURCE_HEADER_SIZE
;
4261 vms_debug2 ((3, "source info\n"));
4263 while (src_ptr
< ptr
+ rec_length
)
4265 int cmd
= src_ptr
[0], cmd_length
, data
;
4269 case DST__K_SRC_DECLFILE
:
4272 = bfd_getl16 (src_ptr
+ DST_S_W_SRC_DF_FILEID
);
4274 = _bfd_vms_save_counted_string (src_ptr
+ DST_S_B_SRC_DF_FILENAME
,
4275 (ptr
+ rec_length
) -
4276 (src_ptr
+ DST_S_B_SRC_DF_FILENAME
)
4279 while (fileid
>= module
->file_table_count
)
4281 module
->file_table_count
*= 2;
4283 = bfd_realloc (module
->file_table
,
4284 module
->file_table_count
4285 * sizeof (struct fileinfo
));
4288 module
->file_table
[fileid
].name
= filename
;
4289 module
->file_table
[fileid
].srec
= 1;
4290 cmd_length
= src_ptr
[DST_S_B_SRC_DF_LENGTH
] + 2;
4291 vms_debug2 ((4, "DST_S_C_SRC_DECLFILE: %d, %s\n",
4292 fileid
, module
->file_table
[fileid
].name
));
4296 case DST__K_SRC_DEFLINES_B
:
4297 /* Perform the association and set the next higher index
4299 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4300 srec
= (struct srecinfo
*)
4301 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4302 srec
->line
= curr_srec
->line
+ data
;
4303 srec
->srec
= curr_srec
->srec
+ data
;
4304 srec
->sfile
= curr_srec
->sfile
;
4305 curr_srec
->next
= srec
;
4308 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_B: %d\n", data
));
4311 case DST__K_SRC_DEFLINES_W
:
4312 /* Perform the association and set the next higher index
4314 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4315 srec
= (struct srecinfo
*)
4316 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4317 srec
->line
= curr_srec
->line
+ data
;
4318 srec
->srec
= curr_srec
->srec
+ data
,
4319 srec
->sfile
= curr_srec
->sfile
;
4320 curr_srec
->next
= srec
;
4323 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_W: %d\n", data
));
4326 case DST__K_SRC_INCRLNUM_B
:
4327 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4328 curr_srec
->line
+= data
;
4330 vms_debug2 ((4, "DST_S_C_SRC_INCRLNUM_B: %d\n", data
));
4333 case DST__K_SRC_SETFILE
:
4334 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4335 curr_srec
->sfile
= data
;
4336 curr_srec
->srec
= module
->file_table
[data
].srec
;
4338 vms_debug2 ((4, "DST_S_C_SRC_SETFILE: %d\n", data
));
4341 case DST__K_SRC_SETLNUM_L
:
4342 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4343 curr_srec
->line
= data
;
4345 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_L: %d\n", data
));
4348 case DST__K_SRC_SETLNUM_W
:
4349 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4350 curr_srec
->line
= data
;
4352 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_W: %d\n", data
));
4355 case DST__K_SRC_SETREC_L
:
4356 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4357 curr_srec
->srec
= data
;
4358 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4360 vms_debug2 ((4, "DST_S_C_SRC_SETREC_L: %d\n", data
));
4363 case DST__K_SRC_SETREC_W
:
4364 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4365 curr_srec
->srec
= data
;
4366 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4368 vms_debug2 ((4, "DST_S_C_SRC_SETREC_W: %d\n", data
));
4371 case DST__K_SRC_FORMFEED
:
4373 vms_debug2 ((4, "DST_S_C_SRC_FORMFEED\n"));
4377 _bfd_error_handler (_("unknown source command %d"),
4383 src_ptr
+= cmd_length
;
4387 case DST__K_LINE_NUM
:
4388 pcl_ptr
= ptr
+ DST_S_C_LINE_NUM_HEADER_SIZE
;
4390 vms_debug2 ((3, "line info\n"));
4392 while (pcl_ptr
< ptr
+ rec_length
)
4394 /* The command byte is signed so we must sign-extend it. */
4395 int cmd
= ((signed char *)pcl_ptr
)[0], cmd_length
, data
;
4399 case DST__K_DELTA_PC_W
:
4400 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4404 vms_debug2 ((4, "DST__K_DELTA_PC_W: %d\n", data
));
4407 case DST__K_DELTA_PC_L
:
4408 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4412 vms_debug2 ((4, "DST__K_DELTA_PC_L: %d\n", data
));
4415 case DST__K_INCR_LINUM
:
4416 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4417 curr_linenum
+= data
;
4419 vms_debug2 ((4, "DST__K_INCR_LINUM: %d\n", data
));
4422 case DST__K_INCR_LINUM_W
:
4423 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4424 curr_linenum
+= data
;
4426 vms_debug2 ((4, "DST__K_INCR_LINUM_W: %d\n", data
));
4429 case DST__K_INCR_LINUM_L
:
4430 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4431 curr_linenum
+= data
;
4433 vms_debug2 ((4, "DST__K_INCR_LINUM_L: %d\n", data
));
4436 case DST__K_SET_LINUM_INCR
:
4438 (_("%s not implemented"), "DST__K_SET_LINUM_INCR");
4442 case DST__K_SET_LINUM_INCR_W
:
4444 (_("%s not implemented"), "DST__K_SET_LINUM_INCR_W");
4448 case DST__K_RESET_LINUM_INCR
:
4450 (_("%s not implemented"), "DST__K_RESET_LINUM_INCR");
4454 case DST__K_BEG_STMT_MODE
:
4456 (_("%s not implemented"), "DST__K_BEG_STMT_MODE");
4460 case DST__K_END_STMT_MODE
:
4462 (_("%s not implemented"), "DST__K_END_STMT_MODE");
4466 case DST__K_SET_LINUM_B
:
4467 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4468 curr_linenum
= data
;
4470 vms_debug2 ((4, "DST__K_SET_LINUM_B: %d\n", data
));
4473 case DST__K_SET_LINUM
:
4474 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4475 curr_linenum
= data
;
4477 vms_debug2 ((4, "DST__K_SET_LINE_NUM: %d\n", data
));
4480 case DST__K_SET_LINUM_L
:
4481 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4482 curr_linenum
= data
;
4484 vms_debug2 ((4, "DST__K_SET_LINUM_L: %d\n", data
));
4489 (_("%s not implemented"), "DST__K_SET_PC");
4493 case DST__K_SET_PC_W
:
4495 (_("%s not implemented"), "DST__K_SET_PC_W");
4499 case DST__K_SET_PC_L
:
4501 (_("%s not implemented"), "DST__K_SET_PC_L");
4505 case DST__K_SET_STMTNUM
:
4507 (_("%s not implemented"), "DST__K_SET_STMTNUM");
4512 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4515 vms_debug2 ((4, "DST__K_TERM: %d\n", data
));
4519 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4522 vms_debug2 ((4, "DST__K_TERM_W: %d\n", data
));
4526 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4529 vms_debug2 ((4, "DST__K_TERM_L: %d\n", data
));
4532 case DST__K_SET_ABS_PC
:
4533 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4536 vms_debug2 ((4, "DST__K_SET_ABS_PC: 0x%x\n", data
));
4545 vms_debug2 ((4, "bump pc to 0x%lx and line to %d\n",
4546 (unsigned long)curr_pc
, curr_linenum
));
4550 _bfd_error_handler (_("unknown line command %d"), cmd
);
4556 if ((curr_linenum
!= prev_linum
&& curr_pc
!= prev_pc
)
4558 || cmd
== DST__K_DELTA_PC_L
4559 || cmd
== DST__K_DELTA_PC_W
)
4561 line
= (struct lineinfo
*)
4562 bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4563 line
->address
= curr_pc
;
4564 line
->line
= curr_linenum
;
4566 curr_line
->next
= line
;
4569 prev_linum
= curr_linenum
;
4571 vms_debug2 ((4, "-> correlate pc 0x%lx with line %d\n",
4572 (unsigned long)curr_pc
, curr_linenum
));
4575 pcl_ptr
+= cmd_length
;
4579 case 0x17: /* Undocumented type used by DEC C to declare equates. */
4580 vms_debug2 ((3, "undocumented type 0x17\n"));
4584 vms_debug2 ((3, "ignoring record\n"));
4592 /* Finalize tables with EOL marker. */
4593 srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4594 srec
->line
= (unsigned int) -1;
4595 srec
->srec
= (unsigned int) -1;
4596 curr_srec
->next
= srec
;
4598 line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4599 line
->line
= (unsigned int) -1;
4600 line
->address
= (bfd_vma
) -1;
4601 curr_line
->next
= line
;
4603 /* Advertise that this module has been parsed. This is needed
4604 because parsing can be either performed at module creation
4605 or deferred until debug info is consumed. */
4606 SET_MODULE_PARSED (module
);
4609 /* Build the list of modules for the specified BFD. */
4611 static struct module
*
4612 build_module_list (bfd
*abfd
)
4614 struct module
*module
, *list
= NULL
;
4617 if ((dmt
= bfd_get_section_by_name (abfd
, "$DMT$")))
4619 /* We have a DMT section so this must be an image. Parse the
4620 section and build the list of modules. This is sufficient
4621 since we can compute the start address and the end address
4622 of every module from the section contents. */
4623 bfd_size_type size
= bfd_get_section_size (dmt
);
4624 unsigned char *ptr
, *end
;
4626 ptr
= (unsigned char *) bfd_alloc (abfd
, size
);
4630 if (! bfd_get_section_contents (abfd
, dmt
, ptr
, 0, size
))
4633 vms_debug2 ((2, "DMT\n"));
4639 /* Each header declares a module with its start offset and size
4640 of debug info in the DST section, as well as the count of
4641 program sections (i.e. address spans) it contains. */
4642 int modbeg
= bfd_getl32 (ptr
+ DBG_S_L_DMT_MODBEG
);
4643 int msize
= bfd_getl32 (ptr
+ DBG_S_L_DST_SIZE
);
4644 int count
= bfd_getl16 (ptr
+ DBG_S_W_DMT_PSECT_COUNT
);
4645 ptr
+= DBG_S_C_DMT_HEADER_SIZE
;
4647 vms_debug2 ((3, "module: modbeg = %d, size = %d, count = %d\n",
4648 modbeg
, msize
, count
));
4650 /* We create a 'module' structure for each program section since
4651 we only support contiguous addresses in a 'module' structure.
4652 As a consequence, the actual debug info in the DST section is
4653 shared and can be parsed multiple times; that doesn't seem to
4654 cause problems in practice. */
4657 int start
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_START
);
4658 int length
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_LENGTH
);
4659 module
= new_module (abfd
);
4660 module
->modbeg
= modbeg
;
4661 module
->size
= msize
;
4662 module
->low
= start
;
4663 module
->high
= start
+ length
;
4664 module
->next
= list
;
4666 ptr
+= DBG_S_C_DMT_PSECT_SIZE
;
4668 vms_debug2 ((4, "section: start = 0x%x, length = %d\n",
4675 /* We don't have a DMT section so this must be an object. Parse
4676 the module right now in order to compute its start address and
4678 void *dst
= PRIV (dst_section
)->contents
;
4683 module
= new_module (abfd
);
4684 parse_module (abfd
, module
, PRIV (dst_section
)->contents
, -1);
4691 /* Calculate and return the name of the source file and the line nearest
4692 to the wanted location in the specified module. */
4695 module_find_nearest_line (bfd
*abfd
, struct module
*module
, bfd_vma addr
,
4696 const char **file
, const char **func
,
4699 struct funcinfo
*funcinfo
;
4700 struct lineinfo
*lineinfo
;
4701 struct srecinfo
*srecinfo
;
4702 bfd_boolean ret
= FALSE
;
4704 /* Parse this module if that was not done at module creation. */
4705 if (! IS_MODULE_PARSED (module
))
4707 unsigned int size
= module
->size
;
4708 unsigned int modbeg
= PRIV (dst_section
)->filepos
+ module
->modbeg
;
4709 unsigned char *buffer
= (unsigned char *) bfd_malloc (module
->size
);
4711 if (bfd_seek (abfd
, modbeg
, SEEK_SET
) != 0
4712 || bfd_bread (buffer
, size
, abfd
) != size
)
4714 bfd_set_error (bfd_error_no_debug_section
);
4718 parse_module (abfd
, module
, buffer
, size
);
4722 /* Find out the function (if any) that contains the address. */
4723 for (funcinfo
= module
->func_table
; funcinfo
; funcinfo
= funcinfo
->next
)
4724 if (addr
>= funcinfo
->low
&& addr
<= funcinfo
->high
)
4726 *func
= funcinfo
->name
;
4731 /* Find out the source file and the line nearest to the address. */
4732 for (lineinfo
= module
->line_table
; lineinfo
; lineinfo
= lineinfo
->next
)
4733 if (lineinfo
->next
&& addr
< lineinfo
->next
->address
)
4735 for (srecinfo
= module
->srec_table
; srecinfo
; srecinfo
= srecinfo
->next
)
4736 if (srecinfo
->next
&& lineinfo
->line
< srecinfo
->next
->line
)
4738 if (srecinfo
->sfile
> 0)
4740 *file
= module
->file_table
[srecinfo
->sfile
].name
;
4741 *line
= srecinfo
->srec
+ lineinfo
->line
- srecinfo
->line
;
4745 *file
= module
->name
;
4746 *line
= lineinfo
->line
;
4757 /* Provided a BFD, a section and an offset into the section, calculate and
4758 return the name of the source file and the line nearest to the wanted
4762 _bfd_vms_find_nearest_line (bfd
*abfd
,
4763 asymbol
**symbols ATTRIBUTE_UNUSED
,
4769 unsigned int *discriminator
)
4771 struct module
*module
;
4773 /* What address are we looking for? */
4774 bfd_vma addr
= section
->vma
+ offset
;
4782 /* We can't do anything if there is no DST (debug symbol table). */
4783 if (PRIV (dst_section
) == NULL
)
4786 /* Create the module list - if not already done. */
4787 if (PRIV (modules
) == NULL
)
4789 PRIV (modules
) = build_module_list (abfd
);
4790 if (PRIV (modules
) == NULL
)
4794 for (module
= PRIV (modules
); module
; module
= module
->next
)
4795 if (addr
>= module
->low
&& addr
<= module
->high
)
4796 return module_find_nearest_line (abfd
, module
, addr
, file
, func
, line
);
4801 /* Canonicalizations. */
4802 /* Set name, value, section and flags of SYM from E. */
4805 alpha_vms_convert_symbol (bfd
*abfd
, struct vms_symbol_entry
*e
, asymbol
*sym
)
4814 flags
= BSF_NO_FLAGS
;
4820 if (e
->flags
& EGSY__V_WEAK
)
4823 if (e
->flags
& EGSY__V_DEF
)
4825 /* Symbol definition. */
4826 flags
|= BSF_GLOBAL
;
4827 if (e
->flags
& EGSY__V_NORM
)
4828 flags
|= BSF_FUNCTION
;
4834 /* Symbol reference. */
4835 sec
= bfd_und_section_ptr
;
4840 /* A universal symbol is by definition global... */
4841 flags
|= BSF_GLOBAL
;
4843 /* ...and dynamic in shared libraries. */
4844 if (abfd
->flags
& DYNAMIC
)
4845 flags
|= BSF_DYNAMIC
;
4847 if (e
->flags
& EGSY__V_WEAK
)
4850 if (!(e
->flags
& EGSY__V_DEF
))
4853 if (e
->flags
& EGSY__V_NORM
)
4854 flags
|= BSF_FUNCTION
;
4857 /* sec = e->section; */
4858 sec
= bfd_abs_section_ptr
;
4873 /* Return the number of bytes required to store a vector of pointers
4874 to asymbols for all the symbols in the BFD abfd, including a
4875 terminal NULL pointer. If there are no symbols in the BFD,
4876 then return 0. If an error occurs, return -1. */
4879 alpha_vms_get_symtab_upper_bound (bfd
*abfd
)
4881 vms_debug2 ((1, "alpha_vms_get_symtab_upper_bound (%p), %d symbols\n",
4882 abfd
, PRIV (gsd_sym_count
)));
4884 return (PRIV (gsd_sym_count
) + 1) * sizeof (asymbol
*);
4887 /* Read the symbols from the BFD abfd, and fills in the vector
4888 location with pointers to the symbols and a trailing NULL.
4890 Return number of symbols read. */
4893 alpha_vms_canonicalize_symtab (bfd
*abfd
, asymbol
**symbols
)
4897 vms_debug2 ((1, "alpha_vms_canonicalize_symtab (%p, <ret>)\n", abfd
));
4899 if (PRIV (csymbols
) == NULL
)
4901 PRIV (csymbols
) = (asymbol
**) bfd_alloc
4902 (abfd
, PRIV (gsd_sym_count
) * sizeof (asymbol
*));
4904 /* Traverse table and fill symbols vector. */
4905 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
4907 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
4910 sym
= bfd_make_empty_symbol (abfd
);
4911 if (sym
== NULL
|| !alpha_vms_convert_symbol (abfd
, e
, sym
))
4913 bfd_release (abfd
, PRIV (csymbols
));
4914 PRIV (csymbols
) = NULL
;
4918 PRIV (csymbols
)[i
] = sym
;
4922 if (symbols
!= NULL
)
4924 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
4925 symbols
[i
] = PRIV (csymbols
)[i
];
4929 return PRIV (gsd_sym_count
);
4932 /* Read and convert relocations from ETIR. We do it once for all sections. */
4935 alpha_vms_slurp_relocs (bfd
*abfd
)
4939 vms_debug2 ((3, "alpha_vms_slurp_relocs\n"));
4941 /* We slurp relocs only once, for all sections. */
4942 if (PRIV (reloc_done
))
4944 PRIV (reloc_done
) = TRUE
;
4946 if (alpha_vms_canonicalize_symtab (abfd
, NULL
) < 0)
4949 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
4954 unsigned char *begin
;
4957 bfd_reloc_code_real_type reloc_code
;
4963 bfd_vma cur_address
;
4965 unsigned char *cur_sym
= NULL
;
4967 bfd_vma cur_addend
= 0;
4969 /* Skip non-ETIR records. */
4970 type
= _bfd_vms_get_object_record (abfd
);
4971 if (type
== EOBJ__C_EEOM
)
4973 if (type
!= EOBJ__C_ETIR
)
4976 begin
= PRIV (recrd
.rec
) + 4;
4977 end
= PRIV (recrd
.rec
) + PRIV (recrd
.rec_size
);
4979 for (ptr
= begin
; ptr
< end
; ptr
+= length
)
4983 cmd
= bfd_getl16 (ptr
);
4984 length
= bfd_getl16 (ptr
+ 2);
4986 cur_address
= vaddr
;
4988 vms_debug2 ((4, "alpha_vms_slurp_relocs: etir %s\n",
4989 _bfd_vms_etir_name (cmd
)));
4993 case ETIR__C_STA_GBL
: /* ALPHA_R_REFLONG und_section, step 1 */
4994 /* ALPHA_R_REFQUAD und_section, step 1 */
4999 case ETIR__C_STA_PQ
: /* ALPHA_R_REF{LONG|QUAD}, others part 1 */
5000 cur_psidx
= bfd_getl32 (ptr
+ 4);
5001 cur_addend
= bfd_getl64 (ptr
+ 8);
5005 case ETIR__C_CTL_SETRB
:
5006 if (prev_cmd
!= ETIR__C_STA_PQ
)
5009 /* xgettext:c-format */
5010 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (prev_cmd
),
5011 _bfd_vms_etir_name (cmd
));
5014 cur_psect
= cur_psidx
;
5020 case ETIR__C_STA_LW
: /* ALPHA_R_REFLONG abs_section, step 1 */
5021 /* ALPHA_R_REFLONG und_section, step 2 */
5024 if (prev_cmd
!= ETIR__C_STA_GBL
)
5027 /* xgettext:c-format */
5028 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
5029 _bfd_vms_etir_name (ETIR__C_STA_LW
));
5033 cur_addend
= bfd_getl32 (ptr
+ 4);
5037 case ETIR__C_STA_QW
: /* ALPHA_R_REFQUAD abs_section, step 1 */
5038 /* ALPHA_R_REFQUAD und_section, step 2 */
5039 if (prev_cmd
!= -1 && prev_cmd
!= ETIR__C_STA_GBL
)
5042 /* xgettext:c-format */
5043 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
5044 _bfd_vms_etir_name (ETIR__C_STA_QW
));
5047 cur_addend
= bfd_getl64 (ptr
+ 4);
5051 case ETIR__C_STO_LW
: /* ALPHA_R_REFLONG und_section, step 4 */
5052 /* ALPHA_R_REFLONG abs_section, step 2 */
5053 /* ALPHA_R_REFLONG others, step 2 */
5054 if (prev_cmd
!= ETIR__C_OPR_ADD
5055 && prev_cmd
!= ETIR__C_STA_LW
5056 && prev_cmd
!= ETIR__C_STA_PQ
)
5058 /* xgettext:c-format */
5059 _bfd_error_handler (_("unknown reloc %s + %s"),
5060 _bfd_vms_etir_name (prev_cmd
),
5061 _bfd_vms_etir_name (ETIR__C_STO_LW
));
5064 reloc_code
= BFD_RELOC_32
;
5067 case ETIR__C_STO_QW
: /* ALPHA_R_REFQUAD und_section, step 4 */
5068 /* ALPHA_R_REFQUAD abs_section, step 2 */
5069 if (prev_cmd
!= ETIR__C_OPR_ADD
&& prev_cmd
!= ETIR__C_STA_QW
)
5071 /* xgettext:c-format */
5072 _bfd_error_handler (_("unknown reloc %s + %s"),
5073 _bfd_vms_etir_name (prev_cmd
),
5074 _bfd_vms_etir_name (ETIR__C_STO_QW
));
5077 reloc_code
= BFD_RELOC_64
;
5080 case ETIR__C_STO_OFF
: /* ALPHA_R_REFQUAD others, step 2 */
5081 if (prev_cmd
!= ETIR__C_STA_PQ
)
5083 /* xgettext:c-format */
5084 _bfd_error_handler (_("unknown reloc %s + %s"),
5085 _bfd_vms_etir_name (prev_cmd
),
5086 _bfd_vms_etir_name (ETIR__C_STO_OFF
));
5089 reloc_code
= BFD_RELOC_64
;
5092 case ETIR__C_OPR_ADD
: /* ALPHA_R_REFLONG und_section, step 3 */
5093 /* ALPHA_R_REFQUAD und_section, step 3 */
5094 if (prev_cmd
!= ETIR__C_STA_LW
&& prev_cmd
!= ETIR__C_STA_QW
)
5096 /* xgettext:c-format */
5097 _bfd_error_handler (_("unknown reloc %s + %s"),
5098 _bfd_vms_etir_name (prev_cmd
),
5099 _bfd_vms_etir_name (ETIR__C_OPR_ADD
));
5102 prev_cmd
= ETIR__C_OPR_ADD
;
5105 case ETIR__C_STO_CA
: /* ALPHA_R_CODEADDR */
5106 reloc_code
= BFD_RELOC_ALPHA_CODEADDR
;
5110 case ETIR__C_STO_GBL
: /* ALPHA_R_REFQUAD und_section */
5111 reloc_code
= BFD_RELOC_64
;
5115 case ETIR__C_STO_GBL_LW
: /* ALPHA_R_REFLONG und_section */
5116 reloc_code
= BFD_RELOC_32
;
5120 case ETIR__C_STC_LP_PSB
: /* ALPHA_R_LINKAGE */
5121 reloc_code
= BFD_RELOC_ALPHA_LINKAGE
;
5125 case ETIR__C_STC_NOP_GBL
: /* ALPHA_R_NOP */
5126 reloc_code
= BFD_RELOC_ALPHA_NOP
;
5129 case ETIR__C_STC_BSR_GBL
: /* ALPHA_R_BSR */
5130 reloc_code
= BFD_RELOC_ALPHA_BSR
;
5133 case ETIR__C_STC_LDA_GBL
: /* ALPHA_R_LDA */
5134 reloc_code
= BFD_RELOC_ALPHA_LDA
;
5137 case ETIR__C_STC_BOH_GBL
: /* ALPHA_R_BOH */
5138 reloc_code
= BFD_RELOC_ALPHA_BOH
;
5142 cur_sym
= ptr
+ 4 + 32;
5143 cur_address
= bfd_getl64 (ptr
+ 4 + 8);
5144 cur_addend
= bfd_getl64 (ptr
+ 4 + 24);
5147 case ETIR__C_STO_IMM
:
5148 vaddr
+= bfd_getl32 (ptr
+ 4);
5152 _bfd_error_handler (_("unknown reloc %s"),
5153 _bfd_vms_etir_name (cmd
));
5159 struct vms_section_data_struct
*vms_sec
;
5163 /* Get section to which the relocation applies. */
5164 if (cur_psect
< 0 || cur_psect
> (int)PRIV (section_count
))
5166 _bfd_error_handler (_("invalid section index in ETIR"));
5170 if (PRIV (sections
) == NULL
)
5172 sec
= PRIV (sections
)[cur_psect
];
5173 if (sec
== bfd_abs_section_ptr
)
5175 _bfd_error_handler (_("relocation for non-REL psect"));
5179 vms_sec
= vms_section_data (sec
);
5181 /* Allocate a reloc entry. */
5182 if (sec
->reloc_count
>= vms_sec
->reloc_max
)
5184 if (vms_sec
->reloc_max
== 0)
5186 vms_sec
->reloc_max
= 64;
5187 sec
->relocation
= bfd_zmalloc
5188 (vms_sec
->reloc_max
* sizeof (arelent
));
5192 vms_sec
->reloc_max
*= 2;
5193 sec
->relocation
= bfd_realloc
5194 (sec
->relocation
, vms_sec
->reloc_max
* sizeof (arelent
));
5197 reloc
= &sec
->relocation
[sec
->reloc_count
];
5200 reloc
->howto
= bfd_reloc_type_lookup (abfd
, reloc_code
);
5202 if (cur_sym
!= NULL
)
5205 unsigned int symlen
= *cur_sym
;
5208 /* Linear search. */
5213 for (j
= 0; j
< PRIV (gsd_sym_count
); j
++)
5214 if (PRIV (syms
)[j
]->namelen
== symlen
5215 && memcmp (PRIV (syms
)[j
]->name
, cur_sym
, symlen
) == 0)
5217 sym
= &PRIV (csymbols
)[j
];
5222 _bfd_error_handler (_("unknown symbol in command %s"),
5223 _bfd_vms_etir_name (cmd
));
5224 reloc
->sym_ptr_ptr
= NULL
;
5227 reloc
->sym_ptr_ptr
= sym
;
5229 else if (cur_psidx
>= 0)
5231 if (PRIV (sections
) == NULL
|| cur_psidx
>= (int) PRIV (section_count
))
5233 reloc
->sym_ptr_ptr
=
5234 PRIV (sections
)[cur_psidx
]->symbol_ptr_ptr
;
5237 reloc
->sym_ptr_ptr
= NULL
;
5239 reloc
->address
= cur_address
;
5240 reloc
->addend
= cur_addend
;
5242 if (reloc_code
== ALPHA_R_LINKAGE
)
5245 size
= bfd_get_reloc_size (reloc
->howto
);
5255 vms_debug2 ((3, "alpha_vms_slurp_relocs: result = TRUE\n"));
5260 /* Return the number of bytes required to store the relocation
5261 information associated with the given section. */
5264 alpha_vms_get_reloc_upper_bound (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*section
)
5266 alpha_vms_slurp_relocs (abfd
);
5268 return (section
->reloc_count
+ 1) * sizeof (arelent
*);
5271 /* Convert relocations from VMS (external) form into BFD internal
5272 form. Return the number of relocations. */
5275 alpha_vms_canonicalize_reloc (bfd
*abfd
, asection
*section
, arelent
**relptr
,
5276 asymbol
**symbols ATTRIBUTE_UNUSED
)
5281 if (!alpha_vms_slurp_relocs (abfd
))
5284 count
= section
->reloc_count
;
5285 tblptr
= section
->relocation
;
5288 *relptr
++ = tblptr
++;
5290 *relptr
= (arelent
*) NULL
;
5291 return section
->reloc_count
;
5294 /* Install a new set of internal relocs. */
5296 #define alpha_vms_set_reloc _bfd_generic_set_reloc
5299 /* This is just copied from ecoff-alpha, needs to be fixed probably. */
5301 /* How to process the various reloc types. */
5303 static bfd_reloc_status_type
5304 reloc_nil (bfd
* abfd ATTRIBUTE_UNUSED
,
5305 arelent
*reloc ATTRIBUTE_UNUSED
,
5306 asymbol
*sym ATTRIBUTE_UNUSED
,
5307 void * data ATTRIBUTE_UNUSED
,
5308 asection
*sec ATTRIBUTE_UNUSED
,
5309 bfd
*output_bfd ATTRIBUTE_UNUSED
,
5310 char **error_message ATTRIBUTE_UNUSED
)
5313 vms_debug (1, "reloc_nil (abfd %p, output_bfd %p)\n", abfd
, output_bfd
);
5314 vms_debug (2, "In section %s, symbol %s\n",
5315 sec
->name
, sym
->name
);
5316 vms_debug (2, "reloc sym %s, addr %08lx, addend %08lx, reloc is a %s\n",
5317 reloc
->sym_ptr_ptr
[0]->name
,
5318 (unsigned long)reloc
->address
,
5319 (unsigned long)reloc
->addend
, reloc
->howto
->name
);
5320 vms_debug (2, "data at %p\n", data
);
5321 /* _bfd_hexdump (2, data, bfd_get_reloc_size (reloc->howto), 0); */
5324 return bfd_reloc_ok
;
5327 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
5328 from smaller values. Start with zero, widen, *then* decrement. */
5329 #define MINUS_ONE (((bfd_vma)0) - 1)
5331 static reloc_howto_type alpha_howto_table
[] =
5333 HOWTO (ALPHA_R_IGNORE
, /* Type. */
5334 0, /* Rightshift. */
5335 0, /* Size (0 = byte, 1 = short, 2 = long). */
5337 TRUE
, /* PC relative. */
5339 complain_overflow_dont
,/* Complain_on_overflow. */
5340 reloc_nil
, /* Special_function. */
5341 "IGNORE", /* Name. */
5342 TRUE
, /* Partial_inplace. */
5343 0, /* Source mask */
5345 TRUE
), /* PC rel offset. */
5347 /* A 64 bit reference to a symbol. */
5348 HOWTO (ALPHA_R_REFQUAD
, /* Type. */
5349 0, /* Rightshift. */
5350 4, /* Size (0 = byte, 1 = short, 2 = long). */
5352 FALSE
, /* PC relative. */
5354 complain_overflow_bitfield
, /* Complain_on_overflow. */
5355 reloc_nil
, /* Special_function. */
5356 "REFQUAD", /* Name. */
5357 TRUE
, /* Partial_inplace. */
5358 MINUS_ONE
, /* Source mask. */
5359 MINUS_ONE
, /* Dest mask. */
5360 FALSE
), /* PC rel offset. */
5362 /* A 21 bit branch. The native assembler generates these for
5363 branches within the text segment, and also fills in the PC
5364 relative offset in the instruction. */
5365 HOWTO (ALPHA_R_BRADDR
, /* Type. */
5366 2, /* Rightshift. */
5367 2, /* Size (0 = byte, 1 = short, 2 = long). */
5369 TRUE
, /* PC relative. */
5371 complain_overflow_signed
, /* Complain_on_overflow. */
5372 reloc_nil
, /* Special_function. */
5373 "BRADDR", /* Name. */
5374 TRUE
, /* Partial_inplace. */
5375 0x1fffff, /* Source mask. */
5376 0x1fffff, /* Dest mask. */
5377 FALSE
), /* PC rel offset. */
5379 /* A hint for a jump to a register. */
5380 HOWTO (ALPHA_R_HINT
, /* Type. */
5381 2, /* Rightshift. */
5382 1, /* Size (0 = byte, 1 = short, 2 = long). */
5384 TRUE
, /* PC relative. */
5386 complain_overflow_dont
,/* Complain_on_overflow. */
5387 reloc_nil
, /* Special_function. */
5389 TRUE
, /* Partial_inplace. */
5390 0x3fff, /* Source mask. */
5391 0x3fff, /* Dest mask. */
5392 FALSE
), /* PC rel offset. */
5394 /* 16 bit PC relative offset. */
5395 HOWTO (ALPHA_R_SREL16
, /* Type. */
5396 0, /* Rightshift. */
5397 1, /* Size (0 = byte, 1 = short, 2 = long). */
5399 TRUE
, /* PC relative. */
5401 complain_overflow_signed
, /* Complain_on_overflow. */
5402 reloc_nil
, /* Special_function. */
5403 "SREL16", /* Name. */
5404 TRUE
, /* Partial_inplace. */
5405 0xffff, /* Source mask. */
5406 0xffff, /* Dest mask. */
5407 FALSE
), /* PC rel offset. */
5409 /* 32 bit PC relative offset. */
5410 HOWTO (ALPHA_R_SREL32
, /* Type. */
5411 0, /* Rightshift. */
5412 2, /* Size (0 = byte, 1 = short, 2 = long). */
5414 TRUE
, /* PC relative. */
5416 complain_overflow_signed
, /* Complain_on_overflow. */
5417 reloc_nil
, /* Special_function. */
5418 "SREL32", /* Name. */
5419 TRUE
, /* Partial_inplace. */
5420 0xffffffff, /* Source mask. */
5421 0xffffffff, /* Dest mask. */
5422 FALSE
), /* PC rel offset. */
5424 /* A 64 bit PC relative offset. */
5425 HOWTO (ALPHA_R_SREL64
, /* Type. */
5426 0, /* Rightshift. */
5427 4, /* Size (0 = byte, 1 = short, 2 = long). */
5429 TRUE
, /* PC relative. */
5431 complain_overflow_signed
, /* Complain_on_overflow. */
5432 reloc_nil
, /* Special_function. */
5433 "SREL64", /* Name. */
5434 TRUE
, /* Partial_inplace. */
5435 MINUS_ONE
, /* Source mask. */
5436 MINUS_ONE
, /* Dest mask. */
5437 FALSE
), /* PC rel offset. */
5439 /* Push a value on the reloc evaluation stack. */
5440 HOWTO (ALPHA_R_OP_PUSH
, /* Type. */
5441 0, /* Rightshift. */
5442 0, /* Size (0 = byte, 1 = short, 2 = long). */
5444 FALSE
, /* PC relative. */
5446 complain_overflow_dont
,/* Complain_on_overflow. */
5447 reloc_nil
, /* Special_function. */
5448 "OP_PUSH", /* Name. */
5449 FALSE
, /* Partial_inplace. */
5450 0, /* Source mask. */
5452 FALSE
), /* PC rel offset. */
5454 /* Store the value from the stack at the given address. Store it in
5455 a bitfield of size r_size starting at bit position r_offset. */
5456 HOWTO (ALPHA_R_OP_STORE
, /* Type. */
5457 0, /* Rightshift. */
5458 4, /* Size (0 = byte, 1 = short, 2 = long). */
5460 FALSE
, /* PC relative. */
5462 complain_overflow_dont
,/* Complain_on_overflow. */
5463 reloc_nil
, /* Special_function. */
5464 "OP_STORE", /* Name. */
5465 FALSE
, /* Partial_inplace. */
5466 0, /* Source mask. */
5467 MINUS_ONE
, /* Dest mask. */
5468 FALSE
), /* PC rel offset. */
5470 /* Subtract the reloc address from the value on the top of the
5471 relocation stack. */
5472 HOWTO (ALPHA_R_OP_PSUB
, /* Type. */
5473 0, /* Rightshift. */
5474 0, /* Size (0 = byte, 1 = short, 2 = long). */
5476 FALSE
, /* PC relative. */
5478 complain_overflow_dont
,/* Complain_on_overflow. */
5479 reloc_nil
, /* Special_function. */
5480 "OP_PSUB", /* Name. */
5481 FALSE
, /* Partial_inplace. */
5482 0, /* Source mask. */
5484 FALSE
), /* PC rel offset. */
5486 /* Shift the value on the top of the relocation stack right by the
5488 HOWTO (ALPHA_R_OP_PRSHIFT
, /* Type. */
5489 0, /* Rightshift. */
5490 0, /* Size (0 = byte, 1 = short, 2 = long). */
5492 FALSE
, /* PC relative. */
5494 complain_overflow_dont
,/* Complain_on_overflow. */
5495 reloc_nil
, /* Special_function. */
5496 "OP_PRSHIFT", /* Name. */
5497 FALSE
, /* Partial_inplace. */
5498 0, /* Source mask. */
5500 FALSE
), /* PC rel offset. */
5502 /* Hack. Linkage is done by linker. */
5503 HOWTO (ALPHA_R_LINKAGE
, /* Type. */
5504 0, /* Rightshift. */
5505 0, /* Size (0 = byte, 1 = short, 2 = long). */
5507 FALSE
, /* PC relative. */
5509 complain_overflow_dont
,/* Complain_on_overflow. */
5510 reloc_nil
, /* Special_function. */
5511 "LINKAGE", /* Name. */
5512 FALSE
, /* Partial_inplace. */
5513 0, /* Source mask. */
5515 FALSE
), /* PC rel offset. */
5517 /* A 32 bit reference to a symbol. */
5518 HOWTO (ALPHA_R_REFLONG
, /* Type. */
5519 0, /* Rightshift. */
5520 2, /* Size (0 = byte, 1 = short, 2 = long). */
5522 FALSE
, /* PC relative. */
5524 complain_overflow_bitfield
, /* Complain_on_overflow. */
5525 reloc_nil
, /* Special_function. */
5526 "REFLONG", /* Name. */
5527 TRUE
, /* Partial_inplace. */
5528 0xffffffff, /* Source mask. */
5529 0xffffffff, /* Dest mask. */
5530 FALSE
), /* PC rel offset. */
5532 /* A 64 bit reference to a procedure, written as 32 bit value. */
5533 HOWTO (ALPHA_R_CODEADDR
, /* Type. */
5534 0, /* Rightshift. */
5535 4, /* Size (0 = byte, 1 = short, 2 = long). */
5537 FALSE
, /* PC relative. */
5539 complain_overflow_signed
,/* Complain_on_overflow. */
5540 reloc_nil
, /* Special_function. */
5541 "CODEADDR", /* Name. */
5542 FALSE
, /* Partial_inplace. */
5543 0xffffffff, /* Source mask. */
5544 0xffffffff, /* Dest mask. */
5545 FALSE
), /* PC rel offset. */
5547 HOWTO (ALPHA_R_NOP
, /* Type. */
5548 0, /* Rightshift. */
5549 3, /* Size (0 = byte, 1 = short, 2 = long). */
5551 /* The following value must match that of ALPHA_R_BSR/ALPHA_R_BOH
5552 because the calculations for the 3 relocations are the same.
5553 See B.4.5.2 of the OpenVMS Linker Utility Manual. */
5554 TRUE
, /* PC relative. */
5556 complain_overflow_dont
,/* Complain_on_overflow. */
5557 reloc_nil
, /* Special_function. */
5559 FALSE
, /* Partial_inplace. */
5560 0xffffffff, /* Source mask. */
5561 0xffffffff, /* Dest mask. */
5562 FALSE
), /* PC rel offset. */
5564 HOWTO (ALPHA_R_BSR
, /* Type. */
5565 0, /* Rightshift. */
5566 3, /* Size (0 = byte, 1 = short, 2 = long). */
5568 TRUE
, /* PC relative. */
5570 complain_overflow_dont
,/* Complain_on_overflow. */
5571 reloc_nil
, /* Special_function. */
5573 FALSE
, /* Partial_inplace. */
5574 0xffffffff, /* Source mask. */
5575 0xffffffff, /* Dest mask. */
5576 FALSE
), /* PC rel offset. */
5578 HOWTO (ALPHA_R_LDA
, /* Type. */
5579 0, /* Rightshift. */
5580 3, /* Size (0 = byte, 1 = short, 2 = long). */
5582 FALSE
, /* PC relative. */
5584 complain_overflow_dont
,/* Complain_on_overflow. */
5585 reloc_nil
, /* Special_function. */
5587 FALSE
, /* Partial_inplace. */
5588 0xffffffff, /* Source mask. */
5589 0xffffffff, /* Dest mask. */
5590 FALSE
), /* PC rel offset. */
5592 HOWTO (ALPHA_R_BOH
, /* Type. */
5593 0, /* Rightshift. */
5594 3, /* Size (0 = byte, 1 = short, 2 = long, 3 = nil). */
5596 TRUE
, /* PC relative. */
5598 complain_overflow_dont
,/* Complain_on_overflow. */
5599 reloc_nil
, /* Special_function. */
5601 FALSE
, /* Partial_inplace. */
5602 0xffffffff, /* Source mask. */
5603 0xffffffff, /* Dest mask. */
5604 FALSE
), /* PC rel offset. */
5607 /* Return a pointer to a howto structure which, when invoked, will perform
5608 the relocation code on data from the architecture noted. */
5610 static reloc_howto_type
*
5611 alpha_vms_bfd_reloc_type_lookup (bfd
* abfd ATTRIBUTE_UNUSED
,
5612 bfd_reloc_code_real_type code
)
5616 vms_debug2 ((1, "vms_bfd_reloc_type_lookup (%p, %d)\t", abfd
, code
));
5620 case BFD_RELOC_16
: alpha_type
= ALPHA_R_SREL16
; break;
5621 case BFD_RELOC_32
: alpha_type
= ALPHA_R_REFLONG
; break;
5622 case BFD_RELOC_64
: alpha_type
= ALPHA_R_REFQUAD
; break;
5623 case BFD_RELOC_CTOR
: alpha_type
= ALPHA_R_REFQUAD
; break;
5624 case BFD_RELOC_23_PCREL_S2
: alpha_type
= ALPHA_R_BRADDR
; break;
5625 case BFD_RELOC_ALPHA_HINT
: alpha_type
= ALPHA_R_HINT
; break;
5626 case BFD_RELOC_16_PCREL
: alpha_type
= ALPHA_R_SREL16
; break;
5627 case BFD_RELOC_32_PCREL
: alpha_type
= ALPHA_R_SREL32
; break;
5628 case BFD_RELOC_64_PCREL
: alpha_type
= ALPHA_R_SREL64
; break;
5629 case BFD_RELOC_ALPHA_LINKAGE
: alpha_type
= ALPHA_R_LINKAGE
; break;
5630 case BFD_RELOC_ALPHA_CODEADDR
: alpha_type
= ALPHA_R_CODEADDR
; break;
5631 case BFD_RELOC_ALPHA_NOP
: alpha_type
= ALPHA_R_NOP
; break;
5632 case BFD_RELOC_ALPHA_BSR
: alpha_type
= ALPHA_R_BSR
; break;
5633 case BFD_RELOC_ALPHA_LDA
: alpha_type
= ALPHA_R_LDA
; break;
5634 case BFD_RELOC_ALPHA_BOH
: alpha_type
= ALPHA_R_BOH
; break;
5636 _bfd_error_handler (_("reloc (%d) is *UNKNOWN*"), code
);
5639 vms_debug2 ((2, "reloc is %s\n", alpha_howto_table
[alpha_type
].name
));
5640 return & alpha_howto_table
[alpha_type
];
5643 static reloc_howto_type
*
5644 alpha_vms_bfd_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
5650 i
< sizeof (alpha_howto_table
) / sizeof (alpha_howto_table
[0]);
5652 if (alpha_howto_table
[i
].name
!= NULL
5653 && strcasecmp (alpha_howto_table
[i
].name
, r_name
) == 0)
5654 return &alpha_howto_table
[i
];
5660 alpha_vms_get_synthetic_symtab (bfd
*abfd
,
5661 long symcount ATTRIBUTE_UNUSED
,
5662 asymbol
**usyms ATTRIBUTE_UNUSED
,
5663 long dynsymcount ATTRIBUTE_UNUSED
,
5664 asymbol
**dynsyms ATTRIBUTE_UNUSED
,
5671 syms
= (asymbol
*) bfd_malloc (PRIV (norm_sym_count
) * sizeof (asymbol
));
5676 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
5678 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
5689 flags
= BSF_LOCAL
| BSF_SYNTHETIC
;
5696 if ((e
->flags
& EGSY__V_DEF
) && (e
->flags
& EGSY__V_NORM
))
5698 value
= e
->code_value
;
5699 sec
= e
->code_section
;
5710 sname
= bfd_alloc (abfd
, l
+ 5);
5713 memcpy (sname
, name
, l
);
5714 memcpy (sname
+ l
, "..en", 5);
5721 sym
->udata
.p
= NULL
;
5730 vms_time_to_str (unsigned char *buf
)
5732 time_t t
= vms_rawtime_to_time_t (buf
);
5733 char *res
= ctime (&t
);
5736 res
= "*invalid time*";
5743 evax_bfd_print_emh (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5745 struct vms_emh_common
*emh
= (struct vms_emh_common
*)rec
;
5746 unsigned int subtype
;
5749 subtype
= (unsigned) bfd_getl16 (emh
->subtyp
);
5751 /* xgettext:c-format */
5752 fprintf (file
, _(" EMH %u (len=%u): "), subtype
, rec_len
);
5754 /* PR 21618: Check for invalid lengths. */
5755 if (rec_len
< sizeof (* emh
))
5757 fprintf (file
, _(" Error: The length is less than the length of an EMH record\n"));
5760 extra
= rec_len
- sizeof (struct vms_emh_common
);
5766 struct vms_emh_mhd
*mhd
= (struct vms_emh_mhd
*) rec
;
5768 const char * nextname
;
5769 const char * maxname
;
5771 /* PR 21840: Check for invalid lengths. */
5772 if (rec_len
< sizeof (* mhd
))
5774 fprintf (file
, _(" Error: The record length is less than the size of an EMH_MHD record\n"));
5777 fprintf (file
, _("Module header\n"));
5778 fprintf (file
, _(" structure level: %u\n"), mhd
->strlvl
);
5779 fprintf (file
, _(" max record size: %u\n"),
5780 (unsigned) bfd_getl32 (mhd
->recsiz
));
5781 name
= (char *)(mhd
+ 1);
5782 maxname
= (char *) rec
+ rec_len
;
5783 if (name
> maxname
- 2)
5785 fprintf (file
, _(" Error: The module name is missing\n"));
5788 nextname
= name
+ name
[0] + 1;
5789 if (nextname
>= maxname
)
5791 fprintf (file
, _(" Error: The module name is too long\n"));
5794 fprintf (file
, _(" module name : %.*s\n"), name
[0], name
+ 1);
5796 if (name
> maxname
- 2)
5798 fprintf (file
, _(" Error: The module version is missing\n"));
5801 nextname
= name
+ name
[0] + 1;
5802 if (nextname
>= maxname
)
5804 fprintf (file
, _(" Error: The module version is too long\n"));
5807 fprintf (file
, _(" module version : %.*s\n"), name
[0], name
+ 1);
5809 if ((maxname
- name
) < 17 && maxname
[-1] != 0)
5810 fprintf (file
, _(" Error: The compile date is truncated\n"));
5812 fprintf (file
, _(" compile date : %.17s\n"), name
);
5817 fprintf (file
, _("Language Processor Name\n"));
5818 fprintf (file
, _(" language name: %.*s\n"), extra
, (char *)(emh
+ 1));
5822 fprintf (file
, _("Source Files Header\n"));
5823 fprintf (file
, _(" file: %.*s\n"), extra
, (char *)(emh
+ 1));
5827 fprintf (file
, _("Title Text Header\n"));
5828 fprintf (file
, _(" title: %.*s\n"), extra
, (char *)(emh
+ 1));
5832 fprintf (file
, _("Copyright Header\n"));
5833 fprintf (file
, _(" copyright: %.*s\n"), extra
, (char *)(emh
+ 1));
5837 fprintf (file
, _("unhandled emh subtype %u\n"), subtype
);
5843 evax_bfd_print_eeom (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5845 struct vms_eeom
*eeom
= (struct vms_eeom
*)rec
;
5847 fprintf (file
, _(" EEOM (len=%u):\n"), rec_len
);
5849 /* PR 21618: Check for invalid lengths. */
5850 if (rec_len
< sizeof (* eeom
))
5852 fprintf (file
, _(" Error: The length is less than the length of an EEOM record\n"));
5856 fprintf (file
, _(" number of cond linkage pairs: %u\n"),
5857 (unsigned)bfd_getl32 (eeom
->total_lps
));
5858 fprintf (file
, _(" completion code: %u\n"),
5859 (unsigned)bfd_getl16 (eeom
->comcod
));
5862 fprintf (file
, _(" transfer addr flags: 0x%02x\n"), eeom
->tfrflg
);
5863 fprintf (file
, _(" transfer addr psect: %u\n"),
5864 (unsigned)bfd_getl32 (eeom
->psindx
));
5865 fprintf (file
, _(" transfer address : 0x%08x\n"),
5866 (unsigned)bfd_getl32 (eeom
->tfradr
));
5871 exav_bfd_print_egsy_flags (unsigned int flags
, FILE *file
)
5873 if (flags
& EGSY__V_WEAK
)
5874 fputs (_(" WEAK"), file
);
5875 if (flags
& EGSY__V_DEF
)
5876 fputs (_(" DEF"), file
);
5877 if (flags
& EGSY__V_UNI
)
5878 fputs (_(" UNI"), file
);
5879 if (flags
& EGSY__V_REL
)
5880 fputs (_(" REL"), file
);
5881 if (flags
& EGSY__V_COMM
)
5882 fputs (_(" COMM"), file
);
5883 if (flags
& EGSY__V_VECEP
)
5884 fputs (_(" VECEP"), file
);
5885 if (flags
& EGSY__V_NORM
)
5886 fputs (_(" NORM"), file
);
5887 if (flags
& EGSY__V_QUAD_VAL
)
5888 fputs (_(" QVAL"), file
);
5892 evax_bfd_print_egsd_flags (FILE *file
, unsigned int flags
)
5894 if (flags
& EGPS__V_PIC
)
5895 fputs (_(" PIC"), file
);
5896 if (flags
& EGPS__V_LIB
)
5897 fputs (_(" LIB"), file
);
5898 if (flags
& EGPS__V_OVR
)
5899 fputs (_(" OVR"), file
);
5900 if (flags
& EGPS__V_REL
)
5901 fputs (_(" REL"), file
);
5902 if (flags
& EGPS__V_GBL
)
5903 fputs (_(" GBL"), file
);
5904 if (flags
& EGPS__V_SHR
)
5905 fputs (_(" SHR"), file
);
5906 if (flags
& EGPS__V_EXE
)
5907 fputs (_(" EXE"), file
);
5908 if (flags
& EGPS__V_RD
)
5909 fputs (_(" RD"), file
);
5910 if (flags
& EGPS__V_WRT
)
5911 fputs (_(" WRT"), file
);
5912 if (flags
& EGPS__V_VEC
)
5913 fputs (_(" VEC"), file
);
5914 if (flags
& EGPS__V_NOMOD
)
5915 fputs (_(" NOMOD"), file
);
5916 if (flags
& EGPS__V_COM
)
5917 fputs (_(" COM"), file
);
5918 if (flags
& EGPS__V_ALLOC_64BIT
)
5919 fputs (_(" 64B"), file
);
5923 evax_bfd_print_egsd (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5925 unsigned int off
= sizeof (struct vms_egsd
);
5928 fprintf (file
, _(" EGSD (len=%u):\n"), rec_len
);
5931 for (off
= sizeof (struct vms_egsd
); off
< rec_len
; )
5933 struct vms_egsd_entry
*e
= (struct vms_egsd_entry
*)(rec
+ off
);
5937 type
= (unsigned)bfd_getl16 (e
->gsdtyp
);
5938 len
= (unsigned)bfd_getl16 (e
->gsdsiz
);
5940 /* xgettext:c-format */
5941 fprintf (file
, _(" EGSD entry %2u (type: %u, len: %u): "),
5945 if (off
+ len
> rec_len
|| off
+ len
< off
)
5947 fprintf (file
, _(" Error: length larger than remaining space in record\n"));
5955 struct vms_egps
*egps
= (struct vms_egps
*)e
;
5956 unsigned int flags
= bfd_getl16 (egps
->flags
);
5959 fprintf (file
, _("PSC - Program section definition\n"));
5960 fprintf (file
, _(" alignment : 2**%u\n"), egps
->align
);
5961 fprintf (file
, _(" flags : 0x%04x"), flags
);
5962 evax_bfd_print_egsd_flags (file
, flags
);
5964 l
= bfd_getl32 (egps
->alloc
);
5965 fprintf (file
, _(" alloc (len): %u (0x%08x)\n"), l
, l
);
5966 fprintf (file
, _(" name : %.*s\n"),
5967 egps
->namlng
, egps
->name
);
5972 struct vms_esgps
*esgps
= (struct vms_esgps
*)e
;
5973 unsigned int flags
= bfd_getl16 (esgps
->flags
);
5976 fprintf (file
, _("SPSC - Shared Image Program section def\n"));
5977 fprintf (file
, _(" alignment : 2**%u\n"), esgps
->align
);
5978 fprintf (file
, _(" flags : 0x%04x"), flags
);
5979 evax_bfd_print_egsd_flags (file
, flags
);
5981 l
= bfd_getl32 (esgps
->alloc
);
5982 fprintf (file
, _(" alloc (len) : %u (0x%08x)\n"), l
, l
);
5983 fprintf (file
, _(" image offset : 0x%08x\n"),
5984 (unsigned int)bfd_getl32 (esgps
->base
));
5985 fprintf (file
, _(" symvec offset : 0x%08x\n"),
5986 (unsigned int)bfd_getl32 (esgps
->value
));
5987 fprintf (file
, _(" name : %.*s\n"),
5988 esgps
->namlng
, esgps
->name
);
5993 struct vms_egsy
*egsy
= (struct vms_egsy
*)e
;
5994 unsigned int flags
= bfd_getl16 (egsy
->flags
);
5996 if (flags
& EGSY__V_DEF
)
5998 struct vms_esdf
*esdf
= (struct vms_esdf
*)e
;
6000 fprintf (file
, _("SYM - Global symbol definition\n"));
6001 fprintf (file
, _(" flags: 0x%04x"), flags
);
6002 exav_bfd_print_egsy_flags (flags
, file
);
6004 fprintf (file
, _(" psect offset: 0x%08x\n"),
6005 (unsigned)bfd_getl32 (esdf
->value
));
6006 if (flags
& EGSY__V_NORM
)
6008 fprintf (file
, _(" code address: 0x%08x\n"),
6009 (unsigned)bfd_getl32 (esdf
->code_address
));
6010 fprintf (file
, _(" psect index for entry point : %u\n"),
6011 (unsigned)bfd_getl32 (esdf
->ca_psindx
));
6013 fprintf (file
, _(" psect index : %u\n"),
6014 (unsigned)bfd_getl32 (esdf
->psindx
));
6015 fprintf (file
, _(" name : %.*s\n"),
6016 esdf
->namlng
, esdf
->name
);
6020 struct vms_esrf
*esrf
= (struct vms_esrf
*)e
;
6022 fprintf (file
, _("SYM - Global symbol reference\n"));
6023 fprintf (file
, _(" name : %.*s\n"),
6024 esrf
->namlng
, esrf
->name
);
6030 struct vms_eidc
*eidc
= (struct vms_eidc
*)e
;
6031 unsigned int flags
= bfd_getl32 (eidc
->flags
);
6034 fprintf (file
, _("IDC - Ident Consistency check\n"));
6035 fprintf (file
, _(" flags : 0x%08x"), flags
);
6036 if (flags
& EIDC__V_BINIDENT
)
6037 fputs (" BINDENT", file
);
6039 fprintf (file
, _(" id match : %x\n"),
6040 (flags
>> EIDC__V_IDMATCH_SH
) & EIDC__V_IDMATCH_MASK
);
6041 fprintf (file
, _(" error severity: %x\n"),
6042 (flags
>> EIDC__V_ERRSEV_SH
) & EIDC__V_ERRSEV_MASK
);
6044 fprintf (file
, _(" entity name : %.*s\n"), p
[0], p
+ 1);
6046 fprintf (file
, _(" object name : %.*s\n"), p
[0], p
+ 1);
6048 if (flags
& EIDC__V_BINIDENT
)
6049 fprintf (file
, _(" binary ident : 0x%08x\n"),
6050 (unsigned)bfd_getl32 (p
+ 1));
6052 fprintf (file
, _(" ascii ident : %.*s\n"), p
[0], p
+ 1);
6057 struct vms_egst
*egst
= (struct vms_egst
*)e
;
6058 unsigned int flags
= bfd_getl16 (egst
->header
.flags
);
6060 fprintf (file
, _("SYMG - Universal symbol definition\n"));
6061 fprintf (file
, _(" flags: 0x%04x"), flags
);
6062 exav_bfd_print_egsy_flags (flags
, file
);
6064 fprintf (file
, _(" symbol vector offset: 0x%08x\n"),
6065 (unsigned)bfd_getl32 (egst
->value
));
6066 fprintf (file
, _(" entry point: 0x%08x\n"),
6067 (unsigned)bfd_getl32 (egst
->lp_1
));
6068 fprintf (file
, _(" proc descr : 0x%08x\n"),
6069 (unsigned)bfd_getl32 (egst
->lp_2
));
6070 fprintf (file
, _(" psect index: %u\n"),
6071 (unsigned)bfd_getl32 (egst
->psindx
));
6072 fprintf (file
, _(" name : %.*s\n"),
6073 egst
->namlng
, egst
->name
);
6078 struct vms_esdfv
*esdfv
= (struct vms_esdfv
*)e
;
6079 unsigned int flags
= bfd_getl16 (esdfv
->flags
);
6081 fprintf (file
, _("SYMV - Vectored symbol definition\n"));
6082 fprintf (file
, _(" flags: 0x%04x"), flags
);
6083 exav_bfd_print_egsy_flags (flags
, file
);
6085 fprintf (file
, _(" vector : 0x%08x\n"),
6086 (unsigned)bfd_getl32 (esdfv
->vector
));
6087 fprintf (file
, _(" psect offset: %u\n"),
6088 (unsigned)bfd_getl32 (esdfv
->value
));
6089 fprintf (file
, _(" psect index : %u\n"),
6090 (unsigned)bfd_getl32 (esdfv
->psindx
));
6091 fprintf (file
, _(" name : %.*s\n"),
6092 esdfv
->namlng
, esdfv
->name
);
6097 struct vms_esdfm
*esdfm
= (struct vms_esdfm
*)e
;
6098 unsigned int flags
= bfd_getl16 (esdfm
->flags
);
6100 fprintf (file
, _("SYMM - Global symbol definition with version\n"));
6101 fprintf (file
, _(" flags: 0x%04x"), flags
);
6102 exav_bfd_print_egsy_flags (flags
, file
);
6104 fprintf (file
, _(" version mask: 0x%08x\n"),
6105 (unsigned)bfd_getl32 (esdfm
->version_mask
));
6106 fprintf (file
, _(" psect offset: %u\n"),
6107 (unsigned)bfd_getl32 (esdfm
->value
));
6108 fprintf (file
, _(" psect index : %u\n"),
6109 (unsigned)bfd_getl32 (esdfm
->psindx
));
6110 fprintf (file
, _(" name : %.*s\n"),
6111 esdfm
->namlng
, esdfm
->name
);
6115 fprintf (file
, _("unhandled egsd entry type %u\n"), type
);
6123 evax_bfd_print_hex (FILE *file
, const char *pfx
,
6124 const unsigned char *buf
, unsigned int len
)
6130 for (i
= 0; i
< len
; i
++)
6134 fprintf (file
, " %02x", buf
[i
]);
6147 evax_bfd_print_etir_stc_ir (FILE *file
, const unsigned char *buf
, int is_ps
)
6149 /* xgettext:c-format */
6150 fprintf (file
, _(" linkage index: %u, replacement insn: 0x%08x\n"),
6151 (unsigned)bfd_getl32 (buf
),
6152 (unsigned)bfd_getl32 (buf
+ 16));
6153 /* xgettext:c-format */
6154 fprintf (file
, _(" psect idx 1: %u, offset 1: 0x%08x %08x\n"),
6155 (unsigned)bfd_getl32 (buf
+ 4),
6156 (unsigned)bfd_getl32 (buf
+ 12),
6157 (unsigned)bfd_getl32 (buf
+ 8));
6158 /* xgettext:c-format */
6159 fprintf (file
, _(" psect idx 2: %u, offset 2: 0x%08x %08x\n"),
6160 (unsigned)bfd_getl32 (buf
+ 20),
6161 (unsigned)bfd_getl32 (buf
+ 28),
6162 (unsigned)bfd_getl32 (buf
+ 24));
6164 /* xgettext:c-format */
6165 fprintf (file
, _(" psect idx 3: %u, offset 3: 0x%08x %08x\n"),
6166 (unsigned)bfd_getl32 (buf
+ 32),
6167 (unsigned)bfd_getl32 (buf
+ 40),
6168 (unsigned)bfd_getl32 (buf
+ 36));
6170 fprintf (file
, _(" global name: %.*s\n"), buf
[32], buf
+ 33);
6174 evax_bfd_print_etir (FILE *file
, const char *name
,
6175 unsigned char *rec
, unsigned int rec_len
)
6177 unsigned int off
= sizeof (struct vms_egsd
);
6178 unsigned int sec_len
= 0;
6180 /* xgettext:c-format */
6181 fprintf (file
, _(" %s (len=%u+%u):\n"), name
,
6182 (unsigned)(rec_len
- sizeof (struct vms_eobjrec
)),
6183 (unsigned)sizeof (struct vms_eobjrec
));
6185 for (off
= sizeof (struct vms_eobjrec
); off
< rec_len
; )
6187 struct vms_etir
*etir
= (struct vms_etir
*)(rec
+ off
);
6192 type
= bfd_getl16 (etir
->rectyp
);
6193 size
= bfd_getl16 (etir
->size
);
6194 buf
= rec
+ off
+ sizeof (struct vms_etir
);
6196 if (off
+ size
> rec_len
|| off
+ size
< off
)
6198 fprintf (file
, _(" Error: length larger than remaining space in record\n"));
6202 /* xgettext:c-format */
6203 fprintf (file
, _(" (type: %3u, size: 4+%3u): "), type
, size
- 4);
6206 case ETIR__C_STA_GBL
:
6207 fprintf (file
, _("STA_GBL (stack global) %.*s\n"),
6210 case ETIR__C_STA_LW
:
6211 fprintf (file
, _("STA_LW (stack longword) 0x%08x\n"),
6212 (unsigned)bfd_getl32 (buf
));
6214 case ETIR__C_STA_QW
:
6215 fprintf (file
, _("STA_QW (stack quadword) 0x%08x %08x\n"),
6216 (unsigned)bfd_getl32 (buf
+ 4),
6217 (unsigned)bfd_getl32 (buf
+ 0));
6219 case ETIR__C_STA_PQ
:
6220 fprintf (file
, _("STA_PQ (stack psect base + offset)\n"));
6221 /* xgettext:c-format */
6222 fprintf (file
, _(" psect: %u, offset: 0x%08x %08x\n"),
6223 (unsigned)bfd_getl32 (buf
+ 0),
6224 (unsigned)bfd_getl32 (buf
+ 8),
6225 (unsigned)bfd_getl32 (buf
+ 4));
6227 case ETIR__C_STA_LI
:
6228 fprintf (file
, _("STA_LI (stack literal)\n"));
6230 case ETIR__C_STA_MOD
:
6231 fprintf (file
, _("STA_MOD (stack module)\n"));
6233 case ETIR__C_STA_CKARG
:
6234 fprintf (file
, _("STA_CKARG (compare procedure argument)\n"));
6238 fprintf (file
, _("STO_B (store byte)\n"));
6241 fprintf (file
, _("STO_W (store word)\n"));
6243 case ETIR__C_STO_LW
:
6244 fprintf (file
, _("STO_LW (store longword)\n"));
6246 case ETIR__C_STO_QW
:
6247 fprintf (file
, _("STO_QW (store quadword)\n"));
6249 case ETIR__C_STO_IMMR
:
6251 unsigned int len
= bfd_getl32 (buf
);
6253 _("STO_IMMR (store immediate repeat) %u bytes\n"),
6255 evax_bfd_print_hex (file
, " ", buf
+ 4, len
);
6259 case ETIR__C_STO_GBL
:
6260 fprintf (file
, _("STO_GBL (store global) %.*s\n"),
6263 case ETIR__C_STO_CA
:
6264 fprintf (file
, _("STO_CA (store code address) %.*s\n"),
6267 case ETIR__C_STO_RB
:
6268 fprintf (file
, _("STO_RB (store relative branch)\n"));
6270 case ETIR__C_STO_AB
:
6271 fprintf (file
, _("STO_AB (store absolute branch)\n"));
6273 case ETIR__C_STO_OFF
:
6274 fprintf (file
, _("STO_OFF (store offset to psect)\n"));
6276 case ETIR__C_STO_IMM
:
6278 unsigned int len
= bfd_getl32 (buf
);
6280 _("STO_IMM (store immediate) %u bytes\n"),
6282 evax_bfd_print_hex (file
, " ", buf
+ 4, len
);
6286 case ETIR__C_STO_GBL_LW
:
6287 fprintf (file
, _("STO_GBL_LW (store global longword) %.*s\n"),
6290 case ETIR__C_STO_LP_PSB
:
6291 fprintf (file
, _("STO_OFF (store LP with procedure signature)\n"));
6293 case ETIR__C_STO_HINT_GBL
:
6294 fprintf (file
, _("STO_BR_GBL (store branch global) *todo*\n"));
6296 case ETIR__C_STO_HINT_PS
:
6297 fprintf (file
, _("STO_BR_PS (store branch psect + offset) *todo*\n"));
6300 case ETIR__C_OPR_NOP
:
6301 fprintf (file
, _("OPR_NOP (no-operation)\n"));
6303 case ETIR__C_OPR_ADD
:
6304 fprintf (file
, _("OPR_ADD (add)\n"));
6306 case ETIR__C_OPR_SUB
:
6307 fprintf (file
, _("OPR_SUB (subtract)\n"));
6309 case ETIR__C_OPR_MUL
:
6310 fprintf (file
, _("OPR_MUL (multiply)\n"));
6312 case ETIR__C_OPR_DIV
:
6313 fprintf (file
, _("OPR_DIV (divide)\n"));
6315 case ETIR__C_OPR_AND
:
6316 fprintf (file
, _("OPR_AND (logical and)\n"));
6318 case ETIR__C_OPR_IOR
:
6319 fprintf (file
, _("OPR_IOR (logical inclusive or)\n"));
6321 case ETIR__C_OPR_EOR
:
6322 fprintf (file
, _("OPR_EOR (logical exclusive or)\n"));
6324 case ETIR__C_OPR_NEG
:
6325 fprintf (file
, _("OPR_NEG (negate)\n"));
6327 case ETIR__C_OPR_COM
:
6328 fprintf (file
, _("OPR_COM (complement)\n"));
6330 case ETIR__C_OPR_INSV
:
6331 fprintf (file
, _("OPR_INSV (insert field)\n"));
6333 case ETIR__C_OPR_ASH
:
6334 fprintf (file
, _("OPR_ASH (arithmetic shift)\n"));
6336 case ETIR__C_OPR_USH
:
6337 fprintf (file
, _("OPR_USH (unsigned shift)\n"));
6339 case ETIR__C_OPR_ROT
:
6340 fprintf (file
, _("OPR_ROT (rotate)\n"));
6342 case ETIR__C_OPR_SEL
:
6343 fprintf (file
, _("OPR_SEL (select)\n"));
6345 case ETIR__C_OPR_REDEF
:
6346 fprintf (file
, _("OPR_REDEF (redefine symbol to curr location)\n"));
6348 case ETIR__C_OPR_DFLIT
:
6349 fprintf (file
, _("OPR_REDEF (define a literal)\n"));
6352 case ETIR__C_STC_LP
:
6353 fprintf (file
, _("STC_LP (store cond linkage pair)\n"));
6355 case ETIR__C_STC_LP_PSB
:
6357 _("STC_LP_PSB (store cond linkage pair + signature)\n"));
6358 /* xgettext:c-format */
6359 fprintf (file
, _(" linkage index: %u, procedure: %.*s\n"),
6360 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6361 buf
+= 4 + 1 + buf
[4];
6362 fprintf (file
, _(" signature: %.*s\n"), buf
[0], buf
+ 1);
6364 case ETIR__C_STC_GBL
:
6365 fprintf (file
, _("STC_GBL (store cond global)\n"));
6366 /* xgettext:c-format */
6367 fprintf (file
, _(" linkage index: %u, global: %.*s\n"),
6368 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6370 case ETIR__C_STC_GCA
:
6371 fprintf (file
, _("STC_GCA (store cond code address)\n"));
6372 /* xgettext:c-format */
6373 fprintf (file
, _(" linkage index: %u, procedure name: %.*s\n"),
6374 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6376 case ETIR__C_STC_PS
:
6377 fprintf (file
, _("STC_PS (store cond psect + offset)\n"));
6379 /* xgettext:c-format */
6380 _(" linkage index: %u, psect: %u, offset: 0x%08x %08x\n"),
6381 (unsigned)bfd_getl32 (buf
),
6382 (unsigned)bfd_getl32 (buf
+ 4),
6383 (unsigned)bfd_getl32 (buf
+ 12),
6384 (unsigned)bfd_getl32 (buf
+ 8));
6386 case ETIR__C_STC_NOP_GBL
:
6387 fprintf (file
, _("STC_NOP_GBL (store cond NOP at global addr)\n"));
6388 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6390 case ETIR__C_STC_NOP_PS
:
6391 fprintf (file
, _("STC_NOP_PS (store cond NOP at psect + offset)\n"));
6392 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6394 case ETIR__C_STC_BSR_GBL
:
6395 fprintf (file
, _("STC_BSR_GBL (store cond BSR at global addr)\n"));
6396 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6398 case ETIR__C_STC_BSR_PS
:
6399 fprintf (file
, _("STC_BSR_PS (store cond BSR at psect + offset)\n"));
6400 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6402 case ETIR__C_STC_LDA_GBL
:
6403 fprintf (file
, _("STC_LDA_GBL (store cond LDA at global addr)\n"));
6404 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6406 case ETIR__C_STC_LDA_PS
:
6407 fprintf (file
, _("STC_LDA_PS (store cond LDA at psect + offset)\n"));
6408 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6410 case ETIR__C_STC_BOH_GBL
:
6411 fprintf (file
, _("STC_BOH_GBL (store cond BOH at global addr)\n"));
6412 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6414 case ETIR__C_STC_BOH_PS
:
6415 fprintf (file
, _("STC_BOH_PS (store cond BOH at psect + offset)\n"));
6416 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6418 case ETIR__C_STC_NBH_GBL
:
6420 _("STC_NBH_GBL (store cond or hint at global addr)\n"));
6422 case ETIR__C_STC_NBH_PS
:
6424 _("STC_NBH_PS (store cond or hint at psect + offset)\n"));
6427 case ETIR__C_CTL_SETRB
:
6428 fprintf (file
, _("CTL_SETRB (set relocation base)\n"));
6431 case ETIR__C_CTL_AUGRB
:
6433 unsigned int val
= bfd_getl32 (buf
);
6434 fprintf (file
, _("CTL_AUGRB (augment relocation base) %u\n"), val
);
6437 case ETIR__C_CTL_DFLOC
:
6438 fprintf (file
, _("CTL_DFLOC (define location)\n"));
6440 case ETIR__C_CTL_STLOC
:
6441 fprintf (file
, _("CTL_STLOC (set location)\n"));
6443 case ETIR__C_CTL_STKDL
:
6444 fprintf (file
, _("CTL_STKDL (stack defined location)\n"));
6447 fprintf (file
, _("*unhandled*\n"));
6455 evax_bfd_print_eobj (struct bfd
*abfd
, FILE *file
)
6457 bfd_boolean is_first
= TRUE
;
6458 bfd_boolean has_records
= FALSE
;
6462 unsigned int rec_len
;
6463 unsigned int pad_len
;
6465 unsigned int hdr_size
;
6470 unsigned char buf
[6];
6475 if (bfd_bread (buf
, sizeof (buf
), abfd
) != sizeof (buf
))
6477 fprintf (file
, _("cannot read GST record length\n"));
6480 rec_len
= bfd_getl16 (buf
+ 0);
6481 if (rec_len
== bfd_getl16 (buf
+ 4)
6482 && bfd_getl16 (buf
+ 2) == EOBJ__C_EMH
)
6484 /* The format is raw: record-size, type, record-size. */
6486 pad_len
= (rec_len
+ 1) & ~1U;
6489 else if (rec_len
== EOBJ__C_EMH
)
6491 has_records
= FALSE
;
6492 pad_len
= bfd_getl16 (buf
+ 2);
6498 fprintf (file
, _("cannot find EMH in first GST record\n"));
6501 rec
= bfd_malloc (pad_len
);
6502 memcpy (rec
, buf
+ sizeof (buf
) - hdr_size
, hdr_size
);
6506 unsigned int rec_len2
= 0;
6507 unsigned char hdr
[4];
6511 unsigned char buf_len
[2];
6513 if (bfd_bread (buf_len
, sizeof (buf_len
), abfd
)
6514 != sizeof (buf_len
))
6516 fprintf (file
, _("cannot read GST record length\n"));
6519 rec_len2
= (unsigned)bfd_getl16 (buf_len
);
6522 if (bfd_bread (hdr
, sizeof (hdr
), abfd
) != sizeof (hdr
))
6524 fprintf (file
, _("cannot read GST record header\n"));
6527 rec_len
= (unsigned)bfd_getl16 (hdr
+ 2);
6529 pad_len
= (rec_len
+ 1) & ~1U;
6532 rec
= bfd_malloc (pad_len
);
6533 memcpy (rec
, hdr
, sizeof (hdr
));
6534 hdr_size
= sizeof (hdr
);
6535 if (has_records
&& rec_len2
!= rec_len
)
6537 fprintf (file
, _(" corrupted GST\n"));
6542 if (bfd_bread (rec
+ hdr_size
, pad_len
- hdr_size
, abfd
)
6543 != pad_len
- hdr_size
)
6545 fprintf (file
, _("cannot read GST record\n"));
6549 type
= (unsigned)bfd_getl16 (rec
);
6554 evax_bfd_print_emh (file
, rec
, rec_len
);
6557 evax_bfd_print_egsd (file
, rec
, rec_len
);
6560 evax_bfd_print_eeom (file
, rec
, rec_len
);
6565 evax_bfd_print_etir (file
, "ETIR", rec
, rec_len
);
6568 evax_bfd_print_etir (file
, "EDBG", rec
, rec_len
);
6571 evax_bfd_print_etir (file
, "ETBT", rec
, rec_len
);
6574 fprintf (file
, _(" unhandled EOBJ record type %u\n"), type
);
6582 evax_bfd_print_relocation_records (FILE *file
, const unsigned char *rel
,
6583 unsigned int stride
)
6591 count
= bfd_getl32 (rel
+ 0);
6595 base
= bfd_getl32 (rel
+ 4);
6597 /* xgettext:c-format */
6598 fprintf (file
, _(" bitcount: %u, base addr: 0x%08x\n"),
6602 for (j
= 0; count
> 0; j
+= 4, count
-= 32)
6608 val
= bfd_getl32 (rel
);
6611 /* xgettext:c-format */
6612 fprintf (file
, _(" bitmap: 0x%08x (count: %u):\n"), val
, count
);
6614 for (k
= 0; k
< 32; k
++)
6619 fprintf (file
, _(" %08x"), base
+ (j
* 8 + k
) * stride
);
6634 evax_bfd_print_address_fixups (FILE *file
, const unsigned char *rel
)
6641 count
= bfd_getl32 (rel
+ 0);
6644 /* xgettext:c-format */
6645 fprintf (file
, _(" image %u (%u entries)\n"),
6646 (unsigned)bfd_getl32 (rel
+ 4), count
);
6648 for (j
= 0; j
< count
; j
++)
6650 /* xgettext:c-format */
6651 fprintf (file
, _(" offset: 0x%08x, val: 0x%08x\n"),
6652 (unsigned)bfd_getl32 (rel
+ 0),
6653 (unsigned)bfd_getl32 (rel
+ 4));
6660 evax_bfd_print_reference_fixups (FILE *file
, const unsigned char *rel
)
6669 count
= bfd_getl32 (rel
+ 0);
6672 /* xgettext:c-format */
6673 fprintf (file
, _(" image %u (%u entries), offsets:\n"),
6674 (unsigned)bfd_getl32 (rel
+ 4), count
);
6676 for (j
= 0; j
< count
; j
++)
6680 fprintf (file
, _(" 0x%08x"), (unsigned)bfd_getl32 (rel
));
6695 evax_bfd_print_indent (int indent
, FILE *file
)
6697 for (; indent
; indent
--)
6702 evax_bfd_get_dsc_name (unsigned int v
)
6706 case DSC__K_DTYPE_Z
:
6707 return "Z (Unspecified)";
6708 case DSC__K_DTYPE_V
:
6710 case DSC__K_DTYPE_BU
:
6711 return "BU (Byte logical)";
6712 case DSC__K_DTYPE_WU
:
6713 return "WU (Word logical)";
6714 case DSC__K_DTYPE_LU
:
6715 return "LU (Longword logical)";
6716 case DSC__K_DTYPE_QU
:
6717 return "QU (Quadword logical)";
6718 case DSC__K_DTYPE_B
:
6719 return "B (Byte integer)";
6720 case DSC__K_DTYPE_W
:
6721 return "W (Word integer)";
6722 case DSC__K_DTYPE_L
:
6723 return "L (Longword integer)";
6724 case DSC__K_DTYPE_Q
:
6725 return "Q (Quadword integer)";
6726 case DSC__K_DTYPE_F
:
6727 return "F (Single-precision floating)";
6728 case DSC__K_DTYPE_D
:
6729 return "D (Double-precision floating)";
6730 case DSC__K_DTYPE_FC
:
6731 return "FC (Complex)";
6732 case DSC__K_DTYPE_DC
:
6733 return "DC (Double-precision Complex)";
6734 case DSC__K_DTYPE_T
:
6735 return "T (ASCII text string)";
6736 case DSC__K_DTYPE_NU
:
6737 return "NU (Numeric string, unsigned)";
6738 case DSC__K_DTYPE_NL
:
6739 return "NL (Numeric string, left separate sign)";
6740 case DSC__K_DTYPE_NLO
:
6741 return "NLO (Numeric string, left overpunched sign)";
6742 case DSC__K_DTYPE_NR
:
6743 return "NR (Numeric string, right separate sign)";
6744 case DSC__K_DTYPE_NRO
:
6745 return "NRO (Numeric string, right overpunched sig)";
6746 case DSC__K_DTYPE_NZ
:
6747 return "NZ (Numeric string, zoned sign)";
6748 case DSC__K_DTYPE_P
:
6749 return "P (Packed decimal string)";
6750 case DSC__K_DTYPE_ZI
:
6751 return "ZI (Sequence of instructions)";
6752 case DSC__K_DTYPE_ZEM
:
6753 return "ZEM (Procedure entry mask)";
6754 case DSC__K_DTYPE_DSC
:
6755 return "DSC (Descriptor, used for arrays of dyn strings)";
6756 case DSC__K_DTYPE_OU
:
6757 return "OU (Octaword logical)";
6758 case DSC__K_DTYPE_O
:
6759 return "O (Octaword integer)";
6760 case DSC__K_DTYPE_G
:
6761 return "G (Double precision G floating, 64 bit)";
6762 case DSC__K_DTYPE_H
:
6763 return "H (Quadruple precision floating, 128 bit)";
6764 case DSC__K_DTYPE_GC
:
6765 return "GC (Double precision complex, G floating)";
6766 case DSC__K_DTYPE_HC
:
6767 return "HC (Quadruple precision complex, H floating)";
6768 case DSC__K_DTYPE_CIT
:
6769 return "CIT (COBOL intermediate temporary)";
6770 case DSC__K_DTYPE_BPV
:
6771 return "BPV (Bound Procedure Value)";
6772 case DSC__K_DTYPE_BLV
:
6773 return "BLV (Bound Label Value)";
6774 case DSC__K_DTYPE_VU
:
6775 return "VU (Bit Unaligned)";
6776 case DSC__K_DTYPE_ADT
:
6777 return "ADT (Absolute Date-Time)";
6778 case DSC__K_DTYPE_VT
:
6779 return "VT (Varying Text)";
6780 case DSC__K_DTYPE_T2
:
6781 return "T2 (16-bit char)";
6782 case DSC__K_DTYPE_VT2
:
6783 return "VT2 (16-bit varying char)";
6785 return "?? (unknown)";
6790 evax_bfd_print_desc (const unsigned char *buf
, int indent
, FILE *file
)
6792 unsigned char bclass
= buf
[3];
6793 unsigned char dtype
= buf
[2];
6794 unsigned int len
= (unsigned)bfd_getl16 (buf
);
6795 unsigned int pointer
= (unsigned)bfd_getl32 (buf
+ 4);
6797 evax_bfd_print_indent (indent
, file
);
6799 if (len
== 1 && pointer
== 0xffffffffUL
)
6802 fprintf (file
, _("64 bits *unhandled*\n"));
6806 /* xgettext:c-format */
6807 fprintf (file
, _("class: %u, dtype: %u, length: %u, pointer: 0x%08x\n"),
6808 bclass
, dtype
, len
, pointer
);
6811 case DSC__K_CLASS_NCA
:
6813 const struct vms_dsc_nca
*dsc
= (const void *)buf
;
6815 const unsigned char *b
;
6817 evax_bfd_print_indent (indent
, file
);
6818 fprintf (file
, _("non-contiguous array of %s\n"),
6819 evax_bfd_get_dsc_name (dsc
->dtype
));
6820 evax_bfd_print_indent (indent
+ 1, file
);
6822 /* xgettext:c-format */
6823 _("dimct: %u, aflags: 0x%02x, digits: %u, scale: %u\n"),
6824 dsc
->dimct
, dsc
->aflags
, dsc
->digits
, dsc
->scale
);
6825 evax_bfd_print_indent (indent
+ 1, file
);
6827 /* xgettext:c-format */
6828 _("arsize: %u, a0: 0x%08x\n"),
6829 (unsigned)bfd_getl32 (dsc
->arsize
),
6830 (unsigned)bfd_getl32 (dsc
->a0
));
6831 evax_bfd_print_indent (indent
+ 1, file
);
6832 fprintf (file
, _("Strides:\n"));
6833 b
= buf
+ sizeof (*dsc
);
6834 for (i
= 0; i
< dsc
->dimct
; i
++)
6836 evax_bfd_print_indent (indent
+ 2, file
);
6837 fprintf (file
, "[%u]: %u\n", i
+ 1,
6838 (unsigned)bfd_getl32 (b
));
6841 evax_bfd_print_indent (indent
+ 1, file
);
6842 fprintf (file
, _("Bounds:\n"));
6843 b
= buf
+ sizeof (*dsc
);
6844 for (i
= 0; i
< dsc
->dimct
; i
++)
6846 evax_bfd_print_indent (indent
+ 2, file
);
6847 /* xgettext:c-format */
6848 fprintf (file
, _("[%u]: Lower: %u, upper: %u\n"), i
+ 1,
6849 (unsigned)bfd_getl32 (b
+ 0),
6850 (unsigned)bfd_getl32 (b
+ 4));
6855 case DSC__K_CLASS_UBS
:
6857 const struct vms_dsc_ubs
*ubs
= (const void *)buf
;
6859 evax_bfd_print_indent (indent
, file
);
6860 fprintf (file
, _("unaligned bit-string of %s\n"),
6861 evax_bfd_get_dsc_name (ubs
->dtype
));
6862 evax_bfd_print_indent (indent
+ 1, file
);
6864 /* xgettext:c-format */
6865 _("base: %u, pos: %u\n"),
6866 (unsigned)bfd_getl32 (ubs
->base
),
6867 (unsigned)bfd_getl32 (ubs
->pos
));
6871 fprintf (file
, _("*unhandled*\n"));
6878 evax_bfd_print_valspec (const unsigned char *buf
, int indent
, FILE *file
)
6880 unsigned int vflags
= buf
[0];
6881 unsigned int value
= (unsigned)bfd_getl32 (buf
+ 1);
6882 unsigned int len
= 5;
6884 evax_bfd_print_indent (indent
, file
);
6885 /* xgettext:c-format */
6886 fprintf (file
, _("vflags: 0x%02x, value: 0x%08x "), vflags
, value
);
6891 case DST__K_VFLAGS_NOVAL
:
6892 fprintf (file
, _("(no value)\n"));
6894 case DST__K_VFLAGS_NOTACTIVE
:
6895 fprintf (file
, _("(not active)\n"));
6897 case DST__K_VFLAGS_UNALLOC
:
6898 fprintf (file
, _("(not allocated)\n"));
6900 case DST__K_VFLAGS_DSC
:
6901 fprintf (file
, _("(descriptor)\n"));
6902 evax_bfd_print_desc (buf
+ value
, indent
+ 1, file
);
6904 case DST__K_VFLAGS_TVS
:
6905 fprintf (file
, _("(trailing value)\n"));
6907 case DST__K_VS_FOLLOWS
:
6908 fprintf (file
, _("(value spec follows)\n"));
6910 case DST__K_VFLAGS_BITOFFS
:
6911 fprintf (file
, _("(at bit offset %u)\n"), value
);
6914 /* xgettext:c-format */
6915 fprintf (file
, _("(reg: %u, disp: %u, indir: %u, kind: "),
6916 (vflags
& DST__K_REGNUM_MASK
) >> DST__K_REGNUM_SHIFT
,
6917 vflags
& DST__K_DISP
? 1 : 0,
6918 vflags
& DST__K_INDIR
? 1 : 0);
6919 switch (vflags
& DST__K_VALKIND_MASK
)
6921 case DST__K_VALKIND_LITERAL
:
6922 fputs (_("literal"), file
);
6924 case DST__K_VALKIND_ADDR
:
6925 fputs (_("address"), file
);
6927 case DST__K_VALKIND_DESC
:
6928 fputs (_("desc"), file
);
6930 case DST__K_VALKIND_REG
:
6931 fputs (_("reg"), file
);
6934 fputs (")\n", file
);
6941 evax_bfd_print_typspec (const unsigned char *buf
, int indent
, FILE *file
)
6943 unsigned char kind
= buf
[2];
6944 unsigned int len
= (unsigned)bfd_getl16 (buf
);
6946 evax_bfd_print_indent (indent
, file
);
6947 /* xgettext:c-format */
6948 fprintf (file
, _("len: %2u, kind: %2u "), len
, kind
);
6952 case DST__K_TS_ATOM
:
6953 /* xgettext:c-format */
6954 fprintf (file
, _("atomic, type=0x%02x %s\n"),
6955 buf
[0], evax_bfd_get_dsc_name (buf
[0]));
6958 fprintf (file
, _("indirect, defined at 0x%08x\n"),
6959 (unsigned)bfd_getl32 (buf
));
6961 case DST__K_TS_TPTR
:
6962 fprintf (file
, _("typed pointer\n"));
6963 evax_bfd_print_typspec (buf
, indent
+ 1, file
);
6966 fprintf (file
, _("pointer\n"));
6968 case DST__K_TS_ARRAY
:
6970 const unsigned char *vs
;
6971 unsigned int vec_len
;
6974 fprintf (file
, _("array, dim: %u, bitmap: "), buf
[0]);
6975 vec_len
= (buf
[0] + 1 + 7) / 8;
6976 for (i
= 0; i
< vec_len
; i
++)
6977 fprintf (file
, " %02x", buf
[i
+ 1]);
6979 vs
= buf
+ 1 + vec_len
;
6980 evax_bfd_print_indent (indent
, file
);
6981 fprintf (file
, _("array descriptor:\n"));
6982 vs
+= evax_bfd_print_valspec (vs
, indent
+ 1, file
);
6983 for (i
= 0; i
< buf
[0] + 1U; i
++)
6984 if (buf
[1 + i
/ 8] & (1 << (i
% 8)))
6986 evax_bfd_print_indent (indent
, file
);
6988 fprintf (file
, _("type spec for element:\n"));
6990 fprintf (file
, _("type spec for subscript %u:\n"), i
);
6991 evax_bfd_print_typspec (vs
, indent
+ 1, file
);
6992 vs
+= bfd_getl16 (vs
);
6997 fprintf (file
, _("*unhandled*\n"));
7002 evax_bfd_print_dst (struct bfd
*abfd
, unsigned int dst_size
, FILE *file
)
7004 unsigned int off
= 0;
7005 unsigned int pc
= 0;
7006 unsigned int line
= 0;
7008 fprintf (file
, _("Debug symbol table:\n"));
7010 while (dst_size
> 0)
7012 struct vms_dst_header dsth
;
7017 if (bfd_bread (&dsth
, sizeof (dsth
), abfd
) != sizeof (dsth
))
7019 fprintf (file
, _("cannot read DST header\n"));
7022 len
= bfd_getl16 (dsth
.length
);
7023 type
= bfd_getl16 (dsth
.type
);
7024 /* xgettext:c-format */
7025 fprintf (file
, _(" type: %3u, len: %3u (at 0x%08x): "),
7035 len
-= sizeof (dsth
);
7036 buf
= bfd_malloc (len
);
7037 if (bfd_bread (buf
, len
, abfd
) != len
)
7039 fprintf (file
, _("cannot read DST symbol\n"));
7044 case DSC__K_DTYPE_V
:
7045 case DSC__K_DTYPE_BU
:
7046 case DSC__K_DTYPE_WU
:
7047 case DSC__K_DTYPE_LU
:
7048 case DSC__K_DTYPE_QU
:
7049 case DSC__K_DTYPE_B
:
7050 case DSC__K_DTYPE_W
:
7051 case DSC__K_DTYPE_L
:
7052 case DSC__K_DTYPE_Q
:
7053 case DSC__K_DTYPE_F
:
7054 case DSC__K_DTYPE_D
:
7055 case DSC__K_DTYPE_FC
:
7056 case DSC__K_DTYPE_DC
:
7057 case DSC__K_DTYPE_T
:
7058 case DSC__K_DTYPE_NU
:
7059 case DSC__K_DTYPE_NL
:
7060 case DSC__K_DTYPE_NLO
:
7061 case DSC__K_DTYPE_NR
:
7062 case DSC__K_DTYPE_NRO
:
7063 case DSC__K_DTYPE_NZ
:
7064 case DSC__K_DTYPE_P
:
7065 case DSC__K_DTYPE_ZI
:
7066 case DSC__K_DTYPE_ZEM
:
7067 case DSC__K_DTYPE_DSC
:
7068 case DSC__K_DTYPE_OU
:
7069 case DSC__K_DTYPE_O
:
7070 case DSC__K_DTYPE_G
:
7071 case DSC__K_DTYPE_H
:
7072 case DSC__K_DTYPE_GC
:
7073 case DSC__K_DTYPE_HC
:
7074 case DSC__K_DTYPE_CIT
:
7075 case DSC__K_DTYPE_BPV
:
7076 case DSC__K_DTYPE_BLV
:
7077 case DSC__K_DTYPE_VU
:
7078 case DSC__K_DTYPE_ADT
:
7079 case DSC__K_DTYPE_VT
:
7080 case DSC__K_DTYPE_T2
:
7081 case DSC__K_DTYPE_VT2
:
7082 fprintf (file
, _("standard data: %s\n"),
7083 evax_bfd_get_dsc_name (type
));
7084 evax_bfd_print_valspec (buf
, 4, file
);
7085 fprintf (file
, _(" name: %.*s\n"), buf
[5], buf
+ 6);
7089 struct vms_dst_modbeg
*dst
= (void *)buf
;
7090 const char *name
= (const char *)buf
+ sizeof (*dst
);
7092 fprintf (file
, _("modbeg\n"));
7093 /* xgettext:c-format */
7094 fprintf (file
, _(" flags: %d, language: %u, "
7095 "major: %u, minor: %u\n"),
7097 (unsigned)bfd_getl32 (dst
->language
),
7098 (unsigned)bfd_getl16 (dst
->major
),
7099 (unsigned)bfd_getl16 (dst
->minor
));
7100 fprintf (file
, _(" module name: %.*s\n"),
7102 name
+= name
[0] + 1;
7103 fprintf (file
, _(" compiler : %.*s\n"),
7108 fprintf (file
, _("modend\n"));
7112 struct vms_dst_rtnbeg
*dst
= (void *)buf
;
7113 const char *name
= (const char *)buf
+ sizeof (*dst
);
7115 fputs (_("rtnbeg\n"), file
);
7116 /* xgettext:c-format */
7117 fprintf (file
, _(" flags: %u, address: 0x%08x, "
7118 "pd-address: 0x%08x\n"),
7120 (unsigned)bfd_getl32 (dst
->address
),
7121 (unsigned)bfd_getl32 (dst
->pd_address
));
7122 fprintf (file
, _(" routine name: %.*s\n"),
7128 struct vms_dst_rtnend
*dst
= (void *)buf
;
7130 fprintf (file
, _("rtnend: size 0x%08x\n"),
7131 (unsigned)bfd_getl32 (dst
->size
));
7136 struct vms_dst_prolog
*dst
= (void *)buf
;
7138 fprintf (file
, _("prolog: bkpt address 0x%08x\n"),
7139 (unsigned)bfd_getl32 (dst
->bkpt_addr
));
7144 struct vms_dst_epilog
*dst
= (void *)buf
;
7146 /* xgettext:c-format */
7147 fprintf (file
, _("epilog: flags: %u, count: %u\n"),
7148 dst
->flags
, (unsigned)bfd_getl32 (dst
->count
));
7153 struct vms_dst_blkbeg
*dst
= (void *)buf
;
7154 const char *name
= (const char *)buf
+ sizeof (*dst
);
7156 /* xgettext:c-format */
7157 fprintf (file
, _("blkbeg: address: 0x%08x, name: %.*s\n"),
7158 (unsigned)bfd_getl32 (dst
->address
),
7164 struct vms_dst_blkend
*dst
= (void *)buf
;
7166 fprintf (file
, _("blkend: size: 0x%08x\n"),
7167 (unsigned)bfd_getl32 (dst
->size
));
7170 case DST__K_TYPSPEC
:
7172 fprintf (file
, _("typspec (len: %u)\n"), len
);
7173 fprintf (file
, _(" name: %.*s\n"), buf
[0], buf
+ 1);
7174 evax_bfd_print_typspec (buf
+ 1 + buf
[0], 5, file
);
7179 fprintf (file
, _("septyp, name: %.*s\n"), buf
[5], buf
+ 6);
7180 evax_bfd_print_valspec (buf
, 4, file
);
7185 struct vms_dst_recbeg
*recbeg
= (void *)buf
;
7186 const char *name
= (const char *)buf
+ sizeof (*recbeg
);
7188 fprintf (file
, _("recbeg: name: %.*s\n"), name
[0], name
+ 1);
7189 evax_bfd_print_valspec (buf
, 4, file
);
7190 fprintf (file
, _(" len: %u bits\n"),
7191 (unsigned)bfd_getl32 (name
+ 1 + name
[0]));
7195 fprintf (file
, _("recend\n"));
7197 case DST__K_ENUMBEG
:
7198 /* xgettext:c-format */
7199 fprintf (file
, _("enumbeg, len: %u, name: %.*s\n"),
7200 buf
[0], buf
[1], buf
+ 2);
7202 case DST__K_ENUMELT
:
7203 fprintf (file
, _("enumelt, name: %.*s\n"), buf
[5], buf
+ 6);
7204 evax_bfd_print_valspec (buf
, 4, file
);
7206 case DST__K_ENUMEND
:
7207 fprintf (file
, _("enumend\n"));
7211 struct vms_dst_label
*lab
= (void *)buf
;
7212 fprintf (file
, _("label, name: %.*s\n"),
7213 lab
->name
[0], lab
->name
+ 1);
7214 fprintf (file
, _(" address: 0x%08x\n"),
7215 (unsigned)bfd_getl32 (lab
->value
));
7218 case DST__K_DIS_RANGE
:
7220 unsigned int cnt
= bfd_getl32 (buf
);
7221 unsigned char *rng
= buf
+ 4;
7224 fprintf (file
, _("discontiguous range (nbr: %u)\n"), cnt
);
7225 for (i
= 0; i
< cnt
; i
++, rng
+= 8)
7226 /* xgettext:c-format */
7227 fprintf (file
, _(" address: 0x%08x, size: %u\n"),
7228 (unsigned)bfd_getl32 (rng
),
7229 (unsigned)bfd_getl32 (rng
+ 4));
7233 case DST__K_LINE_NUM
:
7235 unsigned char *buf_orig
= buf
;
7237 fprintf (file
, _("line num (len: %u)\n"), len
);
7242 unsigned char cmdlen
;
7252 case DST__K_DELTA_PC_W
:
7253 val
= bfd_getl16 (buf
+ 1);
7254 fprintf (file
, _("delta_pc_w %u\n"), val
);
7259 case DST__K_INCR_LINUM
:
7261 fprintf (file
, _("incr_linum(b): +%u\n"), val
);
7265 case DST__K_INCR_LINUM_W
:
7266 val
= bfd_getl16 (buf
+ 1);
7267 fprintf (file
, _("incr_linum_w: +%u\n"), val
);
7271 case DST__K_INCR_LINUM_L
:
7272 val
= bfd_getl32 (buf
+ 1);
7273 fprintf (file
, _("incr_linum_l: +%u\n"), val
);
7277 case DST__K_SET_LINUM
:
7278 line
= bfd_getl16 (buf
+ 1);
7279 fprintf (file
, _("set_line_num(w) %u\n"), line
);
7282 case DST__K_SET_LINUM_B
:
7284 fprintf (file
, _("set_line_num_b %u\n"), line
);
7287 case DST__K_SET_LINUM_L
:
7288 line
= bfd_getl32 (buf
+ 1);
7289 fprintf (file
, _("set_line_num_l %u\n"), line
);
7292 case DST__K_SET_ABS_PC
:
7293 pc
= bfd_getl32 (buf
+ 1);
7294 fprintf (file
, _("set_abs_pc: 0x%08x\n"), pc
);
7297 case DST__K_DELTA_PC_L
:
7298 fprintf (file
, _("delta_pc_l: +0x%08x\n"),
7299 (unsigned)bfd_getl32 (buf
+ 1));
7303 fprintf (file
, _("term(b): 0x%02x"), buf
[1]);
7305 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7309 val
= bfd_getl16 (buf
+ 1);
7310 fprintf (file
, _("term_w: 0x%04x"), val
);
7312 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7318 fprintf (file
, _("delta pc +%-4d"), -cmd
);
7319 line
++; /* FIXME: curr increment. */
7321 /* xgettext:c-format */
7322 fprintf (file
, _(" pc: 0x%08x line: %5u\n"),
7327 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7340 unsigned char *buf_orig
= buf
;
7342 fprintf (file
, _("source (len: %u)\n"), len
);
7346 signed char cmd
= buf
[0];
7347 unsigned char cmdlen
= 0;
7351 case DST__K_SRC_DECLFILE
:
7353 struct vms_dst_src_decl_src
*src
= (void *)(buf
+ 1);
7356 /* xgettext:c-format */
7357 fprintf (file
, _(" declfile: len: %u, flags: %u, "
7359 src
->length
, src
->flags
,
7360 (unsigned)bfd_getl16 (src
->fileid
));
7361 /* xgettext:c-format */
7362 fprintf (file
, _(" rms: cdt: 0x%08x %08x, "
7363 "ebk: 0x%08x, ffb: 0x%04x, "
7365 (unsigned)bfd_getl32 (src
->rms_cdt
+ 4),
7366 (unsigned)bfd_getl32 (src
->rms_cdt
+ 0),
7367 (unsigned)bfd_getl32 (src
->rms_ebk
),
7368 (unsigned)bfd_getl16 (src
->rms_ffb
),
7370 name
= (const char *)buf
+ 1 + sizeof (*src
);
7371 fprintf (file
, _(" filename : %.*s\n"),
7373 name
+= name
[0] + 1;
7374 fprintf (file
, _(" module name: %.*s\n"),
7376 cmdlen
= 2 + src
->length
;
7379 case DST__K_SRC_SETFILE
:
7380 fprintf (file
, _(" setfile %u\n"),
7381 (unsigned)bfd_getl16 (buf
+ 1));
7384 case DST__K_SRC_SETREC_W
:
7385 fprintf (file
, _(" setrec %u\n"),
7386 (unsigned)bfd_getl16 (buf
+ 1));
7389 case DST__K_SRC_SETREC_L
:
7390 fprintf (file
, _(" setrec %u\n"),
7391 (unsigned)bfd_getl32 (buf
+ 1));
7394 case DST__K_SRC_SETLNUM_W
:
7395 fprintf (file
, _(" setlnum %u\n"),
7396 (unsigned)bfd_getl16 (buf
+ 1));
7399 case DST__K_SRC_SETLNUM_L
:
7400 fprintf (file
, _(" setlnum %u\n"),
7401 (unsigned)bfd_getl32 (buf
+ 1));
7404 case DST__K_SRC_DEFLINES_W
:
7405 fprintf (file
, _(" deflines %u\n"),
7406 (unsigned)bfd_getl16 (buf
+ 1));
7409 case DST__K_SRC_DEFLINES_B
:
7410 fprintf (file
, _(" deflines %u\n"), buf
[1]);
7413 case DST__K_SRC_FORMFEED
:
7414 fprintf (file
, _(" formfeed\n"));
7418 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7430 fprintf (file
, _("*unhandled* dst type %u\n"), type
);
7438 evax_bfd_print_image (bfd
*abfd
, FILE *file
)
7440 struct vms_eihd eihd
;
7443 unsigned int eiha_off
;
7444 unsigned int eihi_off
;
7445 unsigned int eihs_off
;
7446 unsigned int eisd_off
;
7447 unsigned int eihef_off
= 0;
7448 unsigned int eihnp_off
= 0;
7449 unsigned int dmt_vbn
= 0;
7450 unsigned int dmt_size
= 0;
7451 unsigned int dst_vbn
= 0;
7452 unsigned int dst_size
= 0;
7453 unsigned int gst_vbn
= 0;
7454 unsigned int gst_size
= 0;
7455 unsigned int eiaf_vbn
= 0;
7456 unsigned int eiaf_size
= 0;
7457 unsigned int eihvn_off
;
7459 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
)
7460 || bfd_bread (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
7462 fprintf (file
, _("cannot read EIHD\n"));
7465 /* xgettext:c-format */
7466 fprintf (file
, _("EIHD: (size: %u, nbr blocks: %u)\n"),
7467 (unsigned)bfd_getl32 (eihd
.size
),
7468 (unsigned)bfd_getl32 (eihd
.hdrblkcnt
));
7469 /* xgettext:c-format */
7470 fprintf (file
, _(" majorid: %u, minorid: %u\n"),
7471 (unsigned)bfd_getl32 (eihd
.majorid
),
7472 (unsigned)bfd_getl32 (eihd
.minorid
));
7474 val
= (unsigned)bfd_getl32 (eihd
.imgtype
);
7478 name
= _("executable");
7481 name
= _("linkable image");
7484 name
= _("unknown");
7487 /* xgettext:c-format */
7488 fprintf (file
, _(" image type: %u (%s)"), val
, name
);
7490 val
= (unsigned)bfd_getl32 (eihd
.subtype
);
7493 case EIHD__C_NATIVE
:
7500 name
= _("unknown");
7503 /* xgettext:c-format */
7504 fprintf (file
, _(", subtype: %u (%s)\n"), val
, name
);
7506 eisd_off
= bfd_getl32 (eihd
.isdoff
);
7507 eiha_off
= bfd_getl32 (eihd
.activoff
);
7508 eihi_off
= bfd_getl32 (eihd
.imgidoff
);
7509 eihs_off
= bfd_getl32 (eihd
.symdbgoff
);
7510 /* xgettext:c-format */
7511 fprintf (file
, _(" offsets: isd: %u, activ: %u, symdbg: %u, "
7512 "imgid: %u, patch: %u\n"),
7513 eisd_off
, eiha_off
, eihs_off
, eihi_off
,
7514 (unsigned)bfd_getl32 (eihd
.patchoff
));
7515 fprintf (file
, _(" fixup info rva: "));
7516 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.iafva
));
7517 fprintf (file
, _(", symbol vector rva: "));
7518 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.symvva
));
7519 eihvn_off
= bfd_getl32 (eihd
.version_array_off
);
7520 fprintf (file
, _("\n"
7521 " version array off: %u\n"),
7524 /* xgettext:c-format */
7525 _(" img I/O count: %u, nbr channels: %u, req pri: %08x%08x\n"),
7526 (unsigned)bfd_getl32 (eihd
.imgiocnt
),
7527 (unsigned)bfd_getl32 (eihd
.iochancnt
),
7528 (unsigned)bfd_getl32 (eihd
.privreqs
+ 4),
7529 (unsigned)bfd_getl32 (eihd
.privreqs
+ 0));
7530 val
= (unsigned)bfd_getl32 (eihd
.lnkflags
);
7531 fprintf (file
, _(" linker flags: %08x:"), val
);
7532 if (val
& EIHD__M_LNKDEBUG
)
7533 fprintf (file
, " LNKDEBUG");
7534 if (val
& EIHD__M_LNKNOTFR
)
7535 fprintf (file
, " LNKNOTFR");
7536 if (val
& EIHD__M_NOP0BUFS
)
7537 fprintf (file
, " NOP0BUFS");
7538 if (val
& EIHD__M_PICIMG
)
7539 fprintf (file
, " PICIMG");
7540 if (val
& EIHD__M_P0IMAGE
)
7541 fprintf (file
, " P0IMAGE");
7542 if (val
& EIHD__M_DBGDMT
)
7543 fprintf (file
, " DBGDMT");
7544 if (val
& EIHD__M_INISHR
)
7545 fprintf (file
, " INISHR");
7546 if (val
& EIHD__M_XLATED
)
7547 fprintf (file
, " XLATED");
7548 if (val
& EIHD__M_BIND_CODE_SEC
)
7549 fprintf (file
, " BIND_CODE_SEC");
7550 if (val
& EIHD__M_BIND_DATA_SEC
)
7551 fprintf (file
, " BIND_DATA_SEC");
7552 if (val
& EIHD__M_MKTHREADS
)
7553 fprintf (file
, " MKTHREADS");
7554 if (val
& EIHD__M_UPCALLS
)
7555 fprintf (file
, " UPCALLS");
7556 if (val
& EIHD__M_OMV_READY
)
7557 fprintf (file
, " OMV_READY");
7558 if (val
& EIHD__M_EXT_BIND_SECT
)
7559 fprintf (file
, " EXT_BIND_SECT");
7560 fprintf (file
, "\n");
7561 /* xgettext:c-format */
7562 fprintf (file
, _(" ident: 0x%08x, sysver: 0x%08x, "
7563 "match ctrl: %u, symvect_size: %u\n"),
7564 (unsigned)bfd_getl32 (eihd
.ident
),
7565 (unsigned)bfd_getl32 (eihd
.sysver
),
7567 (unsigned)bfd_getl32 (eihd
.symvect_size
));
7568 fprintf (file
, _(" BPAGE: %u"),
7569 (unsigned)bfd_getl32 (eihd
.virt_mem_block_size
));
7570 if (val
& (EIHD__M_OMV_READY
| EIHD__M_EXT_BIND_SECT
))
7572 eihef_off
= bfd_getl32 (eihd
.ext_fixup_off
);
7573 eihnp_off
= bfd_getl32 (eihd
.noopt_psect_off
);
7574 /* xgettext:c-format */
7575 fprintf (file
, _(", ext fixup offset: %u, no_opt psect off: %u"),
7576 eihef_off
, eihnp_off
);
7578 fprintf (file
, _(", alias: %u\n"), (unsigned)bfd_getl16 (eihd
.alias
));
7582 struct vms_eihvn eihvn
;
7586 fprintf (file
, _("system version array information:\n"));
7587 if (bfd_seek (abfd
, (file_ptr
) eihvn_off
, SEEK_SET
)
7588 || bfd_bread (&eihvn
, sizeof (eihvn
), abfd
) != sizeof (eihvn
))
7590 fprintf (file
, _("cannot read EIHVN header\n"));
7593 mask
= bfd_getl32 (eihvn
.subsystem_mask
);
7594 for (j
= 0; j
< 32; j
++)
7595 if (mask
& (1 << j
))
7597 struct vms_eihvn_subversion ver
;
7598 if (bfd_bread (&ver
, sizeof (ver
), abfd
) != sizeof (ver
))
7600 fprintf (file
, _("cannot read EIHVN version\n"));
7603 fprintf (file
, _(" %02u "), j
);
7606 case EIHVN__BASE_IMAGE_BIT
:
7607 fputs (_("BASE_IMAGE "), file
);
7609 case EIHVN__MEMORY_MANAGEMENT_BIT
:
7610 fputs (_("MEMORY_MANAGEMENT"), file
);
7613 fputs (_("IO "), file
);
7615 case EIHVN__FILES_VOLUMES_BIT
:
7616 fputs (_("FILES_VOLUMES "), file
);
7618 case EIHVN__PROCESS_SCHED_BIT
:
7619 fputs (_("PROCESS_SCHED "), file
);
7621 case EIHVN__SYSGEN_BIT
:
7622 fputs (_("SYSGEN "), file
);
7624 case EIHVN__CLUSTERS_LOCKMGR_BIT
:
7625 fputs (_("CLUSTERS_LOCKMGR "), file
);
7627 case EIHVN__LOGICAL_NAMES_BIT
:
7628 fputs (_("LOGICAL_NAMES "), file
);
7630 case EIHVN__SECURITY_BIT
:
7631 fputs (_("SECURITY "), file
);
7633 case EIHVN__IMAGE_ACTIVATOR_BIT
:
7634 fputs (_("IMAGE_ACTIVATOR "), file
);
7636 case EIHVN__NETWORKS_BIT
:
7637 fputs (_("NETWORKS "), file
);
7639 case EIHVN__COUNTERS_BIT
:
7640 fputs (_("COUNTERS "), file
);
7642 case EIHVN__STABLE_BIT
:
7643 fputs (_("STABLE "), file
);
7645 case EIHVN__MISC_BIT
:
7646 fputs (_("MISC "), file
);
7648 case EIHVN__CPU_BIT
:
7649 fputs (_("CPU "), file
);
7651 case EIHVN__VOLATILE_BIT
:
7652 fputs (_("VOLATILE "), file
);
7654 case EIHVN__SHELL_BIT
:
7655 fputs (_("SHELL "), file
);
7657 case EIHVN__POSIX_BIT
:
7658 fputs (_("POSIX "), file
);
7660 case EIHVN__MULTI_PROCESSING_BIT
:
7661 fputs (_("MULTI_PROCESSING "), file
);
7663 case EIHVN__GALAXY_BIT
:
7664 fputs (_("GALAXY "), file
);
7667 fputs (_("*unknown* "), file
);
7670 fprintf (file
, ": %u.%u\n",
7671 (unsigned)bfd_getl16 (ver
.major
),
7672 (unsigned)bfd_getl16 (ver
.minor
));
7678 struct vms_eiha eiha
;
7680 if (bfd_seek (abfd
, (file_ptr
) eiha_off
, SEEK_SET
)
7681 || bfd_bread (&eiha
, sizeof (eiha
), abfd
) != sizeof (eiha
))
7683 fprintf (file
, _("cannot read EIHA\n"));
7686 fprintf (file
, _("Image activation: (size=%u)\n"),
7687 (unsigned)bfd_getl32 (eiha
.size
));
7688 /* xgettext:c-format */
7689 fprintf (file
, _(" First address : 0x%08x 0x%08x\n"),
7690 (unsigned)bfd_getl32 (eiha
.tfradr1_h
),
7691 (unsigned)bfd_getl32 (eiha
.tfradr1
));
7692 /* xgettext:c-format */
7693 fprintf (file
, _(" Second address: 0x%08x 0x%08x\n"),
7694 (unsigned)bfd_getl32 (eiha
.tfradr2_h
),
7695 (unsigned)bfd_getl32 (eiha
.tfradr2
));
7696 /* xgettext:c-format */
7697 fprintf (file
, _(" Third address : 0x%08x 0x%08x\n"),
7698 (unsigned)bfd_getl32 (eiha
.tfradr3_h
),
7699 (unsigned)bfd_getl32 (eiha
.tfradr3
));
7700 /* xgettext:c-format */
7701 fprintf (file
, _(" Fourth address: 0x%08x 0x%08x\n"),
7702 (unsigned)bfd_getl32 (eiha
.tfradr4_h
),
7703 (unsigned)bfd_getl32 (eiha
.tfradr4
));
7704 /* xgettext:c-format */
7705 fprintf (file
, _(" Shared image : 0x%08x 0x%08x\n"),
7706 (unsigned)bfd_getl32 (eiha
.inishr_h
),
7707 (unsigned)bfd_getl32 (eiha
.inishr
));
7711 struct vms_eihi eihi
;
7713 if (bfd_seek (abfd
, (file_ptr
) eihi_off
, SEEK_SET
)
7714 || bfd_bread (&eihi
, sizeof (eihi
), abfd
) != sizeof (eihi
))
7716 fprintf (file
, _("cannot read EIHI\n"));
7719 /* xgettext:c-format */
7720 fprintf (file
, _("Image identification: (major: %u, minor: %u)\n"),
7721 (unsigned)bfd_getl32 (eihi
.majorid
),
7722 (unsigned)bfd_getl32 (eihi
.minorid
));
7723 fprintf (file
, _(" image name : %.*s\n"),
7724 eihi
.imgnam
[0], eihi
.imgnam
+ 1);
7725 fprintf (file
, _(" link time : %s\n"),
7726 vms_time_to_str (eihi
.linktime
));
7727 fprintf (file
, _(" image ident : %.*s\n"),
7728 eihi
.imgid
[0], eihi
.imgid
+ 1);
7729 fprintf (file
, _(" linker ident : %.*s\n"),
7730 eihi
.linkid
[0], eihi
.linkid
+ 1);
7731 fprintf (file
, _(" image build ident: %.*s\n"),
7732 eihi
.imgbid
[0], eihi
.imgbid
+ 1);
7736 struct vms_eihs eihs
;
7738 if (bfd_seek (abfd
, (file_ptr
) eihs_off
, SEEK_SET
)
7739 || bfd_bread (&eihs
, sizeof (eihs
), abfd
) != sizeof (eihs
))
7741 fprintf (file
, _("cannot read EIHS\n"));
7744 /* xgettext:c-format */
7745 fprintf (file
, _("Image symbol & debug table: (major: %u, minor: %u)\n"),
7746 (unsigned)bfd_getl32 (eihs
.majorid
),
7747 (unsigned)bfd_getl32 (eihs
.minorid
));
7748 dst_vbn
= bfd_getl32 (eihs
.dstvbn
);
7749 dst_size
= bfd_getl32 (eihs
.dstsize
);
7750 /* xgettext:c-format */
7751 fprintf (file
, _(" debug symbol table : vbn: %u, size: %u (0x%x)\n"),
7752 dst_vbn
, dst_size
, dst_size
);
7753 gst_vbn
= bfd_getl32 (eihs
.gstvbn
);
7754 gst_size
= bfd_getl32 (eihs
.gstsize
);
7755 /* xgettext:c-format */
7756 fprintf (file
, _(" global symbol table: vbn: %u, records: %u\n"),
7758 dmt_vbn
= bfd_getl32 (eihs
.dmtvbn
);
7759 dmt_size
= bfd_getl32 (eihs
.dmtsize
);
7760 /* xgettext:c-format */
7761 fprintf (file
, _(" debug module table : vbn: %u, size: %u\n"),
7764 while (eisd_off
!= 0)
7766 struct vms_eisd eisd
;
7771 if (bfd_seek (abfd
, (file_ptr
) eisd_off
, SEEK_SET
)
7772 || bfd_bread (&eisd
, sizeof (eisd
), abfd
) != sizeof (eisd
))
7774 fprintf (file
, _("cannot read EISD\n"));
7777 len
= (unsigned)bfd_getl32 (eisd
.eisdsize
);
7778 if (len
!= (unsigned)-1)
7782 eisd_off
= (eisd_off
+ VMS_BLOCK_SIZE
) & ~(VMS_BLOCK_SIZE
- 1);
7784 /* xgettext:c-format */
7785 fprintf (file
, _("Image section descriptor: (major: %u, minor: %u, "
7786 "size: %u, offset: %u)\n"),
7787 (unsigned)bfd_getl32 (eisd
.majorid
),
7788 (unsigned)bfd_getl32 (eisd
.minorid
),
7792 /* xgettext:c-format */
7793 fprintf (file
, _(" section: base: 0x%08x%08x size: 0x%08x\n"),
7794 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 4),
7795 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 0),
7796 (unsigned)bfd_getl32 (eisd
.secsize
));
7797 val
= (unsigned)bfd_getl32 (eisd
.flags
);
7798 fprintf (file
, _(" flags: 0x%04x"), val
);
7799 if (val
& EISD__M_GBL
)
7800 fprintf (file
, " GBL");
7801 if (val
& EISD__M_CRF
)
7802 fprintf (file
, " CRF");
7803 if (val
& EISD__M_DZRO
)
7804 fprintf (file
, " DZRO");
7805 if (val
& EISD__M_WRT
)
7806 fprintf (file
, " WRT");
7807 if (val
& EISD__M_INITALCODE
)
7808 fprintf (file
, " INITALCODE");
7809 if (val
& EISD__M_BASED
)
7810 fprintf (file
, " BASED");
7811 if (val
& EISD__M_FIXUPVEC
)
7812 fprintf (file
, " FIXUPVEC");
7813 if (val
& EISD__M_RESIDENT
)
7814 fprintf (file
, " RESIDENT");
7815 if (val
& EISD__M_VECTOR
)
7816 fprintf (file
, " VECTOR");
7817 if (val
& EISD__M_PROTECT
)
7818 fprintf (file
, " PROTECT");
7819 if (val
& EISD__M_LASTCLU
)
7820 fprintf (file
, " LASTCLU");
7821 if (val
& EISD__M_EXE
)
7822 fprintf (file
, " EXE");
7823 if (val
& EISD__M_NONSHRADR
)
7824 fprintf (file
, " NONSHRADR");
7825 if (val
& EISD__M_QUAD_LENGTH
)
7826 fprintf (file
, " QUAD_LENGTH");
7827 if (val
& EISD__M_ALLOC_64BIT
)
7828 fprintf (file
, " ALLOC_64BIT");
7829 fprintf (file
, "\n");
7830 if (val
& EISD__M_FIXUPVEC
)
7832 eiaf_vbn
= bfd_getl32 (eisd
.vbn
);
7833 eiaf_size
= bfd_getl32 (eisd
.secsize
);
7835 /* xgettext:c-format */
7836 fprintf (file
, _(" vbn: %u, pfc: %u, matchctl: %u type: %u ("),
7837 (unsigned)bfd_getl32 (eisd
.vbn
),
7838 eisd
.pfc
, eisd
.matchctl
, eisd
.type
);
7841 case EISD__K_NORMAL
:
7842 fputs (_("NORMAL"), file
);
7844 case EISD__K_SHRFXD
:
7845 fputs (_("SHRFXD"), file
);
7847 case EISD__K_PRVFXD
:
7848 fputs (_("PRVFXD"), file
);
7850 case EISD__K_SHRPIC
:
7851 fputs (_("SHRPIC"), file
);
7853 case EISD__K_PRVPIC
:
7854 fputs (_("PRVPIC"), file
);
7856 case EISD__K_USRSTACK
:
7857 fputs (_("USRSTACK"), file
);
7860 fputs (_("*unknown*"), file
);
7863 fputs (_(")\n"), file
);
7864 if (val
& EISD__M_GBL
)
7865 /* xgettext:c-format */
7866 fprintf (file
, _(" ident: 0x%08x, name: %.*s\n"),
7867 (unsigned)bfd_getl32 (eisd
.ident
),
7868 eisd
.gblnam
[0], eisd
.gblnam
+ 1);
7874 if (bfd_seek (abfd
, (file_ptr
) (dmt_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7876 fprintf (file
, _("cannot read DMT\n"));
7880 fprintf (file
, _("Debug module table:\n"));
7882 while (dmt_size
> 0)
7884 struct vms_dmt_header dmth
;
7887 if (bfd_bread (&dmth
, sizeof (dmth
), abfd
) != sizeof (dmth
))
7889 fprintf (file
, _("cannot read DMT header\n"));
7892 count
= bfd_getl16 (dmth
.psect_count
);
7894 /* xgettext:c-format */
7895 _(" module offset: 0x%08x, size: 0x%08x, (%u psects)\n"),
7896 (unsigned)bfd_getl32 (dmth
.modbeg
),
7897 (unsigned)bfd_getl32 (dmth
.size
), count
);
7898 dmt_size
-= sizeof (dmth
);
7901 struct vms_dmt_psect dmtp
;
7903 if (bfd_bread (&dmtp
, sizeof (dmtp
), abfd
) != sizeof (dmtp
))
7905 fprintf (file
, _("cannot read DMT psect\n"));
7908 /* xgettext:c-format */
7909 fprintf (file
, _(" psect start: 0x%08x, length: %u\n"),
7910 (unsigned)bfd_getl32 (dmtp
.start
),
7911 (unsigned)bfd_getl32 (dmtp
.length
));
7913 dmt_size
-= sizeof (dmtp
);
7920 if (bfd_seek (abfd
, (file_ptr
) (dst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7922 fprintf (file
, _("cannot read DST\n"));
7926 evax_bfd_print_dst (abfd
, dst_size
, file
);
7930 if (bfd_seek (abfd
, (file_ptr
) (gst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7932 fprintf (file
, _("cannot read GST\n"));
7936 fprintf (file
, _("Global symbol table:\n"));
7937 evax_bfd_print_eobj (abfd
, file
);
7942 struct vms_eiaf
*eiaf
;
7943 unsigned int qrelfixoff
;
7944 unsigned int lrelfixoff
;
7945 unsigned int qdotadroff
;
7946 unsigned int ldotadroff
;
7947 unsigned int shrimgcnt
;
7948 unsigned int shlstoff
;
7949 unsigned int codeadroff
;
7950 unsigned int lpfixoff
;
7951 unsigned int chgprtoff
;
7953 buf
= bfd_malloc (eiaf_size
);
7955 if (bfd_seek (abfd
, (file_ptr
) (eiaf_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
)
7956 || bfd_bread (buf
, eiaf_size
, abfd
) != eiaf_size
)
7958 fprintf (file
, _("cannot read EIHA\n"));
7962 eiaf
= (struct vms_eiaf
*)buf
;
7964 /* xgettext:c-format */
7965 _("Image activator fixup: (major: %u, minor: %u)\n"),
7966 (unsigned)bfd_getl32 (eiaf
->majorid
),
7967 (unsigned)bfd_getl32 (eiaf
->minorid
));
7968 /* xgettext:c-format */
7969 fprintf (file
, _(" iaflink : 0x%08x %08x\n"),
7970 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 0),
7971 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 4));
7972 /* xgettext:c-format */
7973 fprintf (file
, _(" fixuplnk: 0x%08x %08x\n"),
7974 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 0),
7975 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 4));
7976 fprintf (file
, _(" size : %u\n"),
7977 (unsigned)bfd_getl32 (eiaf
->size
));
7978 fprintf (file
, _(" flags: 0x%08x\n"),
7979 (unsigned)bfd_getl32 (eiaf
->flags
));
7980 qrelfixoff
= bfd_getl32 (eiaf
->qrelfixoff
);
7981 lrelfixoff
= bfd_getl32 (eiaf
->lrelfixoff
);
7982 /* xgettext:c-format */
7983 fprintf (file
, _(" qrelfixoff: %5u, lrelfixoff: %5u\n"),
7984 qrelfixoff
, lrelfixoff
);
7985 qdotadroff
= bfd_getl32 (eiaf
->qdotadroff
);
7986 ldotadroff
= bfd_getl32 (eiaf
->ldotadroff
);
7987 /* xgettext:c-format */
7988 fprintf (file
, _(" qdotadroff: %5u, ldotadroff: %5u\n"),
7989 qdotadroff
, ldotadroff
);
7990 codeadroff
= bfd_getl32 (eiaf
->codeadroff
);
7991 lpfixoff
= bfd_getl32 (eiaf
->lpfixoff
);
7992 /* xgettext:c-format */
7993 fprintf (file
, _(" codeadroff: %5u, lpfixoff : %5u\n"),
7994 codeadroff
, lpfixoff
);
7995 chgprtoff
= bfd_getl32 (eiaf
->chgprtoff
);
7996 fprintf (file
, _(" chgprtoff : %5u\n"), chgprtoff
);
7997 shrimgcnt
= bfd_getl32 (eiaf
->shrimgcnt
);
7998 shlstoff
= bfd_getl32 (eiaf
->shlstoff
);
7999 /* xgettext:c-format */
8000 fprintf (file
, _(" shlstoff : %5u, shrimgcnt : %5u\n"),
8001 shlstoff
, shrimgcnt
);
8002 /* xgettext:c-format */
8003 fprintf (file
, _(" shlextra : %5u, permctx : %5u\n"),
8004 (unsigned)bfd_getl32 (eiaf
->shlextra
),
8005 (unsigned)bfd_getl32 (eiaf
->permctx
));
8006 fprintf (file
, _(" base_va : 0x%08x\n"),
8007 (unsigned)bfd_getl32 (eiaf
->base_va
));
8008 fprintf (file
, _(" lppsbfixoff: %5u\n"),
8009 (unsigned)bfd_getl32 (eiaf
->lppsbfixoff
));
8013 struct vms_shl
*shl
= (struct vms_shl
*)(buf
+ shlstoff
);
8016 fprintf (file
, _(" Shareable images:\n"));
8017 for (j
= 0; j
< shrimgcnt
; j
++, shl
++)
8020 /* xgettext:c-format */
8021 _(" %u: size: %u, flags: 0x%02x, name: %.*s\n"),
8022 j
, shl
->size
, shl
->flags
,
8023 shl
->imgnam
[0], shl
->imgnam
+ 1);
8026 if (qrelfixoff
!= 0)
8028 fprintf (file
, _(" quad-word relocation fixups:\n"));
8029 evax_bfd_print_relocation_records (file
, buf
+ qrelfixoff
, 8);
8031 if (lrelfixoff
!= 0)
8033 fprintf (file
, _(" long-word relocation fixups:\n"));
8034 evax_bfd_print_relocation_records (file
, buf
+ lrelfixoff
, 4);
8036 if (qdotadroff
!= 0)
8038 fprintf (file
, _(" quad-word .address reference fixups:\n"));
8039 evax_bfd_print_address_fixups (file
, buf
+ qdotadroff
);
8041 if (ldotadroff
!= 0)
8043 fprintf (file
, _(" long-word .address reference fixups:\n"));
8044 evax_bfd_print_address_fixups (file
, buf
+ ldotadroff
);
8046 if (codeadroff
!= 0)
8048 fprintf (file
, _(" Code Address Reference Fixups:\n"));
8049 evax_bfd_print_reference_fixups (file
, buf
+ codeadroff
);
8053 fprintf (file
, _(" Linkage Pairs Reference Fixups:\n"));
8054 evax_bfd_print_reference_fixups (file
, buf
+ lpfixoff
);
8058 unsigned int count
= (unsigned)bfd_getl32 (buf
+ chgprtoff
);
8059 struct vms_eicp
*eicp
= (struct vms_eicp
*)(buf
+ chgprtoff
+ 4);
8062 fprintf (file
, _(" Change Protection (%u entries):\n"), count
);
8063 for (j
= 0; j
< count
; j
++, eicp
++)
8065 unsigned int prot
= bfd_getl32 (eicp
->newprt
);
8067 /* xgettext:c-format */
8068 _(" base: 0x%08x %08x, size: 0x%08x, prot: 0x%08x "),
8069 (unsigned)bfd_getl32 (eicp
->baseva
+ 4),
8070 (unsigned)bfd_getl32 (eicp
->baseva
+ 0),
8071 (unsigned)bfd_getl32 (eicp
->size
),
8072 (unsigned)bfd_getl32 (eicp
->newprt
));
8076 fprintf (file
, "NA");
8078 case PRT__C_RESERVED
:
8079 fprintf (file
, "RES");
8082 fprintf (file
, "KW");
8085 fprintf (file
, "KR");
8088 fprintf (file
, "UW");
8091 fprintf (file
, "EW");
8094 fprintf (file
, "ERKW");
8097 fprintf (file
, "ER");
8100 fprintf (file
, "SW");
8103 fprintf (file
, "SREW");
8106 fprintf (file
, "SRKW");
8109 fprintf (file
, "SR");
8112 fprintf (file
, "URSW");
8115 fprintf (file
, "UREW");
8118 fprintf (file
, "URKW");
8121 fprintf (file
, "UR");
8135 vms_bfd_print_private_bfd_data (bfd
*abfd
, void *ptr
)
8137 FILE *file
= (FILE *)ptr
;
8139 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
8140 evax_bfd_print_image (abfd
, file
);
8143 if (bfd_seek (abfd
, 0, SEEK_SET
))
8145 evax_bfd_print_eobj (abfd
, file
);
8152 /* Slurp ETIR/EDBG/ETBT VMS object records. */
8155 alpha_vms_read_sections_content (bfd
*abfd
, struct bfd_link_info
*info
)
8157 asection
*cur_section
;
8158 file_ptr cur_offset
;
8159 asection
*dst_section
;
8160 file_ptr dst_offset
;
8162 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
8168 dst_section
= PRIV (dst_section
);
8172 if (info
->strip
== strip_all
|| info
->strip
== strip_debugger
)
8174 /* Discard the DST section. */
8178 else if (dst_section
)
8180 dst_offset
= dst_section
->output_offset
;
8181 dst_section
= dst_section
->output_section
;
8190 type
= _bfd_vms_get_object_record (abfd
);
8193 vms_debug2 ((2, "next_record failed\n"));
8199 PRIV (image_section
) = cur_section
;
8200 PRIV (image_offset
) = cur_offset
;
8201 res
= _bfd_vms_slurp_etir (abfd
, info
);
8202 cur_section
= PRIV (image_section
);
8203 cur_offset
= PRIV (image_offset
);
8207 if (dst_section
== NULL
)
8209 PRIV (image_section
) = dst_section
;
8210 PRIV (image_offset
) = dst_offset
;
8211 res
= _bfd_vms_slurp_etir (abfd
, info
);
8212 dst_offset
= PRIV (image_offset
);
8221 vms_debug2 ((2, "slurp eobj type %d failed\n", type
));
8228 alpha_vms_sizeof_headers (bfd
*abfd ATTRIBUTE_UNUSED
,
8229 struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8234 /* Add a linkage pair fixup at address SECT + OFFSET to SHLIB. */
8237 alpha_vms_add_fixup_lp (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
8239 struct alpha_vms_shlib_el
*sl
;
8240 asection
*sect
= PRIV2 (src
, image_section
);
8241 file_ptr offset
= PRIV2 (src
, image_offset
);
8243 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8244 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8245 sl
->has_fixups
= TRUE
;
8246 VEC_APPEND_EL (sl
->lp
, bfd_vma
,
8247 sect
->output_section
->vma
+ sect
->output_offset
+ offset
);
8248 sect
->output_section
->flags
|= SEC_RELOC
;
8251 /* Add a code address fixup at address SECT + OFFSET to SHLIB. */
8254 alpha_vms_add_fixup_ca (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
8256 struct alpha_vms_shlib_el
*sl
;
8257 asection
*sect
= PRIV2 (src
, image_section
);
8258 file_ptr offset
= PRIV2 (src
, image_offset
);
8260 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8261 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8262 sl
->has_fixups
= TRUE
;
8263 VEC_APPEND_EL (sl
->ca
, bfd_vma
,
8264 sect
->output_section
->vma
+ sect
->output_offset
+ offset
);
8265 sect
->output_section
->flags
|= SEC_RELOC
;
8268 /* Add a quad word relocation fixup at address SECT + OFFSET to SHLIB. */
8271 alpha_vms_add_fixup_qr (struct bfd_link_info
*info
, bfd
*src
,
8272 bfd
*shlib
, bfd_vma vec
)
8274 struct alpha_vms_shlib_el
*sl
;
8275 struct alpha_vms_vma_ref
*r
;
8276 asection
*sect
= PRIV2 (src
, image_section
);
8277 file_ptr offset
= PRIV2 (src
, image_offset
);
8279 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8280 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8281 sl
->has_fixups
= TRUE
;
8282 r
= VEC_APPEND (sl
->qr
, struct alpha_vms_vma_ref
);
8283 r
->vma
= sect
->output_section
->vma
+ sect
->output_offset
+ offset
;
8285 sect
->output_section
->flags
|= SEC_RELOC
;
8289 alpha_vms_add_fixup_lr (struct bfd_link_info
*info ATTRIBUTE_UNUSED
,
8290 unsigned int shr ATTRIBUTE_UNUSED
,
8291 bfd_vma vec ATTRIBUTE_UNUSED
)
8293 /* Not yet supported. */
8297 /* Add relocation. FIXME: Not yet emitted. */
8300 alpha_vms_add_lw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8305 alpha_vms_add_qw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8309 static struct bfd_hash_entry
*
8310 alpha_vms_link_hash_newfunc (struct bfd_hash_entry
*entry
,
8311 struct bfd_hash_table
*table
,
8314 struct alpha_vms_link_hash_entry
*ret
=
8315 (struct alpha_vms_link_hash_entry
*) entry
;
8317 /* Allocate the structure if it has not already been allocated by a
8320 ret
= ((struct alpha_vms_link_hash_entry
*)
8321 bfd_hash_allocate (table
,
8322 sizeof (struct alpha_vms_link_hash_entry
)));
8326 /* Call the allocation method of the superclass. */
8327 ret
= ((struct alpha_vms_link_hash_entry
*)
8328 _bfd_link_hash_newfunc ((struct bfd_hash_entry
*) ret
,
8333 return (struct bfd_hash_entry
*) ret
;
8336 /* Create an Alpha/VMS link hash table. */
8338 static struct bfd_link_hash_table
*
8339 alpha_vms_bfd_link_hash_table_create (bfd
*abfd
)
8341 struct alpha_vms_link_hash_table
*ret
;
8342 bfd_size_type amt
= sizeof (struct alpha_vms_link_hash_table
);
8344 ret
= (struct alpha_vms_link_hash_table
*) bfd_malloc (amt
);
8347 if (!_bfd_link_hash_table_init (&ret
->root
, abfd
,
8348 alpha_vms_link_hash_newfunc
,
8349 sizeof (struct alpha_vms_link_hash_entry
)))
8355 VEC_INIT (ret
->shrlibs
);
8362 alpha_vms_link_add_object_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8366 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
8368 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
8369 struct alpha_vms_link_hash_entry
*h
;
8370 struct bfd_link_hash_entry
*h_root
;
8373 if (!alpha_vms_convert_symbol (abfd
, e
, &sym
))
8376 if ((e
->flags
& EGSY__V_DEF
) && abfd
->selective_search
)
8378 /* In selective_search mode, only add definition that are
8380 h
= (struct alpha_vms_link_hash_entry
*)bfd_link_hash_lookup
8381 (info
->hash
, sym
.name
, FALSE
, FALSE
, FALSE
);
8382 if (h
== NULL
|| h
->root
.type
!= bfd_link_hash_undefined
)
8388 h_root
= (struct bfd_link_hash_entry
*) h
;
8389 if (!_bfd_generic_link_add_one_symbol (info
, abfd
, sym
.name
, sym
.flags
,
8390 sym
.section
, sym
.value
, NULL
,
8391 FALSE
, FALSE
, &h_root
))
8393 h
= (struct alpha_vms_link_hash_entry
*) h_root
;
8395 if ((e
->flags
& EGSY__V_DEF
)
8397 && abfd
->xvec
== info
->output_bfd
->xvec
)
8401 if (abfd
->flags
& DYNAMIC
)
8403 struct alpha_vms_shlib_el
*shlib
;
8405 /* We do not want to include any of the sections in a dynamic
8406 object in the output file. See comment in elflink.c. */
8407 bfd_section_list_clear (abfd
);
8409 shlib
= VEC_APPEND (alpha_vms_link_hash (info
)->shrlibs
,
8410 struct alpha_vms_shlib_el
);
8412 VEC_INIT (shlib
->ca
);
8413 VEC_INIT (shlib
->lp
);
8414 VEC_INIT (shlib
->qr
);
8415 PRIV (shr_index
) = VEC_COUNT (alpha_vms_link_hash (info
)->shrlibs
) - 1;
8422 alpha_vms_link_add_archive_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8425 struct bfd_link_hash_entry
**pundef
;
8426 struct bfd_link_hash_entry
**next_pundef
;
8428 /* We only accept VMS libraries. */
8429 if (info
->output_bfd
->xvec
!= abfd
->xvec
)
8431 bfd_set_error (bfd_error_wrong_format
);
8435 /* The archive_pass field in the archive itself is used to
8436 initialize PASS, since we may search the same archive multiple
8438 pass
= ++abfd
->archive_pass
;
8440 /* Look through the list of undefined symbols. */
8441 for (pundef
= &info
->hash
->undefs
; *pundef
!= NULL
; pundef
= next_pundef
)
8443 struct bfd_link_hash_entry
*h
;
8449 next_pundef
= &(*pundef
)->u
.undef
.next
;
8451 /* When a symbol is defined, it is not necessarily removed from
8453 if (h
->type
!= bfd_link_hash_undefined
8454 && h
->type
!= bfd_link_hash_common
)
8456 /* Remove this entry from the list, for general cleanliness
8457 and because we are going to look through the list again
8458 if we search any more libraries. We can't remove the
8459 entry if it is the tail, because that would lose any
8460 entries we add to the list later on. */
8461 if (*pundef
!= info
->hash
->undefs_tail
)
8463 *pundef
= *next_pundef
;
8464 next_pundef
= pundef
;
8469 /* Look for this symbol in the archive hash table. */
8470 symidx
= _bfd_vms_lib_find_symbol (abfd
, h
->root
.string
);
8471 if (symidx
== BFD_NO_MORE_SYMBOLS
)
8473 /* Nothing in this slot. */
8477 element
= bfd_get_elt_at_index (abfd
, symidx
);
8478 if (element
== NULL
)
8481 if (element
->archive_pass
== -1 || element
->archive_pass
== pass
)
8483 /* Next symbol if this archive is wrong or already handled. */
8487 if (! bfd_check_format (element
, bfd_object
))
8489 element
->archive_pass
= -1;
8493 orig_element
= element
;
8494 if (bfd_is_thin_archive (abfd
))
8496 element
= _bfd_vms_lib_get_imagelib_file (element
);
8497 if (element
== NULL
|| !bfd_check_format (element
, bfd_object
))
8499 orig_element
->archive_pass
= -1;
8504 /* Unlike the generic linker, we know that this element provides
8505 a definition for an undefined symbol and we know that we want
8506 to include it. We don't need to check anything. */
8507 if (!(*info
->callbacks
8508 ->add_archive_element
) (info
, element
, h
->root
.string
, &element
))
8510 if (!alpha_vms_link_add_object_symbols (element
, info
))
8513 orig_element
->archive_pass
= pass
;
8520 alpha_vms_bfd_link_add_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8522 switch (bfd_get_format (abfd
))
8525 vms_debug2 ((2, "vms_link_add_symbols for object %s\n",
8527 return alpha_vms_link_add_object_symbols (abfd
, info
);
8530 vms_debug2 ((2, "vms_link_add_symbols for archive %s\n",
8532 return alpha_vms_link_add_archive_symbols (abfd
, info
);
8535 bfd_set_error (bfd_error_wrong_format
);
8541 alpha_vms_build_fixups (struct bfd_link_info
*info
)
8543 struct alpha_vms_link_hash_table
*t
= alpha_vms_link_hash (info
);
8544 unsigned char *content
;
8546 unsigned int sz
= 0;
8547 unsigned int lp_sz
= 0;
8548 unsigned int ca_sz
= 0;
8549 unsigned int qr_sz
= 0;
8550 unsigned int shrimg_cnt
= 0;
8551 unsigned int chgprt_num
= 0;
8552 unsigned int chgprt_sz
= 0;
8553 struct vms_eiaf
*eiaf
;
8557 /* Shared libraries. */
8558 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8560 struct alpha_vms_shlib_el
*shlib
;
8562 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8564 if (!shlib
->has_fixups
)
8569 if (VEC_COUNT (shlib
->ca
) > 0)
8571 /* Header + entries. */
8573 ca_sz
+= VEC_COUNT (shlib
->ca
) * 4;
8575 if (VEC_COUNT (shlib
->lp
) > 0)
8577 /* Header + entries. */
8579 lp_sz
+= VEC_COUNT (shlib
->lp
) * 4;
8581 if (VEC_COUNT (shlib
->qr
) > 0)
8583 /* Header + entries. */
8585 qr_sz
+= VEC_COUNT (shlib
->qr
) * 8;
8596 /* Finish now if there is no content. */
8597 if (ca_sz
+ lp_sz
+ qr_sz
== 0)
8600 /* Add an eicp entry for the fixup itself. */
8602 for (sec
= info
->output_bfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
8604 /* This isect could be made RO or EXE after relocations are applied. */
8605 if ((sec
->flags
& SEC_RELOC
) != 0
8606 && (sec
->flags
& (SEC_CODE
| SEC_READONLY
)) != 0)
8609 chgprt_sz
= 4 + chgprt_num
* sizeof (struct vms_eicp
);
8611 /* Allocate section content (round-up size) */
8612 sz
= sizeof (struct vms_eiaf
) + shrimg_cnt
* sizeof (struct vms_shl
)
8613 + ca_sz
+ lp_sz
+ qr_sz
+ chgprt_sz
;
8614 sz
= (sz
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
8615 content
= bfd_zalloc (info
->output_bfd
, sz
);
8616 if (content
== NULL
)
8619 sec
= alpha_vms_link_hash (info
)->fixup
;
8620 sec
->contents
= content
;
8623 eiaf
= (struct vms_eiaf
*)content
;
8624 off
= sizeof (struct vms_eiaf
);
8625 bfd_putl32 (0, eiaf
->majorid
);
8626 bfd_putl32 (0, eiaf
->minorid
);
8627 bfd_putl32 (0, eiaf
->iaflink
);
8628 bfd_putl32 (0, eiaf
->fixuplnk
);
8629 bfd_putl32 (sizeof (struct vms_eiaf
), eiaf
->size
);
8630 bfd_putl32 (0, eiaf
->flags
);
8631 bfd_putl32 (0, eiaf
->qrelfixoff
);
8632 bfd_putl32 (0, eiaf
->lrelfixoff
);
8633 bfd_putl32 (0, eiaf
->qdotadroff
);
8634 bfd_putl32 (0, eiaf
->ldotadroff
);
8635 bfd_putl32 (0, eiaf
->codeadroff
);
8636 bfd_putl32 (0, eiaf
->lpfixoff
);
8637 bfd_putl32 (0, eiaf
->chgprtoff
);
8638 bfd_putl32 (shrimg_cnt
? off
: 0, eiaf
->shlstoff
);
8639 bfd_putl32 (shrimg_cnt
, eiaf
->shrimgcnt
);
8640 bfd_putl32 (0, eiaf
->shlextra
);
8641 bfd_putl32 (0, eiaf
->permctx
);
8642 bfd_putl32 (0, eiaf
->base_va
);
8643 bfd_putl32 (0, eiaf
->lppsbfixoff
);
8650 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8652 struct alpha_vms_shlib_el
*shlib
;
8653 struct vms_shl
*shl
;
8655 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8657 if (!shlib
->has_fixups
)
8660 /* Renumber shared images. */
8661 PRIV2 (shlib
->abfd
, shr_index
) = shrimg_cnt
++;
8663 shl
= (struct vms_shl
*)(content
+ off
);
8664 bfd_putl32 (0, shl
->baseva
);
8665 bfd_putl32 (0, shl
->shlptr
);
8666 bfd_putl32 (0, shl
->ident
);
8667 bfd_putl32 (0, shl
->permctx
);
8668 shl
->size
= sizeof (struct vms_shl
);
8669 bfd_putl16 (0, shl
->fill_1
);
8671 bfd_putl32 (0, shl
->icb
);
8672 shl
->imgnam
[0] = strlen (PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
));
8673 memcpy (shl
->imgnam
+ 1, PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
),
8676 off
+= sizeof (struct vms_shl
);
8682 bfd_putl32 (off
, eiaf
->codeadroff
);
8684 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8686 struct alpha_vms_shlib_el
*shlib
;
8689 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8691 if (VEC_COUNT (shlib
->ca
) == 0)
8694 bfd_putl32 (VEC_COUNT (shlib
->ca
), content
+ off
);
8695 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8698 for (j
= 0; j
< VEC_COUNT (shlib
->ca
); j
++)
8700 bfd_putl32 (VEC_EL (shlib
->ca
, bfd_vma
, j
) - t
->base_addr
,
8706 bfd_putl32 (0, content
+ off
);
8707 bfd_putl32 (0, content
+ off
+ 4);
8714 bfd_putl32 (off
, eiaf
->lpfixoff
);
8716 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8718 struct alpha_vms_shlib_el
*shlib
;
8721 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8723 if (VEC_COUNT (shlib
->lp
) == 0)
8726 bfd_putl32 (VEC_COUNT (shlib
->lp
), content
+ off
);
8727 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8730 for (j
= 0; j
< VEC_COUNT (shlib
->lp
); j
++)
8732 bfd_putl32 (VEC_EL (shlib
->lp
, bfd_vma
, j
) - t
->base_addr
,
8738 bfd_putl32 (0, content
+ off
);
8739 bfd_putl32 (0, content
+ off
+ 4);
8746 bfd_putl32 (off
, eiaf
->qdotadroff
);
8748 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8750 struct alpha_vms_shlib_el
*shlib
;
8753 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8755 if (VEC_COUNT (shlib
->qr
) == 0)
8758 bfd_putl32 (VEC_COUNT (shlib
->qr
), content
+ off
);
8759 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8762 for (j
= 0; j
< VEC_COUNT (shlib
->qr
); j
++)
8764 struct alpha_vms_vma_ref
*r
;
8765 r
= &VEC_EL (shlib
->qr
, struct alpha_vms_vma_ref
, j
);
8766 bfd_putl32 (r
->vma
- t
->base_addr
, content
+ off
);
8767 bfd_putl32 (r
->ref
, content
+ off
+ 4);
8772 bfd_putl32 (0, content
+ off
);
8773 bfd_putl32 (0, content
+ off
+ 4);
8778 /* Write the change protection table. */
8779 bfd_putl32 (off
, eiaf
->chgprtoff
);
8780 bfd_putl32 (chgprt_num
, content
+ off
);
8783 for (sec
= info
->output_bfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
8785 struct vms_eicp
*eicp
;
8788 if ((sec
->flags
& SEC_LINKER_CREATED
) != 0 &&
8789 strcmp (sec
->name
, "$FIXUP$") == 0)
8791 else if ((sec
->flags
& SEC_RELOC
) != 0
8792 && (sec
->flags
& (SEC_CODE
| SEC_READONLY
)) != 0)
8797 eicp
= (struct vms_eicp
*)(content
+ off
);
8798 bfd_putl64 (sec
->vma
- t
->base_addr
, eicp
->baseva
);
8799 bfd_putl32 ((sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1),
8801 bfd_putl32 (prot
, eicp
->newprt
);
8802 off
+= sizeof (struct vms_eicp
);
8808 /* Called by bfd_hash_traverse to fill the symbol table.
8809 Return FALSE in case of failure. */
8812 alpha_vms_link_output_symbol (struct bfd_hash_entry
*bh
, void *infov
)
8814 struct bfd_link_hash_entry
*hc
= (struct bfd_link_hash_entry
*) bh
;
8815 struct bfd_link_info
*info
= (struct bfd_link_info
*)infov
;
8816 struct alpha_vms_link_hash_entry
*h
;
8817 struct vms_symbol_entry
*sym
;
8819 if (hc
->type
== bfd_link_hash_warning
)
8822 if (hc
->type
== bfd_link_hash_new
)
8825 h
= (struct alpha_vms_link_hash_entry
*) hc
;
8827 switch (h
->root
.type
)
8829 case bfd_link_hash_undefined
:
8831 case bfd_link_hash_new
:
8832 case bfd_link_hash_warning
:
8834 case bfd_link_hash_undefweak
:
8836 case bfd_link_hash_defined
:
8837 case bfd_link_hash_defweak
:
8839 asection
*sec
= h
->root
.u
.def
.section
;
8841 /* FIXME: this is certainly a symbol from a dynamic library. */
8842 if (bfd_is_abs_section (sec
))
8845 if (sec
->owner
->flags
& DYNAMIC
)
8849 case bfd_link_hash_common
:
8851 case bfd_link_hash_indirect
:
8855 /* Do not write not kept symbols. */
8856 if (info
->strip
== strip_some
8857 && bfd_hash_lookup (info
->keep_hash
, h
->root
.root
.string
,
8858 FALSE
, FALSE
) != NULL
)
8863 /* This symbol doesn't come from a VMS object. So we suppose it is
8865 int len
= strlen (h
->root
.root
.string
);
8867 sym
= (struct vms_symbol_entry
*)bfd_zalloc (info
->output_bfd
,
8868 sizeof (*sym
) + len
);
8872 memcpy (sym
->name
, h
->root
.root
.string
, len
);
8874 sym
->owner
= info
->output_bfd
;
8876 sym
->typ
= EGSD__C_SYMG
;
8878 sym
->flags
= EGSY__V_DEF
| EGSY__V_REL
;
8879 sym
->symbol_vector
= h
->root
.u
.def
.value
;
8880 sym
->section
= h
->root
.u
.def
.section
;
8881 sym
->value
= h
->root
.u
.def
.value
;
8886 if (!add_symbol_entry (info
->output_bfd
, sym
))
8893 alpha_vms_bfd_final_link (bfd
*abfd
, struct bfd_link_info
*info
)
8896 struct bfd_link_order
*p
;
8904 if (bfd_link_relocatable (info
))
8906 /* FIXME: we do not yet support relocatable link. It is not obvious
8907 how to do it for debug infos. */
8908 (*info
->callbacks
->einfo
)(_("%P: relocatable link is not supported\n"));
8912 bfd_get_outsymbols (abfd
) = NULL
;
8913 bfd_get_symcount (abfd
) = 0;
8915 /* Mark all sections which will be included in the output file. */
8916 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8917 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
8918 if (p
->type
== bfd_indirect_link_order
)
8919 p
->u
.indirect
.section
->linker_mark
= TRUE
;
8922 /* Handle all the link order information for the sections. */
8923 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8925 printf ("For section %s (at 0x%08x, flags=0x%08x):\n",
8926 o
->name
, (unsigned)o
->vma
, (unsigned)o
->flags
);
8928 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
8930 printf (" at 0x%08x - 0x%08x: ",
8931 (unsigned)p
->offset
, (unsigned)(p
->offset
+ p
->size
- 1));
8934 case bfd_section_reloc_link_order
:
8935 case bfd_symbol_reloc_link_order
:
8936 printf (" section/symbol reloc\n");
8938 case bfd_indirect_link_order
:
8939 printf (" section %s of %s\n",
8940 p
->u
.indirect
.section
->name
,
8941 p
->u
.indirect
.section
->owner
->filename
);
8943 case bfd_data_link_order
:
8944 printf (" explicit data\n");
8947 printf (" *unknown* type %u\n", p
->type
);
8954 /* Generate the symbol table. */
8955 BFD_ASSERT (PRIV (syms
) == NULL
);
8956 if (info
->strip
!= strip_all
)
8957 bfd_hash_traverse (&info
->hash
->table
, alpha_vms_link_output_symbol
, info
);
8959 /* Find the entry point. */
8960 if (bfd_get_start_address (abfd
) == 0)
8962 bfd
*startbfd
= NULL
;
8964 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
8966 /* Consider only VMS object files. */
8967 if (sub
->xvec
!= abfd
->xvec
)
8970 if (!PRIV2 (sub
, eom_data
).eom_has_transfer
)
8972 if ((PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
) && startbfd
)
8974 if (startbfd
!= NULL
8975 && !(PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
))
8977 (*info
->callbacks
->einfo
)
8978 /* xgettext:c-format */
8979 (_("%P: multiple entry points: in modules %pB and %pB\n"),
8988 unsigned int ps_idx
= PRIV2 (startbfd
, eom_data
).eom_l_psindx
;
8989 bfd_vma tfradr
= PRIV2 (startbfd
, eom_data
).eom_l_tfradr
;
8992 sec
= PRIV2 (startbfd
, sections
)[ps_idx
];
8994 bfd_set_start_address
8995 (abfd
, sec
->output_section
->vma
+ sec
->output_offset
+ tfradr
);
8999 /* Set transfer addresses. */
9002 struct bfd_link_hash_entry
*h
;
9005 PRIV (transfer_address
[i
++]) = 0xffffffff00000340ULL
; /* SYS$IMGACT */
9006 h
= bfd_link_hash_lookup (info
->hash
, "LIB$INITIALIZE", FALSE
, FALSE
, TRUE
);
9007 if (h
!= NULL
&& h
->type
== bfd_link_hash_defined
)
9008 PRIV (transfer_address
[i
++]) =
9009 alpha_vms_get_sym_value (h
->u
.def
.section
, h
->u
.def
.value
);
9010 PRIV (transfer_address
[i
++]) = bfd_get_start_address (abfd
);
9012 PRIV (transfer_address
[i
++]) = 0;
9015 /* Allocate contents.
9016 Also compute the virtual base address. */
9017 base_addr
= (bfd_vma
)-1;
9019 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9021 if (o
->flags
& SEC_HAS_CONTENTS
)
9023 o
->contents
= bfd_alloc (abfd
, o
->size
);
9024 if (o
->contents
== NULL
)
9027 if (o
->flags
& SEC_LOAD
)
9029 if (o
->vma
< base_addr
)
9031 if (o
->vma
+ o
->size
> last_addr
)
9032 last_addr
= o
->vma
+ o
->size
;
9034 /* Clear the RELOC flags. Currently we don't support incremental
9035 linking. We use the RELOC flag for computing the eicp entries. */
9036 o
->flags
&= ~SEC_RELOC
;
9039 /* Create the fixup section. */
9040 fixupsec
= bfd_make_section_anyway_with_flags
9041 (info
->output_bfd
, "$FIXUP$",
9042 SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
9043 if (fixupsec
== NULL
)
9045 last_addr
= (last_addr
+ 0xffff) & ~0xffff;
9046 fixupsec
->vma
= last_addr
;
9048 alpha_vms_link_hash (info
)->fixup
= fixupsec
;
9049 alpha_vms_link_hash (info
)->base_addr
= base_addr
;
9051 /* Create the DMT section, if necessary. */
9052 BFD_ASSERT (PRIV (dst_section
) == NULL
);
9053 dst
= bfd_get_section_by_name (abfd
, "$DST$");
9054 if (dst
!= NULL
&& dst
->size
== 0)
9058 PRIV (dst_section
) = dst
;
9059 dmt
= bfd_make_section_anyway_with_flags
9060 (info
->output_bfd
, "$DMT$",
9061 SEC_DEBUGGING
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
9068 /* Read all sections from the inputs. */
9069 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9071 if (sub
->flags
& DYNAMIC
)
9073 alpha_vms_create_eisd_for_shared (abfd
, sub
);
9077 if (!alpha_vms_read_sections_content (sub
, info
))
9081 /* Handle all the link order information for the sections.
9082 Note: past this point, it is not possible to create new sections. */
9083 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9085 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
9089 case bfd_section_reloc_link_order
:
9090 case bfd_symbol_reloc_link_order
:
9093 case bfd_indirect_link_order
:
9097 if (! _bfd_default_link_order (abfd
, info
, o
, p
))
9104 /* Compute fixups. */
9105 if (!alpha_vms_build_fixups (info
))
9108 /* Compute the DMT. */
9112 unsigned char *contents
= NULL
;
9114 /* In pass 1, compute the size. In pass 2, write the DMT contents. */
9115 for (pass
= 0; pass
< 2; pass
++)
9117 unsigned int off
= 0;
9119 /* For each object file (ie for each module). */
9120 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9123 struct vms_dmt_header
*dmth
= NULL
;
9124 unsigned int psect_count
;
9126 /* Skip this module if it has no DST. */
9127 sub_dst
= PRIV2 (sub
, dst_section
);
9128 if (sub_dst
== NULL
|| sub_dst
->size
== 0)
9133 /* Write the header. */
9134 dmth
= (struct vms_dmt_header
*)(contents
+ off
);
9135 bfd_putl32 (sub_dst
->output_offset
, dmth
->modbeg
);
9136 bfd_putl32 (sub_dst
->size
, dmth
->size
);
9139 off
+= sizeof (struct vms_dmt_header
);
9142 /* For each section (ie for each psect). */
9143 for (o
= sub
->sections
; o
!= NULL
; o
= o
->next
)
9145 /* Only consider interesting sections. */
9146 if (!(o
->flags
& SEC_ALLOC
))
9148 if (o
->flags
& SEC_LINKER_CREATED
)
9153 /* Write an entry. */
9154 struct vms_dmt_psect
*dmtp
;
9156 dmtp
= (struct vms_dmt_psect
*)(contents
+ off
);
9157 bfd_putl32 (o
->output_offset
+ o
->output_section
->vma
,
9159 bfd_putl32 (o
->size
, dmtp
->length
);
9162 off
+= sizeof (struct vms_dmt_psect
);
9165 bfd_putl32 (psect_count
, dmth
->psect_count
);
9170 contents
= bfd_zalloc (info
->output_bfd
, off
);
9171 if (contents
== NULL
)
9173 dmt
->contents
= contents
;
9178 BFD_ASSERT (off
== dmt
->size
);
9186 /* Read the contents of a section.
9187 buf points to a buffer of buf_size bytes to be filled with
9188 section data (starting at offset into section) */
9191 alpha_vms_get_section_contents (bfd
*abfd
, asection
*section
,
9192 void *buf
, file_ptr offset
,
9193 bfd_size_type count
)
9197 /* Image are easy. */
9198 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
9199 return _bfd_generic_get_section_contents (abfd
, section
,
9200 buf
, offset
, count
);
9203 if (offset
+ count
< count
9204 || offset
+ count
> section
->size
)
9206 bfd_set_error (bfd_error_invalid_operation
);
9210 /* If the section is already in memory, just copy it. */
9211 if (section
->flags
& SEC_IN_MEMORY
)
9213 BFD_ASSERT (section
->contents
!= NULL
);
9214 memcpy (buf
, section
->contents
+ offset
, count
);
9217 if (section
->size
== 0)
9220 /* Alloc in memory and read ETIRs. */
9221 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
9223 BFD_ASSERT (sec
->contents
== NULL
);
9225 if (sec
->size
!= 0 && (sec
->flags
& SEC_HAS_CONTENTS
))
9227 sec
->contents
= bfd_alloc (abfd
, sec
->size
);
9228 if (sec
->contents
== NULL
)
9232 if (!alpha_vms_read_sections_content (abfd
, NULL
))
9234 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
9236 sec
->flags
|= SEC_IN_MEMORY
;
9237 memcpy (buf
, section
->contents
+ offset
, count
);
9242 /* Set the format of a file being written. */
9245 alpha_vms_mkobject (bfd
* abfd
)
9247 const bfd_arch_info_type
*arch
;
9249 vms_debug2 ((1, "alpha_vms_mkobject (%p)\n", abfd
));
9251 if (!vms_initialize (abfd
))
9254 PRIV (recwr
.buf
) = bfd_alloc (abfd
, MAX_OUTREC_SIZE
);
9255 if (PRIV (recwr
.buf
) == NULL
)
9258 arch
= bfd_scan_arch ("alpha");
9262 bfd_set_error (bfd_error_wrong_format
);
9266 abfd
->arch_info
= arch
;
9273 /* Called when the BFD is being closed to do any necessary cleanup. */
9276 vms_close_and_cleanup (bfd
* abfd
)
9278 vms_debug2 ((1, "vms_close_and_cleanup (%p)\n", abfd
));
9280 if (abfd
== NULL
|| abfd
->tdata
.any
== NULL
)
9283 if (abfd
->format
== bfd_archive
)
9285 bfd_release (abfd
, abfd
->tdata
.any
);
9286 abfd
->tdata
.any
= NULL
;
9290 if (PRIV (recrd
.buf
) != NULL
)
9291 free (PRIV (recrd
.buf
));
9293 if (PRIV (sections
) != NULL
)
9294 free (PRIV (sections
));
9296 bfd_release (abfd
, abfd
->tdata
.any
);
9297 abfd
->tdata
.any
= NULL
;
9300 if (abfd
->direction
== write_direction
)
9302 /* Last step on VMS is to convert the file to variable record length
9304 if (!bfd_cache_close (abfd
))
9306 if (!_bfd_vms_convert_to_var_unix_filename (abfd
->filename
))
9314 /* Called when a new section is created. */
9317 vms_new_section_hook (bfd
* abfd
, asection
*section
)
9321 vms_debug2 ((1, "vms_new_section_hook (%p, [%u]%s)\n",
9322 abfd
, section
->index
, section
->name
));
9324 if (! bfd_set_section_alignment (abfd
, section
, 0))
9327 vms_debug2 ((7, "%u: %s\n", section
->index
, section
->name
));
9329 amt
= sizeof (struct vms_section_data_struct
);
9330 section
->used_by_bfd
= bfd_zalloc (abfd
, amt
);
9331 if (section
->used_by_bfd
== NULL
)
9334 /* Create the section symbol. */
9335 return _bfd_generic_new_section_hook (abfd
, section
);
9338 /* Part 4.5, symbols. */
9340 /* Print symbol to file according to how. how is one of
9341 bfd_print_symbol_name just print the name
9342 bfd_print_symbol_more print more (???)
9343 bfd_print_symbol_all print all we know, which is not much right now :-). */
9346 vms_print_symbol (bfd
* abfd
,
9349 bfd_print_symbol_type how
)
9351 vms_debug2 ((1, "vms_print_symbol (%p, %p, %p, %d)\n",
9352 abfd
, file
, symbol
, how
));
9356 case bfd_print_symbol_name
:
9357 case bfd_print_symbol_more
:
9358 fprintf ((FILE *)file
," %s", symbol
->name
);
9361 case bfd_print_symbol_all
:
9363 const char *section_name
= symbol
->section
->name
;
9365 bfd_print_symbol_vandf (abfd
, file
, symbol
);
9367 fprintf ((FILE *) file
," %-8s %s", section_name
, symbol
->name
);
9373 /* Return information about symbol in ret.
9375 fill type, value and name
9378 B bss segment symbol
9380 D data segment symbol
9382 t a static function symbol
9383 T text segment symbol
9388 vms_get_symbol_info (bfd
* abfd ATTRIBUTE_UNUSED
,
9394 vms_debug2 ((1, "vms_get_symbol_info (%p, %p, %p)\n", abfd
, symbol
, ret
));
9396 sec
= symbol
->section
;
9403 else if (bfd_is_com_section (sec
))
9405 else if (bfd_is_abs_section (sec
))
9407 else if (bfd_is_und_section (sec
))
9409 else if (bfd_is_ind_section (sec
))
9411 else if ((symbol
->flags
& BSF_FUNCTION
)
9412 || (bfd_get_section_flags (abfd
, sec
) & SEC_CODE
))
9414 else if (bfd_get_section_flags (abfd
, sec
) & SEC_DATA
)
9416 else if (bfd_get_section_flags (abfd
, sec
) & SEC_ALLOC
)
9421 if (ret
->type
!= 'U')
9422 ret
->value
= symbol
->value
+ symbol
->section
->vma
;
9425 ret
->name
= symbol
->name
;
9428 /* Return TRUE if the given symbol sym in the BFD abfd is
9429 a compiler generated local label, else return FALSE. */
9432 vms_bfd_is_local_label_name (bfd
* abfd ATTRIBUTE_UNUSED
,
9435 return name
[0] == '$';
9438 /* Part 4.7, writing an object file. */
9440 /* Sets the contents of the section section in BFD abfd to the data starting
9441 in memory at LOCATION. The data is written to the output section starting
9442 at offset offset for count bytes.
9444 Normally TRUE is returned, else FALSE. Possible error returns are:
9445 o bfd_error_no_contents - The output section does not have the
9446 SEC_HAS_CONTENTS attribute, so nothing can be written to it.
9447 o and some more too */
9450 _bfd_vms_set_section_contents (bfd
* abfd
,
9452 const void * location
,
9454 bfd_size_type count
)
9456 if (section
->contents
== NULL
)
9458 section
->contents
= bfd_alloc (abfd
, section
->size
);
9459 if (section
->contents
== NULL
)
9462 memcpy (section
->contents
+ offset
, location
, (size_t) count
);
9468 /* Set the architecture and machine type in BFD abfd to arch and mach.
9469 Find the correct pointer to a structure and insert it into the arch_info
9473 alpha_vms_set_arch_mach (bfd
*abfd
,
9474 enum bfd_architecture arch
, unsigned long mach
)
9476 if (arch
!= bfd_arch_alpha
9477 && arch
!= bfd_arch_unknown
)
9480 return bfd_default_set_arch_mach (abfd
, arch
, mach
);
9483 /* Set section VMS flags. Clear NO_FLAGS and set FLAGS. */
9486 bfd_vms_set_section_flags (bfd
*abfd ATTRIBUTE_UNUSED
,
9487 asection
*sec
, flagword no_flags
, flagword flags
)
9489 vms_section_data (sec
)->no_flags
= no_flags
;
9490 vms_section_data (sec
)->flags
= flags
;
9493 struct vms_private_data_struct
*
9494 bfd_vms_get_data (bfd
*abfd
)
9496 return (struct vms_private_data_struct
*)abfd
->tdata
.any
;
9499 #define vms_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false
9500 #define vms_bfd_link_just_syms _bfd_generic_link_just_syms
9501 #define vms_bfd_copy_link_hash_symbol_type \
9502 _bfd_generic_copy_link_hash_symbol_type
9503 #define vms_bfd_is_group_section bfd_generic_is_group_section
9504 #define vms_bfd_discard_group bfd_generic_discard_group
9505 #define vms_section_already_linked _bfd_generic_section_already_linked
9506 #define vms_bfd_define_common_symbol bfd_generic_define_common_symbol
9507 #define vms_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
9508 #define vms_bfd_define_start_stop bfd_generic_define_start_stop
9509 #define vms_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
9511 #define vms_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
9512 #define vms_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
9513 #define vms_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data
9514 #define vms_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
9515 #define vms_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
9516 #define vms_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
9518 /* Symbols table. */
9519 #define alpha_vms_make_empty_symbol _bfd_generic_make_empty_symbol
9520 #define alpha_vms_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false
9521 #define alpha_vms_print_symbol vms_print_symbol
9522 #define alpha_vms_get_symbol_info vms_get_symbol_info
9523 #define alpha_vms_get_symbol_version_string \
9524 _bfd_nosymbols_get_symbol_version_string
9526 #define alpha_vms_read_minisymbols _bfd_generic_read_minisymbols
9527 #define alpha_vms_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
9528 #define alpha_vms_get_lineno _bfd_nosymbols_get_lineno
9529 #define alpha_vms_find_inliner_info _bfd_nosymbols_find_inliner_info
9530 #define alpha_vms_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
9531 #define alpha_vms_find_nearest_line _bfd_vms_find_nearest_line
9532 #define alpha_vms_find_line _bfd_nosymbols_find_line
9533 #define alpha_vms_bfd_is_local_label_name vms_bfd_is_local_label_name
9535 /* Generic table. */
9536 #define alpha_vms_close_and_cleanup vms_close_and_cleanup
9537 #define alpha_vms_bfd_free_cached_info vms_bfd_free_cached_info
9538 #define alpha_vms_new_section_hook vms_new_section_hook
9539 #define alpha_vms_set_section_contents _bfd_vms_set_section_contents
9540 #define alpha_vms_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
9542 #define alpha_vms_bfd_get_relocated_section_contents \
9543 bfd_generic_get_relocated_section_contents
9545 #define alpha_vms_bfd_relax_section bfd_generic_relax_section
9546 #define alpha_vms_bfd_gc_sections bfd_generic_gc_sections
9547 #define alpha_vms_bfd_lookup_section_flags bfd_generic_lookup_section_flags
9548 #define alpha_vms_bfd_merge_sections bfd_generic_merge_sections
9549 #define alpha_vms_bfd_is_group_section bfd_generic_is_group_section
9550 #define alpha_vms_bfd_discard_group bfd_generic_discard_group
9551 #define alpha_vms_section_already_linked \
9552 _bfd_generic_section_already_linked
9554 #define alpha_vms_bfd_define_common_symbol bfd_generic_define_common_symbol
9555 #define alpha_vms_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
9556 #define alpha_vms_bfd_define_start_stop bfd_generic_define_start_stop
9557 #define alpha_vms_bfd_link_just_syms _bfd_generic_link_just_syms
9558 #define alpha_vms_bfd_copy_link_hash_symbol_type \
9559 _bfd_generic_copy_link_hash_symbol_type
9561 #define alpha_vms_bfd_link_split_section _bfd_generic_link_split_section
9563 #define alpha_vms_get_dynamic_symtab_upper_bound \
9564 _bfd_nodynamic_get_dynamic_symtab_upper_bound
9565 #define alpha_vms_canonicalize_dynamic_symtab \
9566 _bfd_nodynamic_canonicalize_dynamic_symtab
9567 #define alpha_vms_get_dynamic_reloc_upper_bound \
9568 _bfd_nodynamic_get_dynamic_reloc_upper_bound
9569 #define alpha_vms_canonicalize_dynamic_reloc \
9570 _bfd_nodynamic_canonicalize_dynamic_reloc
9571 #define alpha_vms_bfd_link_check_relocs _bfd_generic_link_check_relocs
9573 const bfd_target alpha_vms_vec
=
9575 "vms-alpha", /* Name. */
9576 bfd_target_evax_flavour
,
9577 BFD_ENDIAN_LITTLE
, /* Data byte order is little. */
9578 BFD_ENDIAN_LITTLE
, /* Header byte order is little. */
9580 (HAS_RELOC
| EXEC_P
| HAS_LINENO
| HAS_DEBUG
| HAS_SYMS
| HAS_LOCALS
9581 | WP_TEXT
| D_PAGED
), /* Object flags. */
9582 (SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
9583 | SEC_READONLY
| SEC_CODE
| SEC_DATA
9584 | SEC_HAS_CONTENTS
| SEC_IN_MEMORY
), /* Sect flags. */
9585 0, /* symbol_leading_char. */
9586 ' ', /* ar_pad_char. */
9587 15, /* ar_max_namelen. */
9588 0, /* match priority. */
9589 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
9590 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
9591 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
9592 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
9593 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
9594 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
9596 { /* bfd_check_format. */
9599 _bfd_vms_lib_alpha_archive_p
,
9602 { /* bfd_set_format. */
9603 _bfd_bool_bfd_false_error
,
9605 _bfd_vms_lib_alpha_mkarchive
,
9606 _bfd_bool_bfd_false_error
9608 { /* bfd_write_contents. */
9609 _bfd_bool_bfd_false_error
,
9610 alpha_vms_write_object_contents
,
9611 _bfd_vms_lib_write_archive_contents
,
9612 _bfd_bool_bfd_false_error
9615 BFD_JUMP_TABLE_GENERIC (alpha_vms
),
9616 BFD_JUMP_TABLE_COPY (vms
),
9617 BFD_JUMP_TABLE_CORE (_bfd_nocore
),
9618 BFD_JUMP_TABLE_ARCHIVE (_bfd_vms_lib
),
9619 BFD_JUMP_TABLE_SYMBOLS (alpha_vms
),
9620 BFD_JUMP_TABLE_RELOCS (alpha_vms
),
9621 BFD_JUMP_TABLE_WRITE (alpha_vms
),
9622 BFD_JUMP_TABLE_LINK (alpha_vms
),
9623 BFD_JUMP_TABLE_DYNAMIC (alpha_vms
),