1 /* vms.c -- BFD back-end for EVAX (openVMS/Alpha) files.
2 Copyright (C) 1996-2020 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 bfd_boolean
alpha_vms_add_fixup_lp (struct bfd_link_info
*,
373 static bfd_boolean
alpha_vms_add_fixup_ca (struct bfd_link_info
*,
375 static bfd_boolean
alpha_vms_add_fixup_qr (struct bfd_link_info
*,
376 bfd
*, bfd
*, bfd_vma
);
377 static bfd_boolean
alpha_vms_add_fixup_lr (struct bfd_link_info
*,
378 unsigned int, bfd_vma
);
379 static bfd_boolean
alpha_vms_add_lw_reloc (struct bfd_link_info
*);
380 static bfd_boolean
alpha_vms_add_qw_reloc (struct bfd_link_info
*);
389 /* Number of elements in VEC. */
391 #define VEC_COUNT(VEC) ((VEC).nbr_el)
393 /* Get the address of the Nth element. */
395 #define VEC_EL(VEC, TYPE, N) (((TYPE *)((VEC).els))[N])
397 #define VEC_INIT(VEC) \
404 /* Be sure there is room for a new element. */
406 static void *vector_grow1 (struct vector_type
*vec
, size_t elsz
);
408 /* Allocate room for a new element and return its address. */
410 #define VEC_APPEND(VEC, TYPE) \
411 ((TYPE *) vector_grow1 (&VEC, sizeof (TYPE)))
413 struct alpha_vms_vma_ref
415 bfd_vma vma
; /* Vma in the output. */
416 bfd_vma ref
; /* Reference in the input. */
419 struct alpha_vms_shlib_el
422 bfd_boolean has_fixups
;
424 struct vector_type lp
; /* Vector of bfd_vma. */
425 struct vector_type ca
; /* Vector of bfd_vma. */
426 struct vector_type qr
; /* Vector of struct alpha_vms_vma_ref. */
429 /* Alpha VMS linker hash table. */
431 struct alpha_vms_link_hash_table
433 struct bfd_link_hash_table root
;
435 /* Vector of shared libraries. */
436 struct vector_type shrlibs
;
441 /* Base address. Used by fixups. */
445 #define alpha_vms_link_hash(INFO) \
446 ((struct alpha_vms_link_hash_table *)(INFO->hash))
448 /* Alpha VMS linker hash table entry. */
450 struct alpha_vms_link_hash_entry
452 struct bfd_link_hash_entry root
;
454 /* Pointer to the original vms symbol. */
455 struct vms_symbol_entry
*sym
;
460 /* Read & process EIHD record.
461 Return TRUE on success, FALSE on error. */
464 _bfd_vms_slurp_eihd (bfd
*abfd
, unsigned int *eisd_offset
,
465 unsigned int *eihs_offset
)
467 unsigned int imgtype
, size
;
469 struct vms_eihd
*eihd
= (struct vms_eihd
*)PRIV (recrd
.rec
);
471 vms_debug2 ((8, "_bfd_vms_slurp_eihd\n"));
473 /* PR 21813: Check for an undersized record. */
474 if (PRIV (recrd
.buf_size
) < sizeof (* eihd
))
476 _bfd_error_handler (_("corrupt EIHD record - size is too small"));
477 bfd_set_error (bfd_error_bad_value
);
481 size
= bfd_getl32 (eihd
->size
);
482 imgtype
= bfd_getl32 (eihd
->imgtype
);
484 if (imgtype
== EIHD__K_EXE
|| imgtype
== EIHD__K_LIM
)
485 abfd
->flags
|= EXEC_P
;
487 symvva
= bfd_getl64 (eihd
->symvva
);
490 PRIV (symvva
) = symvva
;
491 abfd
->flags
|= DYNAMIC
;
494 PRIV (ident
) = bfd_getl32 (eihd
->ident
);
495 PRIV (matchctl
) = eihd
->matchctl
;
497 *eisd_offset
= bfd_getl32 (eihd
->isdoff
);
498 *eihs_offset
= bfd_getl32 (eihd
->symdbgoff
);
500 vms_debug2 ((4, "EIHD size %d imgtype %d symvva 0x%lx eisd %d eihs %d\n",
501 size
, imgtype
, (unsigned long)symvva
,
502 *eisd_offset
, *eihs_offset
));
508 /* Read & process EISD record.
509 Return TRUE on success, FALSE on error. */
512 _bfd_vms_slurp_eisd (bfd
*abfd
, unsigned int offset
)
514 int section_count
= 0;
516 vms_debug2 ((8, "_bfd_vms_slurp_eisd\n"));
520 struct vms_eisd
*eisd
;
521 unsigned int rec_size
;
530 /* PR 17512: file: 3d9e9fe9. */
531 if (offset
> PRIV (recrd
.rec_size
)
532 || (PRIV (recrd
.rec_size
) - offset
533 < offsetof (struct vms_eisd
, eisdsize
) + 4))
535 eisd
= (struct vms_eisd
*) (PRIV (recrd
.rec
) + offset
);
536 rec_size
= bfd_getl32 (eisd
->eisdsize
);
540 /* Skip to next block if pad. */
541 if (rec_size
== 0xffffffff)
543 offset
= (offset
+ VMS_BLOCK_SIZE
) & ~(VMS_BLOCK_SIZE
- 1);
547 /* Make sure that there is enough data present in the record. */
548 if (rec_size
< offsetof (struct vms_eisd
, type
) + 1)
550 /* Make sure that the record is not too big either. */
551 if (rec_size
> PRIV (recrd
.rec_size
) - offset
)
556 size
= bfd_getl32 (eisd
->secsize
);
557 vaddr
= bfd_getl64 (eisd
->virt_addr
);
558 flags
= bfd_getl32 (eisd
->flags
);
559 vbn
= bfd_getl32 (eisd
->vbn
);
561 vms_debug2 ((4, "EISD at 0x%x size 0x%x addr 0x%lx flags 0x%x blk %d\n",
562 offset
, size
, (unsigned long)vaddr
, flags
, vbn
));
564 /* VMS combines psects from .obj files into isects in the .exe. This
565 process doesn't preserve enough information to reliably determine
566 what's in each section without examining the data. This is
567 especially true of DWARF debug sections. */
568 bfd_flags
= SEC_ALLOC
;
570 bfd_flags
|= SEC_HAS_CONTENTS
| SEC_LOAD
;
572 if (flags
& EISD__M_EXE
)
573 bfd_flags
|= SEC_CODE
;
575 if (flags
& EISD__M_NONSHRADR
)
576 bfd_flags
|= SEC_DATA
;
578 if (!(flags
& EISD__M_WRT
))
579 bfd_flags
|= SEC_READONLY
;
581 if (flags
& EISD__M_DZRO
)
582 bfd_flags
|= SEC_DATA
;
584 if (flags
& EISD__M_FIXUPVEC
)
585 bfd_flags
|= SEC_DATA
;
587 if (flags
& EISD__M_CRF
)
588 bfd_flags
|= SEC_DATA
;
590 if (flags
& EISD__M_GBL
)
592 if (rec_size
<= offsetof (struct vms_eisd
, gblnam
))
594 else if (rec_size
< sizeof (struct vms_eisd
))
595 name
= _bfd_vms_save_counted_string (abfd
, eisd
->gblnam
,
596 rec_size
- offsetof (struct vms_eisd
, gblnam
));
598 name
= _bfd_vms_save_counted_string (abfd
, eisd
->gblnam
,
600 if (name
== NULL
|| name
[0] == 0)
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);
616 if (flags
& EISD__M_DZRO
)
618 else if (flags
& EISD__M_EXE
)
620 else if (!(flags
& EISD__M_WRT
))
624 BFD_ASSERT (section_count
< 999);
625 sprintf (name
, "$%s_%03d$", pfx
, section_count
++);
628 section
= bfd_make_section (abfd
, name
);
633 section
->filepos
= vbn
? VMS_BLOCK_SIZE
* (vbn
- 1) : 0;
634 section
->size
= size
;
635 section
->vma
= vaddr
;
637 if (!bfd_set_section_flags (section
, bfd_flags
))
644 /* Read & process EIHS record.
645 Return TRUE on success, FALSE on error. */
648 _bfd_vms_slurp_eihs (bfd
*abfd
, unsigned int offset
)
650 unsigned char *p
= PRIV (recrd
.rec
) + offset
;
652 unsigned int gstsize ATTRIBUTE_UNUSED
;
654 unsigned int dstsize
;
656 unsigned int dmtbytes
;
659 /* PR 21611: Check that offset is valid. */
660 if (offset
> PRIV (recrd
.rec_size
) - (EIHS__L_DMTBYTES
+ 4))
662 _bfd_error_handler (_("unable to read EIHS record at offset %#x"),
664 bfd_set_error (bfd_error_file_truncated
);
668 gstvbn
= bfd_getl32 (p
+ EIHS__L_GSTVBN
);
669 gstsize
= bfd_getl32 (p
+ EIHS__L_GSTSIZE
);
670 dstvbn
= bfd_getl32 (p
+ EIHS__L_DSTVBN
);
671 dstsize
= bfd_getl32 (p
+ EIHS__L_DSTSIZE
);
672 dmtvbn
= bfd_getl32 (p
+ EIHS__L_DMTVBN
);
673 dmtbytes
= bfd_getl32 (p
+ EIHS__L_DMTBYTES
);
676 vms_debug (8, "_bfd_vms_slurp_ihs\n");
677 vms_debug (4, "EIHS record gstvbn %d gstsize %d dstvbn %d dstsize %d dmtvbn %d dmtbytes %d\n",
678 gstvbn
, gstsize
, dstvbn
, dstsize
, dmtvbn
, dmtbytes
);
683 flagword bfd_flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
;
685 section
= bfd_make_section (abfd
, "$DST$");
689 section
->size
= dstsize
;
690 section
->filepos
= VMS_BLOCK_SIZE
* (dstvbn
- 1);
692 if (!bfd_set_section_flags (section
, bfd_flags
))
695 PRIV (dst_section
) = section
;
696 abfd
->flags
|= (HAS_DEBUG
| HAS_LINENO
);
701 flagword bfd_flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
;
703 section
= bfd_make_section (abfd
, "$DMT$");
707 section
->size
= dmtbytes
;
708 section
->filepos
= VMS_BLOCK_SIZE
* (dmtvbn
- 1);
710 if (!bfd_set_section_flags (section
, bfd_flags
))
716 if (bfd_seek (abfd
, VMS_BLOCK_SIZE
* (gstvbn
- 1), SEEK_SET
))
718 bfd_set_error (bfd_error_file_truncated
);
722 if (!_bfd_vms_slurp_object_records (abfd
))
725 abfd
->flags
|= HAS_SYMS
;
731 /* Object file reading. */
733 /* Object file input functions. */
735 /* Get next record from object file to vms_buf.
736 Set PRIV(buf_size) and return it
738 This is a little tricky since it should be portable.
740 The openVMS object file has 'variable length' which means that
741 read() returns data in chunks of (hopefully) correct and expected
742 size. The linker (and other tools on VMS) depend on that. Unix
743 doesn't know about 'formatted' files, so reading and writing such
744 an object file in a Unix environment is not trivial.
746 With the tool 'file' (available on all VMS FTP sites), one
747 can view and change the attributes of a file. Changing from
748 'variable length' to 'fixed length, 512 bytes' reveals the
749 record size at the first 2 bytes of every record. The same
750 may happen during the transfer of object files from VMS to Unix,
751 at least with UCX, the DEC implementation of TCP/IP.
753 The VMS format repeats the size at bytes 2 & 3 of every record.
755 On the first call (file_format == FF_UNKNOWN) we check if
756 the first and the third byte pair (!) of the record match.
757 If they do it's an object file in an Unix environment or with
758 wrong attributes (FF_FOREIGN), else we should be in a VMS
759 environment where read() returns the record size (FF_NATIVE).
761 Reading is always done in 2 steps:
762 1. first just the record header is read and the size extracted,
763 2. then the read buffer is adjusted and the remaining bytes are
766 All file I/O is done on even file positions. */
768 #define VMS_OBJECT_ADJUSTMENT 2
771 maybe_adjust_record_pointer_for_object (bfd
*abfd
)
773 /* Set the file format once for all on the first invocation. */
774 if (PRIV (recrd
.file_format
) == FF_UNKNOWN
)
776 if (PRIV (recrd
.rec
)[0] == PRIV (recrd
.rec
)[4]
777 && PRIV (recrd
.rec
)[1] == PRIV (recrd
.rec
)[5])
778 PRIV (recrd
.file_format
) = FF_FOREIGN
;
780 PRIV (recrd
.file_format
) = FF_NATIVE
;
783 /* The adjustment is needed only in an Unix environment. */
784 if (PRIV (recrd
.file_format
) == FF_FOREIGN
)
785 PRIV (recrd
.rec
) += VMS_OBJECT_ADJUSTMENT
;
788 /* Implement step #1 of the object record reading procedure.
789 Return the record type or -1 on failure. */
792 _bfd_vms_get_object_record (bfd
*abfd
)
794 unsigned int test_len
= 6;
797 vms_debug2 ((8, "_bfd_vms_get_obj_record\n"));
799 /* Skip alignment byte if the current position is odd. */
800 if (PRIV (recrd
.file_format
) == FF_FOREIGN
&& (bfd_tell (abfd
) & 1))
802 if (bfd_bread (PRIV (recrd
.buf
), 1, abfd
) != 1)
804 bfd_set_error (bfd_error_file_truncated
);
809 /* Read the record header */
810 if (bfd_bread (PRIV (recrd
.buf
), test_len
, abfd
) != test_len
)
812 bfd_set_error (bfd_error_file_truncated
);
816 /* Reset the record pointer. */
817 PRIV (recrd
.rec
) = PRIV (recrd
.buf
);
818 maybe_adjust_record_pointer_for_object (abfd
);
820 if (vms_get_remaining_object_record (abfd
, test_len
) <= 0)
823 type
= bfd_getl16 (PRIV (recrd
.rec
));
825 vms_debug2 ((8, "_bfd_vms_get_obj_record: rec %p, size %d, type %d\n",
826 PRIV (recrd
.rec
), PRIV (recrd
.rec_size
), type
));
831 /* Implement step #2 of the object record reading procedure.
832 Return the size of the record or 0 on failure. */
835 vms_get_remaining_object_record (bfd
*abfd
, unsigned int read_so_far
)
837 unsigned int to_read
;
839 vms_debug2 ((8, "vms_get_remaining_obj_record\n"));
841 /* Extract record size. */
842 PRIV (recrd
.rec_size
) = bfd_getl16 (PRIV (recrd
.rec
) + 2);
844 if (PRIV (recrd
.rec_size
) == 0)
846 bfd_set_error (bfd_error_file_truncated
);
850 /* That's what the linker manual says. */
851 if (PRIV (recrd
.rec_size
) > EOBJ__C_MAXRECSIZ
)
853 bfd_set_error (bfd_error_file_truncated
);
857 /* Take into account object adjustment. */
858 to_read
= PRIV (recrd
.rec_size
);
859 if (PRIV (recrd
.file_format
) == FF_FOREIGN
)
860 to_read
+= VMS_OBJECT_ADJUSTMENT
;
862 /* Adjust the buffer. */
863 if (to_read
> PRIV (recrd
.buf_size
))
866 = (unsigned char *) bfd_realloc (PRIV (recrd
.buf
), to_read
);
867 if (PRIV (recrd
.buf
) == NULL
)
869 PRIV (recrd
.buf_size
) = to_read
;
871 /* PR 17512: file: 025-1974-0.004. */
872 else if (to_read
<= read_so_far
)
875 /* Read the remaining record. */
876 to_read
-= read_so_far
;
878 vms_debug2 ((8, "vms_get_remaining_obj_record: to_read %d\n", to_read
));
880 if (bfd_bread (PRIV (recrd
.buf
) + read_so_far
, to_read
, abfd
) != to_read
)
882 bfd_set_error (bfd_error_file_truncated
);
886 /* Reset the record pointer. */
887 PRIV (recrd
.rec
) = PRIV (recrd
.buf
);
888 maybe_adjust_record_pointer_for_object (abfd
);
890 vms_debug2 ((8, "vms_get_remaining_obj_record: size %d\n",
891 PRIV (recrd
.rec_size
)));
893 return PRIV (recrd
.rec_size
);
896 /* Read and process emh record.
897 Return TRUE on success, FALSE on error. */
900 _bfd_vms_slurp_ehdr (bfd
*abfd
)
903 unsigned char *vms_rec
;
907 vms_rec
= PRIV (recrd
.rec
);
908 /* PR 17512: file: 62736583. */
909 end
= PRIV (recrd
.buf
) + PRIV (recrd
.buf_size
);
911 vms_debug2 ((2, "HDR/EMH\n"));
913 subtype
= bfd_getl16 (vms_rec
+ 4);
915 vms_debug2 ((3, "subtype %d\n", subtype
));
921 if (vms_rec
+ 21 >= end
)
923 PRIV (hdr_data
).hdr_b_strlvl
= vms_rec
[6];
924 PRIV (hdr_data
).hdr_l_arch1
= bfd_getl32 (vms_rec
+ 8);
925 PRIV (hdr_data
).hdr_l_arch2
= bfd_getl32 (vms_rec
+ 12);
926 PRIV (hdr_data
).hdr_l_recsiz
= bfd_getl32 (vms_rec
+ 16);
927 if ((vms_rec
+ 20 + vms_rec
[20] + 1) >= end
)
929 PRIV (hdr_data
).hdr_t_name
930 = _bfd_vms_save_counted_string (abfd
, vms_rec
+ 20, vms_rec
[20]);
931 ptr
= vms_rec
+ 20 + vms_rec
[20] + 1;
932 if ((ptr
+ *ptr
+ 1) >= end
)
934 PRIV (hdr_data
).hdr_t_version
935 = _bfd_vms_save_counted_string (abfd
, ptr
, *ptr
);
939 PRIV (hdr_data
).hdr_t_date
940 = _bfd_vms_save_sized_string (abfd
, ptr
, 17);
944 if (vms_rec
+ PRIV (recrd
.rec_size
- 6) > end
)
946 PRIV (hdr_data
).hdr_c_lnm
947 = _bfd_vms_save_sized_string (abfd
, vms_rec
, PRIV (recrd
.rec_size
- 6));
951 if (vms_rec
+ PRIV (recrd
.rec_size
- 6) > end
)
953 PRIV (hdr_data
).hdr_c_src
954 = _bfd_vms_save_sized_string (abfd
, vms_rec
, PRIV (recrd
.rec_size
- 6));
958 if (vms_rec
+ PRIV (recrd
.rec_size
- 6) > end
)
960 PRIV (hdr_data
).hdr_c_ttl
961 = _bfd_vms_save_sized_string (abfd
, vms_rec
, PRIV (recrd
.rec_size
- 6));
971 bfd_set_error (bfd_error_wrong_format
);
978 /* Typical sections for evax object files. */
980 #define EVAX_ABS_NAME "$ABS$"
981 #define EVAX_CODE_NAME "$CODE$"
982 #define EVAX_LINK_NAME "$LINK$"
983 #define EVAX_DATA_NAME "$DATA$"
984 #define EVAX_BSS_NAME "$BSS$"
985 #define EVAX_READONLYADDR_NAME "$READONLY_ADDR$"
986 #define EVAX_READONLY_NAME "$READONLY$"
987 #define EVAX_LITERAL_NAME "$LITERAL$"
988 #define EVAX_LITERALS_NAME "$LITERALS"
989 #define EVAX_COMMON_NAME "$COMMON$"
990 #define EVAX_LOCAL_NAME "$LOCAL$"
992 struct sec_flags_struct
994 const char *name
; /* Name of section. */
996 flagword flags_always
; /* Flags we set always. */
998 flagword flags_hassize
; /* Flags we set if the section has a size > 0. */
1001 /* These flags are deccrtl/vaxcrtl (openVMS 6.2 Alpha) compatible. */
1003 static const struct sec_flags_struct evax_section_flags
[] =
1011 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_EXE
,
1012 SEC_CODE
| SEC_READONLY
,
1013 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_EXE
,
1014 SEC_CODE
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1015 { EVAX_LITERAL_NAME
,
1016 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
| EGPS__V_NOMOD
,
1017 SEC_DATA
| SEC_READONLY
,
1018 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
,
1019 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1021 EGPS__V_REL
| EGPS__V_RD
,
1022 SEC_DATA
| SEC_READONLY
,
1023 EGPS__V_REL
| EGPS__V_RD
,
1024 SEC_DATA
| SEC_READONLY
| 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
,
1029 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1031 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
,
1033 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
,
1035 { EVAX_READONLYADDR_NAME
,
1036 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_RD
,
1037 SEC_DATA
| SEC_READONLY
,
1038 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_RD
,
1039 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1040 { EVAX_READONLY_NAME
,
1041 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
| EGPS__V_NOMOD
,
1042 SEC_DATA
| SEC_READONLY
,
1043 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
,
1044 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1046 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1048 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1049 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1050 { EVAX_LITERALS_NAME
,
1051 EGPS__V_PIC
| EGPS__V_OVR
,
1052 SEC_DATA
| SEC_READONLY
,
1053 EGPS__V_PIC
| EGPS__V_OVR
,
1054 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1056 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1058 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1059 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
}
1062 /* Retrieve BFD section flags by name and size. */
1065 vms_secflag_by_name (const struct sec_flags_struct
*section_flags
,
1071 while (section_flags
[i
].name
!= NULL
)
1073 if (strcmp (name
, section_flags
[i
].name
) == 0)
1076 return section_flags
[i
].flags_hassize
;
1078 return section_flags
[i
].flags_always
;
1083 return section_flags
[i
].flags_hassize
;
1084 return section_flags
[i
].flags_always
;
1087 /* Retrieve VMS section flags by name and size. */
1090 vms_esecflag_by_name (const struct sec_flags_struct
*section_flags
,
1096 while (section_flags
[i
].name
!= NULL
)
1098 if (strcmp (name
, section_flags
[i
].name
) == 0)
1101 return section_flags
[i
].vflags_hassize
;
1103 return section_flags
[i
].vflags_always
;
1108 return section_flags
[i
].vflags_hassize
;
1109 return section_flags
[i
].vflags_always
;
1112 /* Add SYM to the symbol table of ABFD.
1113 Return FALSE in case of error. */
1116 add_symbol_entry (bfd
*abfd
, struct vms_symbol_entry
*sym
)
1118 if (PRIV (gsd_sym_count
) >= PRIV (max_sym_count
))
1120 if (PRIV (max_sym_count
) == 0)
1122 PRIV (max_sym_count
) = 128;
1123 PRIV (syms
) = bfd_malloc
1124 (PRIV (max_sym_count
) * sizeof (struct vms_symbol_entry
*));
1128 PRIV (max_sym_count
) *= 2;
1129 PRIV (syms
) = bfd_realloc
1131 (PRIV (max_sym_count
) * sizeof (struct vms_symbol_entry
*)));
1133 if (PRIV (syms
) == NULL
)
1137 PRIV (syms
)[PRIV (gsd_sym_count
)++] = sym
;
1141 /* Create a symbol whose name is ASCIC and add it to ABFD.
1142 Return NULL in case of error. */
1144 static struct vms_symbol_entry
*
1145 add_symbol (bfd
*abfd
, const unsigned char *ascic
, unsigned int max
)
1147 struct vms_symbol_entry
*entry
;
1154 _bfd_error_handler (_("record is too small for symbol name length"));
1155 bfd_set_error (bfd_error_bad_value
);
1159 entry
= (struct vms_symbol_entry
*)bfd_zalloc (abfd
, sizeof (*entry
) + len
);
1162 entry
->namelen
= len
;
1163 memcpy (entry
->name
, ascic
, len
);
1164 entry
->name
[len
] = 0;
1165 entry
->owner
= abfd
;
1167 if (!add_symbol_entry (abfd
, entry
))
1172 /* Read and process EGSD. Return FALSE on failure. */
1175 _bfd_vms_slurp_egsd (bfd
*abfd
)
1178 unsigned int gsd_size
;
1179 unsigned char *vms_rec
;
1183 vms_debug2 ((2, "EGSD\n"));
1185 if (PRIV (recrd
.rec_size
) < 8)
1187 _bfd_error_handler (_("corrupt EGSD record: its size (%#x) is too small"),
1188 PRIV (recrd
.rec_size
));
1189 bfd_set_error (bfd_error_bad_value
);
1193 PRIV (recrd
.rec
) += 8; /* Skip type, size, align pad. */
1194 PRIV (recrd
.rec_size
) -= 8;
1196 /* Calculate base address for each section. */
1199 while (PRIV (recrd
.rec_size
) > 4)
1201 vms_rec
= PRIV (recrd
.rec
);
1203 gsd_type
= bfd_getl16 (vms_rec
);
1204 gsd_size
= bfd_getl16 (vms_rec
+ 2);
1206 vms_debug2 ((3, "egsd_type %d\n", gsd_type
));
1208 /* PR 21615: Check for size overflow. */
1209 if (PRIV (recrd
.rec_size
) < gsd_size
)
1211 _bfd_error_handler (_("corrupt EGSD record type %d: size (%#x) "
1212 "is larger than remaining space (%#x)"),
1213 gsd_type
, gsd_size
, PRIV (recrd
.rec_size
));
1214 bfd_set_error (bfd_error_bad_value
);
1221 _bfd_error_handler (_("corrupt EGSD record type %d: size (%#x) "
1223 gsd_type
, gsd_size
);
1224 bfd_set_error (bfd_error_bad_value
);
1231 /* Program section definition. */
1233 struct vms_egps
*egps
= (struct vms_egps
*) vms_rec
;
1234 flagword new_flags
, vms_flags
;
1237 if (offsetof (struct vms_egps
, flags
) + 2 > gsd_size
)
1239 vms_flags
= bfd_getl16 (egps
->flags
);
1241 if ((vms_flags
& EGPS__V_REL
) == 0)
1243 /* Use the global absolute section for all
1244 absolute sections. */
1245 section
= bfd_abs_section_ptr
;
1253 if (offsetof (struct vms_egps
, namlng
) >= gsd_size
)
1255 left
= gsd_size
- offsetof (struct vms_egps
, namlng
);
1256 name
= _bfd_vms_save_counted_string (abfd
, &egps
->namlng
, left
);
1257 if (name
== NULL
|| name
[0] == 0)
1260 section
= bfd_make_section (abfd
, name
);
1264 section
->filepos
= 0;
1265 section
->size
= bfd_getl32 (egps
->alloc
);
1266 section
->alignment_power
= egps
->align
& 31;
1268 vms_section_data (section
)->flags
= vms_flags
;
1269 vms_section_data (section
)->no_flags
= 0;
1271 new_flags
= vms_secflag_by_name (evax_section_flags
,
1274 if (section
->size
> 0)
1275 new_flags
|= SEC_LOAD
;
1276 if (!(vms_flags
& EGPS__V_NOMOD
) && section
->size
> 0)
1278 /* Set RELOC and HAS_CONTENTS if the section is not
1279 demand-zero and not empty. */
1280 new_flags
|= SEC_HAS_CONTENTS
;
1281 if (vms_flags
& EGPS__V_REL
)
1282 new_flags
|= SEC_RELOC
;
1284 if (vms_flags
& EGPS__V_EXE
)
1286 /* Set CODE if section is executable. */
1287 new_flags
|= SEC_CODE
;
1288 new_flags
&= ~SEC_DATA
;
1290 if (!bfd_set_section_flags (section
, new_flags
))
1293 /* Give a non-overlapping vma to non absolute sections. */
1294 align_addr
= (bfd_vma
) 1 << section
->alignment_power
;
1295 base_addr
= (base_addr
+ align_addr
- 1) & -align_addr
;
1296 section
->vma
= base_addr
;
1297 base_addr
+= section
->size
;
1300 /* Append it to the section array. */
1301 if (PRIV (section_count
) >= PRIV (section_max
))
1303 if (PRIV (section_max
) == 0)
1304 PRIV (section_max
) = 16;
1306 PRIV (section_max
) *= 2;
1307 PRIV (sections
) = bfd_realloc_or_free
1308 (PRIV (sections
), PRIV (section_max
) * sizeof (asection
*));
1309 if (PRIV (sections
) == NULL
)
1313 PRIV (sections
)[PRIV (section_count
)] = section
;
1314 PRIV (section_count
)++;
1320 unsigned int nameoff
;
1321 struct vms_symbol_entry
*entry
;
1322 struct vms_egsy
*egsy
= (struct vms_egsy
*) vms_rec
;
1325 if (offsetof (struct vms_egsy
, flags
) + 2 > gsd_size
)
1327 old_flags
= bfd_getl16 (egsy
->flags
);
1328 if (old_flags
& EGSY__V_DEF
)
1329 nameoff
= ESDF__B_NAMLNG
;
1331 nameoff
= ESRF__B_NAMLNG
;
1333 if (nameoff
>= gsd_size
)
1335 entry
= add_symbol (abfd
, vms_rec
+ nameoff
, gsd_size
- nameoff
);
1339 /* Allow only duplicate reference. */
1340 if ((entry
->flags
& EGSY__V_DEF
) && (old_flags
& EGSY__V_DEF
))
1343 if (entry
->typ
== 0)
1345 entry
->typ
= gsd_type
;
1346 entry
->data_type
= egsy
->datyp
;
1347 entry
->flags
= old_flags
;
1350 if (old_flags
& EGSY__V_DEF
)
1352 struct vms_esdf
*esdf
= (struct vms_esdf
*) vms_rec
;
1354 entry
->value
= bfd_getl64 (esdf
->value
);
1355 if (PRIV (sections
) == NULL
)
1358 psindx
= bfd_getl32 (esdf
->psindx
);
1359 /* PR 21813: Check for an out of range index. */
1360 if (psindx
< 0 || psindx
>= (int) PRIV (section_count
))
1363 _bfd_error_handler (_("corrupt EGSD record: its psindx "
1364 "field is too big (%#lx)"),
1366 bfd_set_error (bfd_error_bad_value
);
1369 entry
->section
= PRIV (sections
)[psindx
];
1371 if (old_flags
& EGSY__V_NORM
)
1373 PRIV (norm_sym_count
)++;
1375 entry
->code_value
= bfd_getl64 (esdf
->code_address
);
1376 psindx
= bfd_getl32 (esdf
->ca_psindx
);
1377 /* PR 21813: Check for an out of range index. */
1378 if (psindx
< 0 || psindx
>= (int) PRIV (section_count
))
1380 entry
->code_section
= PRIV (sections
)[psindx
];
1388 struct vms_symbol_entry
*entry
;
1389 struct vms_egst
*egst
= (struct vms_egst
*)vms_rec
;
1391 unsigned int nameoff
= offsetof (struct vms_egst
, namlng
);
1393 old_flags
= bfd_getl16 (egst
->header
.flags
);
1395 if (nameoff
>= gsd_size
)
1397 entry
= add_symbol (abfd
, &egst
->namlng
, gsd_size
- nameoff
);
1401 entry
->typ
= gsd_type
;
1402 entry
->data_type
= egst
->header
.datyp
;
1403 entry
->flags
= old_flags
;
1405 entry
->symbol_vector
= bfd_getl32 (egst
->value
);
1407 if (old_flags
& EGSY__V_REL
)
1409 if (PRIV (sections
) == NULL
)
1411 psindx
= bfd_getl32 (egst
->psindx
);
1412 /* PR 21813: Check for an out of range index. */
1413 if (psindx
< 0 || psindx
>= (int) PRIV (section_count
))
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
));
1478 /* Pop value and section index. */
1481 _bfd_vms_pop (bfd
*abfd
, bfd_vma
*val
, unsigned int *rel
)
1483 if (PRIV (stackptr
) == 0)
1485 bfd_set_error (bfd_error_bad_value
);
1486 _bfd_error_handler (_("stack underflow in _bfd_vms_pop"));
1490 *val
= PRIV (stack
[PRIV (stackptr
)]).value
;
1491 *rel
= PRIV (stack
[PRIV (stackptr
)]).reloc
;
1493 vms_debug2 ((4, "<pop %08lx (0x%08x)>\n", (unsigned long)*val
, *rel
));
1497 /* Routines to fill sections contents during tir/etir read. */
1499 /* Initialize image buffer pointer to be filled. */
1502 image_set_ptr (bfd
*abfd
, bfd_vma vma
, int sect
, struct bfd_link_info
*info
)
1506 vms_debug2 ((4, "image_set_ptr (0x%08x, sect=%d)\n", (unsigned)vma
, sect
));
1508 if (PRIV (sections
) == NULL
)
1510 if (sect
< 0 || sect
>= (int) PRIV (section_count
))
1513 sec
= PRIV (sections
)[sect
];
1517 /* Reading contents to an output bfd. */
1519 if (sec
->output_section
== NULL
)
1521 /* Section discarded. */
1522 vms_debug2 ((5, " section %s discarded\n", sec
->name
));
1524 /* This is not used. */
1525 PRIV (image_section
) = NULL
;
1526 PRIV (image_offset
) = 0;
1529 PRIV (image_offset
) = sec
->output_offset
+ vma
;
1530 PRIV (image_section
) = sec
->output_section
;
1534 PRIV (image_offset
) = vma
;
1535 PRIV (image_section
) = sec
;
1539 /* Increment image buffer pointer by offset. */
1542 image_inc_ptr (bfd
*abfd
, bfd_vma offset
)
1544 vms_debug2 ((4, "image_inc_ptr (%u)\n", (unsigned)offset
));
1546 PRIV (image_offset
) += offset
;
1549 /* Save current DST location counter under specified index. */
1552 dst_define_location (bfd
*abfd
, unsigned int loc
)
1554 vms_debug2 ((4, "dst_define_location (%d)\n", (int)loc
));
1556 /* Grow the ptr offset table if necessary. */
1557 if (loc
+ 1 > PRIV (dst_ptr_offsets_count
))
1559 PRIV (dst_ptr_offsets
) = bfd_realloc (PRIV (dst_ptr_offsets
),
1560 (loc
+ 1) * sizeof (unsigned int));
1561 PRIV (dst_ptr_offsets_count
) = loc
+ 1;
1564 PRIV (dst_ptr_offsets
)[loc
] = PRIV (image_offset
);
1567 /* Restore saved DST location counter from specified index. */
1570 dst_restore_location (bfd
*abfd
, unsigned int loc
)
1572 vms_debug2 ((4, "dst_restore_location (%d)\n", (int)loc
));
1574 PRIV (image_offset
) = PRIV (dst_ptr_offsets
)[loc
];
1577 /* Retrieve saved DST location counter from specified index. */
1580 dst_retrieve_location (bfd
*abfd
, unsigned int loc
)
1582 vms_debug2 ((4, "dst_retrieve_location (%d)\n", (int)loc
));
1584 return PRIV (dst_ptr_offsets
)[loc
];
1587 /* Write multiple bytes to section image. */
1590 image_write (bfd
*abfd
, unsigned char *ptr
, unsigned int size
)
1593 _bfd_vms_debug (8, "image_write from (%p, %d) to (%ld)\n", ptr
, size
,
1594 (long)PRIV (image_offset
));
1597 if (PRIV (image_section
)->contents
!= NULL
)
1599 asection
*sec
= PRIV (image_section
);
1600 size_t off
= PRIV (image_offset
);
1604 || size
> sec
->size
- off
)
1606 bfd_set_error (bfd_error_bad_value
);
1610 memcpy (sec
->contents
+ off
, ptr
, size
);
1613 _bfd_hexdump (9, ptr
, size
, 0);
1616 PRIV (image_offset
) += size
;
1620 /* Write byte to section image. */
1623 image_write_b (bfd
* abfd
, unsigned int value
)
1625 unsigned char data
[1];
1627 vms_debug2 ((6, "image_write_b (%02x)\n", (int) value
));
1631 return image_write (abfd
, data
, sizeof (data
));
1634 /* Write 2-byte word to image. */
1637 image_write_w (bfd
* abfd
, unsigned int value
)
1639 unsigned char data
[2];
1641 vms_debug2 ((6, "image_write_w (%04x)\n", (int) value
));
1643 bfd_putl16 (value
, data
);
1644 return image_write (abfd
, data
, sizeof (data
));
1647 /* Write 4-byte long to image. */
1650 image_write_l (bfd
* abfd
, unsigned long value
)
1652 unsigned char data
[4];
1654 vms_debug2 ((6, "image_write_l (%08lx)\n", value
));
1656 bfd_putl32 (value
, data
);
1657 return image_write (abfd
, data
, sizeof (data
));
1660 /* Write 8-byte quad to image. */
1663 image_write_q (bfd
* abfd
, bfd_vma value
)
1665 unsigned char data
[8];
1667 vms_debug2 ((6, "image_write_q (%08lx)\n", (unsigned long)value
));
1669 bfd_putl64 (value
, data
);
1670 return image_write (abfd
, data
, sizeof (data
));
1674 _bfd_vms_etir_name (int cmd
)
1678 case ETIR__C_STA_GBL
: return "ETIR__C_STA_GBL";
1679 case ETIR__C_STA_LW
: return "ETIR__C_STA_LW";
1680 case ETIR__C_STA_QW
: return "ETIR__C_STA_QW";
1681 case ETIR__C_STA_PQ
: return "ETIR__C_STA_PQ";
1682 case ETIR__C_STA_LI
: return "ETIR__C_STA_LI";
1683 case ETIR__C_STA_MOD
: return "ETIR__C_STA_MOD";
1684 case ETIR__C_STA_CKARG
: return "ETIR__C_STA_CKARG";
1685 case ETIR__C_STO_B
: return "ETIR__C_STO_B";
1686 case ETIR__C_STO_W
: return "ETIR__C_STO_W";
1687 case ETIR__C_STO_GBL
: return "ETIR__C_STO_GBL";
1688 case ETIR__C_STO_CA
: return "ETIR__C_STO_CA";
1689 case ETIR__C_STO_RB
: return "ETIR__C_STO_RB";
1690 case ETIR__C_STO_AB
: return "ETIR__C_STO_AB";
1691 case ETIR__C_STO_OFF
: return "ETIR__C_STO_OFF";
1692 case ETIR__C_STO_IMM
: return "ETIR__C_STO_IMM";
1693 case ETIR__C_STO_IMMR
: return "ETIR__C_STO_IMMR";
1694 case ETIR__C_STO_LW
: return "ETIR__C_STO_LW";
1695 case ETIR__C_STO_QW
: return "ETIR__C_STO_QW";
1696 case ETIR__C_STO_GBL_LW
: return "ETIR__C_STO_GBL_LW";
1697 case ETIR__C_STO_LP_PSB
: return "ETIR__C_STO_LP_PSB";
1698 case ETIR__C_STO_HINT_GBL
: return "ETIR__C_STO_HINT_GBL";
1699 case ETIR__C_STO_HINT_PS
: return "ETIR__C_STO_HINT_PS";
1700 case ETIR__C_OPR_ADD
: return "ETIR__C_OPR_ADD";
1701 case ETIR__C_OPR_SUB
: return "ETIR__C_OPR_SUB";
1702 case ETIR__C_OPR_INSV
: return "ETIR__C_OPR_INSV";
1703 case ETIR__C_OPR_USH
: return "ETIR__C_OPR_USH";
1704 case ETIR__C_OPR_ROT
: return "ETIR__C_OPR_ROT";
1705 case ETIR__C_OPR_REDEF
: return "ETIR__C_OPR_REDEF";
1706 case ETIR__C_OPR_DFLIT
: return "ETIR__C_OPR_DFLIT";
1707 case ETIR__C_STC_LP
: return "ETIR__C_STC_LP";
1708 case ETIR__C_STC_GBL
: return "ETIR__C_STC_GBL";
1709 case ETIR__C_STC_GCA
: return "ETIR__C_STC_GCA";
1710 case ETIR__C_STC_PS
: return "ETIR__C_STC_PS";
1711 case ETIR__C_STC_NBH_PS
: return "ETIR__C_STC_NBH_PS";
1712 case ETIR__C_STC_NOP_GBL
: return "ETIR__C_STC_NOP_GBL";
1713 case ETIR__C_STC_NOP_PS
: return "ETIR__C_STC_NOP_PS";
1714 case ETIR__C_STC_BSR_GBL
: return "ETIR__C_STC_BSR_GBL";
1715 case ETIR__C_STC_BSR_PS
: return "ETIR__C_STC_BSR_PS";
1716 case ETIR__C_STC_LDA_GBL
: return "ETIR__C_STC_LDA_GBL";
1717 case ETIR__C_STC_LDA_PS
: return "ETIR__C_STC_LDA_PS";
1718 case ETIR__C_STC_BOH_GBL
: return "ETIR__C_STC_BOH_GBL";
1719 case ETIR__C_STC_BOH_PS
: return "ETIR__C_STC_BOH_PS";
1720 case ETIR__C_STC_NBH_GBL
: return "ETIR__C_STC_NBH_GBL";
1721 case ETIR__C_STC_LP_PSB
: return "ETIR__C_STC_LP_PSB";
1722 case ETIR__C_CTL_SETRB
: return "ETIR__C_CTL_SETRB";
1723 case ETIR__C_CTL_AUGRB
: return "ETIR__C_CTL_AUGRB";
1724 case ETIR__C_CTL_DFLOC
: return "ETIR__C_CTL_DFLOC";
1725 case ETIR__C_CTL_STLOC
: return "ETIR__C_CTL_STLOC";
1726 case ETIR__C_CTL_STKDL
: return "ETIR__C_CTL_STKDL";
1729 /* These names have not yet been added to this switch statement. */
1730 _bfd_error_handler (_("unknown ETIR command %d"), cmd
);
1735 #define HIGHBIT(op) ((op & 0x80000000L) == 0x80000000L)
1738 _bfd_vms_get_value (bfd
*abfd
,
1739 const unsigned char *ascic
,
1740 const unsigned char *max_ascic
,
1741 struct bfd_link_info
*info
,
1743 struct alpha_vms_link_hash_entry
**hp
)
1748 struct alpha_vms_link_hash_entry
*h
;
1750 /* Not linking. Do not try to resolve the symbol. */
1759 if (ascic
+ len
>= max_ascic
)
1761 _bfd_error_handler (_("corrupt vms value"));
1767 for (i
= 0; i
< len
; i
++)
1768 name
[i
] = ascic
[i
+ 1];
1771 h
= (struct alpha_vms_link_hash_entry
*)
1772 bfd_link_hash_lookup (info
->hash
, name
, FALSE
, FALSE
, TRUE
);
1777 && (h
->root
.type
== bfd_link_hash_defined
1778 || h
->root
.type
== bfd_link_hash_defweak
))
1779 *vma
= h
->root
.u
.def
.value
1780 + h
->root
.u
.def
.section
->output_offset
1781 + h
->root
.u
.def
.section
->output_section
->vma
;
1782 else if (h
&& h
->root
.type
== bfd_link_hash_undefweak
)
1786 (*info
->callbacks
->undefined_symbol
)
1787 (info
, name
, abfd
, PRIV (image_section
), PRIV (image_offset
), TRUE
);
1794 #define RELC_SHR_BASE 0x10000
1795 #define RELC_SEC_BASE 0x20000
1796 #define RELC_MASK 0x0ffff
1799 alpha_vms_sym_to_ctxt (struct alpha_vms_link_hash_entry
*h
)
1801 /* Handle undefined symbols. */
1802 if (h
== NULL
|| h
->sym
== NULL
)
1805 if (h
->sym
->typ
== EGSD__C_SYMG
)
1807 if (h
->sym
->flags
& EGSY__V_REL
)
1808 return RELC_SHR_BASE
+ PRIV2 (h
->sym
->owner
, shr_index
);
1811 /* Can this happen (non-relocatable symg) ? I'd like to see
1816 if (h
->sym
->typ
== EGSD__C_SYM
)
1818 if (h
->sym
->flags
& EGSY__V_REL
)
1827 alpha_vms_get_sym_value (asection
*sect
, bfd_vma addr
)
1829 return sect
->output_section
->vma
+ sect
->output_offset
+ addr
;
1833 alpha_vms_fix_sec_rel (bfd
*abfd
, struct bfd_link_info
*info
,
1834 unsigned int rel
, bfd_vma vma
)
1838 if (PRIV (sections
) == NULL
)
1841 sec
= PRIV (sections
)[rel
& RELC_MASK
];
1845 if (sec
->output_section
== NULL
)
1847 return vma
+ sec
->output_section
->vma
+ sec
->output_offset
;
1850 return vma
+ sec
->vma
;
1853 /* Read an ETIR record from ABFD. If INFO is not null, put the content into
1854 the output section (used during linking).
1855 Return FALSE in case of error. */
1858 _bfd_vms_slurp_etir (bfd
*abfd
, struct bfd_link_info
*info
)
1861 unsigned int length
;
1862 unsigned char *maxptr
;
1865 unsigned int rel1
= RELC_NONE
;
1866 unsigned int rel2
= RELC_NONE
;
1867 struct alpha_vms_link_hash_entry
*h
;
1869 PRIV (recrd
.rec
) += ETIR__C_HEADER_SIZE
;
1870 PRIV (recrd
.rec_size
) -= ETIR__C_HEADER_SIZE
;
1872 ptr
= PRIV (recrd
.rec
);
1873 length
= PRIV (recrd
.rec_size
);
1874 maxptr
= ptr
+ length
;
1876 vms_debug2 ((2, "ETIR: %d bytes\n", length
));
1878 while (ptr
< maxptr
)
1880 int cmd
, cmd_length
;
1882 if (ptr
+ 4 > maxptr
)
1885 cmd
= bfd_getl16 (ptr
);
1886 cmd_length
= bfd_getl16 (ptr
+ 2);
1888 /* PR 21589 and 21579: Check for a corrupt ETIR record. */
1889 if (cmd_length
< 4 || ptr
+ cmd_length
> maxptr
)
1892 _bfd_error_handler (_("corrupt ETIR record encountered"));
1893 bfd_set_error (bfd_error_bad_value
);
1899 _bfd_vms_debug (4, "etir: %s(%d)\n",
1900 _bfd_vms_etir_name (cmd
), cmd
);
1901 _bfd_hexdump (8, ptr
, cmd_length
- 4, 0);
1909 stack 32 bit value of symbol (high bits set to 0). */
1910 case ETIR__C_STA_GBL
:
1911 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
1912 if (!_bfd_vms_push (abfd
, op1
, alpha_vms_sym_to_ctxt (h
)))
1919 stack 32 bit value, sign extend to 64 bit. */
1920 case ETIR__C_STA_LW
:
1921 if (ptr
+ 4 > maxptr
)
1923 if (!_bfd_vms_push (abfd
, bfd_getl32 (ptr
), RELC_NONE
))
1930 stack 64 bit value of symbol. */
1931 case ETIR__C_STA_QW
:
1932 if (ptr
+ 8 > maxptr
)
1934 if (!_bfd_vms_push (abfd
, bfd_getl64 (ptr
), RELC_NONE
))
1938 /* Stack psect base plus quadword offset
1939 arg: lw section index
1940 qw signed quadword offset (low 32 bits)
1942 Stack qw argument and section index
1943 (see ETIR__C_STO_OFF, ETIR__C_CTL_SETRB). */
1944 case ETIR__C_STA_PQ
:
1948 if (ptr
+ 12 > maxptr
)
1950 psect
= bfd_getl32 (ptr
);
1951 if ((unsigned int) psect
>= PRIV (section_count
))
1953 _bfd_error_handler (_("bad section index in %s"),
1954 _bfd_vms_etir_name (cmd
));
1955 bfd_set_error (bfd_error_bad_value
);
1958 op1
= bfd_getl64 (ptr
+ 4);
1959 if (!_bfd_vms_push (abfd
, op1
, psect
| RELC_SEC_BASE
))
1964 case ETIR__C_STA_LI
:
1965 case ETIR__C_STA_MOD
:
1966 case ETIR__C_STA_CKARG
:
1967 _bfd_error_handler (_("unsupported STA cmd %s"),
1968 _bfd_vms_etir_name (cmd
));
1972 /* Store byte: pop stack, write byte
1975 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
1977 if (rel1
!= RELC_NONE
)
1979 image_write_b (abfd
, (unsigned int) op1
& 0xff);
1982 /* Store word: pop stack, write word
1985 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
1987 if (rel1
!= RELC_NONE
)
1989 image_write_w (abfd
, (unsigned int) op1
& 0xffff);
1992 /* Store longword: pop stack, write longword
1994 case ETIR__C_STO_LW
:
1995 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
1997 if (rel1
& RELC_SEC_BASE
)
1999 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2002 else if (rel1
& RELC_SHR_BASE
)
2004 if (!alpha_vms_add_fixup_lr (info
, rel1
& RELC_MASK
, op1
))
2008 if (rel1
!= RELC_NONE
)
2010 if (rel1
!= RELC_REL
)
2012 if (!alpha_vms_add_lw_reloc (info
))
2015 image_write_l (abfd
, op1
);
2018 /* Store quadword: pop stack, write quadword
2020 case ETIR__C_STO_QW
:
2021 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2023 if (rel1
& RELC_SEC_BASE
)
2025 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2028 else if (rel1
& RELC_SHR_BASE
)
2030 if (rel1
!= RELC_NONE
)
2032 if (rel1
!= RELC_REL
)
2034 if (!alpha_vms_add_qw_reloc (info
))
2037 image_write_q (abfd
, op1
);
2040 /* Store immediate repeated: pop stack for repeat count
2043 case ETIR__C_STO_IMMR
:
2047 if (ptr
+ 4 > maxptr
)
2049 size
= bfd_getl32 (ptr
);
2050 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2052 if (rel1
!= RELC_NONE
)
2055 image_write (abfd
, ptr
+ 4, size
);
2059 /* Store global: write symbol value
2060 arg: cs global symbol name. */
2061 case ETIR__C_STO_GBL
:
2062 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
2065 if (h
->sym
->typ
== EGSD__C_SYMG
)
2067 if (!alpha_vms_add_fixup_qr (info
, abfd
, h
->sym
->owner
,
2068 h
->sym
->symbol_vector
))
2074 op1
= alpha_vms_get_sym_value (h
->sym
->section
,
2076 if (!alpha_vms_add_qw_reloc (info
))
2080 image_write_q (abfd
, op1
);
2083 /* Store code address: write address of entry point
2084 arg: cs global symbol name (procedure). */
2085 case ETIR__C_STO_CA
:
2086 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
2089 if (h
->sym
->flags
& EGSY__V_NORM
)
2091 /* That's really a procedure. */
2092 if (h
->sym
->typ
== EGSD__C_SYMG
)
2094 if (!alpha_vms_add_fixup_ca (info
, abfd
, h
->sym
->owner
))
2096 op1
= h
->sym
->symbol_vector
;
2100 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
2101 h
->sym
->code_value
);
2102 if (!alpha_vms_add_qw_reloc (info
))
2108 /* Symbol is not a procedure. */
2112 image_write_q (abfd
, op1
);
2115 /* Store offset to psect: pop stack, add low 32 bits to base of psect
2117 case ETIR__C_STO_OFF
:
2118 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2121 if (!(rel1
& RELC_SEC_BASE
))
2124 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2126 image_write_q (abfd
, op1
);
2130 arg: lw count of bytes
2132 case ETIR__C_STO_IMM
:
2136 if (ptr
+ 4 > maxptr
)
2138 size
= bfd_getl32 (ptr
);
2139 image_write (abfd
, ptr
+ 4, size
);
2143 /* This code is 'reserved to digital' according to the openVMS
2144 linker manual, however it is generated by the DEC C compiler
2145 and defined in the include file.
2146 FIXME, since the following is just a guess
2147 store global longword: store 32bit value of symbol
2148 arg: cs symbol name. */
2149 case ETIR__C_STO_GBL_LW
:
2150 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
2154 image_write_l (abfd
, op1
);
2157 case ETIR__C_STO_RB
:
2158 case ETIR__C_STO_AB
:
2159 case ETIR__C_STO_LP_PSB
:
2160 _bfd_error_handler (_("%s: not supported"),
2161 _bfd_vms_etir_name (cmd
));
2164 case ETIR__C_STO_HINT_GBL
:
2165 case ETIR__C_STO_HINT_PS
:
2166 _bfd_error_handler (_("%s: not implemented"),
2167 _bfd_vms_etir_name (cmd
));
2171 /* 200 Store-conditional Linkage Pair
2173 case ETIR__C_STC_LP
:
2175 /* 202 Store-conditional Address at global address
2179 case ETIR__C_STC_GBL
:
2181 /* 203 Store-conditional Code Address at global address
2183 cs procedure name. */
2184 case ETIR__C_STC_GCA
:
2186 /* 204 Store-conditional Address at psect + offset
2190 case ETIR__C_STC_PS
:
2191 _bfd_error_handler (_("%s: not supported"),
2192 _bfd_vms_etir_name (cmd
));
2196 /* 201 Store-conditional Linkage Pair with Procedure Signature
2202 case ETIR__C_STC_LP_PSB
:
2203 _bfd_vms_get_value (abfd
, ptr
+ 4, maxptr
, info
, &op1
, &h
);
2206 if (h
->sym
->typ
== EGSD__C_SYMG
)
2208 if (!alpha_vms_add_fixup_lp (info
, abfd
, h
->sym
->owner
))
2210 op1
= h
->sym
->symbol_vector
;
2215 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
2216 h
->sym
->code_value
);
2217 op2
= alpha_vms_get_sym_value (h
->sym
->section
,
2223 /* Undefined symbol. */
2227 image_write_q (abfd
, op1
);
2228 image_write_q (abfd
, op2
);
2231 /* 205 Store-conditional NOP at address of global
2233 case ETIR__C_STC_NOP_GBL
:
2236 /* 207 Store-conditional BSR at global address
2239 case ETIR__C_STC_BSR_GBL
:
2242 /* 209 Store-conditional LDA at global address
2245 case ETIR__C_STC_LDA_GBL
:
2248 /* 211 Store-conditional BSR or Hint at global address
2251 case ETIR__C_STC_BOH_GBL
:
2252 /* Currentl ignored. */
2255 /* 213 Store-conditional NOP,BSR or HINT at global address
2258 case ETIR__C_STC_NBH_GBL
:
2260 /* 206 Store-conditional NOP at pect + offset
2263 case ETIR__C_STC_NOP_PS
:
2265 /* 208 Store-conditional BSR at pect + offset
2268 case ETIR__C_STC_BSR_PS
:
2270 /* 210 Store-conditional LDA at psect + offset
2273 case ETIR__C_STC_LDA_PS
:
2275 /* 212 Store-conditional BSR or Hint at pect + offset
2278 case ETIR__C_STC_BOH_PS
:
2280 /* 214 Store-conditional NOP, BSR or HINT at psect + offset
2282 case ETIR__C_STC_NBH_PS
:
2283 _bfd_error_handler (_("%s: not supported"),
2284 _bfd_vms_etir_name (cmd
));
2288 /* Det relocation base: pop stack, set image location counter
2290 case ETIR__C_CTL_SETRB
:
2291 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2293 if (!(rel1
& RELC_SEC_BASE
))
2295 image_set_ptr (abfd
, op1
, rel1
& RELC_MASK
, info
);
2298 /* Augment relocation base: increment image location counter by offset
2299 arg: lw offset value. */
2300 case ETIR__C_CTL_AUGRB
:
2301 if (ptr
+ 4 > maxptr
)
2303 op1
= bfd_getl32 (ptr
);
2304 image_inc_ptr (abfd
, op1
);
2307 /* Define location: pop index, save location counter under index
2309 case ETIR__C_CTL_DFLOC
:
2310 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2312 if (rel1
!= RELC_NONE
)
2314 dst_define_location (abfd
, op1
);
2317 /* Set location: pop index, restore location counter from index
2319 case ETIR__C_CTL_STLOC
:
2320 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2322 if (rel1
!= RELC_NONE
)
2324 dst_restore_location (abfd
, op1
);
2327 /* Stack defined location: pop index, push location counter from index
2329 case ETIR__C_CTL_STKDL
:
2330 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2332 if (rel1
!= RELC_NONE
)
2334 if (!_bfd_vms_push (abfd
, dst_retrieve_location (abfd
, op1
),
2339 case ETIR__C_OPR_NOP
: /* No-op. */
2342 case ETIR__C_OPR_ADD
: /* Add. */
2343 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2344 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2346 if (rel1
== RELC_NONE
&& rel2
!= RELC_NONE
)
2348 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2350 if (!_bfd_vms_push (abfd
, op1
+ op2
, rel1
))
2354 case ETIR__C_OPR_SUB
: /* Subtract. */
2355 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2356 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2358 if (rel1
== RELC_NONE
&& rel2
!= RELC_NONE
)
2360 else if ((rel1
& RELC_SEC_BASE
) && (rel2
& RELC_SEC_BASE
))
2362 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2363 op2
= alpha_vms_fix_sec_rel (abfd
, info
, rel2
, op2
);
2366 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2368 if (!_bfd_vms_push (abfd
, op2
- op1
, rel1
))
2372 case ETIR__C_OPR_MUL
: /* Multiply. */
2373 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2374 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2376 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2378 if (!_bfd_vms_push (abfd
, op1
* op2
, RELC_NONE
))
2382 case ETIR__C_OPR_DIV
: /* Divide. */
2383 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2384 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2386 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2390 if (!_bfd_vms_push (abfd
, 0, RELC_NONE
))
2395 if (!_bfd_vms_push (abfd
, op2
/ op1
, RELC_NONE
))
2400 case ETIR__C_OPR_AND
: /* Logical AND. */
2401 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2402 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2404 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2406 if (!_bfd_vms_push (abfd
, op1
& op2
, RELC_NONE
))
2410 case ETIR__C_OPR_IOR
: /* Logical inclusive OR. */
2411 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2412 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2414 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2416 if (!_bfd_vms_push (abfd
, op1
| op2
, RELC_NONE
))
2420 case ETIR__C_OPR_EOR
: /* Logical exclusive OR. */
2421 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2422 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2424 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2426 if (!_bfd_vms_push (abfd
, op1
^ op2
, RELC_NONE
))
2430 case ETIR__C_OPR_NEG
: /* Negate. */
2431 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2433 if (rel1
!= RELC_NONE
)
2435 if (!_bfd_vms_push (abfd
, -op1
, RELC_NONE
))
2439 case ETIR__C_OPR_COM
: /* Complement. */
2440 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2442 if (rel1
!= RELC_NONE
)
2444 if (!_bfd_vms_push (abfd
, ~op1
, RELC_NONE
))
2448 case ETIR__C_OPR_ASH
: /* Arithmetic shift. */
2449 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2450 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2452 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2455 _bfd_error_handler (_("invalid use of %s with contexts"),
2456 _bfd_vms_etir_name (cmd
));
2459 if ((int)op2
< 0) /* Shift right. */
2461 else /* Shift left. */
2463 if (!_bfd_vms_push (abfd
, op1
, RELC_NONE
)) /* FIXME: sym. */
2467 case ETIR__C_OPR_INSV
: /* Insert field. */
2468 case ETIR__C_OPR_USH
: /* Unsigned shift. */
2469 case ETIR__C_OPR_ROT
: /* Rotate. */
2470 case ETIR__C_OPR_REDEF
: /* Redefine symbol to current location. */
2471 case ETIR__C_OPR_DFLIT
: /* Define a literal. */
2472 _bfd_error_handler (_("%s: not supported"),
2473 _bfd_vms_etir_name (cmd
));
2477 case ETIR__C_OPR_SEL
: /* Select. */
2478 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2482 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2487 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2488 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2490 if (!_bfd_vms_push (abfd
, op1
, rel1
))
2496 _bfd_error_handler (_("reserved cmd %d"), cmd
);
2501 ptr
+= cmd_length
- 4;
2507 /* Process EDBG/ETBT record.
2508 Return TRUE on success, FALSE on error */
2511 vms_slurp_debug (bfd
*abfd
)
2513 asection
*section
= PRIV (dst_section
);
2515 if (section
== NULL
)
2517 /* We have no way to find out beforehand how much debug info there
2518 is in an object file, so pick an initial amount and grow it as
2520 flagword flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
| SEC_RELOC
2523 section
= bfd_make_section (abfd
, "$DST$");
2526 if (!bfd_set_section_flags (section
, flags
))
2528 PRIV (dst_section
) = section
;
2531 PRIV (image_section
) = section
;
2532 PRIV (image_offset
) = section
->size
;
2534 if (!_bfd_vms_slurp_etir (abfd
, NULL
))
2537 section
->size
= PRIV (image_offset
);
2541 /* Process EDBG record.
2542 Return TRUE on success, FALSE on error. */
2545 _bfd_vms_slurp_edbg (bfd
*abfd
)
2547 vms_debug2 ((2, "EDBG\n"));
2549 abfd
->flags
|= HAS_DEBUG
| HAS_LINENO
;
2551 return vms_slurp_debug (abfd
);
2554 /* Process ETBT record.
2555 Return TRUE on success, FALSE on error. */
2558 _bfd_vms_slurp_etbt (bfd
*abfd
)
2560 vms_debug2 ((2, "ETBT\n"));
2562 abfd
->flags
|= HAS_LINENO
;
2564 return vms_slurp_debug (abfd
);
2567 /* Process EEOM record.
2568 Return TRUE on success, FALSE on error. */
2571 _bfd_vms_slurp_eeom (bfd
*abfd
)
2573 struct vms_eeom
*eeom
= (struct vms_eeom
*) PRIV (recrd
.rec
);
2575 vms_debug2 ((2, "EEOM\n"));
2577 /* PR 21813: Check for an undersized record. */
2578 if (PRIV (recrd
.buf_size
) < sizeof (* eeom
))
2580 _bfd_error_handler (_("corrupt EEOM record - size is too small"));
2581 bfd_set_error (bfd_error_bad_value
);
2585 PRIV (eom_data
).eom_l_total_lps
= bfd_getl32 (eeom
->total_lps
);
2586 PRIV (eom_data
).eom_w_comcod
= bfd_getl16 (eeom
->comcod
);
2587 if (PRIV (eom_data
).eom_w_comcod
> 1)
2589 _bfd_error_handler (_("object module not error-free !"));
2590 bfd_set_error (bfd_error_bad_value
);
2594 PRIV (eom_data
).eom_has_transfer
= FALSE
;
2595 if (PRIV (recrd
.rec_size
) > 10)
2597 PRIV (eom_data
).eom_has_transfer
= TRUE
;
2598 PRIV (eom_data
).eom_b_tfrflg
= eeom
->tfrflg
;
2599 PRIV (eom_data
).eom_l_psindx
= bfd_getl32 (eeom
->psindx
);
2600 PRIV (eom_data
).eom_l_tfradr
= bfd_getl32 (eeom
->tfradr
);
2602 abfd
->start_address
= PRIV (eom_data
).eom_l_tfradr
;
2607 /* Slurp an ordered set of VMS object records. Return FALSE on error. */
2610 _bfd_vms_slurp_object_records (bfd
* abfd
)
2617 vms_debug2 ((7, "reading at %08lx\n", (unsigned long)bfd_tell (abfd
)));
2619 type
= _bfd_vms_get_object_record (abfd
);
2622 vms_debug2 ((2, "next_record failed\n"));
2629 err
= _bfd_vms_slurp_ehdr (abfd
);
2632 err
= _bfd_vms_slurp_eeom (abfd
);
2635 err
= _bfd_vms_slurp_egsd (abfd
);
2638 err
= TRUE
; /* _bfd_vms_slurp_etir (abfd); */
2641 err
= _bfd_vms_slurp_edbg (abfd
);
2644 err
= _bfd_vms_slurp_etbt (abfd
);
2651 vms_debug2 ((2, "slurp type %d failed\n", type
));
2655 while (type
!= EOBJ__C_EEOM
);
2660 /* Initialize private data */
2662 vms_initialize (bfd
* abfd
)
2666 amt
= sizeof (struct vms_private_data_struct
);
2667 abfd
->tdata
.any
= bfd_zalloc (abfd
, amt
);
2668 if (abfd
->tdata
.any
== NULL
)
2671 PRIV (recrd
.file_format
) = FF_UNKNOWN
;
2673 amt
= sizeof (struct stack_struct
) * STACKSIZE
;
2674 PRIV (stack
) = bfd_alloc (abfd
, amt
);
2675 if (PRIV (stack
) == NULL
)
2681 bfd_release (abfd
, abfd
->tdata
.any
);
2682 abfd
->tdata
.any
= NULL
;
2686 /* Free malloc'd memory. */
2689 alpha_vms_free_private (bfd
*abfd
)
2691 struct module
*module
;
2693 free (PRIV (recrd
.buf
));
2694 free (PRIV (sections
));
2696 free (PRIV (dst_ptr_offsets
));
2698 for (module
= PRIV (modules
); module
; module
= module
->next
)
2699 free (module
->file_table
);
2702 /* Check the format for a file being read.
2703 Return a (bfd_target *) if it's an object file or zero if not. */
2705 static const struct bfd_target
*
2706 alpha_vms_object_p (bfd
*abfd
)
2708 void *tdata_save
= abfd
->tdata
.any
;
2709 unsigned int test_len
;
2712 vms_debug2 ((1, "vms_object_p(%p)\n", abfd
));
2714 /* Allocate alpha-vms specific data. */
2715 if (!vms_initialize (abfd
))
2717 abfd
->tdata
.any
= tdata_save
;
2721 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
))
2722 goto err_wrong_format
;
2724 /* The first challenge with VMS is to discover the kind of the file.
2726 Image files (executable or shared images) are stored as a raw
2727 stream of bytes (like on UNIX), but there is no magic number.
2729 Object files are written with RMS (record management service), ie
2730 each records are preceeded by its length (on a word - 2 bytes), and
2731 padded for word-alignment. That would be simple but when files
2732 are transfered to a UNIX filesystem (using ftp), records are lost.
2733 Only the raw content of the records are transfered. Fortunately,
2734 the Alpha Object file format also store the length of the record
2735 in the records. Is that clear ? */
2737 /* Minimum is 6 bytes for objects (2 bytes size, 2 bytes record id,
2738 2 bytes size repeated) and 12 bytes for images (4 bytes major id,
2739 4 bytes minor id, 4 bytes length). */
2742 /* Size the main buffer. */
2743 buf
= (unsigned char *) bfd_malloc (test_len
);
2746 PRIV (recrd
.buf
) = buf
;
2747 PRIV (recrd
.buf_size
) = test_len
;
2749 /* Initialize the record pointer. */
2750 PRIV (recrd
.rec
) = buf
;
2752 if (bfd_bread (buf
, test_len
, abfd
) != test_len
)
2753 goto err_wrong_format
;
2755 /* Is it an image? */
2756 if ((bfd_getl32 (buf
) == EIHD__K_MAJORID
)
2757 && (bfd_getl32 (buf
+ 4) == EIHD__K_MINORID
))
2759 unsigned int to_read
;
2760 unsigned int read_so_far
;
2761 unsigned int remaining
;
2762 unsigned int eisd_offset
, eihs_offset
;
2764 /* Extract the header size. */
2765 PRIV (recrd
.rec_size
) = bfd_getl32 (buf
+ EIHD__L_SIZE
);
2767 /* The header size is 0 for DSF files. */
2768 if (PRIV (recrd
.rec_size
) == 0)
2769 PRIV (recrd
.rec_size
) = sizeof (struct vms_eihd
);
2771 if (PRIV (recrd
.rec_size
) > PRIV (recrd
.buf_size
))
2773 buf
= bfd_realloc_or_free (buf
, PRIV (recrd
.rec_size
));
2777 PRIV (recrd
.buf
) = NULL
;
2780 PRIV (recrd
.buf
) = buf
;
2781 PRIV (recrd
.buf_size
) = PRIV (recrd
.rec_size
);
2784 /* PR 21813: Check for a truncated record. */
2785 if (PRIV (recrd
.rec_size
< test_len
))
2787 /* Read the remaining record. */
2788 remaining
= PRIV (recrd
.rec_size
) - test_len
;
2789 to_read
= MIN (VMS_BLOCK_SIZE
- test_len
, remaining
);
2790 read_so_far
= test_len
;
2792 while (remaining
> 0)
2794 if (bfd_bread (buf
+ read_so_far
, to_read
, abfd
) != to_read
)
2795 goto err_wrong_format
;
2797 read_so_far
+= to_read
;
2798 remaining
-= to_read
;
2800 to_read
= MIN (VMS_BLOCK_SIZE
, remaining
);
2803 /* Reset the record pointer. */
2804 PRIV (recrd
.rec
) = buf
;
2806 /* PR 17512: file: 7d7c57c2. */
2807 if (PRIV (recrd
.rec_size
) < sizeof (struct vms_eihd
))
2809 vms_debug2 ((2, "file type is image\n"));
2811 if (!_bfd_vms_slurp_eihd (abfd
, &eisd_offset
, &eihs_offset
))
2812 goto err_wrong_format
;
2814 if (!_bfd_vms_slurp_eisd (abfd
, eisd_offset
))
2815 goto err_wrong_format
;
2817 /* EIHS is optional. */
2818 if (eihs_offset
!= 0 && !_bfd_vms_slurp_eihs (abfd
, eihs_offset
))
2819 goto err_wrong_format
;
2825 /* Assume it's a module and adjust record pointer if necessary. */
2826 maybe_adjust_record_pointer_for_object (abfd
);
2828 /* But is it really a module? */
2829 if (bfd_getl16 (PRIV (recrd
.rec
)) <= EOBJ__C_MAXRECTYP
2830 && bfd_getl16 (PRIV (recrd
.rec
) + 2) <= EOBJ__C_MAXRECSIZ
)
2832 if (vms_get_remaining_object_record (abfd
, test_len
) <= 0)
2833 goto err_wrong_format
;
2835 vms_debug2 ((2, "file type is module\n"));
2837 type
= bfd_getl16 (PRIV (recrd
.rec
));
2838 if (type
!= EOBJ__C_EMH
|| !_bfd_vms_slurp_ehdr (abfd
))
2839 goto err_wrong_format
;
2841 if (!_bfd_vms_slurp_object_records (abfd
))
2842 goto err_wrong_format
;
2845 goto err_wrong_format
;
2848 /* Set arch_info to alpha. */
2850 if (! bfd_default_set_arch_mach (abfd
, bfd_arch_alpha
, 0))
2851 goto err_wrong_format
;
2856 bfd_set_error (bfd_error_wrong_format
);
2859 alpha_vms_free_private (abfd
);
2860 if (abfd
->tdata
.any
!= tdata_save
&& abfd
->tdata
.any
!= NULL
)
2861 bfd_release (abfd
, abfd
->tdata
.any
);
2862 abfd
->tdata
.any
= tdata_save
;
2868 /* Write an EMH/MHD record. */
2871 _bfd_vms_write_emh (bfd
*abfd
)
2873 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2875 _bfd_vms_output_alignment (recwr
, 2);
2878 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
2879 _bfd_vms_output_short (recwr
, EMH__C_MHD
);
2880 _bfd_vms_output_short (recwr
, EOBJ__C_STRLVL
);
2881 _bfd_vms_output_long (recwr
, 0);
2882 _bfd_vms_output_long (recwr
, 0);
2883 _bfd_vms_output_long (recwr
, MAX_OUTREC_SIZE
);
2885 /* Create module name from filename. */
2886 if (bfd_get_filename (abfd
) != 0)
2888 char *module
= vms_get_module_name (bfd_get_filename (abfd
), TRUE
);
2889 _bfd_vms_output_counted (recwr
, module
);
2893 _bfd_vms_output_counted (recwr
, "NONAME");
2895 _bfd_vms_output_counted (recwr
, BFD_VERSION_STRING
);
2896 _bfd_vms_output_dump (recwr
, get_vms_time_string (), EMH_DATE_LENGTH
);
2897 _bfd_vms_output_fill (recwr
, 0, EMH_DATE_LENGTH
);
2898 _bfd_vms_output_end (abfd
, recwr
);
2901 /* Write an EMH/LMN record. */
2904 _bfd_vms_write_lmn (bfd
*abfd
, const char *name
)
2907 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2908 unsigned int ver
= BFD_VERSION
/ 10000;
2911 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
2912 _bfd_vms_output_short (recwr
, EMH__C_LNM
);
2913 snprintf (version
, sizeof (version
), "%s %d.%d.%d", name
,
2914 ver
/ 10000, (ver
/ 100) % 100, ver
% 100);
2915 _bfd_vms_output_dump (recwr
, (unsigned char *)version
, strlen (version
));
2916 _bfd_vms_output_end (abfd
, recwr
);
2920 /* Write eom record for bfd abfd. Return FALSE on error. */
2923 _bfd_vms_write_eeom (bfd
*abfd
)
2925 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2927 vms_debug2 ((2, "vms_write_eeom\n"));
2929 _bfd_vms_output_alignment (recwr
, 2);
2931 _bfd_vms_output_begin (recwr
, EOBJ__C_EEOM
);
2932 _bfd_vms_output_long (recwr
, PRIV (vms_linkage_index
+ 1) >> 1);
2933 _bfd_vms_output_byte (recwr
, 0); /* Completion code. */
2934 _bfd_vms_output_byte (recwr
, 0); /* Fill byte. */
2936 if ((abfd
->flags
& EXEC_P
) == 0
2937 && bfd_get_start_address (abfd
) != (bfd_vma
)-1)
2941 section
= bfd_get_section_by_name (abfd
, ".link");
2944 bfd_set_error (bfd_error_nonrepresentable_section
);
2947 _bfd_vms_output_short (recwr
, 0);
2948 _bfd_vms_output_long (recwr
, (unsigned long) section
->target_index
);
2949 _bfd_vms_output_long (recwr
,
2950 (unsigned long) bfd_get_start_address (abfd
));
2951 _bfd_vms_output_long (recwr
, 0);
2954 _bfd_vms_output_end (abfd
, recwr
);
2959 vector_grow1 (struct vector_type
*vec
, size_t elsz
)
2961 if (vec
->nbr_el
>= vec
->max_el
)
2963 if (vec
->max_el
== 0)
2966 vec
->els
= bfd_malloc2 (vec
->max_el
, elsz
);
2970 if (vec
->max_el
> -1u / 2)
2972 bfd_set_error (bfd_error_file_too_big
);
2976 vec
->els
= bfd_realloc2 (vec
->els
, vec
->max_el
, elsz
);
2979 if (vec
->els
== NULL
)
2981 return (char *) vec
->els
+ elsz
* vec
->nbr_el
++;
2984 /* Bump ABFD file position to next block. */
2987 alpha_vms_file_position_block (bfd
*abfd
)
2990 PRIV (file_pos
) += VMS_BLOCK_SIZE
- 1;
2991 PRIV (file_pos
) -= (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
2994 /* Convert from internal structure SRC to external structure DST. */
2997 alpha_vms_swap_eisd_out (struct vms_internal_eisd_map
*src
,
2998 struct vms_eisd
*dst
)
3000 bfd_putl32 (src
->u
.eisd
.majorid
, dst
->majorid
);
3001 bfd_putl32 (src
->u
.eisd
.minorid
, dst
->minorid
);
3002 bfd_putl32 (src
->u
.eisd
.eisdsize
, dst
->eisdsize
);
3003 if (src
->u
.eisd
.eisdsize
<= EISD__K_LENEND
)
3005 bfd_putl32 (src
->u
.eisd
.secsize
, dst
->secsize
);
3006 bfd_putl64 (src
->u
.eisd
.virt_addr
, dst
->virt_addr
);
3007 bfd_putl32 (src
->u
.eisd
.flags
, dst
->flags
);
3008 bfd_putl32 (src
->u
.eisd
.vbn
, dst
->vbn
);
3009 dst
->pfc
= src
->u
.eisd
.pfc
;
3010 dst
->matchctl
= src
->u
.eisd
.matchctl
;
3011 dst
->type
= src
->u
.eisd
.type
;
3013 if (src
->u
.eisd
.flags
& EISD__M_GBL
)
3015 bfd_putl32 (src
->u
.gbl_eisd
.ident
, dst
->ident
);
3016 memcpy (dst
->gblnam
, src
->u
.gbl_eisd
.gblnam
,
3017 src
->u
.gbl_eisd
.gblnam
[0] + 1);
3021 /* Append EISD to the list of extra eisd for ABFD. */
3024 alpha_vms_append_extra_eisd (bfd
*abfd
, struct vms_internal_eisd_map
*eisd
)
3027 if (PRIV (gbl_eisd_head
) == NULL
)
3028 PRIV (gbl_eisd_head
) = eisd
;
3030 PRIV (gbl_eisd_tail
)->next
= eisd
;
3031 PRIV (gbl_eisd_tail
) = eisd
;
3034 /* Create an EISD for shared image SHRIMG.
3035 Return FALSE in case of error. */
3038 alpha_vms_create_eisd_for_shared (bfd
*abfd
, bfd
*shrimg
)
3040 struct vms_internal_eisd_map
*eisd
;
3043 namlen
= strlen (PRIV2 (shrimg
, hdr_data
.hdr_t_name
));
3044 if (namlen
+ 5 > EISD__K_GBLNAMLEN
)
3050 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
3054 /* Fill the fields. */
3055 eisd
->u
.gbl_eisd
.common
.majorid
= EISD__K_MAJORID
;
3056 eisd
->u
.gbl_eisd
.common
.minorid
= EISD__K_MINORID
;
3057 eisd
->u
.gbl_eisd
.common
.eisdsize
= (EISD__K_LEN
+ 4 + namlen
+ 5 + 3) & ~3;
3058 eisd
->u
.gbl_eisd
.common
.secsize
= VMS_BLOCK_SIZE
; /* Must not be 0. */
3059 eisd
->u
.gbl_eisd
.common
.virt_addr
= 0;
3060 eisd
->u
.gbl_eisd
.common
.flags
= EISD__M_GBL
;
3061 eisd
->u
.gbl_eisd
.common
.vbn
= 0;
3062 eisd
->u
.gbl_eisd
.common
.pfc
= 0;
3063 eisd
->u
.gbl_eisd
.common
.matchctl
= PRIV2 (shrimg
, matchctl
);
3064 eisd
->u
.gbl_eisd
.common
.type
= EISD__K_SHRPIC
;
3066 eisd
->u
.gbl_eisd
.ident
= PRIV2 (shrimg
, ident
);
3067 eisd
->u
.gbl_eisd
.gblnam
[0] = namlen
+ 4;
3068 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1, PRIV2 (shrimg
, hdr_data
.hdr_t_name
),
3070 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1 + namlen
, "_001", 4);
3072 /* Append it to the list. */
3073 alpha_vms_append_extra_eisd (abfd
, eisd
);
3078 /* Create an EISD for section SEC.
3079 Return FALSE in case of failure. */
3082 alpha_vms_create_eisd_for_section (bfd
*abfd
, asection
*sec
)
3084 struct vms_internal_eisd_map
*eisd
;
3086 /* Only for allocating section. */
3087 if (!(sec
->flags
& SEC_ALLOC
))
3090 BFD_ASSERT (vms_section_data (sec
)->eisd
== NULL
);
3091 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
3094 vms_section_data (sec
)->eisd
= eisd
;
3096 /* Fill the fields. */
3097 eisd
->u
.eisd
.majorid
= EISD__K_MAJORID
;
3098 eisd
->u
.eisd
.minorid
= EISD__K_MINORID
;
3099 eisd
->u
.eisd
.eisdsize
= EISD__K_LEN
;
3100 eisd
->u
.eisd
.secsize
=
3101 (sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
3102 eisd
->u
.eisd
.virt_addr
= sec
->vma
;
3103 eisd
->u
.eisd
.flags
= 0;
3104 eisd
->u
.eisd
.vbn
= 0; /* To be later defined. */
3105 eisd
->u
.eisd
.pfc
= 0; /* Default. */
3106 eisd
->u
.eisd
.matchctl
= EISD__K_MATALL
;
3107 eisd
->u
.eisd
.type
= EISD__K_NORMAL
;
3109 if (sec
->flags
& SEC_CODE
)
3110 eisd
->u
.eisd
.flags
|= EISD__M_EXE
;
3111 if (!(sec
->flags
& SEC_READONLY
))
3112 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
3114 /* If relocations or fixup will be applied, make this isect writeable. */
3115 if (sec
->flags
& SEC_RELOC
)
3116 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
3118 if (!(sec
->flags
& SEC_HAS_CONTENTS
))
3120 eisd
->u
.eisd
.flags
|= EISD__M_DZRO
;
3121 eisd
->u
.eisd
.flags
&= ~EISD__M_CRF
;
3123 if (sec
->flags
& SEC_LINKER_CREATED
)
3125 if (strcmp (sec
->name
, "$FIXUP$") == 0)
3126 eisd
->u
.eisd
.flags
|= EISD__M_FIXUPVEC
;
3129 /* Append it to the list. */
3131 if (PRIV (eisd_head
) == NULL
)
3132 PRIV (eisd_head
) = eisd
;
3134 PRIV (eisd_tail
)->next
= eisd
;
3135 PRIV (eisd_tail
) = eisd
;
3140 /* Layout executable ABFD and write it to the disk.
3141 Return FALSE in case of failure. */
3144 alpha_vms_write_exec (bfd
*abfd
)
3146 struct vms_eihd eihd
;
3147 struct vms_eiha
*eiha
;
3148 struct vms_eihi
*eihi
;
3149 struct vms_eihs
*eihs
= NULL
;
3151 struct vms_internal_eisd_map
*first_eisd
;
3152 struct vms_internal_eisd_map
*eisd
;
3155 file_ptr gst_filepos
= 0;
3156 unsigned int lnkflags
= 0;
3158 /* Build the EIHD. */
3159 PRIV (file_pos
) = EIHD__C_LENGTH
;
3161 memset (&eihd
, 0, sizeof (eihd
));
3162 memset (eihd
.fill_2
, 0xff, sizeof (eihd
.fill_2
));
3164 bfd_putl32 (EIHD__K_MAJORID
, eihd
.majorid
);
3165 bfd_putl32 (EIHD__K_MINORID
, eihd
.minorid
);
3167 bfd_putl32 (sizeof (eihd
), eihd
.size
);
3168 bfd_putl32 (0, eihd
.isdoff
);
3169 bfd_putl32 (0, eihd
.activoff
);
3170 bfd_putl32 (0, eihd
.symdbgoff
);
3171 bfd_putl32 (0, eihd
.imgidoff
);
3172 bfd_putl32 (0, eihd
.patchoff
);
3173 bfd_putl64 (0, eihd
.iafva
);
3174 bfd_putl32 (0, eihd
.version_array_off
);
3176 bfd_putl32 (EIHD__K_EXE
, eihd
.imgtype
);
3177 bfd_putl32 (0, eihd
.subtype
);
3179 bfd_putl32 (0, eihd
.imgiocnt
);
3180 bfd_putl32 (-1, eihd
.privreqs
);
3181 bfd_putl32 (-1, eihd
.privreqs
+ 4);
3183 bfd_putl32 ((sizeof (eihd
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
3185 bfd_putl32 (0, eihd
.ident
);
3186 bfd_putl32 (0, eihd
.sysver
);
3189 bfd_putl32 (0, eihd
.symvect_size
);
3190 bfd_putl32 (16, eihd
.virt_mem_block_size
);
3191 bfd_putl32 (0, eihd
.ext_fixup_off
);
3192 bfd_putl32 (0, eihd
.noopt_psect_off
);
3193 bfd_putl32 (-1, eihd
.alias
);
3196 eiha
= (struct vms_eiha
*)((char *) &eihd
+ PRIV (file_pos
));
3197 bfd_putl32 (PRIV (file_pos
), eihd
.activoff
);
3198 PRIV (file_pos
) += sizeof (struct vms_eiha
);
3200 bfd_putl32 (sizeof (struct vms_eiha
), eiha
->size
);
3201 bfd_putl32 (0, eiha
->spare
);
3202 bfd_putl64 (PRIV (transfer_address
[0]), eiha
->tfradr1
);
3203 bfd_putl64 (PRIV (transfer_address
[1]), eiha
->tfradr2
);
3204 bfd_putl64 (PRIV (transfer_address
[2]), eiha
->tfradr3
);
3205 bfd_putl64 (PRIV (transfer_address
[3]), eiha
->tfradr4
);
3206 bfd_putl64 (0, eiha
->inishr
);
3209 eihi
= (struct vms_eihi
*)((char *) &eihd
+ PRIV (file_pos
));
3210 bfd_putl32 (PRIV (file_pos
), eihd
.imgidoff
);
3211 PRIV (file_pos
) += sizeof (struct vms_eihi
);
3213 bfd_putl32 (EIHI__K_MAJORID
, eihi
->majorid
);
3214 bfd_putl32 (EIHI__K_MINORID
, eihi
->minorid
);
3219 /* Set module name. */
3220 module
= vms_get_module_name (bfd_get_filename (abfd
), TRUE
);
3221 len
= strlen (module
);
3222 if (len
> sizeof (eihi
->imgnam
) - 1)
3223 len
= sizeof (eihi
->imgnam
) - 1;
3224 eihi
->imgnam
[0] = len
;
3225 memcpy (eihi
->imgnam
+ 1, module
, len
);
3233 vms_get_time (&hi
, &lo
);
3234 bfd_putl32 (lo
, eihi
->linktime
+ 0);
3235 bfd_putl32 (hi
, eihi
->linktime
+ 4);
3238 eihi
->linkid
[0] = 0;
3239 eihi
->imgbid
[0] = 0;
3242 dst
= PRIV (dst_section
);
3243 dmt
= bfd_get_section_by_name (abfd
, "$DMT$");
3244 if (dst
!= NULL
&& dst
->size
!= 0)
3246 eihs
= (struct vms_eihs
*)((char *) &eihd
+ PRIV (file_pos
));
3247 bfd_putl32 (PRIV (file_pos
), eihd
.symdbgoff
);
3248 PRIV (file_pos
) += sizeof (struct vms_eihs
);
3250 bfd_putl32 (EIHS__K_MAJORID
, eihs
->majorid
);
3251 bfd_putl32 (EIHS__K_MINORID
, eihs
->minorid
);
3252 bfd_putl32 (0, eihs
->dstvbn
);
3253 bfd_putl32 (0, eihs
->dstsize
);
3254 bfd_putl32 (0, eihs
->gstvbn
);
3255 bfd_putl32 (0, eihs
->gstsize
);
3256 bfd_putl32 (0, eihs
->dmtvbn
);
3257 bfd_putl32 (0, eihs
->dmtsize
);
3260 /* One EISD per section. */
3261 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3263 if (!alpha_vms_create_eisd_for_section (abfd
, sec
))
3267 /* Merge section EIDS which extra ones. */
3268 if (PRIV (eisd_tail
))
3269 PRIV (eisd_tail
)->next
= PRIV (gbl_eisd_head
);
3271 PRIV (eisd_head
) = PRIV (gbl_eisd_head
);
3272 if (PRIV (gbl_eisd_tail
))
3273 PRIV (eisd_tail
) = PRIV (gbl_eisd_tail
);
3275 first_eisd
= PRIV (eisd_head
);
3277 /* Add end of eisd. */
3280 eisd
= bfd_zalloc (abfd
, sizeof (*eisd
));
3283 eisd
->u
.eisd
.majorid
= 0;
3284 eisd
->u
.eisd
.minorid
= 0;
3285 eisd
->u
.eisd
.eisdsize
= 0;
3286 alpha_vms_append_extra_eisd (abfd
, eisd
);
3289 /* Place EISD in the file. */
3290 for (eisd
= first_eisd
; eisd
; eisd
= eisd
->next
)
3292 file_ptr room
= VMS_BLOCK_SIZE
- (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
3294 /* First block is a little bit special: there is a word at the end. */
3295 if (PRIV (file_pos
) < VMS_BLOCK_SIZE
&& room
> 2)
3297 if (room
< eisd
->u
.eisd
.eisdsize
+ EISD__K_LENEND
)
3298 alpha_vms_file_position_block (abfd
);
3300 eisd
->file_pos
= PRIV (file_pos
);
3301 PRIV (file_pos
) += eisd
->u
.eisd
.eisdsize
;
3303 if (eisd
->u
.eisd
.flags
& EISD__M_FIXUPVEC
)
3304 bfd_putl64 (eisd
->u
.eisd
.virt_addr
, eihd
.iafva
);
3307 if (first_eisd
!= NULL
)
3309 bfd_putl32 (first_eisd
->file_pos
, eihd
.isdoff
);
3310 /* Real size of end of eisd marker. */
3311 PRIV (file_pos
) += EISD__K_LENEND
;
3314 bfd_putl32 (PRIV (file_pos
), eihd
.size
);
3315 bfd_putl32 ((PRIV (file_pos
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
3318 /* Place sections. */
3319 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3321 if (!(sec
->flags
& SEC_HAS_CONTENTS
))
3324 eisd
= vms_section_data (sec
)->eisd
;
3326 /* Align on a block. */
3327 alpha_vms_file_position_block (abfd
);
3328 sec
->filepos
= PRIV (file_pos
);
3331 eisd
->u
.eisd
.vbn
= (sec
->filepos
/ VMS_BLOCK_SIZE
) + 1;
3333 PRIV (file_pos
) += sec
->size
;
3337 if (eihs
!= NULL
&& dst
!= NULL
)
3339 bfd_putl32 ((dst
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dstvbn
);
3340 bfd_putl32 (dst
->size
, eihs
->dstsize
);
3344 lnkflags
|= EIHD__M_DBGDMT
;
3345 bfd_putl32 ((dmt
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dmtvbn
);
3346 bfd_putl32 (dmt
->size
, eihs
->dmtsize
);
3348 if (PRIV (gsd_sym_count
) != 0)
3350 alpha_vms_file_position_block (abfd
);
3351 gst_filepos
= PRIV (file_pos
);
3352 bfd_putl32 ((gst_filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->gstvbn
);
3353 bfd_putl32 ((PRIV (gsd_sym_count
) + 4) / 5 + 4, eihs
->gstsize
);
3357 /* Write EISD in hdr. */
3358 for (eisd
= first_eisd
; eisd
&& eisd
->file_pos
< VMS_BLOCK_SIZE
;
3360 alpha_vms_swap_eisd_out
3361 (eisd
, (struct vms_eisd
*)((char *)&eihd
+ eisd
->file_pos
));
3363 /* Write first block. */
3364 bfd_putl32 (lnkflags
, eihd
.lnkflags
);
3365 if (bfd_bwrite (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
3368 /* Write remaining eisd. */
3371 unsigned char blk
[VMS_BLOCK_SIZE
];
3372 struct vms_internal_eisd_map
*next_eisd
;
3374 memset (blk
, 0xff, sizeof (blk
));
3375 while (eisd
!= NULL
)
3377 alpha_vms_swap_eisd_out
3379 (struct vms_eisd
*)(blk
+ (eisd
->file_pos
% VMS_BLOCK_SIZE
)));
3381 next_eisd
= eisd
->next
;
3382 if (next_eisd
== NULL
3383 || (next_eisd
->file_pos
/ VMS_BLOCK_SIZE
3384 != eisd
->file_pos
/ VMS_BLOCK_SIZE
))
3386 if (bfd_bwrite (blk
, sizeof (blk
), abfd
) != sizeof (blk
))
3389 memset (blk
, 0xff, sizeof (blk
));
3395 /* Write sections. */
3396 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3398 unsigned char blk
[VMS_BLOCK_SIZE
];
3401 if (sec
->size
== 0 || !(sec
->flags
& SEC_HAS_CONTENTS
))
3403 if (bfd_bwrite (sec
->contents
, sec
->size
, abfd
) != sec
->size
)
3407 len
= VMS_BLOCK_SIZE
- sec
->size
% VMS_BLOCK_SIZE
;
3408 if (len
!= VMS_BLOCK_SIZE
)
3410 memset (blk
, 0, len
);
3411 if (bfd_bwrite (blk
, len
, abfd
) != len
)
3417 if (gst_filepos
!= 0)
3419 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3422 _bfd_vms_write_emh (abfd
);
3423 _bfd_vms_write_lmn (abfd
, "GNU LD");
3425 /* PSC for the absolute section. */
3426 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3427 _bfd_vms_output_long (recwr
, 0);
3428 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3429 _bfd_vms_output_short (recwr
, 0);
3430 _bfd_vms_output_short (recwr
, EGPS__V_PIC
| EGPS__V_LIB
| EGPS__V_RD
);
3431 _bfd_vms_output_long (recwr
, 0);
3432 _bfd_vms_output_counted (recwr
, ".$$ABS$$.");
3433 _bfd_vms_output_end_subrec (recwr
);
3434 _bfd_vms_output_end (abfd
, recwr
);
3436 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
3438 struct vms_symbol_entry
*sym
= PRIV (syms
)[i
];
3444 _bfd_vms_output_alignment (recwr
, 8);
3445 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3446 _bfd_vms_output_long (recwr
, 0);
3448 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYMG
);
3449 _bfd_vms_output_short (recwr
, 0); /* Data type, alignment. */
3450 _bfd_vms_output_short (recwr
, sym
->flags
);
3452 if (sym
->code_section
)
3453 ep
= alpha_vms_get_sym_value (sym
->code_section
, sym
->code_value
);
3456 BFD_ASSERT (sym
->code_value
== 0);
3459 val
= alpha_vms_get_sym_value (sym
->section
, sym
->value
);
3460 _bfd_vms_output_quad
3461 (recwr
, sym
->typ
== EGSD__C_SYMG
? sym
->symbol_vector
: val
);
3462 _bfd_vms_output_quad (recwr
, ep
);
3463 _bfd_vms_output_quad (recwr
, val
);
3464 _bfd_vms_output_long (recwr
, 0);
3465 _bfd_vms_output_counted (recwr
, sym
->name
);
3466 _bfd_vms_output_end_subrec (recwr
);
3468 _bfd_vms_output_end (abfd
, recwr
);
3471 _bfd_vms_output_end (abfd
, recwr
);
3473 if (!_bfd_vms_write_eeom (abfd
))
3481 /* Write section and symbol directory of bfd abfd. Return FALSE on error. */
3484 _bfd_vms_write_egsd (bfd
*abfd
)
3488 unsigned int symnum
;
3490 flagword new_flags
, old_flags
;
3491 int abs_section_index
= -1;
3492 unsigned int target_index
= 0;
3493 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3495 vms_debug2 ((2, "vms_write_egsd\n"));
3497 /* Egsd is quadword aligned. */
3498 _bfd_vms_output_alignment (recwr
, 8);
3500 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3501 _bfd_vms_output_long (recwr
, 0);
3503 /* Number sections. */
3504 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3506 if (section
->flags
& SEC_DEBUGGING
)
3508 if (!strcmp (section
->name
, ".vmsdebug"))
3510 section
->flags
|= SEC_DEBUGGING
;
3513 section
->target_index
= target_index
++;
3516 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3518 vms_debug2 ((3, "Section #%d %s, %d bytes\n",
3519 section
->target_index
, section
->name
, (int)section
->size
));
3521 /* Don't write out the VMS debug info section since it is in the
3522 ETBT and EDBG sections in etir. */
3523 if (section
->flags
& SEC_DEBUGGING
)
3526 /* 13 bytes egsd, max 31 chars name -> should be 44 bytes. */
3527 if (_bfd_vms_output_check (recwr
, 64) < 0)
3529 _bfd_vms_output_end (abfd
, recwr
);
3530 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3531 _bfd_vms_output_long (recwr
, 0);
3534 /* Don't know if this is necessary for the linker but for now it keeps
3535 vms_slurp_gsd happy. */
3536 sname
= section
->name
;
3539 /* Remove leading dot. */
3541 if ((*sname
== 't') && (strcmp (sname
, "text") == 0))
3542 sname
= EVAX_CODE_NAME
;
3543 else if ((*sname
== 'd') && (strcmp (sname
, "data") == 0))
3544 sname
= EVAX_DATA_NAME
;
3545 else if ((*sname
== 'b') && (strcmp (sname
, "bss") == 0))
3546 sname
= EVAX_BSS_NAME
;
3547 else if ((*sname
== 'l') && (strcmp (sname
, "link") == 0))
3548 sname
= EVAX_LINK_NAME
;
3549 else if ((*sname
== 'r') && (strcmp (sname
, "rdata") == 0))
3550 sname
= EVAX_READONLY_NAME
;
3551 else if ((*sname
== 'l') && (strcmp (sname
, "literal") == 0))
3552 sname
= EVAX_LITERAL_NAME
;
3553 else if ((*sname
== 'l') && (strcmp (sname
, "literals") == 0))
3554 sname
= EVAX_LITERALS_NAME
;
3555 else if ((*sname
== 'c') && (strcmp (sname
, "comm") == 0))
3556 sname
= EVAX_COMMON_NAME
;
3557 else if ((*sname
== 'l') && (strcmp (sname
, "lcomm") == 0))
3558 sname
= EVAX_LOCAL_NAME
;
3561 if (bfd_is_com_section (section
))
3562 new_flags
= (EGPS__V_OVR
| EGPS__V_REL
| EGPS__V_GBL
| EGPS__V_RD
3563 | EGPS__V_WRT
| EGPS__V_NOMOD
| EGPS__V_COM
);
3565 new_flags
= vms_esecflag_by_name (evax_section_flags
, sname
,
3568 /* Modify them as directed. */
3569 if (section
->flags
& SEC_READONLY
)
3570 new_flags
&= ~EGPS__V_WRT
;
3572 new_flags
&= ~vms_section_data (section
)->no_flags
;
3573 new_flags
|= vms_section_data (section
)->flags
;
3575 vms_debug2 ((3, "sec flags %x\n", section
->flags
));
3576 vms_debug2 ((3, "new_flags %x, _raw_size %lu\n",
3577 new_flags
, (unsigned long)section
->size
));
3579 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3580 _bfd_vms_output_short (recwr
, section
->alignment_power
& 0xff);
3581 _bfd_vms_output_short (recwr
, new_flags
);
3582 _bfd_vms_output_long (recwr
, (unsigned long) section
->size
);
3583 _bfd_vms_output_counted (recwr
, sname
);
3584 _bfd_vms_output_end_subrec (recwr
);
3586 /* If the section is an obsolute one, remind its index as it will be
3587 used later for absolute symbols. */
3588 if ((new_flags
& EGPS__V_REL
) == 0 && abs_section_index
< 0)
3589 abs_section_index
= section
->target_index
;
3592 /* Output symbols. */
3593 vms_debug2 ((3, "%d symbols found\n", abfd
->symcount
));
3595 bfd_set_start_address (abfd
, (bfd_vma
) -1);
3597 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3599 symbol
= abfd
->outsymbols
[symnum
];
3600 old_flags
= symbol
->flags
;
3602 /* Work-around a missing feature: consider __main as the main entry
3604 if (symbol
->name
[0] == '_' && strcmp (symbol
->name
, "__main") == 0)
3605 bfd_set_start_address (abfd
, (bfd_vma
)symbol
->value
);
3607 /* Only put in the GSD the global and the undefined symbols. */
3608 if (old_flags
& BSF_FILE
)
3611 if ((old_flags
& BSF_GLOBAL
) == 0 && !bfd_is_und_section (symbol
->section
))
3613 /* If the LIB$INITIIALIZE section is present, add a reference to
3614 LIB$INITIALIZE symbol. FIXME: this should be done explicitely
3615 in the assembly file. */
3616 if (!((old_flags
& BSF_SECTION_SYM
) != 0
3617 && strcmp (symbol
->section
->name
, "LIB$INITIALIZE") == 0))
3621 /* 13 bytes egsd, max 64 chars name -> should be 77 bytes. Add 16 more
3622 bytes for a possible ABS section. */
3623 if (_bfd_vms_output_check (recwr
, 80 + 16) < 0)
3625 _bfd_vms_output_end (abfd
, recwr
);
3626 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3627 _bfd_vms_output_long (recwr
, 0);
3630 if ((old_flags
& BSF_GLOBAL
) != 0
3631 && bfd_is_abs_section (symbol
->section
)
3632 && abs_section_index
<= 0)
3634 /* Create an absolute section if none was defined. It is highly
3635 unlikely that the name $ABS$ clashes with a user defined
3636 non-absolute section name. */
3637 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3638 _bfd_vms_output_short (recwr
, 4);
3639 _bfd_vms_output_short (recwr
, EGPS__V_SHR
);
3640 _bfd_vms_output_long (recwr
, 0);
3641 _bfd_vms_output_counted (recwr
, "$ABS$");
3642 _bfd_vms_output_end_subrec (recwr
);
3644 abs_section_index
= target_index
++;
3647 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYM
);
3649 /* Data type, alignment. */
3650 _bfd_vms_output_short (recwr
, 0);
3654 if (old_flags
& BSF_WEAK
)
3655 new_flags
|= EGSY__V_WEAK
;
3656 if (bfd_is_com_section (symbol
->section
)) /* .comm */
3657 new_flags
|= (EGSY__V_WEAK
| EGSY__V_COMM
);
3659 if (old_flags
& BSF_FUNCTION
)
3661 new_flags
|= EGSY__V_NORM
;
3662 new_flags
|= EGSY__V_REL
;
3664 if (old_flags
& BSF_GLOBAL
)
3666 new_flags
|= EGSY__V_DEF
;
3667 if (!bfd_is_abs_section (symbol
->section
))
3668 new_flags
|= EGSY__V_REL
;
3670 _bfd_vms_output_short (recwr
, new_flags
);
3672 if (old_flags
& BSF_GLOBAL
)
3674 /* Symbol definition. */
3675 bfd_vma code_address
= 0;
3676 unsigned long ca_psindx
= 0;
3677 unsigned long psindx
;
3679 if ((old_flags
& BSF_FUNCTION
) && symbol
->udata
.p
!= NULL
)
3684 ((struct evax_private_udata_struct
*)symbol
->udata
.p
)->enbsym
;
3685 code_address
= sym
->value
;
3686 ca_psindx
= sym
->section
->target_index
;
3688 if (bfd_is_abs_section (symbol
->section
))
3689 psindx
= abs_section_index
;
3691 psindx
= symbol
->section
->target_index
;
3693 _bfd_vms_output_quad (recwr
, symbol
->value
);
3694 _bfd_vms_output_quad (recwr
, code_address
);
3695 _bfd_vms_output_long (recwr
, ca_psindx
);
3696 _bfd_vms_output_long (recwr
, psindx
);
3698 _bfd_vms_output_counted (recwr
, symbol
->name
);
3700 _bfd_vms_output_end_subrec (recwr
);
3703 _bfd_vms_output_alignment (recwr
, 8);
3704 _bfd_vms_output_end (abfd
, recwr
);
3709 /* Write object header for bfd abfd. Return FALSE on error. */
3712 _bfd_vms_write_ehdr (bfd
*abfd
)
3715 unsigned int symnum
;
3716 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3718 vms_debug2 ((2, "vms_write_ehdr (%p)\n", abfd
));
3720 _bfd_vms_output_alignment (recwr
, 2);
3722 _bfd_vms_write_emh (abfd
);
3723 _bfd_vms_write_lmn (abfd
, "GNU AS");
3726 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3727 _bfd_vms_output_short (recwr
, EMH__C_SRC
);
3729 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3731 symbol
= abfd
->outsymbols
[symnum
];
3733 if (symbol
->flags
& BSF_FILE
)
3735 _bfd_vms_output_dump (recwr
, (unsigned char *) symbol
->name
,
3736 (int) strlen (symbol
->name
));
3741 if (symnum
== abfd
->symcount
)
3742 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("noname"));
3744 _bfd_vms_output_end (abfd
, recwr
);
3747 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3748 _bfd_vms_output_short (recwr
, EMH__C_TTL
);
3749 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("TTL"));
3750 _bfd_vms_output_end (abfd
, recwr
);
3753 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3754 _bfd_vms_output_short (recwr
, EMH__C_CPR
);
3755 _bfd_vms_output_dump (recwr
,
3756 (unsigned char *)"GNU BFD ported by Klaus Kämpf 1994-1996",
3758 _bfd_vms_output_end (abfd
, recwr
);
3763 /* Part 4.6, relocations. */
3766 /* WRITE ETIR SECTION
3768 This is still under construction and therefore not documented. */
3770 /* Close the etir/etbt record. */
3773 end_etir_record (bfd
* abfd
)
3775 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3777 _bfd_vms_output_end (abfd
, recwr
);
3781 start_etir_or_etbt_record (bfd
*abfd
, asection
*section
, bfd_vma offset
)
3783 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3785 if (section
->flags
& SEC_DEBUGGING
)
3787 _bfd_vms_output_begin (recwr
, EOBJ__C_ETBT
);
3791 /* Push start offset. */
3792 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3793 _bfd_vms_output_long (recwr
, (unsigned long) 0);
3794 _bfd_vms_output_end_subrec (recwr
);
3797 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_DFLOC
);
3798 _bfd_vms_output_end_subrec (recwr
);
3803 _bfd_vms_output_begin (recwr
, EOBJ__C_ETIR
);
3807 /* Push start offset. */
3808 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3809 _bfd_vms_output_long (recwr
, (unsigned long) section
->target_index
);
3810 _bfd_vms_output_quad (recwr
, offset
);
3811 _bfd_vms_output_end_subrec (recwr
);
3813 /* Start = pop (). */
3814 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_SETRB
);
3815 _bfd_vms_output_end_subrec (recwr
);
3820 /* Output a STO_IMM command for SSIZE bytes of data from CPR at virtual
3821 address VADDR in section specified by SEC_INDEX and NAME. */
3824 sto_imm (bfd
*abfd
, asection
*section
,
3825 bfd_size_type ssize
, unsigned char *cptr
, bfd_vma vaddr
)
3828 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3831 _bfd_vms_debug (8, "sto_imm %d bytes\n", (int) ssize
);
3832 _bfd_hexdump (9, cptr
, (int) ssize
, (int) vaddr
);
3837 /* Try all the rest. */
3840 if (_bfd_vms_output_check (recwr
, size
) < 0)
3842 /* Doesn't fit, split ! */
3843 end_etir_record (abfd
);
3845 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3847 size
= _bfd_vms_output_check (recwr
, 0); /* get max size */
3848 if (size
> ssize
) /* more than what's left ? */
3852 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_IMM
);
3853 _bfd_vms_output_long (recwr
, (unsigned long) (size
));
3854 _bfd_vms_output_dump (recwr
, cptr
, size
);
3855 _bfd_vms_output_end_subrec (recwr
);
3858 _bfd_vms_debug (10, "dumped %d bytes\n", (int) size
);
3859 _bfd_hexdump (10, cptr
, (int) size
, (int) vaddr
);
3869 etir_output_check (bfd
*abfd
, asection
*section
, bfd_vma vaddr
, int checklen
)
3871 if (_bfd_vms_output_check (&PRIV (recwr
), checklen
) < 0)
3873 /* Not enough room in this record. Close it and open a new one. */
3874 end_etir_record (abfd
);
3875 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3879 /* Return whether RELOC must be deferred till the end. */
3882 defer_reloc_p (arelent
*reloc
)
3884 switch (reloc
->howto
->type
)
3897 /* Write section contents for bfd abfd. Return FALSE on error. */
3900 _bfd_vms_write_etir (bfd
* abfd
, int objtype ATTRIBUTE_UNUSED
)
3903 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3905 vms_debug2 ((2, "vms_write_tir (%p, %d)\n", abfd
, objtype
));
3907 _bfd_vms_output_alignment (recwr
, 4);
3909 PRIV (vms_linkage_index
) = 0;
3911 for (section
= abfd
->sections
; section
; section
= section
->next
)
3913 vms_debug2 ((4, "writing %d. section '%s' (%d bytes)\n",
3914 section
->target_index
, section
->name
, (int) (section
->size
)));
3916 if (!(section
->flags
& SEC_HAS_CONTENTS
)
3917 || bfd_is_com_section (section
))
3920 if (!section
->contents
)
3922 bfd_set_error (bfd_error_no_contents
);
3926 start_etir_or_etbt_record (abfd
, section
, 0);
3928 if (section
->flags
& SEC_RELOC
)
3930 bfd_vma curr_addr
= 0;
3931 unsigned char *curr_data
= section
->contents
;
3933 int pass2_needed
= 0;
3934 int pass2_in_progress
= 0;
3937 if (section
->reloc_count
== 0)
3939 (_("SEC_RELOC with no relocs in section %pA"), section
);
3944 int i
= section
->reloc_count
;
3945 arelent
**rptr
= section
->orelocation
;
3946 _bfd_vms_debug (4, "%d relocations:\n", i
);
3949 _bfd_vms_debug (4, "sym %s in sec %s, value %08lx, "
3950 "addr %08lx, off %08lx, len %d: %s\n",
3951 (*(*rptr
)->sym_ptr_ptr
)->name
,
3952 (*(*rptr
)->sym_ptr_ptr
)->section
->name
,
3953 (long) (*(*rptr
)->sym_ptr_ptr
)->value
,
3954 (unsigned long)(*rptr
)->address
,
3955 (unsigned long)(*rptr
)->addend
,
3956 bfd_get_reloc_size ((*rptr
)->howto
),
3957 ( *rptr
)->howto
->name
);
3964 for (irel
= 0; irel
< section
->reloc_count
; irel
++)
3966 struct evax_private_udata_struct
*udata
;
3967 arelent
*rptr
= section
->orelocation
[irel
];
3968 bfd_vma addr
= rptr
->address
;
3969 asymbol
*sym
= *rptr
->sym_ptr_ptr
;
3970 asection
*sec
= sym
->section
;
3971 bfd_boolean defer
= defer_reloc_p (rptr
);
3974 if (pass2_in_progress
)
3976 /* Non-deferred relocs have already been output. */
3982 /* Deferred relocs must be output at the very end. */
3989 /* Regular relocs are intertwined with binary data. */
3990 if (curr_addr
> addr
)
3991 _bfd_error_handler (_("size error in section %pA"),
3993 size
= addr
- curr_addr
;
3994 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
3999 size
= bfd_get_reloc_size (rptr
->howto
);
4001 switch (rptr
->howto
->type
)
4003 case ALPHA_R_IGNORE
:
4006 case ALPHA_R_REFLONG
:
4007 if (bfd_is_und_section (sym
->section
))
4009 bfd_vma addend
= rptr
->addend
;
4010 slen
= strlen ((char *) sym
->name
);
4011 etir_output_check (abfd
, section
, curr_addr
, slen
);
4014 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
4015 _bfd_vms_output_counted (recwr
, sym
->name
);
4016 _bfd_vms_output_end_subrec (recwr
);
4017 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
4018 _bfd_vms_output_long (recwr
, (unsigned long) addend
);
4019 _bfd_vms_output_end_subrec (recwr
);
4020 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
4021 _bfd_vms_output_end_subrec (recwr
);
4022 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
4023 _bfd_vms_output_end_subrec (recwr
);
4027 _bfd_vms_output_begin_subrec
4028 (recwr
, ETIR__C_STO_GBL_LW
);
4029 _bfd_vms_output_counted (recwr
, sym
->name
);
4030 _bfd_vms_output_end_subrec (recwr
);
4033 else if (bfd_is_abs_section (sym
->section
))
4035 etir_output_check (abfd
, section
, curr_addr
, 16);
4036 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
4037 _bfd_vms_output_long (recwr
, (unsigned long) sym
->value
);
4038 _bfd_vms_output_end_subrec (recwr
);
4039 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
4040 _bfd_vms_output_end_subrec (recwr
);
4044 etir_output_check (abfd
, section
, curr_addr
, 32);
4045 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
4046 _bfd_vms_output_long (recwr
,
4047 (unsigned long) sec
->target_index
);
4048 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
4049 _bfd_vms_output_end_subrec (recwr
);
4050 /* ??? Table B-8 of the OpenVMS Linker Utilily Manual
4051 says that we should have a ETIR__C_STO_OFF here.
4052 But the relocation would not be BFD_RELOC_32 then.
4053 This case is very likely unreachable. */
4054 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
4055 _bfd_vms_output_end_subrec (recwr
);
4059 case ALPHA_R_REFQUAD
:
4060 if (bfd_is_und_section (sym
->section
))
4062 bfd_vma addend
= rptr
->addend
;
4063 slen
= strlen ((char *) sym
->name
);
4064 etir_output_check (abfd
, section
, curr_addr
, slen
);
4067 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
4068 _bfd_vms_output_counted (recwr
, sym
->name
);
4069 _bfd_vms_output_end_subrec (recwr
);
4070 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
4071 _bfd_vms_output_quad (recwr
, addend
);
4072 _bfd_vms_output_end_subrec (recwr
);
4073 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
4074 _bfd_vms_output_end_subrec (recwr
);
4075 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
4076 _bfd_vms_output_end_subrec (recwr
);
4080 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_GBL
);
4081 _bfd_vms_output_counted (recwr
, sym
->name
);
4082 _bfd_vms_output_end_subrec (recwr
);
4085 else if (bfd_is_abs_section (sym
->section
))
4087 etir_output_check (abfd
, section
, curr_addr
, 16);
4088 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
4089 _bfd_vms_output_quad (recwr
, sym
->value
);
4090 _bfd_vms_output_end_subrec (recwr
);
4091 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
4092 _bfd_vms_output_end_subrec (recwr
);
4096 etir_output_check (abfd
, section
, curr_addr
, 32);
4097 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
4098 _bfd_vms_output_long (recwr
,
4099 (unsigned long) sec
->target_index
);
4100 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
4101 _bfd_vms_output_end_subrec (recwr
);
4102 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_OFF
);
4103 _bfd_vms_output_end_subrec (recwr
);
4108 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
4111 case ALPHA_R_LINKAGE
:
4113 etir_output_check (abfd
, section
, curr_addr
, 64);
4114 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LP_PSB
);
4115 _bfd_vms_output_long
4116 (recwr
, (unsigned long) rptr
->addend
);
4117 if (rptr
->addend
> PRIV (vms_linkage_index
))
4118 PRIV (vms_linkage_index
) = rptr
->addend
;
4119 _bfd_vms_output_counted (recwr
, sym
->name
);
4120 _bfd_vms_output_byte (recwr
, 0);
4121 _bfd_vms_output_end_subrec (recwr
);
4124 case ALPHA_R_CODEADDR
:
4125 slen
= strlen ((char *) sym
->name
);
4126 etir_output_check (abfd
, section
, curr_addr
, slen
);
4127 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_CA
);
4128 _bfd_vms_output_counted (recwr
, sym
->name
);
4129 _bfd_vms_output_end_subrec (recwr
);
4134 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4135 etir_output_check (abfd
, section
, curr_addr
,
4136 32 + 1 + strlen (udata
->origname
));
4137 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_NOP_GBL
);
4138 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
4139 _bfd_vms_output_long
4140 (recwr
, (unsigned long) section
->target_index
);
4141 _bfd_vms_output_quad (recwr
, rptr
->address
);
4142 _bfd_vms_output_long (recwr
, (unsigned long) 0x47ff041f);
4143 _bfd_vms_output_long
4144 (recwr
, (unsigned long) section
->target_index
);
4145 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4146 _bfd_vms_output_counted (recwr
, udata
->origname
);
4147 _bfd_vms_output_end_subrec (recwr
);
4151 _bfd_error_handler (_("spurious ALPHA_R_BSR reloc"));
4156 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4157 etir_output_check (abfd
, section
, curr_addr
,
4158 32 + 1 + strlen (udata
->origname
));
4159 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LDA_GBL
);
4160 _bfd_vms_output_long
4161 (recwr
, (unsigned long) udata
->lkindex
+ 1);
4162 _bfd_vms_output_long
4163 (recwr
, (unsigned long) section
->target_index
);
4164 _bfd_vms_output_quad (recwr
, rptr
->address
);
4165 _bfd_vms_output_long (recwr
, (unsigned long) 0x237B0000);
4166 _bfd_vms_output_long
4167 (recwr
, (unsigned long) udata
->bsym
->section
->target_index
);
4168 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4169 _bfd_vms_output_counted (recwr
, udata
->origname
);
4170 _bfd_vms_output_end_subrec (recwr
);
4175 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4176 etir_output_check (abfd
, section
, curr_addr
,
4177 32 + 1 + strlen (udata
->origname
));
4178 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_BOH_GBL
);
4179 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
4180 _bfd_vms_output_long
4181 (recwr
, (unsigned long) section
->target_index
);
4182 _bfd_vms_output_quad (recwr
, rptr
->address
);
4183 _bfd_vms_output_long (recwr
, (unsigned long) 0xD3400000);
4184 _bfd_vms_output_long
4185 (recwr
, (unsigned long) section
->target_index
);
4186 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4187 _bfd_vms_output_counted (recwr
, udata
->origname
);
4188 _bfd_vms_output_end_subrec (recwr
);
4192 _bfd_error_handler (_("unhandled relocation %s"),
4199 } /* End of relocs loop. */
4201 if (!pass2_in_progress
)
4203 /* Output rest of section. */
4204 if (curr_addr
> section
->size
)
4206 _bfd_error_handler (_("size error in section %pA"), section
);
4209 size
= section
->size
- curr_addr
;
4210 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
4216 pass2_in_progress
= 1;
4222 else /* (section->flags & SEC_RELOC) */
4223 sto_imm (abfd
, section
, section
->size
, section
->contents
, 0);
4225 end_etir_record (abfd
);
4228 _bfd_vms_output_alignment (recwr
, 2);
4232 /* Write cached information into a file being written, at bfd_close. */
4235 alpha_vms_write_object_contents (bfd
*abfd
)
4237 vms_debug2 ((1, "vms_write_object_contents (%p)\n", abfd
));
4239 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
4241 return alpha_vms_write_exec (abfd
);
4245 if (abfd
->section_count
> 0) /* we have sections */
4247 if (!_bfd_vms_write_ehdr (abfd
))
4249 if (!_bfd_vms_write_egsd (abfd
))
4251 if (!_bfd_vms_write_etir (abfd
, EOBJ__C_ETIR
))
4253 if (!_bfd_vms_write_eeom (abfd
))
4260 /* Debug stuff: nearest line. */
4262 #define SET_MODULE_PARSED(m) \
4263 do { if ((m)->name == NULL) (m)->name = ""; } while (0)
4264 #define IS_MODULE_PARSED(m) ((m)->name != NULL)
4266 /* Build a new module for the specified BFD. */
4268 static struct module
*
4269 new_module (bfd
*abfd
)
4271 struct module
*module
4272 = (struct module
*) bfd_zalloc (abfd
, sizeof (struct module
));
4273 module
->file_table_count
= 16; /* Arbitrary. */
4275 = bfd_malloc (module
->file_table_count
* sizeof (struct fileinfo
));
4279 /* Parse debug info for a module and internalize it. */
4282 parse_module (bfd
*abfd
, struct module
*module
, unsigned char *ptr
,
4285 unsigned char *maxptr
= ptr
+ length
;
4286 unsigned char *src_ptr
, *pcl_ptr
;
4287 unsigned int prev_linum
= 0, curr_linenum
= 0;
4288 bfd_vma prev_pc
= 0, curr_pc
= 0;
4289 struct srecinfo
*curr_srec
, *srec
;
4290 struct lineinfo
*curr_line
, *line
;
4291 struct funcinfo
*funcinfo
;
4293 /* Initialize tables with zero element. */
4294 curr_srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4295 module
->srec_table
= curr_srec
;
4297 curr_line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4298 module
->line_table
= curr_line
;
4300 while (length
== -1 || ptr
< maxptr
)
4302 /* The first byte is not counted in the recorded length. */
4303 int rec_length
= bfd_getl16 (ptr
) + 1;
4304 int rec_type
= bfd_getl16 (ptr
+ 2);
4306 vms_debug2 ((2, "DST record: leng %d, type %d\n", rec_length
, rec_type
));
4308 if (length
== -1 && rec_type
== DST__K_MODEND
)
4315 = _bfd_vms_save_counted_string (abfd
, ptr
+ DST_S_B_MODBEG_NAME
,
4316 maxptr
- (ptr
+ DST_S_B_MODBEG_NAME
));
4323 vms_debug2 ((3, "module: %s\n", module
->name
));
4330 funcinfo
= (struct funcinfo
*)
4331 bfd_zalloc (abfd
, sizeof (struct funcinfo
));
4333 = _bfd_vms_save_counted_string (abfd
, ptr
+ DST_S_B_RTNBEG_NAME
,
4334 maxptr
- (ptr
+ DST_S_B_RTNBEG_NAME
));
4335 funcinfo
->low
= bfd_getl32 (ptr
+ DST_S_L_RTNBEG_ADDRESS
);
4336 funcinfo
->next
= module
->func_table
;
4337 module
->func_table
= funcinfo
;
4339 vms_debug2 ((3, "routine: %s at 0x%lx\n",
4340 funcinfo
->name
, (unsigned long) funcinfo
->low
));
4344 module
->func_table
->high
= module
->func_table
->low
4345 + bfd_getl32 (ptr
+ DST_S_L_RTNEND_SIZE
) - 1;
4347 if (module
->func_table
->high
> module
->high
)
4348 module
->high
= module
->func_table
->high
;
4350 vms_debug2 ((3, "end routine\n"));
4354 vms_debug2 ((3, "prologue\n"));
4358 vms_debug2 ((3, "epilog\n"));
4362 vms_debug2 ((3, "block\n"));
4366 vms_debug2 ((3, "end block\n"));
4370 src_ptr
= ptr
+ DST_S_C_SOURCE_HEADER_SIZE
;
4372 vms_debug2 ((3, "source info\n"));
4374 while (src_ptr
< ptr
+ rec_length
)
4376 int cmd
= src_ptr
[0], cmd_length
, data
;
4380 case DST__K_SRC_DECLFILE
:
4383 = bfd_getl16 (src_ptr
+ DST_S_W_SRC_DF_FILEID
);
4384 char *filename
= _bfd_vms_save_counted_string
4386 src_ptr
+ DST_S_B_SRC_DF_FILENAME
,
4387 ptr
+ rec_length
- (src_ptr
+ DST_S_B_SRC_DF_FILENAME
));
4389 while (fileid
>= module
->file_table_count
)
4391 module
->file_table_count
*= 2;
4393 = bfd_realloc (module
->file_table
,
4394 module
->file_table_count
4395 * sizeof (struct fileinfo
));
4398 module
->file_table
[fileid
].name
= filename
;
4399 module
->file_table
[fileid
].srec
= 1;
4400 cmd_length
= src_ptr
[DST_S_B_SRC_DF_LENGTH
] + 2;
4401 vms_debug2 ((4, "DST_S_C_SRC_DECLFILE: %d, %s\n",
4402 fileid
, module
->file_table
[fileid
].name
));
4406 case DST__K_SRC_DEFLINES_B
:
4407 /* Perform the association and set the next higher index
4409 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4410 srec
= (struct srecinfo
*)
4411 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4412 srec
->line
= curr_srec
->line
+ data
;
4413 srec
->srec
= curr_srec
->srec
+ data
;
4414 srec
->sfile
= curr_srec
->sfile
;
4415 curr_srec
->next
= srec
;
4418 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_B: %d\n", data
));
4421 case DST__K_SRC_DEFLINES_W
:
4422 /* Perform the association and set the next higher index
4424 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4425 srec
= (struct srecinfo
*)
4426 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4427 srec
->line
= curr_srec
->line
+ data
;
4428 srec
->srec
= curr_srec
->srec
+ data
,
4429 srec
->sfile
= curr_srec
->sfile
;
4430 curr_srec
->next
= srec
;
4433 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_W: %d\n", data
));
4436 case DST__K_SRC_INCRLNUM_B
:
4437 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4438 curr_srec
->line
+= data
;
4440 vms_debug2 ((4, "DST_S_C_SRC_INCRLNUM_B: %d\n", data
));
4443 case DST__K_SRC_SETFILE
:
4444 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4445 curr_srec
->sfile
= data
;
4446 curr_srec
->srec
= module
->file_table
[data
].srec
;
4448 vms_debug2 ((4, "DST_S_C_SRC_SETFILE: %d\n", data
));
4451 case DST__K_SRC_SETLNUM_L
:
4452 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4453 curr_srec
->line
= data
;
4455 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_L: %d\n", data
));
4458 case DST__K_SRC_SETLNUM_W
:
4459 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4460 curr_srec
->line
= data
;
4462 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_W: %d\n", data
));
4465 case DST__K_SRC_SETREC_L
:
4466 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4467 curr_srec
->srec
= data
;
4468 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4470 vms_debug2 ((4, "DST_S_C_SRC_SETREC_L: %d\n", data
));
4473 case DST__K_SRC_SETREC_W
:
4474 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4475 curr_srec
->srec
= data
;
4476 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4478 vms_debug2 ((4, "DST_S_C_SRC_SETREC_W: %d\n", data
));
4481 case DST__K_SRC_FORMFEED
:
4483 vms_debug2 ((4, "DST_S_C_SRC_FORMFEED\n"));
4487 _bfd_error_handler (_("unknown source command %d"),
4493 src_ptr
+= cmd_length
;
4497 case DST__K_LINE_NUM
:
4498 pcl_ptr
= ptr
+ DST_S_C_LINE_NUM_HEADER_SIZE
;
4500 vms_debug2 ((3, "line info\n"));
4502 while (pcl_ptr
< ptr
+ rec_length
)
4504 /* The command byte is signed so we must sign-extend it. */
4505 int cmd
= ((signed char *)pcl_ptr
)[0], cmd_length
, data
;
4509 case DST__K_DELTA_PC_W
:
4510 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4514 vms_debug2 ((4, "DST__K_DELTA_PC_W: %d\n", data
));
4517 case DST__K_DELTA_PC_L
:
4518 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4522 vms_debug2 ((4, "DST__K_DELTA_PC_L: %d\n", data
));
4525 case DST__K_INCR_LINUM
:
4526 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4527 curr_linenum
+= data
;
4529 vms_debug2 ((4, "DST__K_INCR_LINUM: %d\n", data
));
4532 case DST__K_INCR_LINUM_W
:
4533 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4534 curr_linenum
+= data
;
4536 vms_debug2 ((4, "DST__K_INCR_LINUM_W: %d\n", data
));
4539 case DST__K_INCR_LINUM_L
:
4540 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4541 curr_linenum
+= data
;
4543 vms_debug2 ((4, "DST__K_INCR_LINUM_L: %d\n", data
));
4546 case DST__K_SET_LINUM_INCR
:
4548 (_("%s not implemented"), "DST__K_SET_LINUM_INCR");
4552 case DST__K_SET_LINUM_INCR_W
:
4554 (_("%s not implemented"), "DST__K_SET_LINUM_INCR_W");
4558 case DST__K_RESET_LINUM_INCR
:
4560 (_("%s not implemented"), "DST__K_RESET_LINUM_INCR");
4564 case DST__K_BEG_STMT_MODE
:
4566 (_("%s not implemented"), "DST__K_BEG_STMT_MODE");
4570 case DST__K_END_STMT_MODE
:
4572 (_("%s not implemented"), "DST__K_END_STMT_MODE");
4576 case DST__K_SET_LINUM_B
:
4577 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4578 curr_linenum
= data
;
4580 vms_debug2 ((4, "DST__K_SET_LINUM_B: %d\n", data
));
4583 case DST__K_SET_LINUM
:
4584 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4585 curr_linenum
= data
;
4587 vms_debug2 ((4, "DST__K_SET_LINE_NUM: %d\n", data
));
4590 case DST__K_SET_LINUM_L
:
4591 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4592 curr_linenum
= data
;
4594 vms_debug2 ((4, "DST__K_SET_LINUM_L: %d\n", data
));
4599 (_("%s not implemented"), "DST__K_SET_PC");
4603 case DST__K_SET_PC_W
:
4605 (_("%s not implemented"), "DST__K_SET_PC_W");
4609 case DST__K_SET_PC_L
:
4611 (_("%s not implemented"), "DST__K_SET_PC_L");
4615 case DST__K_SET_STMTNUM
:
4617 (_("%s not implemented"), "DST__K_SET_STMTNUM");
4622 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4625 vms_debug2 ((4, "DST__K_TERM: %d\n", data
));
4629 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4632 vms_debug2 ((4, "DST__K_TERM_W: %d\n", data
));
4636 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4639 vms_debug2 ((4, "DST__K_TERM_L: %d\n", data
));
4642 case DST__K_SET_ABS_PC
:
4643 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4646 vms_debug2 ((4, "DST__K_SET_ABS_PC: 0x%x\n", data
));
4655 vms_debug2 ((4, "bump pc to 0x%lx and line to %d\n",
4656 (unsigned long)curr_pc
, curr_linenum
));
4660 _bfd_error_handler (_("unknown line command %d"), cmd
);
4666 if ((curr_linenum
!= prev_linum
&& curr_pc
!= prev_pc
)
4668 || cmd
== DST__K_DELTA_PC_L
4669 || cmd
== DST__K_DELTA_PC_W
)
4671 line
= (struct lineinfo
*)
4672 bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4673 line
->address
= curr_pc
;
4674 line
->line
= curr_linenum
;
4676 curr_line
->next
= line
;
4679 prev_linum
= curr_linenum
;
4681 vms_debug2 ((4, "-> correlate pc 0x%lx with line %d\n",
4682 (unsigned long)curr_pc
, curr_linenum
));
4685 pcl_ptr
+= cmd_length
;
4689 case 0x17: /* Undocumented type used by DEC C to declare equates. */
4690 vms_debug2 ((3, "undocumented type 0x17\n"));
4694 vms_debug2 ((3, "ignoring record\n"));
4702 /* Finalize tables with EOL marker. */
4703 srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4704 srec
->line
= (unsigned int) -1;
4705 srec
->srec
= (unsigned int) -1;
4706 curr_srec
->next
= srec
;
4708 line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4709 line
->line
= (unsigned int) -1;
4710 line
->address
= (bfd_vma
) -1;
4711 curr_line
->next
= line
;
4713 /* Advertise that this module has been parsed. This is needed
4714 because parsing can be either performed at module creation
4715 or deferred until debug info is consumed. */
4716 SET_MODULE_PARSED (module
);
4719 /* Build the list of modules for the specified BFD. */
4721 static struct module
*
4722 build_module_list (bfd
*abfd
)
4724 struct module
*module
, *list
= NULL
;
4727 if ((dmt
= bfd_get_section_by_name (abfd
, "$DMT$")))
4729 /* We have a DMT section so this must be an image. Parse the
4730 section and build the list of modules. This is sufficient
4731 since we can compute the start address and the end address
4732 of every module from the section contents. */
4733 bfd_size_type size
= bfd_section_size (dmt
);
4734 unsigned char *ptr
, *end
;
4736 ptr
= (unsigned char *) bfd_alloc (abfd
, size
);
4740 if (! bfd_get_section_contents (abfd
, dmt
, ptr
, 0, size
))
4743 vms_debug2 ((2, "DMT\n"));
4749 /* Each header declares a module with its start offset and size
4750 of debug info in the DST section, as well as the count of
4751 program sections (i.e. address spans) it contains. */
4752 int modbeg
= bfd_getl32 (ptr
+ DBG_S_L_DMT_MODBEG
);
4753 int msize
= bfd_getl32 (ptr
+ DBG_S_L_DST_SIZE
);
4754 int count
= bfd_getl16 (ptr
+ DBG_S_W_DMT_PSECT_COUNT
);
4755 ptr
+= DBG_S_C_DMT_HEADER_SIZE
;
4757 vms_debug2 ((3, "module: modbeg = %d, size = %d, count = %d\n",
4758 modbeg
, msize
, count
));
4760 /* We create a 'module' structure for each program section since
4761 we only support contiguous addresses in a 'module' structure.
4762 As a consequence, the actual debug info in the DST section is
4763 shared and can be parsed multiple times; that doesn't seem to
4764 cause problems in practice. */
4767 int start
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_START
);
4768 int length
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_LENGTH
);
4769 module
= new_module (abfd
);
4770 module
->modbeg
= modbeg
;
4771 module
->size
= msize
;
4772 module
->low
= start
;
4773 module
->high
= start
+ length
;
4774 module
->next
= list
;
4776 ptr
+= DBG_S_C_DMT_PSECT_SIZE
;
4778 vms_debug2 ((4, "section: start = 0x%x, length = %d\n",
4785 /* We don't have a DMT section so this must be an object. Parse
4786 the module right now in order to compute its start address and
4788 void *dst
= PRIV (dst_section
)->contents
;
4793 module
= new_module (abfd
);
4794 parse_module (abfd
, module
, PRIV (dst_section
)->contents
, -1);
4801 /* Calculate and return the name of the source file and the line nearest
4802 to the wanted location in the specified module. */
4805 module_find_nearest_line (bfd
*abfd
, struct module
*module
, bfd_vma addr
,
4806 const char **file
, const char **func
,
4809 struct funcinfo
*funcinfo
;
4810 struct lineinfo
*lineinfo
;
4811 struct srecinfo
*srecinfo
;
4812 bfd_boolean ret
= FALSE
;
4814 /* Parse this module if that was not done at module creation. */
4815 if (! IS_MODULE_PARSED (module
))
4817 unsigned int size
= module
->size
;
4818 unsigned int modbeg
= PRIV (dst_section
)->filepos
+ module
->modbeg
;
4819 unsigned char *buffer
= (unsigned char *) bfd_malloc (module
->size
);
4821 if (bfd_seek (abfd
, modbeg
, SEEK_SET
) != 0
4822 || bfd_bread (buffer
, size
, abfd
) != size
)
4824 bfd_set_error (bfd_error_no_debug_section
);
4828 parse_module (abfd
, module
, buffer
, size
);
4832 /* Find out the function (if any) that contains the address. */
4833 for (funcinfo
= module
->func_table
; funcinfo
; funcinfo
= funcinfo
->next
)
4834 if (addr
>= funcinfo
->low
&& addr
<= funcinfo
->high
)
4836 *func
= funcinfo
->name
;
4841 /* Find out the source file and the line nearest to the address. */
4842 for (lineinfo
= module
->line_table
; lineinfo
; lineinfo
= lineinfo
->next
)
4843 if (lineinfo
->next
&& addr
< lineinfo
->next
->address
)
4845 for (srecinfo
= module
->srec_table
; srecinfo
; srecinfo
= srecinfo
->next
)
4846 if (srecinfo
->next
&& lineinfo
->line
< srecinfo
->next
->line
)
4848 if (srecinfo
->sfile
> 0)
4850 *file
= module
->file_table
[srecinfo
->sfile
].name
;
4851 *line
= srecinfo
->srec
+ lineinfo
->line
- srecinfo
->line
;
4855 *file
= module
->name
;
4856 *line
= lineinfo
->line
;
4867 /* Provided a BFD, a section and an offset into the section, calculate and
4868 return the name of the source file and the line nearest to the wanted
4872 _bfd_vms_find_nearest_line (bfd
*abfd
,
4873 asymbol
**symbols ATTRIBUTE_UNUSED
,
4879 unsigned int *discriminator
)
4881 struct module
*module
;
4883 /* What address are we looking for? */
4884 bfd_vma addr
= section
->vma
+ offset
;
4892 /* We can't do anything if there is no DST (debug symbol table). */
4893 if (PRIV (dst_section
) == NULL
)
4896 /* Create the module list - if not already done. */
4897 if (PRIV (modules
) == NULL
)
4899 PRIV (modules
) = build_module_list (abfd
);
4900 if (PRIV (modules
) == NULL
)
4904 for (module
= PRIV (modules
); module
; module
= module
->next
)
4905 if (addr
>= module
->low
&& addr
<= module
->high
)
4906 return module_find_nearest_line (abfd
, module
, addr
, file
, func
, line
);
4911 /* Canonicalizations. */
4912 /* Set name, value, section and flags of SYM from E. */
4915 alpha_vms_convert_symbol (bfd
*abfd
, struct vms_symbol_entry
*e
, asymbol
*sym
)
4924 flags
= BSF_NO_FLAGS
;
4930 if (e
->flags
& EGSY__V_WEAK
)
4933 if (e
->flags
& EGSY__V_DEF
)
4935 /* Symbol definition. */
4936 flags
|= BSF_GLOBAL
;
4937 if (e
->flags
& EGSY__V_NORM
)
4938 flags
|= BSF_FUNCTION
;
4944 /* Symbol reference. */
4945 sec
= bfd_und_section_ptr
;
4950 /* A universal symbol is by definition global... */
4951 flags
|= BSF_GLOBAL
;
4953 /* ...and dynamic in shared libraries. */
4954 if (abfd
->flags
& DYNAMIC
)
4955 flags
|= BSF_DYNAMIC
;
4957 if (e
->flags
& EGSY__V_WEAK
)
4960 if (!(e
->flags
& EGSY__V_DEF
))
4963 if (e
->flags
& EGSY__V_NORM
)
4964 flags
|= BSF_FUNCTION
;
4967 /* sec = e->section; */
4968 sec
= bfd_abs_section_ptr
;
4983 /* Return the number of bytes required to store a vector of pointers
4984 to asymbols for all the symbols in the BFD abfd, including a
4985 terminal NULL pointer. If there are no symbols in the BFD,
4986 then return 0. If an error occurs, return -1. */
4989 alpha_vms_get_symtab_upper_bound (bfd
*abfd
)
4991 vms_debug2 ((1, "alpha_vms_get_symtab_upper_bound (%p), %d symbols\n",
4992 abfd
, PRIV (gsd_sym_count
)));
4994 return (PRIV (gsd_sym_count
) + 1) * sizeof (asymbol
*);
4997 /* Read the symbols from the BFD abfd, and fills in the vector
4998 location with pointers to the symbols and a trailing NULL.
5000 Return number of symbols read. */
5003 alpha_vms_canonicalize_symtab (bfd
*abfd
, asymbol
**symbols
)
5007 vms_debug2 ((1, "alpha_vms_canonicalize_symtab (%p, <ret>)\n", abfd
));
5009 if (PRIV (csymbols
) == NULL
)
5011 PRIV (csymbols
) = (asymbol
**) bfd_alloc
5012 (abfd
, PRIV (gsd_sym_count
) * sizeof (asymbol
*));
5014 /* Traverse table and fill symbols vector. */
5015 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
5017 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
5020 sym
= bfd_make_empty_symbol (abfd
);
5021 if (sym
== NULL
|| !alpha_vms_convert_symbol (abfd
, e
, sym
))
5023 bfd_release (abfd
, PRIV (csymbols
));
5024 PRIV (csymbols
) = NULL
;
5028 PRIV (csymbols
)[i
] = sym
;
5032 if (symbols
!= NULL
)
5034 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
5035 symbols
[i
] = PRIV (csymbols
)[i
];
5039 return PRIV (gsd_sym_count
);
5042 /* Read and convert relocations from ETIR. We do it once for all sections. */
5045 alpha_vms_slurp_relocs (bfd
*abfd
)
5049 vms_debug2 ((3, "alpha_vms_slurp_relocs\n"));
5051 /* We slurp relocs only once, for all sections. */
5052 if (PRIV (reloc_done
))
5054 PRIV (reloc_done
) = TRUE
;
5056 if (alpha_vms_canonicalize_symtab (abfd
, NULL
) < 0)
5059 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
5064 unsigned char *begin
;
5067 bfd_reloc_code_real_type reloc_code
;
5073 bfd_vma cur_address
;
5075 unsigned char *cur_sym
= NULL
;
5077 bfd_vma cur_addend
= 0;
5079 /* Skip non-ETIR records. */
5080 type
= _bfd_vms_get_object_record (abfd
);
5081 if (type
== EOBJ__C_EEOM
)
5083 if (type
!= EOBJ__C_ETIR
)
5086 begin
= PRIV (recrd
.rec
) + 4;
5087 end
= PRIV (recrd
.rec
) + PRIV (recrd
.rec_size
);
5089 for (ptr
= begin
; ptr
< end
; ptr
+= length
)
5093 cmd
= bfd_getl16 (ptr
);
5094 length
= bfd_getl16 (ptr
+ 2);
5096 cur_address
= vaddr
;
5098 vms_debug2 ((4, "alpha_vms_slurp_relocs: etir %s\n",
5099 _bfd_vms_etir_name (cmd
)));
5103 case ETIR__C_STA_GBL
: /* ALPHA_R_REFLONG und_section, step 1 */
5104 /* ALPHA_R_REFQUAD und_section, step 1 */
5109 case ETIR__C_STA_PQ
: /* ALPHA_R_REF{LONG|QUAD}, others part 1 */
5110 cur_psidx
= bfd_getl32 (ptr
+ 4);
5111 cur_addend
= bfd_getl64 (ptr
+ 8);
5115 case ETIR__C_CTL_SETRB
:
5116 if (prev_cmd
!= ETIR__C_STA_PQ
)
5119 /* xgettext:c-format */
5120 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (prev_cmd
),
5121 _bfd_vms_etir_name (cmd
));
5124 cur_psect
= cur_psidx
;
5130 case ETIR__C_STA_LW
: /* ALPHA_R_REFLONG abs_section, step 1 */
5131 /* ALPHA_R_REFLONG und_section, step 2 */
5134 if (prev_cmd
!= ETIR__C_STA_GBL
)
5137 /* xgettext:c-format */
5138 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
5139 _bfd_vms_etir_name (ETIR__C_STA_LW
));
5143 cur_addend
= bfd_getl32 (ptr
+ 4);
5147 case ETIR__C_STA_QW
: /* ALPHA_R_REFQUAD abs_section, step 1 */
5148 /* ALPHA_R_REFQUAD und_section, step 2 */
5149 if (prev_cmd
!= -1 && prev_cmd
!= ETIR__C_STA_GBL
)
5152 /* xgettext:c-format */
5153 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
5154 _bfd_vms_etir_name (ETIR__C_STA_QW
));
5157 cur_addend
= bfd_getl64 (ptr
+ 4);
5161 case ETIR__C_STO_LW
: /* ALPHA_R_REFLONG und_section, step 4 */
5162 /* ALPHA_R_REFLONG abs_section, step 2 */
5163 /* ALPHA_R_REFLONG others, step 2 */
5164 if (prev_cmd
!= ETIR__C_OPR_ADD
5165 && prev_cmd
!= ETIR__C_STA_LW
5166 && prev_cmd
!= ETIR__C_STA_PQ
)
5168 /* xgettext:c-format */
5169 _bfd_error_handler (_("unknown reloc %s + %s"),
5170 _bfd_vms_etir_name (prev_cmd
),
5171 _bfd_vms_etir_name (ETIR__C_STO_LW
));
5174 reloc_code
= BFD_RELOC_32
;
5177 case ETIR__C_STO_QW
: /* ALPHA_R_REFQUAD und_section, step 4 */
5178 /* ALPHA_R_REFQUAD abs_section, step 2 */
5179 if (prev_cmd
!= ETIR__C_OPR_ADD
&& prev_cmd
!= ETIR__C_STA_QW
)
5181 /* xgettext:c-format */
5182 _bfd_error_handler (_("unknown reloc %s + %s"),
5183 _bfd_vms_etir_name (prev_cmd
),
5184 _bfd_vms_etir_name (ETIR__C_STO_QW
));
5187 reloc_code
= BFD_RELOC_64
;
5190 case ETIR__C_STO_OFF
: /* ALPHA_R_REFQUAD others, step 2 */
5191 if (prev_cmd
!= ETIR__C_STA_PQ
)
5193 /* xgettext:c-format */
5194 _bfd_error_handler (_("unknown reloc %s + %s"),
5195 _bfd_vms_etir_name (prev_cmd
),
5196 _bfd_vms_etir_name (ETIR__C_STO_OFF
));
5199 reloc_code
= BFD_RELOC_64
;
5202 case ETIR__C_OPR_ADD
: /* ALPHA_R_REFLONG und_section, step 3 */
5203 /* ALPHA_R_REFQUAD und_section, step 3 */
5204 if (prev_cmd
!= ETIR__C_STA_LW
&& prev_cmd
!= ETIR__C_STA_QW
)
5206 /* xgettext:c-format */
5207 _bfd_error_handler (_("unknown reloc %s + %s"),
5208 _bfd_vms_etir_name (prev_cmd
),
5209 _bfd_vms_etir_name (ETIR__C_OPR_ADD
));
5212 prev_cmd
= ETIR__C_OPR_ADD
;
5215 case ETIR__C_STO_CA
: /* ALPHA_R_CODEADDR */
5216 reloc_code
= BFD_RELOC_ALPHA_CODEADDR
;
5220 case ETIR__C_STO_GBL
: /* ALPHA_R_REFQUAD und_section */
5221 reloc_code
= BFD_RELOC_64
;
5225 case ETIR__C_STO_GBL_LW
: /* ALPHA_R_REFLONG und_section */
5226 reloc_code
= BFD_RELOC_32
;
5230 case ETIR__C_STC_LP_PSB
: /* ALPHA_R_LINKAGE */
5231 reloc_code
= BFD_RELOC_ALPHA_LINKAGE
;
5235 case ETIR__C_STC_NOP_GBL
: /* ALPHA_R_NOP */
5236 reloc_code
= BFD_RELOC_ALPHA_NOP
;
5239 case ETIR__C_STC_BSR_GBL
: /* ALPHA_R_BSR */
5240 reloc_code
= BFD_RELOC_ALPHA_BSR
;
5243 case ETIR__C_STC_LDA_GBL
: /* ALPHA_R_LDA */
5244 reloc_code
= BFD_RELOC_ALPHA_LDA
;
5247 case ETIR__C_STC_BOH_GBL
: /* ALPHA_R_BOH */
5248 reloc_code
= BFD_RELOC_ALPHA_BOH
;
5252 cur_sym
= ptr
+ 4 + 32;
5253 cur_address
= bfd_getl64 (ptr
+ 4 + 8);
5254 cur_addend
= bfd_getl64 (ptr
+ 4 + 24);
5257 case ETIR__C_STO_IMM
:
5258 vaddr
+= bfd_getl32 (ptr
+ 4);
5262 _bfd_error_handler (_("unknown reloc %s"),
5263 _bfd_vms_etir_name (cmd
));
5269 struct vms_section_data_struct
*vms_sec
;
5273 /* Get section to which the relocation applies. */
5274 if (cur_psect
< 0 || cur_psect
> (int)PRIV (section_count
))
5276 _bfd_error_handler (_("invalid section index in ETIR"));
5280 if (PRIV (sections
) == NULL
)
5282 sec
= PRIV (sections
)[cur_psect
];
5283 if (sec
== bfd_abs_section_ptr
)
5285 _bfd_error_handler (_("relocation for non-REL psect"));
5289 vms_sec
= vms_section_data (sec
);
5291 /* Allocate a reloc entry. */
5292 if (sec
->reloc_count
>= vms_sec
->reloc_max
)
5294 if (vms_sec
->reloc_max
== 0)
5296 vms_sec
->reloc_max
= 64;
5297 sec
->relocation
= bfd_zmalloc
5298 (vms_sec
->reloc_max
* sizeof (arelent
));
5302 vms_sec
->reloc_max
*= 2;
5303 sec
->relocation
= bfd_realloc
5304 (sec
->relocation
, vms_sec
->reloc_max
* sizeof (arelent
));
5307 reloc
= &sec
->relocation
[sec
->reloc_count
];
5310 reloc
->howto
= bfd_reloc_type_lookup (abfd
, reloc_code
);
5312 if (cur_sym
!= NULL
)
5315 unsigned int symlen
= *cur_sym
;
5318 /* Linear search. */
5323 for (j
= 0; j
< PRIV (gsd_sym_count
); j
++)
5324 if (PRIV (syms
)[j
]->namelen
== symlen
5325 && memcmp (PRIV (syms
)[j
]->name
, cur_sym
, symlen
) == 0)
5327 sym
= &PRIV (csymbols
)[j
];
5332 _bfd_error_handler (_("unknown symbol in command %s"),
5333 _bfd_vms_etir_name (cmd
));
5334 reloc
->sym_ptr_ptr
= NULL
;
5337 reloc
->sym_ptr_ptr
= sym
;
5339 else if (cur_psidx
>= 0)
5341 if (PRIV (sections
) == NULL
|| cur_psidx
>= (int) PRIV (section_count
))
5343 reloc
->sym_ptr_ptr
=
5344 PRIV (sections
)[cur_psidx
]->symbol_ptr_ptr
;
5347 reloc
->sym_ptr_ptr
= NULL
;
5349 reloc
->address
= cur_address
;
5350 reloc
->addend
= cur_addend
;
5352 if (reloc_code
== ALPHA_R_LINKAGE
)
5355 size
= bfd_get_reloc_size (reloc
->howto
);
5365 vms_debug2 ((3, "alpha_vms_slurp_relocs: result = TRUE\n"));
5370 /* Return the number of bytes required to store the relocation
5371 information associated with the given section. */
5374 alpha_vms_get_reloc_upper_bound (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*section
)
5376 alpha_vms_slurp_relocs (abfd
);
5378 return (section
->reloc_count
+ 1) * sizeof (arelent
*);
5381 /* Convert relocations from VMS (external) form into BFD internal
5382 form. Return the number of relocations. */
5385 alpha_vms_canonicalize_reloc (bfd
*abfd
, asection
*section
, arelent
**relptr
,
5386 asymbol
**symbols ATTRIBUTE_UNUSED
)
5391 if (!alpha_vms_slurp_relocs (abfd
))
5394 count
= section
->reloc_count
;
5395 tblptr
= section
->relocation
;
5398 *relptr
++ = tblptr
++;
5400 *relptr
= (arelent
*) NULL
;
5401 return section
->reloc_count
;
5404 /* Install a new set of internal relocs. */
5406 #define alpha_vms_set_reloc _bfd_generic_set_reloc
5409 /* This is just copied from ecoff-alpha, needs to be fixed probably. */
5411 /* How to process the various reloc types. */
5413 static bfd_reloc_status_type
5414 reloc_nil (bfd
* abfd ATTRIBUTE_UNUSED
,
5415 arelent
*reloc ATTRIBUTE_UNUSED
,
5416 asymbol
*sym ATTRIBUTE_UNUSED
,
5417 void * data ATTRIBUTE_UNUSED
,
5418 asection
*sec ATTRIBUTE_UNUSED
,
5419 bfd
*output_bfd ATTRIBUTE_UNUSED
,
5420 char **error_message ATTRIBUTE_UNUSED
)
5423 vms_debug (1, "reloc_nil (abfd %p, output_bfd %p)\n", abfd
, output_bfd
);
5424 vms_debug (2, "In section %s, symbol %s\n",
5425 sec
->name
, sym
->name
);
5426 vms_debug (2, "reloc sym %s, addr %08lx, addend %08lx, reloc is a %s\n",
5427 reloc
->sym_ptr_ptr
[0]->name
,
5428 (unsigned long)reloc
->address
,
5429 (unsigned long)reloc
->addend
, reloc
->howto
->name
);
5430 vms_debug (2, "data at %p\n", data
);
5431 /* _bfd_hexdump (2, data, bfd_get_reloc_size (reloc->howto), 0); */
5434 return bfd_reloc_ok
;
5437 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
5438 from smaller values. Start with zero, widen, *then* decrement. */
5439 #define MINUS_ONE (((bfd_vma)0) - 1)
5441 static reloc_howto_type alpha_howto_table
[] =
5443 HOWTO (ALPHA_R_IGNORE
, /* Type. */
5444 0, /* Rightshift. */
5445 0, /* Size (0 = byte, 1 = short, 2 = long). */
5447 TRUE
, /* PC relative. */
5449 complain_overflow_dont
,/* Complain_on_overflow. */
5450 reloc_nil
, /* Special_function. */
5451 "IGNORE", /* Name. */
5452 TRUE
, /* Partial_inplace. */
5453 0, /* Source mask */
5455 TRUE
), /* PC rel offset. */
5457 /* A 64 bit reference to a symbol. */
5458 HOWTO (ALPHA_R_REFQUAD
, /* Type. */
5459 0, /* Rightshift. */
5460 4, /* Size (0 = byte, 1 = short, 2 = long). */
5462 FALSE
, /* PC relative. */
5464 complain_overflow_bitfield
, /* Complain_on_overflow. */
5465 reloc_nil
, /* Special_function. */
5466 "REFQUAD", /* Name. */
5467 TRUE
, /* Partial_inplace. */
5468 MINUS_ONE
, /* Source mask. */
5469 MINUS_ONE
, /* Dest mask. */
5470 FALSE
), /* PC rel offset. */
5472 /* A 21 bit branch. The native assembler generates these for
5473 branches within the text segment, and also fills in the PC
5474 relative offset in the instruction. */
5475 HOWTO (ALPHA_R_BRADDR
, /* Type. */
5476 2, /* Rightshift. */
5477 2, /* Size (0 = byte, 1 = short, 2 = long). */
5479 TRUE
, /* PC relative. */
5481 complain_overflow_signed
, /* Complain_on_overflow. */
5482 reloc_nil
, /* Special_function. */
5483 "BRADDR", /* Name. */
5484 TRUE
, /* Partial_inplace. */
5485 0x1fffff, /* Source mask. */
5486 0x1fffff, /* Dest mask. */
5487 FALSE
), /* PC rel offset. */
5489 /* A hint for a jump to a register. */
5490 HOWTO (ALPHA_R_HINT
, /* Type. */
5491 2, /* Rightshift. */
5492 1, /* Size (0 = byte, 1 = short, 2 = long). */
5494 TRUE
, /* PC relative. */
5496 complain_overflow_dont
,/* Complain_on_overflow. */
5497 reloc_nil
, /* Special_function. */
5499 TRUE
, /* Partial_inplace. */
5500 0x3fff, /* Source mask. */
5501 0x3fff, /* Dest mask. */
5502 FALSE
), /* PC rel offset. */
5504 /* 16 bit PC relative offset. */
5505 HOWTO (ALPHA_R_SREL16
, /* Type. */
5506 0, /* Rightshift. */
5507 1, /* Size (0 = byte, 1 = short, 2 = long). */
5509 TRUE
, /* PC relative. */
5511 complain_overflow_signed
, /* Complain_on_overflow. */
5512 reloc_nil
, /* Special_function. */
5513 "SREL16", /* Name. */
5514 TRUE
, /* Partial_inplace. */
5515 0xffff, /* Source mask. */
5516 0xffff, /* Dest mask. */
5517 FALSE
), /* PC rel offset. */
5519 /* 32 bit PC relative offset. */
5520 HOWTO (ALPHA_R_SREL32
, /* Type. */
5521 0, /* Rightshift. */
5522 2, /* Size (0 = byte, 1 = short, 2 = long). */
5524 TRUE
, /* PC relative. */
5526 complain_overflow_signed
, /* Complain_on_overflow. */
5527 reloc_nil
, /* Special_function. */
5528 "SREL32", /* Name. */
5529 TRUE
, /* Partial_inplace. */
5530 0xffffffff, /* Source mask. */
5531 0xffffffff, /* Dest mask. */
5532 FALSE
), /* PC rel offset. */
5534 /* A 64 bit PC relative offset. */
5535 HOWTO (ALPHA_R_SREL64
, /* Type. */
5536 0, /* Rightshift. */
5537 4, /* Size (0 = byte, 1 = short, 2 = long). */
5539 TRUE
, /* PC relative. */
5541 complain_overflow_signed
, /* Complain_on_overflow. */
5542 reloc_nil
, /* Special_function. */
5543 "SREL64", /* Name. */
5544 TRUE
, /* Partial_inplace. */
5545 MINUS_ONE
, /* Source mask. */
5546 MINUS_ONE
, /* Dest mask. */
5547 FALSE
), /* PC rel offset. */
5549 /* Push a value on the reloc evaluation stack. */
5550 HOWTO (ALPHA_R_OP_PUSH
, /* Type. */
5551 0, /* Rightshift. */
5552 0, /* Size (0 = byte, 1 = short, 2 = long). */
5554 FALSE
, /* PC relative. */
5556 complain_overflow_dont
,/* Complain_on_overflow. */
5557 reloc_nil
, /* Special_function. */
5558 "OP_PUSH", /* Name. */
5559 FALSE
, /* Partial_inplace. */
5560 0, /* Source mask. */
5562 FALSE
), /* PC rel offset. */
5564 /* Store the value from the stack at the given address. Store it in
5565 a bitfield of size r_size starting at bit position r_offset. */
5566 HOWTO (ALPHA_R_OP_STORE
, /* Type. */
5567 0, /* Rightshift. */
5568 4, /* Size (0 = byte, 1 = short, 2 = long). */
5570 FALSE
, /* PC relative. */
5572 complain_overflow_dont
,/* Complain_on_overflow. */
5573 reloc_nil
, /* Special_function. */
5574 "OP_STORE", /* Name. */
5575 FALSE
, /* Partial_inplace. */
5576 0, /* Source mask. */
5577 MINUS_ONE
, /* Dest mask. */
5578 FALSE
), /* PC rel offset. */
5580 /* Subtract the reloc address from the value on the top of the
5581 relocation stack. */
5582 HOWTO (ALPHA_R_OP_PSUB
, /* Type. */
5583 0, /* Rightshift. */
5584 0, /* Size (0 = byte, 1 = short, 2 = long). */
5586 FALSE
, /* PC relative. */
5588 complain_overflow_dont
,/* Complain_on_overflow. */
5589 reloc_nil
, /* Special_function. */
5590 "OP_PSUB", /* Name. */
5591 FALSE
, /* Partial_inplace. */
5592 0, /* Source mask. */
5594 FALSE
), /* PC rel offset. */
5596 /* Shift the value on the top of the relocation stack right by the
5598 HOWTO (ALPHA_R_OP_PRSHIFT
, /* Type. */
5599 0, /* Rightshift. */
5600 0, /* Size (0 = byte, 1 = short, 2 = long). */
5602 FALSE
, /* PC relative. */
5604 complain_overflow_dont
,/* Complain_on_overflow. */
5605 reloc_nil
, /* Special_function. */
5606 "OP_PRSHIFT", /* Name. */
5607 FALSE
, /* Partial_inplace. */
5608 0, /* Source mask. */
5610 FALSE
), /* PC rel offset. */
5612 /* Hack. Linkage is done by linker. */
5613 HOWTO (ALPHA_R_LINKAGE
, /* Type. */
5614 0, /* Rightshift. */
5615 0, /* Size (0 = byte, 1 = short, 2 = long). */
5617 FALSE
, /* PC relative. */
5619 complain_overflow_dont
,/* Complain_on_overflow. */
5620 reloc_nil
, /* Special_function. */
5621 "LINKAGE", /* Name. */
5622 FALSE
, /* Partial_inplace. */
5623 0, /* Source mask. */
5625 FALSE
), /* PC rel offset. */
5627 /* A 32 bit reference to a symbol. */
5628 HOWTO (ALPHA_R_REFLONG
, /* Type. */
5629 0, /* Rightshift. */
5630 2, /* Size (0 = byte, 1 = short, 2 = long). */
5632 FALSE
, /* PC relative. */
5634 complain_overflow_bitfield
, /* Complain_on_overflow. */
5635 reloc_nil
, /* Special_function. */
5636 "REFLONG", /* Name. */
5637 TRUE
, /* Partial_inplace. */
5638 0xffffffff, /* Source mask. */
5639 0xffffffff, /* Dest mask. */
5640 FALSE
), /* PC rel offset. */
5642 /* A 64 bit reference to a procedure, written as 32 bit value. */
5643 HOWTO (ALPHA_R_CODEADDR
, /* Type. */
5644 0, /* Rightshift. */
5645 4, /* Size (0 = byte, 1 = short, 2 = long). */
5647 FALSE
, /* PC relative. */
5649 complain_overflow_signed
,/* Complain_on_overflow. */
5650 reloc_nil
, /* Special_function. */
5651 "CODEADDR", /* Name. */
5652 FALSE
, /* Partial_inplace. */
5653 0xffffffff, /* Source mask. */
5654 0xffffffff, /* Dest mask. */
5655 FALSE
), /* PC rel offset. */
5657 HOWTO (ALPHA_R_NOP
, /* Type. */
5658 0, /* Rightshift. */
5659 3, /* Size (0 = byte, 1 = short, 2 = long). */
5661 /* The following value must match that of ALPHA_R_BSR/ALPHA_R_BOH
5662 because the calculations for the 3 relocations are the same.
5663 See B.4.5.2 of the OpenVMS Linker Utility Manual. */
5664 TRUE
, /* PC relative. */
5666 complain_overflow_dont
,/* Complain_on_overflow. */
5667 reloc_nil
, /* Special_function. */
5669 FALSE
, /* Partial_inplace. */
5670 0xffffffff, /* Source mask. */
5671 0xffffffff, /* Dest mask. */
5672 FALSE
), /* PC rel offset. */
5674 HOWTO (ALPHA_R_BSR
, /* Type. */
5675 0, /* Rightshift. */
5676 3, /* Size (0 = byte, 1 = short, 2 = long). */
5678 TRUE
, /* PC relative. */
5680 complain_overflow_dont
,/* Complain_on_overflow. */
5681 reloc_nil
, /* Special_function. */
5683 FALSE
, /* Partial_inplace. */
5684 0xffffffff, /* Source mask. */
5685 0xffffffff, /* Dest mask. */
5686 FALSE
), /* PC rel offset. */
5688 HOWTO (ALPHA_R_LDA
, /* Type. */
5689 0, /* Rightshift. */
5690 3, /* Size (0 = byte, 1 = short, 2 = long). */
5692 FALSE
, /* PC relative. */
5694 complain_overflow_dont
,/* Complain_on_overflow. */
5695 reloc_nil
, /* Special_function. */
5697 FALSE
, /* Partial_inplace. */
5698 0xffffffff, /* Source mask. */
5699 0xffffffff, /* Dest mask. */
5700 FALSE
), /* PC rel offset. */
5702 HOWTO (ALPHA_R_BOH
, /* Type. */
5703 0, /* Rightshift. */
5704 3, /* Size (0 = byte, 1 = short, 2 = long, 3 = nil). */
5706 TRUE
, /* PC relative. */
5708 complain_overflow_dont
,/* Complain_on_overflow. */
5709 reloc_nil
, /* Special_function. */
5711 FALSE
, /* Partial_inplace. */
5712 0xffffffff, /* Source mask. */
5713 0xffffffff, /* Dest mask. */
5714 FALSE
), /* PC rel offset. */
5717 /* Return a pointer to a howto structure which, when invoked, will perform
5718 the relocation code on data from the architecture noted. */
5720 static reloc_howto_type
*
5721 alpha_vms_bfd_reloc_type_lookup (bfd
* abfd ATTRIBUTE_UNUSED
,
5722 bfd_reloc_code_real_type code
)
5726 vms_debug2 ((1, "vms_bfd_reloc_type_lookup (%p, %d)\t", abfd
, code
));
5730 case BFD_RELOC_16
: alpha_type
= ALPHA_R_SREL16
; break;
5731 case BFD_RELOC_32
: alpha_type
= ALPHA_R_REFLONG
; break;
5732 case BFD_RELOC_64
: alpha_type
= ALPHA_R_REFQUAD
; break;
5733 case BFD_RELOC_CTOR
: alpha_type
= ALPHA_R_REFQUAD
; break;
5734 case BFD_RELOC_23_PCREL_S2
: alpha_type
= ALPHA_R_BRADDR
; break;
5735 case BFD_RELOC_ALPHA_HINT
: alpha_type
= ALPHA_R_HINT
; break;
5736 case BFD_RELOC_16_PCREL
: alpha_type
= ALPHA_R_SREL16
; break;
5737 case BFD_RELOC_32_PCREL
: alpha_type
= ALPHA_R_SREL32
; break;
5738 case BFD_RELOC_64_PCREL
: alpha_type
= ALPHA_R_SREL64
; break;
5739 case BFD_RELOC_ALPHA_LINKAGE
: alpha_type
= ALPHA_R_LINKAGE
; break;
5740 case BFD_RELOC_ALPHA_CODEADDR
: alpha_type
= ALPHA_R_CODEADDR
; break;
5741 case BFD_RELOC_ALPHA_NOP
: alpha_type
= ALPHA_R_NOP
; break;
5742 case BFD_RELOC_ALPHA_BSR
: alpha_type
= ALPHA_R_BSR
; break;
5743 case BFD_RELOC_ALPHA_LDA
: alpha_type
= ALPHA_R_LDA
; break;
5744 case BFD_RELOC_ALPHA_BOH
: alpha_type
= ALPHA_R_BOH
; break;
5746 _bfd_error_handler (_("reloc (%d) is *UNKNOWN*"), code
);
5749 vms_debug2 ((2, "reloc is %s\n", alpha_howto_table
[alpha_type
].name
));
5750 return & alpha_howto_table
[alpha_type
];
5753 static reloc_howto_type
*
5754 alpha_vms_bfd_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
5760 i
< sizeof (alpha_howto_table
) / sizeof (alpha_howto_table
[0]);
5762 if (alpha_howto_table
[i
].name
!= NULL
5763 && strcasecmp (alpha_howto_table
[i
].name
, r_name
) == 0)
5764 return &alpha_howto_table
[i
];
5770 alpha_vms_get_synthetic_symtab (bfd
*abfd
,
5771 long symcount ATTRIBUTE_UNUSED
,
5772 asymbol
**usyms ATTRIBUTE_UNUSED
,
5773 long dynsymcount ATTRIBUTE_UNUSED
,
5774 asymbol
**dynsyms ATTRIBUTE_UNUSED
,
5781 syms
= (asymbol
*) bfd_malloc (PRIV (norm_sym_count
) * sizeof (asymbol
));
5786 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
5788 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
5799 flags
= BSF_LOCAL
| BSF_SYNTHETIC
;
5806 if ((e
->flags
& EGSY__V_DEF
) && (e
->flags
& EGSY__V_NORM
))
5808 value
= e
->code_value
;
5809 sec
= e
->code_section
;
5820 sname
= bfd_alloc (abfd
, l
+ 5);
5823 memcpy (sname
, name
, l
);
5824 memcpy (sname
+ l
, "..en", 5);
5831 sym
->udata
.p
= NULL
;
5840 vms_time_to_str (unsigned char *buf
)
5842 time_t t
= vms_rawtime_to_time_t (buf
);
5843 char *res
= ctime (&t
);
5846 res
= "*invalid time*";
5853 evax_bfd_print_emh (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5855 struct vms_emh_common
*emh
= (struct vms_emh_common
*)rec
;
5856 unsigned int subtype
;
5859 subtype
= (unsigned) bfd_getl16 (emh
->subtyp
);
5861 /* xgettext:c-format */
5862 fprintf (file
, _(" EMH %u (len=%u): "), subtype
, rec_len
);
5864 /* PR 21618: Check for invalid lengths. */
5865 if (rec_len
< sizeof (* emh
))
5867 fprintf (file
, _(" Error: The length is less than the length of an EMH record\n"));
5870 extra
= rec_len
- sizeof (struct vms_emh_common
);
5876 struct vms_emh_mhd
*mhd
= (struct vms_emh_mhd
*) rec
;
5878 const char * nextname
;
5879 const char * maxname
;
5881 /* PR 21840: Check for invalid lengths. */
5882 if (rec_len
< sizeof (* mhd
))
5884 fprintf (file
, _(" Error: The record length is less than the size of an EMH_MHD record\n"));
5887 fprintf (file
, _("Module header\n"));
5888 fprintf (file
, _(" structure level: %u\n"), mhd
->strlvl
);
5889 fprintf (file
, _(" max record size: %u\n"),
5890 (unsigned) bfd_getl32 (mhd
->recsiz
));
5891 name
= (char *)(mhd
+ 1);
5892 maxname
= (char *) rec
+ rec_len
;
5893 if (name
> maxname
- 2)
5895 fprintf (file
, _(" Error: The module name is missing\n"));
5898 nextname
= name
+ name
[0] + 1;
5899 if (nextname
>= maxname
)
5901 fprintf (file
, _(" Error: The module name is too long\n"));
5904 fprintf (file
, _(" module name : %.*s\n"), name
[0], name
+ 1);
5906 if (name
> maxname
- 2)
5908 fprintf (file
, _(" Error: The module version is missing\n"));
5911 nextname
= name
+ name
[0] + 1;
5912 if (nextname
>= maxname
)
5914 fprintf (file
, _(" Error: The module version is too long\n"));
5917 fprintf (file
, _(" module version : %.*s\n"), name
[0], name
+ 1);
5919 if ((maxname
- name
) < 17 && maxname
[-1] != 0)
5920 fprintf (file
, _(" Error: The compile date is truncated\n"));
5922 fprintf (file
, _(" compile date : %.17s\n"), name
);
5927 fprintf (file
, _("Language Processor Name\n"));
5928 fprintf (file
, _(" language name: %.*s\n"), extra
, (char *)(emh
+ 1));
5932 fprintf (file
, _("Source Files Header\n"));
5933 fprintf (file
, _(" file: %.*s\n"), extra
, (char *)(emh
+ 1));
5937 fprintf (file
, _("Title Text Header\n"));
5938 fprintf (file
, _(" title: %.*s\n"), extra
, (char *)(emh
+ 1));
5942 fprintf (file
, _("Copyright Header\n"));
5943 fprintf (file
, _(" copyright: %.*s\n"), extra
, (char *)(emh
+ 1));
5947 fprintf (file
, _("unhandled emh subtype %u\n"), subtype
);
5953 evax_bfd_print_eeom (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5955 struct vms_eeom
*eeom
= (struct vms_eeom
*)rec
;
5957 fprintf (file
, _(" EEOM (len=%u):\n"), rec_len
);
5959 /* PR 21618: Check for invalid lengths. */
5960 if (rec_len
< sizeof (* eeom
))
5962 fprintf (file
, _(" Error: The length is less than the length of an EEOM record\n"));
5966 fprintf (file
, _(" number of cond linkage pairs: %u\n"),
5967 (unsigned)bfd_getl32 (eeom
->total_lps
));
5968 fprintf (file
, _(" completion code: %u\n"),
5969 (unsigned)bfd_getl16 (eeom
->comcod
));
5972 fprintf (file
, _(" transfer addr flags: 0x%02x\n"), eeom
->tfrflg
);
5973 fprintf (file
, _(" transfer addr psect: %u\n"),
5974 (unsigned)bfd_getl32 (eeom
->psindx
));
5975 fprintf (file
, _(" transfer address : 0x%08x\n"),
5976 (unsigned)bfd_getl32 (eeom
->tfradr
));
5981 exav_bfd_print_egsy_flags (unsigned int flags
, FILE *file
)
5983 if (flags
& EGSY__V_WEAK
)
5984 fputs (_(" WEAK"), file
);
5985 if (flags
& EGSY__V_DEF
)
5986 fputs (_(" DEF"), file
);
5987 if (flags
& EGSY__V_UNI
)
5988 fputs (_(" UNI"), file
);
5989 if (flags
& EGSY__V_REL
)
5990 fputs (_(" REL"), file
);
5991 if (flags
& EGSY__V_COMM
)
5992 fputs (_(" COMM"), file
);
5993 if (flags
& EGSY__V_VECEP
)
5994 fputs (_(" VECEP"), file
);
5995 if (flags
& EGSY__V_NORM
)
5996 fputs (_(" NORM"), file
);
5997 if (flags
& EGSY__V_QUAD_VAL
)
5998 fputs (_(" QVAL"), file
);
6002 evax_bfd_print_egsd_flags (FILE *file
, unsigned int flags
)
6004 if (flags
& EGPS__V_PIC
)
6005 fputs (_(" PIC"), file
);
6006 if (flags
& EGPS__V_LIB
)
6007 fputs (_(" LIB"), file
);
6008 if (flags
& EGPS__V_OVR
)
6009 fputs (_(" OVR"), file
);
6010 if (flags
& EGPS__V_REL
)
6011 fputs (_(" REL"), file
);
6012 if (flags
& EGPS__V_GBL
)
6013 fputs (_(" GBL"), file
);
6014 if (flags
& EGPS__V_SHR
)
6015 fputs (_(" SHR"), file
);
6016 if (flags
& EGPS__V_EXE
)
6017 fputs (_(" EXE"), file
);
6018 if (flags
& EGPS__V_RD
)
6019 fputs (_(" RD"), file
);
6020 if (flags
& EGPS__V_WRT
)
6021 fputs (_(" WRT"), file
);
6022 if (flags
& EGPS__V_VEC
)
6023 fputs (_(" VEC"), file
);
6024 if (flags
& EGPS__V_NOMOD
)
6025 fputs (_(" NOMOD"), file
);
6026 if (flags
& EGPS__V_COM
)
6027 fputs (_(" COM"), file
);
6028 if (flags
& EGPS__V_ALLOC_64BIT
)
6029 fputs (_(" 64B"), file
);
6033 evax_bfd_print_egsd (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
6035 unsigned int off
= sizeof (struct vms_egsd
);
6038 fprintf (file
, _(" EGSD (len=%u):\n"), rec_len
);
6041 for (off
= sizeof (struct vms_egsd
); off
< rec_len
; )
6043 struct vms_egsd_entry
*e
= (struct vms_egsd_entry
*)(rec
+ off
);
6047 type
= (unsigned)bfd_getl16 (e
->gsdtyp
);
6048 len
= (unsigned)bfd_getl16 (e
->gsdsiz
);
6050 /* xgettext:c-format */
6051 fprintf (file
, _(" EGSD entry %2u (type: %u, len: %u): "),
6055 if (off
+ len
> rec_len
|| off
+ len
< off
)
6057 fprintf (file
, _(" Error: length larger than remaining space in record\n"));
6065 struct vms_egps
*egps
= (struct vms_egps
*)e
;
6066 unsigned int flags
= bfd_getl16 (egps
->flags
);
6069 fprintf (file
, _("PSC - Program section definition\n"));
6070 fprintf (file
, _(" alignment : 2**%u\n"), egps
->align
);
6071 fprintf (file
, _(" flags : 0x%04x"), flags
);
6072 evax_bfd_print_egsd_flags (file
, flags
);
6074 l
= bfd_getl32 (egps
->alloc
);
6075 fprintf (file
, _(" alloc (len): %u (0x%08x)\n"), l
, l
);
6076 fprintf (file
, _(" name : %.*s\n"),
6077 egps
->namlng
, egps
->name
);
6082 struct vms_esgps
*esgps
= (struct vms_esgps
*)e
;
6083 unsigned int flags
= bfd_getl16 (esgps
->flags
);
6086 fprintf (file
, _("SPSC - Shared Image Program section def\n"));
6087 fprintf (file
, _(" alignment : 2**%u\n"), esgps
->align
);
6088 fprintf (file
, _(" flags : 0x%04x"), flags
);
6089 evax_bfd_print_egsd_flags (file
, flags
);
6091 l
= bfd_getl32 (esgps
->alloc
);
6092 fprintf (file
, _(" alloc (len) : %u (0x%08x)\n"), l
, l
);
6093 fprintf (file
, _(" image offset : 0x%08x\n"),
6094 (unsigned int)bfd_getl32 (esgps
->base
));
6095 fprintf (file
, _(" symvec offset : 0x%08x\n"),
6096 (unsigned int)bfd_getl32 (esgps
->value
));
6097 fprintf (file
, _(" name : %.*s\n"),
6098 esgps
->namlng
, esgps
->name
);
6103 struct vms_egsy
*egsy
= (struct vms_egsy
*)e
;
6104 unsigned int flags
= bfd_getl16 (egsy
->flags
);
6106 if (flags
& EGSY__V_DEF
)
6108 struct vms_esdf
*esdf
= (struct vms_esdf
*)e
;
6110 fprintf (file
, _("SYM - Global symbol definition\n"));
6111 fprintf (file
, _(" flags: 0x%04x"), flags
);
6112 exav_bfd_print_egsy_flags (flags
, file
);
6114 fprintf (file
, _(" psect offset: 0x%08x\n"),
6115 (unsigned)bfd_getl32 (esdf
->value
));
6116 if (flags
& EGSY__V_NORM
)
6118 fprintf (file
, _(" code address: 0x%08x\n"),
6119 (unsigned)bfd_getl32 (esdf
->code_address
));
6120 fprintf (file
, _(" psect index for entry point : %u\n"),
6121 (unsigned)bfd_getl32 (esdf
->ca_psindx
));
6123 fprintf (file
, _(" psect index : %u\n"),
6124 (unsigned)bfd_getl32 (esdf
->psindx
));
6125 fprintf (file
, _(" name : %.*s\n"),
6126 esdf
->namlng
, esdf
->name
);
6130 struct vms_esrf
*esrf
= (struct vms_esrf
*)e
;
6132 fprintf (file
, _("SYM - Global symbol reference\n"));
6133 fprintf (file
, _(" name : %.*s\n"),
6134 esrf
->namlng
, esrf
->name
);
6140 struct vms_eidc
*eidc
= (struct vms_eidc
*)e
;
6141 unsigned int flags
= bfd_getl32 (eidc
->flags
);
6144 fprintf (file
, _("IDC - Ident Consistency check\n"));
6145 fprintf (file
, _(" flags : 0x%08x"), flags
);
6146 if (flags
& EIDC__V_BINIDENT
)
6147 fputs (" BINDENT", file
);
6149 fprintf (file
, _(" id match : %x\n"),
6150 (flags
>> EIDC__V_IDMATCH_SH
) & EIDC__V_IDMATCH_MASK
);
6151 fprintf (file
, _(" error severity: %x\n"),
6152 (flags
>> EIDC__V_ERRSEV_SH
) & EIDC__V_ERRSEV_MASK
);
6154 fprintf (file
, _(" entity name : %.*s\n"), p
[0], p
+ 1);
6156 fprintf (file
, _(" object name : %.*s\n"), p
[0], p
+ 1);
6158 if (flags
& EIDC__V_BINIDENT
)
6159 fprintf (file
, _(" binary ident : 0x%08x\n"),
6160 (unsigned)bfd_getl32 (p
+ 1));
6162 fprintf (file
, _(" ascii ident : %.*s\n"), p
[0], p
+ 1);
6167 struct vms_egst
*egst
= (struct vms_egst
*)e
;
6168 unsigned int flags
= bfd_getl16 (egst
->header
.flags
);
6170 fprintf (file
, _("SYMG - Universal symbol definition\n"));
6171 fprintf (file
, _(" flags: 0x%04x"), flags
);
6172 exav_bfd_print_egsy_flags (flags
, file
);
6174 fprintf (file
, _(" symbol vector offset: 0x%08x\n"),
6175 (unsigned)bfd_getl32 (egst
->value
));
6176 fprintf (file
, _(" entry point: 0x%08x\n"),
6177 (unsigned)bfd_getl32 (egst
->lp_1
));
6178 fprintf (file
, _(" proc descr : 0x%08x\n"),
6179 (unsigned)bfd_getl32 (egst
->lp_2
));
6180 fprintf (file
, _(" psect index: %u\n"),
6181 (unsigned)bfd_getl32 (egst
->psindx
));
6182 fprintf (file
, _(" name : %.*s\n"),
6183 egst
->namlng
, egst
->name
);
6188 struct vms_esdfv
*esdfv
= (struct vms_esdfv
*)e
;
6189 unsigned int flags
= bfd_getl16 (esdfv
->flags
);
6191 fprintf (file
, _("SYMV - Vectored symbol definition\n"));
6192 fprintf (file
, _(" flags: 0x%04x"), flags
);
6193 exav_bfd_print_egsy_flags (flags
, file
);
6195 fprintf (file
, _(" vector : 0x%08x\n"),
6196 (unsigned)bfd_getl32 (esdfv
->vector
));
6197 fprintf (file
, _(" psect offset: %u\n"),
6198 (unsigned)bfd_getl32 (esdfv
->value
));
6199 fprintf (file
, _(" psect index : %u\n"),
6200 (unsigned)bfd_getl32 (esdfv
->psindx
));
6201 fprintf (file
, _(" name : %.*s\n"),
6202 esdfv
->namlng
, esdfv
->name
);
6207 struct vms_esdfm
*esdfm
= (struct vms_esdfm
*)e
;
6208 unsigned int flags
= bfd_getl16 (esdfm
->flags
);
6210 fprintf (file
, _("SYMM - Global symbol definition with version\n"));
6211 fprintf (file
, _(" flags: 0x%04x"), flags
);
6212 exav_bfd_print_egsy_flags (flags
, file
);
6214 fprintf (file
, _(" version mask: 0x%08x\n"),
6215 (unsigned)bfd_getl32 (esdfm
->version_mask
));
6216 fprintf (file
, _(" psect offset: %u\n"),
6217 (unsigned)bfd_getl32 (esdfm
->value
));
6218 fprintf (file
, _(" psect index : %u\n"),
6219 (unsigned)bfd_getl32 (esdfm
->psindx
));
6220 fprintf (file
, _(" name : %.*s\n"),
6221 esdfm
->namlng
, esdfm
->name
);
6225 fprintf (file
, _("unhandled egsd entry type %u\n"), type
);
6233 evax_bfd_print_hex (FILE *file
, const char *pfx
,
6234 const unsigned char *buf
, unsigned int len
)
6240 for (i
= 0; i
< len
; i
++)
6244 fprintf (file
, " %02x", buf
[i
]);
6257 evax_bfd_print_etir_stc_ir (FILE *file
, const unsigned char *buf
, int is_ps
)
6259 /* xgettext:c-format */
6260 fprintf (file
, _(" linkage index: %u, replacement insn: 0x%08x\n"),
6261 (unsigned)bfd_getl32 (buf
),
6262 (unsigned)bfd_getl32 (buf
+ 16));
6263 /* xgettext:c-format */
6264 fprintf (file
, _(" psect idx 1: %u, offset 1: 0x%08x %08x\n"),
6265 (unsigned)bfd_getl32 (buf
+ 4),
6266 (unsigned)bfd_getl32 (buf
+ 12),
6267 (unsigned)bfd_getl32 (buf
+ 8));
6268 /* xgettext:c-format */
6269 fprintf (file
, _(" psect idx 2: %u, offset 2: 0x%08x %08x\n"),
6270 (unsigned)bfd_getl32 (buf
+ 20),
6271 (unsigned)bfd_getl32 (buf
+ 28),
6272 (unsigned)bfd_getl32 (buf
+ 24));
6274 /* xgettext:c-format */
6275 fprintf (file
, _(" psect idx 3: %u, offset 3: 0x%08x %08x\n"),
6276 (unsigned)bfd_getl32 (buf
+ 32),
6277 (unsigned)bfd_getl32 (buf
+ 40),
6278 (unsigned)bfd_getl32 (buf
+ 36));
6280 fprintf (file
, _(" global name: %.*s\n"), buf
[32], buf
+ 33);
6284 evax_bfd_print_etir (FILE *file
, const char *name
,
6285 unsigned char *rec
, unsigned int rec_len
)
6287 unsigned int off
= sizeof (struct vms_egsd
);
6288 unsigned int sec_len
= 0;
6290 /* xgettext:c-format */
6291 fprintf (file
, _(" %s (len=%u+%u):\n"), name
,
6292 (unsigned)(rec_len
- sizeof (struct vms_eobjrec
)),
6293 (unsigned)sizeof (struct vms_eobjrec
));
6295 for (off
= sizeof (struct vms_eobjrec
); off
< rec_len
; )
6297 struct vms_etir
*etir
= (struct vms_etir
*)(rec
+ off
);
6302 type
= bfd_getl16 (etir
->rectyp
);
6303 size
= bfd_getl16 (etir
->size
);
6304 buf
= rec
+ off
+ sizeof (struct vms_etir
);
6306 if (off
+ size
> rec_len
|| off
+ size
< off
)
6308 fprintf (file
, _(" Error: length larger than remaining space in record\n"));
6312 /* xgettext:c-format */
6313 fprintf (file
, _(" (type: %3u, size: 4+%3u): "), type
, size
- 4);
6316 case ETIR__C_STA_GBL
:
6317 fprintf (file
, _("STA_GBL (stack global) %.*s\n"),
6320 case ETIR__C_STA_LW
:
6321 fprintf (file
, _("STA_LW (stack longword) 0x%08x\n"),
6322 (unsigned)bfd_getl32 (buf
));
6324 case ETIR__C_STA_QW
:
6325 fprintf (file
, _("STA_QW (stack quadword) 0x%08x %08x\n"),
6326 (unsigned)bfd_getl32 (buf
+ 4),
6327 (unsigned)bfd_getl32 (buf
+ 0));
6329 case ETIR__C_STA_PQ
:
6330 fprintf (file
, _("STA_PQ (stack psect base + offset)\n"));
6331 /* xgettext:c-format */
6332 fprintf (file
, _(" psect: %u, offset: 0x%08x %08x\n"),
6333 (unsigned)bfd_getl32 (buf
+ 0),
6334 (unsigned)bfd_getl32 (buf
+ 8),
6335 (unsigned)bfd_getl32 (buf
+ 4));
6337 case ETIR__C_STA_LI
:
6338 fprintf (file
, _("STA_LI (stack literal)\n"));
6340 case ETIR__C_STA_MOD
:
6341 fprintf (file
, _("STA_MOD (stack module)\n"));
6343 case ETIR__C_STA_CKARG
:
6344 fprintf (file
, _("STA_CKARG (compare procedure argument)\n"));
6348 fprintf (file
, _("STO_B (store byte)\n"));
6351 fprintf (file
, _("STO_W (store word)\n"));
6353 case ETIR__C_STO_LW
:
6354 fprintf (file
, _("STO_LW (store longword)\n"));
6356 case ETIR__C_STO_QW
:
6357 fprintf (file
, _("STO_QW (store quadword)\n"));
6359 case ETIR__C_STO_IMMR
:
6361 unsigned int len
= bfd_getl32 (buf
);
6363 _("STO_IMMR (store immediate repeat) %u bytes\n"),
6365 evax_bfd_print_hex (file
, " ", buf
+ 4, len
);
6369 case ETIR__C_STO_GBL
:
6370 fprintf (file
, _("STO_GBL (store global) %.*s\n"),
6373 case ETIR__C_STO_CA
:
6374 fprintf (file
, _("STO_CA (store code address) %.*s\n"),
6377 case ETIR__C_STO_RB
:
6378 fprintf (file
, _("STO_RB (store relative branch)\n"));
6380 case ETIR__C_STO_AB
:
6381 fprintf (file
, _("STO_AB (store absolute branch)\n"));
6383 case ETIR__C_STO_OFF
:
6384 fprintf (file
, _("STO_OFF (store offset to psect)\n"));
6386 case ETIR__C_STO_IMM
:
6388 unsigned int len
= bfd_getl32 (buf
);
6390 _("STO_IMM (store immediate) %u bytes\n"),
6392 evax_bfd_print_hex (file
, " ", buf
+ 4, len
);
6396 case ETIR__C_STO_GBL_LW
:
6397 fprintf (file
, _("STO_GBL_LW (store global longword) %.*s\n"),
6400 case ETIR__C_STO_LP_PSB
:
6401 fprintf (file
, _("STO_OFF (store LP with procedure signature)\n"));
6403 case ETIR__C_STO_HINT_GBL
:
6404 fprintf (file
, _("STO_BR_GBL (store branch global) *todo*\n"));
6406 case ETIR__C_STO_HINT_PS
:
6407 fprintf (file
, _("STO_BR_PS (store branch psect + offset) *todo*\n"));
6410 case ETIR__C_OPR_NOP
:
6411 fprintf (file
, _("OPR_NOP (no-operation)\n"));
6413 case ETIR__C_OPR_ADD
:
6414 fprintf (file
, _("OPR_ADD (add)\n"));
6416 case ETIR__C_OPR_SUB
:
6417 fprintf (file
, _("OPR_SUB (subtract)\n"));
6419 case ETIR__C_OPR_MUL
:
6420 fprintf (file
, _("OPR_MUL (multiply)\n"));
6422 case ETIR__C_OPR_DIV
:
6423 fprintf (file
, _("OPR_DIV (divide)\n"));
6425 case ETIR__C_OPR_AND
:
6426 fprintf (file
, _("OPR_AND (logical and)\n"));
6428 case ETIR__C_OPR_IOR
:
6429 fprintf (file
, _("OPR_IOR (logical inclusive or)\n"));
6431 case ETIR__C_OPR_EOR
:
6432 fprintf (file
, _("OPR_EOR (logical exclusive or)\n"));
6434 case ETIR__C_OPR_NEG
:
6435 fprintf (file
, _("OPR_NEG (negate)\n"));
6437 case ETIR__C_OPR_COM
:
6438 fprintf (file
, _("OPR_COM (complement)\n"));
6440 case ETIR__C_OPR_INSV
:
6441 fprintf (file
, _("OPR_INSV (insert field)\n"));
6443 case ETIR__C_OPR_ASH
:
6444 fprintf (file
, _("OPR_ASH (arithmetic shift)\n"));
6446 case ETIR__C_OPR_USH
:
6447 fprintf (file
, _("OPR_USH (unsigned shift)\n"));
6449 case ETIR__C_OPR_ROT
:
6450 fprintf (file
, _("OPR_ROT (rotate)\n"));
6452 case ETIR__C_OPR_SEL
:
6453 fprintf (file
, _("OPR_SEL (select)\n"));
6455 case ETIR__C_OPR_REDEF
:
6456 fprintf (file
, _("OPR_REDEF (redefine symbol to curr location)\n"));
6458 case ETIR__C_OPR_DFLIT
:
6459 fprintf (file
, _("OPR_REDEF (define a literal)\n"));
6462 case ETIR__C_STC_LP
:
6463 fprintf (file
, _("STC_LP (store cond linkage pair)\n"));
6465 case ETIR__C_STC_LP_PSB
:
6467 _("STC_LP_PSB (store cond linkage pair + signature)\n"));
6468 /* xgettext:c-format */
6469 fprintf (file
, _(" linkage index: %u, procedure: %.*s\n"),
6470 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6471 buf
+= 4 + 1 + buf
[4];
6472 fprintf (file
, _(" signature: %.*s\n"), buf
[0], buf
+ 1);
6474 case ETIR__C_STC_GBL
:
6475 fprintf (file
, _("STC_GBL (store cond global)\n"));
6476 /* xgettext:c-format */
6477 fprintf (file
, _(" linkage index: %u, global: %.*s\n"),
6478 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6480 case ETIR__C_STC_GCA
:
6481 fprintf (file
, _("STC_GCA (store cond code address)\n"));
6482 /* xgettext:c-format */
6483 fprintf (file
, _(" linkage index: %u, procedure name: %.*s\n"),
6484 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6486 case ETIR__C_STC_PS
:
6487 fprintf (file
, _("STC_PS (store cond psect + offset)\n"));
6489 /* xgettext:c-format */
6490 _(" linkage index: %u, psect: %u, offset: 0x%08x %08x\n"),
6491 (unsigned)bfd_getl32 (buf
),
6492 (unsigned)bfd_getl32 (buf
+ 4),
6493 (unsigned)bfd_getl32 (buf
+ 12),
6494 (unsigned)bfd_getl32 (buf
+ 8));
6496 case ETIR__C_STC_NOP_GBL
:
6497 fprintf (file
, _("STC_NOP_GBL (store cond NOP at global addr)\n"));
6498 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6500 case ETIR__C_STC_NOP_PS
:
6501 fprintf (file
, _("STC_NOP_PS (store cond NOP at psect + offset)\n"));
6502 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6504 case ETIR__C_STC_BSR_GBL
:
6505 fprintf (file
, _("STC_BSR_GBL (store cond BSR at global addr)\n"));
6506 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6508 case ETIR__C_STC_BSR_PS
:
6509 fprintf (file
, _("STC_BSR_PS (store cond BSR at psect + offset)\n"));
6510 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6512 case ETIR__C_STC_LDA_GBL
:
6513 fprintf (file
, _("STC_LDA_GBL (store cond LDA at global addr)\n"));
6514 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6516 case ETIR__C_STC_LDA_PS
:
6517 fprintf (file
, _("STC_LDA_PS (store cond LDA at psect + offset)\n"));
6518 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6520 case ETIR__C_STC_BOH_GBL
:
6521 fprintf (file
, _("STC_BOH_GBL (store cond BOH at global addr)\n"));
6522 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6524 case ETIR__C_STC_BOH_PS
:
6525 fprintf (file
, _("STC_BOH_PS (store cond BOH at psect + offset)\n"));
6526 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6528 case ETIR__C_STC_NBH_GBL
:
6530 _("STC_NBH_GBL (store cond or hint at global addr)\n"));
6532 case ETIR__C_STC_NBH_PS
:
6534 _("STC_NBH_PS (store cond or hint at psect + offset)\n"));
6537 case ETIR__C_CTL_SETRB
:
6538 fprintf (file
, _("CTL_SETRB (set relocation base)\n"));
6541 case ETIR__C_CTL_AUGRB
:
6543 unsigned int val
= bfd_getl32 (buf
);
6544 fprintf (file
, _("CTL_AUGRB (augment relocation base) %u\n"), val
);
6547 case ETIR__C_CTL_DFLOC
:
6548 fprintf (file
, _("CTL_DFLOC (define location)\n"));
6550 case ETIR__C_CTL_STLOC
:
6551 fprintf (file
, _("CTL_STLOC (set location)\n"));
6553 case ETIR__C_CTL_STKDL
:
6554 fprintf (file
, _("CTL_STKDL (stack defined location)\n"));
6557 fprintf (file
, _("*unhandled*\n"));
6565 evax_bfd_print_eobj (struct bfd
*abfd
, FILE *file
)
6567 bfd_boolean is_first
= TRUE
;
6568 bfd_boolean has_records
= FALSE
;
6572 unsigned int rec_len
;
6573 unsigned int pad_len
;
6575 unsigned int hdr_size
;
6580 unsigned char buf
[6];
6585 if (bfd_bread (buf
, sizeof (buf
), abfd
) != sizeof (buf
))
6587 fprintf (file
, _("cannot read GST record length\n"));
6590 rec_len
= bfd_getl16 (buf
+ 0);
6591 if (rec_len
== bfd_getl16 (buf
+ 4)
6592 && bfd_getl16 (buf
+ 2) == EOBJ__C_EMH
)
6594 /* The format is raw: record-size, type, record-size. */
6596 pad_len
= (rec_len
+ 1) & ~1U;
6599 else if (rec_len
== EOBJ__C_EMH
)
6601 has_records
= FALSE
;
6602 pad_len
= bfd_getl16 (buf
+ 2);
6608 fprintf (file
, _("cannot find EMH in first GST record\n"));
6611 rec
= bfd_malloc (pad_len
);
6612 memcpy (rec
, buf
+ sizeof (buf
) - hdr_size
, hdr_size
);
6616 unsigned int rec_len2
= 0;
6617 unsigned char hdr
[4];
6621 unsigned char buf_len
[2];
6623 if (bfd_bread (buf_len
, sizeof (buf_len
), abfd
)
6624 != sizeof (buf_len
))
6626 fprintf (file
, _("cannot read GST record length\n"));
6629 rec_len2
= (unsigned)bfd_getl16 (buf_len
);
6632 if (bfd_bread (hdr
, sizeof (hdr
), abfd
) != sizeof (hdr
))
6634 fprintf (file
, _("cannot read GST record header\n"));
6637 rec_len
= (unsigned)bfd_getl16 (hdr
+ 2);
6639 pad_len
= (rec_len
+ 1) & ~1U;
6642 rec
= bfd_malloc (pad_len
);
6643 memcpy (rec
, hdr
, sizeof (hdr
));
6644 hdr_size
= sizeof (hdr
);
6645 if (has_records
&& rec_len2
!= rec_len
)
6647 fprintf (file
, _(" corrupted GST\n"));
6652 if (bfd_bread (rec
+ hdr_size
, pad_len
- hdr_size
, abfd
)
6653 != pad_len
- hdr_size
)
6655 fprintf (file
, _("cannot read GST record\n"));
6659 type
= (unsigned)bfd_getl16 (rec
);
6664 evax_bfd_print_emh (file
, rec
, rec_len
);
6667 evax_bfd_print_egsd (file
, rec
, rec_len
);
6670 evax_bfd_print_eeom (file
, rec
, rec_len
);
6675 evax_bfd_print_etir (file
, "ETIR", rec
, rec_len
);
6678 evax_bfd_print_etir (file
, "EDBG", rec
, rec_len
);
6681 evax_bfd_print_etir (file
, "ETBT", rec
, rec_len
);
6684 fprintf (file
, _(" unhandled EOBJ record type %u\n"), type
);
6692 evax_bfd_print_relocation_records (FILE *file
, const unsigned char *rel
,
6693 unsigned int stride
)
6701 count
= bfd_getl32 (rel
+ 0);
6705 base
= bfd_getl32 (rel
+ 4);
6707 /* xgettext:c-format */
6708 fprintf (file
, _(" bitcount: %u, base addr: 0x%08x\n"),
6712 for (j
= 0; count
> 0; j
+= 4, count
-= 32)
6718 val
= bfd_getl32 (rel
);
6721 /* xgettext:c-format */
6722 fprintf (file
, _(" bitmap: 0x%08x (count: %u):\n"), val
, count
);
6724 for (k
= 0; k
< 32; k
++)
6725 if (val
& (1u << k
))
6729 fprintf (file
, _(" %08x"), base
+ (j
* 8 + k
) * stride
);
6744 evax_bfd_print_address_fixups (FILE *file
, const unsigned char *rel
)
6751 count
= bfd_getl32 (rel
+ 0);
6754 /* xgettext:c-format */
6755 fprintf (file
, _(" image %u (%u entries)\n"),
6756 (unsigned)bfd_getl32 (rel
+ 4), count
);
6758 for (j
= 0; j
< count
; j
++)
6760 /* xgettext:c-format */
6761 fprintf (file
, _(" offset: 0x%08x, val: 0x%08x\n"),
6762 (unsigned)bfd_getl32 (rel
+ 0),
6763 (unsigned)bfd_getl32 (rel
+ 4));
6770 evax_bfd_print_reference_fixups (FILE *file
, const unsigned char *rel
)
6779 count
= bfd_getl32 (rel
+ 0);
6782 /* xgettext:c-format */
6783 fprintf (file
, _(" image %u (%u entries), offsets:\n"),
6784 (unsigned)bfd_getl32 (rel
+ 4), count
);
6786 for (j
= 0; j
< count
; j
++)
6790 fprintf (file
, _(" 0x%08x"), (unsigned)bfd_getl32 (rel
));
6805 evax_bfd_print_indent (int indent
, FILE *file
)
6807 for (; indent
; indent
--)
6812 evax_bfd_get_dsc_name (unsigned int v
)
6816 case DSC__K_DTYPE_Z
:
6817 return "Z (Unspecified)";
6818 case DSC__K_DTYPE_V
:
6820 case DSC__K_DTYPE_BU
:
6821 return "BU (Byte logical)";
6822 case DSC__K_DTYPE_WU
:
6823 return "WU (Word logical)";
6824 case DSC__K_DTYPE_LU
:
6825 return "LU (Longword logical)";
6826 case DSC__K_DTYPE_QU
:
6827 return "QU (Quadword logical)";
6828 case DSC__K_DTYPE_B
:
6829 return "B (Byte integer)";
6830 case DSC__K_DTYPE_W
:
6831 return "W (Word integer)";
6832 case DSC__K_DTYPE_L
:
6833 return "L (Longword integer)";
6834 case DSC__K_DTYPE_Q
:
6835 return "Q (Quadword integer)";
6836 case DSC__K_DTYPE_F
:
6837 return "F (Single-precision floating)";
6838 case DSC__K_DTYPE_D
:
6839 return "D (Double-precision floating)";
6840 case DSC__K_DTYPE_FC
:
6841 return "FC (Complex)";
6842 case DSC__K_DTYPE_DC
:
6843 return "DC (Double-precision Complex)";
6844 case DSC__K_DTYPE_T
:
6845 return "T (ASCII text string)";
6846 case DSC__K_DTYPE_NU
:
6847 return "NU (Numeric string, unsigned)";
6848 case DSC__K_DTYPE_NL
:
6849 return "NL (Numeric string, left separate sign)";
6850 case DSC__K_DTYPE_NLO
:
6851 return "NLO (Numeric string, left overpunched sign)";
6852 case DSC__K_DTYPE_NR
:
6853 return "NR (Numeric string, right separate sign)";
6854 case DSC__K_DTYPE_NRO
:
6855 return "NRO (Numeric string, right overpunched sig)";
6856 case DSC__K_DTYPE_NZ
:
6857 return "NZ (Numeric string, zoned sign)";
6858 case DSC__K_DTYPE_P
:
6859 return "P (Packed decimal string)";
6860 case DSC__K_DTYPE_ZI
:
6861 return "ZI (Sequence of instructions)";
6862 case DSC__K_DTYPE_ZEM
:
6863 return "ZEM (Procedure entry mask)";
6864 case DSC__K_DTYPE_DSC
:
6865 return "DSC (Descriptor, used for arrays of dyn strings)";
6866 case DSC__K_DTYPE_OU
:
6867 return "OU (Octaword logical)";
6868 case DSC__K_DTYPE_O
:
6869 return "O (Octaword integer)";
6870 case DSC__K_DTYPE_G
:
6871 return "G (Double precision G floating, 64 bit)";
6872 case DSC__K_DTYPE_H
:
6873 return "H (Quadruple precision floating, 128 bit)";
6874 case DSC__K_DTYPE_GC
:
6875 return "GC (Double precision complex, G floating)";
6876 case DSC__K_DTYPE_HC
:
6877 return "HC (Quadruple precision complex, H floating)";
6878 case DSC__K_DTYPE_CIT
:
6879 return "CIT (COBOL intermediate temporary)";
6880 case DSC__K_DTYPE_BPV
:
6881 return "BPV (Bound Procedure Value)";
6882 case DSC__K_DTYPE_BLV
:
6883 return "BLV (Bound Label Value)";
6884 case DSC__K_DTYPE_VU
:
6885 return "VU (Bit Unaligned)";
6886 case DSC__K_DTYPE_ADT
:
6887 return "ADT (Absolute Date-Time)";
6888 case DSC__K_DTYPE_VT
:
6889 return "VT (Varying Text)";
6890 case DSC__K_DTYPE_T2
:
6891 return "T2 (16-bit char)";
6892 case DSC__K_DTYPE_VT2
:
6893 return "VT2 (16-bit varying char)";
6895 return "?? (unknown)";
6900 evax_bfd_print_desc (const unsigned char *buf
, int indent
, FILE *file
)
6902 unsigned char bclass
= buf
[3];
6903 unsigned char dtype
= buf
[2];
6904 unsigned int len
= (unsigned)bfd_getl16 (buf
);
6905 unsigned int pointer
= (unsigned)bfd_getl32 (buf
+ 4);
6907 evax_bfd_print_indent (indent
, file
);
6909 if (len
== 1 && pointer
== 0xffffffffUL
)
6912 fprintf (file
, _("64 bits *unhandled*\n"));
6916 /* xgettext:c-format */
6917 fprintf (file
, _("class: %u, dtype: %u, length: %u, pointer: 0x%08x\n"),
6918 bclass
, dtype
, len
, pointer
);
6921 case DSC__K_CLASS_NCA
:
6923 const struct vms_dsc_nca
*dsc
= (const void *)buf
;
6925 const unsigned char *b
;
6927 evax_bfd_print_indent (indent
, file
);
6928 fprintf (file
, _("non-contiguous array of %s\n"),
6929 evax_bfd_get_dsc_name (dsc
->dtype
));
6930 evax_bfd_print_indent (indent
+ 1, file
);
6932 /* xgettext:c-format */
6933 _("dimct: %u, aflags: 0x%02x, digits: %u, scale: %u\n"),
6934 dsc
->dimct
, dsc
->aflags
, dsc
->digits
, dsc
->scale
);
6935 evax_bfd_print_indent (indent
+ 1, file
);
6937 /* xgettext:c-format */
6938 _("arsize: %u, a0: 0x%08x\n"),
6939 (unsigned)bfd_getl32 (dsc
->arsize
),
6940 (unsigned)bfd_getl32 (dsc
->a0
));
6941 evax_bfd_print_indent (indent
+ 1, file
);
6942 fprintf (file
, _("Strides:\n"));
6943 b
= buf
+ sizeof (*dsc
);
6944 for (i
= 0; i
< dsc
->dimct
; i
++)
6946 evax_bfd_print_indent (indent
+ 2, file
);
6947 fprintf (file
, "[%u]: %u\n", i
+ 1,
6948 (unsigned)bfd_getl32 (b
));
6951 evax_bfd_print_indent (indent
+ 1, file
);
6952 fprintf (file
, _("Bounds:\n"));
6953 b
= buf
+ sizeof (*dsc
);
6954 for (i
= 0; i
< dsc
->dimct
; i
++)
6956 evax_bfd_print_indent (indent
+ 2, file
);
6957 /* xgettext:c-format */
6958 fprintf (file
, _("[%u]: Lower: %u, upper: %u\n"), i
+ 1,
6959 (unsigned)bfd_getl32 (b
+ 0),
6960 (unsigned)bfd_getl32 (b
+ 4));
6965 case DSC__K_CLASS_UBS
:
6967 const struct vms_dsc_ubs
*ubs
= (const void *)buf
;
6969 evax_bfd_print_indent (indent
, file
);
6970 fprintf (file
, _("unaligned bit-string of %s\n"),
6971 evax_bfd_get_dsc_name (ubs
->dtype
));
6972 evax_bfd_print_indent (indent
+ 1, file
);
6974 /* xgettext:c-format */
6975 _("base: %u, pos: %u\n"),
6976 (unsigned)bfd_getl32 (ubs
->base
),
6977 (unsigned)bfd_getl32 (ubs
->pos
));
6981 fprintf (file
, _("*unhandled*\n"));
6988 evax_bfd_print_valspec (const unsigned char *buf
, int indent
, FILE *file
)
6990 unsigned int vflags
= buf
[0];
6991 unsigned int value
= (unsigned)bfd_getl32 (buf
+ 1);
6992 unsigned int len
= 5;
6994 evax_bfd_print_indent (indent
, file
);
6995 /* xgettext:c-format */
6996 fprintf (file
, _("vflags: 0x%02x, value: 0x%08x "), vflags
, value
);
7001 case DST__K_VFLAGS_NOVAL
:
7002 fprintf (file
, _("(no value)\n"));
7004 case DST__K_VFLAGS_NOTACTIVE
:
7005 fprintf (file
, _("(not active)\n"));
7007 case DST__K_VFLAGS_UNALLOC
:
7008 fprintf (file
, _("(not allocated)\n"));
7010 case DST__K_VFLAGS_DSC
:
7011 fprintf (file
, _("(descriptor)\n"));
7012 evax_bfd_print_desc (buf
+ value
, indent
+ 1, file
);
7014 case DST__K_VFLAGS_TVS
:
7015 fprintf (file
, _("(trailing value)\n"));
7017 case DST__K_VS_FOLLOWS
:
7018 fprintf (file
, _("(value spec follows)\n"));
7020 case DST__K_VFLAGS_BITOFFS
:
7021 fprintf (file
, _("(at bit offset %u)\n"), value
);
7024 /* xgettext:c-format */
7025 fprintf (file
, _("(reg: %u, disp: %u, indir: %u, kind: "),
7026 (vflags
& DST__K_REGNUM_MASK
) >> DST__K_REGNUM_SHIFT
,
7027 vflags
& DST__K_DISP
? 1 : 0,
7028 vflags
& DST__K_INDIR
? 1 : 0);
7029 switch (vflags
& DST__K_VALKIND_MASK
)
7031 case DST__K_VALKIND_LITERAL
:
7032 fputs (_("literal"), file
);
7034 case DST__K_VALKIND_ADDR
:
7035 fputs (_("address"), file
);
7037 case DST__K_VALKIND_DESC
:
7038 fputs (_("desc"), file
);
7040 case DST__K_VALKIND_REG
:
7041 fputs (_("reg"), file
);
7044 fputs (")\n", file
);
7051 evax_bfd_print_typspec (const unsigned char *buf
, int indent
, FILE *file
)
7053 unsigned char kind
= buf
[2];
7054 unsigned int len
= (unsigned)bfd_getl16 (buf
);
7056 evax_bfd_print_indent (indent
, file
);
7057 /* xgettext:c-format */
7058 fprintf (file
, _("len: %2u, kind: %2u "), len
, kind
);
7062 case DST__K_TS_ATOM
:
7063 /* xgettext:c-format */
7064 fprintf (file
, _("atomic, type=0x%02x %s\n"),
7065 buf
[0], evax_bfd_get_dsc_name (buf
[0]));
7068 fprintf (file
, _("indirect, defined at 0x%08x\n"),
7069 (unsigned)bfd_getl32 (buf
));
7071 case DST__K_TS_TPTR
:
7072 fprintf (file
, _("typed pointer\n"));
7073 evax_bfd_print_typspec (buf
, indent
+ 1, file
);
7076 fprintf (file
, _("pointer\n"));
7078 case DST__K_TS_ARRAY
:
7080 const unsigned char *vs
;
7081 unsigned int vec_len
;
7084 fprintf (file
, _("array, dim: %u, bitmap: "), buf
[0]);
7085 vec_len
= (buf
[0] + 1 + 7) / 8;
7086 for (i
= 0; i
< vec_len
; i
++)
7087 fprintf (file
, " %02x", buf
[i
+ 1]);
7089 vs
= buf
+ 1 + vec_len
;
7090 evax_bfd_print_indent (indent
, file
);
7091 fprintf (file
, _("array descriptor:\n"));
7092 vs
+= evax_bfd_print_valspec (vs
, indent
+ 1, file
);
7093 for (i
= 0; i
< buf
[0] + 1U; i
++)
7094 if (buf
[1 + i
/ 8] & (1 << (i
% 8)))
7096 evax_bfd_print_indent (indent
, file
);
7098 fprintf (file
, _("type spec for element:\n"));
7100 fprintf (file
, _("type spec for subscript %u:\n"), i
);
7101 evax_bfd_print_typspec (vs
, indent
+ 1, file
);
7102 vs
+= bfd_getl16 (vs
);
7107 fprintf (file
, _("*unhandled*\n"));
7112 evax_bfd_print_dst (struct bfd
*abfd
, unsigned int dst_size
, FILE *file
)
7114 unsigned int off
= 0;
7115 unsigned int pc
= 0;
7116 unsigned int line
= 0;
7118 fprintf (file
, _("Debug symbol table:\n"));
7120 while (dst_size
> 0)
7122 struct vms_dst_header dsth
;
7127 if (bfd_bread (&dsth
, sizeof (dsth
), abfd
) != sizeof (dsth
))
7129 fprintf (file
, _("cannot read DST header\n"));
7132 len
= bfd_getl16 (dsth
.length
);
7133 type
= bfd_getl16 (dsth
.type
);
7134 /* xgettext:c-format */
7135 fprintf (file
, _(" type: %3u, len: %3u (at 0x%08x): "),
7145 len
-= sizeof (dsth
);
7146 buf
= bfd_malloc (len
);
7147 if (bfd_bread (buf
, len
, abfd
) != len
)
7149 fprintf (file
, _("cannot read DST symbol\n"));
7154 case DSC__K_DTYPE_V
:
7155 case DSC__K_DTYPE_BU
:
7156 case DSC__K_DTYPE_WU
:
7157 case DSC__K_DTYPE_LU
:
7158 case DSC__K_DTYPE_QU
:
7159 case DSC__K_DTYPE_B
:
7160 case DSC__K_DTYPE_W
:
7161 case DSC__K_DTYPE_L
:
7162 case DSC__K_DTYPE_Q
:
7163 case DSC__K_DTYPE_F
:
7164 case DSC__K_DTYPE_D
:
7165 case DSC__K_DTYPE_FC
:
7166 case DSC__K_DTYPE_DC
:
7167 case DSC__K_DTYPE_T
:
7168 case DSC__K_DTYPE_NU
:
7169 case DSC__K_DTYPE_NL
:
7170 case DSC__K_DTYPE_NLO
:
7171 case DSC__K_DTYPE_NR
:
7172 case DSC__K_DTYPE_NRO
:
7173 case DSC__K_DTYPE_NZ
:
7174 case DSC__K_DTYPE_P
:
7175 case DSC__K_DTYPE_ZI
:
7176 case DSC__K_DTYPE_ZEM
:
7177 case DSC__K_DTYPE_DSC
:
7178 case DSC__K_DTYPE_OU
:
7179 case DSC__K_DTYPE_O
:
7180 case DSC__K_DTYPE_G
:
7181 case DSC__K_DTYPE_H
:
7182 case DSC__K_DTYPE_GC
:
7183 case DSC__K_DTYPE_HC
:
7184 case DSC__K_DTYPE_CIT
:
7185 case DSC__K_DTYPE_BPV
:
7186 case DSC__K_DTYPE_BLV
:
7187 case DSC__K_DTYPE_VU
:
7188 case DSC__K_DTYPE_ADT
:
7189 case DSC__K_DTYPE_VT
:
7190 case DSC__K_DTYPE_T2
:
7191 case DSC__K_DTYPE_VT2
:
7192 fprintf (file
, _("standard data: %s\n"),
7193 evax_bfd_get_dsc_name (type
));
7194 evax_bfd_print_valspec (buf
, 4, file
);
7195 fprintf (file
, _(" name: %.*s\n"), buf
[5], buf
+ 6);
7199 struct vms_dst_modbeg
*dst
= (void *)buf
;
7200 const char *name
= (const char *)buf
+ sizeof (*dst
);
7202 fprintf (file
, _("modbeg\n"));
7203 /* xgettext:c-format */
7204 fprintf (file
, _(" flags: %d, language: %u, "
7205 "major: %u, minor: %u\n"),
7207 (unsigned)bfd_getl32 (dst
->language
),
7208 (unsigned)bfd_getl16 (dst
->major
),
7209 (unsigned)bfd_getl16 (dst
->minor
));
7210 fprintf (file
, _(" module name: %.*s\n"),
7212 name
+= name
[0] + 1;
7213 fprintf (file
, _(" compiler : %.*s\n"),
7218 fprintf (file
, _("modend\n"));
7222 struct vms_dst_rtnbeg
*dst
= (void *)buf
;
7223 const char *name
= (const char *)buf
+ sizeof (*dst
);
7225 fputs (_("rtnbeg\n"), file
);
7226 /* xgettext:c-format */
7227 fprintf (file
, _(" flags: %u, address: 0x%08x, "
7228 "pd-address: 0x%08x\n"),
7230 (unsigned)bfd_getl32 (dst
->address
),
7231 (unsigned)bfd_getl32 (dst
->pd_address
));
7232 fprintf (file
, _(" routine name: %.*s\n"),
7238 struct vms_dst_rtnend
*dst
= (void *)buf
;
7240 fprintf (file
, _("rtnend: size 0x%08x\n"),
7241 (unsigned)bfd_getl32 (dst
->size
));
7246 struct vms_dst_prolog
*dst
= (void *)buf
;
7248 fprintf (file
, _("prolog: bkpt address 0x%08x\n"),
7249 (unsigned)bfd_getl32 (dst
->bkpt_addr
));
7254 struct vms_dst_epilog
*dst
= (void *)buf
;
7256 /* xgettext:c-format */
7257 fprintf (file
, _("epilog: flags: %u, count: %u\n"),
7258 dst
->flags
, (unsigned)bfd_getl32 (dst
->count
));
7263 struct vms_dst_blkbeg
*dst
= (void *)buf
;
7264 const char *name
= (const char *)buf
+ sizeof (*dst
);
7266 /* xgettext:c-format */
7267 fprintf (file
, _("blkbeg: address: 0x%08x, name: %.*s\n"),
7268 (unsigned)bfd_getl32 (dst
->address
),
7274 struct vms_dst_blkend
*dst
= (void *)buf
;
7276 fprintf (file
, _("blkend: size: 0x%08x\n"),
7277 (unsigned)bfd_getl32 (dst
->size
));
7280 case DST__K_TYPSPEC
:
7282 fprintf (file
, _("typspec (len: %u)\n"), len
);
7283 fprintf (file
, _(" name: %.*s\n"), buf
[0], buf
+ 1);
7284 evax_bfd_print_typspec (buf
+ 1 + buf
[0], 5, file
);
7289 fprintf (file
, _("septyp, name: %.*s\n"), buf
[5], buf
+ 6);
7290 evax_bfd_print_valspec (buf
, 4, file
);
7295 struct vms_dst_recbeg
*recbeg
= (void *)buf
;
7296 const char *name
= (const char *)buf
+ sizeof (*recbeg
);
7298 fprintf (file
, _("recbeg: name: %.*s\n"), name
[0], name
+ 1);
7299 evax_bfd_print_valspec (buf
, 4, file
);
7300 fprintf (file
, _(" len: %u bits\n"),
7301 (unsigned)bfd_getl32 (name
+ 1 + name
[0]));
7305 fprintf (file
, _("recend\n"));
7307 case DST__K_ENUMBEG
:
7308 /* xgettext:c-format */
7309 fprintf (file
, _("enumbeg, len: %u, name: %.*s\n"),
7310 buf
[0], buf
[1], buf
+ 2);
7312 case DST__K_ENUMELT
:
7313 fprintf (file
, _("enumelt, name: %.*s\n"), buf
[5], buf
+ 6);
7314 evax_bfd_print_valspec (buf
, 4, file
);
7316 case DST__K_ENUMEND
:
7317 fprintf (file
, _("enumend\n"));
7321 struct vms_dst_label
*lab
= (void *)buf
;
7322 fprintf (file
, _("label, name: %.*s\n"),
7323 lab
->name
[0], lab
->name
+ 1);
7324 fprintf (file
, _(" address: 0x%08x\n"),
7325 (unsigned)bfd_getl32 (lab
->value
));
7328 case DST__K_DIS_RANGE
:
7330 unsigned int cnt
= bfd_getl32 (buf
);
7331 unsigned char *rng
= buf
+ 4;
7334 fprintf (file
, _("discontiguous range (nbr: %u)\n"), cnt
);
7335 for (i
= 0; i
< cnt
; i
++, rng
+= 8)
7336 /* xgettext:c-format */
7337 fprintf (file
, _(" address: 0x%08x, size: %u\n"),
7338 (unsigned)bfd_getl32 (rng
),
7339 (unsigned)bfd_getl32 (rng
+ 4));
7343 case DST__K_LINE_NUM
:
7345 unsigned char *buf_orig
= buf
;
7347 fprintf (file
, _("line num (len: %u)\n"), len
);
7352 unsigned char cmdlen
;
7362 case DST__K_DELTA_PC_W
:
7363 val
= bfd_getl16 (buf
+ 1);
7364 fprintf (file
, _("delta_pc_w %u\n"), val
);
7369 case DST__K_INCR_LINUM
:
7371 fprintf (file
, _("incr_linum(b): +%u\n"), val
);
7375 case DST__K_INCR_LINUM_W
:
7376 val
= bfd_getl16 (buf
+ 1);
7377 fprintf (file
, _("incr_linum_w: +%u\n"), val
);
7381 case DST__K_INCR_LINUM_L
:
7382 val
= bfd_getl32 (buf
+ 1);
7383 fprintf (file
, _("incr_linum_l: +%u\n"), val
);
7387 case DST__K_SET_LINUM
:
7388 line
= bfd_getl16 (buf
+ 1);
7389 fprintf (file
, _("set_line_num(w) %u\n"), line
);
7392 case DST__K_SET_LINUM_B
:
7394 fprintf (file
, _("set_line_num_b %u\n"), line
);
7397 case DST__K_SET_LINUM_L
:
7398 line
= bfd_getl32 (buf
+ 1);
7399 fprintf (file
, _("set_line_num_l %u\n"), line
);
7402 case DST__K_SET_ABS_PC
:
7403 pc
= bfd_getl32 (buf
+ 1);
7404 fprintf (file
, _("set_abs_pc: 0x%08x\n"), pc
);
7407 case DST__K_DELTA_PC_L
:
7408 fprintf (file
, _("delta_pc_l: +0x%08x\n"),
7409 (unsigned)bfd_getl32 (buf
+ 1));
7413 fprintf (file
, _("term(b): 0x%02x"), buf
[1]);
7415 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7419 val
= bfd_getl16 (buf
+ 1);
7420 fprintf (file
, _("term_w: 0x%04x"), val
);
7422 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7428 fprintf (file
, _("delta pc +%-4d"), -cmd
);
7429 line
++; /* FIXME: curr increment. */
7431 /* xgettext:c-format */
7432 fprintf (file
, _(" pc: 0x%08x line: %5u\n"),
7437 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7450 unsigned char *buf_orig
= buf
;
7452 fprintf (file
, _("source (len: %u)\n"), len
);
7456 signed char cmd
= buf
[0];
7457 unsigned char cmdlen
= 0;
7461 case DST__K_SRC_DECLFILE
:
7463 struct vms_dst_src_decl_src
*src
= (void *)(buf
+ 1);
7466 /* xgettext:c-format */
7467 fprintf (file
, _(" declfile: len: %u, flags: %u, "
7469 src
->length
, src
->flags
,
7470 (unsigned)bfd_getl16 (src
->fileid
));
7471 /* xgettext:c-format */
7472 fprintf (file
, _(" rms: cdt: 0x%08x %08x, "
7473 "ebk: 0x%08x, ffb: 0x%04x, "
7475 (unsigned)bfd_getl32 (src
->rms_cdt
+ 4),
7476 (unsigned)bfd_getl32 (src
->rms_cdt
+ 0),
7477 (unsigned)bfd_getl32 (src
->rms_ebk
),
7478 (unsigned)bfd_getl16 (src
->rms_ffb
),
7480 name
= (const char *)buf
+ 1 + sizeof (*src
);
7481 fprintf (file
, _(" filename : %.*s\n"),
7483 name
+= name
[0] + 1;
7484 fprintf (file
, _(" module name: %.*s\n"),
7486 cmdlen
= 2 + src
->length
;
7489 case DST__K_SRC_SETFILE
:
7490 fprintf (file
, _(" setfile %u\n"),
7491 (unsigned)bfd_getl16 (buf
+ 1));
7494 case DST__K_SRC_SETREC_W
:
7495 fprintf (file
, _(" setrec %u\n"),
7496 (unsigned)bfd_getl16 (buf
+ 1));
7499 case DST__K_SRC_SETREC_L
:
7500 fprintf (file
, _(" setrec %u\n"),
7501 (unsigned)bfd_getl32 (buf
+ 1));
7504 case DST__K_SRC_SETLNUM_W
:
7505 fprintf (file
, _(" setlnum %u\n"),
7506 (unsigned)bfd_getl16 (buf
+ 1));
7509 case DST__K_SRC_SETLNUM_L
:
7510 fprintf (file
, _(" setlnum %u\n"),
7511 (unsigned)bfd_getl32 (buf
+ 1));
7514 case DST__K_SRC_DEFLINES_W
:
7515 fprintf (file
, _(" deflines %u\n"),
7516 (unsigned)bfd_getl16 (buf
+ 1));
7519 case DST__K_SRC_DEFLINES_B
:
7520 fprintf (file
, _(" deflines %u\n"), buf
[1]);
7523 case DST__K_SRC_FORMFEED
:
7524 fprintf (file
, _(" formfeed\n"));
7528 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7540 fprintf (file
, _("*unhandled* dst type %u\n"), type
);
7548 evax_bfd_print_image (bfd
*abfd
, FILE *file
)
7550 struct vms_eihd eihd
;
7553 unsigned int eiha_off
;
7554 unsigned int eihi_off
;
7555 unsigned int eihs_off
;
7556 unsigned int eisd_off
;
7557 unsigned int eihef_off
= 0;
7558 unsigned int eihnp_off
= 0;
7559 unsigned int dmt_vbn
= 0;
7560 unsigned int dmt_size
= 0;
7561 unsigned int dst_vbn
= 0;
7562 unsigned int dst_size
= 0;
7563 unsigned int gst_vbn
= 0;
7564 unsigned int gst_size
= 0;
7565 unsigned int eiaf_vbn
= 0;
7566 unsigned int eiaf_size
= 0;
7567 unsigned int eihvn_off
;
7569 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
)
7570 || bfd_bread (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
7572 fprintf (file
, _("cannot read EIHD\n"));
7575 /* xgettext:c-format */
7576 fprintf (file
, _("EIHD: (size: %u, nbr blocks: %u)\n"),
7577 (unsigned)bfd_getl32 (eihd
.size
),
7578 (unsigned)bfd_getl32 (eihd
.hdrblkcnt
));
7579 /* xgettext:c-format */
7580 fprintf (file
, _(" majorid: %u, minorid: %u\n"),
7581 (unsigned)bfd_getl32 (eihd
.majorid
),
7582 (unsigned)bfd_getl32 (eihd
.minorid
));
7584 val
= (unsigned)bfd_getl32 (eihd
.imgtype
);
7588 name
= _("executable");
7591 name
= _("linkable image");
7594 name
= _("unknown");
7597 /* xgettext:c-format */
7598 fprintf (file
, _(" image type: %u (%s)"), val
, name
);
7600 val
= (unsigned)bfd_getl32 (eihd
.subtype
);
7603 case EIHD__C_NATIVE
:
7610 name
= _("unknown");
7613 /* xgettext:c-format */
7614 fprintf (file
, _(", subtype: %u (%s)\n"), val
, name
);
7616 eisd_off
= bfd_getl32 (eihd
.isdoff
);
7617 eiha_off
= bfd_getl32 (eihd
.activoff
);
7618 eihi_off
= bfd_getl32 (eihd
.imgidoff
);
7619 eihs_off
= bfd_getl32 (eihd
.symdbgoff
);
7620 /* xgettext:c-format */
7621 fprintf (file
, _(" offsets: isd: %u, activ: %u, symdbg: %u, "
7622 "imgid: %u, patch: %u\n"),
7623 eisd_off
, eiha_off
, eihs_off
, eihi_off
,
7624 (unsigned)bfd_getl32 (eihd
.patchoff
));
7625 fprintf (file
, _(" fixup info rva: "));
7626 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.iafva
));
7627 fprintf (file
, _(", symbol vector rva: "));
7628 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.symvva
));
7629 eihvn_off
= bfd_getl32 (eihd
.version_array_off
);
7630 fprintf (file
, _("\n"
7631 " version array off: %u\n"),
7634 /* xgettext:c-format */
7635 _(" img I/O count: %u, nbr channels: %u, req pri: %08x%08x\n"),
7636 (unsigned)bfd_getl32 (eihd
.imgiocnt
),
7637 (unsigned)bfd_getl32 (eihd
.iochancnt
),
7638 (unsigned)bfd_getl32 (eihd
.privreqs
+ 4),
7639 (unsigned)bfd_getl32 (eihd
.privreqs
+ 0));
7640 val
= (unsigned)bfd_getl32 (eihd
.lnkflags
);
7641 fprintf (file
, _(" linker flags: %08x:"), val
);
7642 if (val
& EIHD__M_LNKDEBUG
)
7643 fprintf (file
, " LNKDEBUG");
7644 if (val
& EIHD__M_LNKNOTFR
)
7645 fprintf (file
, " LNKNOTFR");
7646 if (val
& EIHD__M_NOP0BUFS
)
7647 fprintf (file
, " NOP0BUFS");
7648 if (val
& EIHD__M_PICIMG
)
7649 fprintf (file
, " PICIMG");
7650 if (val
& EIHD__M_P0IMAGE
)
7651 fprintf (file
, " P0IMAGE");
7652 if (val
& EIHD__M_DBGDMT
)
7653 fprintf (file
, " DBGDMT");
7654 if (val
& EIHD__M_INISHR
)
7655 fprintf (file
, " INISHR");
7656 if (val
& EIHD__M_XLATED
)
7657 fprintf (file
, " XLATED");
7658 if (val
& EIHD__M_BIND_CODE_SEC
)
7659 fprintf (file
, " BIND_CODE_SEC");
7660 if (val
& EIHD__M_BIND_DATA_SEC
)
7661 fprintf (file
, " BIND_DATA_SEC");
7662 if (val
& EIHD__M_MKTHREADS
)
7663 fprintf (file
, " MKTHREADS");
7664 if (val
& EIHD__M_UPCALLS
)
7665 fprintf (file
, " UPCALLS");
7666 if (val
& EIHD__M_OMV_READY
)
7667 fprintf (file
, " OMV_READY");
7668 if (val
& EIHD__M_EXT_BIND_SECT
)
7669 fprintf (file
, " EXT_BIND_SECT");
7670 fprintf (file
, "\n");
7671 /* xgettext:c-format */
7672 fprintf (file
, _(" ident: 0x%08x, sysver: 0x%08x, "
7673 "match ctrl: %u, symvect_size: %u\n"),
7674 (unsigned)bfd_getl32 (eihd
.ident
),
7675 (unsigned)bfd_getl32 (eihd
.sysver
),
7677 (unsigned)bfd_getl32 (eihd
.symvect_size
));
7678 fprintf (file
, _(" BPAGE: %u"),
7679 (unsigned)bfd_getl32 (eihd
.virt_mem_block_size
));
7680 if (val
& (EIHD__M_OMV_READY
| EIHD__M_EXT_BIND_SECT
))
7682 eihef_off
= bfd_getl32 (eihd
.ext_fixup_off
);
7683 eihnp_off
= bfd_getl32 (eihd
.noopt_psect_off
);
7684 /* xgettext:c-format */
7685 fprintf (file
, _(", ext fixup offset: %u, no_opt psect off: %u"),
7686 eihef_off
, eihnp_off
);
7688 fprintf (file
, _(", alias: %u\n"), (unsigned)bfd_getl16 (eihd
.alias
));
7692 struct vms_eihvn eihvn
;
7696 fprintf (file
, _("system version array information:\n"));
7697 if (bfd_seek (abfd
, (file_ptr
) eihvn_off
, SEEK_SET
)
7698 || bfd_bread (&eihvn
, sizeof (eihvn
), abfd
) != sizeof (eihvn
))
7700 fprintf (file
, _("cannot read EIHVN header\n"));
7703 mask
= bfd_getl32 (eihvn
.subsystem_mask
);
7704 for (j
= 0; j
< 32; j
++)
7705 if (mask
& (1 << j
))
7707 struct vms_eihvn_subversion ver
;
7708 if (bfd_bread (&ver
, sizeof (ver
), abfd
) != sizeof (ver
))
7710 fprintf (file
, _("cannot read EIHVN version\n"));
7713 fprintf (file
, _(" %02u "), j
);
7716 case EIHVN__BASE_IMAGE_BIT
:
7717 fputs (_("BASE_IMAGE "), file
);
7719 case EIHVN__MEMORY_MANAGEMENT_BIT
:
7720 fputs (_("MEMORY_MANAGEMENT"), file
);
7723 fputs (_("IO "), file
);
7725 case EIHVN__FILES_VOLUMES_BIT
:
7726 fputs (_("FILES_VOLUMES "), file
);
7728 case EIHVN__PROCESS_SCHED_BIT
:
7729 fputs (_("PROCESS_SCHED "), file
);
7731 case EIHVN__SYSGEN_BIT
:
7732 fputs (_("SYSGEN "), file
);
7734 case EIHVN__CLUSTERS_LOCKMGR_BIT
:
7735 fputs (_("CLUSTERS_LOCKMGR "), file
);
7737 case EIHVN__LOGICAL_NAMES_BIT
:
7738 fputs (_("LOGICAL_NAMES "), file
);
7740 case EIHVN__SECURITY_BIT
:
7741 fputs (_("SECURITY "), file
);
7743 case EIHVN__IMAGE_ACTIVATOR_BIT
:
7744 fputs (_("IMAGE_ACTIVATOR "), file
);
7746 case EIHVN__NETWORKS_BIT
:
7747 fputs (_("NETWORKS "), file
);
7749 case EIHVN__COUNTERS_BIT
:
7750 fputs (_("COUNTERS "), file
);
7752 case EIHVN__STABLE_BIT
:
7753 fputs (_("STABLE "), file
);
7755 case EIHVN__MISC_BIT
:
7756 fputs (_("MISC "), file
);
7758 case EIHVN__CPU_BIT
:
7759 fputs (_("CPU "), file
);
7761 case EIHVN__VOLATILE_BIT
:
7762 fputs (_("VOLATILE "), file
);
7764 case EIHVN__SHELL_BIT
:
7765 fputs (_("SHELL "), file
);
7767 case EIHVN__POSIX_BIT
:
7768 fputs (_("POSIX "), file
);
7770 case EIHVN__MULTI_PROCESSING_BIT
:
7771 fputs (_("MULTI_PROCESSING "), file
);
7773 case EIHVN__GALAXY_BIT
:
7774 fputs (_("GALAXY "), file
);
7777 fputs (_("*unknown* "), file
);
7780 fprintf (file
, ": %u.%u\n",
7781 (unsigned)bfd_getl16 (ver
.major
),
7782 (unsigned)bfd_getl16 (ver
.minor
));
7788 struct vms_eiha eiha
;
7790 if (bfd_seek (abfd
, (file_ptr
) eiha_off
, SEEK_SET
)
7791 || bfd_bread (&eiha
, sizeof (eiha
), abfd
) != sizeof (eiha
))
7793 fprintf (file
, _("cannot read EIHA\n"));
7796 fprintf (file
, _("Image activation: (size=%u)\n"),
7797 (unsigned)bfd_getl32 (eiha
.size
));
7798 /* xgettext:c-format */
7799 fprintf (file
, _(" First address : 0x%08x 0x%08x\n"),
7800 (unsigned)bfd_getl32 (eiha
.tfradr1_h
),
7801 (unsigned)bfd_getl32 (eiha
.tfradr1
));
7802 /* xgettext:c-format */
7803 fprintf (file
, _(" Second address: 0x%08x 0x%08x\n"),
7804 (unsigned)bfd_getl32 (eiha
.tfradr2_h
),
7805 (unsigned)bfd_getl32 (eiha
.tfradr2
));
7806 /* xgettext:c-format */
7807 fprintf (file
, _(" Third address : 0x%08x 0x%08x\n"),
7808 (unsigned)bfd_getl32 (eiha
.tfradr3_h
),
7809 (unsigned)bfd_getl32 (eiha
.tfradr3
));
7810 /* xgettext:c-format */
7811 fprintf (file
, _(" Fourth address: 0x%08x 0x%08x\n"),
7812 (unsigned)bfd_getl32 (eiha
.tfradr4_h
),
7813 (unsigned)bfd_getl32 (eiha
.tfradr4
));
7814 /* xgettext:c-format */
7815 fprintf (file
, _(" Shared image : 0x%08x 0x%08x\n"),
7816 (unsigned)bfd_getl32 (eiha
.inishr_h
),
7817 (unsigned)bfd_getl32 (eiha
.inishr
));
7821 struct vms_eihi eihi
;
7823 if (bfd_seek (abfd
, (file_ptr
) eihi_off
, SEEK_SET
)
7824 || bfd_bread (&eihi
, sizeof (eihi
), abfd
) != sizeof (eihi
))
7826 fprintf (file
, _("cannot read EIHI\n"));
7829 /* xgettext:c-format */
7830 fprintf (file
, _("Image identification: (major: %u, minor: %u)\n"),
7831 (unsigned)bfd_getl32 (eihi
.majorid
),
7832 (unsigned)bfd_getl32 (eihi
.minorid
));
7833 fprintf (file
, _(" image name : %.*s\n"),
7834 eihi
.imgnam
[0], eihi
.imgnam
+ 1);
7835 fprintf (file
, _(" link time : %s\n"),
7836 vms_time_to_str (eihi
.linktime
));
7837 fprintf (file
, _(" image ident : %.*s\n"),
7838 eihi
.imgid
[0], eihi
.imgid
+ 1);
7839 fprintf (file
, _(" linker ident : %.*s\n"),
7840 eihi
.linkid
[0], eihi
.linkid
+ 1);
7841 fprintf (file
, _(" image build ident: %.*s\n"),
7842 eihi
.imgbid
[0], eihi
.imgbid
+ 1);
7846 struct vms_eihs eihs
;
7848 if (bfd_seek (abfd
, (file_ptr
) eihs_off
, SEEK_SET
)
7849 || bfd_bread (&eihs
, sizeof (eihs
), abfd
) != sizeof (eihs
))
7851 fprintf (file
, _("cannot read EIHS\n"));
7854 /* xgettext:c-format */
7855 fprintf (file
, _("Image symbol & debug table: (major: %u, minor: %u)\n"),
7856 (unsigned)bfd_getl32 (eihs
.majorid
),
7857 (unsigned)bfd_getl32 (eihs
.minorid
));
7858 dst_vbn
= bfd_getl32 (eihs
.dstvbn
);
7859 dst_size
= bfd_getl32 (eihs
.dstsize
);
7860 /* xgettext:c-format */
7861 fprintf (file
, _(" debug symbol table : vbn: %u, size: %u (0x%x)\n"),
7862 dst_vbn
, dst_size
, dst_size
);
7863 gst_vbn
= bfd_getl32 (eihs
.gstvbn
);
7864 gst_size
= bfd_getl32 (eihs
.gstsize
);
7865 /* xgettext:c-format */
7866 fprintf (file
, _(" global symbol table: vbn: %u, records: %u\n"),
7868 dmt_vbn
= bfd_getl32 (eihs
.dmtvbn
);
7869 dmt_size
= bfd_getl32 (eihs
.dmtsize
);
7870 /* xgettext:c-format */
7871 fprintf (file
, _(" debug module table : vbn: %u, size: %u\n"),
7874 while (eisd_off
!= 0)
7876 struct vms_eisd eisd
;
7881 if (bfd_seek (abfd
, (file_ptr
) eisd_off
, SEEK_SET
)
7882 || bfd_bread (&eisd
, sizeof (eisd
), abfd
) != sizeof (eisd
))
7884 fprintf (file
, _("cannot read EISD\n"));
7887 len
= (unsigned)bfd_getl32 (eisd
.eisdsize
);
7888 if (len
!= (unsigned)-1)
7892 eisd_off
= (eisd_off
+ VMS_BLOCK_SIZE
) & ~(VMS_BLOCK_SIZE
- 1);
7894 /* xgettext:c-format */
7895 fprintf (file
, _("Image section descriptor: (major: %u, minor: %u, "
7896 "size: %u, offset: %u)\n"),
7897 (unsigned)bfd_getl32 (eisd
.majorid
),
7898 (unsigned)bfd_getl32 (eisd
.minorid
),
7902 /* xgettext:c-format */
7903 fprintf (file
, _(" section: base: 0x%08x%08x size: 0x%08x\n"),
7904 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 4),
7905 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 0),
7906 (unsigned)bfd_getl32 (eisd
.secsize
));
7907 val
= (unsigned)bfd_getl32 (eisd
.flags
);
7908 fprintf (file
, _(" flags: 0x%04x"), val
);
7909 if (val
& EISD__M_GBL
)
7910 fprintf (file
, " GBL");
7911 if (val
& EISD__M_CRF
)
7912 fprintf (file
, " CRF");
7913 if (val
& EISD__M_DZRO
)
7914 fprintf (file
, " DZRO");
7915 if (val
& EISD__M_WRT
)
7916 fprintf (file
, " WRT");
7917 if (val
& EISD__M_INITALCODE
)
7918 fprintf (file
, " INITALCODE");
7919 if (val
& EISD__M_BASED
)
7920 fprintf (file
, " BASED");
7921 if (val
& EISD__M_FIXUPVEC
)
7922 fprintf (file
, " FIXUPVEC");
7923 if (val
& EISD__M_RESIDENT
)
7924 fprintf (file
, " RESIDENT");
7925 if (val
& EISD__M_VECTOR
)
7926 fprintf (file
, " VECTOR");
7927 if (val
& EISD__M_PROTECT
)
7928 fprintf (file
, " PROTECT");
7929 if (val
& EISD__M_LASTCLU
)
7930 fprintf (file
, " LASTCLU");
7931 if (val
& EISD__M_EXE
)
7932 fprintf (file
, " EXE");
7933 if (val
& EISD__M_NONSHRADR
)
7934 fprintf (file
, " NONSHRADR");
7935 if (val
& EISD__M_QUAD_LENGTH
)
7936 fprintf (file
, " QUAD_LENGTH");
7937 if (val
& EISD__M_ALLOC_64BIT
)
7938 fprintf (file
, " ALLOC_64BIT");
7939 fprintf (file
, "\n");
7940 if (val
& EISD__M_FIXUPVEC
)
7942 eiaf_vbn
= bfd_getl32 (eisd
.vbn
);
7943 eiaf_size
= bfd_getl32 (eisd
.secsize
);
7945 /* xgettext:c-format */
7946 fprintf (file
, _(" vbn: %u, pfc: %u, matchctl: %u type: %u ("),
7947 (unsigned)bfd_getl32 (eisd
.vbn
),
7948 eisd
.pfc
, eisd
.matchctl
, eisd
.type
);
7951 case EISD__K_NORMAL
:
7952 fputs (_("NORMAL"), file
);
7954 case EISD__K_SHRFXD
:
7955 fputs (_("SHRFXD"), file
);
7957 case EISD__K_PRVFXD
:
7958 fputs (_("PRVFXD"), file
);
7960 case EISD__K_SHRPIC
:
7961 fputs (_("SHRPIC"), file
);
7963 case EISD__K_PRVPIC
:
7964 fputs (_("PRVPIC"), file
);
7966 case EISD__K_USRSTACK
:
7967 fputs (_("USRSTACK"), file
);
7970 fputs (_("*unknown*"), file
);
7973 fputs (_(")\n"), file
);
7974 if (val
& EISD__M_GBL
)
7975 /* xgettext:c-format */
7976 fprintf (file
, _(" ident: 0x%08x, name: %.*s\n"),
7977 (unsigned)bfd_getl32 (eisd
.ident
),
7978 eisd
.gblnam
[0], eisd
.gblnam
+ 1);
7984 if (bfd_seek (abfd
, (file_ptr
) (dmt_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7986 fprintf (file
, _("cannot read DMT\n"));
7990 fprintf (file
, _("Debug module table:\n"));
7992 while (dmt_size
> 0)
7994 struct vms_dmt_header dmth
;
7997 if (bfd_bread (&dmth
, sizeof (dmth
), abfd
) != sizeof (dmth
))
7999 fprintf (file
, _("cannot read DMT header\n"));
8002 count
= bfd_getl16 (dmth
.psect_count
);
8004 /* xgettext:c-format */
8005 _(" module offset: 0x%08x, size: 0x%08x, (%u psects)\n"),
8006 (unsigned)bfd_getl32 (dmth
.modbeg
),
8007 (unsigned)bfd_getl32 (dmth
.size
), count
);
8008 dmt_size
-= sizeof (dmth
);
8011 struct vms_dmt_psect dmtp
;
8013 if (bfd_bread (&dmtp
, sizeof (dmtp
), abfd
) != sizeof (dmtp
))
8015 fprintf (file
, _("cannot read DMT psect\n"));
8018 /* xgettext:c-format */
8019 fprintf (file
, _(" psect start: 0x%08x, length: %u\n"),
8020 (unsigned)bfd_getl32 (dmtp
.start
),
8021 (unsigned)bfd_getl32 (dmtp
.length
));
8023 dmt_size
-= sizeof (dmtp
);
8030 if (bfd_seek (abfd
, (file_ptr
) (dst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
8032 fprintf (file
, _("cannot read DST\n"));
8036 evax_bfd_print_dst (abfd
, dst_size
, file
);
8040 if (bfd_seek (abfd
, (file_ptr
) (gst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
8042 fprintf (file
, _("cannot read GST\n"));
8046 fprintf (file
, _("Global symbol table:\n"));
8047 evax_bfd_print_eobj (abfd
, file
);
8052 struct vms_eiaf
*eiaf
;
8053 unsigned int qrelfixoff
;
8054 unsigned int lrelfixoff
;
8055 unsigned int qdotadroff
;
8056 unsigned int ldotadroff
;
8057 unsigned int shrimgcnt
;
8058 unsigned int shlstoff
;
8059 unsigned int codeadroff
;
8060 unsigned int lpfixoff
;
8061 unsigned int chgprtoff
;
8063 buf
= bfd_malloc (eiaf_size
);
8065 if (bfd_seek (abfd
, (file_ptr
) (eiaf_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
)
8066 || bfd_bread (buf
, eiaf_size
, abfd
) != eiaf_size
)
8068 fprintf (file
, _("cannot read EIHA\n"));
8072 eiaf
= (struct vms_eiaf
*)buf
;
8074 /* xgettext:c-format */
8075 _("Image activator fixup: (major: %u, minor: %u)\n"),
8076 (unsigned)bfd_getl32 (eiaf
->majorid
),
8077 (unsigned)bfd_getl32 (eiaf
->minorid
));
8078 /* xgettext:c-format */
8079 fprintf (file
, _(" iaflink : 0x%08x %08x\n"),
8080 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 0),
8081 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 4));
8082 /* xgettext:c-format */
8083 fprintf (file
, _(" fixuplnk: 0x%08x %08x\n"),
8084 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 0),
8085 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 4));
8086 fprintf (file
, _(" size : %u\n"),
8087 (unsigned)bfd_getl32 (eiaf
->size
));
8088 fprintf (file
, _(" flags: 0x%08x\n"),
8089 (unsigned)bfd_getl32 (eiaf
->flags
));
8090 qrelfixoff
= bfd_getl32 (eiaf
->qrelfixoff
);
8091 lrelfixoff
= bfd_getl32 (eiaf
->lrelfixoff
);
8092 /* xgettext:c-format */
8093 fprintf (file
, _(" qrelfixoff: %5u, lrelfixoff: %5u\n"),
8094 qrelfixoff
, lrelfixoff
);
8095 qdotadroff
= bfd_getl32 (eiaf
->qdotadroff
);
8096 ldotadroff
= bfd_getl32 (eiaf
->ldotadroff
);
8097 /* xgettext:c-format */
8098 fprintf (file
, _(" qdotadroff: %5u, ldotadroff: %5u\n"),
8099 qdotadroff
, ldotadroff
);
8100 codeadroff
= bfd_getl32 (eiaf
->codeadroff
);
8101 lpfixoff
= bfd_getl32 (eiaf
->lpfixoff
);
8102 /* xgettext:c-format */
8103 fprintf (file
, _(" codeadroff: %5u, lpfixoff : %5u\n"),
8104 codeadroff
, lpfixoff
);
8105 chgprtoff
= bfd_getl32 (eiaf
->chgprtoff
);
8106 fprintf (file
, _(" chgprtoff : %5u\n"), chgprtoff
);
8107 shrimgcnt
= bfd_getl32 (eiaf
->shrimgcnt
);
8108 shlstoff
= bfd_getl32 (eiaf
->shlstoff
);
8109 /* xgettext:c-format */
8110 fprintf (file
, _(" shlstoff : %5u, shrimgcnt : %5u\n"),
8111 shlstoff
, shrimgcnt
);
8112 /* xgettext:c-format */
8113 fprintf (file
, _(" shlextra : %5u, permctx : %5u\n"),
8114 (unsigned)bfd_getl32 (eiaf
->shlextra
),
8115 (unsigned)bfd_getl32 (eiaf
->permctx
));
8116 fprintf (file
, _(" base_va : 0x%08x\n"),
8117 (unsigned)bfd_getl32 (eiaf
->base_va
));
8118 fprintf (file
, _(" lppsbfixoff: %5u\n"),
8119 (unsigned)bfd_getl32 (eiaf
->lppsbfixoff
));
8123 struct vms_shl
*shl
= (struct vms_shl
*)(buf
+ shlstoff
);
8126 fprintf (file
, _(" Shareable images:\n"));
8127 for (j
= 0; j
< shrimgcnt
; j
++, shl
++)
8130 /* xgettext:c-format */
8131 _(" %u: size: %u, flags: 0x%02x, name: %.*s\n"),
8132 j
, shl
->size
, shl
->flags
,
8133 shl
->imgnam
[0], shl
->imgnam
+ 1);
8136 if (qrelfixoff
!= 0)
8138 fprintf (file
, _(" quad-word relocation fixups:\n"));
8139 evax_bfd_print_relocation_records (file
, buf
+ qrelfixoff
, 8);
8141 if (lrelfixoff
!= 0)
8143 fprintf (file
, _(" long-word relocation fixups:\n"));
8144 evax_bfd_print_relocation_records (file
, buf
+ lrelfixoff
, 4);
8146 if (qdotadroff
!= 0)
8148 fprintf (file
, _(" quad-word .address reference fixups:\n"));
8149 evax_bfd_print_address_fixups (file
, buf
+ qdotadroff
);
8151 if (ldotadroff
!= 0)
8153 fprintf (file
, _(" long-word .address reference fixups:\n"));
8154 evax_bfd_print_address_fixups (file
, buf
+ ldotadroff
);
8156 if (codeadroff
!= 0)
8158 fprintf (file
, _(" Code Address Reference Fixups:\n"));
8159 evax_bfd_print_reference_fixups (file
, buf
+ codeadroff
);
8163 fprintf (file
, _(" Linkage Pairs Reference Fixups:\n"));
8164 evax_bfd_print_reference_fixups (file
, buf
+ lpfixoff
);
8168 unsigned int count
= (unsigned)bfd_getl32 (buf
+ chgprtoff
);
8169 struct vms_eicp
*eicp
= (struct vms_eicp
*)(buf
+ chgprtoff
+ 4);
8172 fprintf (file
, _(" Change Protection (%u entries):\n"), count
);
8173 for (j
= 0; j
< count
; j
++, eicp
++)
8175 unsigned int prot
= bfd_getl32 (eicp
->newprt
);
8177 /* xgettext:c-format */
8178 _(" base: 0x%08x %08x, size: 0x%08x, prot: 0x%08x "),
8179 (unsigned)bfd_getl32 (eicp
->baseva
+ 4),
8180 (unsigned)bfd_getl32 (eicp
->baseva
+ 0),
8181 (unsigned)bfd_getl32 (eicp
->size
),
8182 (unsigned)bfd_getl32 (eicp
->newprt
));
8186 fprintf (file
, "NA");
8188 case PRT__C_RESERVED
:
8189 fprintf (file
, "RES");
8192 fprintf (file
, "KW");
8195 fprintf (file
, "KR");
8198 fprintf (file
, "UW");
8201 fprintf (file
, "EW");
8204 fprintf (file
, "ERKW");
8207 fprintf (file
, "ER");
8210 fprintf (file
, "SW");
8213 fprintf (file
, "SREW");
8216 fprintf (file
, "SRKW");
8219 fprintf (file
, "SR");
8222 fprintf (file
, "URSW");
8225 fprintf (file
, "UREW");
8228 fprintf (file
, "URKW");
8231 fprintf (file
, "UR");
8245 vms_bfd_print_private_bfd_data (bfd
*abfd
, void *ptr
)
8247 FILE *file
= (FILE *)ptr
;
8249 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
8250 evax_bfd_print_image (abfd
, file
);
8253 if (bfd_seek (abfd
, 0, SEEK_SET
))
8255 evax_bfd_print_eobj (abfd
, file
);
8262 /* Slurp ETIR/EDBG/ETBT VMS object records. */
8265 alpha_vms_read_sections_content (bfd
*abfd
, struct bfd_link_info
*info
)
8267 asection
*cur_section
;
8268 file_ptr cur_offset
;
8269 asection
*dst_section
;
8270 file_ptr dst_offset
;
8272 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
8278 dst_section
= PRIV (dst_section
);
8282 if (info
->strip
== strip_all
|| info
->strip
== strip_debugger
)
8284 /* Discard the DST section. */
8288 else if (dst_section
)
8290 dst_offset
= dst_section
->output_offset
;
8291 dst_section
= dst_section
->output_section
;
8300 type
= _bfd_vms_get_object_record (abfd
);
8303 vms_debug2 ((2, "next_record failed\n"));
8309 PRIV (image_section
) = cur_section
;
8310 PRIV (image_offset
) = cur_offset
;
8311 res
= _bfd_vms_slurp_etir (abfd
, info
);
8312 cur_section
= PRIV (image_section
);
8313 cur_offset
= PRIV (image_offset
);
8317 if (dst_section
== NULL
)
8319 PRIV (image_section
) = dst_section
;
8320 PRIV (image_offset
) = dst_offset
;
8321 res
= _bfd_vms_slurp_etir (abfd
, info
);
8322 dst_offset
= PRIV (image_offset
);
8331 vms_debug2 ((2, "slurp eobj type %d failed\n", type
));
8338 alpha_vms_sizeof_headers (bfd
*abfd ATTRIBUTE_UNUSED
,
8339 struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8344 /* Add a linkage pair fixup at address SECT + OFFSET to SHLIB. */
8347 alpha_vms_add_fixup_lp (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
8349 struct alpha_vms_shlib_el
*sl
;
8350 asection
*sect
= PRIV2 (src
, image_section
);
8351 file_ptr offset
= PRIV2 (src
, image_offset
);
8354 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8355 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8356 sl
->has_fixups
= TRUE
;
8357 p
= VEC_APPEND (sl
->lp
, bfd_vma
);
8360 *p
= sect
->output_section
->vma
+ sect
->output_offset
+ offset
;
8361 sect
->output_section
->flags
|= SEC_RELOC
;
8365 /* Add a code address fixup at address SECT + OFFSET to SHLIB. */
8368 alpha_vms_add_fixup_ca (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
8370 struct alpha_vms_shlib_el
*sl
;
8371 asection
*sect
= PRIV2 (src
, image_section
);
8372 file_ptr offset
= PRIV2 (src
, image_offset
);
8375 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8376 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8377 sl
->has_fixups
= TRUE
;
8378 p
= VEC_APPEND (sl
->ca
, bfd_vma
);
8381 *p
= sect
->output_section
->vma
+ sect
->output_offset
+ offset
;
8382 sect
->output_section
->flags
|= SEC_RELOC
;
8386 /* Add a quad word relocation fixup at address SECT + OFFSET to SHLIB. */
8389 alpha_vms_add_fixup_qr (struct bfd_link_info
*info
, bfd
*src
,
8390 bfd
*shlib
, bfd_vma vec
)
8392 struct alpha_vms_shlib_el
*sl
;
8393 struct alpha_vms_vma_ref
*r
;
8394 asection
*sect
= PRIV2 (src
, image_section
);
8395 file_ptr offset
= PRIV2 (src
, image_offset
);
8397 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8398 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8399 sl
->has_fixups
= TRUE
;
8400 r
= VEC_APPEND (sl
->qr
, struct alpha_vms_vma_ref
);
8403 r
->vma
= sect
->output_section
->vma
+ sect
->output_offset
+ offset
;
8405 sect
->output_section
->flags
|= SEC_RELOC
;
8410 alpha_vms_add_fixup_lr (struct bfd_link_info
*info ATTRIBUTE_UNUSED
,
8411 unsigned int shr ATTRIBUTE_UNUSED
,
8412 bfd_vma vec ATTRIBUTE_UNUSED
)
8414 /* Not yet supported. */
8418 /* Add relocation. FIXME: Not yet emitted. */
8421 alpha_vms_add_lw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8427 alpha_vms_add_qw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8432 static struct bfd_hash_entry
*
8433 alpha_vms_link_hash_newfunc (struct bfd_hash_entry
*entry
,
8434 struct bfd_hash_table
*table
,
8437 struct alpha_vms_link_hash_entry
*ret
=
8438 (struct alpha_vms_link_hash_entry
*) entry
;
8440 /* Allocate the structure if it has not already been allocated by a
8443 ret
= ((struct alpha_vms_link_hash_entry
*)
8444 bfd_hash_allocate (table
,
8445 sizeof (struct alpha_vms_link_hash_entry
)));
8449 /* Call the allocation method of the superclass. */
8450 ret
= ((struct alpha_vms_link_hash_entry
*)
8451 _bfd_link_hash_newfunc ((struct bfd_hash_entry
*) ret
,
8456 return (struct bfd_hash_entry
*) ret
;
8460 alpha_vms_bfd_link_hash_table_free (bfd
*abfd
)
8462 struct alpha_vms_link_hash_table
*t
;
8465 t
= (struct alpha_vms_link_hash_table
*) abfd
->link
.hash
;
8466 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8468 struct alpha_vms_shlib_el
*shlib
;
8470 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8471 free (&VEC_EL (shlib
->ca
, bfd_vma
, 0));
8472 free (&VEC_EL (shlib
->lp
, bfd_vma
, 0));
8473 free (&VEC_EL (shlib
->qr
, struct alpha_vms_vma_ref
, 0));
8475 free (&VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, 0));
8477 _bfd_generic_link_hash_table_free (abfd
);
8480 /* Create an Alpha/VMS link hash table. */
8482 static struct bfd_link_hash_table
*
8483 alpha_vms_bfd_link_hash_table_create (bfd
*abfd
)
8485 struct alpha_vms_link_hash_table
*ret
;
8486 size_t amt
= sizeof (struct alpha_vms_link_hash_table
);
8488 ret
= (struct alpha_vms_link_hash_table
*) bfd_malloc (amt
);
8491 if (!_bfd_link_hash_table_init (&ret
->root
, abfd
,
8492 alpha_vms_link_hash_newfunc
,
8493 sizeof (struct alpha_vms_link_hash_entry
)))
8499 VEC_INIT (ret
->shrlibs
);
8501 ret
->root
.hash_table_free
= alpha_vms_bfd_link_hash_table_free
;
8507 alpha_vms_link_add_object_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8511 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
8513 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
8514 struct alpha_vms_link_hash_entry
*h
;
8515 struct bfd_link_hash_entry
*h_root
;
8518 if (!alpha_vms_convert_symbol (abfd
, e
, &sym
))
8521 if ((e
->flags
& EGSY__V_DEF
) && abfd
->selective_search
)
8523 /* In selective_search mode, only add definition that are
8525 h
= (struct alpha_vms_link_hash_entry
*)bfd_link_hash_lookup
8526 (info
->hash
, sym
.name
, FALSE
, FALSE
, FALSE
);
8527 if (h
== NULL
|| h
->root
.type
!= bfd_link_hash_undefined
)
8533 h_root
= (struct bfd_link_hash_entry
*) h
;
8534 if (!_bfd_generic_link_add_one_symbol (info
, abfd
, sym
.name
, sym
.flags
,
8535 sym
.section
, sym
.value
, NULL
,
8536 FALSE
, FALSE
, &h_root
))
8538 h
= (struct alpha_vms_link_hash_entry
*) h_root
;
8540 if ((e
->flags
& EGSY__V_DEF
)
8542 && abfd
->xvec
== info
->output_bfd
->xvec
)
8546 if (abfd
->flags
& DYNAMIC
)
8548 struct alpha_vms_shlib_el
*shlib
;
8550 /* We do not want to include any of the sections in a dynamic
8551 object in the output file. See comment in elflink.c. */
8552 bfd_section_list_clear (abfd
);
8554 shlib
= VEC_APPEND (alpha_vms_link_hash (info
)->shrlibs
,
8555 struct alpha_vms_shlib_el
);
8559 VEC_INIT (shlib
->ca
);
8560 VEC_INIT (shlib
->lp
);
8561 VEC_INIT (shlib
->qr
);
8562 PRIV (shr_index
) = VEC_COUNT (alpha_vms_link_hash (info
)->shrlibs
) - 1;
8569 alpha_vms_link_add_archive_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8572 struct bfd_link_hash_entry
**pundef
;
8573 struct bfd_link_hash_entry
**next_pundef
;
8575 /* We only accept VMS libraries. */
8576 if (info
->output_bfd
->xvec
!= abfd
->xvec
)
8578 bfd_set_error (bfd_error_wrong_format
);
8582 /* The archive_pass field in the archive itself is used to
8583 initialize PASS, since we may search the same archive multiple
8585 pass
= ++abfd
->archive_pass
;
8587 /* Look through the list of undefined symbols. */
8588 for (pundef
= &info
->hash
->undefs
; *pundef
!= NULL
; pundef
= next_pundef
)
8590 struct bfd_link_hash_entry
*h
;
8596 next_pundef
= &(*pundef
)->u
.undef
.next
;
8598 /* When a symbol is defined, it is not necessarily removed from
8600 if (h
->type
!= bfd_link_hash_undefined
8601 && h
->type
!= bfd_link_hash_common
)
8603 /* Remove this entry from the list, for general cleanliness
8604 and because we are going to look through the list again
8605 if we search any more libraries. We can't remove the
8606 entry if it is the tail, because that would lose any
8607 entries we add to the list later on. */
8608 if (*pundef
!= info
->hash
->undefs_tail
)
8610 *pundef
= *next_pundef
;
8611 next_pundef
= pundef
;
8616 /* Look for this symbol in the archive hash table. */
8617 symidx
= _bfd_vms_lib_find_symbol (abfd
, h
->root
.string
);
8618 if (symidx
== BFD_NO_MORE_SYMBOLS
)
8620 /* Nothing in this slot. */
8624 element
= bfd_get_elt_at_index (abfd
, symidx
);
8625 if (element
== NULL
)
8628 if (element
->archive_pass
== -1 || element
->archive_pass
== pass
)
8630 /* Next symbol if this archive is wrong or already handled. */
8634 if (! bfd_check_format (element
, bfd_object
))
8636 element
->archive_pass
= -1;
8640 orig_element
= element
;
8641 if (bfd_is_thin_archive (abfd
))
8643 element
= _bfd_vms_lib_get_imagelib_file (element
);
8644 if (element
== NULL
|| !bfd_check_format (element
, bfd_object
))
8646 orig_element
->archive_pass
= -1;
8651 /* Unlike the generic linker, we know that this element provides
8652 a definition for an undefined symbol and we know that we want
8653 to include it. We don't need to check anything. */
8654 if (!(*info
->callbacks
8655 ->add_archive_element
) (info
, element
, h
->root
.string
, &element
))
8657 if (!alpha_vms_link_add_object_symbols (element
, info
))
8660 orig_element
->archive_pass
= pass
;
8667 alpha_vms_bfd_link_add_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8669 switch (bfd_get_format (abfd
))
8672 vms_debug2 ((2, "vms_link_add_symbols for object %s\n",
8674 return alpha_vms_link_add_object_symbols (abfd
, info
);
8677 vms_debug2 ((2, "vms_link_add_symbols for archive %s\n",
8679 return alpha_vms_link_add_archive_symbols (abfd
, info
);
8682 bfd_set_error (bfd_error_wrong_format
);
8688 alpha_vms_build_fixups (struct bfd_link_info
*info
)
8690 struct alpha_vms_link_hash_table
*t
= alpha_vms_link_hash (info
);
8691 unsigned char *content
;
8693 unsigned int sz
= 0;
8694 unsigned int lp_sz
= 0;
8695 unsigned int ca_sz
= 0;
8696 unsigned int qr_sz
= 0;
8697 unsigned int shrimg_cnt
= 0;
8698 unsigned int chgprt_num
= 0;
8699 unsigned int chgprt_sz
= 0;
8700 struct vms_eiaf
*eiaf
;
8704 /* Shared libraries. */
8705 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8707 struct alpha_vms_shlib_el
*shlib
;
8709 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8711 if (!shlib
->has_fixups
)
8716 if (VEC_COUNT (shlib
->ca
) > 0)
8718 /* Header + entries. */
8720 ca_sz
+= VEC_COUNT (shlib
->ca
) * 4;
8722 if (VEC_COUNT (shlib
->lp
) > 0)
8724 /* Header + entries. */
8726 lp_sz
+= VEC_COUNT (shlib
->lp
) * 4;
8728 if (VEC_COUNT (shlib
->qr
) > 0)
8730 /* Header + entries. */
8732 qr_sz
+= VEC_COUNT (shlib
->qr
) * 8;
8743 /* Finish now if there is no content. */
8744 if (ca_sz
+ lp_sz
+ qr_sz
== 0)
8747 /* Add an eicp entry for the fixup itself. */
8749 for (sec
= info
->output_bfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
8751 /* This isect could be made RO or EXE after relocations are applied. */
8752 if ((sec
->flags
& SEC_RELOC
) != 0
8753 && (sec
->flags
& (SEC_CODE
| SEC_READONLY
)) != 0)
8756 chgprt_sz
= 4 + chgprt_num
* sizeof (struct vms_eicp
);
8758 /* Allocate section content (round-up size) */
8759 sz
= sizeof (struct vms_eiaf
) + shrimg_cnt
* sizeof (struct vms_shl
)
8760 + ca_sz
+ lp_sz
+ qr_sz
+ chgprt_sz
;
8761 sz
= (sz
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
8762 content
= bfd_zalloc (info
->output_bfd
, sz
);
8763 if (content
== NULL
)
8766 sec
= alpha_vms_link_hash (info
)->fixup
;
8767 sec
->contents
= content
;
8770 eiaf
= (struct vms_eiaf
*)content
;
8771 off
= sizeof (struct vms_eiaf
);
8772 bfd_putl32 (0, eiaf
->majorid
);
8773 bfd_putl32 (0, eiaf
->minorid
);
8774 bfd_putl32 (0, eiaf
->iaflink
);
8775 bfd_putl32 (0, eiaf
->fixuplnk
);
8776 bfd_putl32 (sizeof (struct vms_eiaf
), eiaf
->size
);
8777 bfd_putl32 (0, eiaf
->flags
);
8778 bfd_putl32 (0, eiaf
->qrelfixoff
);
8779 bfd_putl32 (0, eiaf
->lrelfixoff
);
8780 bfd_putl32 (0, eiaf
->qdotadroff
);
8781 bfd_putl32 (0, eiaf
->ldotadroff
);
8782 bfd_putl32 (0, eiaf
->codeadroff
);
8783 bfd_putl32 (0, eiaf
->lpfixoff
);
8784 bfd_putl32 (0, eiaf
->chgprtoff
);
8785 bfd_putl32 (shrimg_cnt
? off
: 0, eiaf
->shlstoff
);
8786 bfd_putl32 (shrimg_cnt
, eiaf
->shrimgcnt
);
8787 bfd_putl32 (0, eiaf
->shlextra
);
8788 bfd_putl32 (0, eiaf
->permctx
);
8789 bfd_putl32 (0, eiaf
->base_va
);
8790 bfd_putl32 (0, eiaf
->lppsbfixoff
);
8797 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8799 struct alpha_vms_shlib_el
*shlib
;
8800 struct vms_shl
*shl
;
8802 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8804 if (!shlib
->has_fixups
)
8807 /* Renumber shared images. */
8808 PRIV2 (shlib
->abfd
, shr_index
) = shrimg_cnt
++;
8810 shl
= (struct vms_shl
*)(content
+ off
);
8811 bfd_putl32 (0, shl
->baseva
);
8812 bfd_putl32 (0, shl
->shlptr
);
8813 bfd_putl32 (0, shl
->ident
);
8814 bfd_putl32 (0, shl
->permctx
);
8815 shl
->size
= sizeof (struct vms_shl
);
8816 bfd_putl16 (0, shl
->fill_1
);
8818 bfd_putl32 (0, shl
->icb
);
8819 shl
->imgnam
[0] = strlen (PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
));
8820 memcpy (shl
->imgnam
+ 1, PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
),
8823 off
+= sizeof (struct vms_shl
);
8829 bfd_putl32 (off
, eiaf
->codeadroff
);
8831 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8833 struct alpha_vms_shlib_el
*shlib
;
8836 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8838 if (VEC_COUNT (shlib
->ca
) == 0)
8841 bfd_putl32 (VEC_COUNT (shlib
->ca
), content
+ off
);
8842 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8845 for (j
= 0; j
< VEC_COUNT (shlib
->ca
); j
++)
8847 bfd_putl32 (VEC_EL (shlib
->ca
, bfd_vma
, j
) - t
->base_addr
,
8853 bfd_putl32 (0, content
+ off
);
8854 bfd_putl32 (0, content
+ off
+ 4);
8861 bfd_putl32 (off
, eiaf
->lpfixoff
);
8863 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8865 struct alpha_vms_shlib_el
*shlib
;
8868 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8870 if (VEC_COUNT (shlib
->lp
) == 0)
8873 bfd_putl32 (VEC_COUNT (shlib
->lp
), content
+ off
);
8874 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8877 for (j
= 0; j
< VEC_COUNT (shlib
->lp
); j
++)
8879 bfd_putl32 (VEC_EL (shlib
->lp
, bfd_vma
, j
) - t
->base_addr
,
8885 bfd_putl32 (0, content
+ off
);
8886 bfd_putl32 (0, content
+ off
+ 4);
8893 bfd_putl32 (off
, eiaf
->qdotadroff
);
8895 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8897 struct alpha_vms_shlib_el
*shlib
;
8900 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8902 if (VEC_COUNT (shlib
->qr
) == 0)
8905 bfd_putl32 (VEC_COUNT (shlib
->qr
), content
+ off
);
8906 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8909 for (j
= 0; j
< VEC_COUNT (shlib
->qr
); j
++)
8911 struct alpha_vms_vma_ref
*r
;
8912 r
= &VEC_EL (shlib
->qr
, struct alpha_vms_vma_ref
, j
);
8913 bfd_putl32 (r
->vma
- t
->base_addr
, content
+ off
);
8914 bfd_putl32 (r
->ref
, content
+ off
+ 4);
8919 bfd_putl32 (0, content
+ off
);
8920 bfd_putl32 (0, content
+ off
+ 4);
8925 /* Write the change protection table. */
8926 bfd_putl32 (off
, eiaf
->chgprtoff
);
8927 bfd_putl32 (chgprt_num
, content
+ off
);
8930 for (sec
= info
->output_bfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
8932 struct vms_eicp
*eicp
;
8935 if ((sec
->flags
& SEC_LINKER_CREATED
) != 0 &&
8936 strcmp (sec
->name
, "$FIXUP$") == 0)
8938 else if ((sec
->flags
& SEC_RELOC
) != 0
8939 && (sec
->flags
& (SEC_CODE
| SEC_READONLY
)) != 0)
8944 eicp
= (struct vms_eicp
*)(content
+ off
);
8945 bfd_putl64 (sec
->vma
- t
->base_addr
, eicp
->baseva
);
8946 bfd_putl32 ((sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1),
8948 bfd_putl32 (prot
, eicp
->newprt
);
8949 off
+= sizeof (struct vms_eicp
);
8955 /* Called by bfd_hash_traverse to fill the symbol table.
8956 Return FALSE in case of failure. */
8959 alpha_vms_link_output_symbol (struct bfd_hash_entry
*bh
, void *infov
)
8961 struct bfd_link_hash_entry
*hc
= (struct bfd_link_hash_entry
*) bh
;
8962 struct bfd_link_info
*info
= (struct bfd_link_info
*)infov
;
8963 struct alpha_vms_link_hash_entry
*h
;
8964 struct vms_symbol_entry
*sym
;
8966 if (hc
->type
== bfd_link_hash_warning
)
8969 if (hc
->type
== bfd_link_hash_new
)
8972 h
= (struct alpha_vms_link_hash_entry
*) hc
;
8974 switch (h
->root
.type
)
8976 case bfd_link_hash_undefined
:
8978 case bfd_link_hash_new
:
8979 case bfd_link_hash_warning
:
8981 case bfd_link_hash_undefweak
:
8983 case bfd_link_hash_defined
:
8984 case bfd_link_hash_defweak
:
8986 asection
*sec
= h
->root
.u
.def
.section
;
8988 /* FIXME: this is certainly a symbol from a dynamic library. */
8989 if (bfd_is_abs_section (sec
))
8992 if (sec
->owner
->flags
& DYNAMIC
)
8996 case bfd_link_hash_common
:
8998 case bfd_link_hash_indirect
:
9002 /* Do not write not kept symbols. */
9003 if (info
->strip
== strip_some
9004 && bfd_hash_lookup (info
->keep_hash
, h
->root
.root
.string
,
9005 FALSE
, FALSE
) != NULL
)
9010 /* This symbol doesn't come from a VMS object. So we suppose it is
9012 int len
= strlen (h
->root
.root
.string
);
9014 sym
= (struct vms_symbol_entry
*)bfd_zalloc (info
->output_bfd
,
9015 sizeof (*sym
) + len
);
9019 memcpy (sym
->name
, h
->root
.root
.string
, len
);
9021 sym
->owner
= info
->output_bfd
;
9023 sym
->typ
= EGSD__C_SYMG
;
9025 sym
->flags
= EGSY__V_DEF
| EGSY__V_REL
;
9026 sym
->symbol_vector
= h
->root
.u
.def
.value
;
9027 sym
->section
= h
->root
.u
.def
.section
;
9028 sym
->value
= h
->root
.u
.def
.value
;
9033 if (!add_symbol_entry (info
->output_bfd
, sym
))
9040 alpha_vms_bfd_final_link (bfd
*abfd
, struct bfd_link_info
*info
)
9043 struct bfd_link_order
*p
;
9051 if (bfd_link_relocatable (info
))
9053 /* FIXME: we do not yet support relocatable link. It is not obvious
9054 how to do it for debug infos. */
9055 (*info
->callbacks
->einfo
)(_("%P: relocatable link is not supported\n"));
9059 abfd
->outsymbols
= NULL
;
9062 /* Mark all sections which will be included in the output file. */
9063 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9064 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
9065 if (p
->type
== bfd_indirect_link_order
)
9066 p
->u
.indirect
.section
->linker_mark
= TRUE
;
9069 /* Handle all the link order information for the sections. */
9070 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9072 printf ("For section %s (at 0x%08x, flags=0x%08x):\n",
9073 o
->name
, (unsigned)o
->vma
, (unsigned)o
->flags
);
9075 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
9077 printf (" at 0x%08x - 0x%08x: ",
9078 (unsigned)p
->offset
, (unsigned)(p
->offset
+ p
->size
- 1));
9081 case bfd_section_reloc_link_order
:
9082 case bfd_symbol_reloc_link_order
:
9083 printf (" section/symbol reloc\n");
9085 case bfd_indirect_link_order
:
9086 printf (" section %s of %s\n",
9087 p
->u
.indirect
.section
->name
,
9088 p
->u
.indirect
.section
->owner
->filename
);
9090 case bfd_data_link_order
:
9091 printf (" explicit data\n");
9094 printf (" *unknown* type %u\n", p
->type
);
9101 /* Generate the symbol table. */
9102 BFD_ASSERT (PRIV (syms
) == NULL
);
9103 if (info
->strip
!= strip_all
)
9104 bfd_hash_traverse (&info
->hash
->table
, alpha_vms_link_output_symbol
, info
);
9106 /* Find the entry point. */
9107 if (bfd_get_start_address (abfd
) == 0)
9109 bfd
*startbfd
= NULL
;
9111 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9113 /* Consider only VMS object files. */
9114 if (sub
->xvec
!= abfd
->xvec
)
9117 if (!PRIV2 (sub
, eom_data
).eom_has_transfer
)
9119 if ((PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
) && startbfd
)
9121 if (startbfd
!= NULL
9122 && !(PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
))
9124 (*info
->callbacks
->einfo
)
9125 /* xgettext:c-format */
9126 (_("%P: multiple entry points: in modules %pB and %pB\n"),
9135 unsigned int ps_idx
= PRIV2 (startbfd
, eom_data
).eom_l_psindx
;
9136 bfd_vma tfradr
= PRIV2 (startbfd
, eom_data
).eom_l_tfradr
;
9139 sec
= PRIV2 (startbfd
, sections
)[ps_idx
];
9141 bfd_set_start_address
9142 (abfd
, sec
->output_section
->vma
+ sec
->output_offset
+ tfradr
);
9146 /* Set transfer addresses. */
9149 struct bfd_link_hash_entry
*h
;
9152 PRIV (transfer_address
[i
++]) = 0xffffffff00000340ULL
; /* SYS$IMGACT */
9153 h
= bfd_link_hash_lookup (info
->hash
, "LIB$INITIALIZE", FALSE
, FALSE
, TRUE
);
9154 if (h
!= NULL
&& h
->type
== bfd_link_hash_defined
)
9155 PRIV (transfer_address
[i
++]) =
9156 alpha_vms_get_sym_value (h
->u
.def
.section
, h
->u
.def
.value
);
9157 PRIV (transfer_address
[i
++]) = bfd_get_start_address (abfd
);
9159 PRIV (transfer_address
[i
++]) = 0;
9162 /* Allocate contents.
9163 Also compute the virtual base address. */
9164 base_addr
= (bfd_vma
)-1;
9166 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9168 if (o
->flags
& SEC_HAS_CONTENTS
)
9170 o
->contents
= bfd_alloc (abfd
, o
->size
);
9171 if (o
->contents
== NULL
)
9174 if (o
->flags
& SEC_LOAD
)
9176 if (o
->vma
< base_addr
)
9178 if (o
->vma
+ o
->size
> last_addr
)
9179 last_addr
= o
->vma
+ o
->size
;
9181 /* Clear the RELOC flags. Currently we don't support incremental
9182 linking. We use the RELOC flag for computing the eicp entries. */
9183 o
->flags
&= ~SEC_RELOC
;
9186 /* Create the fixup section. */
9187 fixupsec
= bfd_make_section_anyway_with_flags
9188 (info
->output_bfd
, "$FIXUP$",
9189 SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
9190 if (fixupsec
== NULL
)
9192 last_addr
= (last_addr
+ 0xffff) & ~0xffff;
9193 fixupsec
->vma
= last_addr
;
9195 alpha_vms_link_hash (info
)->fixup
= fixupsec
;
9196 alpha_vms_link_hash (info
)->base_addr
= base_addr
;
9198 /* Create the DMT section, if necessary. */
9199 BFD_ASSERT (PRIV (dst_section
) == NULL
);
9200 dst
= bfd_get_section_by_name (abfd
, "$DST$");
9201 if (dst
!= NULL
&& dst
->size
== 0)
9205 PRIV (dst_section
) = dst
;
9206 dmt
= bfd_make_section_anyway_with_flags
9207 (info
->output_bfd
, "$DMT$",
9208 SEC_DEBUGGING
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
9215 /* Read all sections from the inputs. */
9216 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9218 if (sub
->flags
& DYNAMIC
)
9220 alpha_vms_create_eisd_for_shared (abfd
, sub
);
9224 if (!alpha_vms_read_sections_content (sub
, info
))
9228 /* Handle all the link order information for the sections.
9229 Note: past this point, it is not possible to create new sections. */
9230 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9232 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
9236 case bfd_section_reloc_link_order
:
9237 case bfd_symbol_reloc_link_order
:
9240 case bfd_indirect_link_order
:
9244 if (! _bfd_default_link_order (abfd
, info
, o
, p
))
9251 /* Compute fixups. */
9252 if (!alpha_vms_build_fixups (info
))
9255 /* Compute the DMT. */
9259 unsigned char *contents
= NULL
;
9261 /* In pass 1, compute the size. In pass 2, write the DMT contents. */
9262 for (pass
= 0; pass
< 2; pass
++)
9264 unsigned int off
= 0;
9266 /* For each object file (ie for each module). */
9267 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9270 struct vms_dmt_header
*dmth
= NULL
;
9271 unsigned int psect_count
;
9273 /* Skip this module if it has no DST. */
9274 sub_dst
= PRIV2 (sub
, dst_section
);
9275 if (sub_dst
== NULL
|| sub_dst
->size
== 0)
9280 /* Write the header. */
9281 dmth
= (struct vms_dmt_header
*)(contents
+ off
);
9282 bfd_putl32 (sub_dst
->output_offset
, dmth
->modbeg
);
9283 bfd_putl32 (sub_dst
->size
, dmth
->size
);
9286 off
+= sizeof (struct vms_dmt_header
);
9289 /* For each section (ie for each psect). */
9290 for (o
= sub
->sections
; o
!= NULL
; o
= o
->next
)
9292 /* Only consider interesting sections. */
9293 if (!(o
->flags
& SEC_ALLOC
))
9295 if (o
->flags
& SEC_LINKER_CREATED
)
9300 /* Write an entry. */
9301 struct vms_dmt_psect
*dmtp
;
9303 dmtp
= (struct vms_dmt_psect
*)(contents
+ off
);
9304 bfd_putl32 (o
->output_offset
+ o
->output_section
->vma
,
9306 bfd_putl32 (o
->size
, dmtp
->length
);
9309 off
+= sizeof (struct vms_dmt_psect
);
9312 bfd_putl32 (psect_count
, dmth
->psect_count
);
9317 contents
= bfd_zalloc (info
->output_bfd
, off
);
9318 if (contents
== NULL
)
9320 dmt
->contents
= contents
;
9325 BFD_ASSERT (off
== dmt
->size
);
9333 /* Read the contents of a section.
9334 buf points to a buffer of buf_size bytes to be filled with
9335 section data (starting at offset into section) */
9338 alpha_vms_get_section_contents (bfd
*abfd
, asection
*section
,
9339 void *buf
, file_ptr offset
,
9340 bfd_size_type count
)
9344 /* Image are easy. */
9345 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
9346 return _bfd_generic_get_section_contents (abfd
, section
,
9347 buf
, offset
, count
);
9350 if (offset
+ count
< count
9351 || offset
+ count
> section
->size
)
9353 bfd_set_error (bfd_error_invalid_operation
);
9357 /* If the section is already in memory, just copy it. */
9358 if (section
->flags
& SEC_IN_MEMORY
)
9360 BFD_ASSERT (section
->contents
!= NULL
);
9361 memcpy (buf
, section
->contents
+ offset
, count
);
9364 if (section
->size
== 0)
9367 /* Alloc in memory and read ETIRs. */
9368 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
9370 BFD_ASSERT (sec
->contents
== NULL
);
9372 if (sec
->size
!= 0 && (sec
->flags
& SEC_HAS_CONTENTS
))
9374 sec
->contents
= bfd_alloc (abfd
, sec
->size
);
9375 if (sec
->contents
== NULL
)
9379 if (!alpha_vms_read_sections_content (abfd
, NULL
))
9381 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
9383 sec
->flags
|= SEC_IN_MEMORY
;
9384 memcpy (buf
, section
->contents
+ offset
, count
);
9389 /* Set the format of a file being written. */
9392 alpha_vms_mkobject (bfd
* abfd
)
9394 const bfd_arch_info_type
*arch
;
9396 vms_debug2 ((1, "alpha_vms_mkobject (%p)\n", abfd
));
9398 if (!vms_initialize (abfd
))
9401 PRIV (recwr
.buf
) = bfd_alloc (abfd
, MAX_OUTREC_SIZE
);
9402 if (PRIV (recwr
.buf
) == NULL
)
9405 arch
= bfd_scan_arch ("alpha");
9409 bfd_set_error (bfd_error_wrong_format
);
9413 abfd
->arch_info
= arch
;
9420 /* Called when the BFD is being closed to do any necessary cleanup. */
9423 vms_close_and_cleanup (bfd
* abfd
)
9425 vms_debug2 ((1, "vms_close_and_cleanup (%p)\n", abfd
));
9427 if (abfd
== NULL
|| abfd
->tdata
.any
== NULL
)
9430 if (abfd
->format
== bfd_object
)
9432 alpha_vms_free_private (abfd
);
9435 if (abfd
->direction
== write_direction
)
9437 /* Last step on VMS is to convert the file to variable record length
9439 if (!bfd_cache_close (abfd
))
9441 if (!_bfd_vms_convert_to_var_unix_filename (abfd
->filename
))
9447 return _bfd_generic_close_and_cleanup (abfd
);
9450 /* Called when a new section is created. */
9453 vms_new_section_hook (bfd
* abfd
, asection
*section
)
9457 vms_debug2 ((1, "vms_new_section_hook (%p, [%u]%s)\n",
9458 abfd
, section
->index
, section
->name
));
9460 if (!bfd_set_section_alignment (section
, 0))
9463 vms_debug2 ((7, "%u: %s\n", section
->index
, section
->name
));
9465 amt
= sizeof (struct vms_section_data_struct
);
9466 section
->used_by_bfd
= bfd_zalloc (abfd
, amt
);
9467 if (section
->used_by_bfd
== NULL
)
9470 /* Create the section symbol. */
9471 return _bfd_generic_new_section_hook (abfd
, section
);
9474 /* Part 4.5, symbols. */
9476 /* Print symbol to file according to how. how is one of
9477 bfd_print_symbol_name just print the name
9478 bfd_print_symbol_more print more (???)
9479 bfd_print_symbol_all print all we know, which is not much right now :-). */
9482 vms_print_symbol (bfd
* abfd
,
9485 bfd_print_symbol_type how
)
9487 vms_debug2 ((1, "vms_print_symbol (%p, %p, %p, %d)\n",
9488 abfd
, file
, symbol
, how
));
9492 case bfd_print_symbol_name
:
9493 case bfd_print_symbol_more
:
9494 fprintf ((FILE *)file
," %s", symbol
->name
);
9497 case bfd_print_symbol_all
:
9499 const char *section_name
= symbol
->section
->name
;
9501 bfd_print_symbol_vandf (abfd
, file
, symbol
);
9503 fprintf ((FILE *) file
," %-8s %s", section_name
, symbol
->name
);
9509 /* Return information about symbol in ret.
9511 fill type, value and name
9514 B bss segment symbol
9516 D data segment symbol
9518 t a static function symbol
9519 T text segment symbol
9524 vms_get_symbol_info (bfd
* abfd ATTRIBUTE_UNUSED
,
9530 vms_debug2 ((1, "vms_get_symbol_info (%p, %p, %p)\n", abfd
, symbol
, ret
));
9532 sec
= symbol
->section
;
9539 else if (bfd_is_com_section (sec
))
9541 else if (bfd_is_abs_section (sec
))
9543 else if (bfd_is_und_section (sec
))
9545 else if (bfd_is_ind_section (sec
))
9547 else if ((symbol
->flags
& BSF_FUNCTION
)
9548 || (bfd_section_flags (sec
) & SEC_CODE
))
9550 else if (bfd_section_flags (sec
) & SEC_DATA
)
9552 else if (bfd_section_flags (sec
) & SEC_ALLOC
)
9557 if (ret
->type
!= 'U')
9558 ret
->value
= symbol
->value
+ symbol
->section
->vma
;
9561 ret
->name
= symbol
->name
;
9564 /* Return TRUE if the given symbol sym in the BFD abfd is
9565 a compiler generated local label, else return FALSE. */
9568 vms_bfd_is_local_label_name (bfd
* abfd ATTRIBUTE_UNUSED
,
9571 return name
[0] == '$';
9574 /* Part 4.7, writing an object file. */
9576 /* Sets the contents of the section section in BFD abfd to the data starting
9577 in memory at LOCATION. The data is written to the output section starting
9578 at offset offset for count bytes.
9580 Normally TRUE is returned, else FALSE. Possible error returns are:
9581 o bfd_error_no_contents - The output section does not have the
9582 SEC_HAS_CONTENTS attribute, so nothing can be written to it.
9583 o and some more too */
9586 _bfd_vms_set_section_contents (bfd
* abfd
,
9588 const void * location
,
9590 bfd_size_type count
)
9592 if (section
->contents
== NULL
)
9594 section
->contents
= bfd_alloc (abfd
, section
->size
);
9595 if (section
->contents
== NULL
)
9598 memcpy (section
->contents
+ offset
, location
, (size_t) count
);
9604 /* Set the architecture and machine type in BFD abfd to arch and mach.
9605 Find the correct pointer to a structure and insert it into the arch_info
9609 alpha_vms_set_arch_mach (bfd
*abfd
,
9610 enum bfd_architecture arch
, unsigned long mach
)
9612 if (arch
!= bfd_arch_alpha
9613 && arch
!= bfd_arch_unknown
)
9616 return bfd_default_set_arch_mach (abfd
, arch
, mach
);
9619 /* Set section VMS flags. Clear NO_FLAGS and set FLAGS. */
9622 bfd_vms_set_section_flags (bfd
*abfd ATTRIBUTE_UNUSED
,
9623 asection
*sec
, flagword no_flags
, flagword flags
)
9625 vms_section_data (sec
)->no_flags
= no_flags
;
9626 vms_section_data (sec
)->flags
= flags
;
9629 struct vms_private_data_struct
*
9630 bfd_vms_get_data (bfd
*abfd
)
9632 return (struct vms_private_data_struct
*)abfd
->tdata
.any
;
9635 #define vms_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false
9636 #define vms_bfd_link_just_syms _bfd_generic_link_just_syms
9637 #define vms_bfd_copy_link_hash_symbol_type \
9638 _bfd_generic_copy_link_hash_symbol_type
9639 #define vms_bfd_is_group_section bfd_generic_is_group_section
9640 #define vms_bfd_group_name bfd_generic_group_name
9641 #define vms_bfd_discard_group bfd_generic_discard_group
9642 #define vms_section_already_linked _bfd_generic_section_already_linked
9643 #define vms_bfd_define_common_symbol bfd_generic_define_common_symbol
9644 #define vms_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
9645 #define vms_bfd_define_start_stop bfd_generic_define_start_stop
9646 #define vms_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
9648 #define vms_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
9649 #define vms_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
9650 #define vms_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data
9651 #define vms_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
9652 #define vms_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
9653 #define vms_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
9655 /* Symbols table. */
9656 #define alpha_vms_make_empty_symbol _bfd_generic_make_empty_symbol
9657 #define alpha_vms_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false
9658 #define alpha_vms_print_symbol vms_print_symbol
9659 #define alpha_vms_get_symbol_info vms_get_symbol_info
9660 #define alpha_vms_get_symbol_version_string \
9661 _bfd_nosymbols_get_symbol_version_string
9663 #define alpha_vms_read_minisymbols _bfd_generic_read_minisymbols
9664 #define alpha_vms_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
9665 #define alpha_vms_get_lineno _bfd_nosymbols_get_lineno
9666 #define alpha_vms_find_inliner_info _bfd_nosymbols_find_inliner_info
9667 #define alpha_vms_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
9668 #define alpha_vms_find_nearest_line _bfd_vms_find_nearest_line
9669 #define alpha_vms_find_line _bfd_nosymbols_find_line
9670 #define alpha_vms_bfd_is_local_label_name vms_bfd_is_local_label_name
9672 /* Generic table. */
9673 #define alpha_vms_close_and_cleanup vms_close_and_cleanup
9674 #define alpha_vms_bfd_free_cached_info vms_bfd_free_cached_info
9675 #define alpha_vms_new_section_hook vms_new_section_hook
9676 #define alpha_vms_set_section_contents _bfd_vms_set_section_contents
9677 #define alpha_vms_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
9679 #define alpha_vms_bfd_get_relocated_section_contents \
9680 bfd_generic_get_relocated_section_contents
9682 #define alpha_vms_bfd_relax_section bfd_generic_relax_section
9683 #define alpha_vms_bfd_gc_sections bfd_generic_gc_sections
9684 #define alpha_vms_bfd_lookup_section_flags bfd_generic_lookup_section_flags
9685 #define alpha_vms_bfd_merge_sections bfd_generic_merge_sections
9686 #define alpha_vms_bfd_is_group_section bfd_generic_is_group_section
9687 #define alpha_vms_bfd_group_name bfd_generic_group_name
9688 #define alpha_vms_bfd_discard_group bfd_generic_discard_group
9689 #define alpha_vms_section_already_linked \
9690 _bfd_generic_section_already_linked
9692 #define alpha_vms_bfd_define_common_symbol bfd_generic_define_common_symbol
9693 #define alpha_vms_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
9694 #define alpha_vms_bfd_define_start_stop bfd_generic_define_start_stop
9695 #define alpha_vms_bfd_link_just_syms _bfd_generic_link_just_syms
9696 #define alpha_vms_bfd_copy_link_hash_symbol_type \
9697 _bfd_generic_copy_link_hash_symbol_type
9699 #define alpha_vms_bfd_link_split_section _bfd_generic_link_split_section
9701 #define alpha_vms_get_dynamic_symtab_upper_bound \
9702 _bfd_nodynamic_get_dynamic_symtab_upper_bound
9703 #define alpha_vms_canonicalize_dynamic_symtab \
9704 _bfd_nodynamic_canonicalize_dynamic_symtab
9705 #define alpha_vms_get_dynamic_reloc_upper_bound \
9706 _bfd_nodynamic_get_dynamic_reloc_upper_bound
9707 #define alpha_vms_canonicalize_dynamic_reloc \
9708 _bfd_nodynamic_canonicalize_dynamic_reloc
9709 #define alpha_vms_bfd_link_check_relocs _bfd_generic_link_check_relocs
9711 const bfd_target alpha_vms_vec
=
9713 "vms-alpha", /* Name. */
9714 bfd_target_evax_flavour
,
9715 BFD_ENDIAN_LITTLE
, /* Data byte order is little. */
9716 BFD_ENDIAN_LITTLE
, /* Header byte order is little. */
9718 (HAS_RELOC
| EXEC_P
| HAS_LINENO
| HAS_DEBUG
| HAS_SYMS
| HAS_LOCALS
9719 | WP_TEXT
| D_PAGED
), /* Object flags. */
9720 (SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
9721 | SEC_READONLY
| SEC_CODE
| SEC_DATA
9722 | SEC_HAS_CONTENTS
| SEC_IN_MEMORY
), /* Sect flags. */
9723 0, /* symbol_leading_char. */
9724 ' ', /* ar_pad_char. */
9725 15, /* ar_max_namelen. */
9726 0, /* match priority. */
9727 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
9728 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
9729 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
9730 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
9731 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
9732 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
9734 { /* bfd_check_format. */
9737 _bfd_vms_lib_alpha_archive_p
,
9740 { /* bfd_set_format. */
9741 _bfd_bool_bfd_false_error
,
9743 _bfd_vms_lib_alpha_mkarchive
,
9744 _bfd_bool_bfd_false_error
9746 { /* bfd_write_contents. */
9747 _bfd_bool_bfd_false_error
,
9748 alpha_vms_write_object_contents
,
9749 _bfd_vms_lib_write_archive_contents
,
9750 _bfd_bool_bfd_false_error
9753 BFD_JUMP_TABLE_GENERIC (alpha_vms
),
9754 BFD_JUMP_TABLE_COPY (vms
),
9755 BFD_JUMP_TABLE_CORE (_bfd_nocore
),
9756 BFD_JUMP_TABLE_ARCHIVE (_bfd_vms_lib
),
9757 BFD_JUMP_TABLE_SYMBOLS (alpha_vms
),
9758 BFD_JUMP_TABLE_RELOCS (alpha_vms
),
9759 BFD_JUMP_TABLE_WRITE (alpha_vms
),
9760 BFD_JUMP_TABLE_LINK (alpha_vms
),
9761 BFD_JUMP_TABLE_DYNAMIC (alpha_vms
),