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 (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 (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 (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
, unsigned int max
)
1142 struct vms_symbol_entry
*entry
;
1149 _bfd_error_handler (_("record is too small for symbol name length"));
1150 bfd_set_error (bfd_error_bad_value
);
1154 entry
= (struct vms_symbol_entry
*)bfd_zalloc (abfd
, sizeof (*entry
) + len
);
1157 entry
->namelen
= len
;
1158 memcpy (entry
->name
, ascic
, len
);
1159 entry
->name
[len
] = 0;
1160 entry
->owner
= abfd
;
1162 if (!add_symbol_entry (abfd
, entry
))
1167 /* Read and process EGSD. Return FALSE on failure. */
1170 _bfd_vms_slurp_egsd (bfd
*abfd
)
1173 unsigned int gsd_size
;
1174 unsigned char *vms_rec
;
1175 unsigned long base_addr
;
1177 vms_debug2 ((2, "EGSD\n"));
1179 if (PRIV (recrd
.rec_size
) < 8)
1181 _bfd_error_handler (_("corrupt EGSD record: its size (%#x) is too small"),
1182 PRIV (recrd
.rec_size
));
1183 bfd_set_error (bfd_error_bad_value
);
1187 PRIV (recrd
.rec
) += 8; /* Skip type, size, align pad. */
1188 PRIV (recrd
.rec_size
) -= 8;
1190 /* Calculate base address for each section. */
1193 while (PRIV (recrd
.rec_size
) > 4)
1195 vms_rec
= PRIV (recrd
.rec
);
1197 gsd_type
= bfd_getl16 (vms_rec
);
1198 gsd_size
= bfd_getl16 (vms_rec
+ 2);
1200 vms_debug2 ((3, "egsd_type %d\n", gsd_type
));
1202 /* PR 21615: Check for size overflow. */
1203 if (PRIV (recrd
.rec_size
) < gsd_size
)
1205 _bfd_error_handler (_("corrupt EGSD record: size (%#x) is larger than remaining space (%#x)"),
1206 gsd_size
, PRIV (recrd
.rec_size
));
1207 bfd_set_error (bfd_error_bad_value
);
1213 _bfd_error_handler (_("corrupt EGSD record: size (%#x) is too small"),
1215 bfd_set_error (bfd_error_bad_value
);
1222 /* Program section definition. */
1224 struct vms_egps
*egps
= (struct vms_egps
*)vms_rec
;
1225 flagword new_flags
, vms_flags
;
1228 vms_flags
= bfd_getl16 (egps
->flags
);
1230 if ((vms_flags
& EGPS__V_REL
) == 0)
1232 /* Use the global absolute section for all
1233 absolute sections. */
1234 section
= bfd_abs_section_ptr
;
1239 unsigned long align_addr
;
1241 name
= _bfd_vms_save_counted_string (&egps
->namlng
, gsd_size
- 4);
1243 section
= bfd_make_section (abfd
, name
);
1247 section
->filepos
= 0;
1248 section
->size
= bfd_getl32 (egps
->alloc
);
1249 section
->alignment_power
= egps
->align
;
1251 vms_section_data (section
)->flags
= vms_flags
;
1252 vms_section_data (section
)->no_flags
= 0;
1254 new_flags
= vms_secflag_by_name (evax_section_flags
, name
,
1256 if (section
->size
> 0)
1257 new_flags
|= SEC_LOAD
;
1258 if (!(vms_flags
& EGPS__V_NOMOD
) && section
->size
> 0)
1260 /* Set RELOC and HAS_CONTENTS if the section is not
1261 demand-zero and not empty. */
1262 new_flags
|= SEC_HAS_CONTENTS
;
1263 if (vms_flags
& EGPS__V_REL
)
1264 new_flags
|= SEC_RELOC
;
1266 if (vms_flags
& EGPS__V_EXE
)
1268 /* Set CODE if section is executable. */
1269 new_flags
|= SEC_CODE
;
1270 new_flags
&= ~SEC_DATA
;
1272 if (!bfd_set_section_flags (section
, new_flags
))
1275 /* Give a non-overlapping vma to non absolute sections. */
1276 align_addr
= (1 << section
->alignment_power
);
1277 if ((base_addr
% align_addr
) != 0)
1278 base_addr
+= (align_addr
- (base_addr
% align_addr
));
1279 section
->vma
= (bfd_vma
)base_addr
;
1280 base_addr
+= section
->size
;
1283 /* Append it to the section array. */
1284 if (PRIV (section_count
) >= PRIV (section_max
))
1286 if (PRIV (section_max
) == 0)
1287 PRIV (section_max
) = 16;
1289 PRIV (section_max
) *= 2;
1290 PRIV (sections
) = bfd_realloc_or_free
1291 (PRIV (sections
), PRIV (section_max
) * sizeof (asection
*));
1292 if (PRIV (sections
) == NULL
)
1296 PRIV (sections
)[PRIV (section_count
)] = section
;
1297 PRIV (section_count
)++;
1303 unsigned int nameoff
;
1304 struct vms_symbol_entry
*entry
;
1305 struct vms_egsy
*egsy
= (struct vms_egsy
*) vms_rec
;
1308 old_flags
= bfd_getl16 (egsy
->flags
);
1309 if (old_flags
& EGSY__V_DEF
)
1310 nameoff
= ESDF__B_NAMLNG
;
1312 nameoff
= ESRF__B_NAMLNG
;
1314 if (nameoff
>= gsd_size
)
1316 _bfd_error_handler (_("ECSD__C_SYM record is too small"));
1317 bfd_set_error (bfd_error_bad_value
);
1320 entry
= add_symbol (abfd
, vms_rec
+ nameoff
, gsd_size
- nameoff
);
1324 /* Allow only duplicate reference. */
1325 if ((entry
->flags
& EGSY__V_DEF
) && (old_flags
& EGSY__V_DEF
))
1328 if (entry
->typ
== 0)
1330 entry
->typ
= gsd_type
;
1331 entry
->data_type
= egsy
->datyp
;
1332 entry
->flags
= old_flags
;
1335 if (old_flags
& EGSY__V_DEF
)
1337 struct vms_esdf
*esdf
= (struct vms_esdf
*)vms_rec
;
1340 entry
->value
= bfd_getl64 (esdf
->value
);
1341 if (PRIV (sections
) == NULL
)
1344 psindx
= bfd_getl32 (esdf
->psindx
);
1345 /* PR 21813: Check for an out of range index. */
1346 if (psindx
< 0 || psindx
>= (int) PRIV (section_count
))
1348 _bfd_error_handler (_("corrupt EGSD record: its psindx field is too big (%#lx)"),
1350 bfd_set_error (bfd_error_bad_value
);
1353 entry
->section
= PRIV (sections
)[psindx
];
1355 if (old_flags
& EGSY__V_NORM
)
1357 PRIV (norm_sym_count
)++;
1359 entry
->code_value
= bfd_getl64 (esdf
->code_address
);
1360 psindx
= bfd_getl32 (esdf
->ca_psindx
);
1361 /* PR 21813: Check for an out of range index. */
1362 if (psindx
< 0 || psindx
>= (int) PRIV (section_count
))
1364 _bfd_error_handler (_("corrupt EGSD record: its psindx field is too big (%#lx)"),
1366 bfd_set_error (bfd_error_bad_value
);
1369 entry
->code_section
= PRIV (sections
)[psindx
];
1377 struct vms_symbol_entry
*entry
;
1378 struct vms_egst
*egst
= (struct vms_egst
*)vms_rec
;
1380 unsigned int nameoff
= offsetof (struct vms_egst
, namlng
);
1382 old_flags
= bfd_getl16 (egst
->header
.flags
);
1384 if (nameoff
>= gsd_size
)
1386 _bfd_error_handler (_("ECSD__C_SYMG record is too small"));
1387 bfd_set_error (bfd_error_bad_value
);
1390 entry
= add_symbol (abfd
, &egst
->namlng
, gsd_size
- nameoff
);
1394 entry
->typ
= gsd_type
;
1395 entry
->data_type
= egst
->header
.datyp
;
1396 entry
->flags
= old_flags
;
1398 entry
->symbol_vector
= bfd_getl32 (egst
->value
);
1400 if (old_flags
& EGSY__V_REL
)
1404 if (PRIV (sections
) == NULL
)
1406 psindx
= bfd_getl32 (egst
->psindx
);
1407 /* PR 21813: Check for an out of range index. */
1408 if (psindx
< 0 || psindx
>= (int) PRIV (section_count
))
1410 _bfd_error_handler (_("corrupt EGSD record: its psindx field is too big (%#lx)"),
1412 bfd_set_error (bfd_error_bad_value
);
1415 entry
->section
= PRIV (sections
)[psindx
];
1418 entry
->section
= bfd_abs_section_ptr
;
1420 entry
->value
= bfd_getl64 (egst
->lp_2
);
1422 if (old_flags
& EGSY__V_NORM
)
1424 PRIV (norm_sym_count
)++;
1426 entry
->code_value
= bfd_getl64 (egst
->lp_1
);
1427 entry
->code_section
= bfd_abs_section_ptr
;
1434 /* Currently ignored. */
1439 _bfd_error_handler (_("unknown EGSD subtype %d"), gsd_type
);
1440 bfd_set_error (bfd_error_bad_value
);
1444 PRIV (recrd
.rec_size
) -= gsd_size
;
1445 PRIV (recrd
.rec
) += gsd_size
;
1448 /* FIXME: Should we complain if PRIV (recrd.rec_size) is not zero ? */
1450 if (PRIV (gsd_sym_count
) > 0)
1451 abfd
->flags
|= HAS_SYMS
;
1456 /* Stack routines for vms ETIR commands. */
1458 /* Push value and section index. */
1461 _bfd_vms_push (bfd
*abfd
, bfd_vma val
, unsigned int reloc
)
1463 vms_debug2 ((4, "<push %08lx (0x%08x) at %d>\n",
1464 (unsigned long)val
, reloc
, PRIV (stackptr
)));
1466 PRIV (stack
[PRIV (stackptr
)]).value
= val
;
1467 PRIV (stack
[PRIV (stackptr
)]).reloc
= reloc
;
1469 if (PRIV (stackptr
) >= STACKSIZE
)
1471 bfd_set_error (bfd_error_bad_value
);
1472 _bfd_error_handler (_("stack overflow (%d) in _bfd_vms_push"), PRIV (stackptr
));
1477 /* Pop value and section index. */
1480 _bfd_vms_pop (bfd
*abfd
, bfd_vma
*val
, unsigned int *rel
)
1482 if (PRIV (stackptr
) == 0)
1484 bfd_set_error (bfd_error_bad_value
);
1485 _bfd_error_handler (_("stack underflow in _bfd_vms_pop"));
1489 *val
= PRIV (stack
[PRIV (stackptr
)]).value
;
1490 *rel
= PRIV (stack
[PRIV (stackptr
)]).reloc
;
1492 vms_debug2 ((4, "<pop %08lx (0x%08x)>\n", (unsigned long)*val
, *rel
));
1495 /* Routines to fill sections contents during tir/etir read. */
1497 /* Initialize image buffer pointer to be filled. */
1500 image_set_ptr (bfd
*abfd
, bfd_vma vma
, int sect
, struct bfd_link_info
*info
)
1504 vms_debug2 ((4, "image_set_ptr (0x%08x, sect=%d)\n", (unsigned)vma
, sect
));
1506 if (PRIV (sections
) == NULL
)
1508 if (sect
< 0 || sect
>= (int) PRIV (section_count
))
1511 sec
= PRIV (sections
)[sect
];
1515 /* Reading contents to an output bfd. */
1517 if (sec
->output_section
== NULL
)
1519 /* Section discarded. */
1520 vms_debug2 ((5, " section %s discarded\n", sec
->name
));
1522 /* This is not used. */
1523 PRIV (image_section
) = NULL
;
1524 PRIV (image_offset
) = 0;
1527 PRIV (image_offset
) = sec
->output_offset
+ vma
;
1528 PRIV (image_section
) = sec
->output_section
;
1532 PRIV (image_offset
) = vma
;
1533 PRIV (image_section
) = sec
;
1537 /* Increment image buffer pointer by offset. */
1540 image_inc_ptr (bfd
*abfd
, bfd_vma offset
)
1542 vms_debug2 ((4, "image_inc_ptr (%u)\n", (unsigned)offset
));
1544 PRIV (image_offset
) += offset
;
1547 /* Save current DST location counter under specified index. */
1550 dst_define_location (bfd
*abfd
, unsigned int loc
)
1552 vms_debug2 ((4, "dst_define_location (%d)\n", (int)loc
));
1554 /* Grow the ptr offset table if necessary. */
1555 if (loc
+ 1 > PRIV (dst_ptr_offsets_count
))
1557 PRIV (dst_ptr_offsets
) = bfd_realloc (PRIV (dst_ptr_offsets
),
1558 (loc
+ 1) * sizeof (unsigned int));
1559 PRIV (dst_ptr_offsets_count
) = loc
+ 1;
1562 PRIV (dst_ptr_offsets
)[loc
] = PRIV (image_offset
);
1565 /* Restore saved DST location counter from specified index. */
1568 dst_restore_location (bfd
*abfd
, unsigned int loc
)
1570 vms_debug2 ((4, "dst_restore_location (%d)\n", (int)loc
));
1572 PRIV (image_offset
) = PRIV (dst_ptr_offsets
)[loc
];
1575 /* Retrieve saved DST location counter from specified index. */
1578 dst_retrieve_location (bfd
*abfd
, unsigned int loc
)
1580 vms_debug2 ((4, "dst_retrieve_location (%d)\n", (int)loc
));
1582 return PRIV (dst_ptr_offsets
)[loc
];
1585 /* Write multiple bytes to section image. */
1588 image_write (bfd
*abfd
, unsigned char *ptr
, unsigned int size
)
1591 _bfd_vms_debug (8, "image_write from (%p, %d) to (%ld)\n", ptr
, size
,
1592 (long)PRIV (image_offset
));
1593 _bfd_hexdump (9, ptr
, size
, 0);
1596 if (PRIV (image_section
)->contents
!= NULL
)
1598 asection
*sec
= PRIV (image_section
);
1599 file_ptr off
= PRIV (image_offset
);
1602 if (off
> (file_ptr
)sec
->size
1603 || size
> (file_ptr
)sec
->size
1604 || off
+ size
> (file_ptr
)sec
->size
)
1606 bfd_set_error (bfd_error_bad_value
);
1610 memcpy (sec
->contents
+ off
, ptr
, size
);
1613 PRIV (image_offset
) += size
;
1617 /* Write byte to section image. */
1620 image_write_b (bfd
* abfd
, unsigned int value
)
1622 unsigned char data
[1];
1624 vms_debug2 ((6, "image_write_b (%02x)\n", (int) value
));
1628 return image_write (abfd
, data
, sizeof (data
));
1631 /* Write 2-byte word to image. */
1634 image_write_w (bfd
* abfd
, unsigned int value
)
1636 unsigned char data
[2];
1638 vms_debug2 ((6, "image_write_w (%04x)\n", (int) value
));
1640 bfd_putl16 (value
, data
);
1641 return image_write (abfd
, data
, sizeof (data
));
1644 /* Write 4-byte long to image. */
1647 image_write_l (bfd
* abfd
, unsigned long value
)
1649 unsigned char data
[4];
1651 vms_debug2 ((6, "image_write_l (%08lx)\n", value
));
1653 bfd_putl32 (value
, data
);
1654 return image_write (abfd
, data
, sizeof (data
));
1657 /* Write 8-byte quad to image. */
1660 image_write_q (bfd
* abfd
, bfd_vma value
)
1662 unsigned char data
[8];
1664 vms_debug2 ((6, "image_write_q (%08lx)\n", (unsigned long)value
));
1666 bfd_putl64 (value
, data
);
1667 return image_write (abfd
, data
, sizeof (data
));
1671 _bfd_vms_etir_name (int cmd
)
1675 case ETIR__C_STA_GBL
: return "ETIR__C_STA_GBL";
1676 case ETIR__C_STA_LW
: return "ETIR__C_STA_LW";
1677 case ETIR__C_STA_QW
: return "ETIR__C_STA_QW";
1678 case ETIR__C_STA_PQ
: return "ETIR__C_STA_PQ";
1679 case ETIR__C_STA_LI
: return "ETIR__C_STA_LI";
1680 case ETIR__C_STA_MOD
: return "ETIR__C_STA_MOD";
1681 case ETIR__C_STA_CKARG
: return "ETIR__C_STA_CKARG";
1682 case ETIR__C_STO_B
: return "ETIR__C_STO_B";
1683 case ETIR__C_STO_W
: return "ETIR__C_STO_W";
1684 case ETIR__C_STO_GBL
: return "ETIR__C_STO_GBL";
1685 case ETIR__C_STO_CA
: return "ETIR__C_STO_CA";
1686 case ETIR__C_STO_RB
: return "ETIR__C_STO_RB";
1687 case ETIR__C_STO_AB
: return "ETIR__C_STO_AB";
1688 case ETIR__C_STO_OFF
: return "ETIR__C_STO_OFF";
1689 case ETIR__C_STO_IMM
: return "ETIR__C_STO_IMM";
1690 case ETIR__C_STO_IMMR
: return "ETIR__C_STO_IMMR";
1691 case ETIR__C_STO_LW
: return "ETIR__C_STO_LW";
1692 case ETIR__C_STO_QW
: return "ETIR__C_STO_QW";
1693 case ETIR__C_STO_GBL_LW
: return "ETIR__C_STO_GBL_LW";
1694 case ETIR__C_STO_LP_PSB
: return "ETIR__C_STO_LP_PSB";
1695 case ETIR__C_STO_HINT_GBL
: return "ETIR__C_STO_HINT_GBL";
1696 case ETIR__C_STO_HINT_PS
: return "ETIR__C_STO_HINT_PS";
1697 case ETIR__C_OPR_ADD
: return "ETIR__C_OPR_ADD";
1698 case ETIR__C_OPR_SUB
: return "ETIR__C_OPR_SUB";
1699 case ETIR__C_OPR_INSV
: return "ETIR__C_OPR_INSV";
1700 case ETIR__C_OPR_USH
: return "ETIR__C_OPR_USH";
1701 case ETIR__C_OPR_ROT
: return "ETIR__C_OPR_ROT";
1702 case ETIR__C_OPR_REDEF
: return "ETIR__C_OPR_REDEF";
1703 case ETIR__C_OPR_DFLIT
: return "ETIR__C_OPR_DFLIT";
1704 case ETIR__C_STC_LP
: return "ETIR__C_STC_LP";
1705 case ETIR__C_STC_GBL
: return "ETIR__C_STC_GBL";
1706 case ETIR__C_STC_GCA
: return "ETIR__C_STC_GCA";
1707 case ETIR__C_STC_PS
: return "ETIR__C_STC_PS";
1708 case ETIR__C_STC_NBH_PS
: return "ETIR__C_STC_NBH_PS";
1709 case ETIR__C_STC_NOP_GBL
: return "ETIR__C_STC_NOP_GBL";
1710 case ETIR__C_STC_NOP_PS
: return "ETIR__C_STC_NOP_PS";
1711 case ETIR__C_STC_BSR_GBL
: return "ETIR__C_STC_BSR_GBL";
1712 case ETIR__C_STC_BSR_PS
: return "ETIR__C_STC_BSR_PS";
1713 case ETIR__C_STC_LDA_GBL
: return "ETIR__C_STC_LDA_GBL";
1714 case ETIR__C_STC_LDA_PS
: return "ETIR__C_STC_LDA_PS";
1715 case ETIR__C_STC_BOH_GBL
: return "ETIR__C_STC_BOH_GBL";
1716 case ETIR__C_STC_BOH_PS
: return "ETIR__C_STC_BOH_PS";
1717 case ETIR__C_STC_NBH_GBL
: return "ETIR__C_STC_NBH_GBL";
1718 case ETIR__C_STC_LP_PSB
: return "ETIR__C_STC_LP_PSB";
1719 case ETIR__C_CTL_SETRB
: return "ETIR__C_CTL_SETRB";
1720 case ETIR__C_CTL_AUGRB
: return "ETIR__C_CTL_AUGRB";
1721 case ETIR__C_CTL_DFLOC
: return "ETIR__C_CTL_DFLOC";
1722 case ETIR__C_CTL_STLOC
: return "ETIR__C_CTL_STLOC";
1723 case ETIR__C_CTL_STKDL
: return "ETIR__C_CTL_STKDL";
1726 /* These names have not yet been added to this switch statement. */
1727 _bfd_error_handler (_("unknown ETIR command %d"), cmd
);
1732 #define HIGHBIT(op) ((op & 0x80000000L) == 0x80000000L)
1735 _bfd_vms_get_value (bfd
*abfd
,
1736 const unsigned char *ascic
,
1737 const unsigned char *max_ascic
,
1738 struct bfd_link_info
*info
,
1740 struct alpha_vms_link_hash_entry
**hp
)
1745 struct alpha_vms_link_hash_entry
*h
;
1747 /* Not linking. Do not try to resolve the symbol. */
1756 if (ascic
+ len
>= max_ascic
)
1758 _bfd_error_handler (_("corrupt vms value"));
1764 for (i
= 0; i
< len
; i
++)
1765 name
[i
] = ascic
[i
+ 1];
1768 h
= (struct alpha_vms_link_hash_entry
*)
1769 bfd_link_hash_lookup (info
->hash
, name
, FALSE
, FALSE
, TRUE
);
1774 && (h
->root
.type
== bfd_link_hash_defined
1775 || h
->root
.type
== bfd_link_hash_defweak
))
1776 *vma
= h
->root
.u
.def
.value
1777 + h
->root
.u
.def
.section
->output_offset
1778 + h
->root
.u
.def
.section
->output_section
->vma
;
1779 else if (h
&& h
->root
.type
== bfd_link_hash_undefweak
)
1783 (*info
->callbacks
->undefined_symbol
)
1784 (info
, name
, abfd
, PRIV (image_section
), PRIV (image_offset
), TRUE
);
1791 #define RELC_SHR_BASE 0x10000
1792 #define RELC_SEC_BASE 0x20000
1793 #define RELC_MASK 0x0ffff
1796 alpha_vms_sym_to_ctxt (struct alpha_vms_link_hash_entry
*h
)
1798 /* Handle undefined symbols. */
1799 if (h
== NULL
|| h
->sym
== NULL
)
1802 if (h
->sym
->typ
== EGSD__C_SYMG
)
1804 if (h
->sym
->flags
& EGSY__V_REL
)
1805 return RELC_SHR_BASE
+ PRIV2 (h
->sym
->owner
, shr_index
);
1808 /* Can this happen (non-relocatable symg) ? I'd like to see
1813 if (h
->sym
->typ
== EGSD__C_SYM
)
1815 if (h
->sym
->flags
& EGSY__V_REL
)
1824 alpha_vms_get_sym_value (asection
*sect
, bfd_vma addr
)
1826 return sect
->output_section
->vma
+ sect
->output_offset
+ addr
;
1830 alpha_vms_fix_sec_rel (bfd
*abfd
, struct bfd_link_info
*info
,
1831 unsigned int rel
, bfd_vma vma
)
1835 if (PRIV (sections
) == NULL
)
1838 sec
= PRIV (sections
)[rel
& RELC_MASK
];
1842 if (sec
->output_section
== NULL
)
1844 return vma
+ sec
->output_section
->vma
+ sec
->output_offset
;
1847 return vma
+ sec
->vma
;
1850 /* Read an ETIR record from ABFD. If INFO is not null, put the content into
1851 the output section (used during linking).
1852 Return FALSE in case of error. */
1855 _bfd_vms_slurp_etir (bfd
*abfd
, struct bfd_link_info
*info
)
1858 unsigned int length
;
1859 unsigned char *maxptr
;
1864 struct alpha_vms_link_hash_entry
*h
;
1866 PRIV (recrd
.rec
) += ETIR__C_HEADER_SIZE
;
1867 PRIV (recrd
.rec_size
) -= ETIR__C_HEADER_SIZE
;
1869 ptr
= PRIV (recrd
.rec
);
1870 length
= PRIV (recrd
.rec_size
);
1871 maxptr
= ptr
+ length
;
1873 vms_debug2 ((2, "ETIR: %d bytes\n", length
));
1875 while (ptr
< maxptr
)
1877 int cmd
, cmd_length
;
1879 if (ptr
+ 4 > maxptr
)
1882 cmd
= bfd_getl16 (ptr
);
1883 cmd_length
= bfd_getl16 (ptr
+ 2);
1885 /* PR 21589 and 21579: Check for a corrupt ETIR record. */
1886 if (cmd_length
< 4 || ptr
+ cmd_length
> maxptr
)
1889 _bfd_error_handler (_("corrupt ETIR record encountered"));
1890 bfd_set_error (bfd_error_bad_value
);
1896 _bfd_vms_debug (4, "etir: %s(%d)\n",
1897 _bfd_vms_etir_name (cmd
), cmd
);
1898 _bfd_hexdump (8, ptr
, cmd_length
- 4, 0);
1906 stack 32 bit value of symbol (high bits set to 0). */
1907 case ETIR__C_STA_GBL
:
1908 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
1909 _bfd_vms_push (abfd
, op1
, alpha_vms_sym_to_ctxt (h
));
1915 stack 32 bit value, sign extend to 64 bit. */
1916 case ETIR__C_STA_LW
:
1917 if (ptr
+ 4 > maxptr
)
1919 _bfd_vms_push (abfd
, bfd_getl32 (ptr
), RELC_NONE
);
1925 stack 64 bit value of symbol. */
1926 case ETIR__C_STA_QW
:
1927 if (ptr
+ 8 > maxptr
)
1929 _bfd_vms_push (abfd
, bfd_getl64 (ptr
), RELC_NONE
);
1932 /* Stack psect base plus quadword offset
1933 arg: lw section index
1934 qw signed quadword offset (low 32 bits)
1936 Stack qw argument and section index
1937 (see ETIR__C_STO_OFF, ETIR__C_CTL_SETRB). */
1938 case ETIR__C_STA_PQ
:
1942 if (ptr
+ 12 > maxptr
)
1944 psect
= bfd_getl32 (ptr
);
1945 if ((unsigned int) psect
>= PRIV (section_count
))
1947 _bfd_error_handler (_("bad section index in %s"),
1948 _bfd_vms_etir_name (cmd
));
1949 bfd_set_error (bfd_error_bad_value
);
1952 op1
= bfd_getl64 (ptr
+ 4);
1953 _bfd_vms_push (abfd
, op1
, psect
| RELC_SEC_BASE
);
1957 case ETIR__C_STA_LI
:
1958 case ETIR__C_STA_MOD
:
1959 case ETIR__C_STA_CKARG
:
1960 _bfd_error_handler (_("unsupported STA cmd %s"),
1961 _bfd_vms_etir_name (cmd
));
1965 /* Store byte: pop stack, write byte
1968 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1969 if (rel1
!= RELC_NONE
)
1971 image_write_b (abfd
, (unsigned int) op1
& 0xff);
1974 /* Store word: pop stack, write word
1977 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1978 if (rel1
!= RELC_NONE
)
1980 image_write_w (abfd
, (unsigned int) op1
& 0xffff);
1983 /* Store longword: pop stack, write longword
1985 case ETIR__C_STO_LW
:
1986 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1987 if (rel1
& RELC_SEC_BASE
)
1989 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
1992 else if (rel1
& RELC_SHR_BASE
)
1994 alpha_vms_add_fixup_lr (info
, rel1
& RELC_MASK
, op1
);
1997 if (rel1
!= RELC_NONE
)
1999 if (rel1
!= RELC_REL
)
2001 alpha_vms_add_lw_reloc (info
);
2003 image_write_l (abfd
, op1
);
2006 /* Store quadword: pop stack, write quadword
2008 case ETIR__C_STO_QW
:
2009 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2010 if (rel1
& RELC_SEC_BASE
)
2012 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2015 else if (rel1
& RELC_SHR_BASE
)
2017 if (rel1
!= RELC_NONE
)
2019 if (rel1
!= RELC_REL
)
2021 alpha_vms_add_qw_reloc (info
);
2023 image_write_q (abfd
, op1
);
2026 /* Store immediate repeated: pop stack for repeat count
2029 case ETIR__C_STO_IMMR
:
2033 if (ptr
+ 4 > maxptr
)
2035 size
= bfd_getl32 (ptr
);
2036 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2037 if (rel1
!= RELC_NONE
)
2040 image_write (abfd
, ptr
+ 4, size
);
2044 /* Store global: write symbol value
2045 arg: cs global symbol name. */
2046 case ETIR__C_STO_GBL
:
2047 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
2050 if (h
->sym
->typ
== EGSD__C_SYMG
)
2052 alpha_vms_add_fixup_qr
2053 (info
, abfd
, h
->sym
->owner
, h
->sym
->symbol_vector
);
2058 op1
= alpha_vms_get_sym_value (h
->sym
->section
,
2060 alpha_vms_add_qw_reloc (info
);
2063 image_write_q (abfd
, op1
);
2066 /* Store code address: write address of entry point
2067 arg: cs global symbol name (procedure). */
2068 case ETIR__C_STO_CA
:
2069 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
2072 if (h
->sym
->flags
& EGSY__V_NORM
)
2074 /* That's really a procedure. */
2075 if (h
->sym
->typ
== EGSD__C_SYMG
)
2077 alpha_vms_add_fixup_ca (info
, abfd
, h
->sym
->owner
);
2078 op1
= h
->sym
->symbol_vector
;
2082 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
2083 h
->sym
->code_value
);
2084 alpha_vms_add_qw_reloc (info
);
2089 /* Symbol is not a procedure. */
2093 image_write_q (abfd
, op1
);
2096 /* Store offset to psect: pop stack, add low 32 bits to base of psect
2098 case ETIR__C_STO_OFF
:
2099 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2101 if (!(rel1
& RELC_SEC_BASE
))
2104 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2106 image_write_q (abfd
, op1
);
2110 arg: lw count of bytes
2112 case ETIR__C_STO_IMM
:
2116 if (ptr
+ 4 > maxptr
)
2118 size
= bfd_getl32 (ptr
);
2119 image_write (abfd
, ptr
+ 4, size
);
2123 /* This code is 'reserved to digital' according to the openVMS
2124 linker manual, however it is generated by the DEC C compiler
2125 and defined in the include file.
2126 FIXME, since the following is just a guess
2127 store global longword: store 32bit value of symbol
2128 arg: cs symbol name. */
2129 case ETIR__C_STO_GBL_LW
:
2130 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
2134 image_write_l (abfd
, op1
);
2137 case ETIR__C_STO_RB
:
2138 case ETIR__C_STO_AB
:
2139 case ETIR__C_STO_LP_PSB
:
2140 _bfd_error_handler (_("%s: not supported"),
2141 _bfd_vms_etir_name (cmd
));
2144 case ETIR__C_STO_HINT_GBL
:
2145 case ETIR__C_STO_HINT_PS
:
2146 _bfd_error_handler (_("%s: not implemented"),
2147 _bfd_vms_etir_name (cmd
));
2151 /* 200 Store-conditional Linkage Pair
2153 case ETIR__C_STC_LP
:
2155 /* 202 Store-conditional Address at global address
2159 case ETIR__C_STC_GBL
:
2161 /* 203 Store-conditional Code Address at global address
2163 cs procedure name. */
2164 case ETIR__C_STC_GCA
:
2166 /* 204 Store-conditional Address at psect + offset
2170 case ETIR__C_STC_PS
:
2171 _bfd_error_handler (_("%s: not supported"),
2172 _bfd_vms_etir_name (cmd
));
2176 /* 201 Store-conditional Linkage Pair with Procedure Signature
2182 case ETIR__C_STC_LP_PSB
:
2183 _bfd_vms_get_value (abfd
, ptr
+ 4, maxptr
, info
, &op1
, &h
);
2186 if (h
->sym
->typ
== EGSD__C_SYMG
)
2188 alpha_vms_add_fixup_lp (info
, abfd
, h
->sym
->owner
);
2189 op1
= h
->sym
->symbol_vector
;
2194 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
2195 h
->sym
->code_value
);
2196 op2
= alpha_vms_get_sym_value (h
->sym
->section
,
2202 /* Undefined symbol. */
2206 image_write_q (abfd
, op1
);
2207 image_write_q (abfd
, op2
);
2210 /* 205 Store-conditional NOP at address of global
2212 case ETIR__C_STC_NOP_GBL
:
2215 /* 207 Store-conditional BSR at global address
2218 case ETIR__C_STC_BSR_GBL
:
2221 /* 209 Store-conditional LDA at global address
2224 case ETIR__C_STC_LDA_GBL
:
2227 /* 211 Store-conditional BSR or Hint at global address
2230 case ETIR__C_STC_BOH_GBL
:
2231 /* Currentl ignored. */
2234 /* 213 Store-conditional NOP,BSR or HINT at global address
2237 case ETIR__C_STC_NBH_GBL
:
2239 /* 206 Store-conditional NOP at pect + offset
2242 case ETIR__C_STC_NOP_PS
:
2244 /* 208 Store-conditional BSR at pect + offset
2247 case ETIR__C_STC_BSR_PS
:
2249 /* 210 Store-conditional LDA at psect + offset
2252 case ETIR__C_STC_LDA_PS
:
2254 /* 212 Store-conditional BSR or Hint at pect + offset
2257 case ETIR__C_STC_BOH_PS
:
2259 /* 214 Store-conditional NOP, BSR or HINT at psect + offset
2261 case ETIR__C_STC_NBH_PS
:
2262 _bfd_error_handler (_("%s: not supported"),
2263 _bfd_vms_etir_name (cmd
));
2267 /* Det relocation base: pop stack, set image location counter
2269 case ETIR__C_CTL_SETRB
:
2270 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2271 if (!(rel1
& RELC_SEC_BASE
))
2273 image_set_ptr (abfd
, op1
, rel1
& RELC_MASK
, info
);
2276 /* Augment relocation base: increment image location counter by offset
2277 arg: lw offset value. */
2278 case ETIR__C_CTL_AUGRB
:
2279 if (ptr
+ 4 > maxptr
)
2281 op1
= bfd_getl32 (ptr
);
2282 image_inc_ptr (abfd
, op1
);
2285 /* Define location: pop index, save location counter under index
2287 case ETIR__C_CTL_DFLOC
:
2288 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2289 if (rel1
!= RELC_NONE
)
2291 dst_define_location (abfd
, op1
);
2294 /* Set location: pop index, restore location counter from index
2296 case ETIR__C_CTL_STLOC
:
2297 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2298 if (rel1
!= RELC_NONE
)
2300 dst_restore_location (abfd
, op1
);
2303 /* Stack defined location: pop index, push location counter from index
2305 case ETIR__C_CTL_STKDL
:
2306 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2307 if (rel1
!= RELC_NONE
)
2309 _bfd_vms_push (abfd
, dst_retrieve_location (abfd
, op1
), RELC_NONE
);
2312 case ETIR__C_OPR_NOP
: /* No-op. */
2315 case ETIR__C_OPR_ADD
: /* Add. */
2316 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2317 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2318 if (rel1
== RELC_NONE
&& rel2
!= RELC_NONE
)
2320 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2322 _bfd_vms_push (abfd
, op1
+ op2
, rel1
);
2325 case ETIR__C_OPR_SUB
: /* Subtract. */
2326 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2327 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2328 if (rel1
== RELC_NONE
&& rel2
!= RELC_NONE
)
2330 else if ((rel1
& RELC_SEC_BASE
) && (rel2
& RELC_SEC_BASE
))
2332 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2333 op2
= alpha_vms_fix_sec_rel (abfd
, info
, rel2
, op2
);
2336 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2338 _bfd_vms_push (abfd
, op2
- op1
, rel1
);
2341 case ETIR__C_OPR_MUL
: /* Multiply. */
2342 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2343 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2344 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2346 _bfd_vms_push (abfd
, op1
* op2
, RELC_NONE
);
2349 case ETIR__C_OPR_DIV
: /* Divide. */
2350 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2351 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2352 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2355 _bfd_vms_push (abfd
, 0, RELC_NONE
);
2357 _bfd_vms_push (abfd
, op2
/ op1
, RELC_NONE
);
2360 case ETIR__C_OPR_AND
: /* Logical AND. */
2361 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2362 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2363 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2365 _bfd_vms_push (abfd
, op1
& op2
, RELC_NONE
);
2368 case ETIR__C_OPR_IOR
: /* Logical inclusive OR. */
2369 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2370 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2371 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2373 _bfd_vms_push (abfd
, op1
| op2
, RELC_NONE
);
2376 case ETIR__C_OPR_EOR
: /* Logical exclusive OR. */
2377 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2378 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2379 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2381 _bfd_vms_push (abfd
, op1
^ op2
, RELC_NONE
);
2384 case ETIR__C_OPR_NEG
: /* Negate. */
2385 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2386 if (rel1
!= RELC_NONE
)
2388 _bfd_vms_push (abfd
, -op1
, RELC_NONE
);
2391 case ETIR__C_OPR_COM
: /* Complement. */
2392 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2393 if (rel1
!= RELC_NONE
)
2395 _bfd_vms_push (abfd
, ~op1
, RELC_NONE
);
2398 case ETIR__C_OPR_ASH
: /* Arithmetic shift. */
2399 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2400 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2401 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2404 _bfd_error_handler (_("invalid use of %s with contexts"),
2405 _bfd_vms_etir_name (cmd
));
2408 if ((int)op2
< 0) /* Shift right. */
2410 else /* Shift left. */
2412 _bfd_vms_push (abfd
, op1
, RELC_NONE
); /* FIXME: sym. */
2415 case ETIR__C_OPR_INSV
: /* Insert field. */
2416 case ETIR__C_OPR_USH
: /* Unsigned shift. */
2417 case ETIR__C_OPR_ROT
: /* Rotate. */
2418 case ETIR__C_OPR_REDEF
: /* Redefine symbol to current location. */
2419 case ETIR__C_OPR_DFLIT
: /* Define a literal. */
2420 _bfd_error_handler (_("%s: not supported"),
2421 _bfd_vms_etir_name (cmd
));
2425 case ETIR__C_OPR_SEL
: /* Select. */
2426 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2428 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2431 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2432 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2433 _bfd_vms_push (abfd
, op1
, rel1
);
2438 _bfd_error_handler (_("reserved cmd %d"), cmd
);
2443 ptr
+= cmd_length
- 4;
2449 /* Process EDBG/ETBT record.
2450 Return TRUE on success, FALSE on error */
2453 vms_slurp_debug (bfd
*abfd
)
2455 asection
*section
= PRIV (dst_section
);
2457 if (section
== NULL
)
2459 /* We have no way to find out beforehand how much debug info there
2460 is in an object file, so pick an initial amount and grow it as
2462 flagword flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
| SEC_RELOC
2465 section
= bfd_make_section (abfd
, "$DST$");
2468 if (!bfd_set_section_flags (section
, flags
))
2470 PRIV (dst_section
) = section
;
2473 PRIV (image_section
) = section
;
2474 PRIV (image_offset
) = section
->size
;
2476 if (!_bfd_vms_slurp_etir (abfd
, NULL
))
2479 section
->size
= PRIV (image_offset
);
2483 /* Process EDBG record.
2484 Return TRUE on success, FALSE on error. */
2487 _bfd_vms_slurp_edbg (bfd
*abfd
)
2489 vms_debug2 ((2, "EDBG\n"));
2491 abfd
->flags
|= HAS_DEBUG
| HAS_LINENO
;
2493 return vms_slurp_debug (abfd
);
2496 /* Process ETBT record.
2497 Return TRUE on success, FALSE on error. */
2500 _bfd_vms_slurp_etbt (bfd
*abfd
)
2502 vms_debug2 ((2, "ETBT\n"));
2504 abfd
->flags
|= HAS_LINENO
;
2506 return vms_slurp_debug (abfd
);
2509 /* Process EEOM record.
2510 Return TRUE on success, FALSE on error. */
2513 _bfd_vms_slurp_eeom (bfd
*abfd
)
2515 struct vms_eeom
*eeom
= (struct vms_eeom
*) PRIV (recrd
.rec
);
2517 vms_debug2 ((2, "EEOM\n"));
2519 /* PR 21813: Check for an undersized record. */
2520 if (PRIV (recrd
.buf_size
) < sizeof (* eeom
))
2522 _bfd_error_handler (_("corrupt EEOM record - size is too small"));
2523 bfd_set_error (bfd_error_bad_value
);
2527 PRIV (eom_data
).eom_l_total_lps
= bfd_getl32 (eeom
->total_lps
);
2528 PRIV (eom_data
).eom_w_comcod
= bfd_getl16 (eeom
->comcod
);
2529 if (PRIV (eom_data
).eom_w_comcod
> 1)
2531 _bfd_error_handler (_("object module not error-free !"));
2532 bfd_set_error (bfd_error_bad_value
);
2536 PRIV (eom_data
).eom_has_transfer
= FALSE
;
2537 if (PRIV (recrd
.rec_size
) > 10)
2539 PRIV (eom_data
).eom_has_transfer
= TRUE
;
2540 PRIV (eom_data
).eom_b_tfrflg
= eeom
->tfrflg
;
2541 PRIV (eom_data
).eom_l_psindx
= bfd_getl32 (eeom
->psindx
);
2542 PRIV (eom_data
).eom_l_tfradr
= bfd_getl32 (eeom
->tfradr
);
2544 abfd
->start_address
= PRIV (eom_data
).eom_l_tfradr
;
2549 /* Slurp an ordered set of VMS object records. Return FALSE on error. */
2552 _bfd_vms_slurp_object_records (bfd
* abfd
)
2559 vms_debug2 ((7, "reading at %08lx\n", (unsigned long)bfd_tell (abfd
)));
2561 type
= _bfd_vms_get_object_record (abfd
);
2564 vms_debug2 ((2, "next_record failed\n"));
2571 err
= _bfd_vms_slurp_ehdr (abfd
);
2574 err
= _bfd_vms_slurp_eeom (abfd
);
2577 err
= _bfd_vms_slurp_egsd (abfd
);
2580 err
= TRUE
; /* _bfd_vms_slurp_etir (abfd); */
2583 err
= _bfd_vms_slurp_edbg (abfd
);
2586 err
= _bfd_vms_slurp_etbt (abfd
);
2593 vms_debug2 ((2, "slurp type %d failed\n", type
));
2597 while (type
!= EOBJ__C_EEOM
);
2602 /* Initialize private data */
2604 vms_initialize (bfd
* abfd
)
2608 amt
= sizeof (struct vms_private_data_struct
);
2609 abfd
->tdata
.any
= bfd_zalloc (abfd
, amt
);
2610 if (abfd
->tdata
.any
== NULL
)
2613 PRIV (recrd
.file_format
) = FF_UNKNOWN
;
2615 amt
= sizeof (struct stack_struct
) * STACKSIZE
;
2616 PRIV (stack
) = bfd_alloc (abfd
, amt
);
2617 if (PRIV (stack
) == NULL
)
2623 bfd_release (abfd
, abfd
->tdata
.any
);
2624 abfd
->tdata
.any
= NULL
;
2628 /* Check the format for a file being read.
2629 Return a (bfd_target *) if it's an object file or zero if not. */
2631 static const struct bfd_target
*
2632 alpha_vms_object_p (bfd
*abfd
)
2634 void *tdata_save
= abfd
->tdata
.any
;
2635 unsigned int test_len
;
2638 vms_debug2 ((1, "vms_object_p(%p)\n", abfd
));
2640 /* Allocate alpha-vms specific data. */
2641 if (!vms_initialize (abfd
))
2644 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
))
2645 goto err_wrong_format
;
2647 /* The first challenge with VMS is to discover the kind of the file.
2649 Image files (executable or shared images) are stored as a raw
2650 stream of bytes (like on UNIX), but there is no magic number.
2652 Object files are written with RMS (record management service), ie
2653 each records are preceeded by its length (on a word - 2 bytes), and
2654 padded for word-alignment. That would be simple but when files
2655 are transfered to a UNIX filesystem (using ftp), records are lost.
2656 Only the raw content of the records are transfered. Fortunately,
2657 the Alpha Object file format also store the length of the record
2658 in the records. Is that clear ? */
2660 /* Minimum is 6 bytes for objects (2 bytes size, 2 bytes record id,
2661 2 bytes size repeated) and 12 bytes for images (4 bytes major id,
2662 4 bytes minor id, 4 bytes length). */
2665 /* Size the main buffer. */
2666 buf
= (unsigned char *) bfd_malloc (test_len
);
2669 PRIV (recrd
.buf
) = buf
;
2670 PRIV (recrd
.buf_size
) = test_len
;
2672 /* Initialize the record pointer. */
2673 PRIV (recrd
.rec
) = buf
;
2675 if (bfd_bread (buf
, test_len
, abfd
) != test_len
)
2676 goto err_wrong_format
;
2678 /* Is it an image? */
2679 if ((bfd_getl32 (buf
) == EIHD__K_MAJORID
)
2680 && (bfd_getl32 (buf
+ 4) == EIHD__K_MINORID
))
2682 unsigned int to_read
;
2683 unsigned int read_so_far
;
2684 unsigned int remaining
;
2685 unsigned int eisd_offset
, eihs_offset
;
2687 /* Extract the header size. */
2688 PRIV (recrd
.rec_size
) = bfd_getl32 (buf
+ EIHD__L_SIZE
);
2690 /* The header size is 0 for DSF files. */
2691 if (PRIV (recrd
.rec_size
) == 0)
2692 PRIV (recrd
.rec_size
) = sizeof (struct vms_eihd
);
2694 if (PRIV (recrd
.rec_size
) > PRIV (recrd
.buf_size
))
2696 buf
= bfd_realloc_or_free (buf
, PRIV (recrd
.rec_size
));
2700 PRIV (recrd
.buf
) = NULL
;
2703 PRIV (recrd
.buf
) = buf
;
2704 PRIV (recrd
.buf_size
) = PRIV (recrd
.rec_size
);
2707 /* PR 21813: Check for a truncated record. */
2708 if (PRIV (recrd
.rec_size
< test_len
))
2710 /* Read the remaining record. */
2711 remaining
= PRIV (recrd
.rec_size
) - test_len
;
2712 to_read
= MIN (VMS_BLOCK_SIZE
- test_len
, remaining
);
2713 read_so_far
= test_len
;
2715 while (remaining
> 0)
2717 if (bfd_bread (buf
+ read_so_far
, to_read
, abfd
) != to_read
)
2718 goto err_wrong_format
;
2720 read_so_far
+= to_read
;
2721 remaining
-= to_read
;
2723 to_read
= MIN (VMS_BLOCK_SIZE
, remaining
);
2726 /* Reset the record pointer. */
2727 PRIV (recrd
.rec
) = buf
;
2729 /* PR 17512: file: 7d7c57c2. */
2730 if (PRIV (recrd
.rec_size
) < sizeof (struct vms_eihd
))
2732 vms_debug2 ((2, "file type is image\n"));
2734 if (!_bfd_vms_slurp_eihd (abfd
, &eisd_offset
, &eihs_offset
))
2735 goto err_wrong_format
;
2737 if (!_bfd_vms_slurp_eisd (abfd
, eisd_offset
))
2738 goto err_wrong_format
;
2740 /* EIHS is optional. */
2741 if (eihs_offset
!= 0 && !_bfd_vms_slurp_eihs (abfd
, eihs_offset
))
2742 goto err_wrong_format
;
2748 /* Assume it's a module and adjust record pointer if necessary. */
2749 maybe_adjust_record_pointer_for_object (abfd
);
2751 /* But is it really a module? */
2752 if (bfd_getl16 (PRIV (recrd
.rec
)) <= EOBJ__C_MAXRECTYP
2753 && bfd_getl16 (PRIV (recrd
.rec
) + 2) <= EOBJ__C_MAXRECSIZ
)
2755 if (vms_get_remaining_object_record (abfd
, test_len
) <= 0)
2756 goto err_wrong_format
;
2758 vms_debug2 ((2, "file type is module\n"));
2760 type
= bfd_getl16 (PRIV (recrd
.rec
));
2761 if (type
!= EOBJ__C_EMH
|| !_bfd_vms_slurp_ehdr (abfd
))
2762 goto err_wrong_format
;
2764 if (!_bfd_vms_slurp_object_records (abfd
))
2765 goto err_wrong_format
;
2768 goto err_wrong_format
;
2771 /* Set arch_info to alpha. */
2773 if (! bfd_default_set_arch_mach (abfd
, bfd_arch_alpha
, 0))
2774 goto err_wrong_format
;
2779 bfd_set_error (bfd_error_wrong_format
);
2782 if (PRIV (recrd
.buf
))
2783 free (PRIV (recrd
.buf
));
2784 if (abfd
->tdata
.any
!= tdata_save
&& abfd
->tdata
.any
!= NULL
)
2785 bfd_release (abfd
, abfd
->tdata
.any
);
2786 abfd
->tdata
.any
= tdata_save
;
2792 /* Write an EMH/MHD record. */
2795 _bfd_vms_write_emh (bfd
*abfd
)
2797 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2799 _bfd_vms_output_alignment (recwr
, 2);
2802 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
2803 _bfd_vms_output_short (recwr
, EMH__C_MHD
);
2804 _bfd_vms_output_short (recwr
, EOBJ__C_STRLVL
);
2805 _bfd_vms_output_long (recwr
, 0);
2806 _bfd_vms_output_long (recwr
, 0);
2807 _bfd_vms_output_long (recwr
, MAX_OUTREC_SIZE
);
2809 /* Create module name from filename. */
2810 if (bfd_get_filename (abfd
) != 0)
2812 char *module
= vms_get_module_name (bfd_get_filename (abfd
), TRUE
);
2813 _bfd_vms_output_counted (recwr
, module
);
2817 _bfd_vms_output_counted (recwr
, "NONAME");
2819 _bfd_vms_output_counted (recwr
, BFD_VERSION_STRING
);
2820 _bfd_vms_output_dump (recwr
, get_vms_time_string (), EMH_DATE_LENGTH
);
2821 _bfd_vms_output_fill (recwr
, 0, EMH_DATE_LENGTH
);
2822 _bfd_vms_output_end (abfd
, recwr
);
2825 /* Write an EMH/LMN record. */
2828 _bfd_vms_write_lmn (bfd
*abfd
, const char *name
)
2831 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2832 unsigned int ver
= BFD_VERSION
/ 10000;
2835 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
2836 _bfd_vms_output_short (recwr
, EMH__C_LNM
);
2837 snprintf (version
, sizeof (version
), "%s %d.%d.%d", name
,
2838 ver
/ 10000, (ver
/ 100) % 100, ver
% 100);
2839 _bfd_vms_output_dump (recwr
, (unsigned char *)version
, strlen (version
));
2840 _bfd_vms_output_end (abfd
, recwr
);
2844 /* Write eom record for bfd abfd. Return FALSE on error. */
2847 _bfd_vms_write_eeom (bfd
*abfd
)
2849 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2851 vms_debug2 ((2, "vms_write_eeom\n"));
2853 _bfd_vms_output_alignment (recwr
, 2);
2855 _bfd_vms_output_begin (recwr
, EOBJ__C_EEOM
);
2856 _bfd_vms_output_long (recwr
, PRIV (vms_linkage_index
+ 1) >> 1);
2857 _bfd_vms_output_byte (recwr
, 0); /* Completion code. */
2858 _bfd_vms_output_byte (recwr
, 0); /* Fill byte. */
2860 if ((abfd
->flags
& EXEC_P
) == 0
2861 && bfd_get_start_address (abfd
) != (bfd_vma
)-1)
2865 section
= bfd_get_section_by_name (abfd
, ".link");
2868 bfd_set_error (bfd_error_nonrepresentable_section
);
2871 _bfd_vms_output_short (recwr
, 0);
2872 _bfd_vms_output_long (recwr
, (unsigned long) section
->target_index
);
2873 _bfd_vms_output_long (recwr
,
2874 (unsigned long) bfd_get_start_address (abfd
));
2875 _bfd_vms_output_long (recwr
, 0);
2878 _bfd_vms_output_end (abfd
, recwr
);
2883 vector_grow1 (struct vector_type
*vec
, size_t elsz
)
2885 if (vec
->nbr_el
+ 1 < vec
->max_el
)
2888 if (vec
->max_el
== 0)
2891 vec
->els
= bfd_malloc2 (vec
->max_el
, elsz
);
2896 vec
->els
= bfd_realloc2 (vec
->els
, vec
->max_el
, elsz
);
2900 /* Bump ABFD file position to next block. */
2903 alpha_vms_file_position_block (bfd
*abfd
)
2906 PRIV (file_pos
) += VMS_BLOCK_SIZE
- 1;
2907 PRIV (file_pos
) -= (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
2910 /* Convert from internal structure SRC to external structure DST. */
2913 alpha_vms_swap_eisd_out (struct vms_internal_eisd_map
*src
,
2914 struct vms_eisd
*dst
)
2916 bfd_putl32 (src
->u
.eisd
.majorid
, dst
->majorid
);
2917 bfd_putl32 (src
->u
.eisd
.minorid
, dst
->minorid
);
2918 bfd_putl32 (src
->u
.eisd
.eisdsize
, dst
->eisdsize
);
2919 if (src
->u
.eisd
.eisdsize
<= EISD__K_LENEND
)
2921 bfd_putl32 (src
->u
.eisd
.secsize
, dst
->secsize
);
2922 bfd_putl64 (src
->u
.eisd
.virt_addr
, dst
->virt_addr
);
2923 bfd_putl32 (src
->u
.eisd
.flags
, dst
->flags
);
2924 bfd_putl32 (src
->u
.eisd
.vbn
, dst
->vbn
);
2925 dst
->pfc
= src
->u
.eisd
.pfc
;
2926 dst
->matchctl
= src
->u
.eisd
.matchctl
;
2927 dst
->type
= src
->u
.eisd
.type
;
2929 if (src
->u
.eisd
.flags
& EISD__M_GBL
)
2931 bfd_putl32 (src
->u
.gbl_eisd
.ident
, dst
->ident
);
2932 memcpy (dst
->gblnam
, src
->u
.gbl_eisd
.gblnam
,
2933 src
->u
.gbl_eisd
.gblnam
[0] + 1);
2937 /* Append EISD to the list of extra eisd for ABFD. */
2940 alpha_vms_append_extra_eisd (bfd
*abfd
, struct vms_internal_eisd_map
*eisd
)
2943 if (PRIV (gbl_eisd_head
) == NULL
)
2944 PRIV (gbl_eisd_head
) = eisd
;
2946 PRIV (gbl_eisd_tail
)->next
= eisd
;
2947 PRIV (gbl_eisd_tail
) = eisd
;
2950 /* Create an EISD for shared image SHRIMG.
2951 Return FALSE in case of error. */
2954 alpha_vms_create_eisd_for_shared (bfd
*abfd
, bfd
*shrimg
)
2956 struct vms_internal_eisd_map
*eisd
;
2959 namlen
= strlen (PRIV2 (shrimg
, hdr_data
.hdr_t_name
));
2960 if (namlen
+ 5 > EISD__K_GBLNAMLEN
)
2966 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
2970 /* Fill the fields. */
2971 eisd
->u
.gbl_eisd
.common
.majorid
= EISD__K_MAJORID
;
2972 eisd
->u
.gbl_eisd
.common
.minorid
= EISD__K_MINORID
;
2973 eisd
->u
.gbl_eisd
.common
.eisdsize
= (EISD__K_LEN
+ 4 + namlen
+ 5 + 3) & ~3;
2974 eisd
->u
.gbl_eisd
.common
.secsize
= VMS_BLOCK_SIZE
; /* Must not be 0. */
2975 eisd
->u
.gbl_eisd
.common
.virt_addr
= 0;
2976 eisd
->u
.gbl_eisd
.common
.flags
= EISD__M_GBL
;
2977 eisd
->u
.gbl_eisd
.common
.vbn
= 0;
2978 eisd
->u
.gbl_eisd
.common
.pfc
= 0;
2979 eisd
->u
.gbl_eisd
.common
.matchctl
= PRIV2 (shrimg
, matchctl
);
2980 eisd
->u
.gbl_eisd
.common
.type
= EISD__K_SHRPIC
;
2982 eisd
->u
.gbl_eisd
.ident
= PRIV2 (shrimg
, ident
);
2983 eisd
->u
.gbl_eisd
.gblnam
[0] = namlen
+ 4;
2984 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1, PRIV2 (shrimg
, hdr_data
.hdr_t_name
),
2986 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1 + namlen
, "_001", 4);
2988 /* Append it to the list. */
2989 alpha_vms_append_extra_eisd (abfd
, eisd
);
2994 /* Create an EISD for section SEC.
2995 Return FALSE in case of failure. */
2998 alpha_vms_create_eisd_for_section (bfd
*abfd
, asection
*sec
)
3000 struct vms_internal_eisd_map
*eisd
;
3002 /* Only for allocating section. */
3003 if (!(sec
->flags
& SEC_ALLOC
))
3006 BFD_ASSERT (vms_section_data (sec
)->eisd
== NULL
);
3007 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
3010 vms_section_data (sec
)->eisd
= eisd
;
3012 /* Fill the fields. */
3013 eisd
->u
.eisd
.majorid
= EISD__K_MAJORID
;
3014 eisd
->u
.eisd
.minorid
= EISD__K_MINORID
;
3015 eisd
->u
.eisd
.eisdsize
= EISD__K_LEN
;
3016 eisd
->u
.eisd
.secsize
=
3017 (sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
3018 eisd
->u
.eisd
.virt_addr
= sec
->vma
;
3019 eisd
->u
.eisd
.flags
= 0;
3020 eisd
->u
.eisd
.vbn
= 0; /* To be later defined. */
3021 eisd
->u
.eisd
.pfc
= 0; /* Default. */
3022 eisd
->u
.eisd
.matchctl
= EISD__K_MATALL
;
3023 eisd
->u
.eisd
.type
= EISD__K_NORMAL
;
3025 if (sec
->flags
& SEC_CODE
)
3026 eisd
->u
.eisd
.flags
|= EISD__M_EXE
;
3027 if (!(sec
->flags
& SEC_READONLY
))
3028 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
3030 /* If relocations or fixup will be applied, make this isect writeable. */
3031 if (sec
->flags
& SEC_RELOC
)
3032 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
3034 if (!(sec
->flags
& SEC_HAS_CONTENTS
))
3036 eisd
->u
.eisd
.flags
|= EISD__M_DZRO
;
3037 eisd
->u
.eisd
.flags
&= ~EISD__M_CRF
;
3039 if (sec
->flags
& SEC_LINKER_CREATED
)
3041 if (strcmp (sec
->name
, "$FIXUP$") == 0)
3042 eisd
->u
.eisd
.flags
|= EISD__M_FIXUPVEC
;
3045 /* Append it to the list. */
3047 if (PRIV (eisd_head
) == NULL
)
3048 PRIV (eisd_head
) = eisd
;
3050 PRIV (eisd_tail
)->next
= eisd
;
3051 PRIV (eisd_tail
) = eisd
;
3056 /* Layout executable ABFD and write it to the disk.
3057 Return FALSE in case of failure. */
3060 alpha_vms_write_exec (bfd
*abfd
)
3062 struct vms_eihd eihd
;
3063 struct vms_eiha
*eiha
;
3064 struct vms_eihi
*eihi
;
3065 struct vms_eihs
*eihs
= NULL
;
3067 struct vms_internal_eisd_map
*first_eisd
;
3068 struct vms_internal_eisd_map
*eisd
;
3071 file_ptr gst_filepos
= 0;
3072 unsigned int lnkflags
= 0;
3074 /* Build the EIHD. */
3075 PRIV (file_pos
) = EIHD__C_LENGTH
;
3077 memset (&eihd
, 0, sizeof (eihd
));
3078 memset (eihd
.fill_2
, 0xff, sizeof (eihd
.fill_2
));
3080 bfd_putl32 (EIHD__K_MAJORID
, eihd
.majorid
);
3081 bfd_putl32 (EIHD__K_MINORID
, eihd
.minorid
);
3083 bfd_putl32 (sizeof (eihd
), eihd
.size
);
3084 bfd_putl32 (0, eihd
.isdoff
);
3085 bfd_putl32 (0, eihd
.activoff
);
3086 bfd_putl32 (0, eihd
.symdbgoff
);
3087 bfd_putl32 (0, eihd
.imgidoff
);
3088 bfd_putl32 (0, eihd
.patchoff
);
3089 bfd_putl64 (0, eihd
.iafva
);
3090 bfd_putl32 (0, eihd
.version_array_off
);
3092 bfd_putl32 (EIHD__K_EXE
, eihd
.imgtype
);
3093 bfd_putl32 (0, eihd
.subtype
);
3095 bfd_putl32 (0, eihd
.imgiocnt
);
3096 bfd_putl32 (-1, eihd
.privreqs
);
3097 bfd_putl32 (-1, eihd
.privreqs
+ 4);
3099 bfd_putl32 ((sizeof (eihd
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
3101 bfd_putl32 (0, eihd
.ident
);
3102 bfd_putl32 (0, eihd
.sysver
);
3105 bfd_putl32 (0, eihd
.symvect_size
);
3106 bfd_putl32 (16, eihd
.virt_mem_block_size
);
3107 bfd_putl32 (0, eihd
.ext_fixup_off
);
3108 bfd_putl32 (0, eihd
.noopt_psect_off
);
3109 bfd_putl32 (-1, eihd
.alias
);
3112 eiha
= (struct vms_eiha
*)((char *) &eihd
+ PRIV (file_pos
));
3113 bfd_putl32 (PRIV (file_pos
), eihd
.activoff
);
3114 PRIV (file_pos
) += sizeof (struct vms_eiha
);
3116 bfd_putl32 (sizeof (struct vms_eiha
), eiha
->size
);
3117 bfd_putl32 (0, eiha
->spare
);
3118 bfd_putl64 (PRIV (transfer_address
[0]), eiha
->tfradr1
);
3119 bfd_putl64 (PRIV (transfer_address
[1]), eiha
->tfradr2
);
3120 bfd_putl64 (PRIV (transfer_address
[2]), eiha
->tfradr3
);
3121 bfd_putl64 (PRIV (transfer_address
[3]), eiha
->tfradr4
);
3122 bfd_putl64 (0, eiha
->inishr
);
3125 eihi
= (struct vms_eihi
*)((char *) &eihd
+ PRIV (file_pos
));
3126 bfd_putl32 (PRIV (file_pos
), eihd
.imgidoff
);
3127 PRIV (file_pos
) += sizeof (struct vms_eihi
);
3129 bfd_putl32 (EIHI__K_MAJORID
, eihi
->majorid
);
3130 bfd_putl32 (EIHI__K_MINORID
, eihi
->minorid
);
3135 /* Set module name. */
3136 module
= vms_get_module_name (bfd_get_filename (abfd
), TRUE
);
3137 len
= strlen (module
);
3138 if (len
> sizeof (eihi
->imgnam
) - 1)
3139 len
= sizeof (eihi
->imgnam
) - 1;
3140 eihi
->imgnam
[0] = len
;
3141 memcpy (eihi
->imgnam
+ 1, module
, len
);
3149 vms_get_time (&hi
, &lo
);
3150 bfd_putl32 (lo
, eihi
->linktime
+ 0);
3151 bfd_putl32 (hi
, eihi
->linktime
+ 4);
3154 eihi
->linkid
[0] = 0;
3155 eihi
->imgbid
[0] = 0;
3158 dst
= PRIV (dst_section
);
3159 dmt
= bfd_get_section_by_name (abfd
, "$DMT$");
3160 if (dst
!= NULL
&& dst
->size
!= 0)
3162 eihs
= (struct vms_eihs
*)((char *) &eihd
+ PRIV (file_pos
));
3163 bfd_putl32 (PRIV (file_pos
), eihd
.symdbgoff
);
3164 PRIV (file_pos
) += sizeof (struct vms_eihs
);
3166 bfd_putl32 (EIHS__K_MAJORID
, eihs
->majorid
);
3167 bfd_putl32 (EIHS__K_MINORID
, eihs
->minorid
);
3168 bfd_putl32 (0, eihs
->dstvbn
);
3169 bfd_putl32 (0, eihs
->dstsize
);
3170 bfd_putl32 (0, eihs
->gstvbn
);
3171 bfd_putl32 (0, eihs
->gstsize
);
3172 bfd_putl32 (0, eihs
->dmtvbn
);
3173 bfd_putl32 (0, eihs
->dmtsize
);
3176 /* One EISD per section. */
3177 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3179 if (!alpha_vms_create_eisd_for_section (abfd
, sec
))
3183 /* Merge section EIDS which extra ones. */
3184 if (PRIV (eisd_tail
))
3185 PRIV (eisd_tail
)->next
= PRIV (gbl_eisd_head
);
3187 PRIV (eisd_head
) = PRIV (gbl_eisd_head
);
3188 if (PRIV (gbl_eisd_tail
))
3189 PRIV (eisd_tail
) = PRIV (gbl_eisd_tail
);
3191 first_eisd
= PRIV (eisd_head
);
3193 /* Add end of eisd. */
3196 eisd
= bfd_zalloc (abfd
, sizeof (*eisd
));
3199 eisd
->u
.eisd
.majorid
= 0;
3200 eisd
->u
.eisd
.minorid
= 0;
3201 eisd
->u
.eisd
.eisdsize
= 0;
3202 alpha_vms_append_extra_eisd (abfd
, eisd
);
3205 /* Place EISD in the file. */
3206 for (eisd
= first_eisd
; eisd
; eisd
= eisd
->next
)
3208 file_ptr room
= VMS_BLOCK_SIZE
- (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
3210 /* First block is a little bit special: there is a word at the end. */
3211 if (PRIV (file_pos
) < VMS_BLOCK_SIZE
&& room
> 2)
3213 if (room
< eisd
->u
.eisd
.eisdsize
+ EISD__K_LENEND
)
3214 alpha_vms_file_position_block (abfd
);
3216 eisd
->file_pos
= PRIV (file_pos
);
3217 PRIV (file_pos
) += eisd
->u
.eisd
.eisdsize
;
3219 if (eisd
->u
.eisd
.flags
& EISD__M_FIXUPVEC
)
3220 bfd_putl64 (eisd
->u
.eisd
.virt_addr
, eihd
.iafva
);
3223 if (first_eisd
!= NULL
)
3225 bfd_putl32 (first_eisd
->file_pos
, eihd
.isdoff
);
3226 /* Real size of end of eisd marker. */
3227 PRIV (file_pos
) += EISD__K_LENEND
;
3230 bfd_putl32 (PRIV (file_pos
), eihd
.size
);
3231 bfd_putl32 ((PRIV (file_pos
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
3234 /* Place sections. */
3235 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3237 if (!(sec
->flags
& SEC_HAS_CONTENTS
))
3240 eisd
= vms_section_data (sec
)->eisd
;
3242 /* Align on a block. */
3243 alpha_vms_file_position_block (abfd
);
3244 sec
->filepos
= PRIV (file_pos
);
3247 eisd
->u
.eisd
.vbn
= (sec
->filepos
/ VMS_BLOCK_SIZE
) + 1;
3249 PRIV (file_pos
) += sec
->size
;
3253 if (eihs
!= NULL
&& dst
!= NULL
)
3255 bfd_putl32 ((dst
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dstvbn
);
3256 bfd_putl32 (dst
->size
, eihs
->dstsize
);
3260 lnkflags
|= EIHD__M_DBGDMT
;
3261 bfd_putl32 ((dmt
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dmtvbn
);
3262 bfd_putl32 (dmt
->size
, eihs
->dmtsize
);
3264 if (PRIV (gsd_sym_count
) != 0)
3266 alpha_vms_file_position_block (abfd
);
3267 gst_filepos
= PRIV (file_pos
);
3268 bfd_putl32 ((gst_filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->gstvbn
);
3269 bfd_putl32 ((PRIV (gsd_sym_count
) + 4) / 5 + 4, eihs
->gstsize
);
3273 /* Write EISD in hdr. */
3274 for (eisd
= first_eisd
; eisd
&& eisd
->file_pos
< VMS_BLOCK_SIZE
;
3276 alpha_vms_swap_eisd_out
3277 (eisd
, (struct vms_eisd
*)((char *)&eihd
+ eisd
->file_pos
));
3279 /* Write first block. */
3280 bfd_putl32 (lnkflags
, eihd
.lnkflags
);
3281 if (bfd_bwrite (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
3284 /* Write remaining eisd. */
3287 unsigned char blk
[VMS_BLOCK_SIZE
];
3288 struct vms_internal_eisd_map
*next_eisd
;
3290 memset (blk
, 0xff, sizeof (blk
));
3291 while (eisd
!= NULL
)
3293 alpha_vms_swap_eisd_out
3295 (struct vms_eisd
*)(blk
+ (eisd
->file_pos
% VMS_BLOCK_SIZE
)));
3297 next_eisd
= eisd
->next
;
3298 if (next_eisd
== NULL
3299 || (next_eisd
->file_pos
/ VMS_BLOCK_SIZE
3300 != eisd
->file_pos
/ VMS_BLOCK_SIZE
))
3302 if (bfd_bwrite (blk
, sizeof (blk
), abfd
) != sizeof (blk
))
3305 memset (blk
, 0xff, sizeof (blk
));
3311 /* Write sections. */
3312 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3314 unsigned char blk
[VMS_BLOCK_SIZE
];
3317 if (sec
->size
== 0 || !(sec
->flags
& SEC_HAS_CONTENTS
))
3319 if (bfd_bwrite (sec
->contents
, sec
->size
, abfd
) != sec
->size
)
3323 len
= VMS_BLOCK_SIZE
- sec
->size
% VMS_BLOCK_SIZE
;
3324 if (len
!= VMS_BLOCK_SIZE
)
3326 memset (blk
, 0, len
);
3327 if (bfd_bwrite (blk
, len
, abfd
) != len
)
3333 if (gst_filepos
!= 0)
3335 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3338 _bfd_vms_write_emh (abfd
);
3339 _bfd_vms_write_lmn (abfd
, "GNU LD");
3341 /* PSC for the absolute section. */
3342 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3343 _bfd_vms_output_long (recwr
, 0);
3344 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3345 _bfd_vms_output_short (recwr
, 0);
3346 _bfd_vms_output_short (recwr
, EGPS__V_PIC
| EGPS__V_LIB
| EGPS__V_RD
);
3347 _bfd_vms_output_long (recwr
, 0);
3348 _bfd_vms_output_counted (recwr
, ".$$ABS$$.");
3349 _bfd_vms_output_end_subrec (recwr
);
3350 _bfd_vms_output_end (abfd
, recwr
);
3352 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
3354 struct vms_symbol_entry
*sym
= PRIV (syms
)[i
];
3360 _bfd_vms_output_alignment (recwr
, 8);
3361 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3362 _bfd_vms_output_long (recwr
, 0);
3364 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYMG
);
3365 _bfd_vms_output_short (recwr
, 0); /* Data type, alignment. */
3366 _bfd_vms_output_short (recwr
, sym
->flags
);
3368 if (sym
->code_section
)
3369 ep
= alpha_vms_get_sym_value (sym
->code_section
, sym
->code_value
);
3372 BFD_ASSERT (sym
->code_value
== 0);
3375 val
= alpha_vms_get_sym_value (sym
->section
, sym
->value
);
3376 _bfd_vms_output_quad
3377 (recwr
, sym
->typ
== EGSD__C_SYMG
? sym
->symbol_vector
: val
);
3378 _bfd_vms_output_quad (recwr
, ep
);
3379 _bfd_vms_output_quad (recwr
, val
);
3380 _bfd_vms_output_long (recwr
, 0);
3381 _bfd_vms_output_counted (recwr
, sym
->name
);
3382 _bfd_vms_output_end_subrec (recwr
);
3384 _bfd_vms_output_end (abfd
, recwr
);
3387 _bfd_vms_output_end (abfd
, recwr
);
3389 if (!_bfd_vms_write_eeom (abfd
))
3397 /* Write section and symbol directory of bfd abfd. Return FALSE on error. */
3400 _bfd_vms_write_egsd (bfd
*abfd
)
3404 unsigned int symnum
;
3406 flagword new_flags
, old_flags
;
3407 int abs_section_index
= -1;
3408 unsigned int target_index
= 0;
3409 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3411 vms_debug2 ((2, "vms_write_egsd\n"));
3413 /* Egsd is quadword aligned. */
3414 _bfd_vms_output_alignment (recwr
, 8);
3416 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3417 _bfd_vms_output_long (recwr
, 0);
3419 /* Number sections. */
3420 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3422 if (section
->flags
& SEC_DEBUGGING
)
3424 if (!strcmp (section
->name
, ".vmsdebug"))
3426 section
->flags
|= SEC_DEBUGGING
;
3429 section
->target_index
= target_index
++;
3432 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3434 vms_debug2 ((3, "Section #%d %s, %d bytes\n",
3435 section
->target_index
, section
->name
, (int)section
->size
));
3437 /* Don't write out the VMS debug info section since it is in the
3438 ETBT and EDBG sections in etir. */
3439 if (section
->flags
& SEC_DEBUGGING
)
3442 /* 13 bytes egsd, max 31 chars name -> should be 44 bytes. */
3443 if (_bfd_vms_output_check (recwr
, 64) < 0)
3445 _bfd_vms_output_end (abfd
, recwr
);
3446 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3447 _bfd_vms_output_long (recwr
, 0);
3450 /* Don't know if this is necessary for the linker but for now it keeps
3451 vms_slurp_gsd happy. */
3452 sname
= section
->name
;
3455 /* Remove leading dot. */
3457 if ((*sname
== 't') && (strcmp (sname
, "text") == 0))
3458 sname
= EVAX_CODE_NAME
;
3459 else if ((*sname
== 'd') && (strcmp (sname
, "data") == 0))
3460 sname
= EVAX_DATA_NAME
;
3461 else if ((*sname
== 'b') && (strcmp (sname
, "bss") == 0))
3462 sname
= EVAX_BSS_NAME
;
3463 else if ((*sname
== 'l') && (strcmp (sname
, "link") == 0))
3464 sname
= EVAX_LINK_NAME
;
3465 else if ((*sname
== 'r') && (strcmp (sname
, "rdata") == 0))
3466 sname
= EVAX_READONLY_NAME
;
3467 else if ((*sname
== 'l') && (strcmp (sname
, "literal") == 0))
3468 sname
= EVAX_LITERAL_NAME
;
3469 else if ((*sname
== 'l') && (strcmp (sname
, "literals") == 0))
3470 sname
= EVAX_LITERALS_NAME
;
3471 else if ((*sname
== 'c') && (strcmp (sname
, "comm") == 0))
3472 sname
= EVAX_COMMON_NAME
;
3473 else if ((*sname
== 'l') && (strcmp (sname
, "lcomm") == 0))
3474 sname
= EVAX_LOCAL_NAME
;
3477 if (bfd_is_com_section (section
))
3478 new_flags
= (EGPS__V_OVR
| EGPS__V_REL
| EGPS__V_GBL
| EGPS__V_RD
3479 | EGPS__V_WRT
| EGPS__V_NOMOD
| EGPS__V_COM
);
3481 new_flags
= vms_esecflag_by_name (evax_section_flags
, sname
,
3484 /* Modify them as directed. */
3485 if (section
->flags
& SEC_READONLY
)
3486 new_flags
&= ~EGPS__V_WRT
;
3488 new_flags
&= ~vms_section_data (section
)->no_flags
;
3489 new_flags
|= vms_section_data (section
)->flags
;
3491 vms_debug2 ((3, "sec flags %x\n", section
->flags
));
3492 vms_debug2 ((3, "new_flags %x, _raw_size %lu\n",
3493 new_flags
, (unsigned long)section
->size
));
3495 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3496 _bfd_vms_output_short (recwr
, section
->alignment_power
& 0xff);
3497 _bfd_vms_output_short (recwr
, new_flags
);
3498 _bfd_vms_output_long (recwr
, (unsigned long) section
->size
);
3499 _bfd_vms_output_counted (recwr
, sname
);
3500 _bfd_vms_output_end_subrec (recwr
);
3502 /* If the section is an obsolute one, remind its index as it will be
3503 used later for absolute symbols. */
3504 if ((new_flags
& EGPS__V_REL
) == 0 && abs_section_index
< 0)
3505 abs_section_index
= section
->target_index
;
3508 /* Output symbols. */
3509 vms_debug2 ((3, "%d symbols found\n", abfd
->symcount
));
3511 bfd_set_start_address (abfd
, (bfd_vma
) -1);
3513 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3515 symbol
= abfd
->outsymbols
[symnum
];
3516 old_flags
= symbol
->flags
;
3518 /* Work-around a missing feature: consider __main as the main entry
3520 if (symbol
->name
[0] == '_' && strcmp (symbol
->name
, "__main") == 0)
3521 bfd_set_start_address (abfd
, (bfd_vma
)symbol
->value
);
3523 /* Only put in the GSD the global and the undefined symbols. */
3524 if (old_flags
& BSF_FILE
)
3527 if ((old_flags
& BSF_GLOBAL
) == 0 && !bfd_is_und_section (symbol
->section
))
3529 /* If the LIB$INITIIALIZE section is present, add a reference to
3530 LIB$INITIALIZE symbol. FIXME: this should be done explicitely
3531 in the assembly file. */
3532 if (!((old_flags
& BSF_SECTION_SYM
) != 0
3533 && strcmp (symbol
->section
->name
, "LIB$INITIALIZE") == 0))
3537 /* 13 bytes egsd, max 64 chars name -> should be 77 bytes. Add 16 more
3538 bytes for a possible ABS section. */
3539 if (_bfd_vms_output_check (recwr
, 80 + 16) < 0)
3541 _bfd_vms_output_end (abfd
, recwr
);
3542 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3543 _bfd_vms_output_long (recwr
, 0);
3546 if ((old_flags
& BSF_GLOBAL
) != 0
3547 && bfd_is_abs_section (symbol
->section
)
3548 && abs_section_index
<= 0)
3550 /* Create an absolute section if none was defined. It is highly
3551 unlikely that the name $ABS$ clashes with a user defined
3552 non-absolute section name. */
3553 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3554 _bfd_vms_output_short (recwr
, 4);
3555 _bfd_vms_output_short (recwr
, EGPS__V_SHR
);
3556 _bfd_vms_output_long (recwr
, 0);
3557 _bfd_vms_output_counted (recwr
, "$ABS$");
3558 _bfd_vms_output_end_subrec (recwr
);
3560 abs_section_index
= target_index
++;
3563 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYM
);
3565 /* Data type, alignment. */
3566 _bfd_vms_output_short (recwr
, 0);
3570 if (old_flags
& BSF_WEAK
)
3571 new_flags
|= EGSY__V_WEAK
;
3572 if (bfd_is_com_section (symbol
->section
)) /* .comm */
3573 new_flags
|= (EGSY__V_WEAK
| EGSY__V_COMM
);
3575 if (old_flags
& BSF_FUNCTION
)
3577 new_flags
|= EGSY__V_NORM
;
3578 new_flags
|= EGSY__V_REL
;
3580 if (old_flags
& BSF_GLOBAL
)
3582 new_flags
|= EGSY__V_DEF
;
3583 if (!bfd_is_abs_section (symbol
->section
))
3584 new_flags
|= EGSY__V_REL
;
3586 _bfd_vms_output_short (recwr
, new_flags
);
3588 if (old_flags
& BSF_GLOBAL
)
3590 /* Symbol definition. */
3591 bfd_vma code_address
= 0;
3592 unsigned long ca_psindx
= 0;
3593 unsigned long psindx
;
3595 if ((old_flags
& BSF_FUNCTION
) && symbol
->udata
.p
!= NULL
)
3600 ((struct evax_private_udata_struct
*)symbol
->udata
.p
)->enbsym
;
3601 code_address
= sym
->value
;
3602 ca_psindx
= sym
->section
->target_index
;
3604 if (bfd_is_abs_section (symbol
->section
))
3605 psindx
= abs_section_index
;
3607 psindx
= symbol
->section
->target_index
;
3609 _bfd_vms_output_quad (recwr
, symbol
->value
);
3610 _bfd_vms_output_quad (recwr
, code_address
);
3611 _bfd_vms_output_long (recwr
, ca_psindx
);
3612 _bfd_vms_output_long (recwr
, psindx
);
3614 _bfd_vms_output_counted (recwr
, symbol
->name
);
3616 _bfd_vms_output_end_subrec (recwr
);
3619 _bfd_vms_output_alignment (recwr
, 8);
3620 _bfd_vms_output_end (abfd
, recwr
);
3625 /* Write object header for bfd abfd. Return FALSE on error. */
3628 _bfd_vms_write_ehdr (bfd
*abfd
)
3631 unsigned int symnum
;
3632 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3634 vms_debug2 ((2, "vms_write_ehdr (%p)\n", abfd
));
3636 _bfd_vms_output_alignment (recwr
, 2);
3638 _bfd_vms_write_emh (abfd
);
3639 _bfd_vms_write_lmn (abfd
, "GNU AS");
3642 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3643 _bfd_vms_output_short (recwr
, EMH__C_SRC
);
3645 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3647 symbol
= abfd
->outsymbols
[symnum
];
3649 if (symbol
->flags
& BSF_FILE
)
3651 _bfd_vms_output_dump (recwr
, (unsigned char *) symbol
->name
,
3652 (int) strlen (symbol
->name
));
3657 if (symnum
== abfd
->symcount
)
3658 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("noname"));
3660 _bfd_vms_output_end (abfd
, recwr
);
3663 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3664 _bfd_vms_output_short (recwr
, EMH__C_TTL
);
3665 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("TTL"));
3666 _bfd_vms_output_end (abfd
, recwr
);
3669 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3670 _bfd_vms_output_short (recwr
, EMH__C_CPR
);
3671 _bfd_vms_output_dump (recwr
,
3672 (unsigned char *)"GNU BFD ported by Klaus Kämpf 1994-1996",
3674 _bfd_vms_output_end (abfd
, recwr
);
3679 /* Part 4.6, relocations. */
3682 /* WRITE ETIR SECTION
3684 This is still under construction and therefore not documented. */
3686 /* Close the etir/etbt record. */
3689 end_etir_record (bfd
* abfd
)
3691 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3693 _bfd_vms_output_end (abfd
, recwr
);
3697 start_etir_or_etbt_record (bfd
*abfd
, asection
*section
, bfd_vma offset
)
3699 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3701 if (section
->flags
& SEC_DEBUGGING
)
3703 _bfd_vms_output_begin (recwr
, EOBJ__C_ETBT
);
3707 /* Push start offset. */
3708 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3709 _bfd_vms_output_long (recwr
, (unsigned long) 0);
3710 _bfd_vms_output_end_subrec (recwr
);
3713 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_DFLOC
);
3714 _bfd_vms_output_end_subrec (recwr
);
3719 _bfd_vms_output_begin (recwr
, EOBJ__C_ETIR
);
3723 /* Push start offset. */
3724 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3725 _bfd_vms_output_long (recwr
, (unsigned long) section
->target_index
);
3726 _bfd_vms_output_quad (recwr
, offset
);
3727 _bfd_vms_output_end_subrec (recwr
);
3729 /* Start = pop (). */
3730 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_SETRB
);
3731 _bfd_vms_output_end_subrec (recwr
);
3736 /* Output a STO_IMM command for SSIZE bytes of data from CPR at virtual
3737 address VADDR in section specified by SEC_INDEX and NAME. */
3740 sto_imm (bfd
*abfd
, asection
*section
,
3741 bfd_size_type ssize
, unsigned char *cptr
, bfd_vma vaddr
)
3744 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3747 _bfd_vms_debug (8, "sto_imm %d bytes\n", (int) ssize
);
3748 _bfd_hexdump (9, cptr
, (int) ssize
, (int) vaddr
);
3753 /* Try all the rest. */
3756 if (_bfd_vms_output_check (recwr
, size
) < 0)
3758 /* Doesn't fit, split ! */
3759 end_etir_record (abfd
);
3761 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3763 size
= _bfd_vms_output_check (recwr
, 0); /* get max size */
3764 if (size
> ssize
) /* more than what's left ? */
3768 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_IMM
);
3769 _bfd_vms_output_long (recwr
, (unsigned long) (size
));
3770 _bfd_vms_output_dump (recwr
, cptr
, size
);
3771 _bfd_vms_output_end_subrec (recwr
);
3774 _bfd_vms_debug (10, "dumped %d bytes\n", (int) size
);
3775 _bfd_hexdump (10, cptr
, (int) size
, (int) vaddr
);
3785 etir_output_check (bfd
*abfd
, asection
*section
, bfd_vma vaddr
, int checklen
)
3787 if (_bfd_vms_output_check (&PRIV (recwr
), checklen
) < 0)
3789 /* Not enough room in this record. Close it and open a new one. */
3790 end_etir_record (abfd
);
3791 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3795 /* Return whether RELOC must be deferred till the end. */
3798 defer_reloc_p (arelent
*reloc
)
3800 switch (reloc
->howto
->type
)
3813 /* Write section contents for bfd abfd. Return FALSE on error. */
3816 _bfd_vms_write_etir (bfd
* abfd
, int objtype ATTRIBUTE_UNUSED
)
3819 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3821 vms_debug2 ((2, "vms_write_tir (%p, %d)\n", abfd
, objtype
));
3823 _bfd_vms_output_alignment (recwr
, 4);
3825 PRIV (vms_linkage_index
) = 0;
3827 for (section
= abfd
->sections
; section
; section
= section
->next
)
3829 vms_debug2 ((4, "writing %d. section '%s' (%d bytes)\n",
3830 section
->target_index
, section
->name
, (int) (section
->size
)));
3832 if (!(section
->flags
& SEC_HAS_CONTENTS
)
3833 || bfd_is_com_section (section
))
3836 if (!section
->contents
)
3838 bfd_set_error (bfd_error_no_contents
);
3842 start_etir_or_etbt_record (abfd
, section
, 0);
3844 if (section
->flags
& SEC_RELOC
)
3846 bfd_vma curr_addr
= 0;
3847 unsigned char *curr_data
= section
->contents
;
3849 int pass2_needed
= 0;
3850 int pass2_in_progress
= 0;
3853 if (section
->reloc_count
== 0)
3855 (_("SEC_RELOC with no relocs in section %pA"), section
);
3860 int i
= section
->reloc_count
;
3861 arelent
**rptr
= section
->orelocation
;
3862 _bfd_vms_debug (4, "%d relocations:\n", i
);
3865 _bfd_vms_debug (4, "sym %s in sec %s, value %08lx, "
3866 "addr %08lx, off %08lx, len %d: %s\n",
3867 (*(*rptr
)->sym_ptr_ptr
)->name
,
3868 (*(*rptr
)->sym_ptr_ptr
)->section
->name
,
3869 (long) (*(*rptr
)->sym_ptr_ptr
)->value
,
3870 (unsigned long)(*rptr
)->address
,
3871 (unsigned long)(*rptr
)->addend
,
3872 bfd_get_reloc_size ((*rptr
)->howto
),
3873 ( *rptr
)->howto
->name
);
3880 for (irel
= 0; irel
< section
->reloc_count
; irel
++)
3882 struct evax_private_udata_struct
*udata
;
3883 arelent
*rptr
= section
->orelocation
[irel
];
3884 bfd_vma addr
= rptr
->address
;
3885 asymbol
*sym
= *rptr
->sym_ptr_ptr
;
3886 asection
*sec
= sym
->section
;
3887 bfd_boolean defer
= defer_reloc_p (rptr
);
3890 if (pass2_in_progress
)
3892 /* Non-deferred relocs have already been output. */
3898 /* Deferred relocs must be output at the very end. */
3905 /* Regular relocs are intertwined with binary data. */
3906 if (curr_addr
> addr
)
3907 _bfd_error_handler (_("size error in section %pA"),
3909 size
= addr
- curr_addr
;
3910 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
3915 size
= bfd_get_reloc_size (rptr
->howto
);
3917 switch (rptr
->howto
->type
)
3919 case ALPHA_R_IGNORE
:
3922 case ALPHA_R_REFLONG
:
3923 if (bfd_is_und_section (sym
->section
))
3925 bfd_vma addend
= rptr
->addend
;
3926 slen
= strlen ((char *) sym
->name
);
3927 etir_output_check (abfd
, section
, curr_addr
, slen
);
3930 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
3931 _bfd_vms_output_counted (recwr
, sym
->name
);
3932 _bfd_vms_output_end_subrec (recwr
);
3933 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3934 _bfd_vms_output_long (recwr
, (unsigned long) addend
);
3935 _bfd_vms_output_end_subrec (recwr
);
3936 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
3937 _bfd_vms_output_end_subrec (recwr
);
3938 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3939 _bfd_vms_output_end_subrec (recwr
);
3943 _bfd_vms_output_begin_subrec
3944 (recwr
, ETIR__C_STO_GBL_LW
);
3945 _bfd_vms_output_counted (recwr
, sym
->name
);
3946 _bfd_vms_output_end_subrec (recwr
);
3949 else if (bfd_is_abs_section (sym
->section
))
3951 etir_output_check (abfd
, section
, curr_addr
, 16);
3952 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3953 _bfd_vms_output_long (recwr
, (unsigned long) sym
->value
);
3954 _bfd_vms_output_end_subrec (recwr
);
3955 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3956 _bfd_vms_output_end_subrec (recwr
);
3960 etir_output_check (abfd
, section
, curr_addr
, 32);
3961 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3962 _bfd_vms_output_long (recwr
,
3963 (unsigned long) sec
->target_index
);
3964 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
3965 _bfd_vms_output_end_subrec (recwr
);
3966 /* ??? Table B-8 of the OpenVMS Linker Utilily Manual
3967 says that we should have a ETIR__C_STO_OFF here.
3968 But the relocation would not be BFD_RELOC_32 then.
3969 This case is very likely unreachable. */
3970 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3971 _bfd_vms_output_end_subrec (recwr
);
3975 case ALPHA_R_REFQUAD
:
3976 if (bfd_is_und_section (sym
->section
))
3978 bfd_vma addend
= rptr
->addend
;
3979 slen
= strlen ((char *) sym
->name
);
3980 etir_output_check (abfd
, section
, curr_addr
, slen
);
3983 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
3984 _bfd_vms_output_counted (recwr
, sym
->name
);
3985 _bfd_vms_output_end_subrec (recwr
);
3986 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
3987 _bfd_vms_output_quad (recwr
, addend
);
3988 _bfd_vms_output_end_subrec (recwr
);
3989 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
3990 _bfd_vms_output_end_subrec (recwr
);
3991 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
3992 _bfd_vms_output_end_subrec (recwr
);
3996 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_GBL
);
3997 _bfd_vms_output_counted (recwr
, sym
->name
);
3998 _bfd_vms_output_end_subrec (recwr
);
4001 else if (bfd_is_abs_section (sym
->section
))
4003 etir_output_check (abfd
, section
, curr_addr
, 16);
4004 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
4005 _bfd_vms_output_quad (recwr
, sym
->value
);
4006 _bfd_vms_output_end_subrec (recwr
);
4007 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
4008 _bfd_vms_output_end_subrec (recwr
);
4012 etir_output_check (abfd
, section
, curr_addr
, 32);
4013 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
4014 _bfd_vms_output_long (recwr
,
4015 (unsigned long) sec
->target_index
);
4016 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
4017 _bfd_vms_output_end_subrec (recwr
);
4018 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_OFF
);
4019 _bfd_vms_output_end_subrec (recwr
);
4024 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
4027 case ALPHA_R_LINKAGE
:
4029 etir_output_check (abfd
, section
, curr_addr
, 64);
4030 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LP_PSB
);
4031 _bfd_vms_output_long
4032 (recwr
, (unsigned long) rptr
->addend
);
4033 if (rptr
->addend
> PRIV (vms_linkage_index
))
4034 PRIV (vms_linkage_index
) = rptr
->addend
;
4035 _bfd_vms_output_counted (recwr
, sym
->name
);
4036 _bfd_vms_output_byte (recwr
, 0);
4037 _bfd_vms_output_end_subrec (recwr
);
4040 case ALPHA_R_CODEADDR
:
4041 slen
= strlen ((char *) sym
->name
);
4042 etir_output_check (abfd
, section
, curr_addr
, slen
);
4043 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_CA
);
4044 _bfd_vms_output_counted (recwr
, sym
->name
);
4045 _bfd_vms_output_end_subrec (recwr
);
4050 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4051 etir_output_check (abfd
, section
, curr_addr
,
4052 32 + 1 + strlen (udata
->origname
));
4053 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_NOP_GBL
);
4054 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
4055 _bfd_vms_output_long
4056 (recwr
, (unsigned long) section
->target_index
);
4057 _bfd_vms_output_quad (recwr
, rptr
->address
);
4058 _bfd_vms_output_long (recwr
, (unsigned long) 0x47ff041f);
4059 _bfd_vms_output_long
4060 (recwr
, (unsigned long) section
->target_index
);
4061 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4062 _bfd_vms_output_counted (recwr
, udata
->origname
);
4063 _bfd_vms_output_end_subrec (recwr
);
4067 _bfd_error_handler (_("spurious ALPHA_R_BSR reloc"));
4072 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4073 etir_output_check (abfd
, section
, curr_addr
,
4074 32 + 1 + strlen (udata
->origname
));
4075 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LDA_GBL
);
4076 _bfd_vms_output_long
4077 (recwr
, (unsigned long) udata
->lkindex
+ 1);
4078 _bfd_vms_output_long
4079 (recwr
, (unsigned long) section
->target_index
);
4080 _bfd_vms_output_quad (recwr
, rptr
->address
);
4081 _bfd_vms_output_long (recwr
, (unsigned long) 0x237B0000);
4082 _bfd_vms_output_long
4083 (recwr
, (unsigned long) udata
->bsym
->section
->target_index
);
4084 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4085 _bfd_vms_output_counted (recwr
, udata
->origname
);
4086 _bfd_vms_output_end_subrec (recwr
);
4091 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4092 etir_output_check (abfd
, section
, curr_addr
,
4093 32 + 1 + strlen (udata
->origname
));
4094 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_BOH_GBL
);
4095 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
4096 _bfd_vms_output_long
4097 (recwr
, (unsigned long) section
->target_index
);
4098 _bfd_vms_output_quad (recwr
, rptr
->address
);
4099 _bfd_vms_output_long (recwr
, (unsigned long) 0xD3400000);
4100 _bfd_vms_output_long
4101 (recwr
, (unsigned long) section
->target_index
);
4102 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4103 _bfd_vms_output_counted (recwr
, udata
->origname
);
4104 _bfd_vms_output_end_subrec (recwr
);
4108 _bfd_error_handler (_("unhandled relocation %s"),
4115 } /* End of relocs loop. */
4117 if (!pass2_in_progress
)
4119 /* Output rest of section. */
4120 if (curr_addr
> section
->size
)
4122 _bfd_error_handler (_("size error in section %pA"), section
);
4125 size
= section
->size
- curr_addr
;
4126 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
4132 pass2_in_progress
= 1;
4138 else /* (section->flags & SEC_RELOC) */
4139 sto_imm (abfd
, section
, section
->size
, section
->contents
, 0);
4141 end_etir_record (abfd
);
4144 _bfd_vms_output_alignment (recwr
, 2);
4148 /* Write cached information into a file being written, at bfd_close. */
4151 alpha_vms_write_object_contents (bfd
*abfd
)
4153 vms_debug2 ((1, "vms_write_object_contents (%p)\n", abfd
));
4155 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
4157 return alpha_vms_write_exec (abfd
);
4161 if (abfd
->section_count
> 0) /* we have sections */
4163 if (!_bfd_vms_write_ehdr (abfd
))
4165 if (!_bfd_vms_write_egsd (abfd
))
4167 if (!_bfd_vms_write_etir (abfd
, EOBJ__C_ETIR
))
4169 if (!_bfd_vms_write_eeom (abfd
))
4176 /* Debug stuff: nearest line. */
4178 #define SET_MODULE_PARSED(m) \
4179 do { if ((m)->name == NULL) (m)->name = ""; } while (0)
4180 #define IS_MODULE_PARSED(m) ((m)->name != NULL)
4182 /* Build a new module for the specified BFD. */
4184 static struct module
*
4185 new_module (bfd
*abfd
)
4187 struct module
*module
4188 = (struct module
*) bfd_zalloc (abfd
, sizeof (struct module
));
4189 module
->file_table_count
= 16; /* Arbitrary. */
4191 = bfd_malloc (module
->file_table_count
* sizeof (struct fileinfo
));
4195 /* Parse debug info for a module and internalize it. */
4198 parse_module (bfd
*abfd
, struct module
*module
, unsigned char *ptr
,
4201 unsigned char *maxptr
= ptr
+ length
;
4202 unsigned char *src_ptr
, *pcl_ptr
;
4203 unsigned int prev_linum
= 0, curr_linenum
= 0;
4204 bfd_vma prev_pc
= 0, curr_pc
= 0;
4205 struct srecinfo
*curr_srec
, *srec
;
4206 struct lineinfo
*curr_line
, *line
;
4207 struct funcinfo
*funcinfo
;
4209 /* Initialize tables with zero element. */
4210 curr_srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4211 module
->srec_table
= curr_srec
;
4213 curr_line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4214 module
->line_table
= curr_line
;
4216 while (length
== -1 || ptr
< maxptr
)
4218 /* The first byte is not counted in the recorded length. */
4219 int rec_length
= bfd_getl16 (ptr
) + 1;
4220 int rec_type
= bfd_getl16 (ptr
+ 2);
4222 vms_debug2 ((2, "DST record: leng %d, type %d\n", rec_length
, rec_type
));
4224 if (length
== -1 && rec_type
== DST__K_MODEND
)
4231 = _bfd_vms_save_counted_string (ptr
+ DST_S_B_MODBEG_NAME
,
4232 maxptr
- (ptr
+ DST_S_B_MODBEG_NAME
));
4239 vms_debug2 ((3, "module: %s\n", module
->name
));
4246 funcinfo
= (struct funcinfo
*)
4247 bfd_zalloc (abfd
, sizeof (struct funcinfo
));
4249 = _bfd_vms_save_counted_string (ptr
+ DST_S_B_RTNBEG_NAME
,
4250 maxptr
- (ptr
+ DST_S_B_RTNBEG_NAME
));
4251 funcinfo
->low
= bfd_getl32 (ptr
+ DST_S_L_RTNBEG_ADDRESS
);
4252 funcinfo
->next
= module
->func_table
;
4253 module
->func_table
= funcinfo
;
4255 vms_debug2 ((3, "routine: %s at 0x%lx\n",
4256 funcinfo
->name
, (unsigned long) funcinfo
->low
));
4260 module
->func_table
->high
= module
->func_table
->low
4261 + bfd_getl32 (ptr
+ DST_S_L_RTNEND_SIZE
) - 1;
4263 if (module
->func_table
->high
> module
->high
)
4264 module
->high
= module
->func_table
->high
;
4266 vms_debug2 ((3, "end routine\n"));
4270 vms_debug2 ((3, "prologue\n"));
4274 vms_debug2 ((3, "epilog\n"));
4278 vms_debug2 ((3, "block\n"));
4282 vms_debug2 ((3, "end block\n"));
4286 src_ptr
= ptr
+ DST_S_C_SOURCE_HEADER_SIZE
;
4288 vms_debug2 ((3, "source info\n"));
4290 while (src_ptr
< ptr
+ rec_length
)
4292 int cmd
= src_ptr
[0], cmd_length
, data
;
4296 case DST__K_SRC_DECLFILE
:
4299 = bfd_getl16 (src_ptr
+ DST_S_W_SRC_DF_FILEID
);
4301 = _bfd_vms_save_counted_string (src_ptr
+ DST_S_B_SRC_DF_FILENAME
,
4302 (ptr
+ rec_length
) -
4303 (src_ptr
+ DST_S_B_SRC_DF_FILENAME
)
4306 while (fileid
>= module
->file_table_count
)
4308 module
->file_table_count
*= 2;
4310 = bfd_realloc (module
->file_table
,
4311 module
->file_table_count
4312 * sizeof (struct fileinfo
));
4315 module
->file_table
[fileid
].name
= filename
;
4316 module
->file_table
[fileid
].srec
= 1;
4317 cmd_length
= src_ptr
[DST_S_B_SRC_DF_LENGTH
] + 2;
4318 vms_debug2 ((4, "DST_S_C_SRC_DECLFILE: %d, %s\n",
4319 fileid
, module
->file_table
[fileid
].name
));
4323 case DST__K_SRC_DEFLINES_B
:
4324 /* Perform the association and set the next higher index
4326 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4327 srec
= (struct srecinfo
*)
4328 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4329 srec
->line
= curr_srec
->line
+ data
;
4330 srec
->srec
= curr_srec
->srec
+ data
;
4331 srec
->sfile
= curr_srec
->sfile
;
4332 curr_srec
->next
= srec
;
4335 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_B: %d\n", data
));
4338 case DST__K_SRC_DEFLINES_W
:
4339 /* Perform the association and set the next higher index
4341 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4342 srec
= (struct srecinfo
*)
4343 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4344 srec
->line
= curr_srec
->line
+ data
;
4345 srec
->srec
= curr_srec
->srec
+ data
,
4346 srec
->sfile
= curr_srec
->sfile
;
4347 curr_srec
->next
= srec
;
4350 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_W: %d\n", data
));
4353 case DST__K_SRC_INCRLNUM_B
:
4354 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4355 curr_srec
->line
+= data
;
4357 vms_debug2 ((4, "DST_S_C_SRC_INCRLNUM_B: %d\n", data
));
4360 case DST__K_SRC_SETFILE
:
4361 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4362 curr_srec
->sfile
= data
;
4363 curr_srec
->srec
= module
->file_table
[data
].srec
;
4365 vms_debug2 ((4, "DST_S_C_SRC_SETFILE: %d\n", data
));
4368 case DST__K_SRC_SETLNUM_L
:
4369 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4370 curr_srec
->line
= data
;
4372 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_L: %d\n", data
));
4375 case DST__K_SRC_SETLNUM_W
:
4376 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4377 curr_srec
->line
= data
;
4379 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_W: %d\n", data
));
4382 case DST__K_SRC_SETREC_L
:
4383 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4384 curr_srec
->srec
= data
;
4385 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4387 vms_debug2 ((4, "DST_S_C_SRC_SETREC_L: %d\n", data
));
4390 case DST__K_SRC_SETREC_W
:
4391 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4392 curr_srec
->srec
= data
;
4393 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4395 vms_debug2 ((4, "DST_S_C_SRC_SETREC_W: %d\n", data
));
4398 case DST__K_SRC_FORMFEED
:
4400 vms_debug2 ((4, "DST_S_C_SRC_FORMFEED\n"));
4404 _bfd_error_handler (_("unknown source command %d"),
4410 src_ptr
+= cmd_length
;
4414 case DST__K_LINE_NUM
:
4415 pcl_ptr
= ptr
+ DST_S_C_LINE_NUM_HEADER_SIZE
;
4417 vms_debug2 ((3, "line info\n"));
4419 while (pcl_ptr
< ptr
+ rec_length
)
4421 /* The command byte is signed so we must sign-extend it. */
4422 int cmd
= ((signed char *)pcl_ptr
)[0], cmd_length
, data
;
4426 case DST__K_DELTA_PC_W
:
4427 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4431 vms_debug2 ((4, "DST__K_DELTA_PC_W: %d\n", data
));
4434 case DST__K_DELTA_PC_L
:
4435 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4439 vms_debug2 ((4, "DST__K_DELTA_PC_L: %d\n", data
));
4442 case DST__K_INCR_LINUM
:
4443 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4444 curr_linenum
+= data
;
4446 vms_debug2 ((4, "DST__K_INCR_LINUM: %d\n", data
));
4449 case DST__K_INCR_LINUM_W
:
4450 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4451 curr_linenum
+= data
;
4453 vms_debug2 ((4, "DST__K_INCR_LINUM_W: %d\n", data
));
4456 case DST__K_INCR_LINUM_L
:
4457 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4458 curr_linenum
+= data
;
4460 vms_debug2 ((4, "DST__K_INCR_LINUM_L: %d\n", data
));
4463 case DST__K_SET_LINUM_INCR
:
4465 (_("%s not implemented"), "DST__K_SET_LINUM_INCR");
4469 case DST__K_SET_LINUM_INCR_W
:
4471 (_("%s not implemented"), "DST__K_SET_LINUM_INCR_W");
4475 case DST__K_RESET_LINUM_INCR
:
4477 (_("%s not implemented"), "DST__K_RESET_LINUM_INCR");
4481 case DST__K_BEG_STMT_MODE
:
4483 (_("%s not implemented"), "DST__K_BEG_STMT_MODE");
4487 case DST__K_END_STMT_MODE
:
4489 (_("%s not implemented"), "DST__K_END_STMT_MODE");
4493 case DST__K_SET_LINUM_B
:
4494 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4495 curr_linenum
= data
;
4497 vms_debug2 ((4, "DST__K_SET_LINUM_B: %d\n", data
));
4500 case DST__K_SET_LINUM
:
4501 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4502 curr_linenum
= data
;
4504 vms_debug2 ((4, "DST__K_SET_LINE_NUM: %d\n", data
));
4507 case DST__K_SET_LINUM_L
:
4508 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4509 curr_linenum
= data
;
4511 vms_debug2 ((4, "DST__K_SET_LINUM_L: %d\n", data
));
4516 (_("%s not implemented"), "DST__K_SET_PC");
4520 case DST__K_SET_PC_W
:
4522 (_("%s not implemented"), "DST__K_SET_PC_W");
4526 case DST__K_SET_PC_L
:
4528 (_("%s not implemented"), "DST__K_SET_PC_L");
4532 case DST__K_SET_STMTNUM
:
4534 (_("%s not implemented"), "DST__K_SET_STMTNUM");
4539 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4542 vms_debug2 ((4, "DST__K_TERM: %d\n", data
));
4546 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4549 vms_debug2 ((4, "DST__K_TERM_W: %d\n", data
));
4553 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4556 vms_debug2 ((4, "DST__K_TERM_L: %d\n", data
));
4559 case DST__K_SET_ABS_PC
:
4560 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4563 vms_debug2 ((4, "DST__K_SET_ABS_PC: 0x%x\n", data
));
4572 vms_debug2 ((4, "bump pc to 0x%lx and line to %d\n",
4573 (unsigned long)curr_pc
, curr_linenum
));
4577 _bfd_error_handler (_("unknown line command %d"), cmd
);
4583 if ((curr_linenum
!= prev_linum
&& curr_pc
!= prev_pc
)
4585 || cmd
== DST__K_DELTA_PC_L
4586 || cmd
== DST__K_DELTA_PC_W
)
4588 line
= (struct lineinfo
*)
4589 bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4590 line
->address
= curr_pc
;
4591 line
->line
= curr_linenum
;
4593 curr_line
->next
= line
;
4596 prev_linum
= curr_linenum
;
4598 vms_debug2 ((4, "-> correlate pc 0x%lx with line %d\n",
4599 (unsigned long)curr_pc
, curr_linenum
));
4602 pcl_ptr
+= cmd_length
;
4606 case 0x17: /* Undocumented type used by DEC C to declare equates. */
4607 vms_debug2 ((3, "undocumented type 0x17\n"));
4611 vms_debug2 ((3, "ignoring record\n"));
4619 /* Finalize tables with EOL marker. */
4620 srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4621 srec
->line
= (unsigned int) -1;
4622 srec
->srec
= (unsigned int) -1;
4623 curr_srec
->next
= srec
;
4625 line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4626 line
->line
= (unsigned int) -1;
4627 line
->address
= (bfd_vma
) -1;
4628 curr_line
->next
= line
;
4630 /* Advertise that this module has been parsed. This is needed
4631 because parsing can be either performed at module creation
4632 or deferred until debug info is consumed. */
4633 SET_MODULE_PARSED (module
);
4636 /* Build the list of modules for the specified BFD. */
4638 static struct module
*
4639 build_module_list (bfd
*abfd
)
4641 struct module
*module
, *list
= NULL
;
4644 if ((dmt
= bfd_get_section_by_name (abfd
, "$DMT$")))
4646 /* We have a DMT section so this must be an image. Parse the
4647 section and build the list of modules. This is sufficient
4648 since we can compute the start address and the end address
4649 of every module from the section contents. */
4650 bfd_size_type size
= bfd_section_size (dmt
);
4651 unsigned char *ptr
, *end
;
4653 ptr
= (unsigned char *) bfd_alloc (abfd
, size
);
4657 if (! bfd_get_section_contents (abfd
, dmt
, ptr
, 0, size
))
4660 vms_debug2 ((2, "DMT\n"));
4666 /* Each header declares a module with its start offset and size
4667 of debug info in the DST section, as well as the count of
4668 program sections (i.e. address spans) it contains. */
4669 int modbeg
= bfd_getl32 (ptr
+ DBG_S_L_DMT_MODBEG
);
4670 int msize
= bfd_getl32 (ptr
+ DBG_S_L_DST_SIZE
);
4671 int count
= bfd_getl16 (ptr
+ DBG_S_W_DMT_PSECT_COUNT
);
4672 ptr
+= DBG_S_C_DMT_HEADER_SIZE
;
4674 vms_debug2 ((3, "module: modbeg = %d, size = %d, count = %d\n",
4675 modbeg
, msize
, count
));
4677 /* We create a 'module' structure for each program section since
4678 we only support contiguous addresses in a 'module' structure.
4679 As a consequence, the actual debug info in the DST section is
4680 shared and can be parsed multiple times; that doesn't seem to
4681 cause problems in practice. */
4684 int start
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_START
);
4685 int length
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_LENGTH
);
4686 module
= new_module (abfd
);
4687 module
->modbeg
= modbeg
;
4688 module
->size
= msize
;
4689 module
->low
= start
;
4690 module
->high
= start
+ length
;
4691 module
->next
= list
;
4693 ptr
+= DBG_S_C_DMT_PSECT_SIZE
;
4695 vms_debug2 ((4, "section: start = 0x%x, length = %d\n",
4702 /* We don't have a DMT section so this must be an object. Parse
4703 the module right now in order to compute its start address and
4705 void *dst
= PRIV (dst_section
)->contents
;
4710 module
= new_module (abfd
);
4711 parse_module (abfd
, module
, PRIV (dst_section
)->contents
, -1);
4718 /* Calculate and return the name of the source file and the line nearest
4719 to the wanted location in the specified module. */
4722 module_find_nearest_line (bfd
*abfd
, struct module
*module
, bfd_vma addr
,
4723 const char **file
, const char **func
,
4726 struct funcinfo
*funcinfo
;
4727 struct lineinfo
*lineinfo
;
4728 struct srecinfo
*srecinfo
;
4729 bfd_boolean ret
= FALSE
;
4731 /* Parse this module if that was not done at module creation. */
4732 if (! IS_MODULE_PARSED (module
))
4734 unsigned int size
= module
->size
;
4735 unsigned int modbeg
= PRIV (dst_section
)->filepos
+ module
->modbeg
;
4736 unsigned char *buffer
= (unsigned char *) bfd_malloc (module
->size
);
4738 if (bfd_seek (abfd
, modbeg
, SEEK_SET
) != 0
4739 || bfd_bread (buffer
, size
, abfd
) != size
)
4741 bfd_set_error (bfd_error_no_debug_section
);
4745 parse_module (abfd
, module
, buffer
, size
);
4749 /* Find out the function (if any) that contains the address. */
4750 for (funcinfo
= module
->func_table
; funcinfo
; funcinfo
= funcinfo
->next
)
4751 if (addr
>= funcinfo
->low
&& addr
<= funcinfo
->high
)
4753 *func
= funcinfo
->name
;
4758 /* Find out the source file and the line nearest to the address. */
4759 for (lineinfo
= module
->line_table
; lineinfo
; lineinfo
= lineinfo
->next
)
4760 if (lineinfo
->next
&& addr
< lineinfo
->next
->address
)
4762 for (srecinfo
= module
->srec_table
; srecinfo
; srecinfo
= srecinfo
->next
)
4763 if (srecinfo
->next
&& lineinfo
->line
< srecinfo
->next
->line
)
4765 if (srecinfo
->sfile
> 0)
4767 *file
= module
->file_table
[srecinfo
->sfile
].name
;
4768 *line
= srecinfo
->srec
+ lineinfo
->line
- srecinfo
->line
;
4772 *file
= module
->name
;
4773 *line
= lineinfo
->line
;
4784 /* Provided a BFD, a section and an offset into the section, calculate and
4785 return the name of the source file and the line nearest to the wanted
4789 _bfd_vms_find_nearest_line (bfd
*abfd
,
4790 asymbol
**symbols ATTRIBUTE_UNUSED
,
4796 unsigned int *discriminator
)
4798 struct module
*module
;
4800 /* What address are we looking for? */
4801 bfd_vma addr
= section
->vma
+ offset
;
4809 /* We can't do anything if there is no DST (debug symbol table). */
4810 if (PRIV (dst_section
) == NULL
)
4813 /* Create the module list - if not already done. */
4814 if (PRIV (modules
) == NULL
)
4816 PRIV (modules
) = build_module_list (abfd
);
4817 if (PRIV (modules
) == NULL
)
4821 for (module
= PRIV (modules
); module
; module
= module
->next
)
4822 if (addr
>= module
->low
&& addr
<= module
->high
)
4823 return module_find_nearest_line (abfd
, module
, addr
, file
, func
, line
);
4828 /* Canonicalizations. */
4829 /* Set name, value, section and flags of SYM from E. */
4832 alpha_vms_convert_symbol (bfd
*abfd
, struct vms_symbol_entry
*e
, asymbol
*sym
)
4841 flags
= BSF_NO_FLAGS
;
4847 if (e
->flags
& EGSY__V_WEAK
)
4850 if (e
->flags
& EGSY__V_DEF
)
4852 /* Symbol definition. */
4853 flags
|= BSF_GLOBAL
;
4854 if (e
->flags
& EGSY__V_NORM
)
4855 flags
|= BSF_FUNCTION
;
4861 /* Symbol reference. */
4862 sec
= bfd_und_section_ptr
;
4867 /* A universal symbol is by definition global... */
4868 flags
|= BSF_GLOBAL
;
4870 /* ...and dynamic in shared libraries. */
4871 if (abfd
->flags
& DYNAMIC
)
4872 flags
|= BSF_DYNAMIC
;
4874 if (e
->flags
& EGSY__V_WEAK
)
4877 if (!(e
->flags
& EGSY__V_DEF
))
4880 if (e
->flags
& EGSY__V_NORM
)
4881 flags
|= BSF_FUNCTION
;
4884 /* sec = e->section; */
4885 sec
= bfd_abs_section_ptr
;
4900 /* Return the number of bytes required to store a vector of pointers
4901 to asymbols for all the symbols in the BFD abfd, including a
4902 terminal NULL pointer. If there are no symbols in the BFD,
4903 then return 0. If an error occurs, return -1. */
4906 alpha_vms_get_symtab_upper_bound (bfd
*abfd
)
4908 vms_debug2 ((1, "alpha_vms_get_symtab_upper_bound (%p), %d symbols\n",
4909 abfd
, PRIV (gsd_sym_count
)));
4911 return (PRIV (gsd_sym_count
) + 1) * sizeof (asymbol
*);
4914 /* Read the symbols from the BFD abfd, and fills in the vector
4915 location with pointers to the symbols and a trailing NULL.
4917 Return number of symbols read. */
4920 alpha_vms_canonicalize_symtab (bfd
*abfd
, asymbol
**symbols
)
4924 vms_debug2 ((1, "alpha_vms_canonicalize_symtab (%p, <ret>)\n", abfd
));
4926 if (PRIV (csymbols
) == NULL
)
4928 PRIV (csymbols
) = (asymbol
**) bfd_alloc
4929 (abfd
, PRIV (gsd_sym_count
) * sizeof (asymbol
*));
4931 /* Traverse table and fill symbols vector. */
4932 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
4934 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
4937 sym
= bfd_make_empty_symbol (abfd
);
4938 if (sym
== NULL
|| !alpha_vms_convert_symbol (abfd
, e
, sym
))
4940 bfd_release (abfd
, PRIV (csymbols
));
4941 PRIV (csymbols
) = NULL
;
4945 PRIV (csymbols
)[i
] = sym
;
4949 if (symbols
!= NULL
)
4951 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
4952 symbols
[i
] = PRIV (csymbols
)[i
];
4956 return PRIV (gsd_sym_count
);
4959 /* Read and convert relocations from ETIR. We do it once for all sections. */
4962 alpha_vms_slurp_relocs (bfd
*abfd
)
4966 vms_debug2 ((3, "alpha_vms_slurp_relocs\n"));
4968 /* We slurp relocs only once, for all sections. */
4969 if (PRIV (reloc_done
))
4971 PRIV (reloc_done
) = TRUE
;
4973 if (alpha_vms_canonicalize_symtab (abfd
, NULL
) < 0)
4976 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
4981 unsigned char *begin
;
4984 bfd_reloc_code_real_type reloc_code
;
4990 bfd_vma cur_address
;
4992 unsigned char *cur_sym
= NULL
;
4994 bfd_vma cur_addend
= 0;
4996 /* Skip non-ETIR records. */
4997 type
= _bfd_vms_get_object_record (abfd
);
4998 if (type
== EOBJ__C_EEOM
)
5000 if (type
!= EOBJ__C_ETIR
)
5003 begin
= PRIV (recrd
.rec
) + 4;
5004 end
= PRIV (recrd
.rec
) + PRIV (recrd
.rec_size
);
5006 for (ptr
= begin
; ptr
< end
; ptr
+= length
)
5010 cmd
= bfd_getl16 (ptr
);
5011 length
= bfd_getl16 (ptr
+ 2);
5013 cur_address
= vaddr
;
5015 vms_debug2 ((4, "alpha_vms_slurp_relocs: etir %s\n",
5016 _bfd_vms_etir_name (cmd
)));
5020 case ETIR__C_STA_GBL
: /* ALPHA_R_REFLONG und_section, step 1 */
5021 /* ALPHA_R_REFQUAD und_section, step 1 */
5026 case ETIR__C_STA_PQ
: /* ALPHA_R_REF{LONG|QUAD}, others part 1 */
5027 cur_psidx
= bfd_getl32 (ptr
+ 4);
5028 cur_addend
= bfd_getl64 (ptr
+ 8);
5032 case ETIR__C_CTL_SETRB
:
5033 if (prev_cmd
!= ETIR__C_STA_PQ
)
5036 /* xgettext:c-format */
5037 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (prev_cmd
),
5038 _bfd_vms_etir_name (cmd
));
5041 cur_psect
= cur_psidx
;
5047 case ETIR__C_STA_LW
: /* ALPHA_R_REFLONG abs_section, step 1 */
5048 /* ALPHA_R_REFLONG und_section, step 2 */
5051 if (prev_cmd
!= ETIR__C_STA_GBL
)
5054 /* xgettext:c-format */
5055 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
5056 _bfd_vms_etir_name (ETIR__C_STA_LW
));
5060 cur_addend
= bfd_getl32 (ptr
+ 4);
5064 case ETIR__C_STA_QW
: /* ALPHA_R_REFQUAD abs_section, step 1 */
5065 /* ALPHA_R_REFQUAD und_section, step 2 */
5066 if (prev_cmd
!= -1 && prev_cmd
!= ETIR__C_STA_GBL
)
5069 /* xgettext:c-format */
5070 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
5071 _bfd_vms_etir_name (ETIR__C_STA_QW
));
5074 cur_addend
= bfd_getl64 (ptr
+ 4);
5078 case ETIR__C_STO_LW
: /* ALPHA_R_REFLONG und_section, step 4 */
5079 /* ALPHA_R_REFLONG abs_section, step 2 */
5080 /* ALPHA_R_REFLONG others, step 2 */
5081 if (prev_cmd
!= ETIR__C_OPR_ADD
5082 && prev_cmd
!= ETIR__C_STA_LW
5083 && prev_cmd
!= ETIR__C_STA_PQ
)
5085 /* xgettext:c-format */
5086 _bfd_error_handler (_("unknown reloc %s + %s"),
5087 _bfd_vms_etir_name (prev_cmd
),
5088 _bfd_vms_etir_name (ETIR__C_STO_LW
));
5091 reloc_code
= BFD_RELOC_32
;
5094 case ETIR__C_STO_QW
: /* ALPHA_R_REFQUAD und_section, step 4 */
5095 /* ALPHA_R_REFQUAD abs_section, step 2 */
5096 if (prev_cmd
!= ETIR__C_OPR_ADD
&& prev_cmd
!= ETIR__C_STA_QW
)
5098 /* xgettext:c-format */
5099 _bfd_error_handler (_("unknown reloc %s + %s"),
5100 _bfd_vms_etir_name (prev_cmd
),
5101 _bfd_vms_etir_name (ETIR__C_STO_QW
));
5104 reloc_code
= BFD_RELOC_64
;
5107 case ETIR__C_STO_OFF
: /* ALPHA_R_REFQUAD others, step 2 */
5108 if (prev_cmd
!= ETIR__C_STA_PQ
)
5110 /* xgettext:c-format */
5111 _bfd_error_handler (_("unknown reloc %s + %s"),
5112 _bfd_vms_etir_name (prev_cmd
),
5113 _bfd_vms_etir_name (ETIR__C_STO_OFF
));
5116 reloc_code
= BFD_RELOC_64
;
5119 case ETIR__C_OPR_ADD
: /* ALPHA_R_REFLONG und_section, step 3 */
5120 /* ALPHA_R_REFQUAD und_section, step 3 */
5121 if (prev_cmd
!= ETIR__C_STA_LW
&& prev_cmd
!= ETIR__C_STA_QW
)
5123 /* xgettext:c-format */
5124 _bfd_error_handler (_("unknown reloc %s + %s"),
5125 _bfd_vms_etir_name (prev_cmd
),
5126 _bfd_vms_etir_name (ETIR__C_OPR_ADD
));
5129 prev_cmd
= ETIR__C_OPR_ADD
;
5132 case ETIR__C_STO_CA
: /* ALPHA_R_CODEADDR */
5133 reloc_code
= BFD_RELOC_ALPHA_CODEADDR
;
5137 case ETIR__C_STO_GBL
: /* ALPHA_R_REFQUAD und_section */
5138 reloc_code
= BFD_RELOC_64
;
5142 case ETIR__C_STO_GBL_LW
: /* ALPHA_R_REFLONG und_section */
5143 reloc_code
= BFD_RELOC_32
;
5147 case ETIR__C_STC_LP_PSB
: /* ALPHA_R_LINKAGE */
5148 reloc_code
= BFD_RELOC_ALPHA_LINKAGE
;
5152 case ETIR__C_STC_NOP_GBL
: /* ALPHA_R_NOP */
5153 reloc_code
= BFD_RELOC_ALPHA_NOP
;
5156 case ETIR__C_STC_BSR_GBL
: /* ALPHA_R_BSR */
5157 reloc_code
= BFD_RELOC_ALPHA_BSR
;
5160 case ETIR__C_STC_LDA_GBL
: /* ALPHA_R_LDA */
5161 reloc_code
= BFD_RELOC_ALPHA_LDA
;
5164 case ETIR__C_STC_BOH_GBL
: /* ALPHA_R_BOH */
5165 reloc_code
= BFD_RELOC_ALPHA_BOH
;
5169 cur_sym
= ptr
+ 4 + 32;
5170 cur_address
= bfd_getl64 (ptr
+ 4 + 8);
5171 cur_addend
= bfd_getl64 (ptr
+ 4 + 24);
5174 case ETIR__C_STO_IMM
:
5175 vaddr
+= bfd_getl32 (ptr
+ 4);
5179 _bfd_error_handler (_("unknown reloc %s"),
5180 _bfd_vms_etir_name (cmd
));
5186 struct vms_section_data_struct
*vms_sec
;
5190 /* Get section to which the relocation applies. */
5191 if (cur_psect
< 0 || cur_psect
> (int)PRIV (section_count
))
5193 _bfd_error_handler (_("invalid section index in ETIR"));
5197 if (PRIV (sections
) == NULL
)
5199 sec
= PRIV (sections
)[cur_psect
];
5200 if (sec
== bfd_abs_section_ptr
)
5202 _bfd_error_handler (_("relocation for non-REL psect"));
5206 vms_sec
= vms_section_data (sec
);
5208 /* Allocate a reloc entry. */
5209 if (sec
->reloc_count
>= vms_sec
->reloc_max
)
5211 if (vms_sec
->reloc_max
== 0)
5213 vms_sec
->reloc_max
= 64;
5214 sec
->relocation
= bfd_zmalloc
5215 (vms_sec
->reloc_max
* sizeof (arelent
));
5219 vms_sec
->reloc_max
*= 2;
5220 sec
->relocation
= bfd_realloc
5221 (sec
->relocation
, vms_sec
->reloc_max
* sizeof (arelent
));
5224 reloc
= &sec
->relocation
[sec
->reloc_count
];
5227 reloc
->howto
= bfd_reloc_type_lookup (abfd
, reloc_code
);
5229 if (cur_sym
!= NULL
)
5232 unsigned int symlen
= *cur_sym
;
5235 /* Linear search. */
5240 for (j
= 0; j
< PRIV (gsd_sym_count
); j
++)
5241 if (PRIV (syms
)[j
]->namelen
== symlen
5242 && memcmp (PRIV (syms
)[j
]->name
, cur_sym
, symlen
) == 0)
5244 sym
= &PRIV (csymbols
)[j
];
5249 _bfd_error_handler (_("unknown symbol in command %s"),
5250 _bfd_vms_etir_name (cmd
));
5251 reloc
->sym_ptr_ptr
= NULL
;
5254 reloc
->sym_ptr_ptr
= sym
;
5256 else if (cur_psidx
>= 0)
5258 if (PRIV (sections
) == NULL
|| cur_psidx
>= (int) PRIV (section_count
))
5260 reloc
->sym_ptr_ptr
=
5261 PRIV (sections
)[cur_psidx
]->symbol_ptr_ptr
;
5264 reloc
->sym_ptr_ptr
= NULL
;
5266 reloc
->address
= cur_address
;
5267 reloc
->addend
= cur_addend
;
5269 if (reloc_code
== ALPHA_R_LINKAGE
)
5272 size
= bfd_get_reloc_size (reloc
->howto
);
5282 vms_debug2 ((3, "alpha_vms_slurp_relocs: result = TRUE\n"));
5287 /* Return the number of bytes required to store the relocation
5288 information associated with the given section. */
5291 alpha_vms_get_reloc_upper_bound (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*section
)
5293 alpha_vms_slurp_relocs (abfd
);
5295 return (section
->reloc_count
+ 1) * sizeof (arelent
*);
5298 /* Convert relocations from VMS (external) form into BFD internal
5299 form. Return the number of relocations. */
5302 alpha_vms_canonicalize_reloc (bfd
*abfd
, asection
*section
, arelent
**relptr
,
5303 asymbol
**symbols ATTRIBUTE_UNUSED
)
5308 if (!alpha_vms_slurp_relocs (abfd
))
5311 count
= section
->reloc_count
;
5312 tblptr
= section
->relocation
;
5315 *relptr
++ = tblptr
++;
5317 *relptr
= (arelent
*) NULL
;
5318 return section
->reloc_count
;
5321 /* Install a new set of internal relocs. */
5323 #define alpha_vms_set_reloc _bfd_generic_set_reloc
5326 /* This is just copied from ecoff-alpha, needs to be fixed probably. */
5328 /* How to process the various reloc types. */
5330 static bfd_reloc_status_type
5331 reloc_nil (bfd
* abfd ATTRIBUTE_UNUSED
,
5332 arelent
*reloc ATTRIBUTE_UNUSED
,
5333 asymbol
*sym ATTRIBUTE_UNUSED
,
5334 void * data ATTRIBUTE_UNUSED
,
5335 asection
*sec ATTRIBUTE_UNUSED
,
5336 bfd
*output_bfd ATTRIBUTE_UNUSED
,
5337 char **error_message ATTRIBUTE_UNUSED
)
5340 vms_debug (1, "reloc_nil (abfd %p, output_bfd %p)\n", abfd
, output_bfd
);
5341 vms_debug (2, "In section %s, symbol %s\n",
5342 sec
->name
, sym
->name
);
5343 vms_debug (2, "reloc sym %s, addr %08lx, addend %08lx, reloc is a %s\n",
5344 reloc
->sym_ptr_ptr
[0]->name
,
5345 (unsigned long)reloc
->address
,
5346 (unsigned long)reloc
->addend
, reloc
->howto
->name
);
5347 vms_debug (2, "data at %p\n", data
);
5348 /* _bfd_hexdump (2, data, bfd_get_reloc_size (reloc->howto), 0); */
5351 return bfd_reloc_ok
;
5354 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
5355 from smaller values. Start with zero, widen, *then* decrement. */
5356 #define MINUS_ONE (((bfd_vma)0) - 1)
5358 static reloc_howto_type alpha_howto_table
[] =
5360 HOWTO (ALPHA_R_IGNORE
, /* Type. */
5361 0, /* Rightshift. */
5362 0, /* Size (0 = byte, 1 = short, 2 = long). */
5364 TRUE
, /* PC relative. */
5366 complain_overflow_dont
,/* Complain_on_overflow. */
5367 reloc_nil
, /* Special_function. */
5368 "IGNORE", /* Name. */
5369 TRUE
, /* Partial_inplace. */
5370 0, /* Source mask */
5372 TRUE
), /* PC rel offset. */
5374 /* A 64 bit reference to a symbol. */
5375 HOWTO (ALPHA_R_REFQUAD
, /* Type. */
5376 0, /* Rightshift. */
5377 4, /* Size (0 = byte, 1 = short, 2 = long). */
5379 FALSE
, /* PC relative. */
5381 complain_overflow_bitfield
, /* Complain_on_overflow. */
5382 reloc_nil
, /* Special_function. */
5383 "REFQUAD", /* Name. */
5384 TRUE
, /* Partial_inplace. */
5385 MINUS_ONE
, /* Source mask. */
5386 MINUS_ONE
, /* Dest mask. */
5387 FALSE
), /* PC rel offset. */
5389 /* A 21 bit branch. The native assembler generates these for
5390 branches within the text segment, and also fills in the PC
5391 relative offset in the instruction. */
5392 HOWTO (ALPHA_R_BRADDR
, /* Type. */
5393 2, /* Rightshift. */
5394 2, /* Size (0 = byte, 1 = short, 2 = long). */
5396 TRUE
, /* PC relative. */
5398 complain_overflow_signed
, /* Complain_on_overflow. */
5399 reloc_nil
, /* Special_function. */
5400 "BRADDR", /* Name. */
5401 TRUE
, /* Partial_inplace. */
5402 0x1fffff, /* Source mask. */
5403 0x1fffff, /* Dest mask. */
5404 FALSE
), /* PC rel offset. */
5406 /* A hint for a jump to a register. */
5407 HOWTO (ALPHA_R_HINT
, /* Type. */
5408 2, /* Rightshift. */
5409 1, /* Size (0 = byte, 1 = short, 2 = long). */
5411 TRUE
, /* PC relative. */
5413 complain_overflow_dont
,/* Complain_on_overflow. */
5414 reloc_nil
, /* Special_function. */
5416 TRUE
, /* Partial_inplace. */
5417 0x3fff, /* Source mask. */
5418 0x3fff, /* Dest mask. */
5419 FALSE
), /* PC rel offset. */
5421 /* 16 bit PC relative offset. */
5422 HOWTO (ALPHA_R_SREL16
, /* Type. */
5423 0, /* Rightshift. */
5424 1, /* Size (0 = byte, 1 = short, 2 = long). */
5426 TRUE
, /* PC relative. */
5428 complain_overflow_signed
, /* Complain_on_overflow. */
5429 reloc_nil
, /* Special_function. */
5430 "SREL16", /* Name. */
5431 TRUE
, /* Partial_inplace. */
5432 0xffff, /* Source mask. */
5433 0xffff, /* Dest mask. */
5434 FALSE
), /* PC rel offset. */
5436 /* 32 bit PC relative offset. */
5437 HOWTO (ALPHA_R_SREL32
, /* Type. */
5438 0, /* Rightshift. */
5439 2, /* Size (0 = byte, 1 = short, 2 = long). */
5441 TRUE
, /* PC relative. */
5443 complain_overflow_signed
, /* Complain_on_overflow. */
5444 reloc_nil
, /* Special_function. */
5445 "SREL32", /* Name. */
5446 TRUE
, /* Partial_inplace. */
5447 0xffffffff, /* Source mask. */
5448 0xffffffff, /* Dest mask. */
5449 FALSE
), /* PC rel offset. */
5451 /* A 64 bit PC relative offset. */
5452 HOWTO (ALPHA_R_SREL64
, /* Type. */
5453 0, /* Rightshift. */
5454 4, /* Size (0 = byte, 1 = short, 2 = long). */
5456 TRUE
, /* PC relative. */
5458 complain_overflow_signed
, /* Complain_on_overflow. */
5459 reloc_nil
, /* Special_function. */
5460 "SREL64", /* Name. */
5461 TRUE
, /* Partial_inplace. */
5462 MINUS_ONE
, /* Source mask. */
5463 MINUS_ONE
, /* Dest mask. */
5464 FALSE
), /* PC rel offset. */
5466 /* Push a value on the reloc evaluation stack. */
5467 HOWTO (ALPHA_R_OP_PUSH
, /* Type. */
5468 0, /* Rightshift. */
5469 0, /* Size (0 = byte, 1 = short, 2 = long). */
5471 FALSE
, /* PC relative. */
5473 complain_overflow_dont
,/* Complain_on_overflow. */
5474 reloc_nil
, /* Special_function. */
5475 "OP_PUSH", /* Name. */
5476 FALSE
, /* Partial_inplace. */
5477 0, /* Source mask. */
5479 FALSE
), /* PC rel offset. */
5481 /* Store the value from the stack at the given address. Store it in
5482 a bitfield of size r_size starting at bit position r_offset. */
5483 HOWTO (ALPHA_R_OP_STORE
, /* Type. */
5484 0, /* Rightshift. */
5485 4, /* Size (0 = byte, 1 = short, 2 = long). */
5487 FALSE
, /* PC relative. */
5489 complain_overflow_dont
,/* Complain_on_overflow. */
5490 reloc_nil
, /* Special_function. */
5491 "OP_STORE", /* Name. */
5492 FALSE
, /* Partial_inplace. */
5493 0, /* Source mask. */
5494 MINUS_ONE
, /* Dest mask. */
5495 FALSE
), /* PC rel offset. */
5497 /* Subtract the reloc address from the value on the top of the
5498 relocation stack. */
5499 HOWTO (ALPHA_R_OP_PSUB
, /* Type. */
5500 0, /* Rightshift. */
5501 0, /* Size (0 = byte, 1 = short, 2 = long). */
5503 FALSE
, /* PC relative. */
5505 complain_overflow_dont
,/* Complain_on_overflow. */
5506 reloc_nil
, /* Special_function. */
5507 "OP_PSUB", /* Name. */
5508 FALSE
, /* Partial_inplace. */
5509 0, /* Source mask. */
5511 FALSE
), /* PC rel offset. */
5513 /* Shift the value on the top of the relocation stack right by the
5515 HOWTO (ALPHA_R_OP_PRSHIFT
, /* Type. */
5516 0, /* Rightshift. */
5517 0, /* Size (0 = byte, 1 = short, 2 = long). */
5519 FALSE
, /* PC relative. */
5521 complain_overflow_dont
,/* Complain_on_overflow. */
5522 reloc_nil
, /* Special_function. */
5523 "OP_PRSHIFT", /* Name. */
5524 FALSE
, /* Partial_inplace. */
5525 0, /* Source mask. */
5527 FALSE
), /* PC rel offset. */
5529 /* Hack. Linkage is done by linker. */
5530 HOWTO (ALPHA_R_LINKAGE
, /* Type. */
5531 0, /* Rightshift. */
5532 0, /* Size (0 = byte, 1 = short, 2 = long). */
5534 FALSE
, /* PC relative. */
5536 complain_overflow_dont
,/* Complain_on_overflow. */
5537 reloc_nil
, /* Special_function. */
5538 "LINKAGE", /* Name. */
5539 FALSE
, /* Partial_inplace. */
5540 0, /* Source mask. */
5542 FALSE
), /* PC rel offset. */
5544 /* A 32 bit reference to a symbol. */
5545 HOWTO (ALPHA_R_REFLONG
, /* Type. */
5546 0, /* Rightshift. */
5547 2, /* Size (0 = byte, 1 = short, 2 = long). */
5549 FALSE
, /* PC relative. */
5551 complain_overflow_bitfield
, /* Complain_on_overflow. */
5552 reloc_nil
, /* Special_function. */
5553 "REFLONG", /* Name. */
5554 TRUE
, /* Partial_inplace. */
5555 0xffffffff, /* Source mask. */
5556 0xffffffff, /* Dest mask. */
5557 FALSE
), /* PC rel offset. */
5559 /* A 64 bit reference to a procedure, written as 32 bit value. */
5560 HOWTO (ALPHA_R_CODEADDR
, /* Type. */
5561 0, /* Rightshift. */
5562 4, /* Size (0 = byte, 1 = short, 2 = long). */
5564 FALSE
, /* PC relative. */
5566 complain_overflow_signed
,/* Complain_on_overflow. */
5567 reloc_nil
, /* Special_function. */
5568 "CODEADDR", /* Name. */
5569 FALSE
, /* Partial_inplace. */
5570 0xffffffff, /* Source mask. */
5571 0xffffffff, /* Dest mask. */
5572 FALSE
), /* PC rel offset. */
5574 HOWTO (ALPHA_R_NOP
, /* Type. */
5575 0, /* Rightshift. */
5576 3, /* Size (0 = byte, 1 = short, 2 = long). */
5578 /* The following value must match that of ALPHA_R_BSR/ALPHA_R_BOH
5579 because the calculations for the 3 relocations are the same.
5580 See B.4.5.2 of the OpenVMS Linker Utility Manual. */
5581 TRUE
, /* PC relative. */
5583 complain_overflow_dont
,/* Complain_on_overflow. */
5584 reloc_nil
, /* Special_function. */
5586 FALSE
, /* Partial_inplace. */
5587 0xffffffff, /* Source mask. */
5588 0xffffffff, /* Dest mask. */
5589 FALSE
), /* PC rel offset. */
5591 HOWTO (ALPHA_R_BSR
, /* Type. */
5592 0, /* Rightshift. */
5593 3, /* Size (0 = byte, 1 = short, 2 = long). */
5595 TRUE
, /* PC relative. */
5597 complain_overflow_dont
,/* Complain_on_overflow. */
5598 reloc_nil
, /* Special_function. */
5600 FALSE
, /* Partial_inplace. */
5601 0xffffffff, /* Source mask. */
5602 0xffffffff, /* Dest mask. */
5603 FALSE
), /* PC rel offset. */
5605 HOWTO (ALPHA_R_LDA
, /* Type. */
5606 0, /* Rightshift. */
5607 3, /* Size (0 = byte, 1 = short, 2 = long). */
5609 FALSE
, /* PC relative. */
5611 complain_overflow_dont
,/* Complain_on_overflow. */
5612 reloc_nil
, /* Special_function. */
5614 FALSE
, /* Partial_inplace. */
5615 0xffffffff, /* Source mask. */
5616 0xffffffff, /* Dest mask. */
5617 FALSE
), /* PC rel offset. */
5619 HOWTO (ALPHA_R_BOH
, /* Type. */
5620 0, /* Rightshift. */
5621 3, /* Size (0 = byte, 1 = short, 2 = long, 3 = nil). */
5623 TRUE
, /* PC relative. */
5625 complain_overflow_dont
,/* Complain_on_overflow. */
5626 reloc_nil
, /* Special_function. */
5628 FALSE
, /* Partial_inplace. */
5629 0xffffffff, /* Source mask. */
5630 0xffffffff, /* Dest mask. */
5631 FALSE
), /* PC rel offset. */
5634 /* Return a pointer to a howto structure which, when invoked, will perform
5635 the relocation code on data from the architecture noted. */
5637 static reloc_howto_type
*
5638 alpha_vms_bfd_reloc_type_lookup (bfd
* abfd ATTRIBUTE_UNUSED
,
5639 bfd_reloc_code_real_type code
)
5643 vms_debug2 ((1, "vms_bfd_reloc_type_lookup (%p, %d)\t", abfd
, code
));
5647 case BFD_RELOC_16
: alpha_type
= ALPHA_R_SREL16
; break;
5648 case BFD_RELOC_32
: alpha_type
= ALPHA_R_REFLONG
; break;
5649 case BFD_RELOC_64
: alpha_type
= ALPHA_R_REFQUAD
; break;
5650 case BFD_RELOC_CTOR
: alpha_type
= ALPHA_R_REFQUAD
; break;
5651 case BFD_RELOC_23_PCREL_S2
: alpha_type
= ALPHA_R_BRADDR
; break;
5652 case BFD_RELOC_ALPHA_HINT
: alpha_type
= ALPHA_R_HINT
; break;
5653 case BFD_RELOC_16_PCREL
: alpha_type
= ALPHA_R_SREL16
; break;
5654 case BFD_RELOC_32_PCREL
: alpha_type
= ALPHA_R_SREL32
; break;
5655 case BFD_RELOC_64_PCREL
: alpha_type
= ALPHA_R_SREL64
; break;
5656 case BFD_RELOC_ALPHA_LINKAGE
: alpha_type
= ALPHA_R_LINKAGE
; break;
5657 case BFD_RELOC_ALPHA_CODEADDR
: alpha_type
= ALPHA_R_CODEADDR
; break;
5658 case BFD_RELOC_ALPHA_NOP
: alpha_type
= ALPHA_R_NOP
; break;
5659 case BFD_RELOC_ALPHA_BSR
: alpha_type
= ALPHA_R_BSR
; break;
5660 case BFD_RELOC_ALPHA_LDA
: alpha_type
= ALPHA_R_LDA
; break;
5661 case BFD_RELOC_ALPHA_BOH
: alpha_type
= ALPHA_R_BOH
; break;
5663 _bfd_error_handler (_("reloc (%d) is *UNKNOWN*"), code
);
5666 vms_debug2 ((2, "reloc is %s\n", alpha_howto_table
[alpha_type
].name
));
5667 return & alpha_howto_table
[alpha_type
];
5670 static reloc_howto_type
*
5671 alpha_vms_bfd_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
5677 i
< sizeof (alpha_howto_table
) / sizeof (alpha_howto_table
[0]);
5679 if (alpha_howto_table
[i
].name
!= NULL
5680 && strcasecmp (alpha_howto_table
[i
].name
, r_name
) == 0)
5681 return &alpha_howto_table
[i
];
5687 alpha_vms_get_synthetic_symtab (bfd
*abfd
,
5688 long symcount ATTRIBUTE_UNUSED
,
5689 asymbol
**usyms ATTRIBUTE_UNUSED
,
5690 long dynsymcount ATTRIBUTE_UNUSED
,
5691 asymbol
**dynsyms ATTRIBUTE_UNUSED
,
5698 syms
= (asymbol
*) bfd_malloc (PRIV (norm_sym_count
) * sizeof (asymbol
));
5703 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
5705 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
5716 flags
= BSF_LOCAL
| BSF_SYNTHETIC
;
5723 if ((e
->flags
& EGSY__V_DEF
) && (e
->flags
& EGSY__V_NORM
))
5725 value
= e
->code_value
;
5726 sec
= e
->code_section
;
5737 sname
= bfd_alloc (abfd
, l
+ 5);
5740 memcpy (sname
, name
, l
);
5741 memcpy (sname
+ l
, "..en", 5);
5748 sym
->udata
.p
= NULL
;
5757 vms_time_to_str (unsigned char *buf
)
5759 time_t t
= vms_rawtime_to_time_t (buf
);
5760 char *res
= ctime (&t
);
5763 res
= "*invalid time*";
5770 evax_bfd_print_emh (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5772 struct vms_emh_common
*emh
= (struct vms_emh_common
*)rec
;
5773 unsigned int subtype
;
5776 subtype
= (unsigned) bfd_getl16 (emh
->subtyp
);
5778 /* xgettext:c-format */
5779 fprintf (file
, _(" EMH %u (len=%u): "), subtype
, rec_len
);
5781 /* PR 21618: Check for invalid lengths. */
5782 if (rec_len
< sizeof (* emh
))
5784 fprintf (file
, _(" Error: The length is less than the length of an EMH record\n"));
5787 extra
= rec_len
- sizeof (struct vms_emh_common
);
5793 struct vms_emh_mhd
*mhd
= (struct vms_emh_mhd
*) rec
;
5795 const char * nextname
;
5796 const char * maxname
;
5798 /* PR 21840: Check for invalid lengths. */
5799 if (rec_len
< sizeof (* mhd
))
5801 fprintf (file
, _(" Error: The record length is less than the size of an EMH_MHD record\n"));
5804 fprintf (file
, _("Module header\n"));
5805 fprintf (file
, _(" structure level: %u\n"), mhd
->strlvl
);
5806 fprintf (file
, _(" max record size: %u\n"),
5807 (unsigned) bfd_getl32 (mhd
->recsiz
));
5808 name
= (char *)(mhd
+ 1);
5809 maxname
= (char *) rec
+ rec_len
;
5810 if (name
> maxname
- 2)
5812 fprintf (file
, _(" Error: The module name is missing\n"));
5815 nextname
= name
+ name
[0] + 1;
5816 if (nextname
>= maxname
)
5818 fprintf (file
, _(" Error: The module name is too long\n"));
5821 fprintf (file
, _(" module name : %.*s\n"), name
[0], name
+ 1);
5823 if (name
> maxname
- 2)
5825 fprintf (file
, _(" Error: The module version is missing\n"));
5828 nextname
= name
+ name
[0] + 1;
5829 if (nextname
>= maxname
)
5831 fprintf (file
, _(" Error: The module version is too long\n"));
5834 fprintf (file
, _(" module version : %.*s\n"), name
[0], name
+ 1);
5836 if ((maxname
- name
) < 17 && maxname
[-1] != 0)
5837 fprintf (file
, _(" Error: The compile date is truncated\n"));
5839 fprintf (file
, _(" compile date : %.17s\n"), name
);
5844 fprintf (file
, _("Language Processor Name\n"));
5845 fprintf (file
, _(" language name: %.*s\n"), extra
, (char *)(emh
+ 1));
5849 fprintf (file
, _("Source Files Header\n"));
5850 fprintf (file
, _(" file: %.*s\n"), extra
, (char *)(emh
+ 1));
5854 fprintf (file
, _("Title Text Header\n"));
5855 fprintf (file
, _(" title: %.*s\n"), extra
, (char *)(emh
+ 1));
5859 fprintf (file
, _("Copyright Header\n"));
5860 fprintf (file
, _(" copyright: %.*s\n"), extra
, (char *)(emh
+ 1));
5864 fprintf (file
, _("unhandled emh subtype %u\n"), subtype
);
5870 evax_bfd_print_eeom (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5872 struct vms_eeom
*eeom
= (struct vms_eeom
*)rec
;
5874 fprintf (file
, _(" EEOM (len=%u):\n"), rec_len
);
5876 /* PR 21618: Check for invalid lengths. */
5877 if (rec_len
< sizeof (* eeom
))
5879 fprintf (file
, _(" Error: The length is less than the length of an EEOM record\n"));
5883 fprintf (file
, _(" number of cond linkage pairs: %u\n"),
5884 (unsigned)bfd_getl32 (eeom
->total_lps
));
5885 fprintf (file
, _(" completion code: %u\n"),
5886 (unsigned)bfd_getl16 (eeom
->comcod
));
5889 fprintf (file
, _(" transfer addr flags: 0x%02x\n"), eeom
->tfrflg
);
5890 fprintf (file
, _(" transfer addr psect: %u\n"),
5891 (unsigned)bfd_getl32 (eeom
->psindx
));
5892 fprintf (file
, _(" transfer address : 0x%08x\n"),
5893 (unsigned)bfd_getl32 (eeom
->tfradr
));
5898 exav_bfd_print_egsy_flags (unsigned int flags
, FILE *file
)
5900 if (flags
& EGSY__V_WEAK
)
5901 fputs (_(" WEAK"), file
);
5902 if (flags
& EGSY__V_DEF
)
5903 fputs (_(" DEF"), file
);
5904 if (flags
& EGSY__V_UNI
)
5905 fputs (_(" UNI"), file
);
5906 if (flags
& EGSY__V_REL
)
5907 fputs (_(" REL"), file
);
5908 if (flags
& EGSY__V_COMM
)
5909 fputs (_(" COMM"), file
);
5910 if (flags
& EGSY__V_VECEP
)
5911 fputs (_(" VECEP"), file
);
5912 if (flags
& EGSY__V_NORM
)
5913 fputs (_(" NORM"), file
);
5914 if (flags
& EGSY__V_QUAD_VAL
)
5915 fputs (_(" QVAL"), file
);
5919 evax_bfd_print_egsd_flags (FILE *file
, unsigned int flags
)
5921 if (flags
& EGPS__V_PIC
)
5922 fputs (_(" PIC"), file
);
5923 if (flags
& EGPS__V_LIB
)
5924 fputs (_(" LIB"), file
);
5925 if (flags
& EGPS__V_OVR
)
5926 fputs (_(" OVR"), file
);
5927 if (flags
& EGPS__V_REL
)
5928 fputs (_(" REL"), file
);
5929 if (flags
& EGPS__V_GBL
)
5930 fputs (_(" GBL"), file
);
5931 if (flags
& EGPS__V_SHR
)
5932 fputs (_(" SHR"), file
);
5933 if (flags
& EGPS__V_EXE
)
5934 fputs (_(" EXE"), file
);
5935 if (flags
& EGPS__V_RD
)
5936 fputs (_(" RD"), file
);
5937 if (flags
& EGPS__V_WRT
)
5938 fputs (_(" WRT"), file
);
5939 if (flags
& EGPS__V_VEC
)
5940 fputs (_(" VEC"), file
);
5941 if (flags
& EGPS__V_NOMOD
)
5942 fputs (_(" NOMOD"), file
);
5943 if (flags
& EGPS__V_COM
)
5944 fputs (_(" COM"), file
);
5945 if (flags
& EGPS__V_ALLOC_64BIT
)
5946 fputs (_(" 64B"), file
);
5950 evax_bfd_print_egsd (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5952 unsigned int off
= sizeof (struct vms_egsd
);
5955 fprintf (file
, _(" EGSD (len=%u):\n"), rec_len
);
5958 for (off
= sizeof (struct vms_egsd
); off
< rec_len
; )
5960 struct vms_egsd_entry
*e
= (struct vms_egsd_entry
*)(rec
+ off
);
5964 type
= (unsigned)bfd_getl16 (e
->gsdtyp
);
5965 len
= (unsigned)bfd_getl16 (e
->gsdsiz
);
5967 /* xgettext:c-format */
5968 fprintf (file
, _(" EGSD entry %2u (type: %u, len: %u): "),
5972 if (off
+ len
> rec_len
|| off
+ len
< off
)
5974 fprintf (file
, _(" Error: length larger than remaining space in record\n"));
5982 struct vms_egps
*egps
= (struct vms_egps
*)e
;
5983 unsigned int flags
= bfd_getl16 (egps
->flags
);
5986 fprintf (file
, _("PSC - Program section definition\n"));
5987 fprintf (file
, _(" alignment : 2**%u\n"), egps
->align
);
5988 fprintf (file
, _(" flags : 0x%04x"), flags
);
5989 evax_bfd_print_egsd_flags (file
, flags
);
5991 l
= bfd_getl32 (egps
->alloc
);
5992 fprintf (file
, _(" alloc (len): %u (0x%08x)\n"), l
, l
);
5993 fprintf (file
, _(" name : %.*s\n"),
5994 egps
->namlng
, egps
->name
);
5999 struct vms_esgps
*esgps
= (struct vms_esgps
*)e
;
6000 unsigned int flags
= bfd_getl16 (esgps
->flags
);
6003 fprintf (file
, _("SPSC - Shared Image Program section def\n"));
6004 fprintf (file
, _(" alignment : 2**%u\n"), esgps
->align
);
6005 fprintf (file
, _(" flags : 0x%04x"), flags
);
6006 evax_bfd_print_egsd_flags (file
, flags
);
6008 l
= bfd_getl32 (esgps
->alloc
);
6009 fprintf (file
, _(" alloc (len) : %u (0x%08x)\n"), l
, l
);
6010 fprintf (file
, _(" image offset : 0x%08x\n"),
6011 (unsigned int)bfd_getl32 (esgps
->base
));
6012 fprintf (file
, _(" symvec offset : 0x%08x\n"),
6013 (unsigned int)bfd_getl32 (esgps
->value
));
6014 fprintf (file
, _(" name : %.*s\n"),
6015 esgps
->namlng
, esgps
->name
);
6020 struct vms_egsy
*egsy
= (struct vms_egsy
*)e
;
6021 unsigned int flags
= bfd_getl16 (egsy
->flags
);
6023 if (flags
& EGSY__V_DEF
)
6025 struct vms_esdf
*esdf
= (struct vms_esdf
*)e
;
6027 fprintf (file
, _("SYM - Global symbol definition\n"));
6028 fprintf (file
, _(" flags: 0x%04x"), flags
);
6029 exav_bfd_print_egsy_flags (flags
, file
);
6031 fprintf (file
, _(" psect offset: 0x%08x\n"),
6032 (unsigned)bfd_getl32 (esdf
->value
));
6033 if (flags
& EGSY__V_NORM
)
6035 fprintf (file
, _(" code address: 0x%08x\n"),
6036 (unsigned)bfd_getl32 (esdf
->code_address
));
6037 fprintf (file
, _(" psect index for entry point : %u\n"),
6038 (unsigned)bfd_getl32 (esdf
->ca_psindx
));
6040 fprintf (file
, _(" psect index : %u\n"),
6041 (unsigned)bfd_getl32 (esdf
->psindx
));
6042 fprintf (file
, _(" name : %.*s\n"),
6043 esdf
->namlng
, esdf
->name
);
6047 struct vms_esrf
*esrf
= (struct vms_esrf
*)e
;
6049 fprintf (file
, _("SYM - Global symbol reference\n"));
6050 fprintf (file
, _(" name : %.*s\n"),
6051 esrf
->namlng
, esrf
->name
);
6057 struct vms_eidc
*eidc
= (struct vms_eidc
*)e
;
6058 unsigned int flags
= bfd_getl32 (eidc
->flags
);
6061 fprintf (file
, _("IDC - Ident Consistency check\n"));
6062 fprintf (file
, _(" flags : 0x%08x"), flags
);
6063 if (flags
& EIDC__V_BINIDENT
)
6064 fputs (" BINDENT", file
);
6066 fprintf (file
, _(" id match : %x\n"),
6067 (flags
>> EIDC__V_IDMATCH_SH
) & EIDC__V_IDMATCH_MASK
);
6068 fprintf (file
, _(" error severity: %x\n"),
6069 (flags
>> EIDC__V_ERRSEV_SH
) & EIDC__V_ERRSEV_MASK
);
6071 fprintf (file
, _(" entity name : %.*s\n"), p
[0], p
+ 1);
6073 fprintf (file
, _(" object name : %.*s\n"), p
[0], p
+ 1);
6075 if (flags
& EIDC__V_BINIDENT
)
6076 fprintf (file
, _(" binary ident : 0x%08x\n"),
6077 (unsigned)bfd_getl32 (p
+ 1));
6079 fprintf (file
, _(" ascii ident : %.*s\n"), p
[0], p
+ 1);
6084 struct vms_egst
*egst
= (struct vms_egst
*)e
;
6085 unsigned int flags
= bfd_getl16 (egst
->header
.flags
);
6087 fprintf (file
, _("SYMG - Universal symbol definition\n"));
6088 fprintf (file
, _(" flags: 0x%04x"), flags
);
6089 exav_bfd_print_egsy_flags (flags
, file
);
6091 fprintf (file
, _(" symbol vector offset: 0x%08x\n"),
6092 (unsigned)bfd_getl32 (egst
->value
));
6093 fprintf (file
, _(" entry point: 0x%08x\n"),
6094 (unsigned)bfd_getl32 (egst
->lp_1
));
6095 fprintf (file
, _(" proc descr : 0x%08x\n"),
6096 (unsigned)bfd_getl32 (egst
->lp_2
));
6097 fprintf (file
, _(" psect index: %u\n"),
6098 (unsigned)bfd_getl32 (egst
->psindx
));
6099 fprintf (file
, _(" name : %.*s\n"),
6100 egst
->namlng
, egst
->name
);
6105 struct vms_esdfv
*esdfv
= (struct vms_esdfv
*)e
;
6106 unsigned int flags
= bfd_getl16 (esdfv
->flags
);
6108 fprintf (file
, _("SYMV - Vectored symbol definition\n"));
6109 fprintf (file
, _(" flags: 0x%04x"), flags
);
6110 exav_bfd_print_egsy_flags (flags
, file
);
6112 fprintf (file
, _(" vector : 0x%08x\n"),
6113 (unsigned)bfd_getl32 (esdfv
->vector
));
6114 fprintf (file
, _(" psect offset: %u\n"),
6115 (unsigned)bfd_getl32 (esdfv
->value
));
6116 fprintf (file
, _(" psect index : %u\n"),
6117 (unsigned)bfd_getl32 (esdfv
->psindx
));
6118 fprintf (file
, _(" name : %.*s\n"),
6119 esdfv
->namlng
, esdfv
->name
);
6124 struct vms_esdfm
*esdfm
= (struct vms_esdfm
*)e
;
6125 unsigned int flags
= bfd_getl16 (esdfm
->flags
);
6127 fprintf (file
, _("SYMM - Global symbol definition with version\n"));
6128 fprintf (file
, _(" flags: 0x%04x"), flags
);
6129 exav_bfd_print_egsy_flags (flags
, file
);
6131 fprintf (file
, _(" version mask: 0x%08x\n"),
6132 (unsigned)bfd_getl32 (esdfm
->version_mask
));
6133 fprintf (file
, _(" psect offset: %u\n"),
6134 (unsigned)bfd_getl32 (esdfm
->value
));
6135 fprintf (file
, _(" psect index : %u\n"),
6136 (unsigned)bfd_getl32 (esdfm
->psindx
));
6137 fprintf (file
, _(" name : %.*s\n"),
6138 esdfm
->namlng
, esdfm
->name
);
6142 fprintf (file
, _("unhandled egsd entry type %u\n"), type
);
6150 evax_bfd_print_hex (FILE *file
, const char *pfx
,
6151 const unsigned char *buf
, unsigned int len
)
6157 for (i
= 0; i
< len
; i
++)
6161 fprintf (file
, " %02x", buf
[i
]);
6174 evax_bfd_print_etir_stc_ir (FILE *file
, const unsigned char *buf
, int is_ps
)
6176 /* xgettext:c-format */
6177 fprintf (file
, _(" linkage index: %u, replacement insn: 0x%08x\n"),
6178 (unsigned)bfd_getl32 (buf
),
6179 (unsigned)bfd_getl32 (buf
+ 16));
6180 /* xgettext:c-format */
6181 fprintf (file
, _(" psect idx 1: %u, offset 1: 0x%08x %08x\n"),
6182 (unsigned)bfd_getl32 (buf
+ 4),
6183 (unsigned)bfd_getl32 (buf
+ 12),
6184 (unsigned)bfd_getl32 (buf
+ 8));
6185 /* xgettext:c-format */
6186 fprintf (file
, _(" psect idx 2: %u, offset 2: 0x%08x %08x\n"),
6187 (unsigned)bfd_getl32 (buf
+ 20),
6188 (unsigned)bfd_getl32 (buf
+ 28),
6189 (unsigned)bfd_getl32 (buf
+ 24));
6191 /* xgettext:c-format */
6192 fprintf (file
, _(" psect idx 3: %u, offset 3: 0x%08x %08x\n"),
6193 (unsigned)bfd_getl32 (buf
+ 32),
6194 (unsigned)bfd_getl32 (buf
+ 40),
6195 (unsigned)bfd_getl32 (buf
+ 36));
6197 fprintf (file
, _(" global name: %.*s\n"), buf
[32], buf
+ 33);
6201 evax_bfd_print_etir (FILE *file
, const char *name
,
6202 unsigned char *rec
, unsigned int rec_len
)
6204 unsigned int off
= sizeof (struct vms_egsd
);
6205 unsigned int sec_len
= 0;
6207 /* xgettext:c-format */
6208 fprintf (file
, _(" %s (len=%u+%u):\n"), name
,
6209 (unsigned)(rec_len
- sizeof (struct vms_eobjrec
)),
6210 (unsigned)sizeof (struct vms_eobjrec
));
6212 for (off
= sizeof (struct vms_eobjrec
); off
< rec_len
; )
6214 struct vms_etir
*etir
= (struct vms_etir
*)(rec
+ off
);
6219 type
= bfd_getl16 (etir
->rectyp
);
6220 size
= bfd_getl16 (etir
->size
);
6221 buf
= rec
+ off
+ sizeof (struct vms_etir
);
6223 if (off
+ size
> rec_len
|| off
+ size
< off
)
6225 fprintf (file
, _(" Error: length larger than remaining space in record\n"));
6229 /* xgettext:c-format */
6230 fprintf (file
, _(" (type: %3u, size: 4+%3u): "), type
, size
- 4);
6233 case ETIR__C_STA_GBL
:
6234 fprintf (file
, _("STA_GBL (stack global) %.*s\n"),
6237 case ETIR__C_STA_LW
:
6238 fprintf (file
, _("STA_LW (stack longword) 0x%08x\n"),
6239 (unsigned)bfd_getl32 (buf
));
6241 case ETIR__C_STA_QW
:
6242 fprintf (file
, _("STA_QW (stack quadword) 0x%08x %08x\n"),
6243 (unsigned)bfd_getl32 (buf
+ 4),
6244 (unsigned)bfd_getl32 (buf
+ 0));
6246 case ETIR__C_STA_PQ
:
6247 fprintf (file
, _("STA_PQ (stack psect base + offset)\n"));
6248 /* xgettext:c-format */
6249 fprintf (file
, _(" psect: %u, offset: 0x%08x %08x\n"),
6250 (unsigned)bfd_getl32 (buf
+ 0),
6251 (unsigned)bfd_getl32 (buf
+ 8),
6252 (unsigned)bfd_getl32 (buf
+ 4));
6254 case ETIR__C_STA_LI
:
6255 fprintf (file
, _("STA_LI (stack literal)\n"));
6257 case ETIR__C_STA_MOD
:
6258 fprintf (file
, _("STA_MOD (stack module)\n"));
6260 case ETIR__C_STA_CKARG
:
6261 fprintf (file
, _("STA_CKARG (compare procedure argument)\n"));
6265 fprintf (file
, _("STO_B (store byte)\n"));
6268 fprintf (file
, _("STO_W (store word)\n"));
6270 case ETIR__C_STO_LW
:
6271 fprintf (file
, _("STO_LW (store longword)\n"));
6273 case ETIR__C_STO_QW
:
6274 fprintf (file
, _("STO_QW (store quadword)\n"));
6276 case ETIR__C_STO_IMMR
:
6278 unsigned int len
= bfd_getl32 (buf
);
6280 _("STO_IMMR (store immediate repeat) %u bytes\n"),
6282 evax_bfd_print_hex (file
, " ", buf
+ 4, len
);
6286 case ETIR__C_STO_GBL
:
6287 fprintf (file
, _("STO_GBL (store global) %.*s\n"),
6290 case ETIR__C_STO_CA
:
6291 fprintf (file
, _("STO_CA (store code address) %.*s\n"),
6294 case ETIR__C_STO_RB
:
6295 fprintf (file
, _("STO_RB (store relative branch)\n"));
6297 case ETIR__C_STO_AB
:
6298 fprintf (file
, _("STO_AB (store absolute branch)\n"));
6300 case ETIR__C_STO_OFF
:
6301 fprintf (file
, _("STO_OFF (store offset to psect)\n"));
6303 case ETIR__C_STO_IMM
:
6305 unsigned int len
= bfd_getl32 (buf
);
6307 _("STO_IMM (store immediate) %u bytes\n"),
6309 evax_bfd_print_hex (file
, " ", buf
+ 4, len
);
6313 case ETIR__C_STO_GBL_LW
:
6314 fprintf (file
, _("STO_GBL_LW (store global longword) %.*s\n"),
6317 case ETIR__C_STO_LP_PSB
:
6318 fprintf (file
, _("STO_OFF (store LP with procedure signature)\n"));
6320 case ETIR__C_STO_HINT_GBL
:
6321 fprintf (file
, _("STO_BR_GBL (store branch global) *todo*\n"));
6323 case ETIR__C_STO_HINT_PS
:
6324 fprintf (file
, _("STO_BR_PS (store branch psect + offset) *todo*\n"));
6327 case ETIR__C_OPR_NOP
:
6328 fprintf (file
, _("OPR_NOP (no-operation)\n"));
6330 case ETIR__C_OPR_ADD
:
6331 fprintf (file
, _("OPR_ADD (add)\n"));
6333 case ETIR__C_OPR_SUB
:
6334 fprintf (file
, _("OPR_SUB (subtract)\n"));
6336 case ETIR__C_OPR_MUL
:
6337 fprintf (file
, _("OPR_MUL (multiply)\n"));
6339 case ETIR__C_OPR_DIV
:
6340 fprintf (file
, _("OPR_DIV (divide)\n"));
6342 case ETIR__C_OPR_AND
:
6343 fprintf (file
, _("OPR_AND (logical and)\n"));
6345 case ETIR__C_OPR_IOR
:
6346 fprintf (file
, _("OPR_IOR (logical inclusive or)\n"));
6348 case ETIR__C_OPR_EOR
:
6349 fprintf (file
, _("OPR_EOR (logical exclusive or)\n"));
6351 case ETIR__C_OPR_NEG
:
6352 fprintf (file
, _("OPR_NEG (negate)\n"));
6354 case ETIR__C_OPR_COM
:
6355 fprintf (file
, _("OPR_COM (complement)\n"));
6357 case ETIR__C_OPR_INSV
:
6358 fprintf (file
, _("OPR_INSV (insert field)\n"));
6360 case ETIR__C_OPR_ASH
:
6361 fprintf (file
, _("OPR_ASH (arithmetic shift)\n"));
6363 case ETIR__C_OPR_USH
:
6364 fprintf (file
, _("OPR_USH (unsigned shift)\n"));
6366 case ETIR__C_OPR_ROT
:
6367 fprintf (file
, _("OPR_ROT (rotate)\n"));
6369 case ETIR__C_OPR_SEL
:
6370 fprintf (file
, _("OPR_SEL (select)\n"));
6372 case ETIR__C_OPR_REDEF
:
6373 fprintf (file
, _("OPR_REDEF (redefine symbol to curr location)\n"));
6375 case ETIR__C_OPR_DFLIT
:
6376 fprintf (file
, _("OPR_REDEF (define a literal)\n"));
6379 case ETIR__C_STC_LP
:
6380 fprintf (file
, _("STC_LP (store cond linkage pair)\n"));
6382 case ETIR__C_STC_LP_PSB
:
6384 _("STC_LP_PSB (store cond linkage pair + signature)\n"));
6385 /* xgettext:c-format */
6386 fprintf (file
, _(" linkage index: %u, procedure: %.*s\n"),
6387 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6388 buf
+= 4 + 1 + buf
[4];
6389 fprintf (file
, _(" signature: %.*s\n"), buf
[0], buf
+ 1);
6391 case ETIR__C_STC_GBL
:
6392 fprintf (file
, _("STC_GBL (store cond global)\n"));
6393 /* xgettext:c-format */
6394 fprintf (file
, _(" linkage index: %u, global: %.*s\n"),
6395 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6397 case ETIR__C_STC_GCA
:
6398 fprintf (file
, _("STC_GCA (store cond code address)\n"));
6399 /* xgettext:c-format */
6400 fprintf (file
, _(" linkage index: %u, procedure name: %.*s\n"),
6401 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6403 case ETIR__C_STC_PS
:
6404 fprintf (file
, _("STC_PS (store cond psect + offset)\n"));
6406 /* xgettext:c-format */
6407 _(" linkage index: %u, psect: %u, offset: 0x%08x %08x\n"),
6408 (unsigned)bfd_getl32 (buf
),
6409 (unsigned)bfd_getl32 (buf
+ 4),
6410 (unsigned)bfd_getl32 (buf
+ 12),
6411 (unsigned)bfd_getl32 (buf
+ 8));
6413 case ETIR__C_STC_NOP_GBL
:
6414 fprintf (file
, _("STC_NOP_GBL (store cond NOP at global addr)\n"));
6415 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6417 case ETIR__C_STC_NOP_PS
:
6418 fprintf (file
, _("STC_NOP_PS (store cond NOP at psect + offset)\n"));
6419 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6421 case ETIR__C_STC_BSR_GBL
:
6422 fprintf (file
, _("STC_BSR_GBL (store cond BSR at global addr)\n"));
6423 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6425 case ETIR__C_STC_BSR_PS
:
6426 fprintf (file
, _("STC_BSR_PS (store cond BSR at psect + offset)\n"));
6427 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6429 case ETIR__C_STC_LDA_GBL
:
6430 fprintf (file
, _("STC_LDA_GBL (store cond LDA at global addr)\n"));
6431 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6433 case ETIR__C_STC_LDA_PS
:
6434 fprintf (file
, _("STC_LDA_PS (store cond LDA at psect + offset)\n"));
6435 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6437 case ETIR__C_STC_BOH_GBL
:
6438 fprintf (file
, _("STC_BOH_GBL (store cond BOH at global addr)\n"));
6439 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6441 case ETIR__C_STC_BOH_PS
:
6442 fprintf (file
, _("STC_BOH_PS (store cond BOH at psect + offset)\n"));
6443 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6445 case ETIR__C_STC_NBH_GBL
:
6447 _("STC_NBH_GBL (store cond or hint at global addr)\n"));
6449 case ETIR__C_STC_NBH_PS
:
6451 _("STC_NBH_PS (store cond or hint at psect + offset)\n"));
6454 case ETIR__C_CTL_SETRB
:
6455 fprintf (file
, _("CTL_SETRB (set relocation base)\n"));
6458 case ETIR__C_CTL_AUGRB
:
6460 unsigned int val
= bfd_getl32 (buf
);
6461 fprintf (file
, _("CTL_AUGRB (augment relocation base) %u\n"), val
);
6464 case ETIR__C_CTL_DFLOC
:
6465 fprintf (file
, _("CTL_DFLOC (define location)\n"));
6467 case ETIR__C_CTL_STLOC
:
6468 fprintf (file
, _("CTL_STLOC (set location)\n"));
6470 case ETIR__C_CTL_STKDL
:
6471 fprintf (file
, _("CTL_STKDL (stack defined location)\n"));
6474 fprintf (file
, _("*unhandled*\n"));
6482 evax_bfd_print_eobj (struct bfd
*abfd
, FILE *file
)
6484 bfd_boolean is_first
= TRUE
;
6485 bfd_boolean has_records
= FALSE
;
6489 unsigned int rec_len
;
6490 unsigned int pad_len
;
6492 unsigned int hdr_size
;
6497 unsigned char buf
[6];
6502 if (bfd_bread (buf
, sizeof (buf
), abfd
) != sizeof (buf
))
6504 fprintf (file
, _("cannot read GST record length\n"));
6507 rec_len
= bfd_getl16 (buf
+ 0);
6508 if (rec_len
== bfd_getl16 (buf
+ 4)
6509 && bfd_getl16 (buf
+ 2) == EOBJ__C_EMH
)
6511 /* The format is raw: record-size, type, record-size. */
6513 pad_len
= (rec_len
+ 1) & ~1U;
6516 else if (rec_len
== EOBJ__C_EMH
)
6518 has_records
= FALSE
;
6519 pad_len
= bfd_getl16 (buf
+ 2);
6525 fprintf (file
, _("cannot find EMH in first GST record\n"));
6528 rec
= bfd_malloc (pad_len
);
6529 memcpy (rec
, buf
+ sizeof (buf
) - hdr_size
, hdr_size
);
6533 unsigned int rec_len2
= 0;
6534 unsigned char hdr
[4];
6538 unsigned char buf_len
[2];
6540 if (bfd_bread (buf_len
, sizeof (buf_len
), abfd
)
6541 != sizeof (buf_len
))
6543 fprintf (file
, _("cannot read GST record length\n"));
6546 rec_len2
= (unsigned)bfd_getl16 (buf_len
);
6549 if (bfd_bread (hdr
, sizeof (hdr
), abfd
) != sizeof (hdr
))
6551 fprintf (file
, _("cannot read GST record header\n"));
6554 rec_len
= (unsigned)bfd_getl16 (hdr
+ 2);
6556 pad_len
= (rec_len
+ 1) & ~1U;
6559 rec
= bfd_malloc (pad_len
);
6560 memcpy (rec
, hdr
, sizeof (hdr
));
6561 hdr_size
= sizeof (hdr
);
6562 if (has_records
&& rec_len2
!= rec_len
)
6564 fprintf (file
, _(" corrupted GST\n"));
6569 if (bfd_bread (rec
+ hdr_size
, pad_len
- hdr_size
, abfd
)
6570 != pad_len
- hdr_size
)
6572 fprintf (file
, _("cannot read GST record\n"));
6576 type
= (unsigned)bfd_getl16 (rec
);
6581 evax_bfd_print_emh (file
, rec
, rec_len
);
6584 evax_bfd_print_egsd (file
, rec
, rec_len
);
6587 evax_bfd_print_eeom (file
, rec
, rec_len
);
6592 evax_bfd_print_etir (file
, "ETIR", rec
, rec_len
);
6595 evax_bfd_print_etir (file
, "EDBG", rec
, rec_len
);
6598 evax_bfd_print_etir (file
, "ETBT", rec
, rec_len
);
6601 fprintf (file
, _(" unhandled EOBJ record type %u\n"), type
);
6609 evax_bfd_print_relocation_records (FILE *file
, const unsigned char *rel
,
6610 unsigned int stride
)
6618 count
= bfd_getl32 (rel
+ 0);
6622 base
= bfd_getl32 (rel
+ 4);
6624 /* xgettext:c-format */
6625 fprintf (file
, _(" bitcount: %u, base addr: 0x%08x\n"),
6629 for (j
= 0; count
> 0; j
+= 4, count
-= 32)
6635 val
= bfd_getl32 (rel
);
6638 /* xgettext:c-format */
6639 fprintf (file
, _(" bitmap: 0x%08x (count: %u):\n"), val
, count
);
6641 for (k
= 0; k
< 32; k
++)
6646 fprintf (file
, _(" %08x"), base
+ (j
* 8 + k
) * stride
);
6661 evax_bfd_print_address_fixups (FILE *file
, const unsigned char *rel
)
6668 count
= bfd_getl32 (rel
+ 0);
6671 /* xgettext:c-format */
6672 fprintf (file
, _(" image %u (%u entries)\n"),
6673 (unsigned)bfd_getl32 (rel
+ 4), count
);
6675 for (j
= 0; j
< count
; j
++)
6677 /* xgettext:c-format */
6678 fprintf (file
, _(" offset: 0x%08x, val: 0x%08x\n"),
6679 (unsigned)bfd_getl32 (rel
+ 0),
6680 (unsigned)bfd_getl32 (rel
+ 4));
6687 evax_bfd_print_reference_fixups (FILE *file
, const unsigned char *rel
)
6696 count
= bfd_getl32 (rel
+ 0);
6699 /* xgettext:c-format */
6700 fprintf (file
, _(" image %u (%u entries), offsets:\n"),
6701 (unsigned)bfd_getl32 (rel
+ 4), count
);
6703 for (j
= 0; j
< count
; j
++)
6707 fprintf (file
, _(" 0x%08x"), (unsigned)bfd_getl32 (rel
));
6722 evax_bfd_print_indent (int indent
, FILE *file
)
6724 for (; indent
; indent
--)
6729 evax_bfd_get_dsc_name (unsigned int v
)
6733 case DSC__K_DTYPE_Z
:
6734 return "Z (Unspecified)";
6735 case DSC__K_DTYPE_V
:
6737 case DSC__K_DTYPE_BU
:
6738 return "BU (Byte logical)";
6739 case DSC__K_DTYPE_WU
:
6740 return "WU (Word logical)";
6741 case DSC__K_DTYPE_LU
:
6742 return "LU (Longword logical)";
6743 case DSC__K_DTYPE_QU
:
6744 return "QU (Quadword logical)";
6745 case DSC__K_DTYPE_B
:
6746 return "B (Byte integer)";
6747 case DSC__K_DTYPE_W
:
6748 return "W (Word integer)";
6749 case DSC__K_DTYPE_L
:
6750 return "L (Longword integer)";
6751 case DSC__K_DTYPE_Q
:
6752 return "Q (Quadword integer)";
6753 case DSC__K_DTYPE_F
:
6754 return "F (Single-precision floating)";
6755 case DSC__K_DTYPE_D
:
6756 return "D (Double-precision floating)";
6757 case DSC__K_DTYPE_FC
:
6758 return "FC (Complex)";
6759 case DSC__K_DTYPE_DC
:
6760 return "DC (Double-precision Complex)";
6761 case DSC__K_DTYPE_T
:
6762 return "T (ASCII text string)";
6763 case DSC__K_DTYPE_NU
:
6764 return "NU (Numeric string, unsigned)";
6765 case DSC__K_DTYPE_NL
:
6766 return "NL (Numeric string, left separate sign)";
6767 case DSC__K_DTYPE_NLO
:
6768 return "NLO (Numeric string, left overpunched sign)";
6769 case DSC__K_DTYPE_NR
:
6770 return "NR (Numeric string, right separate sign)";
6771 case DSC__K_DTYPE_NRO
:
6772 return "NRO (Numeric string, right overpunched sig)";
6773 case DSC__K_DTYPE_NZ
:
6774 return "NZ (Numeric string, zoned sign)";
6775 case DSC__K_DTYPE_P
:
6776 return "P (Packed decimal string)";
6777 case DSC__K_DTYPE_ZI
:
6778 return "ZI (Sequence of instructions)";
6779 case DSC__K_DTYPE_ZEM
:
6780 return "ZEM (Procedure entry mask)";
6781 case DSC__K_DTYPE_DSC
:
6782 return "DSC (Descriptor, used for arrays of dyn strings)";
6783 case DSC__K_DTYPE_OU
:
6784 return "OU (Octaword logical)";
6785 case DSC__K_DTYPE_O
:
6786 return "O (Octaword integer)";
6787 case DSC__K_DTYPE_G
:
6788 return "G (Double precision G floating, 64 bit)";
6789 case DSC__K_DTYPE_H
:
6790 return "H (Quadruple precision floating, 128 bit)";
6791 case DSC__K_DTYPE_GC
:
6792 return "GC (Double precision complex, G floating)";
6793 case DSC__K_DTYPE_HC
:
6794 return "HC (Quadruple precision complex, H floating)";
6795 case DSC__K_DTYPE_CIT
:
6796 return "CIT (COBOL intermediate temporary)";
6797 case DSC__K_DTYPE_BPV
:
6798 return "BPV (Bound Procedure Value)";
6799 case DSC__K_DTYPE_BLV
:
6800 return "BLV (Bound Label Value)";
6801 case DSC__K_DTYPE_VU
:
6802 return "VU (Bit Unaligned)";
6803 case DSC__K_DTYPE_ADT
:
6804 return "ADT (Absolute Date-Time)";
6805 case DSC__K_DTYPE_VT
:
6806 return "VT (Varying Text)";
6807 case DSC__K_DTYPE_T2
:
6808 return "T2 (16-bit char)";
6809 case DSC__K_DTYPE_VT2
:
6810 return "VT2 (16-bit varying char)";
6812 return "?? (unknown)";
6817 evax_bfd_print_desc (const unsigned char *buf
, int indent
, FILE *file
)
6819 unsigned char bclass
= buf
[3];
6820 unsigned char dtype
= buf
[2];
6821 unsigned int len
= (unsigned)bfd_getl16 (buf
);
6822 unsigned int pointer
= (unsigned)bfd_getl32 (buf
+ 4);
6824 evax_bfd_print_indent (indent
, file
);
6826 if (len
== 1 && pointer
== 0xffffffffUL
)
6829 fprintf (file
, _("64 bits *unhandled*\n"));
6833 /* xgettext:c-format */
6834 fprintf (file
, _("class: %u, dtype: %u, length: %u, pointer: 0x%08x\n"),
6835 bclass
, dtype
, len
, pointer
);
6838 case DSC__K_CLASS_NCA
:
6840 const struct vms_dsc_nca
*dsc
= (const void *)buf
;
6842 const unsigned char *b
;
6844 evax_bfd_print_indent (indent
, file
);
6845 fprintf (file
, _("non-contiguous array of %s\n"),
6846 evax_bfd_get_dsc_name (dsc
->dtype
));
6847 evax_bfd_print_indent (indent
+ 1, file
);
6849 /* xgettext:c-format */
6850 _("dimct: %u, aflags: 0x%02x, digits: %u, scale: %u\n"),
6851 dsc
->dimct
, dsc
->aflags
, dsc
->digits
, dsc
->scale
);
6852 evax_bfd_print_indent (indent
+ 1, file
);
6854 /* xgettext:c-format */
6855 _("arsize: %u, a0: 0x%08x\n"),
6856 (unsigned)bfd_getl32 (dsc
->arsize
),
6857 (unsigned)bfd_getl32 (dsc
->a0
));
6858 evax_bfd_print_indent (indent
+ 1, file
);
6859 fprintf (file
, _("Strides:\n"));
6860 b
= buf
+ sizeof (*dsc
);
6861 for (i
= 0; i
< dsc
->dimct
; i
++)
6863 evax_bfd_print_indent (indent
+ 2, file
);
6864 fprintf (file
, "[%u]: %u\n", i
+ 1,
6865 (unsigned)bfd_getl32 (b
));
6868 evax_bfd_print_indent (indent
+ 1, file
);
6869 fprintf (file
, _("Bounds:\n"));
6870 b
= buf
+ sizeof (*dsc
);
6871 for (i
= 0; i
< dsc
->dimct
; i
++)
6873 evax_bfd_print_indent (indent
+ 2, file
);
6874 /* xgettext:c-format */
6875 fprintf (file
, _("[%u]: Lower: %u, upper: %u\n"), i
+ 1,
6876 (unsigned)bfd_getl32 (b
+ 0),
6877 (unsigned)bfd_getl32 (b
+ 4));
6882 case DSC__K_CLASS_UBS
:
6884 const struct vms_dsc_ubs
*ubs
= (const void *)buf
;
6886 evax_bfd_print_indent (indent
, file
);
6887 fprintf (file
, _("unaligned bit-string of %s\n"),
6888 evax_bfd_get_dsc_name (ubs
->dtype
));
6889 evax_bfd_print_indent (indent
+ 1, file
);
6891 /* xgettext:c-format */
6892 _("base: %u, pos: %u\n"),
6893 (unsigned)bfd_getl32 (ubs
->base
),
6894 (unsigned)bfd_getl32 (ubs
->pos
));
6898 fprintf (file
, _("*unhandled*\n"));
6905 evax_bfd_print_valspec (const unsigned char *buf
, int indent
, FILE *file
)
6907 unsigned int vflags
= buf
[0];
6908 unsigned int value
= (unsigned)bfd_getl32 (buf
+ 1);
6909 unsigned int len
= 5;
6911 evax_bfd_print_indent (indent
, file
);
6912 /* xgettext:c-format */
6913 fprintf (file
, _("vflags: 0x%02x, value: 0x%08x "), vflags
, value
);
6918 case DST__K_VFLAGS_NOVAL
:
6919 fprintf (file
, _("(no value)\n"));
6921 case DST__K_VFLAGS_NOTACTIVE
:
6922 fprintf (file
, _("(not active)\n"));
6924 case DST__K_VFLAGS_UNALLOC
:
6925 fprintf (file
, _("(not allocated)\n"));
6927 case DST__K_VFLAGS_DSC
:
6928 fprintf (file
, _("(descriptor)\n"));
6929 evax_bfd_print_desc (buf
+ value
, indent
+ 1, file
);
6931 case DST__K_VFLAGS_TVS
:
6932 fprintf (file
, _("(trailing value)\n"));
6934 case DST__K_VS_FOLLOWS
:
6935 fprintf (file
, _("(value spec follows)\n"));
6937 case DST__K_VFLAGS_BITOFFS
:
6938 fprintf (file
, _("(at bit offset %u)\n"), value
);
6941 /* xgettext:c-format */
6942 fprintf (file
, _("(reg: %u, disp: %u, indir: %u, kind: "),
6943 (vflags
& DST__K_REGNUM_MASK
) >> DST__K_REGNUM_SHIFT
,
6944 vflags
& DST__K_DISP
? 1 : 0,
6945 vflags
& DST__K_INDIR
? 1 : 0);
6946 switch (vflags
& DST__K_VALKIND_MASK
)
6948 case DST__K_VALKIND_LITERAL
:
6949 fputs (_("literal"), file
);
6951 case DST__K_VALKIND_ADDR
:
6952 fputs (_("address"), file
);
6954 case DST__K_VALKIND_DESC
:
6955 fputs (_("desc"), file
);
6957 case DST__K_VALKIND_REG
:
6958 fputs (_("reg"), file
);
6961 fputs (")\n", file
);
6968 evax_bfd_print_typspec (const unsigned char *buf
, int indent
, FILE *file
)
6970 unsigned char kind
= buf
[2];
6971 unsigned int len
= (unsigned)bfd_getl16 (buf
);
6973 evax_bfd_print_indent (indent
, file
);
6974 /* xgettext:c-format */
6975 fprintf (file
, _("len: %2u, kind: %2u "), len
, kind
);
6979 case DST__K_TS_ATOM
:
6980 /* xgettext:c-format */
6981 fprintf (file
, _("atomic, type=0x%02x %s\n"),
6982 buf
[0], evax_bfd_get_dsc_name (buf
[0]));
6985 fprintf (file
, _("indirect, defined at 0x%08x\n"),
6986 (unsigned)bfd_getl32 (buf
));
6988 case DST__K_TS_TPTR
:
6989 fprintf (file
, _("typed pointer\n"));
6990 evax_bfd_print_typspec (buf
, indent
+ 1, file
);
6993 fprintf (file
, _("pointer\n"));
6995 case DST__K_TS_ARRAY
:
6997 const unsigned char *vs
;
6998 unsigned int vec_len
;
7001 fprintf (file
, _("array, dim: %u, bitmap: "), buf
[0]);
7002 vec_len
= (buf
[0] + 1 + 7) / 8;
7003 for (i
= 0; i
< vec_len
; i
++)
7004 fprintf (file
, " %02x", buf
[i
+ 1]);
7006 vs
= buf
+ 1 + vec_len
;
7007 evax_bfd_print_indent (indent
, file
);
7008 fprintf (file
, _("array descriptor:\n"));
7009 vs
+= evax_bfd_print_valspec (vs
, indent
+ 1, file
);
7010 for (i
= 0; i
< buf
[0] + 1U; i
++)
7011 if (buf
[1 + i
/ 8] & (1 << (i
% 8)))
7013 evax_bfd_print_indent (indent
, file
);
7015 fprintf (file
, _("type spec for element:\n"));
7017 fprintf (file
, _("type spec for subscript %u:\n"), i
);
7018 evax_bfd_print_typspec (vs
, indent
+ 1, file
);
7019 vs
+= bfd_getl16 (vs
);
7024 fprintf (file
, _("*unhandled*\n"));
7029 evax_bfd_print_dst (struct bfd
*abfd
, unsigned int dst_size
, FILE *file
)
7031 unsigned int off
= 0;
7032 unsigned int pc
= 0;
7033 unsigned int line
= 0;
7035 fprintf (file
, _("Debug symbol table:\n"));
7037 while (dst_size
> 0)
7039 struct vms_dst_header dsth
;
7044 if (bfd_bread (&dsth
, sizeof (dsth
), abfd
) != sizeof (dsth
))
7046 fprintf (file
, _("cannot read DST header\n"));
7049 len
= bfd_getl16 (dsth
.length
);
7050 type
= bfd_getl16 (dsth
.type
);
7051 /* xgettext:c-format */
7052 fprintf (file
, _(" type: %3u, len: %3u (at 0x%08x): "),
7062 len
-= sizeof (dsth
);
7063 buf
= bfd_malloc (len
);
7064 if (bfd_bread (buf
, len
, abfd
) != len
)
7066 fprintf (file
, _("cannot read DST symbol\n"));
7071 case DSC__K_DTYPE_V
:
7072 case DSC__K_DTYPE_BU
:
7073 case DSC__K_DTYPE_WU
:
7074 case DSC__K_DTYPE_LU
:
7075 case DSC__K_DTYPE_QU
:
7076 case DSC__K_DTYPE_B
:
7077 case DSC__K_DTYPE_W
:
7078 case DSC__K_DTYPE_L
:
7079 case DSC__K_DTYPE_Q
:
7080 case DSC__K_DTYPE_F
:
7081 case DSC__K_DTYPE_D
:
7082 case DSC__K_DTYPE_FC
:
7083 case DSC__K_DTYPE_DC
:
7084 case DSC__K_DTYPE_T
:
7085 case DSC__K_DTYPE_NU
:
7086 case DSC__K_DTYPE_NL
:
7087 case DSC__K_DTYPE_NLO
:
7088 case DSC__K_DTYPE_NR
:
7089 case DSC__K_DTYPE_NRO
:
7090 case DSC__K_DTYPE_NZ
:
7091 case DSC__K_DTYPE_P
:
7092 case DSC__K_DTYPE_ZI
:
7093 case DSC__K_DTYPE_ZEM
:
7094 case DSC__K_DTYPE_DSC
:
7095 case DSC__K_DTYPE_OU
:
7096 case DSC__K_DTYPE_O
:
7097 case DSC__K_DTYPE_G
:
7098 case DSC__K_DTYPE_H
:
7099 case DSC__K_DTYPE_GC
:
7100 case DSC__K_DTYPE_HC
:
7101 case DSC__K_DTYPE_CIT
:
7102 case DSC__K_DTYPE_BPV
:
7103 case DSC__K_DTYPE_BLV
:
7104 case DSC__K_DTYPE_VU
:
7105 case DSC__K_DTYPE_ADT
:
7106 case DSC__K_DTYPE_VT
:
7107 case DSC__K_DTYPE_T2
:
7108 case DSC__K_DTYPE_VT2
:
7109 fprintf (file
, _("standard data: %s\n"),
7110 evax_bfd_get_dsc_name (type
));
7111 evax_bfd_print_valspec (buf
, 4, file
);
7112 fprintf (file
, _(" name: %.*s\n"), buf
[5], buf
+ 6);
7116 struct vms_dst_modbeg
*dst
= (void *)buf
;
7117 const char *name
= (const char *)buf
+ sizeof (*dst
);
7119 fprintf (file
, _("modbeg\n"));
7120 /* xgettext:c-format */
7121 fprintf (file
, _(" flags: %d, language: %u, "
7122 "major: %u, minor: %u\n"),
7124 (unsigned)bfd_getl32 (dst
->language
),
7125 (unsigned)bfd_getl16 (dst
->major
),
7126 (unsigned)bfd_getl16 (dst
->minor
));
7127 fprintf (file
, _(" module name: %.*s\n"),
7129 name
+= name
[0] + 1;
7130 fprintf (file
, _(" compiler : %.*s\n"),
7135 fprintf (file
, _("modend\n"));
7139 struct vms_dst_rtnbeg
*dst
= (void *)buf
;
7140 const char *name
= (const char *)buf
+ sizeof (*dst
);
7142 fputs (_("rtnbeg\n"), file
);
7143 /* xgettext:c-format */
7144 fprintf (file
, _(" flags: %u, address: 0x%08x, "
7145 "pd-address: 0x%08x\n"),
7147 (unsigned)bfd_getl32 (dst
->address
),
7148 (unsigned)bfd_getl32 (dst
->pd_address
));
7149 fprintf (file
, _(" routine name: %.*s\n"),
7155 struct vms_dst_rtnend
*dst
= (void *)buf
;
7157 fprintf (file
, _("rtnend: size 0x%08x\n"),
7158 (unsigned)bfd_getl32 (dst
->size
));
7163 struct vms_dst_prolog
*dst
= (void *)buf
;
7165 fprintf (file
, _("prolog: bkpt address 0x%08x\n"),
7166 (unsigned)bfd_getl32 (dst
->bkpt_addr
));
7171 struct vms_dst_epilog
*dst
= (void *)buf
;
7173 /* xgettext:c-format */
7174 fprintf (file
, _("epilog: flags: %u, count: %u\n"),
7175 dst
->flags
, (unsigned)bfd_getl32 (dst
->count
));
7180 struct vms_dst_blkbeg
*dst
= (void *)buf
;
7181 const char *name
= (const char *)buf
+ sizeof (*dst
);
7183 /* xgettext:c-format */
7184 fprintf (file
, _("blkbeg: address: 0x%08x, name: %.*s\n"),
7185 (unsigned)bfd_getl32 (dst
->address
),
7191 struct vms_dst_blkend
*dst
= (void *)buf
;
7193 fprintf (file
, _("blkend: size: 0x%08x\n"),
7194 (unsigned)bfd_getl32 (dst
->size
));
7197 case DST__K_TYPSPEC
:
7199 fprintf (file
, _("typspec (len: %u)\n"), len
);
7200 fprintf (file
, _(" name: %.*s\n"), buf
[0], buf
+ 1);
7201 evax_bfd_print_typspec (buf
+ 1 + buf
[0], 5, file
);
7206 fprintf (file
, _("septyp, name: %.*s\n"), buf
[5], buf
+ 6);
7207 evax_bfd_print_valspec (buf
, 4, file
);
7212 struct vms_dst_recbeg
*recbeg
= (void *)buf
;
7213 const char *name
= (const char *)buf
+ sizeof (*recbeg
);
7215 fprintf (file
, _("recbeg: name: %.*s\n"), name
[0], name
+ 1);
7216 evax_bfd_print_valspec (buf
, 4, file
);
7217 fprintf (file
, _(" len: %u bits\n"),
7218 (unsigned)bfd_getl32 (name
+ 1 + name
[0]));
7222 fprintf (file
, _("recend\n"));
7224 case DST__K_ENUMBEG
:
7225 /* xgettext:c-format */
7226 fprintf (file
, _("enumbeg, len: %u, name: %.*s\n"),
7227 buf
[0], buf
[1], buf
+ 2);
7229 case DST__K_ENUMELT
:
7230 fprintf (file
, _("enumelt, name: %.*s\n"), buf
[5], buf
+ 6);
7231 evax_bfd_print_valspec (buf
, 4, file
);
7233 case DST__K_ENUMEND
:
7234 fprintf (file
, _("enumend\n"));
7238 struct vms_dst_label
*lab
= (void *)buf
;
7239 fprintf (file
, _("label, name: %.*s\n"),
7240 lab
->name
[0], lab
->name
+ 1);
7241 fprintf (file
, _(" address: 0x%08x\n"),
7242 (unsigned)bfd_getl32 (lab
->value
));
7245 case DST__K_DIS_RANGE
:
7247 unsigned int cnt
= bfd_getl32 (buf
);
7248 unsigned char *rng
= buf
+ 4;
7251 fprintf (file
, _("discontiguous range (nbr: %u)\n"), cnt
);
7252 for (i
= 0; i
< cnt
; i
++, rng
+= 8)
7253 /* xgettext:c-format */
7254 fprintf (file
, _(" address: 0x%08x, size: %u\n"),
7255 (unsigned)bfd_getl32 (rng
),
7256 (unsigned)bfd_getl32 (rng
+ 4));
7260 case DST__K_LINE_NUM
:
7262 unsigned char *buf_orig
= buf
;
7264 fprintf (file
, _("line num (len: %u)\n"), len
);
7269 unsigned char cmdlen
;
7279 case DST__K_DELTA_PC_W
:
7280 val
= bfd_getl16 (buf
+ 1);
7281 fprintf (file
, _("delta_pc_w %u\n"), val
);
7286 case DST__K_INCR_LINUM
:
7288 fprintf (file
, _("incr_linum(b): +%u\n"), val
);
7292 case DST__K_INCR_LINUM_W
:
7293 val
= bfd_getl16 (buf
+ 1);
7294 fprintf (file
, _("incr_linum_w: +%u\n"), val
);
7298 case DST__K_INCR_LINUM_L
:
7299 val
= bfd_getl32 (buf
+ 1);
7300 fprintf (file
, _("incr_linum_l: +%u\n"), val
);
7304 case DST__K_SET_LINUM
:
7305 line
= bfd_getl16 (buf
+ 1);
7306 fprintf (file
, _("set_line_num(w) %u\n"), line
);
7309 case DST__K_SET_LINUM_B
:
7311 fprintf (file
, _("set_line_num_b %u\n"), line
);
7314 case DST__K_SET_LINUM_L
:
7315 line
= bfd_getl32 (buf
+ 1);
7316 fprintf (file
, _("set_line_num_l %u\n"), line
);
7319 case DST__K_SET_ABS_PC
:
7320 pc
= bfd_getl32 (buf
+ 1);
7321 fprintf (file
, _("set_abs_pc: 0x%08x\n"), pc
);
7324 case DST__K_DELTA_PC_L
:
7325 fprintf (file
, _("delta_pc_l: +0x%08x\n"),
7326 (unsigned)bfd_getl32 (buf
+ 1));
7330 fprintf (file
, _("term(b): 0x%02x"), buf
[1]);
7332 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7336 val
= bfd_getl16 (buf
+ 1);
7337 fprintf (file
, _("term_w: 0x%04x"), val
);
7339 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7345 fprintf (file
, _("delta pc +%-4d"), -cmd
);
7346 line
++; /* FIXME: curr increment. */
7348 /* xgettext:c-format */
7349 fprintf (file
, _(" pc: 0x%08x line: %5u\n"),
7354 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7367 unsigned char *buf_orig
= buf
;
7369 fprintf (file
, _("source (len: %u)\n"), len
);
7373 signed char cmd
= buf
[0];
7374 unsigned char cmdlen
= 0;
7378 case DST__K_SRC_DECLFILE
:
7380 struct vms_dst_src_decl_src
*src
= (void *)(buf
+ 1);
7383 /* xgettext:c-format */
7384 fprintf (file
, _(" declfile: len: %u, flags: %u, "
7386 src
->length
, src
->flags
,
7387 (unsigned)bfd_getl16 (src
->fileid
));
7388 /* xgettext:c-format */
7389 fprintf (file
, _(" rms: cdt: 0x%08x %08x, "
7390 "ebk: 0x%08x, ffb: 0x%04x, "
7392 (unsigned)bfd_getl32 (src
->rms_cdt
+ 4),
7393 (unsigned)bfd_getl32 (src
->rms_cdt
+ 0),
7394 (unsigned)bfd_getl32 (src
->rms_ebk
),
7395 (unsigned)bfd_getl16 (src
->rms_ffb
),
7397 name
= (const char *)buf
+ 1 + sizeof (*src
);
7398 fprintf (file
, _(" filename : %.*s\n"),
7400 name
+= name
[0] + 1;
7401 fprintf (file
, _(" module name: %.*s\n"),
7403 cmdlen
= 2 + src
->length
;
7406 case DST__K_SRC_SETFILE
:
7407 fprintf (file
, _(" setfile %u\n"),
7408 (unsigned)bfd_getl16 (buf
+ 1));
7411 case DST__K_SRC_SETREC_W
:
7412 fprintf (file
, _(" setrec %u\n"),
7413 (unsigned)bfd_getl16 (buf
+ 1));
7416 case DST__K_SRC_SETREC_L
:
7417 fprintf (file
, _(" setrec %u\n"),
7418 (unsigned)bfd_getl32 (buf
+ 1));
7421 case DST__K_SRC_SETLNUM_W
:
7422 fprintf (file
, _(" setlnum %u\n"),
7423 (unsigned)bfd_getl16 (buf
+ 1));
7426 case DST__K_SRC_SETLNUM_L
:
7427 fprintf (file
, _(" setlnum %u\n"),
7428 (unsigned)bfd_getl32 (buf
+ 1));
7431 case DST__K_SRC_DEFLINES_W
:
7432 fprintf (file
, _(" deflines %u\n"),
7433 (unsigned)bfd_getl16 (buf
+ 1));
7436 case DST__K_SRC_DEFLINES_B
:
7437 fprintf (file
, _(" deflines %u\n"), buf
[1]);
7440 case DST__K_SRC_FORMFEED
:
7441 fprintf (file
, _(" formfeed\n"));
7445 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7457 fprintf (file
, _("*unhandled* dst type %u\n"), type
);
7465 evax_bfd_print_image (bfd
*abfd
, FILE *file
)
7467 struct vms_eihd eihd
;
7470 unsigned int eiha_off
;
7471 unsigned int eihi_off
;
7472 unsigned int eihs_off
;
7473 unsigned int eisd_off
;
7474 unsigned int eihef_off
= 0;
7475 unsigned int eihnp_off
= 0;
7476 unsigned int dmt_vbn
= 0;
7477 unsigned int dmt_size
= 0;
7478 unsigned int dst_vbn
= 0;
7479 unsigned int dst_size
= 0;
7480 unsigned int gst_vbn
= 0;
7481 unsigned int gst_size
= 0;
7482 unsigned int eiaf_vbn
= 0;
7483 unsigned int eiaf_size
= 0;
7484 unsigned int eihvn_off
;
7486 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
)
7487 || bfd_bread (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
7489 fprintf (file
, _("cannot read EIHD\n"));
7492 /* xgettext:c-format */
7493 fprintf (file
, _("EIHD: (size: %u, nbr blocks: %u)\n"),
7494 (unsigned)bfd_getl32 (eihd
.size
),
7495 (unsigned)bfd_getl32 (eihd
.hdrblkcnt
));
7496 /* xgettext:c-format */
7497 fprintf (file
, _(" majorid: %u, minorid: %u\n"),
7498 (unsigned)bfd_getl32 (eihd
.majorid
),
7499 (unsigned)bfd_getl32 (eihd
.minorid
));
7501 val
= (unsigned)bfd_getl32 (eihd
.imgtype
);
7505 name
= _("executable");
7508 name
= _("linkable image");
7511 name
= _("unknown");
7514 /* xgettext:c-format */
7515 fprintf (file
, _(" image type: %u (%s)"), val
, name
);
7517 val
= (unsigned)bfd_getl32 (eihd
.subtype
);
7520 case EIHD__C_NATIVE
:
7527 name
= _("unknown");
7530 /* xgettext:c-format */
7531 fprintf (file
, _(", subtype: %u (%s)\n"), val
, name
);
7533 eisd_off
= bfd_getl32 (eihd
.isdoff
);
7534 eiha_off
= bfd_getl32 (eihd
.activoff
);
7535 eihi_off
= bfd_getl32 (eihd
.imgidoff
);
7536 eihs_off
= bfd_getl32 (eihd
.symdbgoff
);
7537 /* xgettext:c-format */
7538 fprintf (file
, _(" offsets: isd: %u, activ: %u, symdbg: %u, "
7539 "imgid: %u, patch: %u\n"),
7540 eisd_off
, eiha_off
, eihs_off
, eihi_off
,
7541 (unsigned)bfd_getl32 (eihd
.patchoff
));
7542 fprintf (file
, _(" fixup info rva: "));
7543 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.iafva
));
7544 fprintf (file
, _(", symbol vector rva: "));
7545 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.symvva
));
7546 eihvn_off
= bfd_getl32 (eihd
.version_array_off
);
7547 fprintf (file
, _("\n"
7548 " version array off: %u\n"),
7551 /* xgettext:c-format */
7552 _(" img I/O count: %u, nbr channels: %u, req pri: %08x%08x\n"),
7553 (unsigned)bfd_getl32 (eihd
.imgiocnt
),
7554 (unsigned)bfd_getl32 (eihd
.iochancnt
),
7555 (unsigned)bfd_getl32 (eihd
.privreqs
+ 4),
7556 (unsigned)bfd_getl32 (eihd
.privreqs
+ 0));
7557 val
= (unsigned)bfd_getl32 (eihd
.lnkflags
);
7558 fprintf (file
, _(" linker flags: %08x:"), val
);
7559 if (val
& EIHD__M_LNKDEBUG
)
7560 fprintf (file
, " LNKDEBUG");
7561 if (val
& EIHD__M_LNKNOTFR
)
7562 fprintf (file
, " LNKNOTFR");
7563 if (val
& EIHD__M_NOP0BUFS
)
7564 fprintf (file
, " NOP0BUFS");
7565 if (val
& EIHD__M_PICIMG
)
7566 fprintf (file
, " PICIMG");
7567 if (val
& EIHD__M_P0IMAGE
)
7568 fprintf (file
, " P0IMAGE");
7569 if (val
& EIHD__M_DBGDMT
)
7570 fprintf (file
, " DBGDMT");
7571 if (val
& EIHD__M_INISHR
)
7572 fprintf (file
, " INISHR");
7573 if (val
& EIHD__M_XLATED
)
7574 fprintf (file
, " XLATED");
7575 if (val
& EIHD__M_BIND_CODE_SEC
)
7576 fprintf (file
, " BIND_CODE_SEC");
7577 if (val
& EIHD__M_BIND_DATA_SEC
)
7578 fprintf (file
, " BIND_DATA_SEC");
7579 if (val
& EIHD__M_MKTHREADS
)
7580 fprintf (file
, " MKTHREADS");
7581 if (val
& EIHD__M_UPCALLS
)
7582 fprintf (file
, " UPCALLS");
7583 if (val
& EIHD__M_OMV_READY
)
7584 fprintf (file
, " OMV_READY");
7585 if (val
& EIHD__M_EXT_BIND_SECT
)
7586 fprintf (file
, " EXT_BIND_SECT");
7587 fprintf (file
, "\n");
7588 /* xgettext:c-format */
7589 fprintf (file
, _(" ident: 0x%08x, sysver: 0x%08x, "
7590 "match ctrl: %u, symvect_size: %u\n"),
7591 (unsigned)bfd_getl32 (eihd
.ident
),
7592 (unsigned)bfd_getl32 (eihd
.sysver
),
7594 (unsigned)bfd_getl32 (eihd
.symvect_size
));
7595 fprintf (file
, _(" BPAGE: %u"),
7596 (unsigned)bfd_getl32 (eihd
.virt_mem_block_size
));
7597 if (val
& (EIHD__M_OMV_READY
| EIHD__M_EXT_BIND_SECT
))
7599 eihef_off
= bfd_getl32 (eihd
.ext_fixup_off
);
7600 eihnp_off
= bfd_getl32 (eihd
.noopt_psect_off
);
7601 /* xgettext:c-format */
7602 fprintf (file
, _(", ext fixup offset: %u, no_opt psect off: %u"),
7603 eihef_off
, eihnp_off
);
7605 fprintf (file
, _(", alias: %u\n"), (unsigned)bfd_getl16 (eihd
.alias
));
7609 struct vms_eihvn eihvn
;
7613 fprintf (file
, _("system version array information:\n"));
7614 if (bfd_seek (abfd
, (file_ptr
) eihvn_off
, SEEK_SET
)
7615 || bfd_bread (&eihvn
, sizeof (eihvn
), abfd
) != sizeof (eihvn
))
7617 fprintf (file
, _("cannot read EIHVN header\n"));
7620 mask
= bfd_getl32 (eihvn
.subsystem_mask
);
7621 for (j
= 0; j
< 32; j
++)
7622 if (mask
& (1 << j
))
7624 struct vms_eihvn_subversion ver
;
7625 if (bfd_bread (&ver
, sizeof (ver
), abfd
) != sizeof (ver
))
7627 fprintf (file
, _("cannot read EIHVN version\n"));
7630 fprintf (file
, _(" %02u "), j
);
7633 case EIHVN__BASE_IMAGE_BIT
:
7634 fputs (_("BASE_IMAGE "), file
);
7636 case EIHVN__MEMORY_MANAGEMENT_BIT
:
7637 fputs (_("MEMORY_MANAGEMENT"), file
);
7640 fputs (_("IO "), file
);
7642 case EIHVN__FILES_VOLUMES_BIT
:
7643 fputs (_("FILES_VOLUMES "), file
);
7645 case EIHVN__PROCESS_SCHED_BIT
:
7646 fputs (_("PROCESS_SCHED "), file
);
7648 case EIHVN__SYSGEN_BIT
:
7649 fputs (_("SYSGEN "), file
);
7651 case EIHVN__CLUSTERS_LOCKMGR_BIT
:
7652 fputs (_("CLUSTERS_LOCKMGR "), file
);
7654 case EIHVN__LOGICAL_NAMES_BIT
:
7655 fputs (_("LOGICAL_NAMES "), file
);
7657 case EIHVN__SECURITY_BIT
:
7658 fputs (_("SECURITY "), file
);
7660 case EIHVN__IMAGE_ACTIVATOR_BIT
:
7661 fputs (_("IMAGE_ACTIVATOR "), file
);
7663 case EIHVN__NETWORKS_BIT
:
7664 fputs (_("NETWORKS "), file
);
7666 case EIHVN__COUNTERS_BIT
:
7667 fputs (_("COUNTERS "), file
);
7669 case EIHVN__STABLE_BIT
:
7670 fputs (_("STABLE "), file
);
7672 case EIHVN__MISC_BIT
:
7673 fputs (_("MISC "), file
);
7675 case EIHVN__CPU_BIT
:
7676 fputs (_("CPU "), file
);
7678 case EIHVN__VOLATILE_BIT
:
7679 fputs (_("VOLATILE "), file
);
7681 case EIHVN__SHELL_BIT
:
7682 fputs (_("SHELL "), file
);
7684 case EIHVN__POSIX_BIT
:
7685 fputs (_("POSIX "), file
);
7687 case EIHVN__MULTI_PROCESSING_BIT
:
7688 fputs (_("MULTI_PROCESSING "), file
);
7690 case EIHVN__GALAXY_BIT
:
7691 fputs (_("GALAXY "), file
);
7694 fputs (_("*unknown* "), file
);
7697 fprintf (file
, ": %u.%u\n",
7698 (unsigned)bfd_getl16 (ver
.major
),
7699 (unsigned)bfd_getl16 (ver
.minor
));
7705 struct vms_eiha eiha
;
7707 if (bfd_seek (abfd
, (file_ptr
) eiha_off
, SEEK_SET
)
7708 || bfd_bread (&eiha
, sizeof (eiha
), abfd
) != sizeof (eiha
))
7710 fprintf (file
, _("cannot read EIHA\n"));
7713 fprintf (file
, _("Image activation: (size=%u)\n"),
7714 (unsigned)bfd_getl32 (eiha
.size
));
7715 /* xgettext:c-format */
7716 fprintf (file
, _(" First address : 0x%08x 0x%08x\n"),
7717 (unsigned)bfd_getl32 (eiha
.tfradr1_h
),
7718 (unsigned)bfd_getl32 (eiha
.tfradr1
));
7719 /* xgettext:c-format */
7720 fprintf (file
, _(" Second address: 0x%08x 0x%08x\n"),
7721 (unsigned)bfd_getl32 (eiha
.tfradr2_h
),
7722 (unsigned)bfd_getl32 (eiha
.tfradr2
));
7723 /* xgettext:c-format */
7724 fprintf (file
, _(" Third address : 0x%08x 0x%08x\n"),
7725 (unsigned)bfd_getl32 (eiha
.tfradr3_h
),
7726 (unsigned)bfd_getl32 (eiha
.tfradr3
));
7727 /* xgettext:c-format */
7728 fprintf (file
, _(" Fourth address: 0x%08x 0x%08x\n"),
7729 (unsigned)bfd_getl32 (eiha
.tfradr4_h
),
7730 (unsigned)bfd_getl32 (eiha
.tfradr4
));
7731 /* xgettext:c-format */
7732 fprintf (file
, _(" Shared image : 0x%08x 0x%08x\n"),
7733 (unsigned)bfd_getl32 (eiha
.inishr_h
),
7734 (unsigned)bfd_getl32 (eiha
.inishr
));
7738 struct vms_eihi eihi
;
7740 if (bfd_seek (abfd
, (file_ptr
) eihi_off
, SEEK_SET
)
7741 || bfd_bread (&eihi
, sizeof (eihi
), abfd
) != sizeof (eihi
))
7743 fprintf (file
, _("cannot read EIHI\n"));
7746 /* xgettext:c-format */
7747 fprintf (file
, _("Image identification: (major: %u, minor: %u)\n"),
7748 (unsigned)bfd_getl32 (eihi
.majorid
),
7749 (unsigned)bfd_getl32 (eihi
.minorid
));
7750 fprintf (file
, _(" image name : %.*s\n"),
7751 eihi
.imgnam
[0], eihi
.imgnam
+ 1);
7752 fprintf (file
, _(" link time : %s\n"),
7753 vms_time_to_str (eihi
.linktime
));
7754 fprintf (file
, _(" image ident : %.*s\n"),
7755 eihi
.imgid
[0], eihi
.imgid
+ 1);
7756 fprintf (file
, _(" linker ident : %.*s\n"),
7757 eihi
.linkid
[0], eihi
.linkid
+ 1);
7758 fprintf (file
, _(" image build ident: %.*s\n"),
7759 eihi
.imgbid
[0], eihi
.imgbid
+ 1);
7763 struct vms_eihs eihs
;
7765 if (bfd_seek (abfd
, (file_ptr
) eihs_off
, SEEK_SET
)
7766 || bfd_bread (&eihs
, sizeof (eihs
), abfd
) != sizeof (eihs
))
7768 fprintf (file
, _("cannot read EIHS\n"));
7771 /* xgettext:c-format */
7772 fprintf (file
, _("Image symbol & debug table: (major: %u, minor: %u)\n"),
7773 (unsigned)bfd_getl32 (eihs
.majorid
),
7774 (unsigned)bfd_getl32 (eihs
.minorid
));
7775 dst_vbn
= bfd_getl32 (eihs
.dstvbn
);
7776 dst_size
= bfd_getl32 (eihs
.dstsize
);
7777 /* xgettext:c-format */
7778 fprintf (file
, _(" debug symbol table : vbn: %u, size: %u (0x%x)\n"),
7779 dst_vbn
, dst_size
, dst_size
);
7780 gst_vbn
= bfd_getl32 (eihs
.gstvbn
);
7781 gst_size
= bfd_getl32 (eihs
.gstsize
);
7782 /* xgettext:c-format */
7783 fprintf (file
, _(" global symbol table: vbn: %u, records: %u\n"),
7785 dmt_vbn
= bfd_getl32 (eihs
.dmtvbn
);
7786 dmt_size
= bfd_getl32 (eihs
.dmtsize
);
7787 /* xgettext:c-format */
7788 fprintf (file
, _(" debug module table : vbn: %u, size: %u\n"),
7791 while (eisd_off
!= 0)
7793 struct vms_eisd eisd
;
7798 if (bfd_seek (abfd
, (file_ptr
) eisd_off
, SEEK_SET
)
7799 || bfd_bread (&eisd
, sizeof (eisd
), abfd
) != sizeof (eisd
))
7801 fprintf (file
, _("cannot read EISD\n"));
7804 len
= (unsigned)bfd_getl32 (eisd
.eisdsize
);
7805 if (len
!= (unsigned)-1)
7809 eisd_off
= (eisd_off
+ VMS_BLOCK_SIZE
) & ~(VMS_BLOCK_SIZE
- 1);
7811 /* xgettext:c-format */
7812 fprintf (file
, _("Image section descriptor: (major: %u, minor: %u, "
7813 "size: %u, offset: %u)\n"),
7814 (unsigned)bfd_getl32 (eisd
.majorid
),
7815 (unsigned)bfd_getl32 (eisd
.minorid
),
7819 /* xgettext:c-format */
7820 fprintf (file
, _(" section: base: 0x%08x%08x size: 0x%08x\n"),
7821 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 4),
7822 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 0),
7823 (unsigned)bfd_getl32 (eisd
.secsize
));
7824 val
= (unsigned)bfd_getl32 (eisd
.flags
);
7825 fprintf (file
, _(" flags: 0x%04x"), val
);
7826 if (val
& EISD__M_GBL
)
7827 fprintf (file
, " GBL");
7828 if (val
& EISD__M_CRF
)
7829 fprintf (file
, " CRF");
7830 if (val
& EISD__M_DZRO
)
7831 fprintf (file
, " DZRO");
7832 if (val
& EISD__M_WRT
)
7833 fprintf (file
, " WRT");
7834 if (val
& EISD__M_INITALCODE
)
7835 fprintf (file
, " INITALCODE");
7836 if (val
& EISD__M_BASED
)
7837 fprintf (file
, " BASED");
7838 if (val
& EISD__M_FIXUPVEC
)
7839 fprintf (file
, " FIXUPVEC");
7840 if (val
& EISD__M_RESIDENT
)
7841 fprintf (file
, " RESIDENT");
7842 if (val
& EISD__M_VECTOR
)
7843 fprintf (file
, " VECTOR");
7844 if (val
& EISD__M_PROTECT
)
7845 fprintf (file
, " PROTECT");
7846 if (val
& EISD__M_LASTCLU
)
7847 fprintf (file
, " LASTCLU");
7848 if (val
& EISD__M_EXE
)
7849 fprintf (file
, " EXE");
7850 if (val
& EISD__M_NONSHRADR
)
7851 fprintf (file
, " NONSHRADR");
7852 if (val
& EISD__M_QUAD_LENGTH
)
7853 fprintf (file
, " QUAD_LENGTH");
7854 if (val
& EISD__M_ALLOC_64BIT
)
7855 fprintf (file
, " ALLOC_64BIT");
7856 fprintf (file
, "\n");
7857 if (val
& EISD__M_FIXUPVEC
)
7859 eiaf_vbn
= bfd_getl32 (eisd
.vbn
);
7860 eiaf_size
= bfd_getl32 (eisd
.secsize
);
7862 /* xgettext:c-format */
7863 fprintf (file
, _(" vbn: %u, pfc: %u, matchctl: %u type: %u ("),
7864 (unsigned)bfd_getl32 (eisd
.vbn
),
7865 eisd
.pfc
, eisd
.matchctl
, eisd
.type
);
7868 case EISD__K_NORMAL
:
7869 fputs (_("NORMAL"), file
);
7871 case EISD__K_SHRFXD
:
7872 fputs (_("SHRFXD"), file
);
7874 case EISD__K_PRVFXD
:
7875 fputs (_("PRVFXD"), file
);
7877 case EISD__K_SHRPIC
:
7878 fputs (_("SHRPIC"), file
);
7880 case EISD__K_PRVPIC
:
7881 fputs (_("PRVPIC"), file
);
7883 case EISD__K_USRSTACK
:
7884 fputs (_("USRSTACK"), file
);
7887 fputs (_("*unknown*"), file
);
7890 fputs (_(")\n"), file
);
7891 if (val
& EISD__M_GBL
)
7892 /* xgettext:c-format */
7893 fprintf (file
, _(" ident: 0x%08x, name: %.*s\n"),
7894 (unsigned)bfd_getl32 (eisd
.ident
),
7895 eisd
.gblnam
[0], eisd
.gblnam
+ 1);
7901 if (bfd_seek (abfd
, (file_ptr
) (dmt_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7903 fprintf (file
, _("cannot read DMT\n"));
7907 fprintf (file
, _("Debug module table:\n"));
7909 while (dmt_size
> 0)
7911 struct vms_dmt_header dmth
;
7914 if (bfd_bread (&dmth
, sizeof (dmth
), abfd
) != sizeof (dmth
))
7916 fprintf (file
, _("cannot read DMT header\n"));
7919 count
= bfd_getl16 (dmth
.psect_count
);
7921 /* xgettext:c-format */
7922 _(" module offset: 0x%08x, size: 0x%08x, (%u psects)\n"),
7923 (unsigned)bfd_getl32 (dmth
.modbeg
),
7924 (unsigned)bfd_getl32 (dmth
.size
), count
);
7925 dmt_size
-= sizeof (dmth
);
7928 struct vms_dmt_psect dmtp
;
7930 if (bfd_bread (&dmtp
, sizeof (dmtp
), abfd
) != sizeof (dmtp
))
7932 fprintf (file
, _("cannot read DMT psect\n"));
7935 /* xgettext:c-format */
7936 fprintf (file
, _(" psect start: 0x%08x, length: %u\n"),
7937 (unsigned)bfd_getl32 (dmtp
.start
),
7938 (unsigned)bfd_getl32 (dmtp
.length
));
7940 dmt_size
-= sizeof (dmtp
);
7947 if (bfd_seek (abfd
, (file_ptr
) (dst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7949 fprintf (file
, _("cannot read DST\n"));
7953 evax_bfd_print_dst (abfd
, dst_size
, file
);
7957 if (bfd_seek (abfd
, (file_ptr
) (gst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7959 fprintf (file
, _("cannot read GST\n"));
7963 fprintf (file
, _("Global symbol table:\n"));
7964 evax_bfd_print_eobj (abfd
, file
);
7969 struct vms_eiaf
*eiaf
;
7970 unsigned int qrelfixoff
;
7971 unsigned int lrelfixoff
;
7972 unsigned int qdotadroff
;
7973 unsigned int ldotadroff
;
7974 unsigned int shrimgcnt
;
7975 unsigned int shlstoff
;
7976 unsigned int codeadroff
;
7977 unsigned int lpfixoff
;
7978 unsigned int chgprtoff
;
7980 buf
= bfd_malloc (eiaf_size
);
7982 if (bfd_seek (abfd
, (file_ptr
) (eiaf_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
)
7983 || bfd_bread (buf
, eiaf_size
, abfd
) != eiaf_size
)
7985 fprintf (file
, _("cannot read EIHA\n"));
7989 eiaf
= (struct vms_eiaf
*)buf
;
7991 /* xgettext:c-format */
7992 _("Image activator fixup: (major: %u, minor: %u)\n"),
7993 (unsigned)bfd_getl32 (eiaf
->majorid
),
7994 (unsigned)bfd_getl32 (eiaf
->minorid
));
7995 /* xgettext:c-format */
7996 fprintf (file
, _(" iaflink : 0x%08x %08x\n"),
7997 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 0),
7998 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 4));
7999 /* xgettext:c-format */
8000 fprintf (file
, _(" fixuplnk: 0x%08x %08x\n"),
8001 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 0),
8002 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 4));
8003 fprintf (file
, _(" size : %u\n"),
8004 (unsigned)bfd_getl32 (eiaf
->size
));
8005 fprintf (file
, _(" flags: 0x%08x\n"),
8006 (unsigned)bfd_getl32 (eiaf
->flags
));
8007 qrelfixoff
= bfd_getl32 (eiaf
->qrelfixoff
);
8008 lrelfixoff
= bfd_getl32 (eiaf
->lrelfixoff
);
8009 /* xgettext:c-format */
8010 fprintf (file
, _(" qrelfixoff: %5u, lrelfixoff: %5u\n"),
8011 qrelfixoff
, lrelfixoff
);
8012 qdotadroff
= bfd_getl32 (eiaf
->qdotadroff
);
8013 ldotadroff
= bfd_getl32 (eiaf
->ldotadroff
);
8014 /* xgettext:c-format */
8015 fprintf (file
, _(" qdotadroff: %5u, ldotadroff: %5u\n"),
8016 qdotadroff
, ldotadroff
);
8017 codeadroff
= bfd_getl32 (eiaf
->codeadroff
);
8018 lpfixoff
= bfd_getl32 (eiaf
->lpfixoff
);
8019 /* xgettext:c-format */
8020 fprintf (file
, _(" codeadroff: %5u, lpfixoff : %5u\n"),
8021 codeadroff
, lpfixoff
);
8022 chgprtoff
= bfd_getl32 (eiaf
->chgprtoff
);
8023 fprintf (file
, _(" chgprtoff : %5u\n"), chgprtoff
);
8024 shrimgcnt
= bfd_getl32 (eiaf
->shrimgcnt
);
8025 shlstoff
= bfd_getl32 (eiaf
->shlstoff
);
8026 /* xgettext:c-format */
8027 fprintf (file
, _(" shlstoff : %5u, shrimgcnt : %5u\n"),
8028 shlstoff
, shrimgcnt
);
8029 /* xgettext:c-format */
8030 fprintf (file
, _(" shlextra : %5u, permctx : %5u\n"),
8031 (unsigned)bfd_getl32 (eiaf
->shlextra
),
8032 (unsigned)bfd_getl32 (eiaf
->permctx
));
8033 fprintf (file
, _(" base_va : 0x%08x\n"),
8034 (unsigned)bfd_getl32 (eiaf
->base_va
));
8035 fprintf (file
, _(" lppsbfixoff: %5u\n"),
8036 (unsigned)bfd_getl32 (eiaf
->lppsbfixoff
));
8040 struct vms_shl
*shl
= (struct vms_shl
*)(buf
+ shlstoff
);
8043 fprintf (file
, _(" Shareable images:\n"));
8044 for (j
= 0; j
< shrimgcnt
; j
++, shl
++)
8047 /* xgettext:c-format */
8048 _(" %u: size: %u, flags: 0x%02x, name: %.*s\n"),
8049 j
, shl
->size
, shl
->flags
,
8050 shl
->imgnam
[0], shl
->imgnam
+ 1);
8053 if (qrelfixoff
!= 0)
8055 fprintf (file
, _(" quad-word relocation fixups:\n"));
8056 evax_bfd_print_relocation_records (file
, buf
+ qrelfixoff
, 8);
8058 if (lrelfixoff
!= 0)
8060 fprintf (file
, _(" long-word relocation fixups:\n"));
8061 evax_bfd_print_relocation_records (file
, buf
+ lrelfixoff
, 4);
8063 if (qdotadroff
!= 0)
8065 fprintf (file
, _(" quad-word .address reference fixups:\n"));
8066 evax_bfd_print_address_fixups (file
, buf
+ qdotadroff
);
8068 if (ldotadroff
!= 0)
8070 fprintf (file
, _(" long-word .address reference fixups:\n"));
8071 evax_bfd_print_address_fixups (file
, buf
+ ldotadroff
);
8073 if (codeadroff
!= 0)
8075 fprintf (file
, _(" Code Address Reference Fixups:\n"));
8076 evax_bfd_print_reference_fixups (file
, buf
+ codeadroff
);
8080 fprintf (file
, _(" Linkage Pairs Reference Fixups:\n"));
8081 evax_bfd_print_reference_fixups (file
, buf
+ lpfixoff
);
8085 unsigned int count
= (unsigned)bfd_getl32 (buf
+ chgprtoff
);
8086 struct vms_eicp
*eicp
= (struct vms_eicp
*)(buf
+ chgprtoff
+ 4);
8089 fprintf (file
, _(" Change Protection (%u entries):\n"), count
);
8090 for (j
= 0; j
< count
; j
++, eicp
++)
8092 unsigned int prot
= bfd_getl32 (eicp
->newprt
);
8094 /* xgettext:c-format */
8095 _(" base: 0x%08x %08x, size: 0x%08x, prot: 0x%08x "),
8096 (unsigned)bfd_getl32 (eicp
->baseva
+ 4),
8097 (unsigned)bfd_getl32 (eicp
->baseva
+ 0),
8098 (unsigned)bfd_getl32 (eicp
->size
),
8099 (unsigned)bfd_getl32 (eicp
->newprt
));
8103 fprintf (file
, "NA");
8105 case PRT__C_RESERVED
:
8106 fprintf (file
, "RES");
8109 fprintf (file
, "KW");
8112 fprintf (file
, "KR");
8115 fprintf (file
, "UW");
8118 fprintf (file
, "EW");
8121 fprintf (file
, "ERKW");
8124 fprintf (file
, "ER");
8127 fprintf (file
, "SW");
8130 fprintf (file
, "SREW");
8133 fprintf (file
, "SRKW");
8136 fprintf (file
, "SR");
8139 fprintf (file
, "URSW");
8142 fprintf (file
, "UREW");
8145 fprintf (file
, "URKW");
8148 fprintf (file
, "UR");
8162 vms_bfd_print_private_bfd_data (bfd
*abfd
, void *ptr
)
8164 FILE *file
= (FILE *)ptr
;
8166 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
8167 evax_bfd_print_image (abfd
, file
);
8170 if (bfd_seek (abfd
, 0, SEEK_SET
))
8172 evax_bfd_print_eobj (abfd
, file
);
8179 /* Slurp ETIR/EDBG/ETBT VMS object records. */
8182 alpha_vms_read_sections_content (bfd
*abfd
, struct bfd_link_info
*info
)
8184 asection
*cur_section
;
8185 file_ptr cur_offset
;
8186 asection
*dst_section
;
8187 file_ptr dst_offset
;
8189 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
8195 dst_section
= PRIV (dst_section
);
8199 if (info
->strip
== strip_all
|| info
->strip
== strip_debugger
)
8201 /* Discard the DST section. */
8205 else if (dst_section
)
8207 dst_offset
= dst_section
->output_offset
;
8208 dst_section
= dst_section
->output_section
;
8217 type
= _bfd_vms_get_object_record (abfd
);
8220 vms_debug2 ((2, "next_record failed\n"));
8226 PRIV (image_section
) = cur_section
;
8227 PRIV (image_offset
) = cur_offset
;
8228 res
= _bfd_vms_slurp_etir (abfd
, info
);
8229 cur_section
= PRIV (image_section
);
8230 cur_offset
= PRIV (image_offset
);
8234 if (dst_section
== NULL
)
8236 PRIV (image_section
) = dst_section
;
8237 PRIV (image_offset
) = dst_offset
;
8238 res
= _bfd_vms_slurp_etir (abfd
, info
);
8239 dst_offset
= PRIV (image_offset
);
8248 vms_debug2 ((2, "slurp eobj type %d failed\n", type
));
8255 alpha_vms_sizeof_headers (bfd
*abfd ATTRIBUTE_UNUSED
,
8256 struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8261 /* Add a linkage pair fixup at address SECT + OFFSET to SHLIB. */
8264 alpha_vms_add_fixup_lp (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
8266 struct alpha_vms_shlib_el
*sl
;
8267 asection
*sect
= PRIV2 (src
, image_section
);
8268 file_ptr offset
= PRIV2 (src
, image_offset
);
8270 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8271 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8272 sl
->has_fixups
= TRUE
;
8273 VEC_APPEND_EL (sl
->lp
, bfd_vma
,
8274 sect
->output_section
->vma
+ sect
->output_offset
+ offset
);
8275 sect
->output_section
->flags
|= SEC_RELOC
;
8278 /* Add a code address fixup at address SECT + OFFSET to SHLIB. */
8281 alpha_vms_add_fixup_ca (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
8283 struct alpha_vms_shlib_el
*sl
;
8284 asection
*sect
= PRIV2 (src
, image_section
);
8285 file_ptr offset
= PRIV2 (src
, image_offset
);
8287 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8288 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8289 sl
->has_fixups
= TRUE
;
8290 VEC_APPEND_EL (sl
->ca
, bfd_vma
,
8291 sect
->output_section
->vma
+ sect
->output_offset
+ offset
);
8292 sect
->output_section
->flags
|= SEC_RELOC
;
8295 /* Add a quad word relocation fixup at address SECT + OFFSET to SHLIB. */
8298 alpha_vms_add_fixup_qr (struct bfd_link_info
*info
, bfd
*src
,
8299 bfd
*shlib
, bfd_vma vec
)
8301 struct alpha_vms_shlib_el
*sl
;
8302 struct alpha_vms_vma_ref
*r
;
8303 asection
*sect
= PRIV2 (src
, image_section
);
8304 file_ptr offset
= PRIV2 (src
, image_offset
);
8306 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8307 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8308 sl
->has_fixups
= TRUE
;
8309 r
= VEC_APPEND (sl
->qr
, struct alpha_vms_vma_ref
);
8310 r
->vma
= sect
->output_section
->vma
+ sect
->output_offset
+ offset
;
8312 sect
->output_section
->flags
|= SEC_RELOC
;
8316 alpha_vms_add_fixup_lr (struct bfd_link_info
*info ATTRIBUTE_UNUSED
,
8317 unsigned int shr ATTRIBUTE_UNUSED
,
8318 bfd_vma vec ATTRIBUTE_UNUSED
)
8320 /* Not yet supported. */
8324 /* Add relocation. FIXME: Not yet emitted. */
8327 alpha_vms_add_lw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8332 alpha_vms_add_qw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8336 static struct bfd_hash_entry
*
8337 alpha_vms_link_hash_newfunc (struct bfd_hash_entry
*entry
,
8338 struct bfd_hash_table
*table
,
8341 struct alpha_vms_link_hash_entry
*ret
=
8342 (struct alpha_vms_link_hash_entry
*) entry
;
8344 /* Allocate the structure if it has not already been allocated by a
8347 ret
= ((struct alpha_vms_link_hash_entry
*)
8348 bfd_hash_allocate (table
,
8349 sizeof (struct alpha_vms_link_hash_entry
)));
8353 /* Call the allocation method of the superclass. */
8354 ret
= ((struct alpha_vms_link_hash_entry
*)
8355 _bfd_link_hash_newfunc ((struct bfd_hash_entry
*) ret
,
8360 return (struct bfd_hash_entry
*) ret
;
8363 /* Create an Alpha/VMS link hash table. */
8365 static struct bfd_link_hash_table
*
8366 alpha_vms_bfd_link_hash_table_create (bfd
*abfd
)
8368 struct alpha_vms_link_hash_table
*ret
;
8369 bfd_size_type amt
= sizeof (struct alpha_vms_link_hash_table
);
8371 ret
= (struct alpha_vms_link_hash_table
*) bfd_malloc (amt
);
8374 if (!_bfd_link_hash_table_init (&ret
->root
, abfd
,
8375 alpha_vms_link_hash_newfunc
,
8376 sizeof (struct alpha_vms_link_hash_entry
)))
8382 VEC_INIT (ret
->shrlibs
);
8389 alpha_vms_link_add_object_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8393 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
8395 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
8396 struct alpha_vms_link_hash_entry
*h
;
8397 struct bfd_link_hash_entry
*h_root
;
8400 if (!alpha_vms_convert_symbol (abfd
, e
, &sym
))
8403 if ((e
->flags
& EGSY__V_DEF
) && abfd
->selective_search
)
8405 /* In selective_search mode, only add definition that are
8407 h
= (struct alpha_vms_link_hash_entry
*)bfd_link_hash_lookup
8408 (info
->hash
, sym
.name
, FALSE
, FALSE
, FALSE
);
8409 if (h
== NULL
|| h
->root
.type
!= bfd_link_hash_undefined
)
8415 h_root
= (struct bfd_link_hash_entry
*) h
;
8416 if (!_bfd_generic_link_add_one_symbol (info
, abfd
, sym
.name
, sym
.flags
,
8417 sym
.section
, sym
.value
, NULL
,
8418 FALSE
, FALSE
, &h_root
))
8420 h
= (struct alpha_vms_link_hash_entry
*) h_root
;
8422 if ((e
->flags
& EGSY__V_DEF
)
8424 && abfd
->xvec
== info
->output_bfd
->xvec
)
8428 if (abfd
->flags
& DYNAMIC
)
8430 struct alpha_vms_shlib_el
*shlib
;
8432 /* We do not want to include any of the sections in a dynamic
8433 object in the output file. See comment in elflink.c. */
8434 bfd_section_list_clear (abfd
);
8436 shlib
= VEC_APPEND (alpha_vms_link_hash (info
)->shrlibs
,
8437 struct alpha_vms_shlib_el
);
8439 VEC_INIT (shlib
->ca
);
8440 VEC_INIT (shlib
->lp
);
8441 VEC_INIT (shlib
->qr
);
8442 PRIV (shr_index
) = VEC_COUNT (alpha_vms_link_hash (info
)->shrlibs
) - 1;
8449 alpha_vms_link_add_archive_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8452 struct bfd_link_hash_entry
**pundef
;
8453 struct bfd_link_hash_entry
**next_pundef
;
8455 /* We only accept VMS libraries. */
8456 if (info
->output_bfd
->xvec
!= abfd
->xvec
)
8458 bfd_set_error (bfd_error_wrong_format
);
8462 /* The archive_pass field in the archive itself is used to
8463 initialize PASS, since we may search the same archive multiple
8465 pass
= ++abfd
->archive_pass
;
8467 /* Look through the list of undefined symbols. */
8468 for (pundef
= &info
->hash
->undefs
; *pundef
!= NULL
; pundef
= next_pundef
)
8470 struct bfd_link_hash_entry
*h
;
8476 next_pundef
= &(*pundef
)->u
.undef
.next
;
8478 /* When a symbol is defined, it is not necessarily removed from
8480 if (h
->type
!= bfd_link_hash_undefined
8481 && h
->type
!= bfd_link_hash_common
)
8483 /* Remove this entry from the list, for general cleanliness
8484 and because we are going to look through the list again
8485 if we search any more libraries. We can't remove the
8486 entry if it is the tail, because that would lose any
8487 entries we add to the list later on. */
8488 if (*pundef
!= info
->hash
->undefs_tail
)
8490 *pundef
= *next_pundef
;
8491 next_pundef
= pundef
;
8496 /* Look for this symbol in the archive hash table. */
8497 symidx
= _bfd_vms_lib_find_symbol (abfd
, h
->root
.string
);
8498 if (symidx
== BFD_NO_MORE_SYMBOLS
)
8500 /* Nothing in this slot. */
8504 element
= bfd_get_elt_at_index (abfd
, symidx
);
8505 if (element
== NULL
)
8508 if (element
->archive_pass
== -1 || element
->archive_pass
== pass
)
8510 /* Next symbol if this archive is wrong or already handled. */
8514 if (! bfd_check_format (element
, bfd_object
))
8516 element
->archive_pass
= -1;
8520 orig_element
= element
;
8521 if (bfd_is_thin_archive (abfd
))
8523 element
= _bfd_vms_lib_get_imagelib_file (element
);
8524 if (element
== NULL
|| !bfd_check_format (element
, bfd_object
))
8526 orig_element
->archive_pass
= -1;
8531 /* Unlike the generic linker, we know that this element provides
8532 a definition for an undefined symbol and we know that we want
8533 to include it. We don't need to check anything. */
8534 if (!(*info
->callbacks
8535 ->add_archive_element
) (info
, element
, h
->root
.string
, &element
))
8537 if (!alpha_vms_link_add_object_symbols (element
, info
))
8540 orig_element
->archive_pass
= pass
;
8547 alpha_vms_bfd_link_add_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8549 switch (bfd_get_format (abfd
))
8552 vms_debug2 ((2, "vms_link_add_symbols for object %s\n",
8554 return alpha_vms_link_add_object_symbols (abfd
, info
);
8557 vms_debug2 ((2, "vms_link_add_symbols for archive %s\n",
8559 return alpha_vms_link_add_archive_symbols (abfd
, info
);
8562 bfd_set_error (bfd_error_wrong_format
);
8568 alpha_vms_build_fixups (struct bfd_link_info
*info
)
8570 struct alpha_vms_link_hash_table
*t
= alpha_vms_link_hash (info
);
8571 unsigned char *content
;
8573 unsigned int sz
= 0;
8574 unsigned int lp_sz
= 0;
8575 unsigned int ca_sz
= 0;
8576 unsigned int qr_sz
= 0;
8577 unsigned int shrimg_cnt
= 0;
8578 unsigned int chgprt_num
= 0;
8579 unsigned int chgprt_sz
= 0;
8580 struct vms_eiaf
*eiaf
;
8584 /* Shared libraries. */
8585 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8587 struct alpha_vms_shlib_el
*shlib
;
8589 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8591 if (!shlib
->has_fixups
)
8596 if (VEC_COUNT (shlib
->ca
) > 0)
8598 /* Header + entries. */
8600 ca_sz
+= VEC_COUNT (shlib
->ca
) * 4;
8602 if (VEC_COUNT (shlib
->lp
) > 0)
8604 /* Header + entries. */
8606 lp_sz
+= VEC_COUNT (shlib
->lp
) * 4;
8608 if (VEC_COUNT (shlib
->qr
) > 0)
8610 /* Header + entries. */
8612 qr_sz
+= VEC_COUNT (shlib
->qr
) * 8;
8623 /* Finish now if there is no content. */
8624 if (ca_sz
+ lp_sz
+ qr_sz
== 0)
8627 /* Add an eicp entry for the fixup itself. */
8629 for (sec
= info
->output_bfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
8631 /* This isect could be made RO or EXE after relocations are applied. */
8632 if ((sec
->flags
& SEC_RELOC
) != 0
8633 && (sec
->flags
& (SEC_CODE
| SEC_READONLY
)) != 0)
8636 chgprt_sz
= 4 + chgprt_num
* sizeof (struct vms_eicp
);
8638 /* Allocate section content (round-up size) */
8639 sz
= sizeof (struct vms_eiaf
) + shrimg_cnt
* sizeof (struct vms_shl
)
8640 + ca_sz
+ lp_sz
+ qr_sz
+ chgprt_sz
;
8641 sz
= (sz
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
8642 content
= bfd_zalloc (info
->output_bfd
, sz
);
8643 if (content
== NULL
)
8646 sec
= alpha_vms_link_hash (info
)->fixup
;
8647 sec
->contents
= content
;
8650 eiaf
= (struct vms_eiaf
*)content
;
8651 off
= sizeof (struct vms_eiaf
);
8652 bfd_putl32 (0, eiaf
->majorid
);
8653 bfd_putl32 (0, eiaf
->minorid
);
8654 bfd_putl32 (0, eiaf
->iaflink
);
8655 bfd_putl32 (0, eiaf
->fixuplnk
);
8656 bfd_putl32 (sizeof (struct vms_eiaf
), eiaf
->size
);
8657 bfd_putl32 (0, eiaf
->flags
);
8658 bfd_putl32 (0, eiaf
->qrelfixoff
);
8659 bfd_putl32 (0, eiaf
->lrelfixoff
);
8660 bfd_putl32 (0, eiaf
->qdotadroff
);
8661 bfd_putl32 (0, eiaf
->ldotadroff
);
8662 bfd_putl32 (0, eiaf
->codeadroff
);
8663 bfd_putl32 (0, eiaf
->lpfixoff
);
8664 bfd_putl32 (0, eiaf
->chgprtoff
);
8665 bfd_putl32 (shrimg_cnt
? off
: 0, eiaf
->shlstoff
);
8666 bfd_putl32 (shrimg_cnt
, eiaf
->shrimgcnt
);
8667 bfd_putl32 (0, eiaf
->shlextra
);
8668 bfd_putl32 (0, eiaf
->permctx
);
8669 bfd_putl32 (0, eiaf
->base_va
);
8670 bfd_putl32 (0, eiaf
->lppsbfixoff
);
8677 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8679 struct alpha_vms_shlib_el
*shlib
;
8680 struct vms_shl
*shl
;
8682 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8684 if (!shlib
->has_fixups
)
8687 /* Renumber shared images. */
8688 PRIV2 (shlib
->abfd
, shr_index
) = shrimg_cnt
++;
8690 shl
= (struct vms_shl
*)(content
+ off
);
8691 bfd_putl32 (0, shl
->baseva
);
8692 bfd_putl32 (0, shl
->shlptr
);
8693 bfd_putl32 (0, shl
->ident
);
8694 bfd_putl32 (0, shl
->permctx
);
8695 shl
->size
= sizeof (struct vms_shl
);
8696 bfd_putl16 (0, shl
->fill_1
);
8698 bfd_putl32 (0, shl
->icb
);
8699 shl
->imgnam
[0] = strlen (PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
));
8700 memcpy (shl
->imgnam
+ 1, PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
),
8703 off
+= sizeof (struct vms_shl
);
8709 bfd_putl32 (off
, eiaf
->codeadroff
);
8711 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8713 struct alpha_vms_shlib_el
*shlib
;
8716 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8718 if (VEC_COUNT (shlib
->ca
) == 0)
8721 bfd_putl32 (VEC_COUNT (shlib
->ca
), content
+ off
);
8722 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8725 for (j
= 0; j
< VEC_COUNT (shlib
->ca
); j
++)
8727 bfd_putl32 (VEC_EL (shlib
->ca
, bfd_vma
, j
) - t
->base_addr
,
8733 bfd_putl32 (0, content
+ off
);
8734 bfd_putl32 (0, content
+ off
+ 4);
8741 bfd_putl32 (off
, eiaf
->lpfixoff
);
8743 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8745 struct alpha_vms_shlib_el
*shlib
;
8748 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8750 if (VEC_COUNT (shlib
->lp
) == 0)
8753 bfd_putl32 (VEC_COUNT (shlib
->lp
), content
+ off
);
8754 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8757 for (j
= 0; j
< VEC_COUNT (shlib
->lp
); j
++)
8759 bfd_putl32 (VEC_EL (shlib
->lp
, bfd_vma
, j
) - t
->base_addr
,
8765 bfd_putl32 (0, content
+ off
);
8766 bfd_putl32 (0, content
+ off
+ 4);
8773 bfd_putl32 (off
, eiaf
->qdotadroff
);
8775 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8777 struct alpha_vms_shlib_el
*shlib
;
8780 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8782 if (VEC_COUNT (shlib
->qr
) == 0)
8785 bfd_putl32 (VEC_COUNT (shlib
->qr
), content
+ off
);
8786 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8789 for (j
= 0; j
< VEC_COUNT (shlib
->qr
); j
++)
8791 struct alpha_vms_vma_ref
*r
;
8792 r
= &VEC_EL (shlib
->qr
, struct alpha_vms_vma_ref
, j
);
8793 bfd_putl32 (r
->vma
- t
->base_addr
, content
+ off
);
8794 bfd_putl32 (r
->ref
, content
+ off
+ 4);
8799 bfd_putl32 (0, content
+ off
);
8800 bfd_putl32 (0, content
+ off
+ 4);
8805 /* Write the change protection table. */
8806 bfd_putl32 (off
, eiaf
->chgprtoff
);
8807 bfd_putl32 (chgprt_num
, content
+ off
);
8810 for (sec
= info
->output_bfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
8812 struct vms_eicp
*eicp
;
8815 if ((sec
->flags
& SEC_LINKER_CREATED
) != 0 &&
8816 strcmp (sec
->name
, "$FIXUP$") == 0)
8818 else if ((sec
->flags
& SEC_RELOC
) != 0
8819 && (sec
->flags
& (SEC_CODE
| SEC_READONLY
)) != 0)
8824 eicp
= (struct vms_eicp
*)(content
+ off
);
8825 bfd_putl64 (sec
->vma
- t
->base_addr
, eicp
->baseva
);
8826 bfd_putl32 ((sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1),
8828 bfd_putl32 (prot
, eicp
->newprt
);
8829 off
+= sizeof (struct vms_eicp
);
8835 /* Called by bfd_hash_traverse to fill the symbol table.
8836 Return FALSE in case of failure. */
8839 alpha_vms_link_output_symbol (struct bfd_hash_entry
*bh
, void *infov
)
8841 struct bfd_link_hash_entry
*hc
= (struct bfd_link_hash_entry
*) bh
;
8842 struct bfd_link_info
*info
= (struct bfd_link_info
*)infov
;
8843 struct alpha_vms_link_hash_entry
*h
;
8844 struct vms_symbol_entry
*sym
;
8846 if (hc
->type
== bfd_link_hash_warning
)
8849 if (hc
->type
== bfd_link_hash_new
)
8852 h
= (struct alpha_vms_link_hash_entry
*) hc
;
8854 switch (h
->root
.type
)
8856 case bfd_link_hash_undefined
:
8858 case bfd_link_hash_new
:
8859 case bfd_link_hash_warning
:
8861 case bfd_link_hash_undefweak
:
8863 case bfd_link_hash_defined
:
8864 case bfd_link_hash_defweak
:
8866 asection
*sec
= h
->root
.u
.def
.section
;
8868 /* FIXME: this is certainly a symbol from a dynamic library. */
8869 if (bfd_is_abs_section (sec
))
8872 if (sec
->owner
->flags
& DYNAMIC
)
8876 case bfd_link_hash_common
:
8878 case bfd_link_hash_indirect
:
8882 /* Do not write not kept symbols. */
8883 if (info
->strip
== strip_some
8884 && bfd_hash_lookup (info
->keep_hash
, h
->root
.root
.string
,
8885 FALSE
, FALSE
) != NULL
)
8890 /* This symbol doesn't come from a VMS object. So we suppose it is
8892 int len
= strlen (h
->root
.root
.string
);
8894 sym
= (struct vms_symbol_entry
*)bfd_zalloc (info
->output_bfd
,
8895 sizeof (*sym
) + len
);
8899 memcpy (sym
->name
, h
->root
.root
.string
, len
);
8901 sym
->owner
= info
->output_bfd
;
8903 sym
->typ
= EGSD__C_SYMG
;
8905 sym
->flags
= EGSY__V_DEF
| EGSY__V_REL
;
8906 sym
->symbol_vector
= h
->root
.u
.def
.value
;
8907 sym
->section
= h
->root
.u
.def
.section
;
8908 sym
->value
= h
->root
.u
.def
.value
;
8913 if (!add_symbol_entry (info
->output_bfd
, sym
))
8920 alpha_vms_bfd_final_link (bfd
*abfd
, struct bfd_link_info
*info
)
8923 struct bfd_link_order
*p
;
8931 if (bfd_link_relocatable (info
))
8933 /* FIXME: we do not yet support relocatable link. It is not obvious
8934 how to do it for debug infos. */
8935 (*info
->callbacks
->einfo
)(_("%P: relocatable link is not supported\n"));
8939 abfd
->outsymbols
= NULL
;
8942 /* Mark all sections which will be included in the output file. */
8943 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8944 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
8945 if (p
->type
== bfd_indirect_link_order
)
8946 p
->u
.indirect
.section
->linker_mark
= TRUE
;
8949 /* Handle all the link order information for the sections. */
8950 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8952 printf ("For section %s (at 0x%08x, flags=0x%08x):\n",
8953 o
->name
, (unsigned)o
->vma
, (unsigned)o
->flags
);
8955 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
8957 printf (" at 0x%08x - 0x%08x: ",
8958 (unsigned)p
->offset
, (unsigned)(p
->offset
+ p
->size
- 1));
8961 case bfd_section_reloc_link_order
:
8962 case bfd_symbol_reloc_link_order
:
8963 printf (" section/symbol reloc\n");
8965 case bfd_indirect_link_order
:
8966 printf (" section %s of %s\n",
8967 p
->u
.indirect
.section
->name
,
8968 p
->u
.indirect
.section
->owner
->filename
);
8970 case bfd_data_link_order
:
8971 printf (" explicit data\n");
8974 printf (" *unknown* type %u\n", p
->type
);
8981 /* Generate the symbol table. */
8982 BFD_ASSERT (PRIV (syms
) == NULL
);
8983 if (info
->strip
!= strip_all
)
8984 bfd_hash_traverse (&info
->hash
->table
, alpha_vms_link_output_symbol
, info
);
8986 /* Find the entry point. */
8987 if (bfd_get_start_address (abfd
) == 0)
8989 bfd
*startbfd
= NULL
;
8991 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
8993 /* Consider only VMS object files. */
8994 if (sub
->xvec
!= abfd
->xvec
)
8997 if (!PRIV2 (sub
, eom_data
).eom_has_transfer
)
8999 if ((PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
) && startbfd
)
9001 if (startbfd
!= NULL
9002 && !(PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
))
9004 (*info
->callbacks
->einfo
)
9005 /* xgettext:c-format */
9006 (_("%P: multiple entry points: in modules %pB and %pB\n"),
9015 unsigned int ps_idx
= PRIV2 (startbfd
, eom_data
).eom_l_psindx
;
9016 bfd_vma tfradr
= PRIV2 (startbfd
, eom_data
).eom_l_tfradr
;
9019 sec
= PRIV2 (startbfd
, sections
)[ps_idx
];
9021 bfd_set_start_address
9022 (abfd
, sec
->output_section
->vma
+ sec
->output_offset
+ tfradr
);
9026 /* Set transfer addresses. */
9029 struct bfd_link_hash_entry
*h
;
9032 PRIV (transfer_address
[i
++]) = 0xffffffff00000340ULL
; /* SYS$IMGACT */
9033 h
= bfd_link_hash_lookup (info
->hash
, "LIB$INITIALIZE", FALSE
, FALSE
, TRUE
);
9034 if (h
!= NULL
&& h
->type
== bfd_link_hash_defined
)
9035 PRIV (transfer_address
[i
++]) =
9036 alpha_vms_get_sym_value (h
->u
.def
.section
, h
->u
.def
.value
);
9037 PRIV (transfer_address
[i
++]) = bfd_get_start_address (abfd
);
9039 PRIV (transfer_address
[i
++]) = 0;
9042 /* Allocate contents.
9043 Also compute the virtual base address. */
9044 base_addr
= (bfd_vma
)-1;
9046 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9048 if (o
->flags
& SEC_HAS_CONTENTS
)
9050 o
->contents
= bfd_alloc (abfd
, o
->size
);
9051 if (o
->contents
== NULL
)
9054 if (o
->flags
& SEC_LOAD
)
9056 if (o
->vma
< base_addr
)
9058 if (o
->vma
+ o
->size
> last_addr
)
9059 last_addr
= o
->vma
+ o
->size
;
9061 /* Clear the RELOC flags. Currently we don't support incremental
9062 linking. We use the RELOC flag for computing the eicp entries. */
9063 o
->flags
&= ~SEC_RELOC
;
9066 /* Create the fixup section. */
9067 fixupsec
= bfd_make_section_anyway_with_flags
9068 (info
->output_bfd
, "$FIXUP$",
9069 SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
9070 if (fixupsec
== NULL
)
9072 last_addr
= (last_addr
+ 0xffff) & ~0xffff;
9073 fixupsec
->vma
= last_addr
;
9075 alpha_vms_link_hash (info
)->fixup
= fixupsec
;
9076 alpha_vms_link_hash (info
)->base_addr
= base_addr
;
9078 /* Create the DMT section, if necessary. */
9079 BFD_ASSERT (PRIV (dst_section
) == NULL
);
9080 dst
= bfd_get_section_by_name (abfd
, "$DST$");
9081 if (dst
!= NULL
&& dst
->size
== 0)
9085 PRIV (dst_section
) = dst
;
9086 dmt
= bfd_make_section_anyway_with_flags
9087 (info
->output_bfd
, "$DMT$",
9088 SEC_DEBUGGING
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
9095 /* Read all sections from the inputs. */
9096 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9098 if (sub
->flags
& DYNAMIC
)
9100 alpha_vms_create_eisd_for_shared (abfd
, sub
);
9104 if (!alpha_vms_read_sections_content (sub
, info
))
9108 /* Handle all the link order information for the sections.
9109 Note: past this point, it is not possible to create new sections. */
9110 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9112 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
9116 case bfd_section_reloc_link_order
:
9117 case bfd_symbol_reloc_link_order
:
9120 case bfd_indirect_link_order
:
9124 if (! _bfd_default_link_order (abfd
, info
, o
, p
))
9131 /* Compute fixups. */
9132 if (!alpha_vms_build_fixups (info
))
9135 /* Compute the DMT. */
9139 unsigned char *contents
= NULL
;
9141 /* In pass 1, compute the size. In pass 2, write the DMT contents. */
9142 for (pass
= 0; pass
< 2; pass
++)
9144 unsigned int off
= 0;
9146 /* For each object file (ie for each module). */
9147 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9150 struct vms_dmt_header
*dmth
= NULL
;
9151 unsigned int psect_count
;
9153 /* Skip this module if it has no DST. */
9154 sub_dst
= PRIV2 (sub
, dst_section
);
9155 if (sub_dst
== NULL
|| sub_dst
->size
== 0)
9160 /* Write the header. */
9161 dmth
= (struct vms_dmt_header
*)(contents
+ off
);
9162 bfd_putl32 (sub_dst
->output_offset
, dmth
->modbeg
);
9163 bfd_putl32 (sub_dst
->size
, dmth
->size
);
9166 off
+= sizeof (struct vms_dmt_header
);
9169 /* For each section (ie for each psect). */
9170 for (o
= sub
->sections
; o
!= NULL
; o
= o
->next
)
9172 /* Only consider interesting sections. */
9173 if (!(o
->flags
& SEC_ALLOC
))
9175 if (o
->flags
& SEC_LINKER_CREATED
)
9180 /* Write an entry. */
9181 struct vms_dmt_psect
*dmtp
;
9183 dmtp
= (struct vms_dmt_psect
*)(contents
+ off
);
9184 bfd_putl32 (o
->output_offset
+ o
->output_section
->vma
,
9186 bfd_putl32 (o
->size
, dmtp
->length
);
9189 off
+= sizeof (struct vms_dmt_psect
);
9192 bfd_putl32 (psect_count
, dmth
->psect_count
);
9197 contents
= bfd_zalloc (info
->output_bfd
, off
);
9198 if (contents
== NULL
)
9200 dmt
->contents
= contents
;
9205 BFD_ASSERT (off
== dmt
->size
);
9213 /* Read the contents of a section.
9214 buf points to a buffer of buf_size bytes to be filled with
9215 section data (starting at offset into section) */
9218 alpha_vms_get_section_contents (bfd
*abfd
, asection
*section
,
9219 void *buf
, file_ptr offset
,
9220 bfd_size_type count
)
9224 /* Image are easy. */
9225 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
9226 return _bfd_generic_get_section_contents (abfd
, section
,
9227 buf
, offset
, count
);
9230 if (offset
+ count
< count
9231 || offset
+ count
> section
->size
)
9233 bfd_set_error (bfd_error_invalid_operation
);
9237 /* If the section is already in memory, just copy it. */
9238 if (section
->flags
& SEC_IN_MEMORY
)
9240 BFD_ASSERT (section
->contents
!= NULL
);
9241 memcpy (buf
, section
->contents
+ offset
, count
);
9244 if (section
->size
== 0)
9247 /* Alloc in memory and read ETIRs. */
9248 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
9250 BFD_ASSERT (sec
->contents
== NULL
);
9252 if (sec
->size
!= 0 && (sec
->flags
& SEC_HAS_CONTENTS
))
9254 sec
->contents
= bfd_alloc (abfd
, sec
->size
);
9255 if (sec
->contents
== NULL
)
9259 if (!alpha_vms_read_sections_content (abfd
, NULL
))
9261 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
9263 sec
->flags
|= SEC_IN_MEMORY
;
9264 memcpy (buf
, section
->contents
+ offset
, count
);
9269 /* Set the format of a file being written. */
9272 alpha_vms_mkobject (bfd
* abfd
)
9274 const bfd_arch_info_type
*arch
;
9276 vms_debug2 ((1, "alpha_vms_mkobject (%p)\n", abfd
));
9278 if (!vms_initialize (abfd
))
9281 PRIV (recwr
.buf
) = bfd_alloc (abfd
, MAX_OUTREC_SIZE
);
9282 if (PRIV (recwr
.buf
) == NULL
)
9285 arch
= bfd_scan_arch ("alpha");
9289 bfd_set_error (bfd_error_wrong_format
);
9293 abfd
->arch_info
= arch
;
9300 /* Called when the BFD is being closed to do any necessary cleanup. */
9303 vms_close_and_cleanup (bfd
* abfd
)
9305 vms_debug2 ((1, "vms_close_and_cleanup (%p)\n", abfd
));
9307 if (abfd
== NULL
|| abfd
->tdata
.any
== NULL
)
9310 if (abfd
->format
== bfd_archive
)
9312 bfd_release (abfd
, abfd
->tdata
.any
);
9313 abfd
->tdata
.any
= NULL
;
9317 if (PRIV (recrd
.buf
) != NULL
)
9318 free (PRIV (recrd
.buf
));
9320 if (PRIV (sections
) != NULL
)
9321 free (PRIV (sections
));
9323 bfd_release (abfd
, abfd
->tdata
.any
);
9324 abfd
->tdata
.any
= NULL
;
9327 if (abfd
->direction
== write_direction
)
9329 /* Last step on VMS is to convert the file to variable record length
9331 if (!bfd_cache_close (abfd
))
9333 if (!_bfd_vms_convert_to_var_unix_filename (abfd
->filename
))
9341 /* Called when a new section is created. */
9344 vms_new_section_hook (bfd
* abfd
, asection
*section
)
9348 vms_debug2 ((1, "vms_new_section_hook (%p, [%u]%s)\n",
9349 abfd
, section
->index
, section
->name
));
9351 if (!bfd_set_section_alignment (section
, 0))
9354 vms_debug2 ((7, "%u: %s\n", section
->index
, section
->name
));
9356 amt
= sizeof (struct vms_section_data_struct
);
9357 section
->used_by_bfd
= bfd_zalloc (abfd
, amt
);
9358 if (section
->used_by_bfd
== NULL
)
9361 /* Create the section symbol. */
9362 return _bfd_generic_new_section_hook (abfd
, section
);
9365 /* Part 4.5, symbols. */
9367 /* Print symbol to file according to how. how is one of
9368 bfd_print_symbol_name just print the name
9369 bfd_print_symbol_more print more (???)
9370 bfd_print_symbol_all print all we know, which is not much right now :-). */
9373 vms_print_symbol (bfd
* abfd
,
9376 bfd_print_symbol_type how
)
9378 vms_debug2 ((1, "vms_print_symbol (%p, %p, %p, %d)\n",
9379 abfd
, file
, symbol
, how
));
9383 case bfd_print_symbol_name
:
9384 case bfd_print_symbol_more
:
9385 fprintf ((FILE *)file
," %s", symbol
->name
);
9388 case bfd_print_symbol_all
:
9390 const char *section_name
= symbol
->section
->name
;
9392 bfd_print_symbol_vandf (abfd
, file
, symbol
);
9394 fprintf ((FILE *) file
," %-8s %s", section_name
, symbol
->name
);
9400 /* Return information about symbol in ret.
9402 fill type, value and name
9405 B bss segment symbol
9407 D data segment symbol
9409 t a static function symbol
9410 T text segment symbol
9415 vms_get_symbol_info (bfd
* abfd ATTRIBUTE_UNUSED
,
9421 vms_debug2 ((1, "vms_get_symbol_info (%p, %p, %p)\n", abfd
, symbol
, ret
));
9423 sec
= symbol
->section
;
9430 else if (bfd_is_com_section (sec
))
9432 else if (bfd_is_abs_section (sec
))
9434 else if (bfd_is_und_section (sec
))
9436 else if (bfd_is_ind_section (sec
))
9438 else if ((symbol
->flags
& BSF_FUNCTION
)
9439 || (bfd_section_flags (sec
) & SEC_CODE
))
9441 else if (bfd_section_flags (sec
) & SEC_DATA
)
9443 else if (bfd_section_flags (sec
) & SEC_ALLOC
)
9448 if (ret
->type
!= 'U')
9449 ret
->value
= symbol
->value
+ symbol
->section
->vma
;
9452 ret
->name
= symbol
->name
;
9455 /* Return TRUE if the given symbol sym in the BFD abfd is
9456 a compiler generated local label, else return FALSE. */
9459 vms_bfd_is_local_label_name (bfd
* abfd ATTRIBUTE_UNUSED
,
9462 return name
[0] == '$';
9465 /* Part 4.7, writing an object file. */
9467 /* Sets the contents of the section section in BFD abfd to the data starting
9468 in memory at LOCATION. The data is written to the output section starting
9469 at offset offset for count bytes.
9471 Normally TRUE is returned, else FALSE. Possible error returns are:
9472 o bfd_error_no_contents - The output section does not have the
9473 SEC_HAS_CONTENTS attribute, so nothing can be written to it.
9474 o and some more too */
9477 _bfd_vms_set_section_contents (bfd
* abfd
,
9479 const void * location
,
9481 bfd_size_type count
)
9483 if (section
->contents
== NULL
)
9485 section
->contents
= bfd_alloc (abfd
, section
->size
);
9486 if (section
->contents
== NULL
)
9489 memcpy (section
->contents
+ offset
, location
, (size_t) count
);
9495 /* Set the architecture and machine type in BFD abfd to arch and mach.
9496 Find the correct pointer to a structure and insert it into the arch_info
9500 alpha_vms_set_arch_mach (bfd
*abfd
,
9501 enum bfd_architecture arch
, unsigned long mach
)
9503 if (arch
!= bfd_arch_alpha
9504 && arch
!= bfd_arch_unknown
)
9507 return bfd_default_set_arch_mach (abfd
, arch
, mach
);
9510 /* Set section VMS flags. Clear NO_FLAGS and set FLAGS. */
9513 bfd_vms_set_section_flags (bfd
*abfd ATTRIBUTE_UNUSED
,
9514 asection
*sec
, flagword no_flags
, flagword flags
)
9516 vms_section_data (sec
)->no_flags
= no_flags
;
9517 vms_section_data (sec
)->flags
= flags
;
9520 struct vms_private_data_struct
*
9521 bfd_vms_get_data (bfd
*abfd
)
9523 return (struct vms_private_data_struct
*)abfd
->tdata
.any
;
9526 #define vms_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false
9527 #define vms_bfd_link_just_syms _bfd_generic_link_just_syms
9528 #define vms_bfd_copy_link_hash_symbol_type \
9529 _bfd_generic_copy_link_hash_symbol_type
9530 #define vms_bfd_is_group_section bfd_generic_is_group_section
9531 #define vms_bfd_group_name bfd_generic_group_name
9532 #define vms_bfd_discard_group bfd_generic_discard_group
9533 #define vms_section_already_linked _bfd_generic_section_already_linked
9534 #define vms_bfd_define_common_symbol bfd_generic_define_common_symbol
9535 #define vms_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
9536 #define vms_bfd_define_start_stop bfd_generic_define_start_stop
9537 #define vms_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
9539 #define vms_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
9540 #define vms_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
9541 #define vms_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data
9542 #define vms_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
9543 #define vms_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
9544 #define vms_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
9546 /* Symbols table. */
9547 #define alpha_vms_make_empty_symbol _bfd_generic_make_empty_symbol
9548 #define alpha_vms_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false
9549 #define alpha_vms_print_symbol vms_print_symbol
9550 #define alpha_vms_get_symbol_info vms_get_symbol_info
9551 #define alpha_vms_get_symbol_version_string \
9552 _bfd_nosymbols_get_symbol_version_string
9554 #define alpha_vms_read_minisymbols _bfd_generic_read_minisymbols
9555 #define alpha_vms_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
9556 #define alpha_vms_get_lineno _bfd_nosymbols_get_lineno
9557 #define alpha_vms_find_inliner_info _bfd_nosymbols_find_inliner_info
9558 #define alpha_vms_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
9559 #define alpha_vms_find_nearest_line _bfd_vms_find_nearest_line
9560 #define alpha_vms_find_line _bfd_nosymbols_find_line
9561 #define alpha_vms_bfd_is_local_label_name vms_bfd_is_local_label_name
9563 /* Generic table. */
9564 #define alpha_vms_close_and_cleanup vms_close_and_cleanup
9565 #define alpha_vms_bfd_free_cached_info vms_bfd_free_cached_info
9566 #define alpha_vms_new_section_hook vms_new_section_hook
9567 #define alpha_vms_set_section_contents _bfd_vms_set_section_contents
9568 #define alpha_vms_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
9570 #define alpha_vms_bfd_get_relocated_section_contents \
9571 bfd_generic_get_relocated_section_contents
9573 #define alpha_vms_bfd_relax_section bfd_generic_relax_section
9574 #define alpha_vms_bfd_gc_sections bfd_generic_gc_sections
9575 #define alpha_vms_bfd_lookup_section_flags bfd_generic_lookup_section_flags
9576 #define alpha_vms_bfd_merge_sections bfd_generic_merge_sections
9577 #define alpha_vms_bfd_is_group_section bfd_generic_is_group_section
9578 #define alpha_vms_bfd_group_name bfd_generic_group_name
9579 #define alpha_vms_bfd_discard_group bfd_generic_discard_group
9580 #define alpha_vms_section_already_linked \
9581 _bfd_generic_section_already_linked
9583 #define alpha_vms_bfd_define_common_symbol bfd_generic_define_common_symbol
9584 #define alpha_vms_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
9585 #define alpha_vms_bfd_define_start_stop bfd_generic_define_start_stop
9586 #define alpha_vms_bfd_link_just_syms _bfd_generic_link_just_syms
9587 #define alpha_vms_bfd_copy_link_hash_symbol_type \
9588 _bfd_generic_copy_link_hash_symbol_type
9590 #define alpha_vms_bfd_link_split_section _bfd_generic_link_split_section
9592 #define alpha_vms_get_dynamic_symtab_upper_bound \
9593 _bfd_nodynamic_get_dynamic_symtab_upper_bound
9594 #define alpha_vms_canonicalize_dynamic_symtab \
9595 _bfd_nodynamic_canonicalize_dynamic_symtab
9596 #define alpha_vms_get_dynamic_reloc_upper_bound \
9597 _bfd_nodynamic_get_dynamic_reloc_upper_bound
9598 #define alpha_vms_canonicalize_dynamic_reloc \
9599 _bfd_nodynamic_canonicalize_dynamic_reloc
9600 #define alpha_vms_bfd_link_check_relocs _bfd_generic_link_check_relocs
9602 const bfd_target alpha_vms_vec
=
9604 "vms-alpha", /* Name. */
9605 bfd_target_evax_flavour
,
9606 BFD_ENDIAN_LITTLE
, /* Data byte order is little. */
9607 BFD_ENDIAN_LITTLE
, /* Header byte order is little. */
9609 (HAS_RELOC
| EXEC_P
| HAS_LINENO
| HAS_DEBUG
| HAS_SYMS
| HAS_LOCALS
9610 | WP_TEXT
| D_PAGED
), /* Object flags. */
9611 (SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
9612 | SEC_READONLY
| SEC_CODE
| SEC_DATA
9613 | SEC_HAS_CONTENTS
| SEC_IN_MEMORY
), /* Sect flags. */
9614 0, /* symbol_leading_char. */
9615 ' ', /* ar_pad_char. */
9616 15, /* ar_max_namelen. */
9617 0, /* match priority. */
9618 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
9619 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
9620 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
9621 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
9622 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
9623 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
9625 { /* bfd_check_format. */
9628 _bfd_vms_lib_alpha_archive_p
,
9631 { /* bfd_set_format. */
9632 _bfd_bool_bfd_false_error
,
9634 _bfd_vms_lib_alpha_mkarchive
,
9635 _bfd_bool_bfd_false_error
9637 { /* bfd_write_contents. */
9638 _bfd_bool_bfd_false_error
,
9639 alpha_vms_write_object_contents
,
9640 _bfd_vms_lib_write_archive_contents
,
9641 _bfd_bool_bfd_false_error
9644 BFD_JUMP_TABLE_GENERIC (alpha_vms
),
9645 BFD_JUMP_TABLE_COPY (vms
),
9646 BFD_JUMP_TABLE_CORE (_bfd_nocore
),
9647 BFD_JUMP_TABLE_ARCHIVE (_bfd_vms_lib
),
9648 BFD_JUMP_TABLE_SYMBOLS (alpha_vms
),
9649 BFD_JUMP_TABLE_RELOCS (alpha_vms
),
9650 BFD_JUMP_TABLE_WRITE (alpha_vms
),
9651 BFD_JUMP_TABLE_LINK (alpha_vms
),
9652 BFD_JUMP_TABLE_DYNAMIC (alpha_vms
),